Browse Source

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

18482106067 2 years ago
parent
commit
f50b06715a

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/BusinessException.java

@@ -16,7 +16,7 @@ public class BusinessException extends RuntimeException {
     /**
      * 异常信息
      **/
-    private String msg;
+    private final String msg;
     private Object[] param;
 
     public BusinessException(String msg) {

+ 7 - 4
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/CustomPromptException.java

@@ -6,7 +6,7 @@ import java.io.Serial;
 
 /**
  * @Author yzc
- * @Description 自定义提示异常
+ * @Description 前端自定义提示异常
  * @createTime 2023年06月08日 10:05:00
  */
 @Getter
@@ -17,16 +17,19 @@ public class CustomPromptException extends RuntimeException {
     /**
      * 异常信息
      **/
-    private String msg;
+    private final String msg;
+    private final Integer code;
     private Object[] param;
 
-    public CustomPromptException(String msg) {
+    public CustomPromptException(Integer code,String msg) {
         super(msg);
+        this.code = code;
         this.msg = msg;
     }
 
-    public CustomPromptException(String msg, Object... param) {
+    public CustomPromptException(Integer code,String msg, Object... param) {
         super(msg);
+        this.code = code;
         this.msg = msg;
         this.param = param;
     }

+ 3 - 2
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java

@@ -49,14 +49,15 @@ public class GlobalSystemExceptionHandler {
 
     /**
      * 前端自定义提示异常
+     *
      * @param ex
      * @return
      */
     @ResponseBody
     @ExceptionHandler(CustomPromptException.class)
     public HttpResult customPromptExceptionHandler(CustomPromptException ex) {
-        log.info("业务异常,message={},param={}", ex.getMsg(), ex.getParam());
-        return HttpResult.error(HttpStatus.CUSTOM_PROMPT_CODE, ex.getMessage());
+        log.info("前端自定义提示异常,code={},message={},param={}", ex.getCode(), ex.getMsg(), ex.getParam());
+        return HttpResult.error(ex.getCode(), ex.getMessage());
     }
 
 

+ 6 - 2
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -24,9 +24,13 @@ public class HttpStatus {
     /**全局异常状态码*/
     public static final int GLOBAL_EXCEPTION_CODE = 60500;
     /**
-     * 自定义提示异常
+     * 完结贸易订单失败异常码
      */
-    public static final int CUSTOM_PROMPT_CODE = 60666;
+    public static final int COMPLETE_TORDER_FAIL_CODE = 60666;
+    /**
+     * 商品上架失败异常码
+     */
+    public static final int GOODS_PUT_ON_SHELVES_FAIL_CODE = 60667;
     /**全局异常提示信息*/
     public static final String GLOBAL_EXCEPTION_MESSAGE = "攻城狮正在拼命优化,请您稍候再试!";
 

+ 7 - 6
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -326,12 +326,13 @@ public class KwoTradeOrderService {
         if (goods.getAmount().compareTo(amount) < 0) {
             throw new BusinessException("商品库存不足,请联系供应方!");
         }
-        BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
-        //直接采购下单才校验预付款限额
-        if (Objects.equals(param.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue()) && trading.startsWith("1") && price.compareTo(advancePrice) < 0) {
-            throw new BusinessException("您的订单总额未达到预付限额,请确认");
-        }
+        //支付方式预付款校验
         if (trading.startsWith("1")) {
+            BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
+            //直接采购下单才校验预付款限额
+            if (Objects.equals(param.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue()) && price.compareTo(advancePrice) < 0) {
+                throw new BusinessException("您的订单总额未达到预付限额,请确认");
+            }
             R<List<WalletDto>> wallet = payCenterDubboService.wallet(param.getProcureTopEntId(), ChannelEnum.getByCode(trading), param.getSupplyTopEntId());
             if (Objects.isNull(wallet) || Objects.equals(wallet.getCode(), 0)) {
                 throw new BusinessException("校验预付钱包异常,请联系管理员!");
@@ -786,7 +787,7 @@ public class KwoTradeOrderService {
             throw new BusinessException("无订单操作权限!");
         }
         if (transportDubboService.checkLogisticsOrderByTradeOrderId(param.getId())) {
-            throw new CustomPromptException("订单存在未完成的物流托运,不可完结!");
+            throw new CustomPromptException(HttpStatus.COMPLETE_TORDER_FAIL_CODE, "订单存在未完成的物流托运,不可完结!");
         }
         String lockKey = String.format(RedisConstant.TORDER_UPDATE_AMOUNT_KEY, param.getId());
         if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 5L, 10L))) {

+ 4 - 1
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementLogisticsMapper.xml

@@ -123,11 +123,14 @@
         </if>
 
         <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
-            and ( and l.name like concat('%'
+            and ( l.name like concat('%'
             , #{settlementReq.keywords,jdbcType=VARCHAR}
             , '%')
                 or lu2.firm_name like concat('%'
             , #{settlementReq.keywords,jdbcType=VARCHAR}
+            , '%')
+                or s.sl_order_no like concat('%'
+            , #{settlementReq.keywords,jdbcType=VARCHAR}
             , '%')
                 )
         </if>

+ 8 - 2
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -54,6 +54,7 @@
                 and (
                             klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                         or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kst.st_order_no like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
             <if test="settlementReq.status != null">
@@ -100,6 +101,7 @@
                 and (
                             klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                         or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kst.st_order_no like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
             <if test="settlementReq.trading != null and settlementReq.trading != ''">
@@ -128,7 +130,8 @@
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
                                                           kltu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
                  inner join kwp_ledger_trade_unit kltu2 on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and
-                                                           kltu2.unit_type = #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
+                                                           kltu2.unit_type =
+                                                           #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
         <where>
             kst.del_flag = 0
               and kltu2.top_ent_id = #{settlementReq.entId,jdbcType=INTEGER}
@@ -136,6 +139,7 @@
                 and (
                             klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                         or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kst.st_order_no like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
             <if test="settlementReq.status != null">
@@ -162,7 +166,8 @@
                  inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
                                                           kltu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
                  inner join kwp_ledger_trade_unit kltu2 on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and
-                                                           kltu2.unit_type = #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
+                                                           kltu2.unit_type =
+                                                           #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
         <where>
             kst.del_flag = 0
               and kltu2.top_ent_id = #{settlementReq.entId,jdbcType=INTEGER}
@@ -170,6 +175,7 @@
                 and (
                             klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                         or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                        or kst.st_order_no like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
             <if test="settlementReq.trading != null and settlementReq.trading != ''">

+ 45 - 36
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -7,6 +7,7 @@ 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;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableBottom;
@@ -16,6 +17,7 @@ import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.NumberUtils;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.DateUtil;
 import com.sckw.payment.api.dubbo.PayCenterDubboService;
@@ -273,7 +275,10 @@ public class KwpGoodsService {
         }
         if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) ||
                 Objects.equals(goods.getStatus(), GoodsStatusEnum.TAKE_OFF_SHELVES.getCode())) {
-            judgeParameters(param);
+            String msg = judgeParameters(param);
+            if (StringUtils.isNotBlank(msg)) {
+                throw new BusinessException(msg);
+            }
             if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) &&
                     goods.getAmount().compareTo(param.getAmount()) != 0) {
                 throw new BusinessException("上架商品不可修改库存数量!");
@@ -349,103 +354,104 @@ public class KwpGoodsService {
      * @Param param:
      * @return: void
      */
-    private void judgeParameters(UpdateGoodsParam param) {
+    private String judgeParameters(UpdateGoodsParam param) {
         if (StringUtils.isBlank(param.getName())) {
-            throw new BusinessException("商品名称不能为空!");
+            return "商品名称不能为空!";
         }
         if (StringUtils.isBlank(param.getGoodsType())) {
-            throw new BusinessException("商品类型不能为空!");
+            return "商品类型不能为空!";
         }
         if (StringUtils.isBlank(param.getUnit())) {
-            throw new BusinessException("计量单位不能为空!");
+            return "计量单位不能为空!";
         }
         if (StringUtils.isBlank(param.getSpec())) {
-            throw new BusinessException("规格尺寸不能为空!");
+            return "规格尺寸不能为空!";
         }
         if (Objects.isNull(param.getAmount())) {
-            throw new BusinessException("库存数量不能为空!");
+            return "库存数量不能为空!";
         }
         if (StringUtils.isBlank(param.getTaxRate())) {
-            throw new BusinessException("发票税率不能为空!");
+            return "发票税率不能为空!";
         }
         if (Objects.isNull(param.getPrepaidLimit())) {
-            throw new BusinessException("是否设置预付限额不能为空!");
+            return "是否设置预付限额不能为空!";
         }
         if (Objects.equals(param.getPrepaidLimit(), 1) && Objects.isNull(param.getAdvancePrice())) {
-            throw new BusinessException("设置预付限额时,预付款最低限额不能为空!");
+            return "设置预付限额时,预付款最低限额不能为空!";
         }
 
         List<GoodsAttributes> attributes = param.getAttributes();
         if (CollectionUtils.isNotEmpty(attributes)) {
-            attributes.forEach(e -> {
+            for (GoodsAttributes e : attributes) {
                 if (StringUtils.isBlank(e.getName()) || StringUtils.isBlank(e.getVal())) {
-                    throw new BusinessException("参数名称或参数值不能为空且!");
+                    return "参数名称或参数值不能为空!";
                 }
-            });
+            }
         }
         List<GoodsImages> images = param.getImages();
         if (CollectionUtils.isNotEmpty(images)) {
-            images.forEach(e -> {
+            for (GoodsImages e : images) {
                 if (StringUtils.isBlank(e.getImage())) {
-                    throw new BusinessException("商品图片地址不能为空!");
+                    return "商品图片地址不能为空!";
                 }
                 if (Objects.isNull(e.getSort())) {
-                    throw new BusinessException("商品图片排序不能为空!");
+                    return "商品图片排序不能为空!";
                 }
-            });
+            }
         }
         List<GoodsPriceRanges> priceRanges = param.getPriceRanges();
         if (CollectionUtils.isEmpty(priceRanges)) {
-            throw new BusinessException("价格梯度不能为空!");
+            return "价格梯度不能为空!";
         }
-        priceRanges.forEach(e -> {
+        for (GoodsPriceRanges e : priceRanges) {
             if (Objects.isNull(e.getStartAmount()) || e.getStartAmount().compareTo(BigDecimal.ZERO) < 0) {
-                throw new BusinessException("起售量最小为零!");
+                return "起售量不能为空且最小为零!";
             }
             if (Objects.isNull(e.getEndAmount()) || e.getEndAmount().compareTo(new BigDecimal("-1.00")) < 0) {
-                throw new BusinessException("上限售量最小为零!");
+                return "上限售量不能为空且最小为零!";
             }
             if (Objects.isNull(e.getPrice()) || e.getStartAmount().compareTo(BigDecimal.ZERO) < 0) {
-                throw new BusinessException("含税价最低为零!");
+                return "含税价不能为空且最低为零!";
             }
             if (Objects.isNull(e.getSort())) {
-                throw new BusinessException("价格梯度顺序不能为空!");
+                return "价格梯度顺序不能为空!";
             }
-        });
+        }
         AddressInfo address = param.getAddressInfo();
         if (Objects.isNull(address)) {
-            throw new BusinessException("地址信息不能为空!");
+            return "地址信息不能为空!";
         }
         if (StringUtils.isBlank(address.getName()) || address.getName().length() > 50) {
-            throw new BusinessException("地址名称不能为空且最长50字符!");
+            return "地址名称不能为空且最长50字符!";
         }
         if (StringUtils.isBlank(address.getType())) {
-            throw new BusinessException("地址类型不能为空!");
+            return "地址类型不能为空!";
         }
         if (StringUtils.isBlank(address.getContacts())) {
-            throw new BusinessException("联系人不能为空!");
+            return "联系人不能为空!";
         }
         if (StringUtils.isBlank(address.getPhone())) {
-            throw new BusinessException("联系电话不能为空!");
+            return "联系电话不能为空!";
         }
         if (Objects.isNull(address.getCityCode())) {
-            throw new BusinessException("所在地区code不能为空!");
+            return "所在地区code不能为空!";
         }
         if (StringUtils.isBlank(address.getCityName()) || address.getCityName().length() > 40) {
-            throw new BusinessException("所属区域名称不能为空最长40字符!");
+            return "所属区域名称不能为空最长40字符!";
         }
         if (Objects.isNull(address.getLat())) {
-            throw new BusinessException("纬度不能为空!");
+            return "纬度不能为空!";
         }
         if (Objects.isNull(address.getLng())) {
-            throw new BusinessException("经度不能为空!");
+            return "经度不能为空!";
         }
         if (Objects.isNull(param.getSupplyEntId())) {
-            throw new BusinessException("供应企业不能为空!");
+            return "供应企业不能为空!";
         }
         if (Objects.isNull(param.getManager())) {
-            throw new BusinessException("客户经理不能为空!");
+            return "客户经理不能为空!";
         }
+        return null;
     }
 
     /**
@@ -656,7 +662,10 @@ public class KwpGoodsService {
             updateParam.setPriceRanges(BeanUtils.copyToList(kwpGoodsPriceRangeService.getByGoodsId(id), GoodsPriceRanges.class));
             updateParam.setImages(BeanUtils.copyToList(kwpGoodsImageService.getByGoodsId(id), GoodsImages.class));
             updateParam.setAddressInfo(BeanUtils.copyProperties(kwpGoodsAddressService.getByGoodsId(id), AddressInfo.class));
-            judgeParameters(updateParam);
+            String msg = judgeParameters(updateParam);
+            if (StringUtils.isNotBlank(msg)) {
+                throw new CustomPromptException(HttpStatus.GOODS_PUT_ON_SHELVES_FAIL_CODE, msg);
+            }
         }
         LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
         updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).set(KwpGoods::getAddedTime, new Date()).eq(KwpGoods::getId, id);

+ 12 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -290,8 +290,18 @@ public class KwsEnterpriseService {
             typeList = listByEntId.stream().map(KwsEntType::getType).toList();
         }
         List<Integer> finalTypeList = typeList;
+        if (CollectionUtils.isNotEmpty(listByEntId)) {
+            for (KwsEntType listId : listByEntId) {
+                KwsEntType kwsEntType = new KwsEntType();
+                kwsEntType.setId(listId.getId());
+                kwsEntType.setDelFlag(Global.YES);
+                if (kwsEntTypeDao.update(kwsEntType) <= 0) {
+                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+                }
+            }
+        }
         Arrays.stream(reqVo.getEntTypes().split(",")).toList().forEach(item -> {
-            if (!finalTypeList.contains(item)) {
+            //if (!finalTypeList.contains(Integer.parseInt(item))) {
                 KwsEntType kwsEntType = new KwsEntType();
                 kwsEntType.setEntId(entId);
                 kwsEntType.setType(Integer.parseInt(item));
@@ -305,7 +315,7 @@ public class KwsEnterpriseService {
                 if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
                     throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
                 }
-            }
+            //}
         });
 
         /*3、存企业证书*/

+ 12 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java

@@ -2,6 +2,7 @@ package com.sckw.system.service;
 
 import java.util.Date;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
@@ -262,6 +263,16 @@ public class KwsRoleService {
                 }
             }
         }
+        //删除kws_authority表数据
+        List<KwsAuthority> kwsAuthorityList = kwsAuthorityDao.selectByRoleIds(Collections.singletonList(kwsRole.getId()));
+        if (CollectionUtils.isNotEmpty(kwsAuthorityList)) {
+            for (KwsAuthority kwsAuthority : kwsAuthorityList) {
+                kwsAuthority.setDelFlag(Global.YES);
+                if (kwsAuthorityDao.update(kwsAuthority) <= 0) {
+                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
+                }
+            }
+        }
 
         KwsDept kwsDept = kwsDeptDao.selectByKey(kwsRole.getDeptId());
 
@@ -278,6 +289,7 @@ public class KwsRoleService {
         if (kwsRoleDao.update(kwsRoleTable) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
+        saveAuthority(reqVo.getId(), reqVo.getDeptIds());
 //        List<KwsUser> kwsUsers = kwsUserDao.selectByRoleIds(Collections.singletonList(reqVo.getId()));
 //
 //        //删除以前的角色

+ 34 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEntTypeDao.xml

@@ -87,6 +87,40 @@
     </trim>
   </insert>
 
+  <update id="update" parameterType="com.sckw.system.model.KwsEntType">
+    update kws_ent_type
+    <set>
+      <if test="entId != null">
+        ent_id = #{entId,jdbcType=INTEGER},
+      </if>
+      <if test="type != null">
+        type = #{type,jdbcType=INTEGER},
+      </if>
+      <if test="remark != null">
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        status = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        update_time= #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        del_flag = #{delFlag,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+
     <insert id="saveBatch" parameterType="com.sckw.system.model.KwsEntType">
       insert into kws_ent_type
       <trim prefix="(" suffix=")" suffixOverrides=",">

+ 1 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -184,6 +184,7 @@
     <include refid="Base_Column_List" />
     from kws_enterprise
     where del_flag = 0
+    and approval = 1
     <if test="list != null and list.size() > 0">
       and id in
       <foreach collection="list" item="item" open="(" close=")" separator=",">