TRX 1 yıl önce
ebeveyn
işleme
bc697ef30d

+ 11 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/projectAbout/PayChannelConfigModel.java

@@ -27,6 +27,17 @@ public class PayChannelConfigModel extends SuperModel {
     @Schema(description = "支付产品名称")
     private String name;
 
+    private String logo;
+
+    private String paymentChannelTypeName;
+
+    public String getPaymentChannelTypeName() {
+        if (paymentChannelType != null) {
+            return paymentChannelType.name();
+        }
+        return "";
+    }
+
     @Schema(description = "支付类型")
     private PaymentChannelType paymentChannelType;
 

+ 11 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/projectAbout/PayChannelConfigParam.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.client.model.projectAbout;
 
 import com.github.microservice.types.payment.PaymentChannelType;
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.model.base.SuperParam;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotEmpty;
@@ -9,6 +10,9 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 项目的 支付渠道配置模型
  *
@@ -20,6 +24,9 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 public class PayChannelConfigParam extends SuperParam {
 
+    @Schema(description = "logo")
+    private String logo;
+
     @NotEmpty
     @Schema(description = "支付产品名称")
     private String name;
@@ -30,4 +37,8 @@ public class PayChannelConfigParam extends SuperParam {
 
     @Schema(description = "汇率说明")
     private String rateMark;
+
+    @Schema(description = "渠道支持的支付方式")
+    private List<PaymentType> paymentTypes = new ArrayList<>();
+
 }

+ 7 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/paySetting/ProjectChannelController.java

@@ -45,6 +45,13 @@ public class ProjectChannelController {
         return projectChannelConfigService.savePayChannelConfig(param);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "编辑支付渠道数据", description = "编辑支付渠道数据")
+    @RequestMapping(value = "updatePayChannelConfig", method = {RequestMethod.POST})
+    public ResultContent updatePayChannelConfig(@RequestBody PayChannelConfigParam param) {
+        return projectChannelConfigService.updatePayChannelConfig(param);
+    }
+
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "数据列表-分页查询", description = "数据列表-分页查询")
     @RequestMapping(value = {"page"}, method = {RequestMethod.POST})

+ 11 - 11
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/paySetting/PayChannelConfig.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.domain.paySetting;
 
 import com.github.microservice.types.payment.PaymentChannelType;
+import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
 import com.zhongshu.card.server.core.domain.org.Organization;
@@ -12,6 +13,9 @@ import lombok.NoArgsConstructor;
 import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 项目的  支付渠道总设置
  *
@@ -24,19 +28,11 @@ import org.springframework.data.mongodb.core.mapping.Document;
 @AllArgsConstructor
 @NoArgsConstructor
 public class PayChannelConfig extends SuperMain {
-
-    @Schema(description = "项目信息")
-    @DBRef(lazy = true)
-    private Organization projectInfo;
-
-    @Schema(description = "项目名称")
-    private String projectName;
-
-    @Schema(description = "项目编码")
-    private String projectCode;
-
     //-------------------------------业务信息 --------------------
 
+    @Schema(description = "logo")
+    private String logo;
+
     @Schema(description = "支付产品名称")
     private String name;
 
@@ -48,4 +44,8 @@ public class PayChannelConfig extends SuperMain {
 
     @Schema(description = "数据状态")
     private DataState state = DataState.Enable;
+
+    @Schema(description = "渠道支持的支付方式")
+    private List<PaymentType> paymentTypes = new ArrayList<>();
+
 }

+ 37 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/init/DataiInit.java

@@ -0,0 +1,37 @@
+package com.zhongshu.card.server.core.init;
+
+import com.zhongshu.card.server.core.service.openAPI.OpenAPIRegisterService;
+import com.zhongshu.card.server.core.service.paySetting.ProjectChannelConfigService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 平台用户的初始化
+ *
+ * @author TRX
+ * @date 2024/6/3
+ */
+@Component
+@Slf4j
+public class DataiInit implements CommandLineRunner {
+
+    @Autowired
+    private ProjectChannelConfigService projectChannelConfigService;
+
+    @Override
+    public void run(String... args) throws Exception {
+        CompletableFuture.runAsync(() -> {
+            try {
+                TimeUnit.SECONDS.sleep(20);
+                projectChannelConfigService.initAllChannel();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        });
+    }
+}

+ 3 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DevicePermissIotService.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.service.devices;
 
 import cn.hutool.json.JSONUtil;
+import com.github.microservice.dataConfig.IotIdentifierConfig;
 import com.github.microservice.models.device.DevicePerQuery;
 import com.github.microservice.models.devicePermiss.DeviceAboutPermiss;
 import com.github.microservice.models.devicePermiss.GateWayPermissModel;
@@ -22,6 +23,7 @@ import com.zhongshu.card.server.core.domain.devices.DevicePermiss;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.domain.org.UserAccount;
 import com.zhongshu.card.server.core.domain.projectAbout.OrgUserFace;
+import com.zhongshu.card.server.core.domain.projectAbout.ProjectIotInfo;
 import com.zhongshu.card.server.core.event.DevicePermissChangeEvent;
 import com.zhongshu.card.server.core.service.openAPI.OpenApiRequestService;
 import com.zhongshu.card.server.core.service.projectAbout.CardInfoServiceImpl;
@@ -131,7 +133,7 @@ public class DevicePermissIotService {
                 }
                 IotSendParam param = new IotSendParam();
                 param.setDeviceId(deviceId);
-                param.setIdentifier("permissionNotice");
+                param.setIdentifier(IotIdentifierConfig.permissionNotice);
                 param.setFunctionType(FunctionType.Server);
 
                 PermissionChange change = new PermissionChange();

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

@@ -33,8 +33,6 @@ public class OpenAppManagerService {
      * 添加应用
      */
     public Object add(SignParam param) {
-        var ret = restTemplate.postForEntity("http://openapiserver-wjf/manager/app/add", param, ResultContent.class);
-        log.error("ret {}", ret);
         return signService.add(param);
     }
 

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

@@ -60,9 +60,6 @@ public class ProjectChannelConfigService extends SuperService {
             oid = getCurrentOid();
         }
         Organization orgInfo = organizationDao.findTopByOid(oid);
-        if (ObjectUtils.isEmpty(orgInfo)) {
-            return ResultContent.buildFail(String.format("oid不存在:%s", oid));
-        }
         PayChannelConfig entity = null;
         PayChannelConfig nameTemp = payChannelConfigDao.findTopByPaymentChannelType(param.getPaymentChannelType());
 
@@ -85,17 +82,47 @@ public class ProjectChannelConfigService extends SuperService {
             initEntityNoOid(entity);
         }
         BeanUtils.copyProperties(param, entity);
-        entity.setProjectInfo(orgInfo);
-        entity.setProjectName(orgInfo.getName());
-        entity.setProjectCode(orgInfo.getCode());
-        entity.setProjectOid(orgInfo.getOid());
+        if (ObjectUtils.isNotEmpty(orgInfo)) {
+            entity.setProjectOid(orgInfo.getOid());
+            entity.setAboutAuthType(orgInfo.getAuthType());
+        }
         entity.setOid(oid);
         entity.setAboutOid(oid);
-        entity.setAboutAuthType(orgInfo.getAuthType());
         payChannelConfigDao.save(entity);
         return ResultContent.buildSuccess();
     }
 
+    public ResultContent updatePayChannelConfig(PayChannelConfigParam param) {
+        if (StringUtils.isEmpty(param.getId())) {
+            return ResultContent.buildFail("id不能为空");
+        }
+        PayChannelConfig channelConfig = payChannelConfigDao.findTopByPaymentChannelType(param.getPaymentChannelType());
+        if (ObjectUtils.isEmpty(channelConfig)) {
+            return ResultContent.buildFail("数据不存在");
+        }
+
+        BeanUtils.copyProperties(param, channelConfig, "paymentChannelType");
+        initUpdateEntity(channelConfig);
+        payChannelConfigDao.save(channelConfig);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent initAllChannel() {
+        // 免密支付
+        PayChannelConfigParam param = new PayChannelConfigParam();
+        param.setName("免密支付");
+        param.setPaymentChannelType(PaymentChannelType.SecretFreePayment);
+        savePayChannelConfig(param);
+
+        PayChannelConfigParam balanceParam = new PayChannelConfigParam();
+        balanceParam.setName("余额支付");
+        balanceParam.setPaymentChannelType(PaymentChannelType.BalancePayment);
+        balanceParam.setSort(2L);
+        savePayChannelConfig(balanceParam);
+
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * 分页列表
      *
@@ -187,12 +214,19 @@ public class ProjectChannelConfigService extends SuperService {
             model = new PayChannelConfigModel();
             BeanUtils.copyProperties(entity, model);
 
+            List<PaymentType> paymentTypes = entity.getPaymentTypes();
+            if (ObjectUtils.isEmpty(paymentTypes)) {
+                paymentTypes = new ArrayList<>(paymentTypes);
+            }
             // 可用的支付渠道
             List<PaymentTypeModel> canUseAblePaymentTypes = new ArrayList<>();
             for (PaymentType paymentType : PaymentType.values()) {
                 if (paymentType.getChannelType() != null && entity.getPaymentChannelType() == paymentType.getChannelType()) {
                     PaymentTypeModel typeModel = new PaymentTypeModel();
                     typeModel.setPaymentType(paymentType);
+                    if (paymentTypes.contains(paymentType)) {
+                        typeModel.setIsChecked(Boolean.TRUE);
+                    }
                     canUseAblePaymentTypes.add(typeModel);
                 }
             }

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

@@ -16,6 +16,7 @@ import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.gridfs.GridFsTemplate;
 import org.springframework.stereotype.Service;
 
 /**
@@ -37,6 +38,9 @@ public class ProjectPaySettingServiceImpl extends SuperService implements Projec
     @Autowired
     OrganizationDao organizationDao;
 
+    @Autowired
+    GridFsTemplate gridFsTemplate;
+
     /**
      * 设置项目的支付类型
      *
@@ -103,7 +107,6 @@ public class ProjectPaySettingServiceImpl extends SuperService implements Projec
         if (projectOrg.getAuthType() != AuthType.Project) {
             return ResultContent.buildFail(String.format("%s 结构不属于项目类型", projectOrg.getName()));
         }
-
         WxPayConfig wxPayConfig = wxPayConfigDao.findTopByProjectOid(param.getProjectOid());
         WxPayConfig temp = wxPayConfigDao.findTopByAppId(param.getAppId());
         if (ObjectUtils.isEmpty(wxPayConfig)) {