|
@@ -600,7 +600,14 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<FsStoreOrderListVO> selectFsStoreOrderListVO(FsStoreOrderParam param) {
|
|
public List<FsStoreOrderListVO> selectFsStoreOrderListVO(FsStoreOrderParam param) {
|
|
|
- return fsStoreOrderMapper.selectFsStoreOrderListVO(param);
|
|
|
|
|
|
|
+ List<FsStoreOrderListVO> list = fsStoreOrderMapper.selectFsStoreOrderListVO(param);
|
|
|
|
|
+
|
|
|
|
|
+ for (FsStoreOrderListVO vo : list) {
|
|
|
|
|
+ FsStoreOrderFinanceAudit audit = fsStoreOrderFinanceAuditMapper.selectByOrderId(vo.getOrderId());
|
|
|
|
|
+ vo.setIsApplyAudit(audit != null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1965,6 +1972,23 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
companyService.subtractCompanyMoney(order);
|
|
companyService.subtractCompanyMoney(order);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ FsStoreOrderItem queryItem = new FsStoreOrderItem();
|
|
|
|
|
+ queryItem.setOrderId(order.getOrderId());
|
|
|
|
|
+ List<FsStoreOrderItem> orderItems = fsStoreOrderItemMapper.selectFsStoreOrderItemList(queryItem);
|
|
|
|
|
+ if (orderItems != null && !orderItems.isEmpty()) {
|
|
|
|
|
+ for (FsStoreOrderItem item : orderItems) {
|
|
|
|
|
+ Long productId = item.getProductId();
|
|
|
|
|
+ Long productAttrValueId = item.getProductAttrValueId();
|
|
|
|
|
+ Long num = item.getNum() != null ? item.getNum() : 1L;
|
|
|
|
|
+
|
|
|
|
|
+ if (productAttrValueId != null && productAttrValueId > 0) {
|
|
|
|
|
+ fsStoreProductAttrValueMapper.decProductAttrStock(productAttrValueId, num.intValue());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fsStoreProductMapper.decStockIncSales(num, productId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
FsStore store = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
|
|
FsStore store = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
|
|
|
//订阅物流回调
|
|
//订阅物流回调
|
|
|
String lastFourNumber = "";
|
|
String lastFourNumber = "";
|
|
@@ -4703,6 +4727,87 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
return i;
|
|
return i;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStoreOrderFinanceAuditMapper fsStoreOrderFinanceAuditMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int applyFinanceAudit(List<Long> orderIds, Integer auditType,
|
|
|
|
|
+ BigDecimal newTotalPrice, BigDecimal newPayPrice,
|
|
|
|
|
+ String priceChangeReason, String voucherImages, String voucherRemark,
|
|
|
|
|
+ Long applyUserId, String applyUserName) {
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ for (Long orderId : orderIds) {
|
|
|
|
|
+ FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(orderId);
|
|
|
|
|
+ if (order == null) {
|
|
|
|
|
+ throw new CustomException("订单不存在:" + orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsStoreOrderFinanceAudit existAudit = fsStoreOrderFinanceAuditMapper.selectByOrderId(orderId);
|
|
|
|
|
+ if (existAudit != null && existAudit.getAuditStatus() == 0) {
|
|
|
|
|
+ throw new CustomException("订单已存在待审核记录:" + order.getOrderCode());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsStoreOrderFinanceAudit audit = new FsStoreOrderFinanceAudit();
|
|
|
|
|
+ audit.setOrderId(orderId);
|
|
|
|
|
+ audit.setOrderCode(order.getOrderCode());
|
|
|
|
|
+ audit.setAuditType(auditType);
|
|
|
|
|
+ audit.setOriginalTotalPrice(order.getTotalPrice());
|
|
|
|
|
+ audit.setOriginalPayPrice(order.getPayPrice());
|
|
|
|
|
+ audit.setNewTotalPrice(newTotalPrice);
|
|
|
|
|
+ audit.setNewPayPrice(newPayPrice);
|
|
|
|
|
+ audit.setPriceChangeReason(priceChangeReason);
|
|
|
|
|
+ audit.setVoucherImages(voucherImages);
|
|
|
|
|
+ audit.setVoucherRemark(voucherRemark);
|
|
|
|
|
+ audit.setAuditStatus(0);
|
|
|
|
|
+ audit.setApplyUserId(applyUserId);
|
|
|
|
|
+ audit.setApplyUserName(applyUserName);
|
|
|
|
|
+ audit.setApplyTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ count += fsStoreOrderFinanceAuditMapper.insertFsStoreOrderFinanceAudit(audit);
|
|
|
|
|
+ }
|
|
|
|
|
+ return count;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int auditFinanceAudit(Long auditId, Integer auditStatus, String auditRemark,
|
|
|
|
|
+ Long auditUserId, String auditUserName) {
|
|
|
|
|
+ FsStoreOrderFinanceAudit audit = fsStoreOrderFinanceAuditMapper.selectFsStoreOrderFinanceAuditById(auditId);
|
|
|
|
|
+ if (audit == null) {
|
|
|
|
|
+ throw new CustomException("审核记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (audit.getAuditStatus() != 0) {
|
|
|
|
|
+ throw new CustomException("该记录已审核,不能重复审核");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ audit.setAuditStatus(auditStatus);
|
|
|
|
|
+ audit.setAuditUserId(auditUserId);
|
|
|
|
|
+ audit.setAuditUserName(auditUserName);
|
|
|
|
|
+ audit.setAuditTime(new Date());
|
|
|
|
|
+ audit.setAuditRemark(auditRemark);
|
|
|
|
|
+
|
|
|
|
|
+ int result = fsStoreOrderFinanceAuditMapper.updateFsStoreOrderFinanceAudit(audit);
|
|
|
|
|
+
|
|
|
|
|
+ if (auditStatus == 1) {
|
|
|
|
|
+ FsStoreOrder order = new FsStoreOrder();
|
|
|
|
|
+ order.setOrderId(audit.getOrderId());
|
|
|
|
|
+
|
|
|
|
|
+ if (audit.getAuditType() == 1) {
|
|
|
|
|
+ order.setTotalPrice(audit.getNewTotalPrice());
|
|
|
|
|
+ order.setPayPrice(audit.getNewPayPrice());
|
|
|
|
|
+ order.setPayMoney(audit.getNewPayPrice());
|
|
|
|
|
+ } else if (audit.getAuditType() == 2) {
|
|
|
|
|
+ order.setStatus(4);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void createJSTOmsOrder(List<Long> orderIds) throws Exception {
|
|
public void createJSTOmsOrder(List<Long> orderIds) throws Exception {
|
|
|
// 1. 检查 ERP 是否开启
|
|
// 1. 检查 ERP 是否开启
|
|
@@ -4935,6 +5040,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
if (order == null) {
|
|
if (order == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if(order.getStoreId()== null){
|
|
|
|
|
+ log.warn("店铺id为空,订单对象:{}", order);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
|
|
|
ErpOrder erpOrder = new ErpOrder();
|
|
ErpOrder erpOrder = new ErpOrder();
|
|
|
if (order.getCompanyId() != null) {
|
|
if (order.getCompanyId() != null) {
|
|
|
erpOrder.setVip_code(order.getUserId().toString() + order.getCompanyId().toString());
|
|
erpOrder.setVip_code(order.getUserId().toString() + order.getCompanyId().toString());
|
|
@@ -4942,16 +5052,6 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
erpOrder.setVip_code(order.getUserId().toString());
|
|
erpOrder.setVip_code(order.getUserId().toString());
|
|
|
}
|
|
}
|
|
|
erpOrder.setPlatform_code(order.getOrderCode());
|
|
erpOrder.setPlatform_code(order.getOrderCode());
|
|
|
-// if(order.getStoreHouseCode()==null){
|
|
|
|
|
-// erpOrder.setWarehouse_code("CQDS001");
|
|
|
|
|
-// }else{
|
|
|
|
|
-// erpOrder.setWarehouse_code(order.getStoreHouseCode());
|
|
|
|
|
-// }
|
|
|
|
|
- if(order.getStoreId()== null){
|
|
|
|
|
- log.warn("店铺id为空,订单对象:{}", order);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
|
|
|
|
|
erpOrder.setShop_code(fsStore.getShopCode());
|
|
erpOrder.setShop_code(fsStore.getShopCode());
|
|
|
erpOrder.setSeller_memo(order.getRemark());
|
|
erpOrder.setSeller_memo(order.getRemark());
|
|
|
List<ErpOrderPayment> payments = new ArrayList<>();
|
|
List<ErpOrderPayment> payments = new ArrayList<>();
|
|
@@ -4963,7 +5063,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
if (order.getPayTime() != null) {
|
|
if (order.getPayTime() != null) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String timeString = sdf.format(order.getPayTime());
|
|
String timeString = sdf.format(order.getPayTime());
|
|
|
- Date date = sdf.parse(timeString); // 时间格式转为时间戳
|
|
|
|
|
|
|
+ Date date = sdf.parse(timeString);
|
|
|
long timeLong = date.getTime();
|
|
long timeLong = date.getTime();
|
|
|
payment.setPaytime(new Timestamp(timeLong));
|
|
payment.setPaytime(new Timestamp(timeLong));
|
|
|
}
|
|
}
|
|
@@ -5059,6 +5159,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
FsStoreOrderItem itemMap = new FsStoreOrderItem();
|
|
FsStoreOrderItem itemMap = new FsStoreOrderItem();
|
|
|
itemMap.setOrderId(order.getOrderId());
|
|
itemMap.setOrderId(order.getOrderId());
|
|
|
List<FsStoreOrderItem> orderItems = storeOrderItemService.selectFsStoreOrderItemList(itemMap);
|
|
List<FsStoreOrderItem> orderItems = storeOrderItemService.selectFsStoreOrderItemList(itemMap);
|
|
|
|
|
+ String deliveryCheckResult = checkDeliveryPermissionForErp(fsStore, orderItems);
|
|
|
|
|
+ if (deliveryCheckResult != null) {
|
|
|
|
|
+ log.warn("订单{}发货权限校验失败: {}", order.getOrderCode(), deliveryCheckResult);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
List<ErpOrderItem> details = new ArrayList<>();
|
|
List<ErpOrderItem> details = new ArrayList<>();
|
|
|
for (FsStoreOrderItem orderItem : orderItems) {
|
|
for (FsStoreOrderItem orderItem : orderItems) {
|
|
|
FsStoreCartDTO cartDTO = JSONUtil.toBean(orderItem.getJsonInfo(), FsStoreCartDTO.class);
|
|
FsStoreCartDTO cartDTO = JSONUtil.toBean(orderItem.getJsonInfo(), FsStoreCartDTO.class);
|
|
@@ -5187,4 +5292,47 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String checkDeliveryPermissionForErp(FsStore store, List<FsStoreOrderItem> orderItems) {
|
|
|
|
|
+ if (orderItems == null || orderItems.isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String storeChainBrands = store.getChainBrands();
|
|
|
|
|
+ Set<String> storeAllowedBrands = new HashSet<>();
|
|
|
|
|
+ if (storeChainBrands != null && !storeChainBrands.trim().isEmpty()) {
|
|
|
|
|
+ String[] brands = storeChainBrands.split(",");
|
|
|
|
|
+ for (String brand : brands) {
|
|
|
|
|
+ storeAllowedBrands.add(brand.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (FsStoreOrderItem item : orderItems) {
|
|
|
|
|
+ FsStoreProduct product = fsStoreProductMapper.selectFsStoreProductByProductId(item.getProductId());
|
|
|
|
|
+ if (product == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Integer productSourceType = product.getProductSourceType();
|
|
|
|
|
+ if (productSourceType == null) {
|
|
|
|
|
+ productSourceType = ProductSourceTypeEnum.SELF_STORE.getCode();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (ProductSourceTypeEnum.BIG_PACKAGE.getCode().equals(productSourceType)) {
|
|
|
|
|
+ String productChainBrand = product.getChainBrand();
|
|
|
|
|
+ if (productChainBrand == null || productChainBrand.trim().isEmpty()) {
|
|
|
|
|
+ return "商品【" + product.getProductName() + "】为大包品但未配置连锁品牌";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!storeAllowedBrands.contains(productChainBrand)) {
|
|
|
|
|
+ return "店铺无权发货大包品【" + product.getProductName() + "】,连锁品牌:" + productChainBrand;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (ProductSourceTypeEnum.SELF_STORE.getCode().equals(productSourceType)) {
|
|
|
|
|
+ if (!store.getStoreId().equals(product.getStoreId())) {
|
|
|
|
|
+ return "商品【" + product.getProductName() + "】为自库品,不属于当前店铺";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|