TRX 1 год назад
Родитель
Сommit
ac6a2179a8

+ 5 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/scene/ProjectBindSceneParam.java

@@ -7,6 +7,9 @@ import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2024/11/22
@@ -20,4 +23,6 @@ public class ProjectBindSceneParam extends ProjectOidParam {
     @NotEmpty
     private String id;
 
+    private List<String> ids = new ArrayList<>();
+
 }

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/scene/RoleBindSceneParam.java

@@ -6,6 +6,10 @@ import jakarta.validation.constraints.NotEmpty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.w3c.dom.stylesheets.LinkStyle;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author TRX

+ 0 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/scene/SceneInfoParam.java

@@ -26,7 +26,6 @@ public class SceneInfoParam extends SuperParam {
     @Schema(description = "编码")
     private String code;
 
-    @NotEmpty
     @Schema(description = "图标")
     private String logo;
 

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

@@ -51,6 +51,13 @@ public class ProjectSceneInfoController {
         return this.projectSceneInfoService.bindScene(param);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "绑定场景(多个)", description = "绑定场景")
+    @RequestMapping(value = "bindScenes", method = {RequestMethod.POST})
+    public ResultContent bindScenes(@RequestBody @Valid ProjectBindSceneParam param) {
+        return this.projectSceneInfoService.bindScenes(param);
+    }
+
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "根据场景数据ID 场景详情", description = "根据场景数据ID 场景详情")
     @RequestMapping(value = "getDetailById", method = {RequestMethod.POST})

+ 0 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/scene/RoleSceneInfoController.java

@@ -5,7 +5,6 @@ import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.card.client.model.base.SortParam;
-import com.zhongshu.card.client.model.org.role.RoleSimpleModel;
 import com.zhongshu.card.client.model.scene.RoleBindAllParam;
 import com.zhongshu.card.client.model.scene.RoleBindSceneParam;
 import com.zhongshu.card.client.model.scene.RoleSceneInfoModel;

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

