lisai17@sina.com 2020-09-06 23:57:31 +08:00
parent 78ceba3138
commit d7a15ef3a9
11 changed files with 307 additions and 128 deletions

View File

@ -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 Fri Aug 28 00:25:03 CST 2020 * Generated by COWR Sun Sep 06 16:28:55 CST 2020
* TableName: invoice_receive * TableName: invoice_receive
* Remarks: - * Remarks: -
* PrimaryKey: id * PrimaryKey: id
@ -240,5 +240,27 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
return getInt("supermarket_id"); 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");
}
} }

View File

@ -4,6 +4,7 @@ import com.cowr.common.Const;
import com.cowr.common.base.BaseService; import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam; import com.cowr.common.view.PageParam;
import com.cowr.model.InvoiceLog; import com.cowr.model.InvoiceLog;
import com.cowr.model.InvoiceReceive;
import com.jfinal.kit.StrKit; import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Page;
@ -21,11 +22,53 @@ import java.util.List;
public class InvoiceLogService extends BaseService { public class InvoiceLogService extends BaseService {
public static final InvoiceLogService me = new InvoiceLogService(); public static final InvoiceLogService me = new InvoiceLogService();
public Page<Record> 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<Record> find(PageParam pp, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
String selectsql = "select * "; String selectsql = "select * ";
String fromsql = "from invoice_log t where 1=1 "; String fromsql = "from invoice_log t where 1=1 \n";
List<Object> paraList = new ArrayList<>(); List<Object> 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 totalRowSql = "select count(*) " + fromsql;
String findSql = selectsql + fromsql; String findSql = selectsql + fromsql;

View File

@ -32,6 +32,8 @@ public class InvoiceReceiveValidator extends CrudParamValidator {
} }
} }
validateInteger("invoice_type", 1, 2, "invoice_type", "invoice_type 范围 1~2");
// 使用 model 更新时model 不能只有主键有值 // 使用 model 更新时model 不能只有主键有值
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证 // 这里用 getActionMethodName 写死,判断是 update 时,才做验证
// 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段 // 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段

View File

