Browse Source

卓美订单合并

yuhongqi 2 weeks ago
parent
commit
2d55d7b85c

+ 58 - 1
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java

@@ -295,6 +295,62 @@ public class FsStoreHealthOrderScrmController extends BaseController {
         }
         param.setIsHealth("1");
         List<FsStoreOrderItemExportVO> list = orderItemService.selectFsStoreOrderItemListExportVO(param);
+        if ("北京卓美".equals(signProjectName)) {
+            List<FsStoreOrderItemExportZMVO> zmvoList = list.stream()
+                    .map(vo -> {
+                        FsStoreOrderItemExportZMVO zmvo = new FsStoreOrderItemExportZMVO();
+                        try {
+                            BeanUtil.copyProperties(vo, zmvo);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                        return zmvo;
+                    })
+                    .collect(Collectors.toList());
+            if (zmvoList != null) {
+                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+                for (FsStoreOrderItemExportZMVO vo : zmvoList) {
+                    if("2".equals(vo.getOrderType())){
+                        vo.setOrderTypeStr("直播订单" );
+                    }else{
+                        vo.setOrderTypeStr("商城订单" );
+                    }
+                    if(StringUtils.isNotEmpty(vo.getJsonInfo())){
+                        try { 
+                            StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                            BeanUtil.copyProperties(orderProductDTO, vo);
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+
+                    if (vo.getUserPhone() != null) {
+                        String phone = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{1})", "$1****$2");
+                        vo.setUserPhone(phone);
+                    }
+                    if (!StringUtils.isEmpty(vo.getJsonInfo())) {
+                        try {
+                            StoreOrderProductDTO orderProductDTO = JSONObject.parseObject(vo.getJsonInfo(), StoreOrderProductDTO.class);
+                            BeanUtil.copyProperties(orderProductDTO, vo);
+                        } catch (Exception e) {
+                        }
+                    }
+                    if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) && !Objects.isNull(vo.getCost())) {
+                        vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getNum())));
+                    } else {
+                        vo.setPayPostage(BigDecimal.ZERO);
+                        vo.setPayDelivery(BigDecimal.ZERO);
+                        vo.setCost(BigDecimal.ZERO);
+                        vo.setFPrice(BigDecimal.ZERO);
+                        vo.setBarCode("");
+                        vo.setCateName("");
+                        vo.setBankTransactionId("");
+                    }
+                }
+            }
+            ExcelUtil<FsStoreOrderItemExportZMVO> util = new ExcelUtil<FsStoreOrderItemExportZMVO>(FsStoreOrderItemExportZMVO.class);
+            return util.exportExcel(zmvoList, "订单明细数据");
+        }
         //对手机号脱敏
         if (list != null) {
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
@@ -377,9 +433,10 @@ public class FsStoreHealthOrderScrmController extends BaseController {
                             }
                         }
                         if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*") ) && !Objects.isNull(vo.getCost())) {
