Browse Source

汇付回调代码优化,贴合scrm迁移代码和表类型状态

yjwang 2 weeks ago
parent
commit
de1a678549

+ 36 - 16
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -45,6 +45,10 @@ import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
+import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.RecipeDetailParam;
@@ -132,6 +136,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     private HuiFuService huiFuService;
     @Autowired
     private FsStoreOrderMapper fsStoreOrderMapper;
+
+    @Autowired
+    private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
+
     @Autowired
     private FsStoreOrderItemMapper fsStoreOrderItemMapper;
     @Autowired
@@ -151,6 +159,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     private IFsStorePaymentService storePaymentService;
     @Autowired
     private FsStorePaymentMapper fsStorePaymentMapper;
+
+    @Autowired
+    private FsStorePaymentScrmMapper fsStorePaymentScrmMapper;
     @Autowired
     private IFsExpressService expressService;
     @Autowired
@@ -1388,10 +1399,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     @Transactional(rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
     public R payConfirm(String orderCode, String payCode, String tradeNo, String payType, Integer type) {
         try {
-            FsStoreOrder order = null;
+            FsStoreOrderScrm order = null;
             if (type.equals(1)) {
 
-                FsStorePayment storePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentCode(payCode);
+                FsStorePaymentScrm storePayment = fsStorePaymentScrmMapper.selectFsStorePaymentByPaymentCode(payCode);
                 if (storePayment != null) {
                     if (storePayment.getStatus().equals(0)) {
                         log.info(payCode + "待支付");
@@ -1414,31 +1425,40 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                         }
                         fsStorePaymentMapper.updateFsStorePayment(paymentMap);
                         log.info(payCode + "已支付");
-                        order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));
+                        order = fsStoreOrderScrmMapper.selectFsStoreOrderById(Long.parseLong(storePayment.getBusinessOrderId()));
                     }
                 } else {
                     log.info(payCode + "支付单号不存在");
                     return R.error("支付单号不存在");
                 }
             } else if (type.equals(2)) {
-                order = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
+                order = fsStoreOrderScrmMapper.selectFsStoreOrderByOrderCode(orderCode);
             }
-            if (order != null && !order.getStatus().equals(FsStoreOrderStatusEnum.STATUS_1.getValue())) {
+//            if (order != null && !order.getStatus().equals(FsStoreOrderStatusEnum.STATUS_1.getValue())) {
+//                log.info(payCode + "订单号不为待支付回退");
+//                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+//                return R.error();
+//            }
+
+            //orderScrm迁移的表待支付状态码为:0
+            if (order != null && !order.getStatus().equals(0)) {//判断订单状态是否待支付
                 log.info(payCode + "订单号不为待支付回退");
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return R.error();
             }
-            if (order != null && !order.getIsPay().equals(0)) {
+
+            if (order != null && !order.getPaid().equals(0)) {
                 log.info(payCode + "订单号支付不为待支付回退");
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return R.error();
             }
-            fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
+            fsStoreOrderLogsService.create(order.getId(), FsStoreOrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
                     FsStoreOrderLogEnum.PAY_ORDER_SUCCESS.getDesc());
-            FsStoreOrder storeOrder = new FsStoreOrder();
-            storeOrder.setOrderId(order.getOrderId());
-            storeOrder.setIsPay(1);
-            storeOrder.setStatus(2);
+            FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
+            storeOrder.setId(order.getId());
+            storeOrder.setPaid(1);
+//            storeOrder.setStatus(2);
+            storeOrder.setStatus(1);//代发货
             storeOrder.setPrescribePrice(order.getTotalPrice());
             SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.store");
             Map<String, Object> config = (Map<String, Object>) JSON.parse(sysConfig.getConfigValue());
@@ -1451,20 +1471,20 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
             } else {
                 storeOrder.setFollowDoctorId(iFsDoctorService.selectFollowDoctorDoctorByPackage());
             }
-            if (order.getCycle() >= followRate) {
+            if (order.getCycle() != null && order.getCycle() >= followRate) {
                 Calendar calendar = Calendar.getInstance();
                 calendar.setTime(new Date());
                 calendar.add(Calendar.DAY_OF_MONTH, followRate);
                 storeOrder.setFollowTime(calendar.getTime());
             }
             storeOrder.setPayTime(new Date());
-            fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
+            fsStoreOrderScrmMapper.updateFsStoreOrder(storeOrder);
             //更新优惠券状态
-            if (order.getUserCouponId() != null && order.getUserCouponId() > 0) {
-                FsUserCoupon userCoupon = userCouponService.selectFsUserCouponById(order.getUserCouponId());
+            if (order.getCouponId() != null && order.getCouponId() > 0) {
+                FsUserCoupon userCoupon = userCouponService.selectFsUserCouponById(order.getCouponId());
                 if (userCoupon != null && userCoupon.getStatus().equals(0)) {
                     userCoupon.setUseTime(new Date());
-                    userCoupon.setBusinessId(order.getOrderId());
+                    userCoupon.setBusinessId(order.getId());
                     userCoupon.setBusinessType(2);
                     userCoupon.setStatus(1);
                     userCouponService.updateFsUserCoupon(userCoupon);

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreOrderScrm.java

@@ -268,4 +268,10 @@ public class FsStoreOrderScrm extends BaseEntity
 
     private Integer orderMedium; //媒体来源
 
+    //------------新增字段---------------
+    private BigDecimal prescribePrice;//处方定价
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date followTime;//下次随访日期
+    private Long followDoctorId;//随访医生id
+    private Integer cycle; //用药周期
 }

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

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fs.his.domain.FsStorePayment;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.param.FsStorePaymentParam;
 import com.fs.hisStore.param.FsStoreStatisticsParam;
@@ -345,4 +346,7 @@ public interface FsStorePaymentScrmMapper
 
     @Select("select * from fs_store_payment_scrm where trade_no=#{tradeNo}")
     FsStorePaymentScrm selectFsStorePaymentByTradeNo(String tradeNo);
+
+    @Select("select * from fs_store_payment_scrm where pay_code=#{payCode}")
+    FsStorePaymentScrm selectFsStorePaymentByPaymentCode(String payCode);
 }

+ 12 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -244,6 +244,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderVisit != null">order_visit,</if>
             <if test="serviceFee != null">service_fee,</if>
             <if test="orderMedium != null">order_medium,</if>
+            <if test="prescribePrice != null">prescribe_price,</if>
+            <if test="followTime != null">follow_time,</if>
+            <if test="followDoctorId != null">follow_doctor_id,</if>
+            <if test="cycle != null">cycle,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
@@ -326,6 +330,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderVisit != null">#{orderVisit},</if>
             <if test="serviceFee != null">#{serviceFee},</if>
             <if test="orderMedium != null">#{orderMedium},</if>
+            <if test="prescribePrice != null">#{prescribePrice},</if>
+            <if test="followTime != null">#{followTime},</if>
+            <if test="followDoctorId != null">#{followDoctorId},</if>
+            <if test="cycle != null">#{cycle},</if>
          </trim>
     </insert>
 
@@ -414,6 +422,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderVisit != null">order_visit = #{orderVisit},</if>
             <if test="serviceFee != null">service_fee = #{serviceFee},</if>
             <if test="orderMedium != null">order_medium = #{orderMedium},</if>
+            <if test="prescribePrice != null">prescribe_price = #{prescribePrice},</if>
+            <if test="followTime != null">follow_time = #{followTime},</if>
+            <if test="followDoctorId != null">follow_doctor_id = #{followDoctorId},</if>
+            <if test="cycle != null">cycle = #{cycle},</if>
         </trim>
         where id = #{id}
     </update>