瀏覽代碼

钱包管理调试优化

donglang 2 月之前
父節點
當前提交
28f1c4e778

+ 5 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java

@@ -281,4 +281,9 @@ public interface RemoteSystemService {
     PageDataResult<KwsEnterpriseResDto> pageEnt(int pageNum, int pageSize, Long entId);
 
     KwsEnterpriseResDto queryEnterpriseByEntId(Long entId);
+
+    EntTypeResDto queryEntTypeById(Long entId);
+
+
+
 }

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpBizWalletController.java

@@ -15,11 +15,11 @@ import com.sckw.payment.service.wallet.KwpBizWalletService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.parameters.RequestBody;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 

+ 0 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpBizWallet.java

@@ -71,14 +71,12 @@ public class KwpBizWallet {
      * 创建时间
      */
     @TableField(value = "create_time", fill = FieldFill.INSERT)
-    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 
     /**
      * 更新时间
      */
     @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
-    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updateTime;
 
     /**

+ 3 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/repose/vo/KwpBizWalletVO.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.repose.vo;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.payment.model.KwpBizWallet;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -83,12 +84,14 @@ public class KwpBizWalletVO extends PageResult {
      * 创建时间
      */
     @Schema(description = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 
     /**
      * 更新时间
      */
     @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updateTime;
 
     /**

+ 21 - 7
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/wallet/KwpBizWalletService.java

@@ -26,7 +26,9 @@ import com.sckw.payment.request.KwpBizWalletQueryRequest;
 import com.sckw.payment.request.KwpBizWalletSaveRequest;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import com.sckw.system.api.model.dto.res.EntTypeResDto;
 import com.sckw.system.api.model.dto.res.KwsEntDeptDto;
+import com.sckw.system.api.model.dto.res.KwsEnterpriseResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -252,11 +254,11 @@ public class KwpBizWalletService {
         if (entId == null) {
             return "";
         }
-        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
-        if (entCacheResDto == null) {
+        KwsEnterpriseResDto enterpriseResDto= remoteSystemService.queryEnterpriseByEntId(entId);
+        if (enterpriseResDto == null) {
             return "";
         }
-        return entCacheResDto.getFirmName();
+        return enterpriseResDto.getFirmName();
     }
 
 
@@ -271,19 +273,31 @@ public class KwpBizWalletService {
         }
 
         //查询当前登录企业
-        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
-        if (entCacheResDto == null) {
+        EntTypeResDto entTypeResDto = remoteSystemService.queryEntTypeById(LoginUserHolder.getEntId());
+        if (entTypeResDto == null) {
             throw new RuntimeException("entId:" + LoginUserHolder.getEntId() + ", 企业信息不存在!");
         }
         //校验
-        int entType = Integer.parseInt(entCacheResDto.getEntTypes());
-        if (entType != EntTypeEnum.SUPPLIER.getCode()) {
+        if (entTypeResDto.getType() != EntTypeEnum.SUPPLIER.getCode()) {
             throw new RuntimeException("entId:" + LoginUserHolder.getEntId() + ", 非供应商企业不能新建钱包!");
         }
 
+        //校验
+        LambdaQueryWrapper<KwpBizWallet> queryWrapper = Wrappers.<KwpBizWallet>lambdaQuery()
+                .eq(KwpBizWallet::getSupEntId, request.getSupEntId())
+                .eq(KwpBizWallet::getProEntId, request.getProEntId());
+
+        List<KwpBizWallet> bizWalletList = kwpBizWalletRepository.list(queryWrapper);
+        if (CollectionUtils.isNotEmpty(bizWalletList)) {
+            throw new RuntimeException("entId:" + LoginUserHolder.getEntId() + ", 已存在相同供应商企业和采购企业的钱包,不能重复创建!");
+        }
+
+
         KwpBizWallet kwpBizWallet = new KwpBizWallet();
         kwpBizWallet.setSupEntId(request.getSupEntId());
         kwpBizWallet.setProEntId(request.getProEntId());
+        kwpBizWallet.setCreateUser(LoginUserHolder.getUserName());
+        kwpBizWallet.setUpdateUser(LoginUserHolder.getUserName());
         //采购商企业名称
         String entName = queryEntById(request.getProEntId());
         kwpBizWallet.setName(entName + StringConstant.HYPHEN + OFFLINE_WALLET);

+ 3 - 3
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -347,9 +347,9 @@ public class KwsEnterpriseController {
      * 查询供应商企业或采购企业
      */
     @PostMapping("/querySupOrProEnt")
-    public BaseResult<List<EntFindInfoResp>> querySupOrProEnt(@RequestBody EntFindInfoRequest request) {
-        List<EntFindInfoResp> entFindInfoRespList = kwsEntService.querySupOrProEnt(request);
-        return BaseResult.success(entFindInfoRespList);
+    public BaseResult<EntFindInfoResp> querySupOrProEnt() {
+        EntFindInfoResp entFindInfoRes = kwsEntService.querySupOrProEnt();
+        return BaseResult.success(entFindInfoRes);
     }
 
 }

+ 6 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -880,4 +880,10 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
        return remoteBaseService.queryEnterpriseById(entId);
     }
 
+
+    @Override
+    public EntTypeResDto queryEntTypeById(Long entId) {
+        return remoteBaseService.queryEntTypeById(entId).get(0);
+    }
+
 }

+ 8 - 24
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/EntFindInfoResp.java

@@ -1,10 +1,11 @@
 package com.sckw.system.model.vo.res;
 
 
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * Author: donglang
  * Time: 2025-11-05
