Browse Source

Merge remote-tracking branch 'origin/dev' into dev

czh 2 years ago
parent
commit
0aece8aeea
27 changed files with 643 additions and 193 deletions
  1. 1 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictTypeEnum.java
  2. 10 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java
  3. 10 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java
  4. 7 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverMapper.java
  5. 8 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckMapper.java
  6. 9 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java
  7. 9 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java
  8. 26 0
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml
  9. 26 0
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml
  10. 12 3
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java
  11. 15 2
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SmsService.java
  12. 45 1
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java
  13. 57 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/WalletInfoDto.java
  14. 6 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/PrePayWalletVo.java
  15. 23 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/AppendPayCheck.java
  16. 16 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CreateUserReq.java
  17. 1 2
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java
  18. 26 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundBackReq.java
  19. 32 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundCheckReq.java
  20. 14 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/MoneyChange.java
  21. 8 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java
  22. 6 6
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java
  23. 152 4
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java
  24. 10 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsList.java
  25. 78 20
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  26. 13 7
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java
  27. 23 142
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/operation/GoodsManagerService.java

+ 1 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictTypeEnum.java

@@ -12,6 +12,7 @@ import lombok.Getter;
 @AllArgsConstructor
 public enum DictTypeEnum {
     MSG_CATEGORY("msg_category", "消息分类"),
+    MSG_STATUS("msg_status", "消息状态"),
     SEND_SMS_TYPE("send_sms_type", "发送短信类型"),
     INTEGRAL_TYPE("integral_type", "积分类型"),
     UNIT_TYPE("unit_type", "商品单位类型"),

+ 10 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfDriverController.java

@@ -253,4 +253,14 @@ public class KwfDriverController {
         return driverService.forgetPassword(params);
     }
 
+    /**
+     * @desc 企业司机统计
+     * @author zk
+     * @date 2023/9/18
+     **/
+    @GetMapping("/driverStatistics")
+    public HttpResult driverStatistics() {
+        return HttpResult.ok(driverService.driverStatistics());
+    }
+
 }

+ 10 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java

@@ -217,6 +217,16 @@ public class KwfTruckController {
         return truckService.transportLicenseEdit(params);
     }
 
+    /**
+     * @desc 企业车辆统计
+     * @author zk
+     * @date 2023/9/18
+     **/
+    @GetMapping("/truckStatistics")
+    public HttpResult truckStatistics() {
+        return HttpResult.ok(truckService.truckStatistics());
+    }
+
     /**
      * @param params {truckNo 車牌號}
      * @desc 车辆查询(业务关联+归属车辆)

+ 7 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfDriverMapper.java

@@ -68,4 +68,11 @@ public interface KwfDriverMapper extends BaseMapper<KwfDriver> {
      * @return
      */
     KwfDriver findEntDriver(KwfDriver params);
+
+    /**
+     * 企业司机统计
+     * @param entId 企业id
+     * @return
+     */
+    Map<String, Object> driverStatistics(@Param("entId") Long entId);
 }

+ 8 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckMapper.java

@@ -86,4 +86,12 @@ public interface KwfTruckMapper extends BaseMapper<KwfTruck> {
      * @return
      */
     List<KwfTruckMonitorVo> findTruckByAll(Map<String, Object> params);
+
+
+    /**
+     * 企业车辆统计
+     * @param entId 企业id
+     * @return
+     */
+    Map<String, Object> truckStatistics(@Param("entId") Long entId);
 }

+ 9 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfDriverService.java

@@ -841,6 +841,15 @@ public class KwfDriverService {
         }
     }
 
