dev
parent
1073d804ef
commit
7a1c5f62ee
|
|
@ -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 14 11:13:17 CST 2020
|
* Generated by COWR Mon Sep 21 13:04:24 CST 2020
|
||||||
* TableName: invoice_log
|
* TableName: invoice_log
|
||||||
* Remarks: 发票管理 - 发票使用记录
|
* Remarks: 发票管理 - 发票使用记录
|
||||||
* PrimaryKey: id
|
* PrimaryKey: id
|
||||||
|
|
@ -350,5 +350,49 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
return getInt("type");
|
return getInt("type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: invoice_number
|
||||||
|
* type: VARCHAR(20)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param invoiceNumber 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public void setInvoiceNumber(String invoiceNumber) {
|
||||||
|
set("invoice_number", invoiceNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return invoice_number 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public String getInvoiceNumber() {
|
||||||
|
return getStr("invoice_number");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 Sun Sep 06 16:28:55 CST 2020
|
* Generated by COWR Mon Sep 21 13:04:24 CST 2020
|
||||||
* TableName: invoice_receive
|
* TableName: invoice_receive
|
||||||
* Remarks: 发票管理 - 领用记录
|
* Remarks: 发票管理 - 领用记录
|
||||||
* PrimaryKey: id
|
* PrimaryKey: id
|
||||||
|
|
@ -262,5 +262,27 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
return getInt("invoice_type");
|
return getInt("invoice_type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: invoice_number
|
||||||
|
* type: VARCHAR(20)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param invoiceNumber 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public void setInvoiceNumber(String invoiceNumber) {
|
||||||
|
set("invoice_number", invoiceNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return invoice_number 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public String getInvoiceNumber() {
|
||||||
|
return getStr("invoice_number");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 11:15:31 CST 2020
|
* Generated by COWR Mon Sep 21 22:03:28 CST 2020
|
||||||
* TableName: order_temp
|
* TableName: order_temp
|
||||||
* Remarks: 订单相关 - 外销单
|
* Remarks: 订单相关 - 外销单
|
||||||
* PrimaryKey: sn
|
* PrimaryKey: sn
|
||||||
|
|
@ -92,7 +92,7 @@ public abstract class BaseOrderTemp<M extends BaseOrderTemp<M>> extends BaseMode
|
||||||
* 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) {
|
||||||
|
|
@ -101,7 +101,7 @@ public abstract class BaseOrderTemp<M extends BaseOrderTemp<M>> extends BaseMode
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 砂站id
|
* @return supermarket_id 超市id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
@ -1046,5 +1046,27 @@ public abstract class BaseOrderTemp<M extends BaseOrderTemp<M>> extends BaseMode
|
||||||
return getStr("invoice_code");
|
return getStr("invoice_code");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: invoice_number
|
||||||
|
* type: VARCHAR(20)
|
||||||
|
* isNullable: YES
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue:
|
||||||
|
* @param invoiceNumber 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public void setInvoiceNumber(String invoiceNumber) {
|
||||||
|
set("invoice_number", invoiceNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return invoice_number 发票代码
|
||||||
|
*/
|
||||||
|
@JSONField(name="invoice_number")
|
||||||
|
public String getInvoiceNumber() {
|
||||||
|
return getStr("invoice_number");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,17 @@ 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, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
|
public Page<Record> find(PageParam pp, String invoice_number, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
|
||||||
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
|
String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
|
||||||
" case when t.type = 1 then s.weight when t.type = 3 then p.weight end weight, \n" +
|
" case when t.type = 1 then o.weight when t.type = 3 then p.weight end weight, \n" +
|
||||||
" case when t.type = 1 then s.total_price when t.type = 3 then p.total_price end total_price, \n" +
|
" case when t.type = 1 then o.total_price when t.type = 3 then p.total_price end total_price, \n" +
|
||||||
" case when t.type = 1 then s.create_time when t.type = 3 then p.create_time end create_time, \n" +
|
" case when t.type = 1 then o.create_time when t.type = 3 then p.create_time end create_time, \n" +
|
||||||
" case when t.type = 1 then s.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
|
" case when t.type = 1 then o.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
|
||||||
" case when t.type = 1 then s.customer_name when t.type = 3 then p.customer_name end customer_name ";
|
" case when t.type = 1 then o.customer_name when t.type = 3 then p.customer_name end customer_name ";
|
||||||
String fromsql = "from invoice_log t \n" +
|
String fromsql = "from invoice_log t \n" +
|
||||||
" left join invoice_receive r on r.id = t.invoice_receive_id \n" +
|
" left join invoice_receive r on r.id = t.invoice_receive_id \n" +
|
||||||
" left join supermarket s on s.id = r.supermarket_id \n" +
|
" left join supermarket s on s.id = r.supermarket_id \n" +
|
||||||
" left join order_sale s on s.sn = t.order_sn \n" +
|
" left join order_sale o on o.sn = t.order_sn \n" +
|
||||||
" left join order_temp p on p.sn = t.order_sn \n" +
|
" left join order_temp p on p.sn = t.order_sn \n" +
|
||||||
" where 1=1 \n";
|
" where 1=1 \n";
|
||||||
List<Object> paraList = new ArrayList<>();
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
@ -51,6 +51,11 @@ public class InvoiceLogService extends BaseService {
|
||||||
paraList.add("%" + order_sn + "%");
|
paraList.add("%" + order_sn + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(invoice_number)) {
|
||||||
|
fromsql += " and t.invoice_number like ? \n";
|
||||||
|
paraList.add("%" + invoice_number + "%");
|
||||||
|
}
|
||||||
|
|
||||||
if (StrKit.notBlank(stm)) {
|
if (StrKit.notBlank(stm)) {
|
||||||
fromsql += " and t.create_time >= ? \n";
|
fromsql += " and t.create_time >= ? \n";
|
||||||
paraList.add(stm);
|
paraList.add(stm);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.cowr.ssjygl.invoice.receive;
|
||||||
import com.cowr.common.Const;
|
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.common.view.Result;
|
|
||||||
import com.cowr.model.InvoiceReceive;
|
import com.cowr.model.InvoiceReceive;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
@ -24,20 +23,46 @@ public class InvoiceReceiveService extends BaseService {
|
||||||
private static Log log = Log.getLog(InvoiceReceiveService.class);
|
private static Log log = Log.getLog(InvoiceReceiveService.class);
|
||||||
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" +
|
* 检查发票代码、发票号码是否是领用过的
|
||||||
|
* @param supermarket_id
|
||||||
|
* @param invoice_number
|
||||||
|
* @param invoice_code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public InvoiceReceive checkReceive(int supermarket_id, String invoice_number, String invoice_code) {
|
||||||
|
if(!StrKit.notBlank(invoice_number, invoice_code)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long code = Long.parseLong(invoice_code);
|
||||||
|
String sql = "select cast(t.end_code as unsigned integer) - t.surplus, t.* from invoice_receive t\n" +
|
||||||
" where t.supermarket_id = ? \n" +
|
" where t.supermarket_id = ? \n" +
|
||||||
" and t.surplus > 0\n" +
|
" and t.invoice_number = ? \n" +
|
||||||
" order by t.start_code asc\n" +
|
" and t.end_code >= ? \n" +
|
||||||
|
" and cast(t.end_code as unsigned integer) - t.surplus < ? \n" +
|
||||||
" limit 1";
|
" limit 1";
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id);
|
InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id, invoice_number, code, code);
|
||||||
|
|
||||||
|
return receive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvoiceReceive foremostReceive(int supermarket_id, String invoice_number) {
|
||||||
|
String sql = "select * from invoice_receive t\n" +
|
||||||
|
" where t.supermarket_id = ? \n" +
|
||||||
|
" and t.invoice_number = ? \n" +
|
||||||
|
" and t.surplus > 0\n" +
|
||||||
|
" order by cast(t.start_code as unsigned integer) asc\n" +
|
||||||
|
" limit 1";
|
||||||
|
|
||||||
|
InvoiceReceive receive = InvoiceReceive.dao.findFirst(sql, supermarket_id, invoice_number);
|
||||||
|
|
||||||
return receive;
|
return receive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String nextInvoice(InvoiceReceive receive) {
|
public String nextInvoiceCode(InvoiceReceive receive) {
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
log.debug("没有有效的发票领用记录");
|
log.debug("没有有效的发票领用记录");
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -62,13 +87,26 @@ public class InvoiceReceiveService extends BaseService {
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String nextInvoice(int supermarket_id) {
|
public List<Record> nextInvoiceCode(int supermarket_id) {
|
||||||
InvoiceReceive receive = foremostReceive(supermarket_id);
|
String sql = "select * from invoice_receive t\n" +
|
||||||
|
" where t.supermarket_id = ? \n" +
|
||||||
|
" and t.surplus > 0\n" +
|
||||||
|
" order by cast(t.start_code as unsigned integer) asc";
|
||||||
|
|
||||||
return nextInvoice(receive);
|
List<InvoiceReceive> receives = InvoiceReceive.dao.find(sql, supermarket_id);
|
||||||
|
List<Record> out = new ArrayList<>();
|
||||||
|
|
||||||
|
for (InvoiceReceive receive : receives) {
|
||||||
|
Record record = receive.toRecord();
|
||||||
|
record.set("next_invoice_code", nextInvoiceCode(receive));
|
||||||
|
|
||||||
|
out.add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp, Integer supermarket_id, String reveiver_user_name, String stm, String etm, Integer invoice_type) {
|
public Page<Record> find(PageParam pp, String invoice_number, Integer supermarket_id, String reveiver_user_name, String stm, String etm, Integer invoice_type) {
|
||||||
String selectsql = "select t.*, s.name supermarket_name, s.name2 supermarket_name2 ";
|
String selectsql = "select t.*, s.name supermarket_name, s.name2 supermarket_name2 ";
|
||||||
String fromsql = "from invoice_receive t \n" +
|
String fromsql = "from invoice_receive t \n" +
|
||||||
" left join supermarket s on s.id = t.supermarket_id" +
|
" left join supermarket s on s.id = t.supermarket_id" +
|
||||||
|
|
@ -80,17 +118,22 @@ public class InvoiceReceiveService extends BaseService {
|
||||||
paraList.add(supermarket_id);
|
paraList.add(supermarket_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StrKit.notBlank(reveiver_user_name)){
|
if (StrKit.notBlank(reveiver_user_name)) {
|
||||||
fromsql += " and t.receive_user_name like ? \n";
|
fromsql += " and t.receive_user_name like ? \n";
|
||||||
paraList.add("%" + reveiver_user_name + "%");
|
paraList.add("%" + reveiver_user_name + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StrKit.notBlank(stm)){
|
if (StrKit.notBlank(invoice_number)) {
|
||||||
|
fromsql += " and t.invoice_number like ? \n";
|
||||||
|
paraList.add("%" + invoice_number + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(stm)) {
|
||||||
fromsql += " and t.create_time >= ? \n";
|
fromsql += " and t.create_time >= ? \n";
|
||||||
paraList.add(stm);
|
paraList.add(stm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StrKit.notBlank(etm)){
|
if (StrKit.notBlank(etm)) {
|
||||||
fromsql += " and t.create_time <= ? \n";
|
fromsql += " and t.create_time <= ? \n";
|
||||||
paraList.add(etm);
|
paraList.add(etm);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public class InvoiceReceiveValidator extends CrudParamValidator {
|
||||||
validateString("id", 1, 32, "id", "id 长度 1~32");
|
validateString("id", 1, 32, "id", "id 长度 1~32");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateString("invoice_number", 1, 20, "invoice_number", "invoice_number 长度 1~20");
|
||||||
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");
|
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");
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,13 @@ public class InvoiceLogController extends Controller {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
Integer state = getInt("state");
|
Integer state = getInt("state");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
String order_sn = get("order_sn");
|
String order_sn = get("order_sn");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
String code = get("code");
|
String code = get("code");
|
||||||
Integer invoice_type = getInt("invoice_type");
|
Integer invoice_type = getInt("invoice_type");
|
||||||
renderJson(Result.object(InvoiceLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
|
renderJson(Result.object(InvoiceLogService.me.find(pp, invoice_number, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -85,10 +86,11 @@ public class InvoiceLogController extends Controller {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String code = get("code");
|
String code = get("code");
|
||||||
String invalid_memo = get("invalid_memo");
|
String invoice_number = get("invoice_number");
|
||||||
|
String invalid_memo = get("invalid_memo");
|
||||||
|
|
||||||
renderJson(InvoiceLogSyncService.me.cancelByCode(code, invalid_memo, tokenuser));
|
renderJson(InvoiceLogSyncService.me.cancelByCode(invoice_number, code, invalid_memo, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalid() {
|
public void invalid() {
|
||||||
|
|
@ -100,9 +102,10 @@ public class InvoiceLogController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer supermarket_id = getInt("supermarket_id", 0);
|
Integer supermarket_id = getInt("supermarket_id", 0);
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
String code = get("code");
|
String code = get("code");
|
||||||
String invalid_memo = get("invalid_memo");
|
String invalid_memo = get("invalid_memo");
|
||||||
|
|
||||||
renderJson(InvoiceLogSyncService.me.invalid(supermarket_id, code, invalid_memo, tokenuser));
|
renderJson(InvoiceLogSyncService.me.invalid(supermarket_id, invoice_number, code, invalid_memo, tokenuser));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Result invalid(int supermarket_id, String code, String invalid_memo, Sysuser sysuser){
|
public Result invalid(int supermarket_id, String invoice_number, String code, String invalid_memo, Sysuser sysuser){
|
||||||
Supermarket supermarket = Supermarket.dao.findById(supermarket_id);
|
Supermarket supermarket = Supermarket.dao.findById(supermarket_id);
|
||||||
|
|
||||||
if(supermarket == null){
|
if(supermarket == null){
|
||||||
|
|
@ -39,12 +39,12 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
return Result.failed("发票已使用,请使用“取消发票”功能");
|
return Result.failed("发票已使用,请使用“取消发票”功能");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(supermarket_id);
|
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(supermarket_id, invoice_number);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录");
|
return Result.failed("没有有效的发票领用记录");
|
||||||
}
|
}
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
String next_invoice_code = InvoiceReceiveService.me.nextInvoiceCode(receive);
|
||||||
if (next_invoice_code == null) {
|
if (next_invoice_code == null) {
|
||||||
return Result.failed("没有可用发票");
|
return Result.failed("没有可用发票");
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +62,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
invoiceLog.setState(OrderStateEnum.INVALID.getStateid());
|
invoiceLog.setState(OrderStateEnum.INVALID.getStateid());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
invoiceLog.setCode(code);
|
invoiceLog.setCode(code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
|
|
||||||
InvoiceLog finalInvoiceLog = invoiceLog;
|
InvoiceLog finalInvoiceLog = invoiceLog;
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
|
@ -101,8 +102,8 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
return ret ? Result.success(invoiceLog) : Result.failed(false, "处理失败");
|
return ret ? Result.success(invoiceLog) : Result.failed(false, "处理失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result cancelByCode(String code, String invalid_memo, Sysuser sysuser){
|
public Result cancelByCode(String invoice_number, String code, String invalid_memo, Sysuser sysuser){
|
||||||
InvoiceLog invoiceLog = InvoiceLog.dao.findFirst("select * from invoice_log t where code = ? limit 1 ", code);
|
InvoiceLog invoiceLog = InvoiceLog.dao.findFirst("select * from invoice_log t where invoice_number = ? and code = ? limit 1 ", invoice_number, code);
|
||||||
|
|
||||||
if (invoiceLog == null) {
|
if (invoiceLog == null) {
|
||||||
return Result.failed("未找到发票记录");
|
return Result.failed("未找到发票记录");
|
||||||
|
|
@ -151,6 +152,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
try{
|
try{
|
||||||
order.set("invoice_code", null);
|
order.set("invoice_code", null);
|
||||||
|
order.set("invoice_number", null);
|
||||||
boolean ret = order.update();
|
boolean ret = order.update();
|
||||||
|
|
||||||
if(!ret){
|
if(!ret){
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ import com.cowr.ssjygl.invoice.receive.InvoiceReceivePKValidator;
|
||||||
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
||||||
import com.jfinal.aop.Before;
|
import com.jfinal.aop.Before;
|
||||||
import com.jfinal.core.Controller;
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Thu Aug 13 23:09:29 CST 2020
|
* Generated by COWR Thu Aug 13 23:09:29 CST 2020
|
||||||
|
|
@ -35,10 +38,11 @@ public class InvoiceReceiveController extends Controller {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
String reveiver_user_name = get("reveiver_user_name");
|
String reveiver_user_name = get("reveiver_user_name");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
Integer invoice_type = getInt("invoice_type");
|
Integer invoice_type = getInt("invoice_type");
|
||||||
renderJson(Result.object(InvoiceReceiveService.me.find(pp, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
|
renderJson(Result.object(InvoiceReceiveService.me.find(pp, invoice_number, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,18 +66,12 @@ public class InvoiceReceiveController extends Controller {
|
||||||
public void nextInvoice() {
|
public void nextInvoice() {
|
||||||
Integer supermarket_id = getInt("supermarket_id", 0);
|
Integer supermarket_id = getInt("supermarket_id", 0);
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(supermarket_id);
|
List<Record> receives = InvoiceReceiveService.me.nextInvoiceCode(supermarket_id);
|
||||||
if (receive == null) {
|
if (receives == null || receives.isEmpty()) {
|
||||||
renderJson(Result.failed("没有有效的发票领用记录"));
|
renderJson(Result.failed("没有有效的发票领用记录"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
renderJson(Result.success(receives));
|
||||||
if (next_invoice_code == null) {
|
|
||||||
renderJson(Result.failed("没有可用发票"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderJson(Result.success(next_invoice_code));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,15 +51,17 @@ public class OrderTempController extends BaseController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uuid = get("uuid");
|
String uuid = get("uuid");
|
||||||
String transport_id = get("transport_id");
|
String transport_id = get("transport_id");
|
||||||
Integer product_id = getInt("product_id");
|
Integer product_id = getInt("product_id");
|
||||||
Integer pay_type = getInt("pay_type");
|
String invoice_number = get("invoice_number");
|
||||||
String memo = get("memo");
|
String invoice_code = get("invoice_code");
|
||||||
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
Integer pay_type = getInt("pay_type");
|
||||||
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
String memo = get("memo");
|
||||||
|
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
||||||
|
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
||||||
|
|
||||||
renderJson(OrderTempSyncService.me.pay(uuid, transport_id, product_id, pay_type, memo, printer, tokenuser, req_receipt));
|
renderJson(OrderTempSyncService.me.pay(uuid, transport_id, product_id, invoice_number, invoice_code, pay_type, memo, printer, tokenuser, req_receipt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -75,11 +77,13 @@ public class OrderTempController extends BaseController {
|
||||||
String uuid = get("uuid");
|
String uuid = get("uuid");
|
||||||
String transport_id = get("transport_id");
|
String transport_id = get("transport_id");
|
||||||
Integer ordercluster_id = getInt("ordercluster_id");
|
Integer ordercluster_id = getInt("ordercluster_id");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
|
String invoice_code = get("invoice_code");
|
||||||
String memo = get("memo");
|
String memo = get("memo");
|
||||||
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
||||||
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
||||||
|
|
||||||
renderJson(OrderTempSyncService.me.payordercluster(uuid, transport_id, ordercluster_id, memo, printer, tokenuser, req_receipt));
|
renderJson(OrderTempSyncService.me.payordercluster(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, memo, printer, tokenuser, req_receipt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(OrderTempPrepayValidator.class)
|
@Before(OrderTempPrepayValidator.class)
|
||||||
|
|
@ -94,12 +98,14 @@ public class OrderTempController extends BaseController {
|
||||||
String uuid = get("uuid");
|
String uuid = get("uuid");
|
||||||
String transport_id = get("transport_id");
|
String transport_id = get("transport_id");
|
||||||
Integer ordercluster_id = getInt("ordercluster_id");
|
Integer ordercluster_id = getInt("ordercluster_id");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
|
String invoice_code = get("invoice_code");
|
||||||
Integer product_id = getInt("product_id");
|
Integer product_id = getInt("product_id");
|
||||||
String memo = get("memo");
|
String memo = get("memo");
|
||||||
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
||||||
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
int req_receipt = getInt("req_receipt", 0); // 是否需要发票,0 默认不需要,1需要
|
||||||
|
|
||||||
renderJson(OrderTempSyncService.me.prepay(uuid, transport_id, ordercluster_id, product_id, memo, printer, tokenuser, req_receipt));
|
renderJson(OrderTempSyncService.me.prepay(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, product_id, memo, printer, tokenuser, req_receipt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,13 +136,15 @@ public class OrderTempController extends BaseController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sn = get("sn");
|
String sn = get("sn");
|
||||||
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
String invoice_number = get("invoice_number");
|
||||||
|
String invoice_code = get("invoice_code");
|
||||||
|
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
|
||||||
|
|
||||||
if (Integer.parseInt(sn.substring(10, 12)) != OrderTypeEnum.TEMP.getTypeid()) {
|
if (Integer.parseInt(sn.substring(10, 12)) != OrderTypeEnum.TEMP.getTypeid()) {
|
||||||
renderJson(Result.failed("sn 不能为 null"));
|
renderJson(Result.failed("sn 不能为 null"));
|
||||||
} else {
|
} else {
|
||||||
renderJson(OrderTempSyncService.me.invoice(sn, printer, tokenuser));
|
renderJson(OrderTempSyncService.me.invoice(sn, invoice_number, invoice_code, printer, tokenuser));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import com.jfinal.plugin.activerecord.IAtom;
|
||||||
import com.jfinal.plugin.activerecord.Record;
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class OrderTempSyncService {
|
public class OrderTempSyncService {
|
||||||
|
|
@ -36,6 +35,8 @@ public class OrderTempSyncService {
|
||||||
String uuid,
|
String uuid,
|
||||||
String transport_id,
|
String transport_id,
|
||||||
Integer product_id,
|
Integer product_id,
|
||||||
|
String invoice_number,
|
||||||
|
String invoice_code,
|
||||||
Integer pay_type,
|
Integer pay_type,
|
||||||
String memo,
|
String memo,
|
||||||
String printerId,
|
String printerId,
|
||||||
|
|
@ -52,14 +53,9 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录");
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
}
|
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
|
||||||
if (next_invoice_code == null) {
|
|
||||||
return Result.failed("没有可用发票");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Product product = Product.dao.findById(product_id);
|
Product product = Product.dao.findById(product_id);
|
||||||
|
|
@ -102,7 +98,8 @@ 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) { // 需要同时开具发票
|
||||||
order.setInvoiceCode(next_invoice_code);
|
order.setInvoiceCode(invoice_code);
|
||||||
|
order.setInvoiceNumber(invoice_number);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
order.setTransportId(transport.getId());
|
order.setTransportId(transport.getId());
|
||||||
|
|
@ -138,7 +135,6 @@ public class OrderTempSyncService {
|
||||||
transport.setState(order.getState()); // 使用 order 的 state
|
transport.setState(order.getState()); // 使用 order 的 state
|
||||||
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
String finalNext_invoice_code = next_invoice_code;
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
|
|
@ -168,19 +164,20 @@ public class OrderTempSyncService {
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
// 这里的 finalReceive 在前面肯定验证过了
|
// 这里的 finalReceive 在前面肯定验证过了
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
receive.setCurrentCode(finalNext_invoice_code);
|
receive.setCurrentCode(invoice_code);
|
||||||
|
|
||||||
ret = receive.update();
|
ret = receive.update();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log.error("发票领用信息更新失败", finalNext_invoice_code);
|
log.error("发票领用信息更新失败", invoice_code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceLog invoiceLog = new InvoiceLog();
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
invoiceLog.setId(StrKit.getRandomUUID());
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
invoiceLog.setCode(finalNext_invoice_code);
|
invoiceLog.setCode(invoice_code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
invoiceLog.setSettlementTime(now);
|
invoiceLog.setSettlementTime(now);
|
||||||
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
|
@ -221,6 +218,8 @@ public class OrderTempSyncService {
|
||||||
String uuid,
|
String uuid,
|
||||||
String transport_id,
|
String transport_id,
|
||||||
Integer ordercluster_id,
|
Integer ordercluster_id,
|
||||||
|
String invoice_number,
|
||||||
|
String invoice_code,
|
||||||
String memo,
|
String memo,
|
||||||
String printerId,
|
String printerId,
|
||||||
Sysuser sysuser,
|
Sysuser sysuser,
|
||||||
|
|
@ -236,14 +235,9 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录");
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
}
|
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
|
||||||
if (next_invoice_code == null) {
|
|
||||||
return Result.failed("没有可用发票");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
@ -309,7 +303,8 @@ public class OrderTempSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
order.setInvoiceCode(next_invoice_code);
|
order.setInvoiceCode(invoice_code);
|
||||||
|
order.setInvoiceNumber(invoice_number);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
order.setTransportId(transport.getId());
|
order.setTransportId(transport.getId());
|
||||||
|
|
@ -425,19 +420,20 @@ public class OrderTempSyncService {
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
// 这里的 finalReceive 在前面肯定验证过了
|
// 这里的 finalReceive 在前面肯定验证过了
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
receive.setCurrentCode(next_invoice_code);
|
receive.setCurrentCode(invoice_code);
|
||||||
|
|
||||||
ret = receive.update();
|
ret = receive.update();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log.error("发票领用信息更新失败", next_invoice_code);
|
log.error("发票领用信息更新失败", invoice_code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceLog invoiceLog = new InvoiceLog();
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
invoiceLog.setId(StrKit.getRandomUUID());
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
invoiceLog.setCode(next_invoice_code);
|
invoiceLog.setCode(invoice_code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
invoiceLog.setSettlementTime(now);
|
invoiceLog.setSettlementTime(now);
|
||||||
invoiceLog.setSettlementUserId(order.getSettlementUserId()); // 发票使用人
|
invoiceLog.setSettlementUserId(order.getSettlementUserId()); // 发票使用人
|
||||||
|
|
@ -475,6 +471,8 @@ public class OrderTempSyncService {
|
||||||
String uuid,
|
String uuid,
|
||||||
String transport_id,
|
String transport_id,
|
||||||
Integer ordercluster_id,
|
Integer ordercluster_id,
|
||||||
|
String invoice_number,
|
||||||
|
String invoice_code,
|
||||||
Integer product_id,
|
Integer product_id,
|
||||||
String memo,
|
String memo,
|
||||||
String printerId,
|
String printerId,
|
||||||
|
|
@ -498,14 +496,9 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(transport.getSupermarketId());
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录");
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
}
|
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
|
||||||
if (next_invoice_code == null) {
|
|
||||||
return Result.failed("没有可用发票");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
||||||
|
|
@ -605,7 +598,8 @@ public class OrderTempSyncService {
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
order.setInvoiceCode(next_invoice_code);
|
order.setInvoiceCode(invoice_code);
|
||||||
|
order.setInvoiceNumber(invoice_number);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
order.setTransportId(transport.getId());
|
order.setTransportId(transport.getId());
|
||||||
|
|
@ -713,19 +707,20 @@ public class OrderTempSyncService {
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
// 这里的 finalReceive 在前面肯定验证过了
|
// 这里的 finalReceive 在前面肯定验证过了
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
receive.setCurrentCode(next_invoice_code);
|
receive.setCurrentCode(invoice_code);
|
||||||
|
|
||||||
ret = receive.update();
|
ret = receive.update();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log.error("发票领用信息更新失败", next_invoice_code);
|
log.error("发票领用信息更新失败", invoice_code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceLog invoiceLog = new InvoiceLog();
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
invoiceLog.setId(StrKit.getRandomUUID());
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
invoiceLog.setCode(next_invoice_code);
|
invoiceLog.setCode(invoice_code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
invoiceLog.setSettlementTime(now);
|
invoiceLog.setSettlementTime(now);
|
||||||
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
|
@ -901,7 +896,7 @@ public class OrderTempSyncService {
|
||||||
return ret ? Result.success(order) : Result.failed("取消失败");
|
return ret ? Result.success(order) : Result.failed("取消失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result invoice(String sn, String printerId, Sysuser sysuser) {
|
public Result invoice(String sn, String invoice_number, String invoice_code, String printerId, Sysuser sysuser) {
|
||||||
// TODO: 判断权限
|
// TODO: 判断权限
|
||||||
|
|
||||||
OrderTemp order = OrderTemp.dao.findById(sn);
|
OrderTemp order = OrderTemp.dao.findById(sn);
|
||||||
|
|
@ -916,25 +911,21 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("订单已经取消");
|
return Result.failed("订单已经取消");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(order.getSupermarketId());
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(order.getSupermarketId(), invoice_number, invoice_code);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录");
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
}
|
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
|
||||||
if (next_invoice_code == null) {
|
|
||||||
return Result.failed("没有可用发票");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StrKit.notBlank(order.getInvoiceCode())) {
|
if (StrKit.notBlank(order.getInvoiceCode())) {
|
||||||
return Result.failedstr("请先将已开具的发票[%s]取消", order.getInvoiceCode());
|
return Result.failedstr("请先将已开具的发票[%s]取消", order.getInvoiceCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
order.setInvoiceCode(next_invoice_code);
|
order.setInvoiceCode(invoice_code);
|
||||||
|
order.setInvoiceNumber(invoice_number);
|
||||||
|
|
||||||
Record logrecord = new Record();
|
Record logrecord = new Record();
|
||||||
logrecord.set("sn", sn);
|
logrecord.set("sn", sn);
|
||||||
logrecord.set("invoice", next_invoice_code);
|
logrecord.set("invoice", invoice_code);
|
||||||
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -947,19 +938,20 @@ public class OrderTempSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
receive.setCurrentCode(next_invoice_code);
|
receive.setCurrentCode(invoice_code);
|
||||||
|
|
||||||
ret = receive.update();
|
ret = receive.update();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log.error("发票领用信息更新失败", next_invoice_code);
|
log.error("发票领用信息更新失败", invoice_code);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceLog invoiceLog = new InvoiceLog();
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
invoiceLog.setId(StrKit.getRandomUUID());
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
invoiceLog.setCode(next_invoice_code);
|
invoiceLog.setCode(invoice_code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
invoiceLog.setSettlementTime(new Date());
|
invoiceLog.setSettlementTime(new Date());
|
||||||
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
invoiceLog.setSettlementUserId(order.getSettlementUserId());
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ public class TransportQueryService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transobj.set("next_invoice_code", InvoiceReceiveService.me.nextInvoice(transport.getSupermarketId())); // TODO 专票?
|
// transobj.set("next_invoice_code", InvoiceReceiveService.me.nextInvoiceCode(transport.getSupermarketId())); // 2020-09-21 加了发票代码
|
||||||
|
transobj.set("invoice_numbers", InvoiceReceiveService.me.nextInvoiceCode(transport.getSupermarketId())); // TODO 专票?
|
||||||
|
|
||||||
return Result.success(transobj);
|
return Result.success(transobj);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,18 @@ jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx
|
||||||
user=dev_ssjy_xsx
|
user=dev_ssjy_xsx
|
||||||
password=Ssjy_xs_890
|
password=Ssjy_xs_890
|
||||||
|
|
||||||
#jdbcUrl=jdbc:mysql://192.168.20.2:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
|
#jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
|
||||||
#user=root
|
#user=root
|
||||||
#password=Ssjy_xsx_890
|
#password=Ssjy_xsx_890
|
||||||
|
|
||||||
# redis
|
# redis
|
||||||
redis.basekey=ssjcgl_xsx_dev
|
redis.basekey=ssjcgl_xsx_dev
|
||||||
#redis.ip=127.0.0.1
|
|
||||||
redis.ip=r-wz9168ab2f2f7ec4pd.redis.rds.aliyuncs.com
|
|
||||||
redis.port=6379
|
redis.port=6379
|
||||||
|
|
||||||
|
#redis.ip=127.0.0.1
|
||||||
|
#redis.pwd=
|
||||||
|
#redis.db=13
|
||||||
|
|
||||||
|
redis.ip=r-wz9168ab2f2f7ec4pd.redis.rds.aliyuncs.com
|
||||||
redis.pwd=CoWR1111
|
redis.pwd=CoWR1111
|
||||||
redis.db=13
|
redis.db=13
|
||||||
|
|
@ -36,12 +36,13 @@ public class InvoiceLogController extends Controller {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
Integer state = getInt("state");
|
Integer state = getInt("state");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
String order_sn = get("order_sn");
|
String order_sn = get("order_sn");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
String code = get("code");
|
String code = get("code");
|
||||||
Integer invoice_type = getInt("invoice_type");
|
Integer invoice_type = getInt("invoice_type");
|
||||||
renderJson(Result.object(InvoiceLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
|
renderJson(Result.object(InvoiceLogService.me.find(pp, invoice_number, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
||||||
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveValidator;
|
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveValidator;
|
||||||
import com.jfinal.aop.Before;
|
import com.jfinal.aop.Before;
|
||||||
import com.jfinal.core.Controller;
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Thu Aug 13 23:09:29 CST 2020
|
* Generated by COWR Thu Aug 13 23:09:29 CST 2020
|
||||||
|
|
@ -26,7 +29,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 不存在 data = false
|
* 不存在 data = false
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceivePKValidator.class)
|
@Before(InvoiceReceivePKValidator.class)
|
||||||
public void checkExistsByPk(){
|
public void checkExistsByPk() {
|
||||||
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
||||||
renderJson(InvoiceReceiveService.me.checkExistsByPk(model));
|
renderJson(InvoiceReceiveService.me.checkExistsByPk(model));
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +38,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 新增 invoice_receive 发票管理 - 领用记录
|
* 新增 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceiveValidator.class)
|
@Before(InvoiceReceiveValidator.class)
|
||||||
public void save(){
|
public void save() {
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
if (tokenuser == null) {
|
if (tokenuser == null) {
|
||||||
|
|
@ -51,7 +54,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 删除 invoice_receive 发票管理 - 领用记录
|
* 删除 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceivePKValidator.class)
|
@Before(InvoiceReceivePKValidator.class)
|
||||||
public void del(){
|
public void del() {
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
if (tokenuser == null) {
|
if (tokenuser == null) {
|
||||||
|
|
@ -67,7 +70,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 恢复 invoice_receive 发票管理 - 领用记录
|
* 恢复 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceivePKValidator.class)
|
@Before(InvoiceReceivePKValidator.class)
|
||||||
public void restore(){
|
public void restore() {
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
if (tokenuser == null) {
|
if (tokenuser == null) {
|
||||||
|
|
@ -83,7 +86,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 修改 invoice_receive 发票管理 - 领用记录
|
* 修改 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceiveValidator.class)
|
@Before(InvoiceReceiveValidator.class)
|
||||||
public void edit(){
|
public void edit() {
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
if (tokenuser == null) {
|
if (tokenuser == null) {
|
||||||
|
|
@ -98,21 +101,22 @@ public class InvoiceReceiveController extends Controller {
|
||||||
/**
|
/**
|
||||||
* 分页查找 invoice_receive 发票管理 - 领用记录
|
* 分页查找 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
public void find(){
|
public void find() {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
String reveiver_user_name = get("reveiver_user_name");
|
String reveiver_user_name = get("reveiver_user_name");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
Integer invoice_type = getInt("invoice_type");
|
Integer invoice_type = getInt("invoice_type");
|
||||||
renderJson(Result.object(InvoiceReceiveService.me.find(pp, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
|
renderJson(Result.object(InvoiceReceiveService.me.find(pp, invoice_number, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按主键查找单个对象 invoice_receive 发票管理 - 领用记录
|
* 按主键查找单个对象 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceivePKValidator.class)
|
@Before(InvoiceReceivePKValidator.class)
|
||||||
public void findByPk(){
|
public void findByPk() {
|
||||||
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
||||||
renderJson(InvoiceReceiveService.me.findByPk(model));
|
renderJson(InvoiceReceiveService.me.findByPk(model));
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +125,7 @@ public class InvoiceReceiveController extends Controller {
|
||||||
* 按主键查找单个对象 invoice_receive 发票管理 - 领用记录
|
* 按主键查找单个对象 invoice_receive 发票管理 - 领用记录
|
||||||
*/
|
*/
|
||||||
@Before(InvoiceReceivePKValidator.class)
|
@Before(InvoiceReceivePKValidator.class)
|
||||||
public void get(){
|
public void get() {
|
||||||
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
InvoiceReceive model = getModel(InvoiceReceive.class, "", true); // 忽略不在model中的字段
|
||||||
renderJson(InvoiceReceiveService.me.findByPk(model));
|
renderJson(InvoiceReceiveService.me.findByPk(model));
|
||||||
}
|
}
|
||||||
|
|
@ -129,18 +133,12 @@ public class InvoiceReceiveController extends Controller {
|
||||||
public void nextInvoice() {
|
public void nextInvoice() {
|
||||||
Integer supermarket_id = getInt("supermarket_id", 0);
|
Integer supermarket_id = getInt("supermarket_id", 0);
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.foremostReceive(supermarket_id);
|
List<Record> receives = InvoiceReceiveService.me.nextInvoiceCode(supermarket_id);
|
||||||
if (receive == null) {
|
if (receives == null || receives.isEmpty()) {
|
||||||
renderJson(Result.failed("没有有效的发票领用记录"));
|
renderJson(Result.failed("没有有效的发票领用记录"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String next_invoice_code = InvoiceReceiveService.me.nextInvoice(receive);
|
renderJson(Result.success(receives));
|
||||||
if (next_invoice_code == null) {
|
|
||||||
renderJson(Result.failed("没有可用发票"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderJson(Result.success(next_invoice_code));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,9 @@ public class InvoiceReceiveSyncService extends BaseSyncService {
|
||||||
Long end = Long.parseLong(receive.getEndCode());
|
Long end = Long.parseLong(receive.getEndCode());
|
||||||
|
|
||||||
List<InvoiceReceive> chklist = InvoiceReceive.dao.find("select * from invoice_receive t\n" +
|
List<InvoiceReceive> chklist = InvoiceReceive.dao.find("select * from invoice_receive t\n" +
|
||||||
" where ( t.start_code <= ? and t.end_code >= ? )\n" +
|
" where t.invoice_number = ? \n " +
|
||||||
" or ( t.start_code <= ? and t.end_code >= ? )", start, start, end, end);
|
" and (( t.start_code <= ? and t.end_code >= ? )\n" +
|
||||||
|
" or ( t.start_code <= ? and t.end_code >= ? ))", receive.getInvoiceNumber(), start, start, end, end);
|
||||||
|
|
||||||
if (!chklist.isEmpty()) {
|
if (!chklist.isEmpty()) {
|
||||||
return Result.failed("发票段和已领用的记录冲突");
|
return Result.failed("发票段和已领用的记录冲突");
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
Ordercluster model = new Ordercluster();
|
Ordercluster model = new Ordercluster();
|
||||||
model.setCustomerName(customer_name);
|
model.setCustomerName(customer_name);
|
||||||
|
model.setCustomerTexpayerName(customer_name);
|
||||||
|
|
||||||
// 判断是否需要开具发票
|
// 判断是否需要开具发票
|
||||||
// if (req_receipt == 1) {
|
// if (req_receipt == 1) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue