Explorar o código

Merge remote-tracking branch 'origin/master'

wujiefeng hai 1 ano
pai
achega
a223f62a16
Modificáronse 22 ficheiros con 484 adicións e 60 borrados
  1. 6 8
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/payConfig/FrictionlessUnionConfigModel.java
  2. 7 9
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/payConfig/FrictionlessUnionConfigParam.java
  3. 4 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/PayShareListModel.java
  4. 4 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/PayShareListParam.java
  5. 12 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectMainPaySettingModel.java
  6. 6 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectMainPaySettingParam.java
  7. 6 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectPaySettingInfoModel.java
  8. 2 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/payment/PaymentTypeParam.java
  9. 11 4
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/paySetting/ProjectMainPaySettingController.java
  10. 48 8
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/paySetting/ProjectPaySettingController.java
  11. 2 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/projectAbout/PayShareListDao.java
  12. 5 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/projectAbout/ProjectMainPaySettingDao.java
  13. 2 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/schedule/impl/ScheduleTaskConfigDaoImpl.java
  14. 4 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/paySetting/PayShareList.java
  15. 18 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/paySetting/ProjectMainPaySetting.java
  16. 6 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/schedule/ScheduleTaskConfig.java
  17. 2 2
      FullCardServer/src/main/java/com/zhongshu/card/server/core/httpRequest/conf/IotCenterAPIConfig.java
  18. 8 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectChannelConfigService.java
  19. 78 8
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectMainPaySettingService.java
  20. 234 10
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectPaySettingServiceImpl.java
  21. 17 3
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/schedule/ScheduleTaskConfigService.java
  22. 2 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/schedule/ScheduledTask.java

+ 6 - 8
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/payConfig/FrictionlessUnionConfigModel.java