@@ -249,9 +249,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
      */
     private void commonVerifyExpenseFlow(ExpenseFlow entity) {
         String deviceId = entity.getDeviceId();
-        StopWatch stopWatch = new StopWatch();
-        stopWatch.start("验证");
-
         // 验证设备
         DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
         if (ObjectUtils.isEmpty(deviceInfo)) {
@@ -358,8 +355,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         }
         entity.setVerifyParamIsSuccess(Boolean.TRUE);
         entity.setVerifyParamMsg("参数验证成功");
-        stopWatch.stop();
-        log.info("验证; {}", stopWatch.prettyPrint());
     }
 
     /**

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

@@ -108,7 +108,7 @@ public class PayCallService extends SuperService {
             return ResultContent.buildFail(msg);
         }
         stopWatch.stop();
-        log.info("支付过程: {}", stopWatch.prettyPrint());
+
 
         List<PaymentType> paymentTypes = resultContent.getContent();
         if (ObjectUtils.isEmpty(paymentTypes)) {
@@ -132,7 +132,9 @@ public class PayCallService extends SuperService {
             entity.setPaymentWay(paymentType.getRemark());
             if (paymentType == PaymentType.UserWallet) {
                 // 钱包支付
+                stopWatch.start("钱包支付");
                 balancePay(entity);
+                stopWatch.stop();
             } else if (paymentType == PaymentType.UnionFrictionlessPay) {
                 // 银联云闪付
                 unionFrictionlessPay(entity);
@@ -173,6 +175,7 @@ public class PayCallService extends SuperService {
             entity.setIsPaid(Boolean.TRUE);
             expenseFlowDao.save(entity);
         }
+        log.info("支付过程: {}", stopWatch.prettyPrint());
         return ResultContent.buildSuccess();
     }
 
@@ -184,9 +187,12 @@ public class PayCallService extends SuperService {
      */
     public ResultContent balancePay(ExpenseFlow entity) {
         String desc = "消费";
+        // 日志
         OperationLogsAddParam logsAddParam = initLog(entity.getUserId());
         logsAddParam.setTitle(desc);
         logsAddParam.setDataId(entity.getPaymentNo());
+
+        // 支付记录
         PaymentProcess paymentProcess = new PaymentProcess();
         paymentProcess.setPaymentNo(entity.getPaymentNo());
         paymentProcess.setExpenseFlow(entity);
@@ -547,7 +553,7 @@ public class PayCallService extends SuperService {
 
         BigDecimal payAmount = entity.getPayAmount();
         payAmount = payAmount.stripTrailingZeros();
-        ResultContent resultContent = chinaumsSenselessPayService.refund(entity.getProjectOid(), entity.getShopOid(), entity.getUserId(), payAmount, paymentNo, refundNo, param.getRemark(), targetOrderId);
+        ResultContent<UnionFrictionlessPayFinishModel> resultContent = chinaumsSenselessPayService.refund(entity.getProjectOid(), entity.getShopOid(), entity.getUserId(), payAmount, paymentNo, refundNo, param.getRemark(), targetOrderId);
 
         // 退款记录
         RefundRecord refundRecord = new RefundRecord();
@@ -584,6 +590,7 @@ public class PayCallService extends SuperService {
             refundRecordService.saveEntity(refundRecord);
             return ResultContent.buildSuccess(resultContent.getContent());
         } else {
+            // 失败
             refundRecord.setRefundUserId(getCurrentUserId());
             refundRecord.setExamineTime(System.currentTimeMillis());
             refundRecord.setRefuseRemark(resultContent.getMsg());
@@ -615,7 +622,6 @@ public class PayCallService extends SuperService {
         // 退款完成
         ExpenseFlow expenseFlow = expenseFlowDao.findTopByPaymentNo(paymentNo);
 
-
         if (ObjectUtils.isNotEmpty(expenseFlow)) {
             if (state.equals("TRADE_SUCCESS") && refundStatus.equals("SUCCESS")) {
                 orderNoInfoService.markSuccess(paymentNo);

+ 45 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/scene/ProjectSceneInfoService.java

@@ -6,11 +6,9 @@ import com.github.microservice.net.ResultMessage;
 import com.zhongshu.card.client.model.scene.ProjectBindSceneParam;
 import com.zhongshu.card.client.model.scene.ProjectSceneInfoModel;
 import com.zhongshu.card.client.model.scene.ProjectSceneInfoSearch;
-import com.zhongshu.card.client.model.scene.RoleBindAllParam;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.scene.ProjectSceneInfoDao;
-import com.zhongshu.card.server.core.dao.scene.RoleSceneInfoDao;
 import com.zhongshu.card.server.core.dao.scene.SceneInfoDao;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.domain.scene.ProjectSceneInfo;
@@ -26,7 +24,9 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -64,20 +64,57 @@ public class ProjectSceneInfoService extends SuperService {
         if (ObjectUtils.isEmpty(organization)) {
             return ResultContent.buildFail("项目不存在");
         }
-        ProjectSceneInfo projectSceneInfo = projectSceneInfoDao.findTopBySceneInfoAndProjectOid(entity, param.getProjectOid());
+        ProjectSceneInfo projectSceneInfo = buildProjectScene(entity, organization);
         if (ObjectUtils.isNotEmpty(projectSceneInfo)) {
-            return ResultContent.buildFail(String.format("项目已存在场景:%s", entity.getName()));
+            projectSceneInfoDao.save(projectSceneInfo);
+        }
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 绑定多个
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent bindScenes(ProjectBindSceneParam param) {
+        List<String> ids = param.getIds();
+        if (ObjectUtils.isEmpty(ids)) {
+            return ResultContent.buildFail("ids不能为空");
+        }
+        Organization organization = organizationDao.findTopByOid(param.getProjectOid());
+        if (ObjectUtils.isEmpty(organization)) {
+            return ResultContent.buildFail("项目不存在");
+        }
+        List<ProjectSceneInfo> list = new ArrayList<>();
+        for (String id : ids) {
+            SceneInfo entity = sceneInfoDao.findTopById(id);
+            if (ObjectUtils.isNotEmpty(entity)) {
+                ProjectSceneInfo projectSceneInfo = buildProjectScene(entity, organization);
+                if (ObjectUtils.isEmpty(projectSceneInfo)) {
+                    list.add(projectSceneInfo);
+                }
+            }
+        }
+        if (ObjectUtils.isNotEmpty(list)) {
+            projectSceneInfoDao.saveAll(list);
+        }
+        return ResultContent.buildSuccess();
+    }
+
+    private ProjectSceneInfo buildProjectScene(SceneInfo entity, Organization projectInfo) {
+        ProjectSceneInfo projectSceneInfo = projectSceneInfoDao.findTopBySceneInfoAndProjectOid(entity, projectInfo.getOid());
+        if (ObjectUtils.isEmpty(projectSceneInfo)) {
+            projectSceneInfo = new ProjectSceneInfo();
         }
-        projectSceneInfo = new ProjectSceneInfo();
         projectSceneInfo.setSceneInfo(entity);
         projectSceneInfo.setSceneInfoId(entity.getId());
         projectSceneInfo.setName(entity.getName());
         projectSceneInfo.setSceneType(entity.getSceneType());
         projectSceneInfo.setSceneState(entity.getState());
-
         projectSceneInfo.setState(entity.getState());
-        projectSceneInfoDao.save(projectSceneInfo);
-        return ResultContent.buildSuccess();
+        projectSceneInfo.setProjectOid(projectInfo.getOid());
+        return projectSceneInfo;
     }
 
     public ResultContent<Page<ProjectSceneInfoModel>> page(ProjectSceneInfoSearch param, Pageable pageable) {