Jelajahi Sumber

add:同步支付

ct 5 hari lalu
induk
melakukan
4b01133f49

+ 8 - 1
fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java

@@ -119,7 +119,7 @@ public class FsStorePaymentScrmController extends BaseController
     @GetMapping(value = "/{paymentId}")
     public AjaxResult getInfo(@PathVariable("paymentId") Long paymentId)
     {
-        return AjaxResult.success(fsStorePaymentService.selectFsStorePaymentById(paymentId));
+        return AjaxResult.success(fsStorePaymentService.selectFsStorePaymentAndFsUserById(paymentId));
     }
 
 
@@ -163,6 +163,13 @@ public class FsStorePaymentScrmController extends BaseController
         return R.error("请检查外部订单号");
     }
 
+    @GetMapping(value = "getStatus/{paymentId}")
+    public AjaxResult getStatus(@PathVariable("paymentId") Long paymentId)
+    {
+
+        return AjaxResult.success( fsStorePaymentService.updateFsStorePaymentByDecryptForm(paymentId));
+    }
+
 
 
     /**

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

@@ -678,4 +678,9 @@ public class MallStoreTask
         }
     }
 
+    //同步支付状态
+    public void synchronizePayStatus(){
+        fsStorePaymentService.synchronizePayStatus();
+    }
+
 }

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

@@ -8,6 +8,7 @@ import com.fs.his.domain.FsStorePayment;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.param.FsStorePaymentParam;
 import com.fs.hisStore.param.FsStoreStatisticsParam;
+import com.fs.hisStore.vo.FsStorePaymentScrmVo;
 import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
 import com.fs.hisStore.vo.FsStorePaymentUsetVo;
 import com.fs.hisStore.vo.FsStorePaymentVO;
@@ -385,4 +386,6 @@ public interface FsStorePaymentScrmMapper
     void batchUpadte(@Param("list") List<String> list);
 
     void batchUpadteFailed(@Param("list") List<String> list);
+
+    FsStorePaymentScrmVo selectFsStorePaymentAndFsUserById(@Param("paymentId")Long paymentId);
 }

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

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.param.*;
+import com.fs.hisStore.vo.FsStorePaymentScrmVo;
 import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
 import com.fs.hisStore.vo.FsStorePaymentVO;
 
@@ -28,6 +29,8 @@ public interface IFsStorePaymentScrmService
      */
     public FsStorePaymentScrm selectFsStorePaymentById(Long paymentId);
 
+    public FsStorePaymentScrmVo selectFsStorePaymentAndFsUserById(Long paymentId);
+
     /**
      * 查询支付明细列表
      *
@@ -121,4 +124,8 @@ public interface IFsStorePaymentScrmService
      * 批量导入更新微信订单发货状态
      * **/
     R oneClickShipping();
+
+    String updateFsStorePaymentByDecryptForm(Long paymentId);
+
+    void synchronizePayStatus();
 }

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

@@ -3,10 +3,12 @@ package com.fs.hisStore.service.impl;
 
 import java.math.BigDecimal;
 
+import java.text.SimpleDateFormat;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 
@@ -47,11 +49,16 @@ import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.HttpUtil;
 import com.fs.hisStore.config.StoreConfig;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.enums.SysConfigEnum;
 import com.fs.hisStore.param.*;
+import com.fs.hisStore.service.IFsStoreOrderScrmService;
+import com.fs.hisStore.vo.FsStorePaymentScrmVo;
 import com.fs.hisStore.vo.FsStorePaymentUsetVo;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.pay.pay.config.PayConfig;
@@ -138,6 +145,9 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private IFsStoreOrderScrmService storeOrderService;
+
     /**
      * 查询支付明细
      *
@@ -150,6 +160,15 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         return fsStorePaymentMapper.selectFsStorePaymentById(paymentId);
     }
 
+    @Override
+    public FsStorePaymentScrmVo selectFsStorePaymentAndFsUserById(Long paymentId) {
+        FsStorePaymentScrmVo vo = fsStorePaymentMapper.selectFsStorePaymentAndFsUserById(paymentId);
+        if (vo!=null && StringUtils.isNotBlank(vo.getPhone())){
+            vo.setPhone(vo.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+        }
+        return vo;
+    }
+
     /**
      * 查询支付明细列表
      *
@@ -1009,6 +1028,99 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         }
     }
 
+    @Override
+    public String updateFsStorePaymentByDecryptForm(Long paymentId) {
+        FsStorePaymentScrm fsStorePayment = fsStorePaymentMapper.selectFsStorePaymentById(paymentId);
+        logger.info("手动查询单号:" + paymentId + ":" + fsStorePayment);
+        Long orderId = fsStorePayment.getOrderId();
+        FsStoreOrderScrm fsStoreOrder = storeOrderService.selectFsStoreOrderById(orderId);
+        String tradeNo = fsStorePayment.getTradeNo();
+        String payCode = fsStorePayment.getPayCode();
+        String payType = fsStoreOrder.getPayType();
+//        if (fsStorePayment.getPayMode().equals("tz")) {
+//            payQueryOrder payQueryOrder = new payQueryOrder();
+//            payQueryOrder.setOrderFlowNo(payCode);
+//            TzBankResult<QueryOrderResult> result = tzBankService.queryOrder(payQueryOrder);
+//            logger.info("手动查询内容:" + paymentId + ":" + result);
+//            if (result.getRetType().equals("S") && result.getBody().getStatus().equals("90")) {
+//                QueryOrderResult body = result.getBody();
+//                logger.info("手动回调内容:" + body);
+//                if (fsStorePayment.getBusinessType() == 1) {
+//                } else if (fsStorePayment.getBusinessType() == 2) {
+//                } else if (fsStorePayment.getBusinessType() == 3) {
+//                }else if (fsStorePayment.getBusinessType() == 4) {
+//                }else if (fsStorePayment.getBusinessType() == 5) {
+//                }
+//            }
+//        }
+//        if (fsStorePayment.getPayMode().equals("yb")) {
+//            OrderQueryDTO o = new OrderQueryDTO();
+//            o.setUpOrderId(payCode);
+//            OrderResult orderResult = ybPayService.getOrder(o);
+//
+//            if ("0".equals(orderResult.getState())) {
+//                if (orderResult.getStatus().equals("100")) {
+//                    logger.info("手动查询内容:" + paymentId + ":" + orderResult);
+//                    if (orderResult.getStatus().equals("100")) {
+//                        if (fsStorePayment.getBusinessType() == 1) {
+//                        } else if (fsStorePayment.getBusinessType() == 2) {
+//                        } else if (fsStorePayment.getBusinessType() == 3) {
+//                        }else if (fsStorePayment.getBusinessType() == 4) {
+//                        }else if (fsStorePayment.getBusinessType() == 5) {
+//                        }
+//                    }
+//                }
+//            }
+//        }
+        if (fsStorePayment.getPayMode().equals("hf")) {
+            V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
+            request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(fsStorePayment.getCreateTime()));
+            request.setOrgHfSeqId(fsStorePayment.getTradeNo());
+            HuiFuQueryOrderResult queryOrderResult = null;
+            try {
+                queryOrderResult = huiFuService.queryOrder(request);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            logger.info("汇付返回"+queryOrderResult);
+            if ("00000000".equals(queryOrderResult.getResp_code())) {
+                if (queryOrderResult.getTrans_stat().equals("S")) {
+                    logger.info("手动查询内容:" + paymentId + ":" + request);
+                    if (fsStorePayment.getBusinessType() == 1) {
+                    } else if (fsStorePayment.getBusinessType() == 2) {
+                        //查询订单
+                        storeOrderService.payConfirm(Integer.valueOf(payType), orderId, payCode, tradeNo,queryOrderResult.getOut_trans_id(),queryOrderResult.getParty_order_id());
+                    } else if (fsStorePayment.getBusinessType() == 3) {
+                    }  else if (fsStorePayment.getBusinessType() == 4) {
+                    }else if (fsStorePayment.getBusinessType() == 5) {
+                    }
+
+                }
+            }
+        }
+        return "同步完成";
+    }
+
+    @Override
+    public void synchronizePayStatus() {
+        FsStorePaymentScrm queryParam = new FsStorePaymentScrm();
+        queryParam.setStatus(0);//未支付
+        queryParam.setBeginTime(DateUtils.addDateDays(-1));
+        queryParam.setEndTime(DateUtils.getDate());
+        List<FsStorePaymentScrm> list = selectFsStorePaymentList(queryParam);
+        if (list != null && !list.isEmpty()) {
+            List<CompletableFuture<Void>> futures = new ArrayList<>();
+            for (FsStorePaymentScrm fsStorePayment : list) {
+                CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
+                    updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
+                    logger.info("定时任务:同步支付状态,payment_id:{}",fsStorePayment.getPaymentId());
+                });
+                futures.add(future);
+            }
+            CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+        }
+    }
+
     private boolean uploadShippingInfoToWechat(WxMaService wxService,
                                                FsStorePaymentUsetVo dto,
                                                String uploadTime) {

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStorePaymentScrmVo.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.vo;
+
+import com.fs.hisStore.domain.FsStorePaymentScrm;
+import lombok.Data;
+
+@Data
+public class FsStorePaymentScrmVo extends FsStorePaymentScrm {
+    private String nickName;
+
+    private String phone;
+}

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

@@ -88,11 +88,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="scheduleId"    column="schedule_id"    />
         <result property="orderVisit"    column="order_visit"    />
         <result property="serviceFee"    column="service_fee"    />
+        <result property="erpPhone"    column="erp_phone"    />
         <!--<result property="orderMedium"    column="order_medium"    />-->
     </resultMap>
 
     <sql id="selectFsStoreOrderVo">
-        select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id from fs_store_order_scrm
+        select id, order_code,service_fee, extend_order_id,pay_order_id,bank_order_id, user_id,order_visit, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage,pay_delivery,pay_money, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, create_time, update_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_sn, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, pay_integral, back_integral, mark, is_del, remark, cost, verify_code, store_id, shipping_type, is_channel, is_remind, is_sys_del,is_prescribe,prescribe_id ,company_id,company_user_id,is_package,package_json,item_json,order_type,package_id,finish_time,delivery_status,delivery_pay_status,delivery_time,delivery_pay_time,delivery_pay_money,tui_money,tui_money_status,delivery_import_time,tui_user_id,tui_user_money_status,order_create_type,store_house_code,dept_id,is_edit_money,customer_id,is_pay_remain,delivery_send_time,certificates,schedule_id,erp_phone from fs_store_order_scrm
     </sql>
 
     <select id="selectFsStoreOrderList" parameterType="FsStoreOrderScrm" resultMap="FsStoreOrderResult">

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

@@ -65,6 +65,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where payment_id = #{paymentId}
     </select>
 
+    <select id="selectFsStorePaymentAndFsUserById" resultType="com.fs.hisStore.vo.FsStorePaymentScrmVo">
+        select p.*,u.nick_name,u.phone from fs_store_payment_scrm p left join fs_user u on u.user_id = p.user_id
+        where payment_id = #{paymentId}
+    </select>
+
     <insert id="insertFsStorePayment" parameterType="FsStorePaymentScrm" useGeneratedKeys="true" keyProperty="paymentId">
         insert into fs_store_payment_scrm
         <trim prefix="(" suffix=")" suffixOverrides=",">