فهرست منبع

直播订单添加小程序id 售后添加产品名称查询

yuhongqi 3 روز پیش
والد
کامیت
9e06b41a8e

+ 4 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveAfterSalesController.java

@@ -93,6 +93,10 @@ public class LiveAfterSalesController extends BaseController
     public TableDataInfo list(LiveAfterSalesVo liveAfterSales)
     {
         startPage();
+        // 将productName映射到productNameQuery用于查询
+        if (liveAfterSales.getProductName() != null && !liveAfterSales.getProductName().isEmpty()) {
+            liveAfterSales.setProductNameQuery(liveAfterSales.getProductName());
+        }
         List<LiveAfterSalesVo> list = liveAfterSalesService.selectLiveAfterSalesVoList(liveAfterSales);
         for (LiveAfterSalesVo liveAfterSalesVo : list) {
             liveAfterSalesVo.setUserPhone(ParseUtils.parsePhone(liveAfterSalesVo.getUserPhone()));

+ 4 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveAfterSalesController.java

@@ -59,6 +59,10 @@ public class LiveAfterSalesController extends BaseController
         startPage();
         CompanyUser user = SecurityUtils.getLoginUser().getUser();
         liveAfterSales.setCompanyId(user.getCompanyId());
+        // 将productName映射到productNameQuery用于查询
+        if (liveAfterSales.getProductName() != null && !liveAfterSales.getProductName().isEmpty()) {
+            liveAfterSales.setProductNameQuery(liveAfterSales.getProductName());
+        }
         List<LiveAfterSalesVo> list = liveAfterSalesService.selectLiveAfterSalesVoList(liveAfterSales);
         for (LiveAfterSalesVo liveAfterSalesVo : list) {
             liveAfterSalesVo.setUserPhone(ParseUtils.parsePhone(liveAfterSalesVo.getUserPhone()));

+ 1 - 1
fs-service/src/main/java/com/fs/erp/service/impl/JSTErpOrderServiceImpl.java

@@ -844,7 +844,7 @@ public class JSTErpOrderServiceImpl implements IErpOrderService {
         log.info("订单号: {},发货状态: {},是否发货后: {}",fsStoreOrder.getOrderCode(),fsStoreOrder.getStatus(),ObjectUtils.equals(fsStoreOrder.getStatus(),2));
 
         // 发货后退款
-        if(ObjectUtils.equals(param.getOrderStatus(),2)){
+        if(ObjectUtils.equals(param.getOrderStatus(),2) || ObjectUtils.equals(param.getOrderStatus(),3)){
 
             FsJstAftersalePush fsJstAftersalePush = new FsJstAftersalePush();
             fsJstAftersalePush.setOrderId(fsStoreOrder.getOrderCode());

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreAfterSalesScrm.java

@@ -140,4 +140,8 @@ public class FsStoreAfterSalesScrm extends BaseEntity
 
     private String remark;
 
+    /** 产品名称查询参数(用于搜索) */
+    @TableField(exist = false)
+    private String productName;
+
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreAfterSalesScrmMapper.java

@@ -140,6 +140,9 @@ public interface FsStoreAfterSalesScrmMapper
             "<if test = 'maps.consigneePhone != null and  maps.consigneePhone !=\"\"     '> " +
             "and o.user_phone like CONCAT('%',#{maps.consigneePhone},'%') " +
             "</if>" +
+            "<if test = 'maps.productName != null and  maps.productName != \"\" '> " +
+            "and EXISTS (SELECT 1 FROM fs_store_order_item_scrm oi WHERE oi.order_id = o.id AND JSON_UNQUOTE(JSON_EXTRACT(oi.json_info, '$.productName')) LIKE CONCAT('%', #{maps.productName}, '%')) " +
+            "</if>" +
             "<if test = 'maps.deptId != null    '> " +
             "  AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
             "</if>" +

+ 4 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -352,4 +352,8 @@ public class LiveOrder extends BaseEntity {
     @TableField(exist = false)
     private Long attrValueId;
 
+    /** 小程序AppId */
+    @Excel(name = "小程序AppId")
+    private String appId;
+
 }

+ 16 - 3
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -191,6 +191,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     @Autowired
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
 
+    @Autowired
+    private FsStoreProductScrmMapper fsStoreProductScrmMapper;
+
     @Autowired
     private LiveUserLotteryRecordMapper liveUserLotteryRecordMapper;
 
@@ -1962,7 +1965,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         // 更改店铺库存
         fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
         fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
-        fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+        fsStoreProductScrmMapper.incStockDecSales(Long.valueOf("-" + liveOrder.getTotalNum()),fsStoreProduct.getProductId());
         // 更新直播间库存
         goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
         goods.setSales(goods.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
@@ -2946,12 +2949,18 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public R payConfirmReward(LiveOrder liveOrder) {
         Long orderId = liveOrder.getOrderId();
         if(orderId==null) return R.error("订单ID不存在");
+        // 保存传入的appId
+        String appId = liveOrder.getAppId();
         Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
         try {
             liveOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
             if(liveOrder==null || !liveOrder.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())){
                 throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
             }
+            // 设置appId
+            if (StringUtils.isNotEmpty(appId)) {
+                liveOrder.setAppId(appId);
+            }
             FsUserScrm user = userMapper.selectFsUserById(Long.valueOf(liveOrder.getUserId()));
             if(user == null) return R.error("用户不存在");
 //            String json = configService.selectConfigByKey("store.pay");
@@ -3103,6 +3112,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                     order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
 //                    order.setPayMoney(BigDecimal.ZERO);
                 }
+                // 保存appId到订单
+                if (StringUtils.isNotEmpty(param.getAppId())) {
+                    order.setAppId(param.getAppId());
+                }
                 baseMapper.updateLiveOrder(order);
             }
             String payCode = OrderCodeUtils.getOrderSn();
@@ -3564,7 +3577,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         // 更改店铺库存
         fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
         fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
-        fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+        fsStoreProductScrmMapper.incStockDecSales(Long.valueOf("-" + liveOrder.getTotalNum()),fsStoreProduct.getProductId());
 
         // 更新直播间库存
         goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
@@ -3828,7 +3841,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             }
 
             // 更新商品库存
-            fsStoreProductService.updateFsStoreProduct(fsStoreProduct);
+            fsStoreProductScrmMapper.incStockDecSales(Long.valueOf(liveOrder.getTotalNum()),fsStoreProduct.getProductId());
             goods.setStock(goods.getStock()+Long.parseLong(liveOrder.getTotalNum()));
             // 更新商品库存
             liveGoodsMapper.updateLiveGoods(goods);

+ 4 - 0
fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesVo.java

@@ -151,6 +151,10 @@ public class LiveAfterSalesVo {
 
     @Excel(name ="产品名称")
     private String productName;
+    
+    /** 产品名称查询参数(用于搜索) */
+    private String productNameQuery;
+    
     @Excel(name ="产品编码")
     private String productBarCode;
     @Excel(name ="规格")

+ 7 - 0
fs-service/src/main/resources/mapper/live/LiveAfterSalesMapper.xml

@@ -74,12 +74,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join company_user cu on cu.user_id = las.company_user_id
         left join company c on c.company_id = cu.company_id
         left join live_order_payment lop on lop.business_id = lo.order_id and lop.status in (1,-1)
+        <if test="productName != null and productName != ''">
+        left join live_order_item loi on loi.order_id = lo.order_id
+        </if>
 
         <where>
             <if test="liveId != null and liveId != ''"> and las.live_id = #{liveId}</if>
             <if test="companyUserNickName != null and companyUserNickName != ''"> and cu.nick_name like concat(#{companyUserNickName},'%')</if>
             <if test="storeId != null and storeId != ''"> and las.store_id = #{storeId}</if>
             <if test="orderCode != null and orderCode != ''"> and lo.order_code = #{orderCode}</if>
+            <if test="productNameQuery != null and productNameQuery != ''"> and JSON_UNQUOTE(JSON_EXTRACT(loi.json_info, '$.productName')) like concat('%', #{productNameQuery}, '%')</if>
             <if test="refundAmount != null "> and las.refund_amount = #{refundAmount}</if>
             <if test="refundType != null "> and las.refund_type = #{refundType}</if>
             <if test="status != null "> and las.status = #{status}</if>
@@ -105,6 +109,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deptId != null "> and cu.dept_id = #{deptId}</if>
             <if test="userPhone != null "> and lo.user_phone like concat(#{userPhone},'%')</if>
         </where>
+        <if test="productName != null and productName != ''">
+        group by las.id
+        </if>
         order by las.create_time desc
     </select>
 

+ 7 - 3
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="companyName"    column="company_name"    />
         <result property="customerId"    column="customer_id"    />
         <result property="couponPrice"    column="coupon_price"    />
+        <result property="appId"    column="app_id"    />
     </resultMap>
 
     <sql id="selectLiveOrderVo">
@@ -92,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
             a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
             a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
-            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
+            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id,a.app_id
         FROM
             live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
     </sql>
@@ -109,7 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
         a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
         a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
-        a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
+        a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id,a.app_id
         FROM
         live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
         left join company_user cu on a.company_user_id = cu.user_id
@@ -197,7 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             a.pay_remain,	a.delivery_status,	a.delivery_pay_status,	a.delivery_pay_time,	a.delivery_type,
             a.delivery_pay_money,	a.delivery_import_time,	a.delivery_send_time,	a.is_after_sales,	a.dept_id,
             a.channel,	a.source,	a.bill_price,	a.total_postage,	a.pay_postage,	a.gain_integral,a.coupon_price,
-            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id
+            a.use_integral,	a.pay_integral,	a.back_integral,	a.is_edit_money,	b.product_info as product_introduce,a.customer_id,a.app_id
         FROM
             live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
                          left join company_user cu on a.company_user_id = cu.user_id
@@ -279,6 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="productId != null">product_id,</if>
             <if test="customerId != null">customer_id,</if>
             <if test="couponPrice != null">coupon_price,</if>
+            <if test="appId != null and appId != ''">app_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -351,6 +353,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="productId != null">#{productId},</if>
             <if test="customerId != null">#{customerId},</if>
             <if test="couponPrice != null">#{couponPrice},</if>
+            <if test="appId != null and appId != ''">#{appId},</if>
          </trim>
     </insert>
 
@@ -426,6 +429,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isEditMoney != null">is_edit_money = #{isEditMoney},</if>
             <if test="customerId != null">customer_id = #{customerId},</if>
             <if test="couponPrice != null">coupon_price = #{couponPrice},</if>
+            <if test="appId != null and appId != ''">app_id = #{appId},</if>
         </trim>
         where order_id = #{orderId}
     </update>

+ 16 - 0
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -274,6 +274,10 @@ public class LiveOrderController extends AppBaseController
     @RepeatSubmit
     public R createReward(@RequestBody LiveOrder liveOrder)
     {
+        // 校验appId
+        if (StringUtils.isEmpty(liveOrder.getAppId())) {
+            return R.error("appId不能为空");
+        }
         log.info("新增中奖订单: {}", JSON.toJSONString(liveOrder));
 
         liveOrder.setUserId(getUserId());
@@ -289,6 +293,10 @@ public class LiveOrderController extends AppBaseController
     @RepeatSubmit
     public R payConfirmReward(@RequestBody LiveOrder liveOrder)
     {
+        // 校验appId
+        if (StringUtils.isEmpty(liveOrder.getAppId())) {
+            return R.error("appId不能为空");
+        }
         log.info("新增订单: {}", JSON.toJSONString(liveOrder));
 
         liveOrder.setUserId(getUserId());
@@ -299,6 +307,10 @@ public class LiveOrderController extends AppBaseController
     @ApiOperation("创建订单")
     @PostMapping("/create")
     public R create(@Validated @RequestBody LiveOrder param, HttpServletRequest request){
+        // 校验appId
+        if (StringUtils.isEmpty(param.getAppId())) {
+            return R.error("appId不能为空");
+        }
         String userId= getUserId();
         log.info("开始创建订单,登录用户id:{}", userId);
         param.setUserId(userId);
@@ -642,6 +654,10 @@ public class LiveOrderController extends AppBaseController
     @Transactional
     public R pay(HttpServletRequest request, @Validated @RequestBody LiveOrderPayParam param)
     {
+        // 校验appId
+        if (StringUtils.isEmpty(param.getAppId())) {
+            return R.error("appId不能为空");
+        }
         Long orderId = param.getOrderId();
         logger.info("开始处理支付请求, 订单号: {}, 支付类型: {}", orderId, param.getPayType());
         try{