dev
parent
487b31b81a
commit
9b3624a0af
|
|
@ -0,0 +1,14 @@
|
|||
package com.cowr.model;
|
||||
|
||||
import com.cowr.model.base.BaseOssfileLog;
|
||||
|
||||
/**
|
||||
* Generated by COWR Wed Sep 30 00:04:42 CST 2020
|
||||
* TableName: ossfile_log
|
||||
* Remarks: 日志相关 - 文件上传至oss的状态日志
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class OssfileLog extends BaseOssfileLog<OssfileLog> {
|
||||
public static final OssfileLog dao = new OssfileLog().dao();
|
||||
}
|
||||
|
|
@ -49,6 +49,7 @@ public class _MappingKit {
|
|||
arp.addMapping("prepay_truck", "id", PrepayTruck.class);
|
||||
arp.addMapping("sms_log", "id", SmsLog.class);
|
||||
arp.addMapping("sync_task", "id", SyncTask.class);
|
||||
arp.addMapping("ossfile_log", "id", OssfileLog.class);
|
||||
arp.addMapping("modify_log", "id", ModifyLog.class);
|
||||
arp.addMapping("action_cmd_log", "id", ActionCmdLog.class);
|
||||
arp.addMapping("sysuser", "id", Sysuser.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,178 @@
|
|||
package com.cowr.model.base;
|
||||
|
||||
import com.cowr.common.base.BaseModel;
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Generated by COWR Wed Sep 30 00:04:42 CST 2020
|
||||
* TableName: ossfile_log
|
||||
* Remarks: 日志相关 - 文件上传至oss的状态日志
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class BaseOssfileLog<M extends BaseOssfileLog<M>> extends BaseModel<M> implements IBean {
|
||||
|
||||
public static final String tablename = "ossfile_log";
|
||||
|
||||
@JSONField(serialize=false)
|
||||
public String getTablename(){
|
||||
return tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* name: id
|
||||
* type: CHAR(32)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: YES
|
||||
* defaultValue:
|
||||
* @param id uuid
|
||||
*/
|
||||
@JSONField(name="id")
|
||||
public void setId(String id) {
|
||||
set("id", id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return id uuid
|
||||
*/
|
||||
@JSONField(name="id")
|
||||
public String getId() {
|
||||
return getStr("id");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: transport_id
|
||||
* type: CHAR(32)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param transportId transport id
|
||||
*/
|
||||
@JSONField(name="transport_id")
|
||||
public void setTransportId(String transportId) {
|
||||
set("transport_id", transportId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return transport_id transport id
|
||||
*/
|
||||
@JSONField(name="transport_id")
|
||||
public String getTransportId() {
|
||||
return getStr("transport_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: state
|
||||
* type: SMALLINT(5)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param state 0 待上传,1上传成功
|
||||
*/
|
||||
@JSONField(name="state")
|
||||
public void setState(Integer state) {
|
||||
set("state", state);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return state 0 待上传,1上传成功
|
||||
*/
|
||||
@JSONField(name="state")
|
||||
public Integer getState() {
|
||||
return getInt("state");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: osskey
|
||||
* type: VARCHAR(255)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param osskey
|
||||
*/
|
||||
@JSONField(name="osskey")
|
||||
public void setOsskey(String osskey) {
|
||||
set("osskey", osskey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return osskey
|
||||
*/
|
||||
@JSONField(name="osskey")
|
||||
public String getOsskey() {
|
||||
return getStr("osskey");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: absolutepath
|
||||
* type: VARCHAR(255)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param absolutepath 文件绝对路径
|
||||
*/
|
||||
@JSONField(name="absolutepath")
|
||||
public void setAbsolutepath(String absolutepath) {
|
||||
set("absolutepath", absolutepath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return absolutepath 文件绝对路径
|
||||
*/
|
||||
@JSONField(name="absolutepath")
|
||||
public String getAbsolutepath() {
|
||||
return getStr("absolutepath");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: create_time
|
||||
* type: DATETIME(19)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param createTime 创建时间
|
||||
*/
|
||||
@JSONField(name="create_time")
|
||||
public void setCreateTime(java.util.Date createTime) {
|
||||
set("create_time", createTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return create_time 创建时间
|
||||
*/
|
||||
@JSONField(name="create_time")
|
||||
public java.util.Date getCreateTime() {
|
||||
return get("create_time");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: change_time
|
||||
* type: TIMESTAMP(19)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue: CURRENT_TIMESTAMP
|
||||
* @param changeTime 最后修改时间
|
||||
*/
|
||||
@JSONField(name="change_time")
|
||||
public void setChangeTime(java.util.Date changeTime) {
|
||||
set("change_time", changeTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return change_time 最后修改时间
|
||||
*/
|
||||
@JSONField(name="change_time")
|
||||
public java.util.Date getChangeTime() {
|
||||
return get("change_time");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -73,6 +73,7 @@ public class Main {
|
|||
"invoice_receive",
|
||||
"invoice_log",
|
||||
"sms_log",
|
||||
"ossfile_log",
|
||||
};
|
||||
|
||||
PropKit.use("db.properties");
|
||||
|
|
|
|||
|
|
@ -15,11 +15,10 @@ import com.jfinal.kit.StrKit;
|
|||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.IAtom;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class InvoiceLogSyncService extends BaseSyncService {
|
||||
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
||||
|
|
@ -27,6 +26,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
|
||||
/**
|
||||
* 添加专票
|
||||
*
|
||||
* @param invoice_number
|
||||
* @param invoice_code
|
||||
* @param order_sns
|
||||
|
|
@ -56,7 +56,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
List<InvoiceLog> logs = new ArrayList<>();
|
||||
SyncTask synctask = new SyncTask();
|
||||
Map<Integer, SyncTask> map = new HashMap<>();
|
||||
|
||||
for (OrderTemp o : list) {
|
||||
InvoiceLog invoiceLog = new InvoiceLog();
|
||||
|
|
@ -73,14 +73,19 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
|
||||
logs.add(invoiceLog);
|
||||
|
||||
synctask.addSaveData(invoiceLog);
|
||||
|
||||
o.setInvoiceSite(2);
|
||||
o.setInvoiceType(2);
|
||||
o.setInvoiceNumber(invoice_number);
|
||||
o.setInvoiceCode(invoice_code);
|
||||
|
||||
synctask.addUpdateData(o);
|
||||
int supermarket_id = o.getSupermarketId();
|
||||
|
||||
if (!map.containsKey(supermarket_id)) {
|
||||
map.put(supermarket_id, new SyncTask());
|
||||
}
|
||||
|
||||
map.get(supermarket_id).addUpdateData(o);
|
||||
map.get(supermarket_id).addSaveData(invoiceLog);
|
||||
}
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
|
|
@ -105,7 +110,15 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
}
|
||||
}
|
||||
|
||||
return SyncTaskService.me.save(synctask);
|
||||
|
||||
// 将订单同步到不同的超市
|
||||
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
|
|
@ -118,6 +131,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
|
||||
/**
|
||||
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Result invalid(int supermarket_id, String invoice_number, String code, String invalid_memo, Sysuser sysuser) {
|
||||
|
|
@ -203,7 +217,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
return Result.failed("未找到发票记录");
|
||||
}
|
||||
|
||||
return cancel(invoiceLog, invalid_memo, sysuser);
|
||||
return cancelType1(invoiceLog, invalid_memo, sysuser);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -214,16 +228,24 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
return Result.failed("未找到发票记录");
|
||||
}
|
||||
|
||||
return cancel(invoiceLog, invalid_memo, sysuser);
|
||||
if (invoiceLog.getInvoiceType() == 1) {
|
||||
return cancelType1(invoiceLog, invalid_memo, sysuser);
|
||||
} else if (invoiceLog.getInvoiceType() == 2) {
|
||||
return cancelType2(invoiceLog, invalid_memo, sysuser);
|
||||
} else {
|
||||
return Result.failed("发票记录错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消普票
|
||||
* 取消已使用的发票,必须关联了订单的
|
||||
*
|
||||
* @param invoiceLog
|
||||
* @param sysuser
|
||||
* @return
|
||||
*/
|
||||
public Result cancel(InvoiceLog invoiceLog, String invalid_memo, Sysuser sysuser){
|
||||
public Result cancelType1(InvoiceLog invoiceLog, String invalid_memo, Sysuser sysuser) {
|
||||
if (invoiceLog.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||
return Result.failed("记录已作废");
|
||||
}
|
||||
|
|
@ -247,7 +269,6 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
try {
|
||||
order.set("invoice_code", null);
|
||||
order.set("invoice_number", null);
|
||||
order.set("invoice_type", null);
|
||||
order.set("invoice_site", null);
|
||||
boolean ret = order.update();
|
||||
|
||||
|
|
@ -276,4 +297,134 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
|||
|
||||
return ret ? Result.success() : Result.failed("作废失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消专票
|
||||
* 2020-09-29 一个专票可以关联多个订单,取消专票需要将关联的订单都取消发票信息
|
||||
*
|
||||
* @param invoiceLog
|
||||
* @param invalid_memo
|
||||
* @param sysuser
|
||||
* @return
|
||||
*/
|
||||
public Result cancelType2(InvoiceLog invoiceLog, String invalid_memo, Sysuser sysuser) {
|
||||
if (invoiceLog.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||
return Result.failed("记录已作废");
|
||||
}
|
||||
|
||||
List<OrderTemp> ordlist = OrderTemp.dao.find("select * from order_temp t \n" +
|
||||
" where t.state = ? \n" +
|
||||
" and t.invoice_type = ? \n" +
|
||||
" and t.invoice_number = ? \n" +
|
||||
" and t.invoice_code = ? ",
|
||||
OrderStateEnum.RECEIVED.getStateid(),
|
||||
invoiceLog.getInvoiceType(),
|
||||
invoiceLog.getInvoiceNumber(),
|
||||
invoiceLog.getCode()
|
||||
);
|
||||
|
||||
if (ordlist.isEmpty()) {
|
||||
return Result.failed("关联订单信息错误");
|
||||
}
|
||||
|
||||
List<InvoiceLog> loglist = InvoiceLog.dao.find("select * from invoice_log t \n" +
|
||||
" where t.state = ? \n" +
|
||||
" and t.invoice_type = ? \n" +
|
||||
" and t.invoice_number = ? \n" +
|
||||
" and t.code = ? ",
|
||||
OrderStateEnum.RECEIVED.getStateid(),
|
||||
invoiceLog.getInvoiceType(),
|
||||
invoiceLog.getInvoiceNumber(),
|
||||
invoiceLog.getCode()
|
||||
);
|
||||
|
||||
if (ordlist.isEmpty()) {
|
||||
return Result.failed("发票使用信息错误");
|
||||
}
|
||||
|
||||
Map<Integer, SyncTask> map = new HashMap<>();
|
||||
Map<String, OrderTemp> ordmap = new HashMap<>();
|
||||
Date now = new Date();
|
||||
Record logrecord = new Record();
|
||||
|
||||
logrecord.set("state", OrderStateEnum.INVALID.getStateid());
|
||||
logrecord.set("invoice_type", invoiceLog.getInvoiceType());
|
||||
logrecord.set("invoice_number", invoiceLog.getInvoiceNumber());
|
||||
logrecord.set("invoice_code", invoiceLog.getCode());
|
||||
|
||||
for (OrderTemp o : ordlist) {
|
||||
o.setInvoiceCode(null);
|
||||
o.setInvoiceNumber(null);
|
||||
o.setInvoiceSite(null);
|
||||
|
||||
int supermarket_id = o.getSupermarketId();
|
||||
|
||||
if (!map.containsKey(supermarket_id)) {
|
||||
map.put(supermarket_id, new SyncTask());
|
||||
}
|
||||
|
||||
map.get(supermarket_id).addUpdateData(o);
|
||||
ordmap.put(o.getSn(), o);
|
||||
}
|
||||
|
||||
for (InvoiceLog o : loglist) {
|
||||
o.setInvalidMemo(invalid_memo);
|
||||
o.setInvalidTime(now);
|
||||
o.setInvalidUserId(sysuser.getId());
|
||||
o.setInvalidUserName(sysuser.getName());
|
||||
o.setState(OrderStateEnum.INVALID.getStateid());
|
||||
|
||||
if (!ordmap.containsKey(o.getOrderSn())) {
|
||||
return Result.failedstr("发票[%s|%s]未找到订单信息", o.getInvoiceNumber(), o.getCode());
|
||||
}
|
||||
|
||||
int supermarket_id = ordmap.get(o.getOrderSn()).getSupermarketId();
|
||||
|
||||
if (!map.containsKey(supermarket_id)) {
|
||||
map.put(supermarket_id, new SyncTask());
|
||||
}
|
||||
|
||||
map.get(supermarket_id).addUpdateData(o);
|
||||
}
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
try {
|
||||
int[] editret = Db.batchUpdate(ordlist, ordlist.size());
|
||||
|
||||
for (int i : editret) {
|
||||
// 必须是每条 sql 修改一条记录
|
||||
if (i != 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
editret = Db.batchUpdate(loglist, loglist.size());
|
||||
|
||||
for (int i : editret) {
|
||||
// 必须是每条 sql 修改一条记录
|
||||
if (i != 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 将订单同步到不同的超市
|
||||
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ModifyLogService.me.save(InvoiceLog.tablename, "id", logrecord.toJson(), Enums.DataOpType.SAVE.getId(), sysuser);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ret ? Result.success() : Result.failed("修改失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue