|
@@ -94,6 +94,7 @@ public class SalesOrderController {
|
|
|
order.setOrgId(orgId);
|
|
order.setOrgId(orgId);
|
|
|
order.setDelFlag("0");
|
|
order.setDelFlag("0");
|
|
|
order.setAuditStatus(1);
|
|
order.setAuditStatus(1);
|
|
|
|
|
+ order.setSource(1);
|
|
|
String username = getUsername();
|
|
String username = getUsername();
|
|
|
order.setId(null);
|
|
order.setId(null);
|
|
|
order.setCreateBy(username);
|
|
order.setCreateBy(username);
|
|
@@ -120,11 +121,24 @@ public class SalesOrderController {
|
|
|
throw new Exception("已审核的销售订单不能修改,请先反审核");
|
|
throw new Exception("已审核的销售订单不能修改,请先反审核");
|
|
|
}
|
|
}
|
|
|
String orgId = tokenService.getLoginOrgId(request);
|
|
String orgId = tokenService.getLoginOrgId(request);
|
|
|
|
|
+ if (!orgId.equals(old.getOrgId())) {
|
|
|
|
|
+ throw new Exception("销售订单不存在");
|
|
|
|
|
+ }
|
|
|
validateBeforeSave(order, orgId, false);
|
|
validateBeforeSave(order, orgId, false);
|
|
|
fillCustomerAndMarketInfo(order, orgId);
|
|
fillCustomerAndMarketInfo(order, orgId);
|
|
|
recalcGoodsSubTotalsAndOrderTotal(order);
|
|
recalcGoodsSubTotalsAndOrderTotal(order);
|
|
|
order.setOrgId(orgId);
|
|
order.setOrgId(orgId);
|
|
|
- order.setAuditStatus(1);
|
|
|
|
|
|
|
+ int oldSrc = old.getSource() == null ? 1 : old.getSource();
|
|
|
|
|
+ boolean h5Pending = oldSrc == 2 && (old.getAuditStatus() == null || old.getAuditStatus() == 0);
|
|
|
|
|
+ if (h5Pending) {
|
|
|
|
|
+ order.setAuditStatus(0);
|
|
|
|
|
+ order.setSource(2);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ order.setAuditStatus(1);
|
|
|
|
|
+ if (order.getSource() == null) {
|
|
|
|
|
+ order.setSource(old.getSource() != null ? old.getSource() : 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
String username = getUsername();
|
|
String username = getUsername();
|
|
|
order.setCreateBy(old.getCreateBy());
|
|
order.setCreateBy(old.getCreateBy());
|
|
|
order.setCreateTime(old.getCreateTime());
|
|
order.setCreateTime(old.getCreateTime());
|
|
@@ -547,6 +561,10 @@ public class SalesOrderController {
|
|
|
public AjaxResult audit(@RequestBody Map<String, String> params) throws Exception {
|
|
public AjaxResult audit(@RequestBody Map<String, String> params) throws Exception {
|
|
|
String id = params.get("id");
|
|
String id = params.get("id");
|
|
|
SalesOrder order = getActiveById(id);
|
|
SalesOrder order = getActiveById(id);
|
|
|
|
|
+ int src = order.getSource() == null ? 1 : order.getSource();
|
|
|
|
|
+ if (src == 2 && order.getAuditStatus() != null && order.getAuditStatus() != 0) {
|
|
|
|
|
+ throw new Exception("仅待审核的H5销售订单可审核");
|
|
|
|
|
+ }
|
|
|
order.setAuditStatus(1);
|
|
order.setAuditStatus(1);
|
|
|
order.setUpdateBy(getUsername());
|
|
order.setUpdateBy(getUsername());
|
|
|
order.setUpdateTime(new Date());
|
|
order.setUpdateTime(new Date());
|
|
@@ -1045,11 +1063,12 @@ public class SalesOrderController {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private QueryWrapper<SalesOrder> buildWrapper(SalesOrder query, String orgId) {
|
|
|
|
|
|
|
+ QueryWrapper<SalesOrder> buildWrapper(SalesOrder query, String orgId) {
|
|
|
QueryWrapper<SalesOrder> wrapper = new QueryWrapper<SalesOrder>()
|
|
QueryWrapper<SalesOrder> wrapper = new QueryWrapper<SalesOrder>()
|
|
|
.eq("org_id", orgId)
|
|
.eq("org_id", orgId)
|
|
|
.eq("del_flag", "0");
|
|
.eq("del_flag", "0");
|
|
|
if (query == null) {
|
|
if (query == null) {
|
|
|
|
|
+ wrapper.eq("audit_status", 1);
|
|
|
return wrapper;
|
|
return wrapper;
|
|
|
}
|
|
}
|
|
|
if (query.getDocumentDateStart() != null) {
|
|
if (query.getDocumentDateStart() != null) {
|
|
@@ -1081,12 +1100,17 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
if (query.getAuditStatus() != null) {
|
|
if (query.getAuditStatus() != null) {
|
|
|
wrapper.eq("audit_status", query.getAuditStatus());
|
|
wrapper.eq("audit_status", query.getAuditStatus());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.eq("audit_status", 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (query.getSource() != null && (query.getSource() == 1 || query.getSource() == 2)) {
|
|
|
|
|
+ wrapper.eq("source", query.getSource());
|
|
|
}
|
|
}
|
|
|
wrapper.orderByDesc("id");
|
|
wrapper.orderByDesc("id");
|
|
|
return wrapper;
|
|
return wrapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void validateBeforeSave(SalesOrder order, String orgId, boolean isAdd) throws Exception {
|
|
|
|
|
|
|
+ void validateBeforeSave(SalesOrder order, String orgId, boolean isAdd) throws Exception {
|
|
|
if (order == null) {
|
|
if (order == null) {
|
|
|
throw new Exception("参数不能为空");
|
|
throw new Exception("参数不能为空");
|
|
|
}
|
|
}
|
|
@@ -1131,7 +1155,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void fillCustomerAndMarketInfo(SalesOrder order, String orgId) throws Exception {
|
|
|
|
|
|
|
+ void fillCustomerAndMarketInfo(SalesOrder order, String orgId) throws Exception {
|
|
|
BaseCustomer customer = customerService.getOne(new QueryWrapper<BaseCustomer>()
|
|
BaseCustomer customer = customerService.getOne(new QueryWrapper<BaseCustomer>()
|
|
|
.eq("org_id", orgId)
|
|
.eq("org_id", orgId)
|
|
|
.eq("customer_num", order.getCustomerNum())
|
|
.eq("customer_num", order.getCustomerNum())
|
|
@@ -1158,7 +1182,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void enrichSalesOrderDisplay(SalesOrder order, String orgId) {
|
|
|
|
|
|
|
+ void enrichSalesOrderDisplay(SalesOrder order, String orgId) {
|
|
|
if (order == null) {
|
|
if (order == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1189,7 +1213,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void enrichGoodsFromMaterial(List<SalesOrderGoods> goods, String orgId) {
|
|
|
|
|
|
|
+ void enrichGoodsFromMaterial(List<SalesOrderGoods> goods, String orgId) {
|
|
|
if (goods == null || goods.isEmpty()) {
|
|
if (goods == null || goods.isEmpty()) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1227,7 +1251,7 @@ public class SalesOrderController {
|
|
|
* 单据编号规则:
|
|
* 单据编号规则:
|
|
|
* XSDD + 当前日期后一天的yyyyMMdd + 3位机器标识 + 3位递增序号(不足补零,从001开始)
|
|
* XSDD + 当前日期后一天的yyyyMMdd + 3位机器标识 + 3位递增序号(不足补零,从001开始)
|
|
|
*/
|
|
*/
|
|
|
- private String generateSalesOrderNum(String orgId) throws Exception {
|
|
|
|
|
|
|
+ String generateSalesOrderNum(String orgId) throws Exception {
|
|
|
if (StringUtils.isBlank(orgId)) {
|
|
if (StringUtils.isBlank(orgId)) {
|
|
|
throw new Exception("orgId不能为空");
|
|
throw new Exception("orgId不能为空");
|
|
|
}
|
|
}
|
|
@@ -1301,7 +1325,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 小计=单价×基本计量数量;总计金额=各明细小计之和 */
|
|
/** 小计=单价×基本计量数量;总计金额=各明细小计之和 */
|
|
|
- private void recalcGoodsSubTotalsAndOrderTotal(SalesOrder order) {
|
|
|
|
|
|
|
+ void recalcGoodsSubTotalsAndOrderTotal(SalesOrder order) {
|
|
|
List<SalesOrderGoods> goods = order.getGoods();
|
|
List<SalesOrderGoods> goods = order.getGoods();
|
|
|
if (goods == null || goods.isEmpty()) {
|
|
if (goods == null || goods.isEmpty()) {
|
|
|
order.setTotalAmount(null);
|
|
order.setTotalAmount(null);
|
|
@@ -1375,7 +1399,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** 按单据编号将原明细逻辑删除(修改订单时先标记旧清单 del_flag=2) */
|
|
/** 按单据编号将原明细逻辑删除(修改订单时先标记旧清单 del_flag=2) */
|
|
|
- private void deleteSalesOrderGoodsByOrderNum(String orgId, String orderNum) {
|
|
|
|
|
|
|
+ void deleteSalesOrderGoodsByOrderNum(String orgId, String orderNum) {
|
|
|
if (StringUtils.isBlank(orgId) || StringUtils.isBlank(orderNum)) {
|
|
if (StringUtils.isBlank(orgId) || StringUtils.isBlank(orderNum)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1389,7 +1413,7 @@ public class SalesOrderController {
|
|
|
.eq("del_flag", "0"));
|
|
.eq("del_flag", "0"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void saveGoods(SalesOrder order, String orgId, String username) {
|
|
|
|
|
|
|
+ void saveGoods(SalesOrder order, String orgId, String username) {
|
|
|
List<SalesOrderGoods> goods = order.getGoods();
|
|
List<SalesOrderGoods> goods = order.getGoods();
|
|
|
if (goods == null) {
|
|
if (goods == null) {
|
|
|
goods = Collections.emptyList();
|
|
goods = Collections.emptyList();
|
|
@@ -1408,7 +1432,7 @@ public class SalesOrderController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private SalesOrder getActiveById(String id) throws Exception {
|
|
|
|
|
|
|
+ SalesOrder getActiveById(String id) throws Exception {
|
|
|
SalesOrder order = salesOrderService.getById(id);
|
|
SalesOrder order = salesOrderService.getById(id);
|
|
|
if (order == null || !"0".equals(order.getDelFlag())) {
|
|
if (order == null || !"0".equals(order.getDelFlag())) {
|
|
|
throw new Exception("销售订单不存在");
|
|
throw new Exception("销售订单不存在");
|