订单作废审核
parent
7a64083b64
commit
7a99ee5a82
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.cowr.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Oct 23 17:41:51 CST 2020
|
||||||
|
* TableName: order_invalid_verify
|
||||||
|
* Remarks: 订单相关 - 订单作废申请
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class OrderInvalidVerifyPKValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
validateString("id", 1, 32, "id", "id 长度 1~32");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package com.cowr.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.cowr.common.Const;
|
||||||
|
import com.cowr.common.base.BaseService;
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.Page;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Oct 23 17:41:51 CST 2020
|
||||||
|
* TableName: order_invalid_verify
|
||||||
|
* Remarks: 订单相关 - 订单作废申请
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class OrderInvalidVerifyService extends BaseService {
|
||||||
|
public static final OrderInvalidVerifyService me = new OrderInvalidVerifyService();
|
||||||
|
|
||||||
|
public Page<Record> find(
|
||||||
|
PageParam pp,
|
||||||
|
String stm,
|
||||||
|
String etm,
|
||||||
|
Integer state,
|
||||||
|
String create_user_name,
|
||||||
|
Integer supermarket_id,
|
||||||
|
String order_sn
|
||||||
|
) {
|
||||||
|
String selectsql = "select t.*, s.name supermarket_name ";
|
||||||
|
String fromsql = "from order_invalid_verify t \n" +
|
||||||
|
" left join supermarket s on s.id = t.supermarket_id \n" +
|
||||||
|
" where 1=1 ";
|
||||||
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
||||||
|
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(order_sn)) {
|
||||||
|
fromsql += " and t.order_sn like ? \n";
|
||||||
|
paraList.add("%" + order_sn.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(create_user_name)) {
|
||||||
|
fromsql += " and t.create_user_name like ? \n";
|
||||||
|
paraList.add("%" + create_user_name.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supermarket_id != null) {
|
||||||
|
fromsql += " and t.supermarket_id = ? \n";
|
||||||
|
paraList.add(supermarket_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != null) {
|
||||||
|
fromsql += " and t.state = ? \n";
|
||||||
|
paraList.add(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
String totalRowSql = "select count(*) " + fromsql;
|
||||||
|
String findSql = selectsql + fromsql;
|
||||||
|
|
||||||
|
// 前端传了排序字段,并且排序字段存在相关表中
|
||||||
|
if (StrKit.notBlank(pp.getSort_field()) && OrderInvalidVerify.dao.hasColunm(pp.getSort_field())) {
|
||||||
|
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
|
||||||
|
|
||||||
|
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
|
||||||
|
findSql += " " + Const.ORDER_BY_ASC;
|
||||||
|
} else {
|
||||||
|
findSql += " " + Const.ORDER_BY_DESC;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
findSql += " order by t.create_time desc ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderInvalidVerify> list() {
|
||||||
|
return OrderInvalidVerify.dao.find("select * from order_invalid_verify");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.cowr.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Oct 23 17:41:51 CST 2020
|
||||||
|
* TableName: order_invalid_verify
|
||||||
|
* Remarks: 订单相关 - 订单作废申请
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class OrderInvalidVerifyValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateString("order_sn", 1, 16, "order_sn", "order_sn 长度 1~16");
|
||||||
|
validateString("invalid_memo", 1, 255, "invalid_memo", "invalid_memo 长度 1~255");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -86,6 +86,17 @@ public class InvoiceInvalidVerifySyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result save(InvoiceInvalidVerify model, Sysuser sysuser) {
|
public Result save(InvoiceInvalidVerify model, Sysuser sysuser) {
|
||||||
|
InvoiceInvalidVerify old = InvoiceInvalidVerify.dao.findFirst(
|
||||||
|
"select * from invoice_invalid_verify t \n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and t.invoice_number = ? \n" +
|
||||||
|
" and t.invoice_code = ? \n" +
|
||||||
|
" limit 1", 1, model.getInvoiceNumber(), model.getInvoiceCode());
|
||||||
|
|
||||||
|
if (old != null) {
|
||||||
|
return Result.failedstr("发票 %s|%s 已提交申请", model.getInvoiceNumber(), model.getInvoiceCode());
|
||||||
|
}
|
||||||
|
|
||||||
// 先判断这张发票有没有被领用
|
// 先判断这张发票有没有被领用
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(CliCacheData.SUP.getId(), model.getInvoiceNumber(), model.getInvoiceCode());
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(CliCacheData.SUP.getId(), model.getInvoiceNumber(), model.getInvoiceCode());
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.cowr.common.oss.OSSKit;
|
||||||
import com.cowr.local.ssjygl.customer.pact.CustomerPactController;
|
import com.cowr.local.ssjygl.customer.pact.CustomerPactController;
|
||||||
import com.cowr.local.ssjygl.customer.supermarketproduct.CustomerSupermarketProductController;
|
import com.cowr.local.ssjygl.customer.supermarketproduct.CustomerSupermarketProductController;
|
||||||
import com.cowr.local.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController;
|
import com.cowr.local.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController;
|
||||||
|
import com.cowr.local.ssjygl.order.invalidverify.OrderInvalidVerifyController;
|
||||||
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
|
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
|
||||||
import com.cowr.local.ssjygl.authlicense.AuthLicenseController;
|
import com.cowr.local.ssjygl.authlicense.AuthLicenseController;
|
||||||
import com.cowr.local.ssjygl.authlicense.AuthLicenseSyncService;
|
import com.cowr.local.ssjygl.authlicense.AuthLicenseSyncService;
|
||||||
|
|
@ -93,7 +94,7 @@ public class Config extends JFinalConfig {
|
||||||
public static DeviceThread deviceThread = new DeviceThread();
|
public static DeviceThread deviceThread = new DeviceThread();
|
||||||
public static SocketIOService socketio = null;
|
public static SocketIOService socketio = null;
|
||||||
private static boolean client_run = true;
|
private static boolean client_run = true;
|
||||||
public static final String CLINET_VERSION = "20201023";
|
public static final String CLINET_VERSION = "20201024";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
@ -218,6 +219,7 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/order/trash", OrderTrashController.class);
|
me.add("/order/trash", OrderTrashController.class);
|
||||||
me.add("/order/purchase", OrderPurchaseController.class);
|
me.add("/order/purchase", OrderPurchaseController.class);
|
||||||
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
||||||
|
me.add("/order/invalidverify", OrderInvalidVerifyController.class);
|
||||||
|
|
||||||
// -- 统计
|
// -- 统计
|
||||||
me.add("/stat/sale", OrderStatController.class);
|
me.add("/stat/sale", OrderStatController.class);
|
||||||
|
|
@ -345,6 +347,8 @@ public class Config extends JFinalConfig {
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName());
|
log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName());
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
|
log.info("============= 最大限重 %s 吨 =================", configprop.getInt("weigh.max"));
|
||||||
|
log.info("====================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
StockSyncService.me.initSupermarketStock();
|
StockSyncService.me.initSupermarketStock();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.cowr.local.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.ssjygl.order.invalidverify.OrderInvalidVerifyService;
|
||||||
|
import com.cowr.ssjygl.order.invalidverify.OrderInvalidVerifyValidator;
|
||||||
|
import com.jfinal.aop.Before;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Oct 23 17:41:51 CST 2020
|
||||||
|
* TableName: order_invalid_verify
|
||||||
|
* Remarks: 订单相关 - 订单作废申请
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class OrderInvalidVerifyController extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增 order_invalid_verify 订单相关 - 订单作废申请
|
||||||
|
*/
|
||||||
|
@Before(OrderInvalidVerifyValidator.class)
|
||||||
|
public void save() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String order_sn = get("order_sn");
|
||||||
|
String invalid_memo = get("invalid_memo");
|
||||||
|
|
||||||
|
renderJson(OrderInvalidVerifySyncService.me.save(order_sn, invalid_memo, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查找 order_invalid_verify 订单相关 - 订单作废申请
|
||||||
|
*/
|
||||||
|
public void find() {
|
||||||
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
|
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
String order_sn = get("order_sn");
|
||||||
|
String create_user_name = get("create_user_name");
|
||||||
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
|
Integer state = getInt("state");
|
||||||
|
|
||||||
|
renderJson(Result.object(OrderInvalidVerifyService.me.find(pp, stm, etm, state, create_user_name, supermarket_id, order_sn)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.cowr.local.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.cowr.common.enums.OrderStateEnum;
|
||||||
|
import com.cowr.common.enums.OrderTypeEnum;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.local.ssjygl.main.CliCacheData;
|
||||||
|
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
import com.cowr.model.OrderTemp;
|
||||||
|
import com.cowr.model.SyncTask;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class OrderInvalidVerifySyncService {
|
||||||
|
private static Log log = Log.getLog(OrderInvalidVerifySyncService.class);
|
||||||
|
public static OrderInvalidVerifySyncService me = new OrderInvalidVerifySyncService();
|
||||||
|
|
||||||
|
public Result save(String order_sn, String invalid_memo, Sysuser sysuser) {
|
||||||
|
OrderTemp order = OrderTemp.dao.findById(order_sn);
|
||||||
|
|
||||||
|
if (order == null) {
|
||||||
|
return Result.failedstr("按 %s 没有找到订单信息", order_sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(order.getState() != OrderStateEnum.RECEIVED.getStateid()){
|
||||||
|
return Result.failed("只能对已收货的订单提出作废申请");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order.getInvoiceType() == 2) {
|
||||||
|
return Result.failed("专票作废只能由财务处理");
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderInvalidVerify old = OrderInvalidVerify.dao.findFirst("select * from order_invalid_verify t \n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and t.order_sn = ? \n" +
|
||||||
|
" limit 1", 1, order_sn);
|
||||||
|
|
||||||
|
if (old != null) {
|
||||||
|
return Result.failedstr("订单 %s 已提交申请", order_sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderInvalidVerify model = new OrderInvalidVerify();
|
||||||
|
model.setId(StrKit.getRandomUUID());
|
||||||
|
model.setSupermarketId(CliCacheData.SUP.getId());
|
||||||
|
model.setCreateTime(new Date());
|
||||||
|
model.setCreateUserId(sysuser.getId());
|
||||||
|
model.setCreateUserName(sysuser.getName());
|
||||||
|
model.setOrderSn(order.getSn());
|
||||||
|
model.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
model.setInvalidMemo(invalid_memo);
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
try {
|
||||||
|
boolean ret = model.save();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addSaveData(model);
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success(model) : Result.failed("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,9 +15,9 @@ socketserver.port=21002
|
||||||
socketio.port=12002
|
socketio.port=12002
|
||||||
|
|
||||||
#当前部署本地程序的砂站id
|
#当前部署本地程序的砂站id
|
||||||
current.supermarket_id=1
|
current.supermarket_id=6
|
||||||
#落杆后,等待上磅的时间
|
#落杆后,等待上磅的时间
|
||||||
default_scale_wait_time=5000
|
default_scale_wait_time=8000
|
||||||
|
|
||||||
#最大毛重不超过 49 吨,超过 49 吨不能上高速
|
#最大毛重不超过 49 吨,超过 49 吨不能上高速
|
||||||
#2020-10-16 盐港都是小磅,最大只能40
|
#2020-10-16 盐港都是小磅,最大只能40
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ socketio.port=12002
|
||||||
#当前部署本地程序的砂站id
|
#当前部署本地程序的砂站id
|
||||||
current.supermarket_id=6
|
current.supermarket_id=6
|
||||||
#落杆后,等待上磅的时间
|
#落杆后,等待上磅的时间
|
||||||
default_scale_wait_time=5000
|
default_scale_wait_time=8000
|
||||||
#最大毛重不超过 49 吨,超过 49 吨不能上高速
|
#最大毛重不超过 49 吨,超过 49 吨不能上高速
|
||||||
#2020-10-16 盐港都是小磅,最大只能40
|
#2020-10-16 盐港都是小磅,最大只能40
|
||||||
weigh.max=49
|
weigh.max=49
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ public class InvoiceInvalidVerifySyncService {
|
||||||
return Result.failed("没有找到申请记录");
|
return Result.failed("没有找到申请记录");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.getState() == 9) {
|
||||||
|
return Result.failed("申请已作废");
|
||||||
|
}
|
||||||
|
|
||||||
if (model.getState() == state) {
|
if (model.getState() == state) {
|
||||||
return Result.failed("状态值没有变化");
|
return Result.failed("状态值没有变化");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyControl
|
||||||
import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
|
import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
|
||||||
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
|
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
|
||||||
import com.cowr.service.ssjygl.netty.NettyServer;
|
import com.cowr.service.ssjygl.netty.NettyServer;
|
||||||
|
import com.cowr.service.ssjygl.order.invalidverify.OrderInvalidVerifyController;
|
||||||
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
|
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
|
||||||
import com.cowr.service.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
|
import com.cowr.service.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
|
||||||
import com.cowr.service.ssjygl.order.orderpurchase.OrderPurchaseController;
|
import com.cowr.service.ssjygl.order.orderpurchase.OrderPurchaseController;
|
||||||
|
|
@ -185,6 +186,7 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/order/trash", OrderTrashController.class);
|
me.add("/order/trash", OrderTrashController.class);
|
||||||
me.add("/order/purchase", OrderPurchaseController.class);
|
me.add("/order/purchase", OrderPurchaseController.class);
|
||||||
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
||||||
|
me.add("/order/invalidverify", OrderInvalidVerifyController.class);
|
||||||
|
|
||||||
// -- 统计
|
// -- 统计
|
||||||
me.add("/stat/sale", OrderStatController.class);
|
me.add("/stat/sale", OrderStatController.class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.cowr.service.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyValidator;
|
||||||
|
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
|
import com.cowr.ssjygl.order.invalidverify.OrderInvalidVerifyService;
|
||||||
|
import com.jfinal.aop.Before;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by COWR Fri Oct 23 17:41:51 CST 2020
|
||||||
|
* TableName: order_invalid_verify
|
||||||
|
* Remarks: 订单相关 - 订单作废申请
|
||||||
|
* PrimaryKey: id
|
||||||
|
*/
|
||||||
|
public class OrderInvalidVerifyController extends Controller {
|
||||||
|
|
||||||
|
@Before(InvoiceInvalidVerifyValidator.class)
|
||||||
|
public void verify() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
} else if (!SysuserSyncService.me.isTreasurer(tokenuser.getRole())) { // 财务才能审核
|
||||||
|
renderJson(Result.permissionDenied());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String id = get("id");
|
||||||
|
int state = getInt("state", 0);
|
||||||
|
String memo = get("memo");
|
||||||
|
String password = get("password");
|
||||||
|
|
||||||
|
renderJson(OrderInvalidVerifySyncService.me.verify(id, state, memo, tokenuser, password));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查找 order_invalid_verify 订单相关 - 订单作废申请
|
||||||
|
*/
|
||||||
|
public void find() {
|
||||||
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
|
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
String order_sn = get("order_sn");
|
||||||
|
String create_user_name = get("create_user_name");
|
||||||
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
|
Integer state = getInt("state");
|
||||||
|
|
||||||
|
renderJson(Result.object(OrderInvalidVerifyService.me.find(pp, stm, etm, state, create_user_name, supermarket_id, order_sn)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.cowr.service.ssjygl.order.invalidverify;
|
||||||
|
|
||||||
|
import com.cowr.common.enums.OrderStateEnum;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.model.OrderInvalidVerify;
|
||||||
|
import com.cowr.model.SyncTask;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.service.ssjygl.order.ordertemp.OrderTempSyncService;
|
||||||
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
|
|
||||||
|
public class OrderInvalidVerifySyncService {
|
||||||
|
private static Log log = Log.getLog(OrderInvalidVerifySyncService.class);
|
||||||
|
public static OrderInvalidVerifySyncService me = new OrderInvalidVerifySyncService();
|
||||||
|
|
||||||
|
public Result verify(String id, int state, String memo, Sysuser user, String password) {
|
||||||
|
if (state != 2 && state != 9) {
|
||||||
|
return Result.failed("state 值错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderInvalidVerify model = OrderInvalidVerify.dao.findById(id);
|
||||||
|
|
||||||
|
if (model == null) {
|
||||||
|
return Result.failed("没有找到申请记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.getState() == 9) {
|
||||||
|
return Result.failed("申请已作废");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.getState() == state) {
|
||||||
|
return Result.failed("状态值没有变化");
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setVerifyUserId(user.getId());
|
||||||
|
model.setVerifyUserName(user.getName());
|
||||||
|
model.setMemo(memo);
|
||||||
|
model.setState(state);
|
||||||
|
|
||||||
|
if (state == OrderStateEnum.INVALID.getStateid()) {
|
||||||
|
return notPass(model);
|
||||||
|
} else if (state == 2) {
|
||||||
|
return OrderTempSyncService.me.cancel(model.getOrderSn(), model.getInvalidMemo(), user, password, model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Result notPass(OrderInvalidVerify model) {
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
try {
|
||||||
|
boolean ret = model.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(model);
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask, model.getSupermarketId());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success() : Result.failed("修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,10 @@ public class OrderTempSyncService {
|
||||||
private static Log log = Log.getLog(OrderTempSyncService.class);
|
private static Log log = Log.getLog(OrderTempSyncService.class);
|
||||||
|
|
||||||
public Result cancel(String sn, String invalid_memo, Sysuser sysuser, String password) {
|
public Result cancel(String sn, String invalid_memo, Sysuser sysuser, String password) {
|
||||||
|
return cancel(sn, invalid_memo, sysuser, password, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result cancel(String sn, String invalid_memo, Sysuser sysuser, String password, OrderInvalidVerify orderInvalidVerify) {
|
||||||
// TODO: 判断权限
|
// TODO: 判断权限
|
||||||
|
|
||||||
OrderTemp order = OrderTemp.dao.findById(sn);
|
OrderTemp order = OrderTemp.dao.findById(sn);
|
||||||
|
|
@ -55,6 +59,10 @@ public class OrderTempSyncService {
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
SyncTask synctaskincrement = new SyncTask();
|
SyncTask synctaskincrement = new SyncTask();
|
||||||
|
|
||||||
|
if(orderInvalidVerify != null){
|
||||||
|
synctask.addUpdateData(orderInvalidVerify);
|
||||||
|
}
|
||||||
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue