diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseInvoiceReceive.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseInvoiceReceive.java index f9ef088..246ecee 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseInvoiceReceive.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseInvoiceReceive.java @@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean; import com.alibaba.fastjson.annotation.JSONField; /** - * Generated by COWR Fri Aug 28 00:25:03 CST 2020 + * Generated by COWR Sun Sep 06 16:28:55 CST 2020 * TableName: invoice_receive * Remarks: 发票管理 - 领用记录 * PrimaryKey: id @@ -240,5 +240,27 @@ public abstract class BaseInvoiceReceive> extend return getInt("supermarket_id"); } + /** + * name: invoice_type + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: 1 + * @param invoiceType 1.普票,2.专票 + */ + @JSONField(name="invoice_type") + public void setInvoiceType(Integer invoiceType) { + set("invoice_type", invoiceType); + } + + + /** + * @return invoice_type 1.普票,2.专票 + */ + @JSONField(name="invoice_type") + public Integer getInvoiceType() { + return getInt("invoice_type"); + } + } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java index 7323860..034c9f7 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/log/InvoiceLogService.java @@ -4,6 +4,7 @@ import com.cowr.common.Const; import com.cowr.common.base.BaseService; import com.cowr.common.view.PageParam; import com.cowr.model.InvoiceLog; +import com.cowr.model.InvoiceReceive; import com.jfinal.kit.StrKit; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; @@ -21,11 +22,53 @@ import java.util.List; public class InvoiceLogService extends BaseService { public static final InvoiceLogService me = new InvoiceLogService(); - public Page find(PageParam pp) { + 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; + } + + public Page find(PageParam pp, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) { String selectsql = "select * "; - String fromsql = "from invoice_log t where 1=1 "; + String fromsql = "from invoice_log t where 1=1 \n"; List paraList = new ArrayList<>(); + if (state != null) { + fromsql += " and t.state = ? \n"; + paraList.add(state); + } + + if (StrKit.notBlank(order_sn)) { + fromsql += " and t.order_sn like ? \n"; + paraList.add("%" + order_sn + "%"); + } + + if (StrKit.notBlank(stm)) { + fromsql += " and t.create_time >= ? \n"; + paraList.add(stm); + } + + if (StrKit.notBlank(etm)) { + fromsql += " and t.create_time <= ? \n"; + paraList.add(etm); + } + + if (StrKit.notBlank(code)) { + fromsql += " and t.code like ? \n"; + paraList.add("%" + code + "%"); + } + + if (invoice_type != null) { + fromsql += " and t.invoice_type = ? \n"; + paraList.add(state); + } + String totalRowSql = "select count(*) " + fromsql; String findSql = selectsql + fromsql; diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveValidator.java index 1985417..75b0f70 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveValidator.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveValidator.java @@ -32,6 +32,8 @@ public class InvoiceReceiveValidator extends CrudParamValidator { } } + validateInteger("invoice_type", 1, 2, "invoice_type", "invoice_type 范围 1~2"); + // 使用 model 更新时,model 不能只有主键有值 // 这里用 getActionMethodName 写死,判断是 update 时,才做验证 // 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段 diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 6037ae9..44a499d 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -384,14 +384,14 @@ public class OrderStatService { */ public Record monthgrid(String tm, Integer supermarket_id, Integer customer_id) { // 使用实际支付金额统计 - String sql = "select t.customer_id, max(t.customer_name) customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total \n" + + String sql = "select ifnull(max(t.customer_id), t.customer_name) customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, max(s.name) supermarket_name, count(*) cnt, sum(t.total_price) total \n" + " from (\n" + - " select t.customer_id, ifnull(t.customer_name, '民用') customer_name, t.supermarket_id, t.paid, t.total_price, 1 type \n" + + " select t.customer_id, t.customer_name, t.supermarket_id, t.paid, t.total_price, 1 type \n" + " from order_sale t\n" + " where t.state = ? \n" + " and t.create_time like ?\n" + " union all\n" + - " select t.customer_id, case when isnull(t.customer_name) then '民用' else t.customer_name end customer_name , t.supermarket_id, t.paid, t.total_price, 3 type \n" + + " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price, 3 type \n" + " from order_temp t\n" + " where t.state = ? \n" + " and t.create_time like ?\n" + @@ -416,22 +416,22 @@ public class OrderStatService { paraList.add(customer_id); } - sql += " group by t.customer_id, t.supermarket_id"; + sql += " group by t.customer_name, t.supermarket_id"; List dblist = Db.find(sql, paraList.toArray()); Map spkeys = new HashMap<>(); // supermarket_id <-> supermarket_name - Map cumaps = new HashMap<>(); // customer_id <-> out record + Map cumaps = new HashMap<>(); // customer_id <-> out record for (Record record : dblist) { String supermarket_id_str = record.getStr("supermarket_id"); int sql_supermarket_id = record.getInt("supermarket_id"); String supermarket_name = record.getStr("supermarket_name"); - int sql_customer_id; + String sql_customer_id; if (record.get("customer_id") == null) { - sql_customer_id = 0; + sql_customer_id = "0"; } else { - sql_customer_id = record.getInt("customer_id"); + sql_customer_id = record.get("customer_id"); } spkeys.put(sql_supermarket_id, supermarket_name); // 反正可以直接覆盖,就不判断了 @@ -600,23 +600,19 @@ public class OrderStatService { * @return */ public List salestatCustomer(String tm) { - String sql = "select ifnull(t.id, 0) id, ifnull(t.name, '民用') name, ifnull(a.orderCount, 0) orderCount, ifnull(a.totalPrice, 0) totalPrice, ifnull(a.weight, 0) weight\n" + + String sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + " from (\n" + - " select t.id,count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + - " from (\n" + - " select t.customer_id as id, t.paid, t.total_price, t.weight\n" + - " from order_sale t\n" + - " where t.state = ?\n" + - " and t.create_time like ?\n" + - " union all\n" + - " select t.customer_id as id, t.paid, t.total_price, t.weight\n" + - " from order_temp t\n" + - " where t.state = ?\n" + - " and t.create_time like ?\n" + - " ) t\n" + - " group by t.id\n" + - " ) a\n" + - " left join customer t on a.id = t.id"; + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" + + " from order_sale t\n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " union all\n" + + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" + + " from order_temp t\n" + + " where t.state = ? \n" + + " and t.create_time like ? \n" + + " ) t\n" + + " group by t.customer_name"; List dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%"); @@ -1232,18 +1228,13 @@ public class OrderStatService { * @param isprepaid 是否预付费 * @return */ - public List statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, boolean stat_product, Integer product_id, Integer isprepaid) { - String sale_sql = " select t.customer_id, sum(t.weight) weight, sum(t.total_price) total_price, count(t.sn) orderCount "; - String temp_sql = " select t.customer_id, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price, count(t.sn) orderCount "; + public List statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, boolean stat_product, Integer product_id, Integer isprepaid) { + String sale_sql = " select t.customer_id, t.customer_name, t.weight, t.total_price, t.sn, t.product_id, t.product_name "; + String temp_sql = " select t.customer_id, t.customer_name, t.weight, t.total_price, t.sn, t.product_id, t.product_name "; List paraSale = new ArrayList<>(); List paraTemp = new ArrayList<>(); - if (stat_product) { - sale_sql += " , t.product_id, max(t.product_name) product_name \n"; - temp_sql += " , t.product_id, max(t.product_name) product_name \n"; - } - sale_sql += " from order_sale t \n" + " where t.state = ? \n"; @@ -1269,6 +1260,34 @@ public class OrderStatService { paraTemp.add(customer_id); } + if (StrKit.notBlank(customer_ids)) { + String[] cids = customer_ids.split(","); + + if (cids.length > 0) { + sale_sql += " and t.customer_id in( \n"; + temp_sql += " and t.customer_id in( \n"; + + for (int i = 0; i < cids.length; i++) { + String cid = cids[i]; + + if(i > 0){ + sale_sql += ", "; + temp_sql += ", "; + } + + sale_sql += "?"; + temp_sql += "?"; + + paraSale.add(cid); + paraTemp.add(cid); + } + + + sale_sql += " ) \n"; + temp_sql += " ) \n"; + } + } + if (tm == null) { if (!StrKit.notBlank(stm, etm)) { log.error("参数错误"); @@ -1298,6 +1317,8 @@ public class OrderStatService { paraTemp.add(isprepaid); } + String sql; + if (stat_product) { if (product_id != null) { sale_sql += " and t.product_id = ? \n"; @@ -1306,20 +1327,25 @@ public class OrderStatService { temp_sql += " and t.product_id = ? \n"; paraTemp.add(product_id); } - sale_sql += " group by t.customer_id, t.product_id \n"; - temp_sql += " group by t.customer_id, t.product_id \n"; - } else { - sale_sql += " group by t.customer_id \n"; - temp_sql += " group by t.customer_id \n"; - } - String sql = "select ifnull(c.name, '民用') customer_name, a.* from( \n" + - sale_sql + - " union \n " + - temp_sql + - " ) a\n" + - " left join customer c on c.id = a.customer_id \n" + - " order by a.customer_id desc"; + sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id), sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount, a.product_id, max(a.product_name) product_name \n" + + " from( \n" + + sale_sql + + " union \n " + + temp_sql + + " ) a\n" + + " left join customer c on c.id = a.customer_id \n" + + " group by a.customer_name, a.product_id "; + }else{ + sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id), sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount \n" + + " from( \n" + + sale_sql + + " union \n " + + temp_sql + + " ) a\n" + + " left join customer c on c.id = a.customer_id \n" + + " group by a.customer_name "; + } paraSale.addAll(paraTemp); @@ -1337,11 +1363,11 @@ public class OrderStatService { return list; } - public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, boolean stat_product, Integer product_id, Integer isprepaid) { + public Workbook statCustomerExport(String name, String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, String customer_ids, boolean stat_product, Integer product_id, Integer isprepaid) { Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(name); - List list = statCustomer(tm, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid); + List list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); int datalen = list.size(); int end_col = stat_product ? 6 : 5; // 数据共有几列 diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java index 39ba35b..9f9f6f6 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java @@ -23,7 +23,7 @@ public class InvoiceLogController extends Controller { * 不存在 data = false */ @Before(InvoiceLogPKValidator.class) - public void checkExistsByPk(){ + public void checkExistsByPk() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.checkExistsByPk(model)); } @@ -31,16 +31,22 @@ public class InvoiceLogController extends Controller { /** * 分页查找 invoice_log 发票管理 - 发票使用记录 */ - public void find(){ - PageParam pp = getBean(PageParam.class, "", true); - renderJson(Result.object(InvoiceLogService.me.find(pp))); + public void find() { + PageParam pp = getBean(PageParam.class, "", true); + Integer state = getInt("state"); + String order_sn = get("order_sn"); + String stm = get("stm"); + String etm = get("etm"); + String code = get("code"); + Integer invoice_type = getInt("state"); + renderJson(Result.object(InvoiceLogService.me.find(pp, state, order_sn, stm, etm, code, invoice_type))); } /** * 按主键查找单个对象 invoice_log 发票管理 - 发票使用记录 */ @Before(InvoiceLogPKValidator.class) - public void findByPk(){ + public void findByPk() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.findByPk(model)); } @@ -49,7 +55,7 @@ public class InvoiceLogController extends Controller { * 按主键查找单个对象 invoice_log 发票管理 - 发票使用记录 */ @Before(InvoiceLogPKValidator.class) - public void get(){ + public void get() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.findByPk(model)); } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java index 4eb98a0..46defeb 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogSyncService.java @@ -1,22 +1,86 @@ package com.cowr.local.ssjygl.invoice.log; +import com.cowr.common.base.BaseModel; +import com.cowr.common.enums.Enums; +import com.cowr.common.view.Result; import com.cowr.local.ssjygl.base.BaseSyncService; -import com.cowr.model.InvoiceReceive; +import com.cowr.local.ssjygl.order.OrderService; +import com.cowr.local.ssjygl.synctask.SyncTaskService; +import com.cowr.model.*; +import com.cowr.ssjygl.modifylog.ModifyLogService; import com.jfinal.log.Log; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.IAtom; + +import java.util.Date; public class InvoiceLogSyncService extends BaseSyncService { private static Log log = Log.getLog(InvoiceLogSyncService.class); public static InvoiceLogSyncService me = new InvoiceLogSyncService(); - 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"; + /** + * 作废发票,未关联订单的(损毁等,不是正常开票使用的发票) + * @return + */ + public Result save(String code, String invalid_memo, Sysuser sysuser){ + return null; + } - InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id); + /** + * 取消已使用的发票,必须关联了订单的 + * @param id + * @param sysuser + * @return + */ + public Result cancel(String id, String invalid_memo, Sysuser sysuser){ + InvoiceLog invoiceLog = InvoiceLog.dao.findById(id); - return receive; + if(invoiceLog == null){ + return Result.failed("未找到记录"); + } + + InvoiceLog old = invoiceLog.clone(); + BaseModel order = OrderService.me.getOrderBySn(invoiceLog.getOrderSn()); + + if(order == null){ + return Result.failedstr("按[%s]未找到订单信息"); + } + + invoiceLog.setInvalidMemo(invalid_memo); + invoiceLog.setInvalidTime(new Date()); + invoiceLog.setInvalidUserId(sysuser.getId()); + invoiceLog.setInvalidUserName(sysuser.getName()); + + boolean ret = Db.tx(new IAtom() { + @Override + public boolean run() { + try{ + order.set("invoice_code", null); + boolean ret = order.update(); + + if(!ret){ + return false; + } + + SyncTask synctask = new SyncTask(); + synctask.addUpdateData(order); + + ret = invoiceLog.update(); + + if(!ret){ + return false; + } + + synctask.addUpdateData(invoiceLog); + + return SyncTaskService.me.save(synctask) && ModifyLogService.me.save(invoiceLog, old, Enums.DataOpType.UPDATE.getId(), sysuser); + }catch (Exception e){ + log.error(e.getMessage(), e); + } + return false; + } + }); + + return ret ? Result.success() : Result.failed("作废失败"); } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/OrderService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/OrderService.java index daa86ea..8fd2b96 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/OrderService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/OrderService.java @@ -16,6 +16,7 @@ import com.cowr.local.ssjygl.synctask.SyncTaskService; import com.cowr.local.ssjygl.transport.TransportDeviceService; import com.cowr.model.*; import com.cowr.ssjygl.CacheData; +import com.cowr.ssjygl.invoice.log.InvoiceLogService; import com.cowr.ssjygl.modifylog.ModifyLogService; import com.cowr.ssjygl.transprice.TransPriceService; import com.jfinal.kit.PathKit; @@ -593,7 +594,7 @@ public class OrderService { return Result.failed("订单类型错误,只有配送订单和外销订单才能开具发票"); } - InvoiceReceive receive = InvoiceLogSyncService.me.lastReceive(order.getInt("supermarket_id")); + InvoiceReceive receive = InvoiceLogService.me.lastReceive(order.getInt("supermarket_id")); if (receive == null) { return Result.failed("没有有效的领用记录"); @@ -605,9 +606,9 @@ public class OrderService { String next_invoice_code; if (receive.getCurrentCode() == null) { - next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1)); + next_invoice_code = receive.getStartCode(); } else { - 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); } order.set("invoice_code", next_invoice_code); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java index 9b040dd..41a0cb8 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java @@ -91,7 +91,7 @@ public class OrderTempSyncService { BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次 - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); if (receive == null) { @@ -103,13 +103,13 @@ public class OrderTempSyncService { } if (receive.getCurrentCode() == null) { - next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1)); + next_invoice_code = receive.getStartCode(); } else { - 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); } order.setInvoiceCode(next_invoice_code); - } +// } order.setTransportId(transport.getId()); order.setSupermarketId(transport.getSupermarketId()); @@ -172,7 +172,7 @@ public class OrderTempSyncService { return false; } - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 // 这里的 finalReceive 在前面肯定验证过了 finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setCurrentCode(finalNext_invoice_code); @@ -203,7 +203,7 @@ public class OrderTempSyncService { synctask.addSaveData(invoiceLog); synctask.addUpdateData(finalReceive); - } +// } synctask.addUpdateData(transport); synctask.addSaveData(order); @@ -303,11 +303,11 @@ public class OrderTempSyncService { BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次 BigDecimal overweight = OrderclusterService.me.getOverWeight(ordercluster_id); // 集团订单剩余量 // 不能超过集团订单剩余量 - if (net_weight.compareTo(overweight) <= 0) { + if (net_weight.compareTo(overweight) > 0) { return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, overweight); } - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); if (receive == null) { @@ -319,13 +319,13 @@ public class OrderTempSyncService { } if (receive.getCurrentCode() == null) { - next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1)); + next_invoice_code = receive.getStartCode(); } else { - 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); } order.setInvoiceCode(next_invoice_code); - } +// } order.setTransportId(transport.getId()); order.setSupermarketId(transport.getSupermarketId()); @@ -427,7 +427,7 @@ public class OrderTempSyncService { return false; } - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 // 这里的 finalReceive 在前面肯定验证过了 finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setCurrentCode(finalNext_invoice_code); @@ -445,7 +445,7 @@ public class OrderTempSyncService { invoiceLog.setCode(finalNext_invoice_code); invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid()); invoiceLog.setSettlementTime(now); - invoiceLog.setSettlementUserId(order.getSettlementUserId()); + invoiceLog.setSettlementUserId(order.getSettlementUserId()); // 发票使用人 invoiceLog.setSettlementUserName(order.getSettlementUserName()); invoiceLog.setOrderSn(order.getSn()); invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid()); @@ -458,7 +458,7 @@ public class OrderTempSyncService { synctask.addSaveData(invoiceLog); synctask.addUpdateData(finalReceive); - } +// } // 在这里更新sn字段之后存入 synctask.addSaveData(order); @@ -601,7 +601,7 @@ public class OrderTempSyncService { InvoiceReceive receive = null; String next_invoice_code = null; - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); if (receive == null) { @@ -613,13 +613,13 @@ public class OrderTempSyncService { } if (receive.getCurrentCode() == null) { - next_invoice_code = String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode() + 1)); + next_invoice_code = receive.getStartCode(); } else { - 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); } order.setInvoiceCode(next_invoice_code); - } +// } order.setTransportId(transport.getId()); order.setSupermarketId(transport.getSupermarketId()); @@ -725,7 +725,7 @@ public class OrderTempSyncService { return false; } - if (req_receipt == 1) { // 需要同时开具发票 +// if (req_receipt == 1) { // 需要同时开具发票 // 这里的 finalReceive 在前面肯定验证过了 finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setCurrentCode(finalNext_invoice_code); @@ -756,7 +756,7 @@ public class OrderTempSyncService { synctask.addSaveData(invoiceLog); synctask.addUpdateData(finalReceive); - } +// } // 在这里更新sn字段之后存入 synctask.addSaveData(order); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java index f6538af..6938f5f 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/stat/sale/OrderStatController.java @@ -225,14 +225,15 @@ public class OrderStatController extends BaseController { int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Integer product_id = getInt("product_id"); boolean stat_product = getBoolean("stat_product", false); Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -246,14 +247,15 @@ public class OrderStatController extends BaseController { int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Integer product_id = getInt("product_id"); boolean stat_product = getBoolean("stat_product", false); Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -265,14 +267,15 @@ public class OrderStatController extends BaseController { int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Integer product_id = getInt("product_id"); boolean stat_product = getBoolean("stat_product", false); Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogController.java index 930cc32..466828f 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogController.java @@ -24,7 +24,7 @@ public class InvoiceLogController extends Controller { * 不存在 data = false */ @Before(InvoiceLogPKValidator.class) - public void checkExistsByPk(){ + public void checkExistsByPk() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.checkExistsByPk(model)); } @@ -32,16 +32,22 @@ public class InvoiceLogController extends Controller { /** * 分页查找 invoice_log 发票管理 - 发票使用记录 */ - public void find(){ - PageParam pp = getBean(PageParam.class, "", true); - renderJson(Result.object(InvoiceLogService.me.find(pp))); + public void find() { + PageParam pp = getBean(PageParam.class, "", true); + Integer state = getInt("state"); + String order_sn = get("order_sn"); + String stm = get("stm"); + String etm = get("etm"); + String code = get("code"); + Integer invoice_type = getInt("state"); + renderJson(Result.object(InvoiceLogService.me.find(pp, state, order_sn, stm, etm, code, invoice_type))); } /** * 按主键查找单个对象 invoice_log 发票管理 - 发票使用记录 */ @Before(InvoiceLogPKValidator.class) - public void findByPk(){ + public void findByPk() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.findByPk(model)); } @@ -50,7 +56,7 @@ public class InvoiceLogController extends Controller { * 按主键查找单个对象 invoice_log 发票管理 - 发票使用记录 */ @Before(InvoiceLogPKValidator.class) - public void get(){ + public void get() { InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段 renderJson(InvoiceLogService.me.findByPk(model)); } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java index 7cc5e9c..cfaff2b 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/stat/sale/OrderStatController.java @@ -38,9 +38,9 @@ public class OrderStatController extends BaseController { customer_id = tokenuser.getEntityId(); } - Integer type = getInt("type"); - Integer isprepaid = getInt("isprepaid"); - Integer product_id = getInt("product_id"); + Integer type = getInt("type"); + Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 @@ -92,8 +92,8 @@ public class OrderStatController extends BaseController { customer_id = tokenuser.getEntityId(); } - String tm = get("tm"); - int export = getInt("export", 0); + String tm = get("tm"); + int export = getInt("export", 0); if (export == 0) { renderJson(Result.object(OrderStatService.me.monthgrid(tm, supermarket_id, customer_id))); @@ -224,8 +224,8 @@ public class OrderStatController extends BaseController { @Before(StartAndEndintervalValidator.class) public void statRangeTrans() { - String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" - String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" + String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" + String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); Integer product_id = getInt("product_id"); @@ -235,7 +235,7 @@ public class OrderStatController extends BaseController { if (export == 0) { renderJson(Result.object(OrderStatService.me.statTrans(null, stm, etm, supermarket_id, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statTransExport("砂站时段销售汇总表",null, stm, etm, supermarket_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statTransExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, stat_product, product_id, isprepaid); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -249,7 +249,8 @@ public class OrderStatController extends BaseController { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); + Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -259,16 +260,17 @@ public class OrderStatController extends BaseController { return; } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { customer_id = tokenuser.getEntityId(); + customer_ids = null; } - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站日销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -281,7 +283,8 @@ public class OrderStatController extends BaseController { String tm = get("tm"); int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); + Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -291,27 +294,29 @@ public class OrderStatController extends BaseController { return; } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { customer_id = tokenuser.getEntityId(); + customer_ids = null; } - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站月销售汇总表", tm, null, null, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } } @Before(StartAndEndintervalValidator.class) public void statRangeCustomer() { - String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" - String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" + String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00" + String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59" int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 Integer supermarket_id = getInt("supermarket_id"); - Integer customer_id = getInt("customer_id"); + Integer customer_id = getInt("customer_id"); + String customer_ids = get("customer_ids"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -321,16 +326,17 @@ public class OrderStatController extends BaseController { return; } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { customer_id = tokenuser.getEntityId(); + customer_ids = null; } - Integer product_id = getInt("product_id"); - boolean stat_product = getBoolean("stat_product", false); - Integer isprepaid = getInt("isprepaid"); + Integer product_id = getInt("product_id"); + boolean stat_product = getBoolean("stat_product", false); + Integer isprepaid = getInt("isprepaid"); if (export == 0) { - renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid))); + renderJson(Result.object(OrderStatService.me.statCustomer(null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid))); } else { - Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表",null, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid); + Workbook wb = OrderStatService.me.statCustomerExport("砂站时段销售汇总表", null, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb)); } }