@@ -16,32 +17,15 @@ import lombok.Data;
 public class EntFindInfoResp {
 
     /**
-     * 企业id
+     * 供应商企业信息
      */
-    @Schema(description = "企业id")
-    private Long entId;
+    @Schema(description = "供应商企业信息")
+    private List<EntFindInfoVO> supEntInfo;
 
     /**
-     * 企业名称
+     * 采购商企业信息
      */
-    @Schema(description = "企业名称")
-    private String entName;
-
-
-    private static EntFindInfoResp getInstance() {
-        return new EntFindInfoResp();
-    }
-
-
-    public static EntFindInfoResp toPageResp(EntCacheResDto dto) {
-        if (dto == null) {
-            return new EntFindInfoResp();
-        }
-        EntFindInfoResp excelVO = EntFindInfoResp.getInstance();
-        excelVO.setEntId(dto.getId());
-        excelVO.setEntName(dto.getFirmName());
-
-        return excelVO;
-    }
+    @Schema(description = "采购商企业信息")
+    private List<EntFindInfoVO> proEntInfo;
 
 }

+ 50 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/EntFindInfoVO.java

@@ -0,0 +1,50 @@
+package com.sckw.system.model.vo.res;
+
+
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Author: donglang
+ * Time: 2025-11-05
+ * Des: 企业下拉信息
+ * Version: 1.0
+ */
+
+@Data
+public class EntFindInfoVO {
+
+    /**
+     * 企业id
+     */
+    @Schema(description = "企业id")
+    private Long entId;
+
+    /**
+     * 企业名称
+     */
+    @Schema(description = "企业名称")
+    private String entName;
+
+
+    private static EntFindInfoVO getInstance() {
+        return new EntFindInfoVO();
+    }
+
+
+    public static EntFindInfoVO toPageResp(EntCacheResDto dto) {
+        if (dto == null) {
+            return new EntFindInfoVO();
+        }
+        EntFindInfoVO excelVO = EntFindInfoVO.getInstance();
+        excelVO.setEntId(dto.getId());
+        excelVO.setEntName(dto.getFirmName());
+
+        return excelVO;
+    }
+
+
+}

+ 21 - 18
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -1,6 +1,7 @@
 package com.sckw.system.service;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.PageHelper;
@@ -1624,36 +1625,38 @@ public class KwsEnterpriseService {
      *
      * @return
      */
-    public List<EntFindInfoResp> querySupOrProEnt(EntFindInfoRequest request) {
-        List<EntCacheResDto>  entResDtoList = new ArrayList<>();
+    public EntFindInfoResp querySupOrProEnt() {
+        EntFindInfoResp entFindInfoResp = new EntFindInfoResp();
         //查询当前登录企业
         EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
         if (entCacheResDto == null) {
             throw new RuntimeException("entId:" + LoginUserHolder.getEntId() + ", 企业信息不存在!");
         }
-
+        //校验
         int entType = Integer.parseInt(entCacheResDto.getEntTypes());
         if (entType != EntTypeEnum.SUPPLIER.getCode()) {
             throw new RuntimeException("entId:" + LoginUserHolder.getEntId() + ", 只有供应商企业可以创建钱包!");
         }
-        //供应企业
-        if (EntTypeEnum.SUPPLIER.getCode() == request.getEntType()) {
-            entResDtoList.add(entCacheResDto);
-            //查询当前供应商的子级企业
-            List<KwsEntDeptDto> kwsEntDeptDtoList = remoteSystemService.queryEntDeptByPid(entCacheResDto.getParentId());
-            if (CollectionUtils.isEmpty(kwsEntDeptDtoList)){
-                return entResDtoList.stream().map(EntFindInfoResp::toPageResp).collect(Collectors.toList());
-            }
-            List<Long> parentId = kwsEntDeptDtoList.stream().map(KwsEntDeptDto::getEntId).collect(Collectors.toList());
-            List<EntCacheResDto> entDtoList = remoteSystemService.queryEntCacheByIds(parentId);
-            entResDtoList.addAll(entDtoList);
+
+        //查询当前供应商的子级企业
+        List<KwsEntDeptDto> subEntList = remoteSystemService.queryEntDeptByPid(entCacheResDto.getParentId());
+        if (CollectionUtils.isEmpty(subEntList)){
+            EntFindInfoVO entFindInfoVO = EntFindInfoVO.toPageResp(entCacheResDto);
+            //子级为空,只返回父级供应商
+            entFindInfoResp.setSupEntInfo(Lists.newArrayList(entFindInfoVO));
         } else {
-            //查询采购商企业信息
-            List<EntCacheResDto> entDtoList = queryKwsEnterpriseById();
-            entResDtoList.addAll(entDtoList);
+            List<Long> parentId = subEntList.stream().map(KwsEntDeptDto::getEntId).collect(Collectors.toList());
+            List<EntCacheResDto> entDtoList = remoteSystemService.queryEntCacheByIds(parentId);
+            entDtoList.add(0, entCacheResDto);
+            List<EntFindInfoVO> entFindInfoVOList = entDtoList.stream().map(EntFindInfoVO::toPageResp).collect(Collectors.toList());
+            entFindInfoResp.setSupEntInfo(entFindInfoVOList);
         }
+        //查询采购商企业信息
+        List<EntCacheResDto> proEntList = queryKwsEnterpriseById();
+        List<EntFindInfoVO> proEntVOList = proEntList.stream().map(EntFindInfoVO::toPageResp).collect(Collectors.toList());
+        entFindInfoResp.setProEntInfo(proEntVOList);
 
-        return entResDtoList.stream().map(EntFindInfoResp::toPageResp).collect(Collectors.toList());
+        return entFindInfoResp;
     }
 
     /**