xgb 5 dienas atpakaļ
vecāks
revīzija
d02b202535

+ 6 - 3
fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java

@@ -398,10 +398,13 @@ public class FsStorePaymentScrmController extends BaseController
      * **/
     @Log(title = "发货同步导入", businessType = BusinessType.IMPORT)
     @PostMapping("/oneClickShipping")
-    public R oneClickShipping() {
-
+    public R oneClickShipping(@RequestBody(required = false) Map<String, String> params) {
+        String appId = null;
+        if (params != null) {
+            appId = params.get("appId");
+        }
         try {
-            return fsStorePaymentService.oneClickShipping();
+            return fsStorePaymentService.oneClickShipping(appId);
         }catch (Exception e){
             e.getStackTrace();
         }

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

@@ -141,6 +141,7 @@ public interface FsStorePaymentScrmMapper
             " AND date_format(p.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
             "</if>" +
             "<if test=\"maps.appId != null and maps.appId != ''\">  and p.app_id like #{maps.appId}</if>\n" +
+            "<if test='maps.isShipment != null'>  and p.is_shipment = #{maps.isShipment}</if>\n" +
 
 //            "<if test = 'maps.refundTime != null    '> " +
 //            "and DATE_FORMAT(p.refund_time,'%Y-%m-%d') = DATE_FORMAT(#{maps.refundTime},'%Y-%m-%d')  " +
@@ -382,6 +383,8 @@ public interface FsStorePaymentScrmMapper
      **/
     List<FsStorePaymentUsetVo> getPaymentUsetInfoList();
 
+    List<FsStorePaymentUsetVo> getPaymentUsetInfoListByAppId(@Param("appId") String appId);
+
     /**
      * 批量更新发货状态
      * **/

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStorePaymentParam.java

@@ -50,4 +50,6 @@ public class FsStorePaymentParam  extends BaseEntity implements Serializable
     // 小程序ID
     private Long coursePlaySourceConfigId;
     private String appId;
+
+    private Integer isShipment;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java

@@ -122,7 +122,7 @@ public interface IFsStorePaymentScrmService
     /**
      * 批量导入更新微信订单发货状态
      * **/
-    R oneClickShipping();
+    R oneClickShipping(String appId);
 
     R processPaymentScrm(PayOrderParam payOrderParam);
 }

+ 9 - 9
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -1032,16 +1032,18 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
     }
 
     @Override
-    public R oneClickShipping() {
+    public R oneClickShipping(String appId) {
         try {
             StringBuilder builder = new StringBuilder();
-            //获取商城配置
             String json = configService.selectConfigByKey("store.config");
             StoreConfig config = JSONUtil.toBean(json, StoreConfig.class);
-            //验证是否开启微信发货
             if (config.getIsWeChatShipping() != null && config.getIsWeChatShipping()) {
-                //获取支付信息
-                List<FsStorePaymentUsetVo> paymentList = fsStorePaymentMapper.getPaymentUsetInfoList();
+                List<FsStorePaymentUsetVo> paymentList;
+                if (StringUtils.isNotEmpty(appId)) {
+                    paymentList = fsStorePaymentMapper.getPaymentUsetInfoListByAppId(appId);
+                } else {
+                    paymentList = fsStorePaymentMapper.getPaymentUsetInfoList();
+                }
                 if (paymentList.isEmpty()) {
                     return R.ok("操作成功,暂无同步订单信息!");
                 }
@@ -1051,19 +1053,17 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
                 for (Map.Entry<String, List<FsStorePaymentUsetVo>> entry : paymentUsetVoMap.entrySet()) {
                     List<String> successList = new ArrayList<>();
                     List<String> failedList = new ArrayList<>();
-                    String appId = entry.getKey();
+                    String currentAppId = entry.getKey();
                     List<FsStorePaymentUsetVo> userPayments = entry.getValue();
-                    final WxMaService wxService = WxMaConfiguration.getMaService(appId);
+                    final WxMaService wxService = WxMaConfiguration.getMaService(currentAppId);
                     if (!userPayments.isEmpty()) {
                         for (FsStorePaymentUsetVo v : userPayments) {
-                            // 上传物流信息到微信
                             if (uploadShippingInfoToWechat(wxService, v, uploadTime)) {
                                 successList.add(v.getBankTransactionId());
                             }else {
                                 failedList.add(v.getBankTransactionId());
                             }
                         }
-                        //批量更新数据
                         if (!successList.isEmpty()) {
                             fsStorePaymentMapper.batchUpadte(successList);
                         }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStorePaymentVO.java

@@ -94,6 +94,9 @@ public class FsStorePaymentVO implements Serializable
     @Excel(name = "所属小程序")
     private String miniProgramName;
 
+    @Excel(name = "是否发货")
+    private Integer isShipment;
+
 
 
 }

+ 21 - 0
fs-service/src/main/resources/mapper/hisStore/FsStorePaymentScrmMapper.xml

@@ -221,6 +221,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             order by sp.pay_time desc LIMIT 500
     </select>
 
+    <select id="getPaymentUsetInfoListByAppId" resultType="com.fs.hisStore.vo.FsStorePaymentUsetVo">
+        SELECT
+            sp.bank_transaction_id,
+            sp.open_id,
+            sp.app_id,
+            CASE
+                WHEN TRIM(fu.phone) IS NOT NULL AND TRIM(fu.phone) != '' THEN fu.phone
+                ELSE CONCAT(
+                        ELT(FLOOR(1 + RAND() * 6), '13', '14', '15', '17', '18', '19'),
+                        LPAD(FLOOR(RAND() * 1000000000), 9, '0')
+                    )
+                END AS phone
+        FROM
+            fs_store_payment_scrm sp
+                LEFT JOIN fs_user fu ON sp.user_id = fu.user_id
+        WHERE
+            sp.status = 1  and sp.app_id is not null  and sp.is_shipment = 0 and sp.business_type = 1 AND sp.pay_time > '2025-11-27 00:00:00'
+            AND sp.app_id = #{appId}
+            order by sp.pay_time desc LIMIT 500
+    </select>
+
     <update id="batchUpadte">
         update fs_store_payment_scrm set is_shipment = 1 where bank_transaction_id in
         <foreach item="bankTransactionId" collection="list" open="(" separator="," close=")">