@ -384,14 +384,14 @@ public class OrderStatService {
*/ */
public Record monthgrid(String tm, Integer supermarket_id, Integer customer_id) { 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" + " 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" + " from order_sale t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ?\n" + " and t.create_time like ?\n" +
" union all\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" + " from order_temp t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ?\n" + " and t.create_time like ?\n" +
@ -416,22 +416,22 @@ public class OrderStatService {
paraList.add(customer_id); paraList.add(customer_id);
} }
sql += " group by t.customer_id, t.supermarket_id"; sql += " group by t.customer_name, t.supermarket_id";
List<Record> dblist = Db.find(sql, paraList.toArray()); List<Record> dblist = Db.find(sql, paraList.toArray());
Map<Integer, String> spkeys = new HashMap<>(); // supermarket_id <-> supermarket_name Map<Integer, String> spkeys = new HashMap<>(); // supermarket_id <-> supermarket_name
Map<Integer, Record> cumaps = new HashMap<>(); // customer_id <-> out record Map<String, Record> cumaps = new HashMap<>(); // customer_id <-> out record
for (Record record : dblist) { for (Record record : dblist) {
String supermarket_id_str = record.getStr("supermarket_id"); String supermarket_id_str = record.getStr("supermarket_id");
int sql_supermarket_id = record.getInt("supermarket_id"); int sql_supermarket_id = record.getInt("supermarket_id");
String supermarket_name = record.getStr("supermarket_name"); String supermarket_name = record.getStr("supermarket_name");
int sql_customer_id; String sql_customer_id;
if (record.get("customer_id") == null) { if (record.get("customer_id") == null) {
sql_customer_id = 0; sql_customer_id = "0";
} else { } else {
sql_customer_id = record.getInt("customer_id"); sql_customer_id = record.get("customer_id");
} }
spkeys.put(sql_supermarket_id, supermarket_name); // 反正可以直接覆盖,就不判断了 spkeys.put(sql_supermarket_id, supermarket_name); // 反正可以直接覆盖,就不判断了
@ -600,23 +600,19 @@ public class OrderStatService {
* @return * @return
*/ */
public List<Record> salestatCustomer(String tm) { public List<Record> 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" + " from (\n" +
" select t.id,count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" + " select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" +
" from (\n" +
" select t.customer_id as id, t.paid, t.total_price, t.weight\n" +
" from order_sale t\n" + " from order_sale t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
" union all\n" + " union all\n" +
" select t.customer_id as id, t.paid, t.total_price, t.weight\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" + " from order_temp t\n" +
" where t.state = ? \n" + " where t.state = ? \n" +
" and t.create_time like ? \n" + " and t.create_time like ? \n" +
" ) t\n" + " ) t\n" +
" group by t.id\n" + " group by t.customer_name";
" ) a\n" +
" left join customer t on a.id = t.id";
List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%"); List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%");
@ -1232,18 +1228,13 @@ public class OrderStatService {
* @param isprepaid * @param isprepaid
* @return * @return
*/ */
public List<Record> statCustomer(String tm, String stm, String etm, Integer supermarket_id, Integer customer_id, boolean stat_product, Integer product_id, Integer isprepaid) { public List<Record> 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, sum(t.weight) weight, sum(t.total_price) total_price, count(t.sn) orderCount "; 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, ifnull(sum(t.weight), 0) weight, ifnull(sum(t.total_price), 0) total_price, count(t.sn) orderCount "; String temp_sql = " select t.customer_id, t.customer_name, t.weight, t.total_price, t.sn, t.product_id, t.product_name ";
List<Object> paraSale = new ArrayList<>(); List<Object> paraSale = new ArrayList<>();
List<Object> paraTemp = new ArrayList<>(); List<Object> 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" + sale_sql += " from order_sale t \n" +
" where t.state = ? \n"; " where t.state = ? \n";
@ -1269,6 +1260,34 @@ public class OrderStatService {
paraTemp.add(customer_id); 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 (tm == null) {
if (!StrKit.notBlank(stm, etm)) { if (!StrKit.notBlank(stm, etm)) {
log.error("参数错误"); log.error("参数错误");
@ -1298,6 +1317,8 @@ public class OrderStatService {
paraTemp.add(isprepaid); paraTemp.add(isprepaid);
} }
String sql;
if (stat_product) { if (stat_product) {
if (product_id != null) { if (product_id != null) {
sale_sql += " and t.product_id = ? \n"; sale_sql += " and t.product_id = ? \n";
@ -1306,20 +1327,25 @@ public class OrderStatService {
temp_sql += " and t.product_id = ? \n"; temp_sql += " and t.product_id = ? \n";
paraTemp.add(product_id); 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" + 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 + sale_sql +
" union \n " + " union \n " +
temp_sql + temp_sql +
" ) a\n" + " ) a\n" +
" left join customer c on c.id = a.customer_id \n" + " left join customer c on c.id = a.customer_id \n" +
" order by a.customer_id desc"; " 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); paraSale.addAll(paraTemp);
@ -1337,11 +1363,11 @@ public class OrderStatService {
return list; 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(); Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(name); Sheet sheet = wb.createSheet(name);
List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, stat_product, product_id, isprepaid); List<Record> list = statCustomer(tm, stm, etm, supermarket_id, customer_id, customer_ids, stat_product, product_id, isprepaid);
int datalen = list.size(); int datalen = list.size();
int end_col = stat_product ? 6 : 5; // 数据共有几列 int end_col = stat_product ? 6 : 5; // 数据共有几列

View File

@ -33,7 +33,13 @@ public class InvoiceLogController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(InvoiceLogService.me.find(pp))); 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)));
} }
/** /**

View File

@ -1,22 +1,86 @@
package com.cowr.local.ssjygl.invoice.log; 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.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.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom;
import java.util.Date;
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();
public InvoiceReceive lastReceive(int supermarket_id) { /**
String sql = "select * from invoice_receive t\n" + * 使
" where t.supermarket_id = ? \n" + * @return
" and t.surplus > 0\n" + */
" order by t.start_code asc\n" + public Result save(String code, String invalid_memo, Sysuser sysuser){
" limit 1"; 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("作废失败");
} }
} }

View File

@ -16,6 +16,7 @@ import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.transport.TransportDeviceService; import com.cowr.local.ssjygl.transport.TransportDeviceService;
import com.cowr.model.*; import com.cowr.model.*;
import com.cowr.ssjygl.CacheData; import com.cowr.ssjygl.CacheData;
import com.cowr.ssjygl.invoice.log.InvoiceLogService;
import com.cowr.ssjygl.modifylog.ModifyLogService; import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.cowr.ssjygl.transprice.TransPriceService; import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.kit.PathKit; import com.jfinal.kit.PathKit;
@ -593,7 +594,7 @@ public class OrderService {
return Result.failed("订单类型错误,只有配送订单和外销订单才能开具发票"); return Result.failed("订单类型错误,只有配送订单和外销订单才能开具发票");
} }
InvoiceReceive receive = InvoiceLogSyncService.me.lastReceive(order.getInt("supermarket_id")); InvoiceReceive receive = InvoiceLogService.me.lastReceive(order.getInt("supermarket_id"));
if (receive == null) { if (receive == null) {
return Result.failed("没有有效的领用记录"); return Result.failed("没有有效的领用记录");
@ -605,9 +606,9 @@ public class OrderService {
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 = receive.getStartCode();
} else { } 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); order.set("invoice_code", next_invoice_code);

View File

@ -91,7 +91,7 @@ public class OrderTempSyncService {
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 = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
if (receive == null) { if (receive == null) {
@ -103,13 +103,13 @@ public class OrderTempSyncService {
} }
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 = receive.getStartCode();
} else { } 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.setInvoiceCode(next_invoice_code);
} // }
order.setTransportId(transport.getId()); order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId()); order.setSupermarketId(transport.getSupermarketId());
@ -172,7 +172,7 @@ public class OrderTempSyncService {
return false; return false;
} }
if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
// 这里的 finalReceive 在前面肯定验证过了 // 这里的 finalReceive 在前面肯定验证过了
finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setSurplus(finalReceive.getSurplus() - 1);
finalReceive.setCurrentCode(finalNext_invoice_code); finalReceive.setCurrentCode(finalNext_invoice_code);
@ -203,7 +203,7 @@ public class OrderTempSyncService {
synctask.addSaveData(invoiceLog); synctask.addSaveData(invoiceLog);
synctask.addUpdateData(finalReceive); synctask.addUpdateData(finalReceive);
} // }
synctask.addUpdateData(transport); synctask.addUpdateData(transport);
synctask.addSaveData(order); synctask.addSaveData(order);
@ -303,11 +303,11 @@ public class OrderTempSyncService {
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次 BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
BigDecimal overweight = OrderclusterService.me.getOverWeight(ordercluster_id); // 集团订单剩余量 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); return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, overweight);
} }
if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
if (receive == null) { if (receive == null) {
@ -319,13 +319,13 @@ public class OrderTempSyncService {
} }
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 = receive.getStartCode();
} else { } 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.setInvoiceCode(next_invoice_code);
} // }
order.setTransportId(transport.getId()); order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId()); order.setSupermarketId(transport.getSupermarketId());
@ -427,7 +427,7 @@ public class OrderTempSyncService {
return false; return false;
} }
if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
// 这里的 finalReceive 在前面肯定验证过了 // 这里的 finalReceive 在前面肯定验证过了
finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setSurplus(finalReceive.getSurplus() - 1);
finalReceive.setCurrentCode(finalNext_invoice_code); finalReceive.setCurrentCode(finalNext_invoice_code);
@ -445,7 +445,7 @@ public class OrderTempSyncService {
invoiceLog.setCode(finalNext_invoice_code); invoiceLog.setCode(finalNext_invoice_code);
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid()); invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
invoiceLog.setSettlementTime(now); invoiceLog.setSettlementTime(now);
invoiceLog.setSettlementUserId(order.getSettlementUserId()); invoiceLog.setSettlementUserId(order.getSettlementUserId()); // 发票使用人
invoiceLog.setSettlementUserName(order.getSettlementUserName()); invoiceLog.setSettlementUserName(order.getSettlementUserName());
invoiceLog.setOrderSn(order.getSn()); invoiceLog.setOrderSn(order.getSn());
invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid()); invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid());
@ -458,7 +458,7 @@ public class OrderTempSyncService {
synctask.addSaveData(invoiceLog); synctask.addSaveData(invoiceLog);
synctask.addUpdateData(finalReceive); synctask.addUpdateData(finalReceive);
} // }
// 在这里更新sn字段之后存入 // 在这里更新sn字段之后存入
synctask.addSaveData(order); synctask.addSaveData(order);
@ -601,7 +601,7 @@ public class OrderTempSyncService {
InvoiceReceive receive = null; InvoiceReceive receive = null;
String next_invoice_code = null; String next_invoice_code = null;
if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId()); receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
if (receive == null) { if (receive == null) {
@ -613,13 +613,13 @@ public class OrderTempSyncService {
} }
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 = receive.getStartCode();
} else { } 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.setInvoiceCode(next_invoice_code);
} // }
order.setTransportId(transport.getId()); order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId()); order.setSupermarketId(transport.getSupermarketId());
@ -725,7 +725,7 @@ public class OrderTempSyncService {
return false; return false;
} }
if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
// 这里的 finalReceive 在前面肯定验证过了 // 这里的 finalReceive 在前面肯定验证过了
finalReceive.setSurplus(finalReceive.getSurplus() - 1); finalReceive.setSurplus(finalReceive.getSurplus() - 1);
finalReceive.setCurrentCode(finalNext_invoice_code); finalReceive.setCurrentCode(finalNext_invoice_code);
@ -756,7 +756,7 @@ public class OrderTempSyncService {
synctask.addSaveData(invoiceLog); synctask.addSaveData(invoiceLog);
synctask.addUpdateData(finalReceive); synctask.addUpdateData(finalReceive);
} // }
// 在这里更新sn字段之后存入 // 在这里更新sn字段之后存入
synctask.addSaveData(order); synctask.addSaveData(order);