+    /**
+     * @desc 企业司机统计
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public Map<String, Object> driverStatistics() {
+        return driverDao.driverStatistics(LoginUserHolder.getEntId());
+    }
+
     /**
      * @param type 字典类型
      * @param value 字典值

+ 9 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -633,6 +633,15 @@ public class KwfTruckService {
         }
     }
 
+    /**
+     * @desc 企业车辆统计
+     * @author zk
+     * @date 2023/9/18
+     **/
+    public Map<String, Object> truckStatistics() {
+        return truckDao.truckStatistics(LoginUserHolder.getEntId());
+    }
+
     /**
      * @param params {truckNo 車牌號}
      * @desc 车辆查询(业务关联+归属车辆)

+ 26 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfDriverMapper.xml

@@ -305,4 +305,30 @@
         and dr.id = #{id, jdbcType=VARCHAR}
     </select>
 
+    <select id="driverStatistics" resultType="java.util.Map" >
+        select
+            tabA.abnormalTotal, tabB.idleTotal, tabC.inTaskTotal, (tabB.idleTotal + tabC.inTaskTotal) allTotal
+        from
+        (SELECT
+        count(1) abnormalTotal, '' indexNum
+        from kwf_driver tr
+        left join kwf_driver_ent tre on tre.driver_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.auth_status = 3 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabA
+        left join
+        (SELECT
+        count(1) idleTotal, '' indexNum
+        from kwf_driver tr
+        left join kwf_driver_ent tre on tre.driver_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.business_status = 0 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabB	on tabB.indexNum = tabA.indexNum
+        left join
+        (SELECT
+        count(1) inTaskTotal, '' indexNum
+        from kwf_driver tr
+        left join kwf_driver_ent tre on tre.driver_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.business_status = 1 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabC	on tabC.indexNum = tabA.indexNum
+    </select>
+
 </mapper>

+ 26 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml

@@ -359,4 +359,30 @@
         </if>
     </select>
 
+    <select id="truckStatistics" resultType="java.util.Map" >
+        select
+        tabA.abnormalTotal, tabB.idleTotal, tabC.inTaskTotal, (tabB.idleTotal + tabC.inTaskTotal) allTotal
+        from
+        (SELECT
+        count(1) abnormalTotal, '' indexNum
+        from kwf_truck tr
+        left join kwf_truck_ent tre on tre.truck_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.auth_status = 3 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabA
+        left join
+        (SELECT
+        count(1) idleTotal, '' indexNum
+        from kwf_truck tr
+        left join kwf_truck_ent tre on tre.truck_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.business_status = 0 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabB	on tabB.indexNum = tabA.indexNum
+        left join
+        (SELECT
+        count(1) inTaskTotal, '' indexNum
+        from kwf_truck tr
+        left join kwf_truck_ent tre on tre.truck_id = tr.id
+        where tr.del_flag = 0 and tre.del_flag = 0 and tr.business_status = 1 and tre.ent_id = #{entId, jdbcType=BIGINT}
+        ) tabC	on tabC.indexNum = tabA.indexNum
+    </select>
+
 </mapper>

+ 12 - 3
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java

@@ -1,7 +1,6 @@
 package com.sckw.message.service;
 
 import com.alibaba.fastjson2.JSONObject;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
@@ -123,6 +122,16 @@ public class MessageService {
         if (CollectionUtils.isEmpty(list)) {
             return Collections.emptyList();
         }
+        Map<String, String> categoryMap, statusMap;
+        Map<String, Map<String, String>> dictMap = remoteSystemService.queryDictByType(
+                Arrays.asList(DictTypeEnum.MSG_CATEGORY.getType(), DictTypeEnum.MSG_STATUS.getType()));
+        if (CollectionUtils.isNotEmpty(dictMap)) {
+            categoryMap = dictMap.get(DictTypeEnum.MSG_CATEGORY.getType());
+            statusMap = dictMap.get(DictTypeEnum.MSG_STATUS.getType());
+        } else {
+            categoryMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        }
         String clientType = LoginUserHolder.getClientType();
         List<Long> userIds = list.stream().map(MessageListDTO::getCreateBy).toList();
         Map<Long, UserCacheResDto> map = remoteSystemService.queryUserCacheMapByIds(userIds);
@@ -134,8 +143,8 @@ public class MessageService {
                 Map<String, Object> urlMap = JSONObject.parse(e.getUrl());
                 res.setUrl(Objects.isNull(urlMap.get(clientType)) ? null : urlMap.get(clientType).toString());
             }
-            res.setStatusLabel(MsgStatusEnum.getNameByCode(res.getStatus()));
-            res.setCategoryLabel(DictEnum.getLabel(DictTypeEnum.MSG_CATEGORY.getType(), e.getCategory()));
+            res.setStatusLabel(statusMap.get(String.valueOf(e.getStatus())));
+            res.setCategoryLabel(categoryMap.get(e.getCategory()));
             if (Objects.nonNull(user)) {
                 res.setCreateByName(user.getName());
                 EntCacheResDto entInfo = user.getEntInfo();

+ 15 - 2
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/SmsService.java

@@ -1,10 +1,10 @@
 package com.sckw.message.service;
 
 import com.alibaba.fastjson2.JSON;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.message.model.vo.req.GetSmsVerifyCoderReqVO;
@@ -13,11 +13,14 @@ import com.sckw.redis.constant.RedisConstant;
 import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.stream.enums.SmsCodeEnum;
 import com.sckw.stream.model.SckwSms;
+import com.sckw.system.api.RemoteSystemService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.cloud.stream.function.StreamBridge;
 import org.springframework.stereotype.Service;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
@@ -34,6 +37,9 @@ public class SmsService {
 
     private final StreamBridge streamBridge;
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
+
     /**
      * @param param
      * @return com.sckw.core.web.response.HttpResult
@@ -42,8 +48,15 @@ public class SmsService {
      * @date: 2023-06-13 13:43
      */
     public void sendVerifyCode(SendSmsVerifyCoderReqVO param) {
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(Collections.singletonList(DictTypeEnum.SEND_SMS_TYPE.getType()));
+        Map<String, String> map;
+        if (CollectionUtils.isNotEmpty(dict)){
+            map = dict.get(DictTypeEnum.SEND_SMS_TYPE.getType());
+        }else {
+            map = new HashMap<>();
+        }
         String type = param.getType();
-        if (Objects.isNull(DictEnum.getLabel(DictTypeEnum.SEND_SMS_TYPE.getType(), type))) {
+        if (Objects.isNull(map.get(type))) {
             throw new BusinessException("非法短信类型!");
         }
         String phone = param.getPhone();

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

@@ -23,6 +23,16 @@ public class WalletController {
     @Resource
     private WalletService walletService;
 
+    /**
+     * 开户
+     *
+     * @return
+     */
+    @PostMapping("createUser")
+    public HttpResult createUser(CreateUserReq createUserReq) {
+        return HttpResult.ok(walletService.createUser(createUserReq));
+    }
+
     /**
      * 钱包总览信息
      *
@@ -204,6 +214,17 @@ public class WalletController {
         return HttpResult.ok(walletService.addPrePay(prePay));
     }
 
+    /**
+     * 预付追加校验
+     *
+     * @param appendPayCheck
+     * @return
+     */
+    @PostMapping("appendCheck")
+    public HttpResult prePayAppendCheck(@RequestBody @Valid AppendPayCheck appendPayCheck) {
+        return HttpResult.ok(walletService.appendCheck(appendPayCheck));
+    }
+
     /**
      * 预付追加
      *
@@ -226,8 +247,20 @@ public class WalletController {
         return HttpResult.ok(walletService.applyRefund(refundReq));
     }
 
+
     /**
-     * 退款
+     * 发起退款余额查询及校验
+     *
+     * @param refundReq
+     * @return
+     */
+    @PostMapping("refundCheck")
+    public HttpResult refundCheck(@RequestBody @Valid RefundCheckReq refundReq) {
+        return HttpResult.ok(walletService.refundCheck(refundReq));
+    }
+
+    /**
+     * 发起退款
      *
      * @param refundReq
      * @return
@@ -236,4 +269,15 @@ public class WalletController {
     public HttpResult refund(@RequestBody @Valid RefundReq refundReq) {
         return HttpResult.ok(walletService.launchRefund(refundReq));
     }
+
+    /**
+     * 驳回退款
+     *
+     * @param refundReq
+     * @return
+     */
+    @PostMapping("back")
+    public HttpResult back(@RequestBody @Valid RefundBackReq refundReq) {
+        return HttpResult.ok(walletService.backRefund(refundReq));
+    }
 }

+ 57 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/WalletInfoDto.java

@@ -0,0 +1,57 @@
+package com.sckw.payment.model.dto;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.sckw.payment.model.vo.res.MoneyChange;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 钱包清单
+ */
+@Data
+public class WalletInfoDto implements MoneyChange, Serializable {
+    /**
+     * 是否开通钱包
+     */
+    private Boolean openFlag;
+    /**
+     * 企业名称
+     */
+    private String name;
+    /**
+     * 钱包名称
+     */
+    @JSONField(name = "wallet_name")
+    private String walletName;
+
+    /**
+     * 渠道
+     */
+    private String channel;
+
+    private Integer status;
+
+    /**
+     * 预付金额(分)
+     */
+    @JSONField(name = "ap_money")
+    private BigDecimal apMoney;
+    /**
+     * 提现余额
+     */
+    @JSONField(name = "wd_money")
+    private BigDecimal wdMoney;
+    /**
+     * 可用余额
+     */
+    private BigDecimal money;
+
+    /**
+     * 退款金额
+     */
+    private BigDecimal refundMoney;
+
+
+}

+ 6 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/PrePayWalletVo.java

@@ -22,6 +22,7 @@ public class PrePayWalletVo implements Serializable {
     @JSONField(name = "uid")
     private String uid;
     private String uidName;
+    private Long uidEnt;
 
     /**
      * 预付时,代表收款人
@@ -30,9 +31,14 @@ public class PrePayWalletVo implements Serializable {
     @JSONField(name = "filter")
     private String filter;
     private String filterName;
+    private Long filterEnt;
 
     @JSONField(name = "channel")
     private String channel;
+    /**
+     * 字典渠道
+     */
+    private String channelDict;
 
     @JSONField(name = "channel_label")
     private String channelLabel;

+ 23 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/AppendPayCheck.java

@@ -0,0 +1,23 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 预付钱包可用余额校验
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class AppendPayCheck {
+    /**
+     * 支付通道 huifu
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+}

+ 16 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/CreateUserReq.java

@@ -0,0 +1,16 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-09-18 16:19:31
+ */
+@Getter
+@Setter
+public class CreateUserReq {
+    @NotBlank(message = "支付渠道不能为空")
+    private String channel;
+}

+ 1 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/FinanceCount.java

@@ -1,6 +1,5 @@
 package com.sckw.payment.model.vo.req;
 
-import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
 import lombok.Getter;
@@ -20,7 +19,7 @@ public class FinanceCount {
     /**
      * 周期维度 1-日、2-周、3-月 4-年
      */
-    @NotBlank(message = "周期维度不能为空")
+    @NotNull(message = "周期维度不能为空")
     private Integer circle;
     /**
      * 开始时间

+ 26 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundBackReq.java

@@ -0,0 +1,26 @@
+package com.sckw.payment.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 退款驳回
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class RefundBackReq {
+    @NotBlank(message = "当前企业不能为空")
+    private String uid;
+    /**
+     * 支付通道字典值
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+}

+ 32 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/req/RefundCheckReq.java

@@ -0,0 +1,32 @@
+package com.sckw.payment.model.vo.req;
+
+import com.sckw.payment.model.vo.res.MoneyChange;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 预收-退款校验参数
+ *
+ * @author xucaiqin
+ * @date 2023-08-29 09:14:04
+ */
+@Getter
+@Setter
+public class RefundCheckReq implements MoneyChange {
+    /**
+     * 预收时,收款人 当前登录企业
+     */
+    @NotBlank(message = "当前企业不能为空")
+    private String uid;
+    /**
+     * 支付通道 huifu
+     */
+    @NotBlank(message = "支付通道不能为空")
+    private String channel;
+    /**
+     * 预收时,付款方
+     */
+    @NotBlank(message = "合作企业不能为空")
+    private String filter;
+}

+ 14 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/MoneyChange.java

@@ -1,6 +1,7 @@
 package com.sckw.payment.model.vo.res;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Objects;
 
 /**
@@ -24,4 +25,17 @@ public interface MoneyChange {
         return divide.longValueExact();
     }
 
+    /**
+     * 分转元
+     *
+     * @param big
+     * @return
+     */
+    default BigDecimal smallMoney(BigDecimal big) {
+        if (Objects.isNull(big)) {
+            return new BigDecimal("0.00");
+        }
+        return big.divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+    }
+
 }

+ 8 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementLogisticsService.java

@@ -103,6 +103,7 @@ public class KwpSettlementLogisticsService {
         settlementReq.setUnitTypeTwo(LogisticsUnitType.SHIPPER);
         return pageSelect(settlementReq);
     }
+
     /**
      * 查询贸易结算详情
      *
@@ -126,15 +127,15 @@ public class KwpSettlementLogisticsService {
         Integer payType = TradingEnum.getPrefix(trading);
         List<SettlementVo> settlementVoList = new ArrayList<>();
         if (Objects.nonNull(payType)) {
-            if(payType==TradingEnum.OFFLINE_PAY.getStatus()){
+            if (payType == TradingEnum.OFFLINE_PAY.getStatus()) {
                 settlementVoList = kwpSettlementOfflineService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
-            }else {
+            } else {
                 settlementVoList = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), payType);
             }
         }
-        List<SettlementVo> settlementWallet = kwpSettlementWalletService.queryList(id, SettlementOrderTypeEnum.LOGISTICS.getStatus(), TradingEnum.getPrefix(trading));
         return new SettlementDetailDto<>(settlementLogisticsDto, settlementVoList);
     }
+
     /**
      * 运费收款-物流订单详情
      *
@@ -375,14 +376,15 @@ public class KwpSettlementLogisticsService {
     public List<String> checkOrder(Long entId, Long entTarget) {
         return settlementLogisticsMapper.selectJoin(entId, entTarget);
     }
+
     /**
      * @param entId    顶级企业id
-     * @param cur       当月/周
-     * @param pre       上月/周
+     * @param cur      当月/周
+     * @param pre      上月/周
      * @param unitType 企业类型 2-销售 1-采购
      */
     public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {
-        return settlementLogisticsMapper.sumMoneyType(entId,  cur, pre,  unitType);
+        return settlementLogisticsMapper.sumMoneyType(entId, cur, pre, unitType);
 
     }
 }

+ 6 - 6
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/PayCenterService.java

@@ -55,7 +55,7 @@ public class PayCenterService {
     }
 
     private String getHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
@@ -90,12 +90,12 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 
     private String postHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         if (!CollectionUtils.isEmpty(para)) {
             for (Map.Entry<String, Object> p : para.entrySet()) {
@@ -129,13 +129,13 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 
     private String jsonHttp(PayCenterEnum payCenterEnum, Object object) {
         String para = object instanceof JSONObject jsonObject ? jsonObject.toJSONString() : JSONObject.toJSONString(object);
-        log.debug("{}入参->{}", payCenterEnum.getDesc(), para);
+        log.info("{}入参->{}", payCenterEnum.getDesc(), para);
         OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
         okHttpUtils.addBodyJsonStr(para);
         String sync;
@@ -145,7 +145,7 @@ public class PayCenterService {
             log.error("中台服务异常", e.getCause());
             throw new RuntimeException("支付服务异常!");
         }
-        log.debug("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
         return changeRes(sync);
     }
 

+ 152 - 4
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WalletService.java

@@ -24,11 +24,11 @@ import com.sckw.payment.model.KwpWalletTransfer;
 import com.sckw.payment.model.constant.RefundEnum;
 import com.sckw.payment.model.constant.TransferEnum;
 import com.sckw.payment.model.constant.WalletChannelEnum;
+import com.sckw.payment.model.dto.WalletInfoDto;
 import com.sckw.payment.model.dto.common.BusinessNo;
 import com.sckw.payment.model.dto.page.CashPage;
 import com.sckw.payment.model.dto.page.PrePayWalletPage;
 import com.sckw.payment.model.dto.wallet.*;
-import com.sckw.payment.model.dto.wallet.ChannelStatistics;
 import com.sckw.payment.model.vo.PrePayWalletVo;
 import com.sckw.payment.model.vo.req.*;
 import com.sckw.payment.model.vo.res.*;
@@ -91,6 +91,13 @@ public class WalletService {
         return "";
     }
 
+    private Long getEnt(String id) {
+        if (StringUtils.isBlank(id)) {
+            return null;
+        }
+        return walletRelationService.getEnt(id);
+    }
+
     /**
      * 通过企业名称查询关联的中台用户id
      *
@@ -102,7 +109,7 @@ public class WalletService {
             Long entId = LoginUserHolder.getEntId();
             List<FindEntCooperateResVo> allCooperateEnt = remoteManageService.findAllCooperateEnt(entId);
             if (!CollectionUtils.isEmpty(allCooperateEnt)) {
-                List<Long> collect = allCooperateEnt.stream().filter(a -> StringUtils.contains(a.getEntName(), entName)).map(FindEntCooperateResVo::getEntId).collect(Collectors.toList());
+                List<Long> collect = allCooperateEnt.stream().filter(a -> StringUtils.contains(a.getEntName(), entName)).map(FindEntCooperateResVo::getEntId).toList();
                 List<String> res = new ArrayList<>();
                 for (Long aLong : collect) {
                     String relation = walletRelationService.getRelation(aLong);
@@ -156,7 +163,7 @@ public class WalletService {
         } else {
             wrapper.eq(KwpWalletRefund::getUid, prePayWallet.getUid()).eq(KwpWalletRefund::getFilter, prePayWallet.getFilter());
         }
-        wrapper.eq(KwpWalletRefund::getChannel, prePayWallet.getChannel()).eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus()).last("limit 1");
+        wrapper.eq(KwpWalletRefund::getChannel, prePayWallet.getChannel()).orderByDesc(KwpWalletRefund::getCreateTime).last("limit 1");
         KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
         if (Objects.nonNull(kwpWalletRefund)) {
             prePayWalletVo.setRefundApMoney(df.format(kwpWalletRefund.getActualMoney()));
@@ -694,9 +701,13 @@ public class WalletService {
                 for (PrePayWallet row : data.getRows()) {
                     prePayWalletVo = new PrePayWalletVo();
                     BeanUtils.copyProperties(row, prePayWalletVo);
+                    ChannelEnum byChannel = ChannelEnum.getByChannel(row.getChannel());
+                    prePayWalletVo.setChannelDict(Objects.nonNull(byChannel) ? byChannel.getValue() : "");
                     prePayWalletVo.setApMoney(dfMoney(row.getApMoney()));
                     prePayWalletVo.setUidName(getFirmName(row.getUid()));
+                    prePayWalletVo.setUidEnt(getEnt(row.getUid()));
                     prePayWalletVo.setFilterName(getFirmName(row.getFilter()));
+                    prePayWalletVo.setFilterEnt(getEnt(row.getFilter()));
                     prePayWalletVo.setUsingApMoney(dfMoney(row.getUsingApMoney()));
                     prePayWalletVo.setSettlingApMoney(dfMoney(row.getSettlingApMoney()));
                     prePayWalletVo.setTotalApMoney(dfMoney(row.getTotalApMoney()));
@@ -797,9 +808,13 @@ public class WalletService {
                 for (PrePayWallet row : data.getRows()) {
                     prePayWalletVo = new PrePayWalletVo();
                     BeanUtils.copyProperties(row, prePayWalletVo);
+                    ChannelEnum byChannel = ChannelEnum.getByChannel(row.getChannel());
+                    prePayWalletVo.setChannelDict(Objects.nonNull(byChannel) ? byChannel.getValue() : "");
                     prePayWalletVo.setApMoney(dfMoney(row.getApMoney()));
                     prePayWalletVo.setUidName(getFirmName(row.getUid()));
+                    prePayWalletVo.setUidEnt(getEnt(row.getUid()));
                     prePayWalletVo.setFilterName(getFirmName(row.getFilter()));
+                    prePayWalletVo.setFilterEnt(getEnt(row.getFilter()));
                     prePayWalletVo.setUsingApMoney(dfMoney(row.getUsingApMoney()));
                     prePayWalletVo.setSettlingApMoney(dfMoney(row.getSettlingApMoney()));
                     prePayWalletVo.setTotalApMoney(dfMoney(row.getTotalApMoney()));
@@ -891,7 +906,15 @@ public class WalletService {
         if (Objects.isNull(data)) {
             throw new BusinessException("不存在交易");
         }
-        return data;
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setName(data.getName());
+        walletInfoDto.setWalletName(data.getWalletName());
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setStatus(data.getStatus());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        return walletInfoDto;
     }
 
     /**
@@ -1019,6 +1042,131 @@ public class WalletService {
         return businessNoR;
     }
 
+    /**
+     * 发起退款校验
+     *
+     * @param refundReq
+     * @return
+     */
+    public Object refundCheck(RefundCheckReq refundReq) {
+        LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwpWalletRefund::getChannel, refundReq.getChannel());
+        wrapper.eq(KwpWalletRefund::getUid, refundReq.getUid()).eq(KwpWalletRefund::getFilter, refundReq.getFilter()).eq(KwpWalletRefund::getStatus, RefundEnum.APPLY.getStatus()).last("limit 1");
+        KwpWalletRefund kwpWalletRefund = kwpWalletRefundMapper.selectOne(wrapper);
+        if (Objects.isNull(kwpWalletRefund)) {
+            throw new BusinessException("未找到待完成的退款订单");
+        }
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(refundReq.getChannel());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("支付通道不存在");
+        }
+        //发起退款是预收业务,uid和filter是相反的,查询时需要方向查询钱包
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(refundReq.getFilter(), channelEnum, refundReq.getUid());
+        // 未开通钱包
+        if (!walletInfoR.getStatus()) {
+            WalletInfoDto walletInfoDto = new WalletInfoDto();
+            walletInfoDto.setOpenFlag(false);
+            return walletInfoDto;
+        }
+        WalletInfo data = walletInfoR.getData();
+        if (Objects.isNull(data)) {
+            WalletInfoDto walletInfoDto = new WalletInfoDto();
+            walletInfoDto.setOpenFlag(false);
+            return walletInfoDto;
+        }
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setOpenFlag(true);
+        walletInfoDto.setName(data.getName());
+        walletInfoDto.setWalletName(data.getWalletName());
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setStatus(data.getStatus());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        walletInfoDto.setRefundMoney(kwpWalletRefund.getMoney());
+        return walletInfoDto;
+    }
+
+    public Object appendCheck(AppendPayCheck appendPayCheck) {
+        String uid = walletRelationService.getRelation(LoginUserHolder.getEntId());
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
+        //字典
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(appendPayCheck.getChannel());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("支付通道不存在");
+        }
+        R<WalletInfo> walletInfoR = payCenterService.totalInfo(uid, channelEnum, appendPayCheck.getFilter());
+        if (!walletInfoR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(walletInfoR.getMsg()) ? walletInfoR.getMsg() : "未找到交易方");
+        }
+        WalletInfo data = walletInfoR.getData();
+        if (Objects.isNull(data)) {
+            throw new BusinessException("不存在交易");
+        }
+        WalletInfoDto walletInfoDto = new WalletInfoDto();
+        walletInfoDto.setOpenFlag(true);
+        walletInfoDto.setName(data.getName());
+        walletInfoDto.setWalletName(data.getWalletName());
+        walletInfoDto.setChannel(data.getChannel());
+        walletInfoDto.setStatus(data.getStatus());
+        walletInfoDto.setApMoney(walletInfoDto.smallMoney(data.getApMoney()));
+        walletInfoDto.setWdMoney(walletInfoDto.smallMoney(data.getWdMoney()));
+        walletInfoDto.setMoney(walletInfoDto.smallMoney(data.getMoney()));
+        return walletInfoDto;
+    }
+
+    /**
+     * 渠道开通
+     *
+     * @param createUserReq
+     * @return
+     */
+    public Object createUser(CreateUserReq createUserReq) {
+        Long entId = LoginUserHolder.getEntId();
+        String uid = walletRelationService.getRelation(entId);
+        if (StringUtils.isBlank(uid)) {
+            throw new BusinessException("您暂未开通电子钱包");
+        }
+        //字典
+        ChannelEnum channelEnum = ChannelEnum.getByChannel(createUserReq.getChannel());
+        if (Objects.isNull(channelEnum)) {
+            throw new BusinessException("支付通道不存在");
+        }
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
+        if (Objects.isNull(entCacheResDto)) {
+            throw new BusinessException("未找到企业信息");
+        }
+        MemberCreate memberCreate = new MemberCreate();
+        memberCreate.setCompanyName(entCacheResDto.getFirmName());
+        memberCreate.setLicense(entCacheResDto.getBusiness());
+        memberCreate.setLegalName("");
+        memberCreate.setLegalPhone("");
+        memberCreate.setLegalIds("");
+        memberCreate.setAccountNo("");
+        memberCreate.setParentBankName("");
+        memberCreate.setUnionBank("");
+        memberCreate.setBankName("");
+        memberCreate.setChannel("");
+        //开通用户
+        R<MemberRes> memberResR = payCenterService.memberIndex(memberCreate);
+        if (!memberResR.getStatus()) {
+            throw new BusinessException(StringUtils.isNotBlank(memberResR.getMsg()) ? memberResR.getMsg() : "开户失败");
+        }
+        return memberResR.getData();
+    }
+
+    /**
+     * 驳回退款
+     *
+     * @param refundReq
+     * @return
+     */
+    public String backRefund(RefundBackReq refundReq) {
+        return null;
+    }
+
     /**
      * 退款处理
      *

+ 10 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsList.java

@@ -25,6 +25,11 @@ public class GoodsList {
      */
     private Long id;
 
+    /**
+     * 商品编号
+     */
+    private String code;
+
     /**
      * 状态:0草稿/1上架/2下架
      */
@@ -95,6 +100,11 @@ public class GoodsList {
      */
     private String prepaidLimitLabel;
 
+    /**
+     * 预付款最低限额
+     */
+    private BigDecimal advancePrice;
+
     /**
      * 最高单价
      */

+ 78 - 20
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.CustomPromptException;
@@ -204,6 +203,13 @@ public class KwpGoodsService {
         if (CollectionUtils.isEmpty(list)) {
             return detail;
         }
+        Map<String, String> unitMap;
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.UNIT_TYPE.getType()));
+        if (CollectionUtils.isNotEmpty(dict)) {
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        } else {
+            unitMap = new HashMap<>();
+        }
         List<Long> goodsIds = list.stream().map(KwpGoods::getId).toList();
         Map<Long, List<KwpGoodsPriceRange>> map = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
                 .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
@@ -211,7 +217,7 @@ public class KwpGoodsService {
         list.forEach(e -> {
             RecommendGoods recommendGoods = BeanUtils.copyProperties(e, RecommendGoods.class);
             List<KwpGoodsPriceRange> prices = map.get(recommendGoods.getId());
-            recommendGoods.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), recommendGoods.getUnit()))
+            recommendGoods.setUnitLabel(unitMap.get(recommendGoods.getUnit()))
                     .setPrice(CollectionUtils.isNotEmpty(prices) ? prices.get(0).getPrice() : null);
             recommendGoodsList.add(recommendGoods);
         });
