瀏覽代碼

更新!

TRX 1 年之前
父節點
當前提交
5e7e235ee5

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/base/SortParam.java

@@ -16,7 +16,7 @@ import java.util.HashMap;
 @NoArgsConstructor
 public class SortParam {
 
-    @Schema(description = "排序数据,如: {'id1': 1, 'id2': 3, 'id3': 2}")
+    @Schema(description = "排序数据 ,如: {'id1': 1, 'id2': 3, 'id3': 2}")
     private HashMap<String, Long> data = new HashMap<>();
 
 }

+ 1 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/utils/PayExceptionToShowUtil.java

@@ -20,7 +20,7 @@ public class PayExceptionToShowUtil {
         String msg = "";
         if (StringUtils.isNotEmpty(cls)) {
             if (cls.contains("BalanceRangeMinException")) {
-                msg = "消费金额超出限制";
+                msg = "余额不足"; // 消费金额超出限制
             } else if (cls.contains("BalanceRangeMaxException")) {
                 msg = "余额不足";
             } else if (cls.contains("UncategorizedMongoDbException")) {

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/payment/ExpenseFlow.java

@@ -173,6 +173,11 @@ public class ExpenseFlow extends SuperMain {
         orderType = OrderState.PARAM_ERROR;
     }
 
+    //------------------订单类型 start-------------------------
+
+    @Schema(description = "是否必须支付,当是离线的时候,是先在边缘计算,再后面付款,则这个订单用户必须支付")
+    private Boolean isMustPay = Boolean.FALSE;
+
     //------------------支付结果 start-------------------------
 
     @Schema(description = "失败时的重复次数")

+ 39 - 7
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/PayOrderSettingService.java

@@ -11,6 +11,8 @@ import com.zhongshu.card.server.core.dao.projectAbout.ProjectPaySettingDao;
 import com.zhongshu.card.server.core.domain.paySetting.PayOrderSetting;
 import com.zhongshu.card.server.core.domain.paySetting.ProjectPaySetting;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.pay.ChinaumsSenselessPayService;
+import com.zhongshu.card.server.core.service.payment.PayCallService;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
@@ -38,6 +40,12 @@ public class PayOrderSettingService extends SuperService {
     @Autowired
     private ProjectChannelConfigService projectChannelConfigService;
 
+    @Autowired
+    private PayCallService payCallService;
+
+    @Autowired
+    private ChinaumsSenselessPayService chinaumsSenselessPayService;
+
     /**
      * 得到用户的支付服务
      *
@@ -112,10 +120,22 @@ public class PayOrderSettingService extends SuperService {
         return newList;
     }
 
-    public List<PaymentType> getUserPayment(String userId, String projectOid) {
+    /**
+     * 得到用户的支付渠道列表 (排序后的数据)
+     *
+     * @param userId
+     * @param projectOid
+     * @return
+     */
+    public ResultContent<List<PaymentType>> getUserPayment(String userId, String projectOid) {
         // 得到项目支持的付款方式
         List<PaymentType> supportTypes = getProjectPayment(projectOid);
+        if (ObjectUtils.isEmpty(supportTypes)) {
+            return ResultContent.buildFail("项目暂无开启支付渠道");
+        }
+        // 不同的支付渠道 结合当前用户判断
         if (ObjectUtils.isNotEmpty(supportTypes)) {
+            // 用户的排序
             List<PayOrderSetting> payOrderSettings = payOrderSettingDao.findByUserIdAndProjectOidOrderBySortAsc(userId, projectOid);
             if (ObjectUtils.isNotEmpty(payOrderSettings)) {
                 Map<PaymentType, Long> map = payOrderSettings.stream().collect(Collectors.toMap(it -> it.getPaymentType(), it -> it.getSort()));
@@ -132,21 +152,33 @@ public class PayOrderSettingService extends SuperService {
             }
         }
 
-        //
+        // 转换后的
         List<PaymentType> userPaymentTypes = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(supportTypes)) {
             for (PaymentType paymentType : supportTypes) {
-                if (paymentType == PaymentType.WeChat) {
-                    paymentType = PaymentType.UserWallet;
+                paymentType = payCallService.turnPaymentType(paymentType);
+                if (paymentType == PaymentType.UnionFrictionlessPay) {
+                    boolean b = chinaumsSenselessPayService.isSigned(projectOid, userId);
+                    if (!b) {
+                        log.info("用户未开启银联无感支付: {}", userId);
+                        continue;
+                    }
                 }
+
                 if (!userPaymentTypes.contains(paymentType)) {
                     userPaymentTypes.add(paymentType);
                 }
             }
         }
-        return userPaymentTypes;
+        return ResultContent.buildSuccess(userPaymentTypes);
     }
 
+    /**
+     * 得到项目支持的支付渠道(已启用的)
+     *
+     * @param projectOid
+     * @return
+     */
     public List<PaymentType> getProjectPayment(String projectOid) {
         List<PaymentType> paymentTypes = new ArrayList<PaymentType>();
         List<ProjectPaySetting> projectPaySettings = projectPaySettingDao.findByProjectOid(projectOid);
@@ -155,8 +187,8 @@ public class PayOrderSettingService extends SuperService {
                 if (projectPaySetting.getState() != DataState.Enable) {
                     continue;
                 }
-                PaymentType channelType = projectPaySetting.getChannelType();
-                paymentTypes.add(channelType);
+                // 启用状态
+                paymentTypes.add(projectPaySetting.getChannelType());
             }
         }
         return paymentTypes;

+ 25 - 5
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/PayCallService.java

@@ -95,10 +95,23 @@ public class PayCallService extends SuperService {
         if (orderType != OrderState.WAIT_PAYMENT) {
             return ResultContent.buildFail(String.format("订单不能支付:%s", orderType.getRemark()));
         }
+
         // 得到用户所有的支付渠道,依次尝试扣款
-        List<PaymentType> paymentTypes = payOrderSettingService.getUserPayment(entity.getUserId(), entity.getProjectOid());
+        ResultContent<List<PaymentType>> resultContent = payOrderSettingService.getUserPayment(entity.getUserId(), entity.getProjectOid());
+        if (resultContent.isFailed()) {
+            String msg = resultContent.getMsg();
+            entity.setPaymentStatus("支付失败");
+            entity.setIsPaySuccess(Boolean.FALSE);
+            entity.setPayRemark(msg);
+            entity.setOrderType(OrderState.PAID_ERROR);
+            entity.setIsPaid(Boolean.TRUE);
+            expenseFlowDao.save(entity);
+            return ResultContent.buildFail(msg);
+        }
+
+        List<PaymentType> paymentTypes = resultContent.getContent();
         if (ObjectUtils.isEmpty(paymentTypes)) {
-            String msg = "项目无支付渠道";
+            String msg = "用户暂无开启支付渠道";
             entity.setPaymentStatus("支付失败");
             entity.setIsPaySuccess(Boolean.FALSE);
             entity.setPayRemark(msg);
@@ -107,6 +120,7 @@ public class PayCallService extends SuperService {
             expenseFlowDao.save(entity);
             return ResultContent.buildFail(msg);
         }
+
         log.info("开始时间:{}", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
         log.info("开始支付: {} {}", entity.getPaymentNo(), paymentTypes);
         int maxTime = 2 * 1000;
@@ -151,9 +165,9 @@ public class PayCallService extends SuperService {
             entity.setIsPaySuccess(Boolean.FALSE);
             entity.setPayRemark(msg);
             entity.setOrderType(OrderState.PAID_ERROR);
-            entity.setIsPaid(Boolean.TRUE);
-            expenseFlowDao.save(entity);
         }
+        entity.setIsPaid(Boolean.TRUE);
+        expenseFlowDao.save(entity);
         return ResultContent.buildSuccess();
     }
 
@@ -606,7 +620,7 @@ public class PayCallService extends SuperService {
                     expenseFlow.setRefundTransactionIds(resultContent.getContent());
                 }
                 refundRecordService.markState(param.getRefundOrderId(), RefundState.Refunded, resultContent.getContent());
-            } else if (refundStatus.equals("FAIL")){
+            } else if (refundStatus.equals("FAIL")) {
                 orderNoInfoService.markSuccess(paymentNo);
                 // 退款失败
                 expenseFlow.setIsRefund(Boolean.TRUE);
@@ -681,6 +695,12 @@ public class PayCallService extends SuperService {
         }
     }
 
+    /**
+     * 支付类型转换,主要是:WeChat -> UserWallet
+     *
+     * @param paymentType
+     * @return
+     */
     public PaymentType turnPaymentType(PaymentType paymentType) {
         if (paymentType != null && paymentType == PaymentType.WeChat) {
             return PaymentType.UserWallet;