-                            vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
+                            vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getNum())));
                         } else {
                             vo.setPayPostage(BigDecimal.ZERO);
+                            vo.setPayDelivery(BigDecimal.ZERO);
                             vo.setCost(BigDecimal.ZERO);
                             vo.setFPrice(BigDecimal.ZERO);
                             vo.setBarCode("");

+ 1 - 1
fs-admin/src/main/java/com/fs/hisStore/task/MallStoreTask.java

@@ -191,7 +191,7 @@ public class MallStoreTask
                 log.info("汇付返回"+o);
                 if ("00000000".equals(o.getResp_code()) && "S".equals(o.getTrans_stat())) {
                     String[] orderSpilt=o.getOrg_req_seq_id().split("-");
-                    if ("store".equals(orderSpilt[0])) {
+                    if ("store".equals(orderSpilt[0]) || "live".equals(orderSpilt[0])) {
                         orderService.payConfirm(1, null, orderSpilt[1], o.getOrg_hf_seq_id(), o.getOut_trans_id(), o.getParty_order_id());
                     }
                 }

+ 5 - 1
fs-live-app/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -785,7 +785,11 @@ public class WebSocketServer {
         if (session == null || !session.isOpen()) {
             return;
         }
-        session.getAsyncRemote().sendText(JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+        try {
+            sendMessage(session, JSONObject.toJSONString(R.ok().put("data", sendMsgVo)));
+        } catch (IOException e) {
+            log.error(e.getMessage());
+        }
     }
 
     private void sendBlockMessage(Long liveId, Long userId) {

+ 2 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -75,8 +75,8 @@ public interface FsStoreOrderItemScrmMapper
     List<FsStoreOrderItemVO> selectFsStoreOrderItemListAndProductByOrderId(Long id);
 
     @Select({"<script> " +
-            "select i.*,o.user_id,psps.cost,o.pay_postage,o.total_num,o.status,fspcs.cate_name, o.real_name,o.user_phone,o.user_address,o.create_time,o.pay_time,o.delivery_sn,o.delivery_name,o.delivery_id, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,o.upload_time ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload   " +
-            " ,p.title as package_name,cts.name as scheduleName,os.pay_money, os.bank_transaction_id as bankTransactionId, o.delivery_send_time " +
+            "select i.*,o.user_id,psps.cost,o.pay_postage,o.total_num,o.status,fspcs.cate_name, o.real_name,o.user_phone,o.user_address,o.create_time,o.pay_time,o.delivery_sn,o.delivery_name,o.delivery_id, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber,o.upload_time ,CASE WHEN o.certificates IS NULL OR o.certificates = '' THEN 0 ELSE 1 END AS is_upload,p.title as package_name,cts.name as scheduleName,os.pay_money, os.bank_transaction_id as bankTransactionId, o.delivery_send_time," +
+            " o.order_code, o.pay_price, o.pay_money, o.deduction_price,o.pay_delivery, o.order_type,psps.price " +
             ", CASE o.is_audit WHEN 1 THEN '是' ELSE '否' END AS isAudit " +
             " from fs_store_order_item_scrm i " +
             " left join fs_store_order_scrm o on o.id=i.order_id" +

+ 24 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -710,6 +710,12 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyId != null    '> " +
             "and o.company_id =#{maps.companyId} " +
             "</if>" +
+            "<if test = 'maps.salesName != null and maps.salesName != \"\" '> " +
+            "and cu.user_name like CONCAT('%', #{maps.salesName}, '%') " +
+            "</if>" +
+            "<if test = 'maps.payCode != null and maps.payCode != \"\" '> " +
+            "and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%') " +
+            "</if>" +
             "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
             "and o.company_id is null " +
             "</if>" +
@@ -722,6 +728,9 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
             "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
             "</if>" +
+            "<if test = 'maps.productName != null and maps.productName != \"\" '> " +
+            "and EXISTS (select 1 from fs_store_order_item_scrm oi2 join fs_store_product_scrm fsp2 on oi2.product_id = fsp2.product_id where oi2.order_id = o.id and fsp2.product_name like CONCAT('%', #{maps.productName}, '%')) " +
+            "</if>" +
             "<if test = 'maps.orderType != null    '> " +
             "and o.order_type =#{maps.orderType} " +
             "</if>" +
@@ -800,6 +809,9 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyId != null    '> " +
             "and o.company_id =#{maps.companyId} " +
             "</if>" +
+            "<if test = 'maps.salesName != null and maps.salesName != \"\" '> " +
+            "and cu.user_name like CONCAT('%', #{maps.salesName}, '%') " +
+            "</if>" +
             "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
             "and o.company_id is null " +
             "</if>" +
@@ -812,6 +824,9 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
             "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
             "</if>" +
+            "<if test = 'maps.productName != null and maps.productName != \"\" '> " +
+            "and EXISTS (select 1 from fs_store_order_item_scrm oi2 join fs_store_product_scrm fsp2 on oi2.product_id = fsp2.product_id where oi2.order_id = o.id and fsp2.product_name like CONCAT('%', #{maps.productName}, '%')) " +
+            "</if>" +
             "<if test = 'maps.orderType != null    '> " +
             "and o.order_type =#{maps.orderType} " +
             "</if>" +
@@ -1336,6 +1351,12 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyId != null    '> " +
             "and o.company_id =#{maps.companyId} " +
             "</if>" +
+            "<if test = 'maps.salesName != null and maps.salesName != \"\" '> " +
+            "and cu.user_name like CONCAT('%', #{maps.salesName}, '%') " +
+            "</if>" +
+            "<if test = 'maps.payCode != null and maps.payCode != \"\" '> " +
+            "and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%') " +
+            "</if>" +
             "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
             "and o.company_id is null " +
             "</if>" +
@@ -1348,6 +1369,9 @@ public interface FsStoreOrderScrmMapper
             "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=  \"\" '> " +
             "and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%') " +
             "</if>" +
+            "<if test = 'maps.productName != null and maps.productName != \"\" '> " +
+            "and EXISTS (select 1 from fs_store_order_item_scrm oi2 join fs_store_product_scrm fsp2 on oi2.product_id = fsp2.product_id where oi2.order_id = o.id and fsp2.product_name like CONCAT('%', #{maps.productName}, '%')) " +
+            "</if>" +
             "<if test = 'maps.orderType != null    '> " +
             "and o.order_type =#{maps.orderType} " +
             "</if>" +

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderParam.java

@@ -74,6 +74,12 @@ public class FsStoreOrderParam extends BaseEntity implements Serializable
 
     private String productName;
 
+    /** 销售名称(模糊搜索,对应company_user.user_name) */
+    private String salesName;
+
+    /** 汇付商户订单号(支付信息pay_code) */
+    private String payCode;
+
     private Integer isUpload;
 
     /** 开始时间 */

+ 38 - 33
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -141,6 +141,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 
 import javax.annotation.PostConstruct;
 import java.lang.reflect.Field;
@@ -161,6 +163,7 @@ import java.util.stream.Collectors;
 
 import static com.fs.his.utils.PhoneUtil.decryptPhone;
 import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
+import static com.fs.hisStore.constants.UserAppsLockConstant.LOCK_KEY_PAY;
 
 /**
  * 订单Service业务层处理
@@ -206,6 +209,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private RedissonClient redissonClient;
+
     @Autowired
     private IFsStoreCartScrmService cartService;
 
@@ -1986,10 +1992,37 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
     @Override
     @Transactional
-    //类型1支付回调 类型2货到付款
+    //类型1支付回调 类型2货到付款;使用 Redis 锁保证同一订单回调只被一个线程处理
     public String payConfirm(Integer type, Long orderId, String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
-        //支付订单
-//        try {
+
+        FsStorePaymentScrm storePayment = paymentService.selectFsStorePaymentByCode(payCode);
+        if (storePayment == null || !storePayment.getStatus().equals(0)) {
+            return "";
+        }
+        RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY, storePayment.getOrderId()));
+        try {
+            boolean locked = lock.tryLock(100, 30000, TimeUnit.MILLISECONDS);
+            if (!locked) {
+                log.warn("支付回调正在处理中,获取锁失败, payCode: {}", payCode);
+                return "";
+            }
+            return doPayConfirm(type, orderId, payCode, tradeNo, bankTransactionId, bankSerialNo);
+        } catch (InterruptedException e) {
+            log.error("支付回调获取锁被中断, payCode: {}", payCode, e);
+            Thread.currentThread().interrupt();
+            return "";
+        } finally {
+            if (lock.isHeldByCurrentThread()) {
+                lock.unlock();
+                log.debug("支付回调锁已释放, payCode: {}", payCode);
+            }
+        }
+    }
+
+    /**
+     * 支付确认核心逻辑(在 Redis 锁内执行)
+     */
+    private String doPayConfirm(Integer type, Long orderId, String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
         FsStoreOrderScrm order = null;
         if (type.equals(1)) {
             FsStorePaymentScrm storePayment = paymentService.selectFsStorePaymentByCode(payCode);
@@ -2024,17 +2057,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         //写入公司佣金 当有归属公司时只进行公司分佣
         if (order.getCompanyId() != null && order.getCompanyId() > 0) {
             companyService.addCompanyTuiMoney(order);
-            //没有归属公司对个人分佣
         } else if (order.getIsPackage() != 1 && order.getTuiUserId() != null && order.getTuiUserId() > 0) {
-            //处理佣金 套餐不分佣金
             FsStoreOrderItemScrm orderItemMap = new FsStoreOrderItemScrm();
             orderItemMap.setOrderId(order.getId());
             List<FsStoreOrderItemScrm> items = storeOrderItemService.selectFsStoreOrderItemList(orderItemMap);
             userService.addTuiMoney(order, items);
         }
-        //增加用户购买次数
         userService.incPayCount(order.getUserId());
-        //增加状态
         orderStatusService.create(order.getId(), OrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
                 OrderLogEnum.PAY_ORDER_SUCCESS.getDesc());
         FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
@@ -2043,44 +2072,20 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         storeOrder.setStatus(OrderInfoEnum.STATUS_1.getValue());
         storeOrder.setPayTime(new Date());
         fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
-        // 添加订单审核
         if (storeOrder.getCompanyId() != null) {
             addOrderAudit(order);
         }
         try {
-            // 记录限购数量(订单创建成功后记录)
             List<FsStoreOrderItemVO> fsStoreOrderItemVOS = storeOrderItemService.selectFsStoreOrderItemListByOrderId(order.getId());
             if (fsStoreOrderItemVOS != null && !fsStoreOrderItemVOS.isEmpty()) {
                 for (FsStoreOrderItemVO fsStoreOrderItemVO : fsStoreOrderItemVOS) {
                     purchaseLimitService.increasePurchaseLimit(fsStoreOrderItemVO.getProductId(), order.getUserId(), Math.toIntExact(fsStoreOrderItemVO.getNum()));
                 }
             }
-
         } catch (Exception e) {
-            log.error("创建限购商品失败:{}",e.getMessage());
+            log.error("创建限购商品失败:{}", e.getMessage());
         }
-
-    return "SUCCESS";
-
-
-        //非处方直接提交OMS
-//            if(order.getIsPrescribe().equals(0)){
-//                createOmsOrder(order.getId());
-//            }
-//            else if(order.getIsPrescribe().equals(1)){
-//                //是否已开方
-//                FsPrescribe prescribe=prescribeService.selectFsPrescribeByOrderId(order.getId());
-//                if(prescribe!=null&&prescribe.getStatus()==1){
-//                    createOmsOrder(order.getId());
-//                }
-//            }
-//        }
-//        catch (Exception e){
-//            logger.info("payConfirm:"+e.getMessage());
-//            logger.info("payConfirm:"+e.getLocalizedMessage());
-//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-//            return "";
-//        }
+        return "SUCCESS";
     }
 
     /**

+ 8 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportVO.java

@@ -120,4 +120,12 @@ public class FsStoreOrderItemExportVO implements Serializable
     @Excel(name = "是否审核")
     private String isAudit;
 
+
+    private String orderType; // 订单类型 2.直播
+    private BigDecimal payPrice;// 应付金额
+    private BigDecimal deductionPrice;// 应付金额
+    private BigDecimal payDelivery;// 应付邮费
+
+
+
 }

+ 48 - 52
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderItemExportZMVO.java

@@ -9,116 +9,112 @@ import java.math.BigDecimal;
 import java.util.Date;
 
 /**
- * @author MixLiu
- * @date 2025/12/4 上午11:43)
+ * 商城订单明细导出VO-北京卓美(导出字段与合并订单 MergedOrderVO 一致)
  */
-
 @Data
-public class FsStoreOrderItemExportZMVO implements Serializable  {
-
+public class FsStoreOrderItemExportZMVO implements Serializable {
 
     private Long itemId;
 
-    /** 订单号 */
-    @Excel(name = "订单号",sort = 1)
+
+    @Excel(name = "订单类型")
+    private String orderTypeStr;
+
+    @Excel(name = "订单号")
     private String orderCode;
 
-    @Excel(name = "订单状态", dictType = "store_order_status",sort = 10)
+    @Excel(name = "订单状态", dictType = "store_order_status")
     private String status;
 
-    @Excel(name = "会员ID" ,sort = 20)
+    @Excel(name = "会员ID")
     private Long userId;
 
-    @Excel(name = "产品名称",sort = 30)
+    @Excel(name = "产品名称")
     private String productName;
 
-    @Excel(name = "产品编码",sort =40)
+    @Excel(name = "产品编码")
     private String barCode;
 
-
-    @Excel(name = "规格",sort =50)
+    @Excel(name = "规格")
     private String sku;
 
-    @Excel(name = "产品数量",sort =60)
+    @Excel(name = "产品数量")
     private Integer num;
 
+    @Excel(name = "成本单价")
+    private BigDecimal cost;
 
-    @Excel(name = "产品价格",sort =70)
+    @Excel(name = "商品金额")
     private BigDecimal price;
 
-    @Excel(name = "成本单价",sort =80)
-    private BigDecimal cost;
-    @Excel(name = "结算价",sort =90)
-    private BigDecimal FPrice;
+    @Excel(name = "应付金额")
+    private BigDecimal payPrice;
 
-    @Excel(name = "实付金额",sort =91)
+    @Excel(name = "实付金额")
     private BigDecimal payMoney;
 
-    @Excel(name = "额外运费",sort =100)
-    private BigDecimal payPostage;
-    private Integer totalNum;
-    @Excel(name = "商品分类",sort =100)
-    private String cateName;
 
+    @Excel(name = "结算价")
+    private BigDecimal FPrice;
 
-    private String jsonInfo;
+    @Excel(name = "额外运费")
+    private BigDecimal payDelivery;
+
+    @Excel(name = "商品分类")
+    private String cateName;
 
     /** 用户姓名 */
-    @Excel(name = "收货人姓名",sort =110)
+    @Excel(name = "收货人姓名")
     private String realName;
 
     /** 用户电话 */
-    @Excel(name = "收货人电话",sort =120)
+    @Excel(name = "收货人电话")
     private String userPhone;
 
     /** 详细地址 */
-    @Excel(name = "详细地址",sort =130)
+    @Excel(name = "详细地址")
     private String userAddress;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 140)
+    @Excel(name = "下单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
     /** 支付时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 150)
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date payTime;
 
     /** 快递公司编号 */
-    @Excel(name = "快递公司编号",sort = 160)
+    @Excel(name = "快递公司编号")
     private String deliverySn;
 
     /** 快递名称/送货人姓名 */
-    @Excel(name = "快递公司",sort = 170)
+    @Excel(name = "快递公司")
     private String deliveryName;
 
     /** 快递单号/手机号 */
-    @Excel(name = "快递单号",sort = 180)
+    @Excel(name = "快递单号")
     private String deliveryId;
 
-    @Excel(name = "所属公司",sort = 190)
+    @Excel(name = "所属公司")
     private String companyName;
-    @Excel(name = "所属销售",sort = 200)
+    @Excel(name = "所属销售")
     private String companyUserNickName;
 
-    @Excel(name = "套餐名称",sort = 210)
-    private String packageName;
+    //银行交易流水号
+    @Excel(name = "银行交易流水号")
+    private String bankTransactionId;
 
-    @Excel(name = "组合码",sort = 210)
-    private String groupBarCode;
 
-    @Excel(name = "是否上传凭证 0:未上传 1:已上传",sort = 210)
-    private Integer isUpload;
+    /** 商品分类(与 MergedOrderVO 一致,不导出) */
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 220)
+    // 以下字段供内部使用,不参与导出
+    private BigDecimal payPostage;
+    private Integer totalNum;
+    private String jsonInfo;
+    private String packageName;
+    private String groupBarCode;
+    private Integer isUpload;
     private Date uploadTime;
-
-    @Excel(name = "归属档期",sort = 230)
     private String scheduleName;
-
-    //银行交易流水号
-    @Excel(name = "银行交易流水号",sort = 240)
-    private String bankTransactionId;
-
-
+    private String orderType; // 订单类型 2.直播
 }

+ 20 - 22
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -3120,33 +3120,31 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public List<LiveGoodsVo> selectLiveOrderItemList(String orderId) {
         LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(orderId);
         Asserts.notNull(liveOrder, String.format("该订单 %s 没有找到!", orderId));
+        List<LiveOrderItem> liveOrderItems = liveOrderItemMapper.selectCheckedByOrderId(Long.valueOf(orderId));
+        // 从订单明细的jsonInfo中提取barCode
+        Set<String> orderItemBarCodes = new HashSet<>();
+        for (LiveOrderItem item : liveOrderItems) {
+            if (StrUtil.isNotBlank(item.getJsonInfo())) {
+                try {
+                    com.fs.his.domain.FsStoreProduct cartDTO = JSONUtil.toBean(item.getJsonInfo(), com.fs.his.domain.FsStoreProduct.class);
+                    if (StrUtil.isNotBlank(cartDTO.getBarCode())) {
+                        orderItemBarCodes.add(cartDTO.getBarCode());
+                    }
+                } catch (Exception ignored) {
+                }
+            }
+        }
         List<LiveGoodsVo> liveGoodsVos = liveGoodsMapper.selectProductListByOrder(liveOrder);
 
         if (CollectionUtils.isEmpty(liveGoodsVos)) {
             return liveGoodsVos;
         }
-        List<String> productIds = liveGoodsVos.stream()
-                .map(LiveGoodsVo::getProductId)
-                .filter(Objects::nonNull)
-                .map(String::valueOf)
-                .distinct()
-                .collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(productIds)) {
-            return liveGoodsVos;
+        // 与订单明细的barCode做交集,只返回barCode匹配的商品;若订单明细无法解析出barCode则返回全部
+        if (!orderItemBarCodes.isEmpty()) {
+            liveGoodsVos = liveGoodsVos.stream()
+                    .filter(vo -> vo.getBarCode() != null && orderItemBarCodes.contains(vo.getBarCode()))
+                    .collect(Collectors.toList());
         }
-
-//        Map<Long, FsStoreProductScrm> productWarehouseMap =
-//                fsStoreProductBaseMapper.selectWarehouseCodeByProductIds(productIds);
-//
-//        liveGoodsVos.forEach(goodsVo -> {
-//            Long productId = goodsVo.getProductId();
-//            if (productId != null) {
-//                FsStoreProductScrm storeProduct = productWarehouseMap.get(productId);
-//                if (storeProduct != null) {
-//                    goodsVo.setWarehouseCode(storeProduct.getWarehouseCode());
-//                }
-//            }
-//        });
         return liveGoodsVos;
 
     }
@@ -3362,7 +3360,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 storePayment.setPayMoney(order.getPayMoney());
                 storePayment.setCreateTime(new Date());
                 storePayment.setPayTypeCode("weixin");
-                storePayment.setBusinessType(5); // 直播订单业务类型
+                storePayment.setBusinessType(2);
                 storePayment.setRemark("直播订单支付");
                 storePayment.setOpenId(user.getRealName());
                 storePayment.setUserId(user.getUserId());

+ 3 - 1
fs-service/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -381,7 +381,9 @@ public class LiveServiceImpl implements ILiveService
 
     @Override
     public Integer updateLiveIsAudit(Live live) {
-        return baseMapper.updateLiveIsAudit(live);
+        Integer i = baseMapper.updateLiveIsAudit(live);
+        clearLiveCache(live.getLiveId());
+        return i;
     }
 
 

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveVo.java

@@ -56,6 +56,7 @@ public class LiveVo {
     private Integer isShow;
     private String previewUrl;
     private Integer previewVideoType;
+    private Integer isDel;
     private Long previewVideoId;
     private Integer globalVisible;
     private Integer liveFlag;

+ 38 - 2
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -1203,6 +1203,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>
@@ -1373,6 +1379,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>
@@ -1520,6 +1532,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>
@@ -1671,6 +1689,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>
@@ -1818,6 +1842,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>
@@ -1906,7 +1936,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="(maps.nickname != null and  maps.nickname !='') or (maps.phone != null and  maps.phone !='')">
             left join fs_user u on o.user_id=u.user_id
         </if>
-        <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  ''">
+        <if test="(maps.companyUserNickName != null and  maps.companyUserNickName !=  '') or (maps.salesName != null and maps.salesName != '')">
             left join company_user cu on cu.user_id=o.company_user_id
         </if>
         <if test="maps.erpAccount != null and maps.erpAccount != ''">
@@ -1917,7 +1947,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             left join fs_store_order_item_scrm oi on o.id = oi.order_id
             left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
         </if>
-        <if test="(maps.appId != null and maps.appId != '') or (maps.bankTransactionId != null and  maps.bankTransactionId !='')">
+        <if test="(maps.appId != null and maps.appId != '') or (maps.bankTransactionId != null and  maps.bankTransactionId !='') or (maps.payCode != null and maps.payCode != '')">
             LEFT JOIN (
             SELECT
             sp.*,
@@ -2006,6 +2036,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="maps.companyUserId != null  ">
                 and o.company_user_id =#{maps.companyUserId}
             </if>
+            <if test="maps.salesName != null and maps.salesName != ''">
+                and cu.user_name like CONCAT('%', #{maps.salesName}, '%')
+            </if>
+            <if test="maps.payCode != null and maps.payCode != ''">
+                and sp_latest.pay_code like CONCAT('%', #{maps.payCode}, '%')
+            </if>
             <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=  '' ">
                 and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
             </if>

+ 5 - 8
fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml

@@ -255,14 +255,11 @@
     </delete>
 
     <select id="selectProductListByOrder" parameterType="com.fs.live.domain.LiveOrder" resultType="com.fs.live.vo.LiveGoodsVo">
-
-        select sp.image as img_url,sp.product_name,sp.price,sp.stock,sp.sales,sp.product_id,sp.ot_price, sp.is_show as fs_status,pav.bar_code
-        from fs_store_product_scrm sp
-        left join fs_store_product_attr_value_scrm pav
-        ON  sp.product_id = pav.product_id
-        <where>
-            sp.product_id = #{productId}
-        </where>
+        select distinct sp.image as img_url, sp.product_name, sp.price, sp.stock, sp.sales, sp.product_id, sp.ot_price, sp.is_show as fs_status, pav.bar_code
+        from live_order_item loi
+        inner join fs_store_product_scrm sp on loi.product_id = sp.product_id
+        left join fs_store_product_attr_value_scrm pav on sp.product_id = pav.product_id
+        where loi.order_id = #{orderId}
     </select>
 
     <select id="selectLiveGoodsListByStoreId" resultType="com.fs.live.vo.LiveGoodsVo">