View File

@ -225,14 +225,15 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); 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 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); 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 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");
String customer_ids = get("customer_ids");
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
boolean stat_product = getBoolean("stat_product", false); boolean stat_product = getBoolean("stat_product", false);
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }

View File

@ -34,7 +34,13 @@ public class InvoiceLogController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(InvoiceLogService.me.find(pp))); 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)));
} }
/** /**

View File

@ -250,6 +250,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); 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")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -259,6 +260,7 @@ public class OrderStatController extends BaseController {
return; return;
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
customer_id = tokenuser.getEntityId(); customer_id = tokenuser.getEntityId();
customer_ids = null;
} }
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
@ -266,9 +268,9 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站日" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -282,6 +284,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); 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")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -291,6 +294,7 @@ public class OrderStatController extends BaseController {
return; return;
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
customer_id = tokenuser.getEntityId(); customer_id = tokenuser.getEntityId();
customer_ids = null;
} }
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
@ -298,9 +302,9 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(tm + "_砂站月" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }
@ -312,6 +316,7 @@ public class OrderStatController extends BaseController {
int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出 int export = getInt("export", 0); // 是否导出为exce 0 不导出1 导出
Integer supermarket_id = getInt("supermarket_id"); 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")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
@ -321,6 +326,7 @@ public class OrderStatController extends BaseController {
return; return;
} else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) { } else if (tokenuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
customer_id = tokenuser.getEntityId(); customer_id = tokenuser.getEntityId();
customer_ids = null;
} }
Integer product_id = getInt("product_id"); Integer product_id = getInt("product_id");
@ -328,9 +334,9 @@ public class OrderStatController extends BaseController {
Integer isprepaid = getInt("isprepaid"); Integer isprepaid = getInt("isprepaid");
if (export == 0) { 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 { } 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)); render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
} }
} }