调整结算打印
parent
57b1eff310
commit
6fb1bf253f
|
|
@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Mon Aug 17 10:47:18 CST 2020
|
* Generated by COWR Fri Aug 28 00:25:03 CST 2020
|
||||||
* TableName: invoice_receive
|
* TableName: invoice_receive
|
||||||
* Remarks: 发票管理 - 领用记录
|
* Remarks: 发票管理 - 领用记录
|
||||||
* PrimaryKey: id
|
* PrimaryKey: id
|
||||||
|
|
@ -22,46 +22,24 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name: id
|
* name: id
|
||||||
* type: CHAR(32)
|
* type: INT(10)
|
||||||
* isNullable: NO
|
* isNullable: NO
|
||||||
* isPrimaryKey: YES
|
* isPrimaryKey: YES
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param id uuid
|
* @param id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="id")
|
@JSONField(name="id")
|
||||||
public void setId(String id) {
|
public void setId(Integer id) {
|
||||||
set("id", id);
|
set("id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return id uuid
|
* @return id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="id")
|
@JSONField(name="id")
|
||||||
public String getId() {
|
public Integer getId() {
|
||||||
return getStr("id");
|
return getInt("id");
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* name: num
|
|
||||||
* type: INT(10)
|
|
||||||
* isNullable: NO
|
|
||||||
* isPrimaryKey: NO
|
|
||||||
* defaultValue:
|
|
||||||
* @param num 领取数量
|
|
||||||
*/
|
|
||||||
@JSONField(name="num")
|
|
||||||
public void setNum(Integer num) {
|
|
||||||
set("num", num);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return num 领取数量
|
|
||||||
*/
|
|
||||||
@JSONField(name="num")
|
|
||||||
public Integer getNum() {
|
|
||||||
return getInt("num");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -108,6 +86,28 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
return getStr("start_code");
|
return getStr("start_code");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: end_code
|
||||||
|
* type: VARCHAR(20)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param endCode 发票截止号码
|
||||||
|
*/
|
||||||
|
@JSONField(name="end_code")
|
||||||
|
public void setEndCode(String endCode) {
|
||||||
|
set("end_code", endCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return end_code 发票截止号码
|
||||||
|
*/
|
||||||
|
@JSONField(name="end_code")
|
||||||
|
public String getEndCode() {
|
||||||
|
return getStr("end_code");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name: current_code
|
* name: current_code
|
||||||
* type: VARCHAR(20)
|
* type: VARCHAR(20)
|
||||||
|
|
@ -224,7 +224,7 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
* isNullable: NO
|
* isNullable: NO
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param supermarketId 领取砂站id
|
* @param supermarketId 领取超市id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -233,7 +233,7 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 领取砂站id
|
* @return supermarket_id 领取超市id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,18 @@ import java.util.List;
|
||||||
public class InvoiceReceiveService extends BaseService {
|
public class InvoiceReceiveService extends BaseService {
|
||||||
public static final InvoiceReceiveService me = new InvoiceReceiveService();
|
public static final InvoiceReceiveService me = new InvoiceReceiveService();
|
||||||
|
|
||||||
|
public InvoiceReceive foremostReceive(int supermarket_id) {
|
||||||
|
String sql = "select * from invoice_receive t\n" +
|
||||||
|
" where t.supermarket_id = ? \n" +
|
||||||
|
" and t.surplus > 0\n" +
|
||||||
|
" order by t.start_code asc\n" +
|
||||||
|
" limit 1";
|
||||||
|
|
||||||
|
InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id);
|
||||||
|
|
||||||
|
return receive;
|
||||||
|
}
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp) {
|
public Page<Record> find(PageParam pp) {
|
||||||
String selectsql = "select * ";
|
String selectsql = "select * ";
|
||||||
String fromsql = "from invoice_receive t where 1=1 ";
|
String fromsql = "from invoice_receive t where 1=1 ";
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,17 @@ public class InvoiceReceiveValidator extends CrudParamValidator {
|
||||||
validateString("id", 1, 32, "id", "id 长度 1~32");
|
validateString("id", 1, 32, "id", "id 长度 1~32");
|
||||||
}
|
}
|
||||||
|
|
||||||
validateInteger("num", 1, 2147483647, "num", "num 范围 1~2147483647");
|
|
||||||
validateString("start_code", 1, 20, "start_code", "start_code 长度 1~20");
|
validateString("start_code", 1, 20, "start_code", "start_code 长度 1~20");
|
||||||
|
validateString("end_code", 1, 20, "end_code", "end_code 长度 1~20");
|
||||||
validateInteger("receive_user_id", 1, 2147483647, "receive_user_id", "receive_user_id 范围 1~2147483647");
|
validateInteger("receive_user_id", 1, 2147483647, "receive_user_id", "receive_user_id 范围 1~2147483647");
|
||||||
validateInteger("supermarket_id", 1, 2147483647, "supermarket_id", "supermarket_id 范围 1~2147483647");
|
validateInteger("supermarket_id", 1, 2147483647, "supermarket_id", "supermarket_id 范围 1~2147483647");
|
||||||
|
|
||||||
|
if(StrKit.notBlank(c.get("start_code"), c.get("end_code"))){
|
||||||
|
if(c.getInt("end_code") - c.getInt("start_code") < 0){
|
||||||
|
addError("end_code", "end_code 必须大于等于 start_code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 使用 model 更新时,model 不能只有主键有值
|
// 使用 model 更新时,model 不能只有主键有值
|
||||||
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
|
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
|
||||||
// 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段
|
// 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.cowr.ssjygl.prepay;
|
package com.cowr.ssjygl.prepay;
|
||||||
|
|
||||||
|
import com.cowr.common.enums.OrderTypeEnum;
|
||||||
import com.cowr.common.utils.DateTimeUtil;
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
import com.cowr.ssjygl.CacheData;
|
import com.cowr.ssjygl.CacheData;
|
||||||
|
|
@ -18,29 +19,27 @@ import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PrepayService {
|
public class PrepayService {
|
||||||
private static Log log = Log.getLog(PrepayService.class);
|
private static Log log = Log.getLog(PrepayService.class);
|
||||||
public static PrepayService me = new PrepayService();
|
public static PrepayService me = new PrepayService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预付费用户列表
|
* 预付费用户列表
|
||||||
*
|
*
|
||||||
* @param pp 分页参数
|
* @param pp 分页参数
|
||||||
* @param name 客户名称
|
* @param name 客户名称
|
||||||
* @param customer_id 客户id
|
* @param customer_id 客户id
|
||||||
* @param supermarket_id 超时id
|
* @param stm 开始时间
|
||||||
* @param stm 开始时间
|
* @param etm 截止时间
|
||||||
* @param etm 截止时间
|
* @param start 开始金额
|
||||||
* @param start 开始金额
|
* @param end 截止金额
|
||||||
* @param end 截止金额
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Page<Record> find(PageParam pp, String name, Integer customer_id, Integer supermarket_id, String stm, String etm, Double start, Double end) {
|
public Page<Record> find(PageParam pp, String name, Integer customer_id, String stm, String etm, Double start, Double end) {
|
||||||
String selectsql = " select p.*, c.name customer_name, c.address, c.texpayer_name, c.texpayer_num, c.memo, pc.surplus, s.name supermarket_name \n";
|
String selectsql = " select p.*, c.name customer_name, c.address, c.texpayer_name, c.texpayer_num, c.memo, pc.surplus, s.name supermarket_name \n";
|
||||||
String fromsql = " from ( \n" +
|
String fromsql = " from ( \n" +
|
||||||
" select t.customer_id, t.supermarket_id, max(t.create_time) maxtm, max(t.id) maxid from prepay_detail t \n" +
|
" select t.customer_id, t.supermarket_id, max(t.create_time) maxtm, max(t.id) maxid from prepay_detail t \n" +
|
||||||
|
|
@ -49,7 +48,7 @@ public class PrepayService {
|
||||||
" ) a \n" +
|
" ) a \n" +
|
||||||
" left join prepay_detail p on p.id = a.maxid \n" +
|
" left join prepay_detail p on p.id = a.maxid \n" +
|
||||||
" left join customer c on c.id = p.customer_id \n" +
|
" left join customer c on c.id = p.customer_id \n" +
|
||||||
" left join prepay_customer pc on pc.customer_id = p.customer_id and pc.supermarket_id = a.supermarket_id\n" +
|
" left join prepay_customer pc on pc.customer_id = p.customer_id \n" +
|
||||||
" left join supermarket s on s.id = a.supermarket_id\n" +
|
" left join supermarket s on s.id = a.supermarket_id\n" +
|
||||||
" where 1 = 1";
|
" where 1 = 1";
|
||||||
List<Object> paraList = new ArrayList<>();
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
@ -64,11 +63,6 @@ public class PrepayService {
|
||||||
paraList.add(customer_id);
|
paraList.add(customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (supermarket_id != null) {
|
|
||||||
fromsql += " and a.supermarket_id = ? \n";
|
|
||||||
paraList.add(supermarket_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrKit.notBlank(stm)) {
|
if (StrKit.notBlank(stm)) {
|
||||||
fromsql += " and p.create_time >= ?";
|
fromsql += " and p.create_time >= ?";
|
||||||
paraList.add(stm);
|
paraList.add(stm);
|
||||||
|
|
@ -115,20 +109,24 @@ public class PrepayService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepayTruck pt = PrepayTruck.dao.findFirst("select * from prepay_truck t \n" +
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
||||||
" where t.supermarket_id = ? \n" +
|
" where t.truck_license = ? \n" +
|
||||||
" and t.truck_license = ? \n" +
|
|
||||||
" and t.valid_date = ? ",
|
" and t.valid_date = ? ",
|
||||||
transport.getSupermarketId(),
|
|
||||||
transport.getTruckLicense(),
|
transport.getTruckLicense(),
|
||||||
DateTimeUtil.sdf.get().format(transport.getInTime())
|
DateTimeUtil.sdf.get().format(transport.getInTime())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pt == null) {
|
if (ot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Customer customer = Customer.dao.findById(pt.getCustomerId());
|
Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId());
|
||||||
|
|
||||||
|
if (ordercluster == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
|
||||||
|
|
||||||
if (customer == null) {
|
if (customer == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -142,7 +140,7 @@ public class PrepayService {
|
||||||
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
|
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
|
||||||
|
|
||||||
if (prepayCustomer == null) {
|
if (prepayCustomer == null) {
|
||||||
log.debug("未找到预付费信息 %s, %s" + customer.getId() + ", " + transport.getSupermarketId());
|
log.debug("未找到预付费信息 %s, %s" + customer.getId() + ", " + transport.getSupermarketId());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,7 +156,7 @@ public class PrepayService {
|
||||||
|
|
||||||
out.set("prepay_truck", true);
|
out.set("prepay_truck", true);
|
||||||
out.set("prepay_threshold", prepayCustomer.getThreshold());
|
out.set("prepay_threshold", prepayCustomer.getThreshold());
|
||||||
out.set("prepay_truck_type", pt.getType());
|
out.set("prepay_truck_type", OrderTypeEnum.TEMP.getTypeid()); // 浠水固定只有外销
|
||||||
out.set("prepay_customer_id", customer.getId());
|
out.set("prepay_customer_id", customer.getId());
|
||||||
out.set("prepay_customer_name", customer.getName());
|
out.set("prepay_customer_name", customer.getName());
|
||||||
out.set("prepay_contact_name", pd.getContactName());
|
out.set("prepay_contact_name", pd.getContactName());
|
||||||
|
|
@ -166,25 +164,7 @@ public class PrepayService {
|
||||||
out.set("prepay_surplus", prepayCustomer.getSurplus());
|
out.set("prepay_surplus", prepayCustomer.getSurplus());
|
||||||
out.set("prepay_customer", customer);
|
out.set("prepay_customer", customer);
|
||||||
out.set("prepay_customer_info", prepayCustomer);
|
out.set("prepay_customer_info", prepayCustomer);
|
||||||
|
out.set("prepay_ordercluster", ordercluster); // 预付费关联集团客户订单
|
||||||
Truck truck = Truck.dao.findById(transport.getTruckLicense());
|
|
||||||
|
|
||||||
if(truck != null){
|
|
||||||
// 预付费关联集团客户订单
|
|
||||||
List<Record> list = Db.find("select t.*, c.`name` customer_name from ordercluster t\n" +
|
|
||||||
" left join customer c on c.id = t.customer_id\n" +
|
|
||||||
" where t.state < ? \n" +
|
|
||||||
" and t.supermarket_id = ? \n" +
|
|
||||||
" and t.trans_co_id = ? \n" +
|
|
||||||
" and t.customer_id = ? ",
|
|
||||||
OrderStateEnum.RECEIVED.getStateid(),
|
|
||||||
transport.getSupermarketId(),
|
|
||||||
truck.getTransCoId(),
|
|
||||||
pt.getCustomerId()
|
|
||||||
);
|
|
||||||
|
|
||||||
out.set("prepay_ordercluster", list);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Record> list = CustomerReceiverService.me.list(customer.getId(), null, null, transport.getSupermarketId());
|
List<Record> list = CustomerReceiverService.me.list(customer.getId(), null, null, transport.getSupermarketId());
|
||||||
|
|
||||||
|
|
@ -332,7 +312,7 @@ public class PrepayService {
|
||||||
|
|
||||||
// 设置表头
|
// 设置表头
|
||||||
// 表头 start
|
// 表头 start
|
||||||
font = wb.createFont();
|
font = wb.createFont();
|
||||||
cellStyle = wb.createCellStyle();
|
cellStyle = wb.createCellStyle();
|
||||||
font.setFontHeight((short) (10 * 20));
|
font.setFontHeight((short) (10 * 20));
|
||||||
font.setFontName("宋体");
|
font.setFontName("宋体");
|
||||||
|
|
@ -366,7 +346,7 @@ public class PrepayService {
|
||||||
sum_price += DataUtil.getDefaultByRecord(record, "total_price");
|
sum_price += DataUtil.getDefaultByRecord(record, "total_price");
|
||||||
|
|
||||||
row = sheet.createRow(i + 3);
|
row = sheet.createRow(i + 3);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue(record.getStr("sn"));
|
row.createCell(a++).setCellValue(record.getStr("sn"));
|
||||||
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(record.getDate("arrive_time")));
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(record.getDate("arrive_time")));
|
||||||
row.createCell(a++).setCellValue(record.getStr("supermarket_name"));
|
row.createCell(a++).setCellValue(record.getStr("supermarket_name"));
|
||||||
|
|
@ -377,7 +357,7 @@ public class PrepayService {
|
||||||
|
|
||||||
// 合计 start
|
// 合计 start
|
||||||
row = sheet.createRow(datalen + 3);
|
row = sheet.createRow(datalen + 3);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue("合计");
|
row.createCell(a++).setCellValue("合计");
|
||||||
row.createCell(a++).setCellValue("");
|
row.createCell(a++).setCellValue("");
|
||||||
row.createCell(a++).setCellValue("");
|
row.createCell(a++).setCellValue("");
|
||||||
|
|
@ -588,7 +568,7 @@ public class PrepayService {
|
||||||
|
|
||||||
// 设置表头
|
// 设置表头
|
||||||
// 表头 start
|
// 表头 start
|
||||||
font = wb.createFont();
|
font = wb.createFont();
|
||||||
cellStyle = wb.createCellStyle();
|
cellStyle = wb.createCellStyle();
|
||||||
font.setFontHeight((short) (10 * 20));
|
font.setFontHeight((short) (10 * 20));
|
||||||
font.setFontName("宋体");
|
font.setFontName("宋体");
|
||||||
|
|
@ -618,7 +598,7 @@ public class PrepayService {
|
||||||
sum_price += DataUtil.getDefaultByRecord(record, "amount");
|
sum_price += DataUtil.getDefaultByRecord(record, "amount");
|
||||||
|
|
||||||
row = sheet.createRow(i + 3);
|
row = sheet.createRow(i + 3);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(record.getDate("tm")));
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(record.getDate("tm")));
|
||||||
row.createCell(a++).setCellValue(record.getStr("type"));
|
row.createCell(a++).setCellValue(record.getStr("type"));
|
||||||
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "amount"));
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "amount"));
|
||||||
|
|
@ -627,7 +607,7 @@ public class PrepayService {
|
||||||
|
|
||||||
// 合计 start
|
// 合计 start
|
||||||
row = sheet.createRow(datalen + 3);
|
row = sheet.createRow(datalen + 3);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue("合计");
|
row.createCell(a++).setCellValue("合计");
|
||||||
row.createCell(a++).setCellValue("");
|
row.createCell(a++).setCellValue("");
|
||||||
row.createCell(a++).setCellValue(sum_price);
|
row.createCell(a++).setCellValue(sum_price);
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,10 @@
|
||||||
package com.cowr.local.ssjygl.invoice.log;
|
package com.cowr.local.ssjygl.invoice.log;
|
||||||
|
|
||||||
import com.cowr.common.view.Result;
|
|
||||||
import com.cowr.local.ssjygl.base.BaseSyncService;
|
import com.cowr.local.ssjygl.base.BaseSyncService;
|
||||||
import com.cowr.model.InvoiceReceive;
|
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
||||||
public class InvoiceLogSyncService extends BaseSyncService {
|
public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
||||||
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过第三方税盘接口获取当前的 发票号码
|
|
||||||
*
|
|
||||||
* @param supermarket_id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String taxationLastCode(int supermarket_id) {
|
|
||||||
// TODO: 通过税盘获取当前发票号码
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvoiceReceive lastReceive(int supermarket_id) {
|
|
||||||
String sql = "select * from invoice_receive t\n" +
|
|
||||||
" where t.supermarket_id = ? \n" +
|
|
||||||
" and t.surplus > 0\n" +
|
|
||||||
" order by t.start_code asc\n" +
|
|
||||||
" limit 1";
|
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id);
|
|
||||||
|
|
||||||
|
|
||||||
return receive;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -603,7 +603,6 @@ public class OrderService {
|
||||||
return Result.failed("没有可用发票");
|
return Result.failed("没有可用发票");
|
||||||
}
|
}
|
||||||
|
|
||||||
String taxation_invoice_code = InvoiceLogSyncService.me.taxationLastCode(order.getInt("supermarket_id"));
|
|
||||||
String next_invoice_code;
|
String next_invoice_code;
|
||||||
if (receive.getCurrentCode() == null) {
|
if (receive.getCurrentCode() == null) {
|
||||||
next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1));
|
next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1));
|
||||||
|
|
@ -611,10 +610,6 @@ public class OrderService {
|
||||||
next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getCurrentCode() + 1));
|
next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getCurrentCode() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!next_invoice_code.equals(taxation_invoice_code)) {
|
|
||||||
return Result.failed("本地记录和税务系统不一致");
|
|
||||||
}
|
|
||||||
|
|
||||||
order.set("invoice_code", next_invoice_code);
|
order.set("invoice_code", next_invoice_code);
|
||||||
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import com.cowr.common.enums.OrderStateEnum;
|
||||||
import com.cowr.common.enums.OrderTypeEnum;
|
import com.cowr.common.enums.OrderTypeEnum;
|
||||||
import com.cowr.common.utils.DateTimeUtil;
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.local.ssjygl.invoice.log.InvoiceLogSyncService;
|
|
||||||
import com.cowr.local.ssjygl.main.Config;
|
import com.cowr.local.ssjygl.main.Config;
|
||||||
import com.cowr.local.ssjygl.order.OrderService;
|
import com.cowr.local.ssjygl.order.OrderService;
|
||||||
import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
|
import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
|
||||||
|
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
||||||
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
|
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
|
||||||
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
|
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
|
|
@ -84,14 +84,14 @@ public class OrderTempSyncService {
|
||||||
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0){
|
if (transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0) {
|
||||||
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
||||||
|
|
||||||
if (req_receipt == 1) { // 需要同时开具发票
|
if (req_receipt == 1) { // 需要同时开具发票
|
||||||
receive = InvoiceLogSyncService.me.lastReceive(transport.getSupermarketId());
|
receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
||||||
|
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的领用记录");
|
return Result.failed("没有有效的领用记录");
|
||||||
|
|
@ -134,8 +134,8 @@ public class OrderTempSyncService {
|
||||||
// 更新 transport 出入场信息
|
// 更新 transport 出入场信息
|
||||||
// 线下支付才同步将出入场记录设置为完成
|
// 线下支付才同步将出入场记录设置为完成
|
||||||
// if (order.getPayType() == 1) {
|
// if (order.getPayType() == 1) {
|
||||||
transport.setArriveTime(now);
|
transport.setArriveTime(now);
|
||||||
order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程
|
order.setState(OrderStateEnum.RECEIVED.getStateid()); // 直接完成,没有前面的过程
|
||||||
// } else {
|
// } else {
|
||||||
// order.setState(OrderStateEnum.LEAVE.getStateid()); // 等等付款
|
// order.setState(OrderStateEnum.LEAVE.getStateid()); // 等等付款
|
||||||
// }
|
// }
|
||||||
|
|
@ -183,14 +183,24 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 各种信息都保存成功后,再提交税务系统,获取当前发票信息 // TODO:税盘接口是不是还要提交金额等开票相关的信息
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
String taxation_invoice_code = InvoiceLogSyncService.me.taxationLastCode(order.getInt("supermarket_id"));
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
|
invoiceLog.setInvoiceReceiveId(finalReceive.getId());
|
||||||
|
invoiceLog.setCode(finalNext_invoice_code);
|
||||||
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
invoiceLog.setSettlementTime(now);
|
||||||
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
invoiceLog.setSettlementUserName(order.getSettlementUserName());
|
||||||
|
invoiceLog.setOrderSn(order.getSn());
|
||||||
|
invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
if (!finalNext_invoice_code.equals(taxation_invoice_code)) {
|
ret = invoiceLog.save();
|
||||||
log.error("本地记录和税务系统不一致");
|
|
||||||
|
if(!ret){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synctask.addSaveData(invoiceLog);
|
||||||
synctask.addUpdateData(finalReceive);
|
synctask.addUpdateData(finalReceive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +217,7 @@ public class OrderTempSyncService {
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (order.getPayType() == 1) {
|
// if (order.getPayType() == 1) {
|
||||||
return OrderService.me.orderPayComplete(ret, order.toRecord(), transport, printerId);
|
return OrderService.me.orderPayComplete(ret, order.toRecord(), transport, printerId);
|
||||||
// } else {
|
// } else {
|
||||||
// return ret ? Result.success(order) : Result.failed("结算失败");
|
// return ret ? Result.success(order) : Result.failed("结算失败");
|
||||||
// }
|
// }
|
||||||
|
|
@ -237,7 +247,7 @@ public class OrderTempSyncService {
|
||||||
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!DateTimeUtil.isToday(ordercluster.getCutoffTime())){
|
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
||||||
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,14 +289,14 @@ public class OrderTempSyncService {
|
||||||
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0){
|
if (transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0) {
|
||||||
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
||||||
|
|
||||||
if (req_receipt == 1) { // 需要同时开具发票
|
if (req_receipt == 1) { // 需要同时开具发票
|
||||||
receive = InvoiceLogSyncService.me.lastReceive(transport.getSupermarketId());
|
receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
||||||
|
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的领用记录");
|
return Result.failed("没有有效的领用记录");
|
||||||
|
|
@ -380,6 +390,18 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ordercluster.getState() == OrderStateEnum.INITIAL.getStateid()){
|
||||||
|
ordercluster.setState(OrderStateEnum.ENTERED.getStateid());
|
||||||
|
|
||||||
|
ret = ordercluster.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(ordercluster);
|
||||||
|
}
|
||||||
|
|
||||||
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
|
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
|
||||||
if (stock == null) {
|
if (stock == null) {
|
||||||
log.error("未找到库存信息 %s, %s", order.getSupermarketId(), order.getProductId());
|
log.error("未找到库存信息 %s, %s", order.getSupermarketId(), order.getProductId());
|
||||||
|
|
@ -405,14 +427,24 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 各种信息都保存成功后,再提交税务系统,获取当前发票信息 // TODO:税盘接口是不是还要提交金额等开票相关的信息
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
String taxation_invoice_code = InvoiceLogSyncService.me.taxationLastCode(order.getInt("supermarket_id"));
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
|
invoiceLog.setInvoiceReceiveId(finalReceive.getId());
|
||||||
|
invoiceLog.setCode(finalNext_invoice_code);
|
||||||
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
invoiceLog.setSettlementTime(now);
|
||||||
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
invoiceLog.setSettlementUserName(order.getSettlementUserName());
|
||||||
|
invoiceLog.setOrderSn(order.getSn());
|
||||||
|
invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
if (!finalNext_invoice_code.equals(taxation_invoice_code)) {
|
ret = invoiceLog.save();
|
||||||
log.error("本地记录和税务系统不一致");
|
|
||||||
|
if(!ret){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synctask.addSaveData(invoiceLog);
|
||||||
synctask.addUpdateData(finalReceive);
|
synctask.addUpdateData(finalReceive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -459,22 +491,28 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepayTruck pt = PrepayTruck.dao.findFirst("select * from prepay_truck t \n" +
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
||||||
" where t.supermarket_id = ? \n" +
|
" where t.truck_license = ? \n" +
|
||||||
" and t.truck_license = ? \n" +
|
|
||||||
" and t.valid_date = ? ",
|
" and t.valid_date = ? ",
|
||||||
transport.getSupermarketId(),
|
|
||||||
transport.getTruckLicense(),
|
transport.getTruckLicense(),
|
||||||
DateTimeUtil.sdf.get().format(transport.getInTime())
|
DateTimeUtil.sdf.get().format(transport.getInTime())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pt == null) {
|
if (ot == null) {
|
||||||
return Result.failedstr("【%s】不是今日预付费车辆", transport.getTruckLicense());
|
return Result.failedstr("【%s】不是今日预付费车辆", transport.getTruckLicense());
|
||||||
}
|
}
|
||||||
|
|
||||||
Customer customer;
|
Customer customer;
|
||||||
Product product;
|
Product product;
|
||||||
Ordercluster ordercluster = null;
|
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
|
if (ordercluster == null) {
|
||||||
|
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||||
|
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
// 验证重量
|
// 验证重量
|
||||||
if (transport.getFirstWeight() == null
|
if (transport.getFirstWeight() == null
|
||||||
|
|
@ -486,53 +524,38 @@ public class OrderTempSyncService {
|
||||||
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0){
|
if (transport.getSecondWeight().compareTo(BigDecimal.valueOf(Config.configprop.getInt("weigh.max"))) > 0) {
|
||||||
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
return Result.failedstr("毛重不能超过 %.2f 吨", Config.configprop.getInt("weigh.max"));
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
||||||
|
|
||||||
if (ordercluster_id != null) {
|
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
||||||
ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
||||||
if (ordercluster == null) {
|
|
||||||
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
|
||||||
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!DateTimeUtil.isToday(ordercluster.getCutoffTime())){
|
|
||||||
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
customer = Customer.dao.findById(ordercluster.getCustomerId());
|
|
||||||
product = Product.dao.findById(ordercluster.getProductId());
|
|
||||||
|
|
||||||
// 物流公司信息
|
|
||||||
order.setTransCoId(ordercluster.getTransCoId());
|
|
||||||
order.setTransCoAddress(ordercluster.getTransCoAddress());
|
|
||||||
order.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
|
|
||||||
order.setTransCoBankName(ordercluster.getTransCoBankName());
|
|
||||||
order.setTransCoName(ordercluster.getTransCoName());
|
|
||||||
order.setTransCoPhone(ordercluster.getTransCoPhone());
|
|
||||||
order.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
|
||||||
order.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
|
||||||
|
|
||||||
transport.setTransCoId(ordercluster.getTransCoId());
|
|
||||||
transport.setTransCoAddress(ordercluster.getTransCoAddress());
|
|
||||||
transport.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
|
|
||||||
transport.setTransCoBankName(ordercluster.getTransCoBankName());
|
|
||||||
transport.setTransCoName(ordercluster.getTransCoName());
|
|
||||||
transport.setTransCoPhone(ordercluster.getTransCoPhone());
|
|
||||||
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
|
||||||
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
|
||||||
} else {
|
|
||||||
customer = Customer.dao.findById(pt.getCustomerId());
|
|
||||||
|
|
||||||
product = Product.dao.findById(product_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customer = Customer.dao.findById(ordercluster.getCustomerId());
|
||||||
|
product = Product.dao.findById(ordercluster.getProductId());
|
||||||
|
|
||||||
|
// 物流公司信息
|
||||||
|
order.setTransCoId(ordercluster.getTransCoId());
|
||||||
|
order.setTransCoAddress(ordercluster.getTransCoAddress());
|
||||||
|
order.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
|
||||||
|
order.setTransCoBankName(ordercluster.getTransCoBankName());
|
||||||
|
order.setTransCoName(ordercluster.getTransCoName());
|
||||||
|
order.setTransCoPhone(ordercluster.getTransCoPhone());
|
||||||
|
order.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
||||||
|
order.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
||||||
|
|
||||||
|
transport.setTransCoId(ordercluster.getTransCoId());
|
||||||
|
transport.setTransCoAddress(ordercluster.getTransCoAddress());
|
||||||
|
transport.setTransCoBankAccount(ordercluster.getTransCoBankAccount());
|
||||||
|
transport.setTransCoBankName(ordercluster.getTransCoBankName());
|
||||||
|
transport.setTransCoName(ordercluster.getTransCoName());
|
||||||
|
transport.setTransCoPhone(ordercluster.getTransCoPhone());
|
||||||
|
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
||||||
|
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
||||||
|
|
||||||
if (product == null) {
|
if (product == null) {
|
||||||
return Result.failedstr("未找到有效的品类信息");
|
return Result.failedstr("未找到有效的品类信息");
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +590,7 @@ public class OrderTempSyncService {
|
||||||
String next_invoice_code = null;
|
String next_invoice_code = null;
|
||||||
|
|
||||||
if (req_receipt == 1) { // 需要同时开具发票
|
if (req_receipt == 1) { // 需要同时开具发票
|
||||||
receive = InvoiceLogSyncService.me.lastReceive(transport.getSupermarketId());
|
receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
||||||
|
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的领用记录");
|
return Result.failed("没有有效的领用记录");
|
||||||
|
|
@ -626,6 +649,10 @@ public class OrderTempSyncService {
|
||||||
transport.setArriveTime(now);
|
transport.setArriveTime(now);
|
||||||
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
|
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) < 1) {
|
||||||
|
return Result.failedstr("总价 %.2f,客户余额(%.2f)不足以支付");
|
||||||
|
}
|
||||||
|
|
||||||
InvoiceReceive finalReceive = receive;
|
InvoiceReceive finalReceive = receive;
|
||||||
String finalNext_invoice_code = next_invoice_code;
|
String finalNext_invoice_code = next_invoice_code;
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
|
@ -641,75 +668,12 @@ public class OrderTempSyncService {
|
||||||
order.setPrepayCustomerId(prepayCustomer.getId());
|
order.setPrepayCustomerId(prepayCustomer.getId());
|
||||||
prepayCustomer.setSpendTime(now);
|
prepayCustomer.setSpendTime(now);
|
||||||
|
|
||||||
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) > -1) {
|
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) < 1) {
|
||||||
prepayCustomer.setSurplus(prepayCustomer.getSurplus().subtract(order.getTotalPrice()));
|
return false;
|
||||||
} else {
|
|
||||||
// 对于支付的差额,算作一次即充即用的预付费充值
|
|
||||||
prepayCustomer.setSurplus(new BigDecimal(0));
|
|
||||||
|
|
||||||
String paidmemo = "现场补足预付金额:" + order.getPaid().intValue() + "元";
|
|
||||||
|
|
||||||
if (StrKit.isBlank(order.getMemo())) {
|
|
||||||
order.setMemo(paidmemo);
|
|
||||||
} else {
|
|
||||||
order.setMemo(order.getMemo() + "。" + paidmemo);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrepayDetail pd = new PrepayDetail();
|
|
||||||
pd.setId(StrKit.getRandomUUID());
|
|
||||||
pd.setCustomerId(order.getCustomerId());
|
|
||||||
pd.setSupermarketId(order.getSupermarketId());
|
|
||||||
pd.setAmount(order.getTotalPrice().subtract(prepayCustomer.getSurplus())); // 订单总价减去余额,就是本次补的差价
|
|
||||||
pd.setType(2);
|
|
||||||
pd.setContactName("");
|
|
||||||
pd.setContactPhone("");
|
|
||||||
pd.setBankName("");
|
|
||||||
pd.setSerialnum("");
|
|
||||||
pd.setState(2);
|
|
||||||
pd.setChangeTime(now);
|
|
||||||
pd.setCreateTime(now);
|
|
||||||
pd.setVerifyTime(now);
|
|
||||||
|
|
||||||
ret = pd.save();
|
|
||||||
if (!ret) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
synctask.addSaveData(pd);
|
|
||||||
|
|
||||||
PrepayDetailStateHistory his = new PrepayDetailStateHistory();
|
|
||||||
his.setId(StrKit.getRandomUUID());
|
|
||||||
his.setPrepayDetailId(pd.getId());
|
|
||||||
his.setChangeUserId(sysuser.getId());
|
|
||||||
his.setChangeUserName(sysuser.getName());
|
|
||||||
his.setState(1);
|
|
||||||
his.setChangeTime(now);
|
|
||||||
his.setMemo(paidmemo);
|
|
||||||
|
|
||||||
ret = his.save();
|
|
||||||
if (!ret) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
synctask.addSaveData(his);
|
|
||||||
|
|
||||||
his = new PrepayDetailStateHistory();
|
|
||||||
his.setId(StrKit.getRandomUUID());
|
|
||||||
his.setPrepayDetailId(pd.getId());
|
|
||||||
his.setChangeUserId(sysuser.getId());
|
|
||||||
his.setChangeUserName(sysuser.getName());
|
|
||||||
his.setState(2);
|
|
||||||
his.setChangeTime(now);
|
|
||||||
his.setMemo(paidmemo);
|
|
||||||
|
|
||||||
ret = his.save();
|
|
||||||
if (!ret) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
synctask.addSaveData(his);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepayCustomer.setSurplus(prepayCustomer.getSurplus().subtract(order.getTotalPrice()));
|
||||||
|
|
||||||
synctask.addUpdateData(prepayCustomer);
|
synctask.addUpdateData(prepayCustomer);
|
||||||
|
|
||||||
ret = prepayCustomer.update();
|
ret = prepayCustomer.update();
|
||||||
|
|
@ -724,8 +688,16 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if(ordercluster.getState() == OrderStateEnum.INITIAL.getStateid()){
|
||||||
return false;
|
ordercluster.setState(OrderStateEnum.ENTERED.getStateid());
|
||||||
|
|
||||||
|
ret = ordercluster.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(ordercluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
|
Stock stock = Stock.dao.findByIds(transport.getSupermarketId(), order.getProductId());
|
||||||
|
|
@ -753,14 +725,24 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 各种信息都保存成功后,再提交税务系统,获取当前发票信息 // TODO:税盘接口是不是还要提交金额等开票相关的信息
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
String taxation_invoice_code = InvoiceLogSyncService.me.taxationLastCode(order.getInt("supermarket_id"));
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
|
invoiceLog.setInvoiceReceiveId(finalReceive.getId());
|
||||||
|
invoiceLog.setCode(finalNext_invoice_code);
|
||||||
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
invoiceLog.setSettlementTime(now);
|
||||||
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
invoiceLog.setSettlementUserName(order.getSettlementUserName());
|
||||||
|
invoiceLog.setOrderSn(order.getSn());
|
||||||
|
invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
if (!finalNext_invoice_code.equals(taxation_invoice_code)) {
|
ret = invoiceLog.save();
|
||||||
log.error("本地记录和税务系统不一致");
|
|
||||||
|
if(!ret){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synctask.addSaveData(invoiceLog);
|
||||||
synctask.addUpdateData(finalReceive);
|
synctask.addUpdateData(finalReceive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,12 @@ public class PrepayController extends BaseController {
|
||||||
public void find() {
|
public void find() {
|
||||||
String name = get("name");
|
String name = get("name");
|
||||||
Integer customer_id = getInt("customer_id");
|
Integer customer_id = getInt("customer_id");
|
||||||
|
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
Double start = getParaToDouble("start");
|
Double start = getParaToDouble("start");
|
||||||
Double end = getParaToDouble("end");
|
Double end = getParaToDouble("end");
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, supermarket_id, stm, etm, start, end)));
|
renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, stm, etm, start, end)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(StartAndEndTimeValidator.class)
|
@Before(StartAndEndTimeValidator.class)
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@ import com.jfinal.plugin.activerecord.IAtom;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InvoiceReceiveSyncService extends BaseSyncService {
|
public class InvoiceReceiveSyncService extends BaseSyncService {
|
||||||
private static Log log = Log.getLog(InvoiceReceiveSyncService.class);
|
private static Log log = Log.getLog(InvoiceReceiveSyncService.class);
|
||||||
public static InvoiceReceiveSyncService me = new InvoiceReceiveSyncService();
|
public static InvoiceReceiveSyncService me = new InvoiceReceiveSyncService();
|
||||||
|
|
||||||
public Result save(InvoiceReceive receive, Sysuser user){
|
public Result save(InvoiceReceive receive, Sysuser user) {
|
||||||
Sysuser receive_user = Sysuser.dao.findById(receive.getReceiveUserId());
|
Sysuser receive_user = Sysuser.dao.findById(receive.getReceiveUserId());
|
||||||
|
|
||||||
if(receive_user == null){
|
if (receive_user == null) {
|
||||||
return Result.failed("未找到关联用户信息");
|
return Result.failed("未找到关联用户信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,14 +32,29 @@ public class InvoiceReceiveSyncService extends BaseSyncService {
|
||||||
|
|
||||||
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(receive.getSupermarketId());
|
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(receive.getSupermarketId());
|
||||||
|
|
||||||
if(supermarket == null){
|
if (supermarket == null) {
|
||||||
return Result.failed("未找到对应砂站信息");
|
return Result.failed("未找到对应砂站信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 这里需要验证输入的起始发票号码和领用份数,避免多个批次的领用和多个砂站的领用出现发票代码重复的情况
|
try {
|
||||||
|
// 十位或者更长的发票号码要转 long,否则可能超过 Integer.MAX_VALUE 2147483647
|
||||||
|
Long start = Long.parseLong(receive.getStartCode());
|
||||||
|
Long end = Long.parseLong(receive.getEndCode());
|
||||||
|
|
||||||
receive.setId(StrKit.getRandomUUID());
|
List<InvoiceReceive> chklist = InvoiceReceive.dao.find("select * from invoice_receive t\n" +
|
||||||
receive.setSurplus(receive.getNum());
|
" where ( t.start_code <= ? and t.end_code >= ? )\n" +
|
||||||
|
" or ( t.start_code <= ? and t.end_code >= ? )", start, start, end, end);
|
||||||
|
|
||||||
|
if (!chklist.isEmpty()) {
|
||||||
|
return Result.failed("发票段和已领用的记录冲突");
|
||||||
|
}
|
||||||
|
|
||||||
|
receive.setSurplus((int) (end - start) + 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
|
||||||
|
return Result.failed("数据检查错误");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,12 @@ public class PrepayController extends BaseController {
|
||||||
customer_id = tokenuser.getEntityId();
|
customer_id = tokenuser.getEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
Double start = getParaToDouble("start");
|
Double start = getParaToDouble("start");
|
||||||
Double end = getParaToDouble("end");
|
Double end = getParaToDouble("end");
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, supermarket_id, stm, etm, start, end)));
|
renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, stm, etm, start, end)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(StartAndEndTimeValidator.class)
|
@Before(StartAndEndTimeValidator.class)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue