Переглянути джерело

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/ChinaumsSenselessPayService.java
TRX 1 рік тому
батько
коміт
8b88a30873

+ 13 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/QueryRechargeOrderModel.java

@@ -0,0 +1,13 @@
+package com.zhongshu.card.client.model.pay;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class QueryRechargeOrderModel {
+
+    private List<RechargeOrderModel> list;
+
+    private Long amountTotal;
+}

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/QueryRechargeParam.java

@@ -3,6 +3,9 @@ package com.zhongshu.card.client.model.pay;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
 @Data
 public class QueryRechargeParam {
 

+ 21 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/QueryTransLogParam.java

@@ -0,0 +1,21 @@
+package com.zhongshu.card.client.model.pay;
+
+import com.zhongshu.card.client.openApi.base.SuperOpenAPIParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class QueryTransLogParam extends SuperOpenAPIParam {
+
+    @Schema(description = "项目oid")
+    private String projectOid;
+
+    @Schema(description = "用户userId")
+    private String userId;
+
+    @Schema(description = "开始时间")
+    private Long startTime;
+
+    @Schema(description = "结束时间")
+    private Long endTime;
+}

+ 27 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/openApi/RefundQueryParam.java

@@ -0,0 +1,27 @@
+package com.zhongshu.card.client.openApi;
+
+import com.github.microservice.types.payment.PaymentType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+@Data
+public class RefundQueryParam {
+
+    @Schema(description = "项目oid")
+    @NotNull(message = "projectOid不能为null")
+    private String projectOid;
+
+    @Schema(description = "机构oid")
+    @NotNull(message = "oid不能为null")
+    private String oid;
+
+    @Schema(description = "用户userId")
+    @NotNull(message = "userId不能为null")
+    private String userId;
+
+    @Schema(description = "退款单号,支付方式为银联无感支付时,必传")
+    private String refundOrderNo;
+}

+ 22 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/utils/DateUtils.java

@@ -851,6 +851,28 @@ public class DateUtils {
         return formattedWholeHours;
     }
 
+    public static List<String> getYesterdayIntegralPoint(String pattern) {
+        // 获取当前日期
+        LocalDate today = LocalDate.now().minusDays(1);
+
+        // 创建一个列表来存储格式化后的整点时间
+        List<String> formattedWholeHours = new ArrayList<>();
+
+        // 遍历 00:00 到 23:00 的每一个整点
+        for (int hour = 0; hour < 24; hour++) {
+            LocalTime time = LocalTime.of(hour, 0); // 整点时间
+            LocalDateTime dateTime = LocalDateTime.of(today, time);
+
+            // 格式化时间
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
+            String formattedDateTime = dateTime.format(formatter);
+
+            // 添加到列表
+            formattedWholeHours.add(formattedDateTime);
+        }
+        return formattedWholeHours;
+    }
+
     public static void main(String[] args) {
         log.info("本年开始时间:{},结束时间:{}", paresTime(getYearStartTime(2023), FORMAT_LONG), paresTime(getYearEndTime(2023), FORMAT_LONG));
         log.info("本月开始时间:{},结束时间:{}", paresTime(getMonthStartTime(2023, 9), FORMAT_LONG), paresTime(getMonthEndTime(2023, 9), FORMAT_LONG));

+ 0 - 24
FullCardServer/src/main/java/com/zhongshu/card/server/core/config/QueueConfig.java

@@ -1,24 +0,0 @@
-package com.zhongshu.card.server.core.config;
-
-import com.github.microservice.components.data.mongo.queue.config.ExecQueueConfig;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-
-import java.util.Map;
-
-@Configuration
-public class QueueConfig extends ExecQueueConfig{
-
-    private static final Map<Integer, Long> SleepTime = Map.of(
-            1, 2000L,
-            2, 3000L,
-            3, 5000L,
-            4, 7000L,
-            5, 11000L
-    );
-
-    @Override
-    public long sleepTime(int tryIndex) {
-        return SleepTime.getOrDefault(tryIndex, 1000L * 60);
-    }
-}

+ 104 - 85
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/PayOpenApiController.java

@@ -1,85 +1,104 @@
-//package com.zhongshu.card.server.core.controller.openAPI;
-//
-//import com.github.microservice.net.ResultContent;
-//import com.github.microservice.types.payment.PaymentType;
-//import com.zhongshu.card.client.openApi.params.PayParam;
-//import com.zhongshu.card.client.openApi.params.RefundParam;
-//import com.zhongshu.card.server.core.service.pay.BalancePayService;
-//import com.zhongshu.card.server.core.service.pay.ChinaumsSenselessPayService;
-//import com.zhongshu.card.server.core.service.pay.PayAccountService;
-//import io.swagger.v3.oas.annotations.Operation;
-//import io.swagger.v3.oas.annotations.tags.Tag;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.util.Assert;
-//import org.springframework.web.bind.annotation.*;
-//
-//import javax.validation.Valid;
-//
-//@RestController
-//@RequestMapping("/openAPI/v1/pay")
-//@Tag(name = "openAPI-支付管理")
-//public class PayOpenApiController {
-//
-//    @Autowired
-//    BalancePayService balancePayService;
-//
-//    @Autowired
-//    ChinaumsSenselessPayService chinaumsSenselessPayService;
-//
-//    @Autowired
-//    PayAccountService payAccountService;
-//
-//    @Operation(summary = "查询个人钱包账户余额", description = "查询个人钱包账户余额")
-//    @RequestMapping(value = "queryDeviceBindUsers", method = {RequestMethod.GET})
-//    public ResultContent<Long> queryUserWallet(@RequestParam("projectOid") String projectOid,
-//                                               @RequestParam("userId") String userId){
-//        return balancePayService.queryUserBalance(projectOid, userId);
-//    }
-//
-//    @Operation(summary = "支付", description = "支付")
-//    @RequestMapping(value = "pay", method = {RequestMethod.POST})
-//    public ResultContent pay(@RequestBody @Valid PayParam param){
-//
-//        if (param.getPaymentType()==null){
-//            return ResultContent.buildFail("paymentType is null");
-//        }
-//
-//        if (param.getPaymentType().equals(PaymentType.UserWallet)){
-//            return balancePayService.balancePay(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRemark());
-//        }else if (param.getPaymentType().equals(PaymentType.UnionFrictionlessPay)){
-//            return chinaumsSenselessPayService.senselessPay(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRemark());
-//        }
-//        return ResultContent.buildFail("参数传入错误,paymentType");
-//    }
-//
-//    @Operation(summary = "退款", description = "退款")
-//    @RequestMapping(value = "refund", method = {RequestMethod.POST})
-//    public ResultContent refund(@RequestBody @Valid RefundParam param){
-//        if (param.getPaymentType()==null){
-//            return ResultContent.buildFail("paymentType is null");
-//        }
-//
-//        if (param.getPaymentType().equals(PaymentType.UserWallet)){
-//            return balancePayService.refund(param.getProjectOid(), param.getOid(), param.getUserId(), param.getOrderNo(), param.getTotal(), param.getRemark());
-//        }else if (param.getPaymentType().equals(PaymentType.UnionFrictionlessPay)){
-//            return chinaumsSenselessPayService.refund(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRefundOrderNo(), param.getRemark(), param.getTargetOrderId());
-//        }
-//        return ResultContent.buildFail("参数传入错误,paymentType");
-//    }
-//
-//    /**
-//     * 退款结果查询
-//     */
-//
-//    /**
-//     * 查询账本
-//     */
-////    public ResultContent queryGeneralLedger(String projectOid, String oid, String userId) {
-////        payAccountService.get
-////    }
-//
-//    /**
-//     *
-//     */
-////    public
-//}
+package com.zhongshu.card.server.core.controller.openAPI;
+
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.pay.client.model.ledger.TransactionLogModel;
+import com.github.microservice.pay.client.model.ledger.transaction.TransactionLogAggregateRetModel;
+import com.github.microservice.types.payment.PaymentType;
+import com.zhongshu.card.client.model.pay.*;
+import com.zhongshu.card.client.openApi.RefundQueryParam;
+import com.zhongshu.card.client.openApi.params.PayParam;
+import com.zhongshu.card.client.openApi.params.RefundParam;
+import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
+import com.zhongshu.card.server.core.service.openAPI.PayOpenApiService;
+import com.zhongshu.card.server.core.service.pay.BalancePayService;
+import com.zhongshu.card.server.core.service.pay.ChinaumsSenselessPayService;
+import com.zhongshu.card.server.core.service.pay.PayAccountService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/openAPI/v1/pay")
+@Tag(name = "openAPI-支付管理")
+public class PayOpenApiController {
+
+    @Autowired
+    PayOpenApiService payOpenApiService;
+
+    @Operation(summary = "查询个人钱包账户余额", description = "查询个人钱包账户余额")
+    @RequestMapping(value = "queryWallet", method = {RequestMethod.GET})
+    public ResultContent<Long> queryWallet(@RequestParam("projectOid") String projectOid,
+                                               @RequestParam("userId") String userId){
+        return payOpenApiService.queryWallet(projectOid, userId);
+    }
+
+    @Operation(summary = "余额支付", description = "余额支付")
+    @RequestMapping(value = "walletPay", method = {RequestMethod.POST})
+    public ResultContent<List<TransactionLogModel>> walletPay(@RequestBody PayParam param){
+       return payOpenApiService.walletPay(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRemark());
+    }
+
+    @Operation(summary = "余额支付退款", description = "余额支付退款")
+    @RequestMapping(value = "walletRefund", method = {RequestMethod.POST})
+    public ResultContent<List<TransactionLogModel>> walletRefund(@RequestBody RefundParam param){
+       return payOpenApiService.walletRefund(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRemark());
+    }
+
+    @Operation(summary = "充值记录查询", description = "充值记录查询")
+    @RequestMapping(value = "rechargeQuery", method = {RequestMethod.POST})
+    public ResultContent<QueryRechargeOrderModel> rechargeQuery(@RequestBody QueryRechargeParam param){
+        return payOpenApiService.rechargeQuery(param);
+    }
+
+    /**
+     * 查询银联无感支付签约状态
+     */
+    @Operation(summary = "查询银联无感支付签约状态", description = "查询银联无感支付签约状态")
+    @RequestMapping(value = "unionSenselessSignQuery", method = {RequestMethod.GET})
+    public ResultContent<ChinaumsSenselessUserSignInfoModel> unionSenselessSignQuery(@RequestParam("projectOid") String projectOid,
+                                                                                     @RequestParam("userId") String userId){
+        return payOpenApiService.unionSenselessSignQuery(projectOid, userId);
+    }
+
+    @Operation(summary = "银联无感支付签约", description = "银联无感支付签约")
+    @RequestMapping(value = "unionSenselessSign", method = {RequestMethod.POST})
+    public ResultContent<Object> unionSenselessSign(@RequestBody UnionApplySignParam param){
+        return payOpenApiService.unionSenselessSign(param);
+    }
+
+    @Operation(summary = "银联无感支付扣费", description = "银联无感支付扣费")
+    @RequestMapping(value = "unionSenselessPay", method = {RequestMethod.POST})
+    public ResultContent<Object> unionSenselessPay(@RequestBody PayParam param){
+        return payOpenApiService.unionSenselessPay(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRemark());
+    }
+
+    @Operation(summary = "银联无感支付退款", description = "银联无感支付退款")
+    @RequestMapping(value = "unionSenselessRefund", method = {RequestMethod.POST})
+    public ResultContent<Object> unionSenselessRefund(@RequestBody RefundParam param){
+        return payOpenApiService.unionSenselessRefund(param.getProjectOid(), param.getOid(), param.getUserId(), param.getTotal(), param.getOrderNo(), param.getRefundOrderNo(), param.getRemark(), param.getTargetOrderId());
+    }
+
+    @Operation(summary = "银联无感支付退款查询", description = "银联无感支付退款查询")
+    @RequestMapping(value = "unionSenselessRefundQuery", method = {RequestMethod.POST})
+    public ResultContent<UnionFrictionlessPayFinishModel> unionSenselessRefundQuery(@RequestBody RefundQueryParam param){
+        return payOpenApiService.unionSenselessRefundQuery(param.getProjectOid(), param.getOid(), param.getUserId(), param.getRefundOrderNo());
+    }
+
+    /**
+     * 用户流水查询
+     */
+    @Operation(summary = "查询用户流水-分页查询", description = "查询用户流水-分页查询")
+    @RequestMapping(value = {"queryTransLog"}, method = {RequestMethod.POST})
+    public ResultContent<TransactionLogAggregateRetModel> queryTransLog(@RequestBody QueryTransLogParam param){
+        Pageable pageable = PageRequest.of(param.getNumber(), param.getSize());
+        return payOpenApiService.queryTransLog(pageable, param);
+    }
+
+}

+ 143 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/openAPI/PayOpenApiService.java

@@ -0,0 +1,143 @@
+package com.zhongshu.card.server.core.service.openAPI;
+
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.pay.client.model.ledger.TransactionLogModel;
+import com.github.microservice.pay.client.model.ledger.transaction.TransactionLogAggregateRetModel;
+import com.github.microservice.pay.client.ret.ResultState;
+import com.zhongshu.card.client.model.pay.*;
+import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
+import com.zhongshu.card.server.core.service.pay.BalancePayService;
+import com.zhongshu.card.server.core.service.pay.ChinaumsSenselessPayService;
+import com.zhongshu.card.server.core.service.pay.OrgOverviewService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Service
+public class PayOpenApiService {
+
+    @Autowired
+    BalancePayService balancePayService;
+
+    @Autowired
+    ChinaumsSenselessPayService chinaumsSenselessPayService;
+
+    @Autowired
+    OrgOverviewService orgOverviewService;
+
+    /**
+     * 查询钱包余额
+     */
+    public ResultContent<Long> queryWallet(String projectOid, String userId){
+        com.github.microservice.pay.client.ret.ResultContent<Long> resultContent = balancePayService.queryUserBalance(projectOid, userId);
+        if (resultContent.getState() == ResultState.Success){
+            return ResultContent.buildContent(resultContent.getContent());
+        }
+        return ResultContent.buildFail(resultContent.getMsg());
+    }
+
+    /**
+     * 余额支付
+     */
+    public ResultContent<List<TransactionLogModel>> walletPay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark){
+        com.github.microservice.pay.client.ret.ResultContent resultContent = balancePayService.balancePay(projectOid, oid, userId, total, orderNo, remark);
+        if (resultContent.getState() == ResultState.Success){
+            return ResultContent.buildContent(resultContent.getContent());
+        }
+        return ResultContent.buildFail(resultContent.getMsg());
+    }
+
+    /**
+     * 余额支付退款
+     */
+    public ResultContent<List<TransactionLogModel>> walletRefund(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark){
+        com.github.microservice.pay.client.ret.ResultContent<List<TransactionLogModel>> resultContent = balancePayService.refund(projectOid, oid, userId, orderNo, total, remark);
+        if (resultContent.getState() == ResultState.Success){
+            return ResultContent.buildContent(resultContent.getContent());
+        }
+        return ResultContent.buildFail(resultContent.getMsg());
+    }
+
+    /**
+     * 充值记录查询
+     */
+    public ResultContent<QueryRechargeOrderModel> rechargeQuery(QueryRechargeParam param){
+
+        Assert.notNull(param.getYear(), "参数校验失败:year is null");
+        Assert.notNull(param.getMonth(), "参数校验失败:month is null");
+        Assert.notNull(param.getProjectOid(), "参数校验失败:projectOid is null");
+        Assert.notNull(param.getUserId(), "参数校验失败:userId is null");
+
+        com.github.microservice.pay.client.ret.ResultContent resultContent = balancePayService.queryRechargeOrder(param);
+        if (resultContent.getState() == ResultState.Success){
+            return ResultContent.buildContent(resultContent.getContent());
+        }
+        return ResultContent.buildFail(resultContent.getMsg());
+    }
+
+    /**
+     * 查询银联无感支付签约状态
+     */
+    public ResultContent<ChinaumsSenselessUserSignInfoModel> unionSenselessSignQuery(String projectOid, String userId){
+        Assert.notNull(projectOid, "参数校验失败:projectOid is null");
+        Assert.notNull(userId, "参数校验失败:userId is null");
+        return chinaumsSenselessPayService.queryUserSignInfo(userId, projectOid);
+    }
+
+    /**
+     * 银联无感支付签约
+     */
+    public ResultContent unionSenselessSign(UnionApplySignParam param){
+        Assert.notNull(param.getInvokeScene(), "参数校验失败:invokeScene is null");
+        Assert.notNull(param.getMchntWxMpAppId(), "参数校验失败:mchntWxMpAppId is null");
+        Assert.notNull(param.getMchntWxMpPath(), "参数校验失败:mchntWxMpPath is null");
+        Assert.notNull(param.getProjectOid(), "参数校验失败:projectOid is null");
+        Assert.notNull(param.getUserId(), "参数校验失败:userId is null");
+        return chinaumsSenselessPayService.signApply(param);
+    }
+
+    /**
+     * 银联无感支付
+     */
+    public ResultContent unionSenselessPay(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String remark){
+        Assert.notNull(projectOid, "参数校验失败:projectOid is null");
+        Assert.notNull(oid, "参数校验失败:oid is null");
+        Assert.notNull(userId, "参数校验失败:userId is null");
+        Assert.notNull(total, "参数校验失败:total is null");
+        Assert.notNull(orderNo, "参数校验失败:orderNo is null");
+        return chinaumsSenselessPayService.senselessPay(projectOid, oid, userId, total, orderNo, remark);
+    }
+
+    /**
+     * 银联无感支付退款
+     */
+    public ResultContent<Object> unionSenselessRefund(String projectOid, String oid, String userId, BigDecimal total, String orderNo, String refundOrderNo, String remark, String targetOrderId){
+        Assert.notNull(projectOid, "参数校验失败:projectOid is null");
+        Assert.notNull(oid, "参数校验失败:oid is null");
+        Assert.notNull(userId, "参数校验失败:userId is null");
+        Assert.notNull(total, "参数校验失败:total is null");
+        Assert.notNull(orderNo, "参数校验失败:orderNo is null");
+        Assert.notNull(refundOrderNo, "参数校验失败:refundOrderNo is null");
+        Assert.notNull(targetOrderId, "参数校验失败:targetOrderId is null");
+        return chinaumsSenselessPayService.refund(projectOid, oid, userId, total, orderNo, refundOrderNo, remark, targetOrderId);
+    }
+
+    /**
+     * 银联无感支付退款查询
+     */
+    public ResultContent<UnionFrictionlessPayFinishModel> unionSenselessRefundQuery(String projectOid, String oid, String userId, String refundOrderNo){
+        return chinaumsSenselessPayService.refundQuery(projectOid, userId, oid, refundOrderNo, false);
+    }
+
+    /**
+     * 用户流水查询
+     */
+    public ResultContent<TransactionLogAggregateRetModel> queryTransLog(Pageable pageable, QueryTransLogParam param){
+        return orgOverviewService.queryAccountTreeFlow(pageable, param);
+    }
+
+}

+ 2 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/BalancePayService.java

@@ -17,6 +17,7 @@ import com.github.microservice.pay.client.type.ledger.TransactionType;
 import com.github.microservice.types.payment.PaymentChannelType;
 import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.model.mqtt.SendMessageModel;
+import com.zhongshu.card.client.model.pay.QueryRechargeOrderModel;
 import com.zhongshu.card.client.model.pay.QueryRechargeParam;
 import com.zhongshu.card.client.model.pay.RechargeOrderModel;
 import com.zhongshu.card.client.model.pay.RechargeParam;
@@ -224,7 +225,7 @@ public class BalancePayService extends SuperService {
 
     }
 
-    public ResultContent queryRechargeOrder(QueryRechargeParam param) {
+    public ResultContent<QueryRechargeOrderModel> queryRechargeOrder(QueryRechargeParam param) {
         String projectOid = getCurrentProjectOid();
         String userId = getCurrentUserId();
 

+ 35 - 50
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/ChinaumsSenselessPayService.java

@@ -1,9 +1,8 @@
 package com.zhongshu.card.server.core.service.pay;
 
-import com.github.microservice.components.data.mongo.queue.service.ExecQueueService;
-import com.github.microservice.core.helper.ApplicationContextHolder;
 import com.github.microservice.core.util.JsonUtil;
 import com.github.microservice.core.util.bean.BeanUtil;
+import com.github.microservice.core.util.queue.ExecuteQueueUtil;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.pay.client.model.AccountModel;
 import com.github.microservice.pay.client.model.PayProductParameter;
@@ -36,7 +35,6 @@ import com.zhongshu.card.server.core.domain.payment.ExpenseFlow;
 import com.zhongshu.card.server.core.model.pay.UnionFrictionlessPayFinishModel;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.paySetting.OrgPayAccountService;
-import com.zhongshu.card.server.core.service.paySetting.ProjectMainPaySettingService;
 import com.zhongshu.card.server.core.service.payment.PayCallService;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import com.zhongshu.card.server.core.util.CommonUtil;
@@ -76,11 +74,6 @@ public class ChinaumsSenselessPayService extends SuperService {
     @Autowired
     ShareOrderDao shareOrderDao;
 
-    @Autowired
-    ExecQueueService execQueueService;
-
-    @Autowired
-    private ProjectMainPaySettingService projectMainPaySettingService;
 
 
     /**
@@ -88,7 +81,7 @@ public class ChinaumsSenselessPayService extends SuperService {
      *
      * @return
      */
-    public Object signApply(UnionApplySignParam param) {
+    public ResultContent signApply(UnionApplySignParam param) {
 
         String projectOid = param.getProjectOid();
         String userId = param.getUserId();
@@ -105,7 +98,7 @@ public class ChinaumsSenselessPayService extends SuperService {
         String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
         com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
         if (!accountModelResultContent.getState().equals(ResultState.Success)) {
-            return accountModelResultContent;
+            return ResultContent.buildFail(accountModelResultContent.getMsg());
         }
         ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
         String mid = conf.getMchId();
@@ -151,7 +144,7 @@ public class ChinaumsSenselessPayService extends SuperService {
     }
 
     @SneakyThrows
-    private Object signApply(UnionApplySignParam param, String accountName, String userId, String mid) {
+    private ResultContent signApply(UnionApplySignParam param, String accountName, String userId, String mid) {
         PayProductParameter<Object> payProductParameter = new PayProductParameter<>();
         payProductParameter.setAccountName(accountName);
         payProductParameter.setMeta(BeanUtil.bean2Map(param));
@@ -173,7 +166,7 @@ public class ChinaumsSenselessPayService extends SuperService {
                 userSignInfo.setExpireTime(System.currentTimeMillis() + 30 * 60 * 1000);
                 userSignInfo.setExpire(false);
                 chinaumsSenselessUserSignInfoDao.save(userSignInfo);
-                return signApplyResultContent;
+                return ResultContent.buildContent(signApplyResultContent.getContent());
             } else {
                 return ResultContent.buildFail((String) resultMap.get("errMsg"));
             }
@@ -181,18 +174,14 @@ public class ChinaumsSenselessPayService extends SuperService {
         return ResultContent.buildFail("银联请求失败");
     }
 
-    public boolean isSigned(String projectOid, String userId) {
-//        String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
-//        com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
-//        if (!accountModelResultContent.getState().equals(ResultState.Success)) {
-//            throw new RuntimeException(accountModelResultContent.getMsg());
-//        }
-//        ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
-//        String mid = conf.getMchId();
-        String mid = projectMainPaySettingService.getProjectPaymentMchId(projectOid, PaymentType.UnionFrictionlessPay);
-        if (StringUtils.isEmpty(mid)) {
-            return false;
+    public boolean isSigned(String projectOid, String userId){
+        String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
+        com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
+        if (!accountModelResultContent.getState().equals(ResultState.Success)) {
+            throw new RuntimeException(accountModelResultContent.getMsg());
         }
+        ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
+        String mid = conf.getMchId();
         ChinaumsSenselessUserSignInfo topByUserIdAndMidAndExpire = chinaumsSenselessUserSignInfoDao.findTopByUserIdAndMidAndExpire(userId, mid, false);
         return topByUserIdAndMidAndExpire.getContractState().equals(ContractState.SIGNED);
     }
@@ -256,7 +245,7 @@ public class ChinaumsSenselessPayService extends SuperService {
 
 
     //TODO 添加 判断是否在平台外已经签约逻辑
-    public Object queryUserSignInfo(String userId, String projectOid) {
+    public ResultContent<ChinaumsSenselessUserSignInfoModel> queryUserSignInfo(String userId, String projectOid) {
         if (StringUtils.isBlank(userId)) {
             userId = getCurrentUserId();
         }
@@ -269,7 +258,7 @@ public class ChinaumsSenselessPayService extends SuperService {
         String accountName = orgPayAccountService.queryOgPayAccount(projectOid, PaymentType.UnionFrictionlessPay);
         com.github.microservice.pay.client.ret.ResultContent<AccountModel> accountModelResultContent = payProductAccountService.get(accountName);
         if (!accountModelResultContent.getState().equals(ResultState.Success)) {
-            return accountModelResultContent;
+            return ResultContent.buildFail(accountModelResultContent.getMsg());
         }
         ChinaumsSenselessConf conf = (ChinaumsSenselessConf) accountModelResultContent.getContent().getConf();
         String mid = conf.getMchId();
@@ -431,38 +420,34 @@ public class ChinaumsSenselessPayService extends SuperService {
         payProductParameter.setMeta(BeanUtil.bean2Map(request));
         com.github.microservice.pay.client.ret.ResultContent<Object> refundResultContent = senselessPayService.refund(payProductParameter);
         if (!refundResultContent.getState().equals(ResultState.Success)) {
-            return ResultContent.buildFail("请求失败");
+            return ResultContent.buildFail(refundResultContent.getMsg());
         }
         Map bodyMap = JsonUtil.toObject(JsonUtil.toJson(refundResultContent.getContent()), Map.class);
 
         if (bodyMap.get("respCode").equals("TARGET_PROCESSING")) {
-            execQueueService.add(Map.of("refundOrderNo", refundOrderNo), 5, data -> {
-                final ExpenseFlowDao expenseFlowDao = ApplicationContextHolder.getContext().getBean(ExpenseFlowDao.class);
-                final ChinaumsSenselessPayService chinaumsSenselessPayService = ApplicationContextHolder.getContext().getBean(ChinaumsSenselessPayService.class);
-                final PayCallService payCallService = ApplicationContextHolder.getContext().getBean(PayCallService.class);
-                String number = (String) data.get("refundOrderNo");
-                ExpenseFlow refundOrder = expenseFlowDao.findTopByRefundNo(number);
-                if (refundOrder == null) {
-                    log.info("找不到退款单");
-                    return false;
-                }
-                if (refundOrder.getRefundState().equals(RefundState.Refunded) || refundOrder.getRefundState().equals(RefundState.Fail)) {
-                    log.info("当前退款单状态为已退款或退款失败");
-                    return true;
-                }
-                ResultContent<UnionFrictionlessPayFinishModel> refundQuery = chinaumsSenselessPayService.refundQuery(refundOrder.getProjectOid(), refundOrder.getUserId(), refundOrder.getShopOid(), refundOrderNo, true);
-                if (!refundQuery.getState().equals(com.github.microservice.net.ResultState.Success)) {
+            UnionFrictionlessPayFinishModel unionFrictionlessPayFinishModel = ExecuteQueueUtil.execute(5, index->{
+                return Map.of(1, 1000L, 2, 1000L, 3, 1000L, 4, 2000L).getOrDefault(index, 3000L);
+            }, it->{
+                var result = new ExecuteQueueUtil.Result<UnionFrictionlessPayFinishModel>();
+
+                ResultContent<UnionFrictionlessPayFinishModel> refundQuery = refundQuery(projectOid, userId, oid, refundOrderNo, true);
+                if (!refundQuery.getState().equals(com.github.microservice.net.ResultState.Success)){
                     log.info("查询退款结果失败:{}", refundQuery.getMsg());
-                    return false;
+                    return null;
                 }
-                log.info("refundStatus:{}", refundQuery.getContent().getRefundStatus());
-                if (refundQuery.getContent().getRefundStatus().equals("PROCESSING") || refundQuery.getContent().getRefundStatus().equals("UNKNOWN")) {
-                    return false;
+                if (refundQuery.getContent().getRefundStatus().equals("SUCCESS") || refundQuery.getContent().getRefundStatus().equals("FAIL")){
+                    result.setData(refundQuery.getContent());
+                    result.setDone(true);
+                    return result;
+                }
+                long time = System.currentTimeMillis() - it.getStartTime();
+                if (time > 3000L){
+
                 }
-                ResultContent resultContent = payCallService.unionFrictionlessPayRefundFinish(refundQuery.getContent());
-                return resultContent.getState().equals(com.github.microservice.net.ResultState.Success);
-            }, System.currentTimeMillis() + 30 * 24 * 60 * 60 * 1000L);
-            return ResultContent.buildContent(refundResultContent.getContent());
+                log.info("退款状态未知或退款中,继续查询,index:{}", it.getIndex());
+                return null;
+            });
+            return ResultContent.buildContent(unionFrictionlessPayFinishModel);
         }
         return ResultContent.buildFail(bodyMap.get("respDesc").toString());
     }

+ 32 - 20
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/OrgOverviewService.java

@@ -12,10 +12,7 @@ import com.github.microservice.pay.client.type.ledger.LedgerEntry;
 import com.github.microservice.pay.client.type.ledger.TransactionStatus;
 import com.github.microservice.pay.client.type.ledger.TransactionType;
 import com.github.microservice.types.payment.PaymentChannelType;
-import com.zhongshu.card.client.model.pay.BalanceOverviewModel;
-import com.zhongshu.card.client.model.pay.PeriodDetailQueryModel;
-import com.zhongshu.card.client.model.pay.PeriodQueryModel;
-import com.zhongshu.card.client.model.pay.RealTimeOverviewModel;
+import com.zhongshu.card.client.model.pay.*;
 import com.zhongshu.card.client.type.PeriodType;
 import com.zhongshu.card.client.utils.DateUtils;
 import com.zhongshu.card.server.core.domain.pay.PayAccount;
@@ -54,18 +51,27 @@ public class OrgOverviewService extends SuperService {
     /**
      * 查询用户流水
      */
-    public Object queryAccountTreeFlow(Pageable pageable, Long startTime, Long endTime){
-        String currentUserId = getCurrentUserId();
-        String projectOid = getCurrentProjectOid();
+    public com.github.microservice.net.ResultContent<TransactionLogAggregateRetModel> queryAccountTreeFlow(Pageable pageable, QueryTransLogParam param){
+
+        String userId = param.getUserId();
+        String projectOid = param.getProjectOid();
+
+        if (StringUtils.isBlank(userId)){
+            userId = getCurrentUserId();
+        }
+
+        if (StringUtils.isBlank(projectOid)){
+            projectOid = getCurrentProjectOid();
+        }
 
         if (StringUtils.isBlank(projectOid)){
             return com.github.microservice.net.ResultContent.buildFail("projectOid is null");
         }
 
-        PayAccount userParent = payAccountService.getUserParent(projectOid, currentUserId);
+        PayAccount userParent = payAccountService.getUserParent(projectOid, userId);
         ResultContent<GeneralLedgerQueryModel> ledgerRet = generalLedgerService.get(userParent.getLedgerId());
         if (!ledgerRet.getState().equals(ResultState.Success)){
-            return ledgerRet;
+            return com.github.microservice.net.ResultContent.buildFail(ledgerRet.getMsg());
         }
 
         ResultContent<GeneralLedgerTreeModel> descendantRet = generalLedgerService.descendant(userParent.getLedgerId());
@@ -85,9 +91,13 @@ public class OrgOverviewService extends SuperService {
 //        descendantQueryTransactionLogModel.setGeneralLedgerId(new String[]{userParent.getLedgerId()});
         descendantQueryTransactionLogModel.setPage(pageableModel);
         descendantQueryTransactionLogModel.setParentGeneralLedgerId(userParent.getLedgerId());
-        descendantQueryTransactionLogModel.setStartTime(startTime);
-        descendantQueryTransactionLogModel.setEndTime(endTime);
-        return transactionLogService.aggregate(descendantQueryTransactionLogModel);
+        descendantQueryTransactionLogModel.setStartTime(param.getStartTime());
+        descendantQueryTransactionLogModel.setEndTime(param.getEndTime());
+        ResultContent<TransactionLogAggregateRetModel> aggregate = transactionLogService.aggregate(descendantQueryTransactionLogModel);
+        if (aggregate.getState().equals(ResultState.Success)){
+            return com.github.microservice.net.ResultContent.buildContent(aggregate.getContent());
+        }
+        return com.github.microservice.net.ResultContent.buildFail(aggregate.getMsg());
     }
 
     /**
@@ -148,9 +158,9 @@ public class OrgOverviewService extends SuperService {
         List<TransactionLogRealTimeAggregateRetModel> today = realTimeAggregate(waitSettleAccount.getLedgerId(), DateUtils.getCurrentDayStartTime().getTime(),
                 DateUtils.getCurrentDayEndTime().getTime(),
                 Map.of("ledgerEntry", LedgerEntry.Credit));
-        List<String> currentIntegralPoint = DateUtils.getCurrentIntegralPoint("yyyy-MM-dd H");
-
-        buildRealTimeAmountList(yesterdayList, yesterday, currentIntegralPoint);
+        List<String> currentIntegralPoint = DateUtils.getCurrentIntegralPoint("yyyy-MM-dd HH");
+        List<String> yesterdayIntegralPoint = DateUtils.getYesterdayIntegralPoint("yyyy-MM-dd HH");
+        buildRealTimeAmountList(yesterdayList, yesterday, yesterdayIntegralPoint);
         buildRealTimeAmountList(todayList, today, currentIntegralPoint);
         Long todayAmount = todayList.stream().mapToLong(it -> {
             return it;
@@ -170,8 +180,8 @@ public class OrgOverviewService extends SuperService {
                 DateUtils.getCurrentDayEndTime().getTime(),
                 Map.of("ledgerEntry", LedgerEntry.Credit));
 
-        buildRealTimeAmountList(yesterdayOrderList, yesterdayGroupByOrderNumber, currentIntegralPoint);
-        buildRealTimeAmountList(todayOrderList, todayGroupByOrderNumber, currentIntegralPoint);
+        yesterdayOrderList = buildRealTimeAmountList(yesterdayOrderList, yesterdayGroupByOrderNumber, currentIntegralPoint);
+        todayOrderList = buildRealTimeAmountList(todayOrderList, todayGroupByOrderNumber, currentIntegralPoint);
         Long todayOrder = todayOrderList.stream().mapToLong(it -> {
             return it;
         }).sum();
@@ -313,7 +323,7 @@ public class OrgOverviewService extends SuperService {
     }
 
 
-    private static Long changeRate(Long todayAmount, Long yesterdayAmount) {
+    private Long changeRate(Long todayAmount, Long yesterdayAmount) {
         Long amountChangeRate = null;
         if (yesterdayAmount != 0L){
             amountChangeRate = (todayAmount - yesterdayAmount) / yesterdayAmount;
@@ -323,18 +333,20 @@ public class OrgOverviewService extends SuperService {
         return amountChangeRate;
     }
 
-    private static void buildRealTimeAmountList(List<Long> amountList, List<TransactionLogRealTimeAggregateRetModel> modelList, List<String> currentIntegralPoint) {
+    private List<Long> buildRealTimeAmountList(List<Long> amountList, List<TransactionLogRealTimeAggregateRetModel> modelList, List<String> currentIntegralPoint) {
         Map<String, Long> yesterdayMap;
         if (modelList !=null){
             yesterdayMap = modelList.stream().collect(Collectors.toMap(TransactionLogRealTimeAggregateRetModel::getDateTime, TransactionLogRealTimeAggregateRetModel::getAmount));
             for (String point : currentIntegralPoint) {
-                amountList.add(yesterdayMap.getOrDefault(point, 0L)/100);
+                amountList.add(yesterdayMap.getOrDefault(point, 0L));
+                log.info("point: {}, map: {}", point, yesterdayMap.getOrDefault(point, 0L));
             }
         }else {
             for (int i = 0; i < currentIntegralPoint.size(); i++) {
                 amountList.add(0L);
             }
         }
+        return amountList;
     }
 
     private List<TransactionLogRealTimeAggregateRetModel> realTimeAggregate(String ledgerId, Long startTime, Long endTime, Map<String, Object> filter) {

+ 9 - 11
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/WithdrawService.java

@@ -1,8 +1,8 @@
 package com.zhongshu.card.server.core.service.pay;
 
 import com.github.microservice.components.data.base.util.PageEntityUtil;
-import com.github.microservice.components.data.mongo.queue.service.ExecQueueService;
 import com.github.microservice.core.util.JsonUtil;
+import com.github.microservice.core.util.queue.ExecuteQueueUtil;
 import com.github.microservice.pay.client.model.AccountModel;
 import com.github.microservice.pay.client.model.PayProductParameter;
 import com.github.microservice.pay.client.model.ledger.GeneralLedgerQueryModel;
@@ -90,8 +90,6 @@ public class WithdrawService extends SuperService {
     @Autowired
     PayProductAccountService payProductAccountService;
 
-    @Autowired
-    ExecQueueService execQueueService;
 
     /**
      * 查询可提现余额
@@ -398,14 +396,14 @@ public class WithdrawService extends SuperService {
                 withdrawOrder.setProcessUserId(userAccount.getUserId());
                 withdrawOrder.setProcessTime(System.currentTimeMillis());
                 withdrawOrderDao.save(withdrawOrder);
-                execQueueService.add(Map.of("withdrawOrderId", withdrawOrder.getId()), 5, data->{
-                    com.github.microservice.net.ResultContent<WithdrawStatus> resultContent = withdrawQuery((String) data.get("withdrawUserId"));
-                    if (resultContent.getState().equals(com.github.microservice.net.ResultState.Success)){
-                        WithdrawStatus withdrawStatus = resultContent.getContent();
-                        return !withdrawStatus.equals(WithdrawStatus.Accepted);
-                    }
-                    return true;
-                });
+//                ExecuteQueueUtil.execute(5, 1000L, data->{
+//                    com.github.microservice.net.ResultContent<WithdrawStatus> resultContent = withdrawQuery((String) data.get("withdrawUserId"));
+//                    if (resultContent.getState().equals(com.github.microservice.net.ResultState.Success)){
+//                        WithdrawStatus withdrawStatus = resultContent.getContent();
+//                        return !withdrawStatus.equals(WithdrawStatus.Accepted);
+//                    }
+//                    return true;
+//                });
                 return com.github.microservice.net.ResultContent.buildSuccess();
             }
         }