@@ -246,10 +252,24 @@ public class KwpGoodsService {
         if (Objects.nonNull(managerInfo)) {
             detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
         }
-        detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
-                .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
-                .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType(), DictTypeEnum.ADDRESS_TYPE.getType()));
+        Map<String, String> productNameMap = new HashMap<>();
+        Map<String, String> unitMap = new HashMap<>();
+        Map<String, String> taxRateMap = new HashMap<>();
+        Map<String, String> goodsStatusMap = new HashMap<>();
+        Map<String, String> addressMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+            taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
+            goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
+            addressMap = dict.get(DictTypeEnum.ADDRESS_TYPE.getType());
+        }
+        detail.setGoodsTypeLabel(productNameMap.get(detail.getGoodsType()))
+                .setUnitLabel(unitMap.get(detail.getUnit()))
+                .setTaxRateLabel(taxRateMap.get(detail.getTaxRate()))
+                .setStatusLabel(goodsStatusMap.get(String.valueOf(detail.getStatus())))
                 .setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
         //商品图片信息
         List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
@@ -268,7 +288,7 @@ public class KwpGoodsService {
         KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
         AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
         if (Objects.nonNull(addressInfo)) {
-            addressInfo.setTypeName(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), addressInfo.getType()));
+            addressInfo.setTypeName(addressMap.get(addressInfo.getType()));
         }
         detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
 
