Bladeren bron

1.新增钱包do模型里可用余额和冻结余额
2.更新商品代码

donglang 2 maanden geleden
bovenliggende
commit
08d30a0ce4

+ 11 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/KwpBizWalletPrepay.java

@@ -36,10 +36,20 @@ public class KwpBizWalletPrepay {
     private Long orderId;
 
     /**
-     * 金额(单位:元,保留2位小数)
+     * 变动金额(单位:元,保留5位小数)
+     */
+    private BigDecimal changeAmount;
+
+    /**
+     * 可用金额(单位:元,保留5位小数)
      */
     private BigDecimal amount;
 
+    /**
+     * 冻结金额(单位:元,保留5位小数)
+     */
+    private BigDecimal prepayAmount;
+
     /**
      * 动帐类型  0-预付、1-扣款、2-冻结、3-解冻、4-消费
      */

+ 4 - 2
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/repose/KwpBizWalletPrepayPageResponse.java

@@ -52,7 +52,7 @@ public class KwpBizWalletPrepayPageResponse {
     private Long orderId;
 
     /**
-     * 本次更新金额(单位:元,保留2位小数)
+     * 变动金额(单位:元,保留5位小数)
      */
     @Schema(description = "本次更新金额")
     private BigDecimal changeAmount;
@@ -132,7 +132,9 @@ public class KwpBizWalletPrepayPageResponse {
         walletPrepayResponse.setId(walletPrepay.getId());
         walletPrepayResponse.setWalletId(walletPrepay.getWalletId());
         walletPrepayResponse.setOrderId(walletPrepay.getOrderId());
-        walletPrepayResponse.setChangeAmount(walletPrepay.getAmount());
+        walletPrepayResponse.setChangeAmount(walletPrepay.getChangeAmount());
+        walletPrepayResponse.setAmount(walletPrepay.getAmount());
+        walletPrepayResponse.setPrepayAmount(walletPrepay.getPrepayAmount());
         walletPrepayResponse.setType(walletPrepay.getType());
         walletPrepayResponse.setVoucherUrl(walletPrepay.getVoucherUrl());
         walletPrepayResponse.setRemark(walletPrepay.getRemark());

+ 3 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/request/KwpBizWalletPrepayQueryRequest.java

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.core.model.page.PageRequest;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -31,12 +32,14 @@ public class KwpBizWalletPrepayQueryRequest extends PageRequest {
      * 最小金额
      */
     @Schema(description = "最小金额")
+    @Positive(message = "金额必须为正数!")
     private BigDecimal minAmount;
 
     /**
      * 最大金额
      */
     @Schema(description = "最大金额")
+    @Positive(message = "金额必须为正数!")
     private BigDecimal maxAmount;
 
     /**

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

@@ -374,7 +374,10 @@ public class KwpBizWalletService {
         //创建钱包金额更新日志
         KwpBizWalletPrepay walletOperation = new KwpBizWalletPrepay();
         walletOperation.setWalletId(request.getWalletId());
-        walletOperation.setAmount(request.getAmount());
+        //本次变动金额
+        walletOperation.setChangeAmount(request.getAmount());
+        //可用金额
+        walletOperation.setAmount(wallet.getAmount());
         walletOperation.setType(request.getType());
         walletOperation.setVoucherUrl(request.getVoucherUrl());
         walletOperation.setRemark(request.getRemark());
@@ -393,10 +396,10 @@ public class KwpBizWalletService {
                 .eq(KwpBizWalletPrepay::getWalletId, request.getWalletId())
                 .eq(request.getType() != null, KwpBizWalletPrepay::getType, request.getType())
                 .like(StringUtils.isNotBlank(request.getRemark()), KwpBizWalletPrepay::getRemark, request.getRemark())
-                .ge(request.getMinAmount() != null, KwpBizWalletPrepay::getAmount, request.getMinAmount())
-                .lt(request.getMaxAmount() != null, KwpBizWalletPrepay::getAmount, request.getMaxAmount())
+                .ge(request.getMinAmount() != null, KwpBizWalletPrepay::getChangeAmount, request.getMinAmount())
+                .le(request.getMaxAmount() != null, KwpBizWalletPrepay::getChangeAmount, request.getMaxAmount())
                 .ge(request.getStartTime() != null, KwpBizWalletPrepay::getCreateTime, request.getStartTime())
-                .lt(request.getEndTime() != null, KwpBizWalletPrepay::getCreateTime, request.getEndTime());
+                .le(request.getEndTime() != null, KwpBizWalletPrepay::getCreateTime, request.getEndTime());
         Page<KwpBizWalletPrepay> walletPrepayPage = kwpBizWalletPrepayRepository.page(page, queryWrapper);
         //若为null,返回空分页结果
         if (walletPrepayPage == null || CollectionUtils.isEmpty(walletPrepayPage.getRecords())) {
@@ -413,8 +416,6 @@ public class KwpBizWalletService {
                     }
                     //钱包信息
                     pageResp.setWalletName(wallet.getName());
-                    pageResp.setAmount(wallet.getAmount());
-                    pageResp.setPrepayAmount(wallet.getPrepayAmount());
 
                     //企业名称
                     String entName = queryEntById(wallet.getSupEntId());

+ 0 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/AddGoodsParam.java

@@ -56,7 +56,6 @@ public class AddGoodsParam {
      * 库存数量
      */
     @Schema(description = "库存数量")
-    @NotNull(message = "库存数量不能为空")
     @DecimalMin(value = "0.01", message = "库存数量必须大于零")
     private BigDecimal amount;
 

+ 1 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsDetail.java

@@ -99,7 +99,7 @@ public class GoodsDetail {
     /**
      * 价格单位
      */
-    private BigDecimal priceUnit;
+    private String priceUnit;
 
     /**
      * 轴数

+ 10 - 3
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -718,15 +718,19 @@ public class KwpGoodsService {
             }
         });
 
-        //价格梯度信息
+        //价格信息
         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<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,  goodsStatusMap;
+        Map<String, String> productNameMap, unitMap, goodsStatusMap;
         if (CollectionUtils.isNotEmpty(dict)) {
             productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
             unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
@@ -736,13 +740,16 @@ public class KwpGoodsService {
             unitMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
             goodsStatusMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         }
+        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(CollectionUtils.isNotEmpty(goodsStatusMap) ? goodsStatusMap.get(String.valueOf(goodsList.getStatus())) : null)
                     .setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(goodsList.getGoodsType()) : null)
                     .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(goodsList.getUnit()) : null)
+                    .setSupplyEnt(entMap.get(e.getSupplyEntId()))
                     .setThumb(FileUtils.splice(e.getThumb()))
                     .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);

+ 4 - 15
sql/2025/mvp2/2025_11_03_donglang.sql

@@ -17,20 +17,7 @@ CREATE TABLE `kwp_biz_wallet`
 ) COMMENT='钱包管理表';
 
 
-CREATE TABLE `kwp_biz_wallet_operation`
-(
-    id                      bigint                                                          NOT NULL AUTO_INCREMENT COMMENT '主键',
-    wallet_id               bigint                                                          NOT NULL COMMENT '钱包id',
-    amount                  decimal(10,2)                                                   NOT NULL DEFAULT '0.00' COMMENT '本次更新金额(单位:元,保留2位小数)',
-    action                  int                                                             NOT NULL DEFAULT '0' COMMENT  '资金方向 0-预付,1-扣款',
-    voucher_url             varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '凭证URL地址',
-    remark                  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '备注',
-    create_time             datetime                                                        not null default CURRENT_TIMESTAMP comment '创建时间',
-    update_time             datetime                                                        not null default current_timestamp on update CURRENT_TIMESTAMP comment '更新时间',
-    create_user             varchar(255)                                                    not null default '' comment '创建人',
-    update_user             varchar(255)                                                     not null default '' comment '更新人',
-    PRIMARY KEY (`id`) USING BTREE
-) COMMENT='钱包金额更新表';
+
 
 
 CREATE TABLE `kwp_biz_wallet_prepay`
@@ -38,7 +25,9 @@ CREATE TABLE `kwp_biz_wallet_prepay`
     id                      bigint                                                          NOT NULL AUTO_INCREMENT COMMENT '主键',
     wallet_id               bigint                                                          NOT NULL COMMENT '钱包id',
     order_id                bigint                                                          NOT NULL COMMENT '订单id',
-    amount                  decimal(10,2)                                                   NOT NULL DEFAULT '0.00' COMMENT '金额(单位:元,保留2位小数)',
+    change_amount                  decimal(10,2)                                                   NOT NULL DEFAULT '0.00' COMMENT '变动金额(单位:元,保留2位小数)',
+    amount                  decimal(10,2)                                                   NOT NULL DEFAULT '0.00' COMMENT '可用金额(单位:元,保留2位小数)',
+    prepay_amount           decimal(10,2)                                                   NOT NULL DEFAULT '0.00' COMMENT '冻结金额(单位:元,保留2位小数)',
     type                    int                                                             NOT NULL DEFAULT '0' COMMENT '动帐类型  0-预付、1-扣款、2-冻结、3-解冻、4-消费',
     remark                  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '备注',
     voucher_url             varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci   DEFAULT NULL COMMENT '凭证URL地址',