@@ -19,17 +19,9 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 public class FrictionlessUnionConfigModel {
 
-    //----------------------------业务信息 start-----------------
-
     @Schema(description = "商户号")
     private String mchId;
 
-    @Schema(description = "无感支付签约状态通知地址")
-    private String notifyUrl = "";
-
-    @Schema(description = "支付结果通知地址")
-    private String payNotifyUrl = "";
-
     @Schema(description = "无感支付 秘钥 测试环境通知加密密钥")
     private String notifySecret;
 
@@ -54,6 +46,12 @@ public class FrictionlessUnionConfigModel {
     @Schema(description = "商户订单号固定开头")
     private String orderStart = "";
 
+    @Schema(description = "无感支付签约状态通知地址")
+    private String notifyUrl = "";
+
+    @Schema(description = "支付结果通知地址")
+    private String payNotifyUrl = "";
+
     @Schema(description = "订单交易过期时间")
     private Long expireTime = 30 * 60 * 1000L;
 

+ 7 - 9
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/payConfig/FrictionlessUnionConfigParam.java

@@ -19,14 +19,6 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 public class FrictionlessUnionConfigParam extends PayConfigParam {
 
-    //----------------------------业务信息 start-----------------
-
-    @Schema(description = "无感支付签约状态通知地址")
-    private String notifyUrl = "";
-
-    @Schema(description = "支付结果通知地址")
-    private String payNotifyUrl = "";
-
     @Schema(description = "无感支付 秘钥 测试环境通知加密密钥")
     private String notifySecret;
 
@@ -45,12 +37,18 @@ public class FrictionlessUnionConfigParam extends PayConfigParam {
     @Schema(description = "来源编号")
     private String msgSrcId;
 
-    @Schema(description = "签约结束后调整小程序id")
+    @Schema(description = "签约结束后跳转小程序id")
     private String mchntWxMpAppId;
 
     @Schema(description = "商户订单号固定开头")
     private String orderStart = "";
 
+    @Schema(description = "无感支付签约状态通知地址")
+    private String notifyUrl = "";
+
+    @Schema(description = "支付结果通知地址")
+    private String payNotifyUrl = "";
+
     @Schema(description = "订单交易过期时间")
     private Long expireTime = 30 * 60 * 1000L;
 

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/PayShareListModel.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.client.model.paySetting.paySetting;
 
+import com.github.microservice.types.payment.PaymentType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -22,6 +23,9 @@ public class PayShareListModel {
     @Schema(description = "项目ID")
     private String projectOid;
 
+    @Schema(description = "支付渠道")
+    private PaymentType paymentType;
+
     @Schema(description = "规则名称")
     private String name;
 

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/PayShareListParam.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.client.model.paySetting.paySetting;
 
+import com.github.microservice.types.payment.PaymentType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotEmpty;
 import lombok.AllArgsConstructor;
@@ -24,6 +25,9 @@ public class PayShareListParam {
     @NotEmpty
     private String projectOid;
 
+    @Schema(description = "支付渠道")
+    private PaymentType paymentType;
+
     @Schema(description = "规则名称")
     @NotEmpty
     private String name;

+ 12 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectMainPaySettingModel.java

@@ -24,12 +24,18 @@ import java.math.BigDecimal;
 @NoArgsConstructor
 public class ProjectMainPaySettingModel {
 
+    @Schema(description = "所属项目oid")
+    private String projectOid;
+
     @Schema(description = "选择的机构主支付配置数据id")
     private String paySettingInfoId;
 
     @Schema(description = "选择的机构主支付配置数据id")
     private String paySettingInfoName;
 
+    @Schema(description = "选中的机构支付配置")
+    private ProjectPaySettingInfoModel settingInfoModel;
+
     @Schema(description = "所属机构oid")
     private String belongOig;
 
@@ -53,11 +59,17 @@ public class ProjectMainPaySettingModel {
     @Max(value = 100)
     private Integer days;
 
+    @Schema(description = "d+N的时间")
+    private String dnTimeStr;
+
     //---------------定期结算 设置
 
     @Schema(description = "定期类型")
     private RegularType regularType;
 
+    @Schema(description = "定期结算时间")
+    private String regularTimeStr;
+
     @Schema(description = "当前的时间,如:12:30")
     @NotEmpty
     private String timeStr;

+ 6 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectMainPaySettingParam.java

@@ -39,12 +39,17 @@ public class ProjectMainPaySettingParam {
     @Schema(description = "天数,>= 1")
     private Integer days;
 
+    @Schema(description = "d+N的时间")
+    private String dnTimeStr;
+
     //---------------定期结算 设置
 
     @Schema(description = "定期类型")
-    @NotNull
     private RegularType regularType;
 
+    @Schema(description = "定期结算时间")
+    private String regularTimeStr;
+
     @Schema(description = "当前的时间,如:12:30")
     private String timeStr;
 

+ 6 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/paySetting/paySetting/ProjectPaySettingInfoModel.java

@@ -19,6 +19,12 @@ import org.apache.commons.lang3.ObjectUtils;
 @NoArgsConstructor
 public class ProjectPaySettingInfoModel extends SuperModel {
 
+    @Schema(description = "所属机构oid")
+    private String belongOig;
+
+    @Schema(description = "所属机构名称")
+    private String belongOrgName;
+
     //----------------------------------业务数据 -------------------
 
     @Schema(description = "支付产品的logo")

+ 2 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/payment/PaymentTypeParam.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.client.model.payment;
 
 import com.github.microservice.types.payment.PaymentType;
+import com.zhongshu.card.client.model.base.ProjectOidParam;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -13,7 +14,7 @@ import lombok.NoArgsConstructor;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class PaymentTypeParam {
+public class PaymentTypeParam extends ProjectOidParam {
 
     @Schema(description = "支付渠道")
     private PaymentType paymentType;

+ 11 - 4
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/paySetting/ProjectMainPaySettingController.java

@@ -6,6 +6,7 @@ import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.card.client.model.base.ProjectOidParam;
 import com.zhongshu.card.client.model.paySetting.paySetting.*;
+import com.zhongshu.card.client.model.payment.PaymentTypeParam;
 import com.zhongshu.card.server.core.service.paySetting.ProjectMainPaySettingService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -44,8 +45,11 @@ public class ProjectMainPaySettingController {
     @Operation(summary = "得到项目配置", description = "得到项目配置")
     @RequestMapping(value = "getMainPaySetting", method = {RequestMethod.POST})
     public ResultContent<ProjectMainPaySettingModel> getMainPaySetting(
-            @RequestBody ProjectOidParam param) {
-        return projectMainPaySettingService.getMainPaySetting(param.getProjectOid());
+            @RequestBody PaymentTypeParam param) {
+        if (param.getPaymentType() == null) {
+            return ResultContent.buildFail("paymentType不能为空");
+        }
+        return projectMainPaySettingService.getMainPaySetting(param.getProjectOid(), param.getPaymentType());
     }
 
     //------------------------------灵活分账规则 start ------------------------
@@ -61,8 +65,11 @@ public class ProjectMainPaySettingController {
     @Operation(summary = "得到项目的灵活分账规则列表", description = "得到项目的灵活分账规则列表")
     @RequestMapping(value = "getPayShareList", method = {RequestMethod.POST})
     public ResultContent<List<PayShareListModel>> getPayShareList(
-            @RequestBody @Valid ProjectOidParam param) {
-        return projectMainPaySettingService.getPayShareList(param.getProjectOid());
+            @RequestBody @Valid PaymentTypeParam param) {
+        if (param.getPaymentType() == null) {
+            return ResultContent.buildFail("paymentType不能为空");
+        }
+        return projectMainPaySettingService.getPayShareList(param.getProjectOid(), param.getPaymentType());
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)

+ 48 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/paySetting/ProjectPaySettingController.java

@@ -6,6 +6,7 @@ import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.card.client.model.base.ProjectOidParam;
 import com.zhongshu.card.client.model.org.BelongOigParam;
+import com.zhongshu.card.client.model.paySetting.payConfig.FrictionlessUnionConfigParam;
 import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfig;
 import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfigParam;
 import com.zhongshu.card.client.model.paySetting.paySetting.*;
@@ -46,7 +47,41 @@ public class ProjectPaySettingController {
 
     @Autowired
     private ProjectPaySettingServiceImpl projectPaySettingService;
-    
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "关联支付产品", description = "关联支付产品")
+    @RequestMapping(value = "savePayChannel", method = {RequestMethod.POST})
+    public ResultContent savePayChannel(@RequestBody ProjectPaySettingParam param) {
+        return projectPaySettingService.savePayChannel(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "得到项目所有的支付渠道参数配置", description = "得到项目所有的支付渠道参数配置")
+    @RequestMapping(value = "getAllProjectPaySetting", method = {RequestMethod.POST})
+    public ResultContent<List<ProjectPaySettingModel>> getAllProjectPaySetting(@RequestBody ProjectOidParam param) {
+        return projectPaySettingService.getAllProjectPaySetting(param.getProjectOid());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除参数配置", description = "删除参数配置")
+    @RequestMapping(value = "deleteInfo", method = {RequestMethod.POST})
+    public ResultContent deleteInfo(@RequestBody IDParam param) {
+        return projectPaySettingService.deleteInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "启用支付方式", description = "启用支付方式")
+    @RequestMapping(value = "enablePay", method = {RequestMethod.POST})
+    public ResultContent enablePay(@RequestBody IDParam param) {
+        return projectPaySettingService.changeState(param.getId(), DataState.Enable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "停用支付方式", description = "停用支付方式")
+    @RequestMapping(value = "disablePay", method = {RequestMethod.POST})
+    public ResultContent disablePay(@RequestBody IDParam param) {
+        return projectPaySettingService.changeState(param.getId(), DataState.Disable);
+    }
 
     //------------------------------------------------机构支付参数配置 start-----------------------
 
@@ -61,16 +96,14 @@ public class ProjectPaySettingController {
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "项目下所有主账户数据列表", description = "项目下所有主账户数据列表")
     @RequestMapping(value = {"getMainList"}, method = {RequestMethod.POST})
-    public ResultContent<List<ProjectPaySettingInfoModel>> getMainList(@Parameter(required = false) ProjectPaySettingInfoSearch param) {
+    public ResultContent<Page<ProjectPaySettingInfoModel>> getMainList(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) ProjectPaySettingInfoSearch param) {
         Assert.hasText(param.getProjectOid(), "projectOid不能为空");
         param.setIsDefault(Boolean.TRUE);
-        Pageable pageable = PageRequest.of(0, 100);
-        ResultContent<Page<ProjectPaySettingInfoModel>> pageContent = projectPaySettingService.page(param, pageable);
-        if (pageContent.isFailed()) {
-            return ResultContent.buildFail(pageContent.getMsg());
+        if (param.getChannelType() == null) {
+            return ResultContent.buildFail("channelType不能为空");
         }
-        List<ProjectPaySettingInfoModel> list = pageContent.getContent().getContent();
-        return ResultContent.buildSuccess(list);
+        return projectPaySettingService.page(param, pageable);
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
@@ -119,4 +152,11 @@ public class ProjectPaySettingController {
         return projectPaySettingService.saveLaKaLaConfig(param);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "保存银联云闪付支付配置", description = "保存银联云闪付支付配置")
+    @RequestMapping(value = "saveUnionPayConfig", method = RequestMethod.POST)
+    public ResultContent saveUnionPayConfig(@RequestBody @Valid FrictionlessUnionConfigParam param) {
+        return projectPaySettingService.saveUnionPayConfig(param);
+    }
+
 }

+ 2 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/projectAbout/PayShareListDao.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.dao.projectAbout;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.server.core.domain.paySetting.PayShareList;
 
 import java.util.List;
@@ -14,6 +15,6 @@ public interface PayShareListDao extends MongoDao<PayShareList> {
 
     PayShareList findTopByProjectOidAndName(String projectOid, String name);
 
-    List<PayShareList> findByProjectOidOrderBySortAsc(String projectOid);
+    List<PayShareList> findByProjectOidAndPaymentTypeOrderBySortAsc(String projectOid, PaymentType paymentType);
 
 }

+ 5 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/projectAbout/ProjectMainPaySettingDao.java

@@ -1,13 +1,17 @@
 package com.zhongshu.card.server.core.dao.projectAbout;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.server.core.dao.projectAbout.extend.ProjectMainPaySettingDaoExtend;
 import com.zhongshu.card.server.core.domain.paySetting.ProjectMainPaySetting;
+import com.zhongshu.card.server.core.domain.paySetting.ProjectOrgPaySettingInfo;
 
 public interface ProjectMainPaySettingDao extends MongoDao<ProjectMainPaySetting>, ProjectMainPaySettingDaoExtend {
 
     ProjectMainPaySetting findTopById(String id);
 
-    ProjectMainPaySetting findTopByProjectOid(String projectOid);
+    ProjectMainPaySetting findTopByProjectOidAndChannelType(String projectOid, PaymentType channelType);
+
+    Integer countByPaySettingInfo(ProjectOrgPaySettingInfo paySettingInfo);
 
 }

+ 2 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/schedule/impl/ScheduleTaskConfigDaoImpl.java

@@ -54,7 +54,8 @@ public class ScheduleTaskConfigDaoImpl extends BaseImpl implements ScheduleTaskC
     public boolean release(String key) {
         Query releaseQuery = Query.query(Criteria.where("_id").is(key));
         Update releaseUpdate = new Update().set("expireAt", null).set("token", null);
-        FindAndModifyOptions releaseOptions = new FindAndModifyOptions().upsert(true).returnNew(true);
+        // 不存在,,不执行添加操作
+        FindAndModifyOptions releaseOptions = new FindAndModifyOptions().upsert(false).returnNew(true);
         ScheduleTaskConfig flowDisposition = mongoTemplate.findAndModify(releaseQuery, releaseUpdate, releaseOptions, ScheduleTaskConfig.class);
         return StringUtils.isEmpty(flowDisposition.getToken());
     }

+ 4 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/paySetting/PayShareList.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.domain.paySetting;
 
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -38,6 +39,9 @@ public class PayShareList extends SuperMain {
     @Schema(description = "关联数据ID")
     private String aboutDataId;
 
+    @Schema(description = "支付渠道")
+    private PaymentType paymentType;
+
     //-----------------------------业务 start----------------------
 
     @Schema(description = "规则名称")

+ 18 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/paySetting/ProjectMainPaySetting.java

@@ -54,14 +54,31 @@ public class ProjectMainPaySetting extends SuperMain {
     @Schema(description = "天数,>= 1")
     private Integer days;
 
+    @Schema(description = "d+N的时间")
+    private String dnTimeStr;
+
     //---------------定期结算 设置
 
     @Schema(description = "定期类型")
     private RegularType regularType;
 
+    @Schema(description = "定期结算时间")
+    private String regularTimeStr;
+
     @Schema(description = "当前的时间,如:12:30")
     private String timeStr;
 
+    public String getTimeStr() {
+        if (settlementRulesType != null) {
+            if (settlementRulesType == SettlementRulesType.Dn) {
+                return dnTimeStr;
+            } else if (settlementRulesType == SettlementRulesType.Regular) {
+                return regularTimeStr;
+            }
+        }
+        return "";
+    }
+
     //----------------------------提现规则 start --------------
 
     @Schema(description = "提现规则类型")
@@ -78,7 +95,7 @@ public class ProjectMainPaySetting extends SuperMain {
     private BigDecimal orgScale = BigDecimal.ZERO;
 
     @Schema(description = "锁过期时间")
-    private long expireAt;
+    private Long expireAt;
 
     @Schema(description = "锁token")
     private String token;

+ 6 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/schedule/ScheduleTaskConfig.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.domain.schedule;
 
+import cn.hutool.json.JSONObject;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.ScheduleType;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
@@ -9,6 +10,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.util.HashMap;
+
 /**
  * 定时任务记录
  *
@@ -24,6 +27,9 @@ public class ScheduleTaskConfig extends SuperMain {
     @Schema(description = "关联的数据ID")
     private String aboutDataId;
 
+    @Schema(description = "关联的数据")
+    private HashMap<String, Object> data = new HashMap<>();
+
     @Schema(description = "定时任务类型")
     private ScheduleType scheduleType;
 

+ 2 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/httpRequest/conf/IotCenterAPIConfig.java

@@ -21,9 +21,9 @@ public class IotCenterAPIConfig {
     // 项目同步
     public static final String syncFromFullCardProjects = "/projectSync/free/syncFromFullCardProjects";
 
-    public static final String openAPISendMessage = "/oitOpenAPI/manager/sendIotMessage";
+    public static final String openAPISendMessage = "/iotOpenAPI/manager/v1/sendIotMessage";
 
-    public static final String sendIotGateWayMessage = "/oitOpenAPI/manager/sendIotGateWayMessage";
+    public static final String sendIotGateWayMessage = "/iotOpenAPI/manager/v1/sendIotGateWayMessage";
 
     public static final HashMap<String, ApiConfParam> map = new HashMap<>();
 

+ 8 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectChannelConfigService.java

@@ -93,13 +93,20 @@ public class ProjectChannelConfigService extends SuperService {
     }
 
     public ResultContent initAllChannel() {
+        log.info("-------------初始平台支付产品---------------");
         // 免密支付 拉卡拉
         PayChannelConfigParam param = new PayChannelConfigParam();
-        param.setName("免密支付");
+        param.setName("拉卡拉免密支付");
         param.setPaymentChannelType(PaymentChannelType.SecretFreePayment);
         param.setPaymentType(PaymentType.LakalaFrictionlessPay);
         savePayChannelConfig(param);
 
+        PayChannelConfigParam unionPayParam = new PayChannelConfigParam();
+        unionPayParam.setName("云闪付免密支付");
+        unionPayParam.setPaymentChannelType(PaymentChannelType.SecretFreePayment);
+        unionPayParam.setPaymentType(PaymentType.UnionFrictionlessPay);
+        savePayChannelConfig(unionPayParam);
+
         // 余额支付  微信充值
         PayChannelConfigParam balanceParam = new PayChannelConfigParam();
         balanceParam.setName("余额支付");

+ 78 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectMainPaySettingService.java

@@ -1,7 +1,9 @@
 package com.zhongshu.card.server.core.service.paySetting;
 
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.model.paySetting.paySetting.*;
+import com.zhongshu.card.client.type.paySetting.SettlementRulesType;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.projectAbout.PayShareListDao;
 import com.zhongshu.card.server.core.dao.projectAbout.ProjectMainPaySettingDao;
@@ -13,12 +15,14 @@ import com.zhongshu.card.server.core.domain.paySetting.ProjectOrgPaySettingInfo;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.schedule.ScheduleTaskConfigService;
 import com.zhongshu.card.server.core.util.BeanUtils;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -48,6 +52,9 @@ public class ProjectMainPaySettingService extends SuperService {
     @Autowired
     private ScheduleTaskConfigService scheduleTaskConfigService;
 
+    @Autowired
+    private ProjectPaySettingServiceImpl projectPaySettingService;
+
     /**
      * 保存项目配置
      *
@@ -58,6 +65,7 @@ public class ProjectMainPaySettingService extends SuperService {
         if (StringUtils.isEmpty(param.getProjectOid())) {
             return ResultContent.buildFail("projectOid不能为空");
         }
+
         ProjectOrgPaySettingInfo orgPaySettingInfo = projectPaySettingInfoDao.findTopById(param.getPaySettingInfoId());
         if (ObjectUtils.isEmpty(orgPaySettingInfo)) {
             return ResultContent.buildFail("主账号数据不存在");
@@ -65,8 +73,41 @@ public class ProjectMainPaySettingService extends SuperService {
         if (orgPaySettingInfo.getIsDefault() == null || !orgPaySettingInfo.getIsDefault()) {
             return ResultContent.buildFail("选择的不是主账户类型");
         }
+        if (param.getSettlementRulesType() == SettlementRulesType.Dn) {
+            if (StringUtils.isEmpty(param.getDnTimeStr())) {
+                return ResultContent.buildFail("dnTimeStr不能为空");
+            }
+            param.setRegularTimeStr("");
+        }
+        if (param.getSettlementRulesType() == SettlementRulesType.Regular) {
+            if (StringUtils.isEmpty(param.getRegularTimeStr())) {
+                return ResultContent.buildFail("regularTimeStr不能为空");
+            }
+            param.setDnTimeStr("");
+        }
+        // 项目 的分成
+        BigDecimal projectScale = param.getProjectScale();
+        if (projectScale != null) {
+            if (BigDecimal.ZERO.compareTo(projectScale) == 1 ||
+                    BigDecimal.valueOf(100).compareTo(projectScale) == -1) {
+                return ResultContent.buildFail("projectScale不符合要求");
+            }
+        }
+        // 机构 的分成
+        BigDecimal orgScale = param.getOrgScale();
+        if (projectScale != null) {
+            if (BigDecimal.ZERO.compareTo(orgScale) == 1 ||
+                    BigDecimal.valueOf(100).compareTo(orgScale) == -1) {
+                return ResultContent.buildFail("orgScale不符合要求");
+            }
+        }
+        BigDecimal all = orgScale.add(projectScale);
+        if (all.compareTo(BigDecimal.valueOf(100)) != 0) {
+            return ResultContent.buildFail("项目分成和机构分成之和不等100");
+        }
 
-        ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOid(param.getProjectOid());
+        ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOidAndChannelType(
+                param.getProjectOid(), orgPaySettingInfo.getChannelType());
         if (ObjectUtils.isEmpty(mainPaySetting)) {
             mainPaySetting = new ProjectMainPaySetting();
         }
@@ -90,9 +131,12 @@ public class ProjectMainPaySettingService extends SuperService {
      * @param projectOid
      * @return
      */
-    public ResultContent<ProjectMainPaySettingModel> getMainPaySetting(String projectOid) {
-        ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOid(projectOid);
-        return ResultContent.buildSuccess(toMainModel(mainPaySetting));
+    public ResultContent<ProjectMainPaySettingModel> getMainPaySetting(String projectOid, PaymentType paymentType) {
+        ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOidAndChannelType(
+                projectOid, paymentType);
+        ProjectMainPaySettingModel model = toMainModel(mainPaySetting);
+        model.setProjectOid(projectOid);
+        return ResultContent.buildSuccess(model);
     }
 
     //---------------------------项目上的灵活 分账配置 start -----------------------
@@ -107,6 +151,9 @@ public class ProjectMainPaySettingService extends SuperService {
         if (StringUtils.isEmpty(param.getProjectOid())) {
             return ResultContent.buildFail("projectOid不能为空");
         }
+        if (param.getPaymentType() == null) {
+            return ResultContent.buildFail("paymentType不能为空");
+        }
         Organization projectInfo = organizationDao.findTopByOid(param.getProjectOid());
         PayShareList entity = null;
         PayShareList nameTemp = payShareListDao.findTopByProjectOidAndName(param.getProjectOid(), param.getName());
@@ -126,6 +173,28 @@ public class ProjectMainPaySettingService extends SuperService {
             entity = new PayShareList();
             initEntityNoCheckOid(entity);
         }
+
+        // 项目 的分成
+        BigDecimal projectScale = param.getProjectScale();
+        if (projectScale != null) {
+            if (BigDecimal.ZERO.compareTo(projectScale) == 1 ||
+                    BigDecimal.valueOf(100).compareTo(projectScale) == -1) {
+                return ResultContent.buildFail("projectScale不符合要求");
+            }
+        }
+        // 机构 的分成
+        BigDecimal orgScale = param.getOrgScale();
+        if (projectScale != null) {
+            if (BigDecimal.ZERO.compareTo(orgScale) == 1 ||
+                    BigDecimal.valueOf(100).compareTo(orgScale) == -1) {
+                return ResultContent.buildFail("orgScale不符合要求");
+            }
+        }
+        BigDecimal all = orgScale.add(projectScale);
+        if (all.compareTo(BigDecimal.valueOf(100)) != 0) {
+            return ResultContent.buildFail("项目分成和机构分成之和不等100");
+        }
+
         BeanUtils.copyProperties(param, entity);
         entity.setProjectInfo(projectInfo);
         entity.setProjectCode(projectInfo.getCode());
@@ -135,8 +204,8 @@ public class ProjectMainPaySettingService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    public ResultContent<List<PayShareListModel>> getPayShareList(String projectOid) {
-        List<PayShareList> list = payShareListDao.findByProjectOidOrderBySortAsc(projectOid);
+    public ResultContent<List<PayShareListModel>> getPayShareList(String projectOid, PaymentType paymentType) {
+        List<PayShareList> list = payShareListDao.findByProjectOidAndPaymentTypeOrderBySortAsc(projectOid, paymentType);
         List<PayShareListModel> models = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(list)) {
             models = list.stream().map(this::toModel).collect(Collectors.toUnmodifiableList());
@@ -161,7 +230,7 @@ public class ProjectMainPaySettingService extends SuperService {
 
     public PayShareListModel toModel(PayShareList entity) {
         PayShareListModel model = null;
-        if (ObjectUtils.isEmpty(entity)) {
+        if (ObjectUtils.isNotEmpty(entity)) {
             model = new PayShareListModel();
             BeanUtils.copyProperties(entity, model);
         }
@@ -169,7 +238,7 @@ public class ProjectMainPaySettingService extends SuperService {
     }
 
     public ProjectMainPaySettingModel toMainModel(ProjectMainPaySetting entity) {
-        ProjectMainPaySettingModel model = null;
+        ProjectMainPaySettingModel model = new ProjectMainPaySettingModel();
         if (ObjectUtils.isNotEmpty(entity)) {
             model = new ProjectMainPaySettingModel();
             BeanUtils.copyProperties(entity, model);
@@ -179,6 +248,7 @@ public class ProjectMainPaySettingService extends SuperService {
                 model.setPaySettingInfoId(paySettingInfo.getId());
                 model.setPaySettingInfoName(paySettingInfo.getName());
             }
+            model.setSettingInfoModel(projectPaySettingService.toModel(entity.getPaySettingInfo()));
         }
         return model;
     }

+ 234 - 10
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectPaySettingServiceImpl.java

@@ -5,12 +5,15 @@ import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
 import com.github.microservice.pay.client.model.AccountModel;
 import com.github.microservice.pay.client.product.miniApp.weChat.conf.WeChatMiniAppConf;
+import com.github.microservice.pay.client.product.senseless.chinaumsSenseless.conf.ChinaumsSenselessConf;
 import com.github.microservice.pay.client.ret.ResultState;
 import com.github.microservice.pay.client.service.PayProductAccountService;
 import com.github.microservice.pay.client.type.PayProductChannelType;
 import com.github.microservice.types.payment.PayFieldType;
 import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.model.org.BelongOigParam;
+import com.zhongshu.card.client.model.paySetting.payConfig.FrictionlessUnionConfigModel;
+import com.zhongshu.card.client.model.paySetting.payConfig.FrictionlessUnionConfigParam;
 import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfig;
 import com.zhongshu.card.client.model.paySetting.payConfig.LaKaLaCollectionConfigParam;
 import com.zhongshu.card.client.model.paySetting.paySetting.*;
@@ -18,10 +21,12 @@ import com.zhongshu.card.client.model.payment.PaymentTypeParam;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.projectAbout.PayChannelConfigDao;
+import com.zhongshu.card.server.core.dao.projectAbout.ProjectMainPaySettingDao;
 import com.zhongshu.card.server.core.dao.projectAbout.ProjectOrgPaySettingInfoDao;
 import com.zhongshu.card.server.core.dao.projectAbout.ProjectPaySettingDao;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.domain.paySetting.PayChannelConfig;
+import com.zhongshu.card.server.core.domain.paySetting.ProjectMainPaySetting;
 import com.zhongshu.card.server.core.domain.paySetting.ProjectOrgPaySettingInfo;
 import com.zhongshu.card.server.core.domain.paySetting.ProjectPaySetting;
 import com.zhongshu.card.server.core.service.base.SuperService;
@@ -72,6 +77,99 @@ public class ProjectPaySettingServiceImpl extends SuperService {
     @Autowired
     private OrgPayAccountService orgPayAccountService;
 
+    @Autowired
+    private ProjectChannelConfigService projectChannelConfigService;
+
+    @Autowired
+    private ProjectMainPaySettingDao projectMainPaySettingDao;
+
+    /**
+     * 关联支付渠道
+     *
+     * @return
+     */
+    public ResultContent savePayChannel(ProjectPaySettingParam param) {
+        String projectOid = param.getProjectOid();
+        if (StringUtils.isEmpty(projectOid)) {
+            return ResultContent.buildFail("projectOid不能为空");
+        }
+        Organization project = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(project)) {
+            return ResultContent.buildFail("项目不存在");
+        }
+        PayChannelConfig payChannelConfig = payChannelConfigDao.findTopById(param.getId());
+        if (ObjectUtils.isEmpty(payChannelConfig)) {
+            return ResultContent.buildFail("支付产品不存在");
+        }
+        PaymentType paymentType = payChannelConfig.getPaymentType();
+
+        ProjectPaySetting projectPaySetting = projectPaySettingDao.findTopByProjectOidAndChannelType(projectOid, paymentType);
+        if (ObjectUtils.isNotEmpty(projectPaySetting)) {
+            return ResultContent.buildFail(String.format("%s已存在", paymentType.getRemark()));
+        }
+        projectPaySetting = new ProjectPaySetting();
+        initEntityNoCheckOid(projectPaySetting);
+        projectPaySetting.setProjectOid(projectOid);
+        projectPaySetting.setProjectInfo(project);
+        projectPaySetting.setProjectCode(project.getCode());
+        projectPaySetting.setProjectName(project.getName());
+        projectPaySetting.setChannelType(paymentType);
+        projectPaySetting.setPaymentChannelType(payChannelConfig.getPaymentChannelType());
+
+        projectPaySetting.setState(DataState.Disable);
+        projectPaySettingDao.save(projectPaySetting);
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 项目得到所有的支付渠道配置
+     *
+     * @param projectOid
+     * @return
+     */
+    public ResultContent<List<ProjectPaySettingModel>> getAllProjectPaySetting(String projectOid) {
+        List<ProjectPaySetting> list = projectPaySettingDao.findByProjectOid(projectOid);
+        List<ProjectPaySettingModel> models = new ArrayList<>(list.size());
+        if (ObjectUtils.isNotEmpty(list)) {
+            models = list.stream().map(this::toModel).collect(Collectors.toUnmodifiableList());
+        }
+        return ResultContent.buildSuccess(models);
+    }
+
+    public ResultContent deleteInfo(String id) {
+        ProjectPaySetting paySetting = projectPaySettingDao.findTopById(id);
+        if (ObjectUtils.isEmpty(paySetting)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        // 判断是否可以删除
+        if (paySetting.getState() != null && paySetting.getState() == DataState.Enable) {
+            return ResultContent.buildFail(String.format("%s已启用,不能删除!", paySetting.getChannelType().getRemark()));
+        }
+        projectPaySettingDao.delete(paySetting);
+        // 维护支付中心的账户信息
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent changeState(String id, DataState state) {
+        ProjectPaySetting paySetting = projectPaySettingDao.findTopById(id);
+        if (ObjectUtils.isEmpty(paySetting)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        //TODO  检查是否可以启用
+        if (state != null && state == DataState.Enable) {
+            ProjectMainPaySetting mainPaySetting = projectMainPaySettingDao.findTopByProjectOidAndChannelType(paySetting.getProjectOid(), paySetting.getChannelType());
+            if (ObjectUtils.isEmpty(mainPaySetting)) {
+                return ResultContent.buildFail("未配置主账户信息或结算规则等,不能启用!");
+            }
+        }
+        paySetting.setState(state);
+        projectPaySettingDao.save(paySetting);
+
+        // 更新支付中心的账号信息
+        upsertPayAccount(paySetting.getProjectOid(), paySetting.getChannelType());
+        return ResultContent.buildSuccess();
+    }
+
     //-----------------------------通用配置方法 start----------------------------
 
     /**
@@ -112,6 +210,11 @@ public class ProjectPaySettingServiceImpl extends SuperService {
         if (ObjectUtils.isEmpty(entity)) {
             return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
         }
+        // 判断是否可以删除
+        int total = projectMainPaySettingDao.countByPaySettingInfo(entity);
+        if (total > 0) {
+            return ResultContent.buildFail("该账户已被项目引用,不能删除!");
+        }
         projectPaySettingInfoDao.delete(entity);
         initChangeDefault(null, entity.getBelongOig(), entity.getProjectOid(), entity.getChannelType());
         return ResultContent.buildSuccess();
@@ -231,6 +334,35 @@ public class ProjectPaySettingServiceImpl extends SuperService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 银联云闪付参数配置
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent saveUnionPayConfig(FrictionlessUnionConfigParam param) {
+        ResultContent<ProjectOrgPaySettingInfo> content = initProjectPayInfo(param);
+        if (content.isFailed()) {
+            return ResultContent.buildFail(content.getMsg());
+        }
+        ProjectOrgPaySettingInfo settingInfo = content.getContent();
+        FrictionlessUnionConfigModel unionConfigModel = null;
+        if (ObjectUtils.isNotEmpty(settingInfo) && settingInfo.getPayConfig() != null) {
+            unionConfigModel = (FrictionlessUnionConfigModel) settingInfo.getPayConfig();
+        }
+        if (unionConfigModel == null) {
+            unionConfigModel = new FrictionlessUnionConfigModel();
+        }
+        BeanUtils.copyProperties(param, unionConfigModel);
+
+        settingInfo.setPayConfig(unionConfigModel);
+        projectPaySettingInfoDao.save(settingInfo);
+
+        // 如果当前设置为默认,把其他的取消默认
+        initChangeDefault(settingInfo.getId(), settingInfo.getBelongOig(), settingInfo.getProjectOid(), settingInfo.getChannelType());
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * @param param
      * @return
@@ -352,6 +484,11 @@ public class ProjectPaySettingServiceImpl extends SuperService {
             // 微信小程序支付
             model.setApiName("saveWxPayConfig");
             model.setFields(getWxConfig());
+        } else if (paymentType == PaymentType.UnionFrictionlessPay) {
+            // 银联云闪付
+            model.setApiName("saveUnionPayConfig");
+            model.setFields(getUnionPay());
+            model.setType("json");
         }
         return ResultContent.buildSuccess(model);
     }
@@ -365,13 +502,32 @@ public class ProjectPaySettingServiceImpl extends SuperService {
         List<PayConfigField> fields = new ArrayList<>(4);
         fields.add(PayConfigField.builder().name("appId").key("appId").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
         fields.add(PayConfigField.builder().name("商户证书序列号").key("mchSerialNo").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
-//        fields.add(PayConfigField.builder().name("商户ID").key("mchId").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
         fields.add(PayConfigField.builder().name("V3密钥").key("apiV3Key").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
         fields.add(PayConfigField.builder().name("证书文件").key("privateKeyFile").type(PayFieldType.File).isMust(Boolean.FALSE).build());
         fields.add(PayConfigField.builder().name("支付成功回调地址").key("notifyUrl").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(500).build());
         return fields;
     }
 
+    /**
+     * 银联云闪付字段
+     *
+     * @return
+     */
+    public List<PayConfigField> getUnionPay() {
+        List<PayConfigField> fields = new ArrayList<>(4);
+        fields.add(PayConfigField.builder().name("appId").key("appId").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
+        fields.add(PayConfigField.builder().name("appKey").key("appKey").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
+        fields.add(PayConfigField.builder().name("商户订单号开头").key("orderStart").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
+        fields.add(PayConfigField.builder().name("终端号").key("tid").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
+        fields.add(PayConfigField.builder().name("协议模板id").key("planId").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(100).build());
+        fields.add(PayConfigField.builder().name("密钥").key("notifySecret").type(PayFieldType.Str).isMust(Boolean.TRUE).build());
+
+//        fields.add(PayConfigField.builder().name("商户微信小程序AppId").key("mchntWxMpAppId").type(PayFieldType.Str).isMust(Boolean.TRUE).build());
+        fields.add(PayConfigField.builder().name("通知地址").key("notifyUrl").type(PayFieldType.Str).isMust(Boolean.TRUE).maxLength(500).build());
+
+        return fields;
+    }
+
     public ProjectPaySettingInfoModel toModel(ProjectOrgPaySettingInfo entity) {
         ProjectPaySettingInfoModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {
@@ -383,6 +539,10 @@ public class ProjectPaySettingServiceImpl extends SuperService {
             if (ObjectUtils.isNotEmpty(payChannelConfig)) {
                 model.setPayLogo(payChannelConfig.getLogo());
             }
+            Organization organization = organizationDao.findTopByOid(entity.getBelongOig());
+            if (ObjectUtils.isNotEmpty(organization)) {
+                model.setBelongOrgName(organization.getName());
+            }
         }
         return model;
     }
@@ -436,13 +596,24 @@ public class ProjectPaySettingServiceImpl extends SuperService {
      * @return
      */
     public ResultContent upsertPayAccount(String projectOid, PaymentType paymentType) {
-        ProjectOrgPaySettingInfo entity = projectPaySettingInfoDao.findTopByProjectOidAndChannelTypeAndIsDefault(projectOid, paymentType, Boolean.TRUE);
+        log.info("upsertPayAccount 维护支付中心的支付账号");
+        ProjectMainPaySetting projectMainPaySetting = projectMainPaySettingDao.findTopByProjectOidAndChannelType(projectOid, paymentType);
+        if (ObjectUtils.isEmpty(projectMainPaySetting)) {
+            log.error("upsertPayAccount 项目未配置; {} {}", paymentType.getRemark(), projectOid);
+            return ResultContent.buildFail("项目未配置");
+        }
+        ProjectOrgPaySettingInfo entity = projectMainPaySetting.getPaySettingInfo();
+        if (ObjectUtils.isEmpty(entity)) {
+            log.error("upsertPayAccount 关联机构支付配置为空");
+            return ResultContent.buildFail("关联机构支付配置为空");
+        }
 
         String payAccountName = orgPayAccountService.buildPayAccountName(projectOid, paymentType);
 
         AccountModel accountModel = new AccountModel();
         accountModel.setName(payAccountName);
 
+        String remark = "";
         Boolean disable = Boolean.FALSE;
         if (ObjectUtils.isNotEmpty(entity)) {
             if (paymentType == PaymentType.WeChat) {
@@ -459,32 +630,85 @@ public class ProjectPaySettingServiceImpl extends SuperService {
                 accountModel.setConf(appConf);
             } else if (paymentType == PaymentType.UnionFrictionlessPay) {
                 // 银联无感支付
+                accountModel.setProductChannelType(PayProductChannelType.ChinaumsSenseless);
 
+                FrictionlessUnionConfigModel model = (FrictionlessUnionConfigModel) entity.getPayConfig();
+                // 支付中心
+                ChinaumsSenselessConf appConf = new ChinaumsSenselessConf();
+                appConf.setAppId(model.getAppId());
+                appConf.setAppKey(model.getAppKey());
+                appConf.setOrderNoPrefix(model.getOrderStart());
+                appConf.setMchId(model.getMchId());
+                appConf.setTerminalNo(model.getTid());
+                appConf.setPlanId(model.getPlanId());
+                appConf.setSecretKey(model.getNotifySecret());
+                appConf.setNotifyUrl(model.getNotifyUrl());
+
+                accountModel.setConf(appConf);
+            }
+
+            if (!disable) {
+                // 机构配置为开启
+                if (entity.getState() == null || entity.getState() != DataState.Enable) {
+                    disable = Boolean.TRUE;
+                    remark = "机构配置未启用";
+                }
             }
 
-            // 查看平台支付产品状态
-            PayChannelConfig channelConfig = payChannelConfigDao.findTopByPaymentType(paymentType);
-            if (ObjectUtils.isNotEmpty(channelConfig)) {
-                if (channelConfig.getState() == null || channelConfig.getState() != DataState.Enable) {
-                    disable = Boolean.FALSE;
+            if (!disable) {
+                // 查看平台支付产品状态
+                PayChannelConfig channelConfig = payChannelConfigDao.findTopByPaymentType(paymentType);
+                if (ObjectUtils.isNotEmpty(channelConfig)) {
+                    if (channelConfig.getState() != null && channelConfig.getState() == DataState.Enable) {
+                        disable = Boolean.FALSE;
+                    } else {
+                        remark = "平台支付产品未启用";
+                        disable = Boolean.TRUE;
+                    }
                 } else {
+                    remark = "平台支付产品不存在";
                     disable = Boolean.TRUE;
                 }
-            } else {
-                disable = Boolean.TRUE;
+            }
+
+            if (!disable) {
+                // 项目配置 项目上没启用
+                ProjectPaySetting projectPaySetting = projectPaySettingDao.findTopByProjectOidAndChannelType(projectOid, paymentType);
+                if (projectPaySetting.getState() == null || projectPaySetting.getState() == DataState.Disable) {
+                    disable = Boolean.TRUE;
+                    remark = "项目上支付渠道未启用";
+                }
             }
         } else {
             // 不可用
             disable = Boolean.TRUE;
+            remark = "关联的主账户信息不存在";
         }
         accountModel.setDisable(disable);
+        accountModel.setRemark(remark);
         com.github.microservice.pay.client.ret.ResultContent<Void> resultContent = payProductAccountService.upsert(accountModel);
         if (resultContent.getState() == ResultState.Success) {
-            log.info("更新支付产品账户成功...");
+            log.info("更新支付产品账户成功... disable {}", disable);
             orgPayAccountService.saveProjectAccount(projectOid, paymentType, accountModel.getProductChannelType());
         } else {
             log.error("更新支付产品账户出错: {}", resultContent.getMsg());
         }
         return ResultContent.buildSuccess();
     }
+
+    public ProjectPaySettingModel toModel(ProjectPaySetting entity) {
+        ProjectPaySettingModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new ProjectPaySettingModel();
+            BeanUtils.copyProperties(entity, model);
+            // 关联的支付产品信息
+            model.setPayChannelConfigModel(projectChannelConfigService.getProjectPayChannelModel(entity.getChannelType()));
+            // 判断是否完成配置
+            ProjectOrgPaySettingInfo settingInfo = projectPaySettingInfoDao.findTopByProjectOidAndChannelTypeAndIsDefault(entity.getProjectOid(), entity.getChannelType(), Boolean.TRUE);
+            if (ObjectUtils.isNotEmpty(settingInfo)) {
+                model.setIsConfig(Boolean.TRUE);
+            }
+        }
+        return model;
+    }
 }

+ 17 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/schedule/ScheduleTaskConfigService.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.service.schedule;
 
+import cn.hutool.json.JSONObject;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.ScheduleType;
@@ -15,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -59,16 +61,24 @@ public class ScheduleTaskConfigService {
             try {
                 String lockKey = projectMainPaySettingDao.acquire(entity.getId(), 5000L);
                 if (StringUtils.isNotEmpty(lockKey)) {
-                    String aboutDataId = entity.getProjectOid();
+//                    项目结算任务
+                    String aboutDataId = entity.getProjectOid() + "_" + entity.getChannelType().name();
                     ScheduleTaskConfig taskConfig = scheduleTaskConfigDao.findTopByAboutDataId(aboutDataId);
-                    if (ObjectUtils.isNotEmpty(taskConfig)) {
+                    if (ObjectUtils.isEmpty(taskConfig)) {
                         taskConfig = new ScheduleTaskConfig();
                     }
                     taskConfig.setAboutDataId(aboutDataId);
+                    HashMap<String, Object> data = new HashMap<>();
+                    data.put("projectOid", entity.getProjectOid());
+                    data.put("id", entity.getId());
+                    data.put("channelType", entity.getChannelType());
+
+                    taskConfig.setData(data);
                     taskConfig.setDataState(DataState.Enable);
                     taskConfig.setScheduleType(ScheduleType.SettlementTask);
                     String expression = "";
                     String timeStr = entity.getTimeStr();
+
                     String[] timeParts = timeStr.split(":");
                     String hour = timeParts[0];
                     String minute = timeParts[1];
@@ -92,7 +102,8 @@ public class ScheduleTaskConfigService {
                         }
                     }
                     taskConfig.setExpression(expression);
-                    taskConfig.setRemark(String.format("项目结算定时任务:%s", entity.getProjectOid()));
+                    taskConfig.setRemark(String.format("项目结算定时任务: 项目oid=%s,支付渠道= %s",
+                            entity.getProjectOid(), entity.getChannelType().getRemark()));
                     scheduleTaskConfigDao.save(taskConfig);
                 }
             } catch (Exception e) {
@@ -105,6 +116,9 @@ public class ScheduleTaskConfigService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 重置所有的定时任务
+     */
     private void loadAllSchedule() {
         try {
             log.info("================系统启动加载定时任务====开始===========");

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

@@ -110,7 +110,8 @@ public class ScheduledTask implements SchedulingConfigurer {
                         scheduleLog.setExecuteTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
                         // 执行业务逻辑
                         try {
-                            log.info("====执行单个任务,配置ID【{}】,任务ID【{}】执行规则【{}】=======", item.getId(), item.getAboutDataId(), item.getExpression());
+                            log.info("====执行单个任务,时间: {}  配置ID【{}】,任务ID【{}】执行规则【{}】=======",
+                                    DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyyMis), item.getId(), item.getAboutDataId(), item.getExpression());
                             scheduleLog.setScheduleTaskConfig(item);
                             // 得到任务执行锁
                             String token = scheduleTaskConfigDao.acquire(item.getId(), 10000L);