@@ -531,11 +551,23 @@ public class KwpGoodsService {
     public List<GoodsListExport> export(ExportStatisticGoodsListParam params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(params);
         List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
-        List<GoodsList> goodsLists = buildGoodLists(list);
-        if (CollectionUtils.isEmpty(goodsLists)) {
+        if (CollectionUtils.isEmpty(list)) {
             return Collections.emptyList();
         }
-        List<GoodsListExport> result = new ArrayList<>();
+        return getExportResults(list);
+
+    }
+
+    /**
+     * @desc: 获取导出结果
+     * @author: yzc
+     * @date: 2023-09-18 15:19
+     * @Param list:
+     * @return: java.util.List<com.sckw.product.model.GoodsListExport>
+     */
+    public List<GoodsListExport> getExportResults(List<KwpGoods> list) {
+        List<GoodsList> goodsLists = buildGoodLists(list);
+        List<GoodsListExport> result = new ArrayList<>(list.size());
         AtomicInteger i = new AtomicInteger(1);
         goodsLists.forEach(e -> {
             GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
@@ -604,7 +636,7 @@ public class KwpGoodsService {
      * @Param list:
      * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
      */
-    private List<GoodsList> buildGoodLists(List<KwpGoods> list) {
+    public List<GoodsList> buildGoodLists(List<KwpGoods> list) {
         List<GoodsList> result = new ArrayList<>(list.size());
         List<Long> goodsIds = new ArrayList<>(list.size());
         List<Long> supplyEntIds = new ArrayList<>(list.size());
@@ -634,16 +666,30 @@ public class KwpGoodsService {
         if (CollectionUtils.isNotEmpty(supplyEntIds)) {
             entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType(), DictTypeEnum.TAX_RATE.getType(), DictTypeEnum.GOODS_STATUS.getType()));
+        Map<String, String> productNameMap, unitMap, taxRateMap, goodsStatusMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+            taxRateMap = dict.get(DictTypeEnum.TAX_RATE.getType());
+            goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
+        } else {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+            taxRateMap = new HashMap<>();
+            goodsStatusMap = new HashMap<>();
+        }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         list.forEach(e -> {
             Long id = e.getId();
             GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
             UserCacheResDto manager = userMap.get(e.getManager());
             UserCacheResDto createUser = userMap.get(e.getCreateBy());
-            goodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(goodsList.getStatus())))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goodsList.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goodsList.getUnit()))
-                    .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goodsList.getTaxRate()))
+            goodsList.setStatusLabel(goodsStatusMap.get(String.valueOf(goodsList.getStatus())))
+                    .setGoodsTypeLabel(productNameMap.get(goodsList.getGoodsType()))
+                    .setUnitLabel(unitMap.get(goodsList.getUnit()))
+                    .setTaxRateLabel(taxRateMap.get(goodsList.getTaxRate()))
                     .setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
                     .setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
                     .setManageName(Objects.nonNull(manager) ? manager.getName() : null)
@@ -651,7 +697,8 @@ public class KwpGoodsService {
                     .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
             if (CollectionUtils.isNotEmpty(priceRanges)) {
-                goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
+                goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice())
+                        .setLowestPrice(priceRanges.get(0).getPrice());
             }
             result.add(goodsList);
         });
@@ -835,13 +882,22 @@ public class KwpGoodsService {
         //供应企业信息
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
-
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType()));
+        Map<String, String> productNameMap, unitMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        } else {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+        }
         list.forEach(e -> {
             BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
             KwpGoodsAddress address = addressMap.get(e.getId());
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
-            materials.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+            materials.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setUnitLabel(unitMap.get(e.getUnit()))
                     .setAddressName(Objects.isNull(address) ? null : address.getCityName())
                     .setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
                     .setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
@@ -1012,7 +1068,9 @@ public class KwpGoodsService {
         }
         try {
             LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
-            wrapper.eq(KwpGoods::getId, id).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
+            wrapper.eq(KwpGoods::getId, id)
+                    .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
+                    .eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
             KwpGoods goods = kwpGoodsMapper.selectOne(wrapper);
             if (Objects.isNull(goods)) {
                 throw new BusinessException("商品不存在或已下架!");

+ 13 - 7
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsStatisticsService.java

@@ -1,6 +1,5 @@
 package com.sckw.product.service;
 
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
@@ -14,10 +13,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -57,11 +53,21 @@ public class KwpGoodsStatisticsService {
         if (CollectionUtils.isNotEmpty(supplyEntIds)) {
             entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.UNIT_TYPE.getType()));
+        Map<String, String> productNameMap, unitMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            unitMap = new HashMap<>();
+        } else {
+            productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
+        }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         goodsList.forEach(e -> {
             WorkbenchGoodsRes goods = BeanUtils.copyProperties(e, WorkbenchGoodsRes.class);
-            goods.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
+            goods.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setUnitLabel(unitMap.get(e.getUnit()))
                     .setSupplyFireName(entMap.get(e.getSupplyEntId()));
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
             if (CollectionUtils.isNotEmpty(priceRanges)) {

+ 23 - 142
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/operation/GoodsManagerService.java

@@ -3,9 +3,6 @@ package com.sckw.product.service.operation;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.sckw.core.common.enums.enums.DictEnum;
-import com.sckw.core.common.enums.enums.DictTypeEnum;
-import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableBottom;
@@ -14,33 +11,30 @@ import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
-import com.sckw.excel.utils.DateUtil;
 import com.sckw.product.dao.KwpGoodsMapper;
 import com.sckw.product.enums.GoodsStatusEnum;
-import com.sckw.product.model.*;
+import com.sckw.product.model.GoodsListExport;
+import com.sckw.product.model.KwpGoods;
+import com.sckw.product.model.OperationGoodsListExport;
 import com.sckw.product.model.dto.OperatorGoodsListQueryDTO;
 import com.sckw.product.model.vo.req.OperatorGoodsExportQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsListQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsStsQueryVO;
-import com.sckw.product.model.vo.res.*;
-import com.sckw.product.service.KwpGoodsAddressService;
-import com.sckw.product.service.KwpGoodsAttributeService;
-import com.sckw.product.service.KwpGoodsImageService;
-import com.sckw.product.service.KwpGoodsPriceRangeService;
+import com.sckw.product.model.vo.res.GoodsDetail;
+import com.sckw.product.model.vo.res.GoodsList;
+import com.sckw.product.model.vo.res.OperationGoodsDetail;
+import com.sckw.product.model.vo.res.OperationGoodsList;
+import com.sckw.product.service.KwpGoodsService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.KwsUserResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
-import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -60,13 +54,17 @@ public class GoodsManagerService {
     private RemoteUserService remoteUserService;
 
 
+    private final KwpGoodsService kwpGoodsService;
     private final KwpGoodsMapper kwpGoodsMapper;
-    private final KwpGoodsAddressService kwpGoodsAddressService;
-    private final KwpGoodsAttributeService kwpGoodsAttributeService;
-    private final KwpGoodsImageService kwpGoodsImageService;
-    private final KwpGoodsPriceRangeService kwpGoodsPriceRangeService;
 
 
+    /**
+     * @desc: 分页查询
+     * @author: yzc
+     * @date: 2023-09-18 15:19
+     * @Param params:
+     * @return: com.sckw.core.model.page.PageResult
+     */
     public PageResult select(OperatorGoodsListQueryVO params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, OperatorGoodsListQueryDTO.class));
         Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
@@ -75,7 +73,8 @@ public class GoodsManagerService {
         if (CollectionUtils.isEmpty(list)) {
             return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), Collections.emptyList());
         }
-        List<OperationGoodsList> result = buildGoodLists(list);
+        List<GoodsList> goodsLists = kwpGoodsService.buildGoodLists(list);
+        List<OperationGoodsList> result = BeanUtils.copyToList(goodsLists, OperationGoodsList.class);
         return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), result);
     }
 
@@ -129,67 +128,6 @@ public class GoodsManagerService {
         return wrapper;
     }
 
-    /**
-     * @desc: 构建商品列表
-     * @author: lt
-     * @date: 2023-09-14 10:14
-     * @Param list:
-     * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
-     */
-    private List<OperationGoodsList> buildGoodLists(List<KwpGoods> list) {
-        List<OperationGoodsList> result = new ArrayList<>(list.size());
-        List<Long> goodsIds = new ArrayList<>(list.size());
-        List<Long> supplyEntIds = new ArrayList<>(list.size());
-        List<Long> userIds = new ArrayList<>();
-        list.forEach(e -> {
-            goodsIds.add(e.getId());
-            if (Objects.nonNull(e.getSupplyEntId())) {
-                supplyEntIds.add(e.getSupplyEntId());
-            }
-            if (Objects.nonNull(e.getManager())) {
-                userIds.add(e.getManager());
-            }
-            if (Objects.nonNull(e.getCreateBy())) {
-                userIds.add(e.getCreateBy());
-            }
-        });
-        //地址信息
-        Map<Long, String> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds).stream()
-                .collect(Collectors.toMap(KwpGoodsAddress::getGoodsId, KwpGoodsAddress::getName, (k1, k2) -> k1));
-        //价格梯度信息
-        Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
-                .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
-        //用户信息
-        Map<Long, UserCacheResDto> userMap = remoteSystemService.queryUserCacheMapByIds(userIds);
-        //供应企业信息
-        List<EntCacheResDto> entList = new ArrayList<>();
-        if (CollectionUtils.isNotEmpty(supplyEntIds)) {
-            entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
-        }
-        Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
-        list.forEach(e -> {
-            Long id = e.getId();
-            OperationGoodsList operationGoodsList = BeanUtils.copyProperties(e, OperationGoodsList.class);
-            UserCacheResDto manager = userMap.get(e.getManager());
-            UserCacheResDto createUser = userMap.get(e.getCreateBy());
-            operationGoodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(operationGoodsList.getStatus())))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), operationGoodsList.getGoodsType()))
-                    .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), operationGoodsList.getUnit()))
-                    .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), operationGoodsList.getTaxRate()))
-                    .setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
-                    .setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
-                    .setManageName(Objects.nonNull(manager) ? manager.getName() : null)
-                    .setPhone(Objects.nonNull(manager) ? manager.getPhone() : null)
-                    .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
-            List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
-            if (CollectionUtils.isNotEmpty(priceRanges)) {
-                operationGoodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
-            }
-            result.add(operationGoodsList);
-        });
-        return result;
-    }
-
     /**
      * @desc: 获取商品详情
      * @author: lt
@@ -198,52 +136,8 @@ public class GoodsManagerService {
      * @return: com.sckw.product.model.vo.res.GoodsDetail
      */
     public OperationGoodsDetail getDetail(Long id) {
-        KwpGoods goods = kwpGoodsMapper.selectById(id);
-        if (Objects.isNull(goods)) {
-            throw new BusinessException("当前商品不存在!");
-        }
-        OperationGoodsDetail detail = BeanUtils.copyProperties(goods, OperationGoodsDetail.class);
-        Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(Arrays.asList(detail.getEntId(), detail.getSupplyEntId()));
-        EntCacheResDto ent = entMap.get(detail.getEntId());
-        if (Objects.nonNull(ent)) {
-            detail.setEnt(ent.getFirmName()).setEntHead(ent.getHead())
-                    .setEntBusiness(ent.getBusiness()).setEntAddress(ent.getCityName());
-        }
-        EntCacheResDto supplyEnt = entMap.get(detail.getSupplyEntId());
-        if (Objects.nonNull(supplyEnt)) {
-            detail.setSupplyEnt(supplyEnt.getFirmName());
-        }
-        UserCacheResDto managerInfo = remoteSystemService.queryUserCacheById(detail.getManager());
-        if (Objects.nonNull(managerInfo)) {
-            detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
-        }
-        detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
-                .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
-                .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
-                .setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
-        //商品图片信息
-        List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
-        List<GoodsImagesDetail> images = BeanUtils.copyToList(goodsImages, GoodsImagesDetail.class);
-        //商品价格段信息
-        List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(id);
-        List<GoodsPriceRangesDetail> ranges = BeanUtils.copyToList(priceRanges, GoodsPriceRangesDetail.class);
-        ranges.stream().filter(r -> r.getEndAmount().compareTo(new BigDecimal("-1.00")) == 0)
-                .forEach(r -> {
-                    r.setEndAmountLabel("不限");
-                });
-        //商品属性信息
-        List<KwpGoodsAttribute> attributesList = kwpGoodsAttributeService.getByGoodsId(id);
-        List<GoodsAttributesDetail> attributes = BeanUtils.copyToList(attributesList, GoodsAttributesDetail.class);
-        //商品地址信息
-        KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
-        AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
-        if (Objects.nonNull(addressInfo)) {
-            addressInfo.setTypeName(DictEnum.getLabel(DictTypeEnum.ADDRESS_TYPE.getType(), addressInfo.getType()));
-        }
-        detail.setImages(images).setPriceRanges(ranges).setAttributes(attributes).setAddressInfo(addressInfo);
-
-        return detail;
+        GoodsDetail goodsDetail = kwpGoodsService.detail(id);
+        return BeanUtils.copyProperties(goodsDetail, OperationGoodsDetail.class);
     }
 
     /**
@@ -287,24 +181,11 @@ public class GoodsManagerService {
     public List<OperationGoodsListExport> export(OperatorGoodsExportQueryVO params) {
         LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, OperatorGoodsListQueryDTO.class));
         List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
-        List<OperationGoodsList> goodsLists = buildGoodLists(list);
-        if (CollectionUtils.isEmpty(goodsLists)) {
+        if (CollectionUtils.isEmpty(list)) {
             return Collections.emptyList();
         }
-        List<OperationGoodsListExport> result = new ArrayList<>();
-        AtomicInteger i = new AtomicInteger(1);
-        goodsLists.forEach(e -> {
-            OperationGoodsListExport export = BeanUtils.copyProperties(e, OperationGoodsListExport.class);
-            export.setSerialNumber(String.valueOf(i.getAndIncrement()))
-                    .setAmount(Objects.isNull(e.getAmount()) ? null : String.valueOf(e.getAmount()))
-                    .setHighestPrice(Objects.isNull(e.getHighestPrice()) ? null : String.valueOf(e.getHighestPrice()))
-                    .setLowestPrice(Objects.isNull(e.getLowestPrice()) ? null : String.valueOf(e.getLowestPrice()))
-                    .setAddedTime(Objects.isNull(e.getAddedTime()) ? null : DateUtil.getDateTime(e.getAddedTime()))
-                    .setShelfTime(Objects.isNull(e.getShelfTime()) ? null : DateUtil.getDateTime(e.getShelfTime()))
-                    .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()));
-            result.add(export);
-        });
-        return result;
+        List<GoodsListExport> exportResults = kwpGoodsService.getExportResults(list);
+        return BeanUtils.copyToList(exportResults, OperationGoodsListExport.class);
     }