浏览代码

no message

FengChaoYu 1 月之前
父节点
当前提交
c109e8fb84

+ 76 - 2
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserLevelLogic.java

@@ -1,6 +1,7 @@
 package com.gree.mall.manager.logic.user;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
@@ -27,6 +28,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -147,12 +149,18 @@ public class UserLevelLogic {
             throw new RemoteServiceException("无添加会员关系权限");
         }
 
+        final UserLevel level = userLevelService.getById(userLevel.getId());
+
+        if (Objects.isNull(level)) {
+            throw new RemoteServiceException("会员等级信息不存在");
+        }
+
         // 先清空会员关系
         userLevelRelaService.lambdaUpdate()
                 .eq(UserLevelRela::getUserLevelId, userLevel.getId())
                 .remove();
 
-        if (CollectionUtil.isNotEmpty(userLevel.getUserList())) {
+        if (CollectionUtil.isNotEmpty(userLevel.getRelaList())) {
             List<UserLevelRela> relaList = new ArrayList<>();
             for (UserLevelRela userLevelRela : userLevel.getRelaList()) {
                 UserLevelRela rela = new UserLevelRela();
@@ -163,17 +171,83 @@ public class UserLevelLogic {
                     final User user = userService.getById(userLevelRela.getUserId());
                     throw new RemoteServiceException(user.getNickName() + "已在" + existUserLevel.getLevelName() +  "建立关系");
                 }
-                rela.setCompanyWechatId(userLevel.getCompanyWechatId())
+                rela.setCompanyWechatId(level.getCompanyWechatId())
                         .setUserId(userLevelRela.getUserId())
                         .setUserLevelId(userLevel.getId());
 
                 relaList.add(rela);
             }
+            userLevelRelaService.saveBatch(relaList);
         }
 
+        userLevelService.lambdaUpdate()
+                .set(UserLevel::getUserUpdateBy, adminUser.getNickName())
+                .set(UserLevel::getUserUpdateTime, DateUtil.date())
+                .eq(UserLevel::getId, userLevel.getId())
+                .update();
     }
 
     @Transactional
     public void addGoods(UserLevelBean userLevel) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        String loginCompanyWechatId = adminUser.getCompanyWechatId();
+        if (StringUtils.isBlank(loginCompanyWechatId)) {
+            throw new RemoteServiceException("无添加商品规格关系权限");
+        }
+
+        // 先清空会员关系
+        userLevelGoodsService.lambdaUpdate()
+                .eq(UserLevelGoods::getUserLevelId, userLevel.getId())
+                .remove();
+
+        if (CollectionUtil.isNotEmpty(userLevel.getGoodsSpecList())) {
+            int index = 1;
+            for (UserLevelGoods userLevelGoods : userLevel.getGoodsSpecList()) {
+                if (StringUtils.isBlank(userLevelGoods.getGoodsId())) {
+                    throw new RemoteServiceException("第" + index + "行, 商品id不能为空");
+                }
+                if (StringUtils.isBlank(userLevelGoods.getGoodsName())) {
+                    throw new RemoteServiceException("第" + index + "行, 商品名称不能为空");
+                }
+                if (StringUtils.isBlank(userLevelGoods.getGoodsSpecCode())) {
+                    throw new RemoteServiceException("第" + index + "行, 物料编号不能为空");
+                }
+                if (StringUtils.isBlank(userLevelGoods.getGoodsSpecName())) {
+                    throw new RemoteServiceException("第" + index + "行, 规格名称不能为空");
+                }
+                if (StringUtils.isBlank(userLevelGoods.getGoodsSpecValue())) {
+                    throw new RemoteServiceException("第" + index + "行, 规格值不能为空");
+                }
+                if (Objects.isNull(userLevelGoods.getGoodsSpecNewPrice())) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新价格不能为空");
+                }
+                if (Objects.isNull(userLevelGoods.getGoodsSpecNewFirstFee())) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新首件运费不能为空");
+                }
+                if (Objects.isNull(userLevelGoods.getGoodsSpecNewContinueFee())) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新续件运费不能为空");
+                }
+                if (userLevelGoods.getGoodsSpecNewPrice().compareTo(BigDecimal.ZERO) <= 0) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新价格必须大于0");
+                }
+                if (userLevelGoods.getGoodsSpecNewFirstFee().compareTo(BigDecimal.ZERO) < 0) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新首件运费不能少于0");
+                }
+                if (userLevelGoods.getGoodsSpecNewContinueFee().compareTo(BigDecimal.ZERO) < 0) {
+                    throw new RemoteServiceException("第" + index + "行, 商品规格新续件运费不能少于0");
+                }
+                userLevelGoods.setUserLevelId(userLevel.getId());
+                index++;
+            }
+
+            userLevelGoodsService.saveBatch(userLevel.getGoodsSpecList());
+        }
+
+
+        userLevelService.lambdaUpdate()
+                .set(UserLevel::getGoodsUpdateBy, adminUser.getNickName())
+                .set(UserLevel::getGoodsUpdateTime, DateUtil.date())
+                .eq(UserLevel::getId, userLevel.getId())
+                .update();
     }
 }

+ 9 - 6
mall-server-api/src/main/resources/mapper/CustomGoodsMapper.xml

@@ -130,12 +130,15 @@
 
     <select id="querySpecList" resultType="com.gree.mall.manager.bean.goods.GoodsSpecVO">
         SELECT
-           a.goods_id,
-           a.goods_spec_id,
-           b.goods_name,
-           a.price,
-           a.name,
-           a.spec_value
+            a.goods_id,
+            a.goods_spec_id,
+            b.goods_name,
+            a.goods_code,
+            a.price,
+            a.first_fee,
+            a.continue_fee
+            a.name,
+            a.spec_value
         FROM goods_spec a LEFT JOIN goods b ON a.goods_id = b.goods_id
         WHERE b.del = 0 AND  a.del = 0
         <if test="keyword != null and keyword !=''">