Procházet zdrojové kódy

Merge branch 'dev_20260630' into dev_20260630_cxf

chenxiaofei před 1 týdnem
rodič
revize
fd37218a8e
19 změnil soubory, kde provedl 418 přidání a 71 odebrání
  1. 56 53
      sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java
  2. 1 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/EntTypeEnum.java
  3. 13 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/context/LoginUserHolder.java
  4. 4 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/model/LoginUserInfo.java
  5. 4 0
      sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java
  6. 35 0
      sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/model/dto/res/ProxyContractVo.java
  7. 8 2
      sckw-modules-api/sckw-product-api/src/main/java/com/sckw/product/api/dubbo/GoodsInfoService.java
  8. 1 1
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcContractProxyController.java
  9. 22 1
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java
  10. 17 6
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/impl/KwcContractProxyServiceImpl.java
  11. 43 1
      sckw-modules/sckw-contract/src/main/java/com/sckw/contract/task/SynchronousContractStatusTask.java
  12. 18 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/dubbo/GoodsInfoServiceImpl.java
  13. 2 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/KwpGoods.java
  14. 15 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/AddProxyGoods.java
  15. 2 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/ExportStatisticGoodsListParam.java
  16. 1 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/SelectGoodsListParam.java
  17. 5 0
      sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/GoodsList.java
  18. 169 5
      sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java
  19. 2 2
      sckw-modules/sckw-product/src/main/resources/mapper/KwpGoodsMapper.xml

+ 56 - 53
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -71,7 +71,7 @@ public class AuthServiceImpl implements IAuthService {
         /*运营端/企业端登录(PC/APP)*/
         if (loginBase.getSystemType() == SystemTypeEnum.MANAGE.getCode()
                 || loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
-           // KwsUserResDto kwsUserResDto = systemService.queryByAccount(loginBase.getAccount());
+            // KwsUserResDto kwsUserResDto = systemService.queryByAccount(loginBase.getAccount());
             return this.commonAuth(loginBase);
         }
 
@@ -168,7 +168,7 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setClientType(loginBase.getClientType());
         loginRes.setSystemType(loginBase.getSystemType());
         loginRes.setToken(token);
-        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes,loginBase, null,1,loginRes.getEntTypes());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes, loginBase, null, 1, loginRes.getEntTypes());
         if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
             loginRes.setTabBar(tabBar);
         }
@@ -262,7 +262,7 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setDriverId(user.getDriverId());
         loginRes.setRoleName(user.getRoleName());
         loginRes.setRoleList(user.getRoleInfoDto());
-        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes,loginBase, user.getRoleName(),0,loginRes.getEntTypes());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes, loginBase, user.getRoleName(), 0, loginRes.getEntTypes());
         if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
             loginRes.setTabBar(tabBar);
         }
@@ -352,7 +352,7 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setRoleId(user.getRoleId());
         loginRes.setRoleName(user.getRoleName());
         loginRes.setRoleList(user.getRoleInfoDto());
-        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes,loginBase, user.getRoleName(),0,loginRes.getEntTypes());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes, loginBase, user.getRoleName(), 0, loginRes.getEntTypes());
         if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
             loginRes.setTabBar(tabBar);
 
@@ -614,28 +614,28 @@ public class AuthServiceImpl implements IAuthService {
     @Override
     public HttpResult refreshToken(String refreshToken, String clientType, Integer systemType, String deviceId) {
         log.info("刷新token,refreshToken:{},clientType:{},systemType:{},deviceId:{}", refreshToken, clientType, systemType, deviceId);
-        
+
         // 验证refreshToken参数
         HttpResult validateResult = validateRefreshTokenParam(refreshToken);
         if (validateResult != null) {
             return validateResult;
         }
-        
+
         // 解析refreshToken
         Map<String, Object> tokenInfoMap = parseRefreshToken(refreshToken);
         if (tokenInfoMap == null) {
             return HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, "刷新令牌无效!");
         }
-        
+
         // 验证refreshToken是否有效
         HttpResult verifyResult = verifyRefreshToken(tokenInfoMap, refreshToken);
         if (verifyResult != null) {
             return verifyResult;
         }
-        
+
         // 构建LoginBase对象
         LoginBase loginBase = buildLoginBaseFromTokenInfo(tokenInfoMap);
-        
+
         // 根据系统类型处理刷新逻辑
         Integer tokenSystemType = Integer.valueOf(tokenInfoMap.get("systemType").toString());
         if (Objects.equals(tokenSystemType, SystemTypeEnum.DRIVER.getCode())) {
@@ -644,39 +644,39 @@ public class AuthServiceImpl implements IAuthService {
             return handleCommonRefresh(loginBase, tokenInfoMap);
         }
     }
-    
+
     @Override
     public HttpResult switchAccount(String targetRefreshToken, String clientType, Integer systemType, String deviceId) {
         log.info("切换账号,targetRefreshToken:{},clientType:{},systemType:{},deviceId:{}", targetRefreshToken, clientType, systemType, deviceId);
-        
+
         // 验证targetRefreshToken参数
         HttpResult validateResult = validateRefreshTokenParam(targetRefreshToken);
         if (validateResult != null) {
             return validateResult;
         }
-        
+
         // 解析目标账号的refreshToken
         Map<String, Object> targetTokenInfoMap = parseRefreshToken(targetRefreshToken);
         if (targetTokenInfoMap == null) {
             return HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, "目标账号的刷新令牌无效!");
         }
-        
+
         // 验证目标账号的refreshToken是否有效
         HttpResult verifyResult = verifyRefreshToken(targetTokenInfoMap, targetRefreshToken);
         if (verifyResult != null) {
             return HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, "目标账号的刷新令牌已过期或无效!");
         }
-        
+
         // 清除当前登录用户的token缓存(如果存在)
         clearCurrentUserToken(clientType, deviceId);
-        
+
         // 构建LoginBase对象(使用新的deviceId)
         LoginBase loginBase = buildLoginBaseFromTokenInfo(targetTokenInfoMap);
         // 如果传入了新的deviceId,则使用新的deviceId
         if (StringUtils.isNotBlank(deviceId)) {
             loginBase.setDeviceId(deviceId);
         }
-        
+
         // 根据系统类型处理切换逻辑
         Integer targetSystemType = Integer.valueOf(targetTokenInfoMap.get("systemType").toString());
         if (Objects.equals(SystemTypeEnum.DRIVER.getCode(), targetSystemType)) {
@@ -685,7 +685,7 @@ public class AuthServiceImpl implements IAuthService {
             return handleCommonRefresh(loginBase, targetTokenInfoMap);
         }
     }
-    
+
     /**
      * 清除当前登录用户的token缓存
      */
@@ -696,18 +696,18 @@ public class AuthServiceImpl implements IAuthService {
                 // 清除当前用户的token
                 String tokenKey = Global.getFullUserTokenKey(clientType, currentUser.getId());
                 RedissonUtils.delete(tokenKey);
-                
+
                 // 清除当前用户的登录信息缓存
                 String loginKey = Global.getFullUserLoginKey(currentUser.getSystemType(), currentUser.getId());
                 RedissonUtils.delete(loginKey);
-                
+
                 log.info("已清除当前用户token缓存,userId:{}", currentUser.getId());
             }
         } catch (Exception e) {
             log.warn("清除当前用户token缓存失败", e);
         }
     }
-    
+
     /**
      * 验证refreshToken参数
      */
@@ -717,7 +717,7 @@ public class AuthServiceImpl implements IAuthService {
         }
         return null;
     }
-    
+
     /**
      * 解析refreshToken
      */
@@ -731,7 +731,7 @@ public class AuthServiceImpl implements IAuthService {
             return null;
         }
     }
-    
+
     /**
      * 验证refreshToken是否有效
      */
@@ -739,7 +739,7 @@ public class AuthServiceImpl implements IAuthService {
         Long userId = Long.valueOf(tokenInfoMap.get("userId").toString());
         String tokenClientType = tokenInfoMap.get("clientType").toString();
         String tokenDeviceId = tokenInfoMap.get("deviceId") != null ? tokenInfoMap.get("deviceId").toString() : null;
-        
+
         String key = Global.getFullRefreshTokenKey(tokenClientType, userId, tokenDeviceId);
         String storedRefreshToken = RedissonUtils.getString(key);
         if (StringUtils.isBlank(storedRefreshToken) || !storedRefreshToken.equals(refreshToken)) {
@@ -747,7 +747,7 @@ public class AuthServiceImpl implements IAuthService {
         }
         return null;
     }
-    
+
     /**
      * 从token信息构建LoginBase对象
      */
@@ -756,17 +756,17 @@ public class AuthServiceImpl implements IAuthService {
         String tokenClientType = tokenInfoMap.get("clientType").toString();
         Integer tokenSystemType = Integer.valueOf(tokenInfoMap.get("systemType").toString());
         String tokenDeviceId = tokenInfoMap.get("deviceId") != null ? tokenInfoMap.get("deviceId").toString() : null;
-        
+
         LoginBase loginBase = new LoginBase();
         loginBase.setAccount(account);
         loginBase.setClientType(tokenClientType);
         loginBase.setSystemType(tokenSystemType);
         loginBase.setDeviceId(tokenDeviceId);
         loginBase.setRememberMe(true);
-        
+
         return loginBase;
     }
-    
+
     /**
      * 处理司机端token刷新
      */
@@ -774,7 +774,7 @@ public class AuthServiceImpl implements IAuthService {
         String account = tokenInfoMap.get("account").toString();
         String tokenClientType = tokenInfoMap.get("clientType").toString();
         Integer tokenSystemType = Integer.valueOf(tokenInfoMap.get("systemType").toString());
-        
+
         // 查询司机信息
         RDriverDetailVo driver = fleetService.findDriverDetai(account);
         if (driver == null) {
@@ -795,10 +795,10 @@ public class AuthServiceImpl implements IAuthService {
         new AsyncProcess(loginBase, null, driver, enterprise, remoteUserService).run();
 
         // 构建返回结果
-        LoginResVo1 loginRes = buildDriverLoginRes(loginBase,driver, enterprise, tokenClientType, tokenSystemType, newToken, newRefreshToken);
+        LoginResVo1 loginRes = buildDriverLoginRes(loginBase, driver, enterprise, tokenClientType, tokenSystemType, newToken, newRefreshToken);
         return HttpResult.ok(loginRes);
     }
-    
+
     /**
      * 处理运营端/企业端token刷新
      */
@@ -806,7 +806,7 @@ public class AuthServiceImpl implements IAuthService {
         String account = tokenInfoMap.get("account").toString();
         String tokenClientType = tokenInfoMap.get("clientType").toString();
         Integer tokenSystemType = Integer.valueOf(tokenInfoMap.get("systemType").toString());
-        
+
         // 查询用户信息
         KwsUserResDto user = systemService.queryUserDetails(account, tokenSystemType);
         if (user == null) {
@@ -834,15 +834,15 @@ public class AuthServiceImpl implements IAuthService {
         new AsyncProcess(loginBase, user, null, enterprise, remoteUserService).run();
 
         // 构建返回结果
-        LoginResVo1 loginRes = buildCommonLoginRes(loginBase,user, enterprise, tokenClientType, tokenSystemType, newToken, newRefreshToken);
+        LoginResVo1 loginRes = buildCommonLoginRes(loginBase, user, enterprise, tokenClientType, tokenSystemType, newToken, newRefreshToken);
         return HttpResult.ok(loginRes);
     }
-    
+
     /**
      * 构建司机端登录返回结果
      */
-    private LoginResVo1 buildDriverLoginRes(LoginBase loginBase,RDriverDetailVo driver, EntCacheResDto enterprise,
-                                            String tokenClientType, Integer tokenSystemType, 
+    private LoginResVo1 buildDriverLoginRes(LoginBase loginBase, RDriverDetailVo driver, EntCacheResDto enterprise,
+                                            String tokenClientType, Integer tokenSystemType,
                                             String newToken, String newRefreshToken) {
         LoginResVo1 loginRes = new LoginResVo1();
         loginRes.setId(driver.getId());
@@ -859,20 +859,20 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setToken(newToken);
         loginRes.setRefreshToken(newRefreshToken);
         loginRes.setDriverId(driver.getId());
-        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes,loginBase, null,1,loginRes.getEntTypes());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes, loginBase, null, 1, loginRes.getEntTypes());
         if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
             loginRes.setTabBar(tabBar);
         }
         applyAppModulePermissions(loginRes, loginBase, null);
         return loginRes;
     }
-    
+
     /**
      * 构建运营端/企业端登录返回结果
      */
-    private LoginResVo1 buildCommonLoginRes(LoginBase loginBase,KwsUserResDto user, EntCacheResDto enterprise,
-                                           String tokenClientType, Integer tokenSystemType, 
-                                           String newToken, String newRefreshToken) {
+    private LoginResVo1 buildCommonLoginRes(LoginBase loginBase, KwsUserResDto user, EntCacheResDto enterprise,
+                                            String tokenClientType, Integer tokenSystemType,
+                                            String newToken, String newRefreshToken) {
         LoginResVo1 loginRes = new LoginResVo1();
         loginRes.setId(user.getId());
         loginRes.setName(user.getName());
@@ -897,7 +897,7 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setDriverId(user.getDriverId());
         loginRes.setRoleName(user.getRoleName());
         loginRes.setRoleList(user.getRoleInfoDto());
-        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes,loginBase, user.getRoleName(),1,loginRes.getEntTypes());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginRes, loginBase, user.getRoleName(), 1, loginRes.getEntTypes());
         if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
             loginRes.setTabBar(tabBar);
         }
@@ -928,9 +928,9 @@ public class AuthServiceImpl implements IAuthService {
         if (!isAppLogin(loginBase) || StringUtils.isBlank(roleName)) {
             return;
         }
-        boolean isSeller = containsAnyRole(roleName, "销售","供应商管理员");
+        boolean isSeller = containsAnyRole(roleName, "销售", "供应商管理员");
         boolean isFinance = containsAnyRole(roleName, "财务");
-        boolean isPurchase = containsAnyRole(roleName, "采购", "买家","采购商管理员");
+        boolean isPurchase = containsAnyRole(roleName, "采购", "买家", "采购商管理员");
         if (isSeller) {
             loginRes.setShowOrderStatisticsModule(Boolean.TRUE);
             loginRes.setShowSalesStatisticsModule(Boolean.TRUE);
@@ -962,8 +962,8 @@ public class AuthServiceImpl implements IAuthService {
         return false;
     }
 
-    private List<LoginResVo1.TabBarItem> buildAppTabBar(LoginResVo1 loginRes,LoginBase loginBase, String roleName,int flag,  String entTypeNames) {
-       log.info("当前用户角色:{}, 企业类型:{}", roleName, entTypeNames);
+    private List<LoginResVo1.TabBarItem> buildAppTabBar(LoginResVo1 loginRes, LoginBase loginBase, String roleName, int flag, String entTypeNames) {
+        log.info("当前用户角色:{}, 企业类型:{}", roleName, entTypeNames);
         if (!isAppLogin(loginBase)) {
             return List.of();
         }
@@ -978,7 +978,7 @@ public class AuthServiceImpl implements IAuthService {
         boolean isLogistics = StringUtils.isNotBlank(roleName) && roleName.contains("物流");
         boolean isFinance = StringUtils.isNotBlank(roleName) && roleName.contains("财务");
         //企业属性 (1供应商,2采购商,34PL物流,43PL物流)
-        boolean isSupplierAdmin = StringUtils.isNotBlank(roleName) && roleName.contains("系统管理员") && org.apache.commons.lang3.StringUtils.equals(entTypeNames, "1")  ;
+        boolean isSupplierAdmin = StringUtils.isNotBlank(roleName) && roleName.contains("系统管理员") && org.apache.commons.lang3.StringUtils.equals(entTypeNames, "1");
         boolean isLogisticsAdmin = StringUtils.isNotBlank(roleName) && roleName.contains("系统管理员") && org.apache.commons.lang3.StringUtils.equals(entTypeNames, "3");
         boolean isPurchaseAdmin = StringUtils.isNotBlank(roleName) && roleName.contains("系统管理员") && org.apache.commons.lang3.StringUtils.equals(entTypeNames, "2");
 
@@ -991,27 +991,28 @@ public class AuthServiceImpl implements IAuthService {
         if (isBuyer) {
             return buildBuyerTabBar();
         }
-        if (isSeller ||isFinance) {
+        if (isSeller || isFinance) {
             return buildSellerTabBar();
         }
-        if (isDriver){
+        if (isDriver) {
             return buildDefaultDriverTabBar();
         }
-        if (isLogistics){
+        if (isLogistics) {
             return buildLogisticsTabBar();
         }
-        if (isSupplierAdmin){
+        if (isSupplierAdmin) {
             loginRes.setRoleName("供应商管理员");
             return buildSupplierAdminTabBar();
         }
-        if (isLogisticsAdmin){
+        if (isLogisticsAdmin) {
             loginRes.setRoleName("物流商管理员");
             return buildLogisticsAdminTabBar();
         }
-        if (isPurchaseAdmin){
+        if (isPurchaseAdmin) {
             log.info("用户角色包含系统管理员且企业属性为采购商,返回采购管理员TabBar");
             loginRes.setRoleName("采购商管理员");
-            return buildPurchaseAdminTabBar();}
+            return buildPurchaseAdminTabBar();
+        }
         return List.of();
     }
 
@@ -1321,6 +1322,7 @@ public class AuthServiceImpl implements IAuthService {
             loginUserInfo.setEntId(enterprise != null ? enterprise.getId() : null);
             loginUserInfo.setEntName(enterprise != null ? enterprise.getFirmName() : null);
             loginUserInfo.setClientType(loginBase.getClientType());
+            loginUserInfo.setEntTypes(enterprise != null ? enterprise.getEntTypes() : null);
             String key = Global.getFullUserLoginKey(loginUserInfo.getSystemType(), loginUserInfo.getId());
             RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
         }
@@ -1350,6 +1352,7 @@ public class AuthServiceImpl implements IAuthService {
             loginUserInfo.setUseRoleId(user.getRoleId());
             loginUserInfo.setUseEntId(user.getEntId());
             loginUserInfo.setEntName(enterprise != null ? enterprise.getFirmName() : null);
+            loginUserInfo.setEntTypes(enterprise != null ? enterprise.getEntTypes() : null);
 
             //普通用户需要填充数据权限
             if (user.getIsMain().equals(Global.NO)) {

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

@@ -20,6 +20,7 @@ public enum EntTypeEnum {
     //采购商
     PURCHASER(2, "采购商"),
     LOGISTIC(3, "物流属性"),
+    PROXY(4, "代理属性"),
 
     //4PL物流  托运 承运
     LOGISTICS3(3, "4PL物流"),

+ 13 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/context/LoginUserHolder.java

@@ -171,6 +171,19 @@ public class LoginUserHolder {
         return LONGIN_USER_HOLDER.get() == null ? null : LONGIN_USER_HOLDER.get().getUseRoleId();
     }
 
+    public static Integer getEntTypes() {
+        LoginUserInfo loginUserInfo = get();
+        if (Objects.nonNull(loginUserInfo)) {
+            String entTypes = loginUserInfo.getEntTypes();
+            try {
+                return Integer.parseInt(entTypes);
+            } catch (NumberFormatException e) {
+                return null;
+            }
+        }
+        return null;
+    }
+
     /**
      * 用户权限
      */

+ 4 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/model/LoginUserInfo.java

@@ -71,6 +71,10 @@ public class LoginUserInfo {
      * 企业名
      */
     private String entName;
+    /**
+     * 企业类型 3-物流商 4-代理商
+     */
+    private String entTypes;
 
     /**
      * 用户权限

+ 4 - 0
sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/RemoteContractService.java

@@ -174,4 +174,8 @@ public interface RemoteContractService {
      * @param orderAmount 本次下单数量
      */
     void updateTradeContractGoodsPerformed(Long contractId, Long goodsId, BigDecimal orderAmount);
+
+
+    ProxyContractVo queryProxyContract(Long goodsId);
+
 }

+ 35 - 0
sckw-modules-api/sckw-contract-api/src/main/java/com/sckw/contract/api/model/dto/res/ProxyContractVo.java

@@ -0,0 +1,35 @@
+package com.sckw.contract.api.model.dto.res;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 合同公共信息
+ * @date 2023/7/19
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProxyContractVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 2656035411576510101L;
+
+    /**
+     * 合同id
+     */
+    private Long id;
+    private String contractNo;
+
+
+    /**
+     * 合同状态 1待签约 2已签约 3已完结 4已作废
+     */
+    private Integer status;
+
+}

+ 8 - 2
sckw-modules-api/sckw-product-api/src/main/java/com/sckw/product/api/dubbo/GoodsInfoService.java

@@ -41,7 +41,7 @@ public interface GoodsInfoService {
      * @author: yzc
      * @date: 2023-07-20 10:57
      * @Param ids:
-     * @return: java.util.Map<java.lang.Long,com.sckw.product.api.model.KwpGoods>
+     * @return: java.util.Map<java.lang.Long, com.sckw.product.api.model.KwpGoods>
      */
     Map<Long, KwpGoods> getGoodsByIds(List<Long> ids);
 
@@ -76,12 +76,18 @@ public interface GoodsInfoService {
     KwpGoods getGoodsByGoodsName(String goodsName);
 
     List<Long> getGoodsByGoodsNameAndTaxRate(String goodsName, String goodsTaxRate);
-    List<Long> getGoodsByPara(String goodsName,List<String> goodsType, String goodsSpec);
+
+    List<Long> getGoodsByPara(String goodsName, List<String> goodsType, String goodsSpec);
 
     List<KwpGoods> getGoodsByNameTypeDesc(String goodsName, String goodsType, String goodsSpec);
+
     List<KwpGoods> findGoodsByGoodsName(String goodsName);
 
     AddressInfoDetail getGoodsAddress(Long goodsId);
 
     List<KwpGoods> queryGoodsByEntId(Long entId);
+
+    void insertProxyGoods(List<Long> list, Long entId);
+
+    void deleteProxyGoods(List<Long> list);
 }

+ 1 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcContractProxyController.java

@@ -42,7 +42,7 @@ public class KwcContractProxyController {
     }
 
     @PostMapping("finish")
-    @Operation(summary = "审核代理合同")
+    @Operation(summary = "完结代理合同")
     public BaseResult<Boolean> finish(@Valid @RequestBody ProxyContractFinishReq req) {
         return BaseResult.success(kwcContractProxyService.finish(req));
     }

+ 22 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.google.common.collect.Sets;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.req.ContractAuditPara;
@@ -11,6 +12,8 @@ import com.sckw.contract.api.model.dto.res.*;
 import com.sckw.contract.api.model.vo.*;
 import com.sckw.contract.dao.*;
 import com.sckw.contract.model.KwcContractProxy;
+import com.sckw.contract.model.KwcContractProxyGoods;
+import com.sckw.contract.model.KwcContractProxy;
 import com.sckw.contract.model.KwcContractProxyUnit;
 import com.sckw.contract.model.dto.res.QueryContractValidCountResDto;
 import com.sckw.contract.model.entity.*;
@@ -36,6 +39,7 @@ import com.sckw.redis.constant.RedisConstant;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
 import com.sckw.transport.api.model.vo.LogisticContractVo;
+import jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -79,7 +83,10 @@ public class RemoteContractServiceImpl implements RemoteContractService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 8000)
     private TransportRemoteService transportRemoteService;
     private final RedisTemplate<String, Object> redisTemplate;
-
+    @Resource
+    private KwcContractProxyMapper kwcContractProxyMapper;
+    @Resource
+    private KwcContractProxyGoodsMapper kwcContractProxyGoodsMapper;
     private final KwcContractTradeRepository kwcContractTradeRepository;
     private final KwcContractLogisticsRepository contractLogisticsRepository;
     private final KwcContractTradeUnitRepository kwcContractTradeUnitRepository;
@@ -786,4 +793,18 @@ public class RemoteContractServiceImpl implements RemoteContractService {
         kwcContractTradeGoodsMapper.updateById(tradeGoods);
     }
 
+    @Override
+    public ProxyContractVo queryProxyContract(Long goodsId) {
+        KwcContractProxyGoods kwcContractProxyGoods = kwcContractProxyGoodsMapper.selectOne(Wrappers.lambdaQuery(KwcContractProxyGoods.class)
+                .eq(KwcContractProxyGoods::getGoodsId, goodsId)
+                .eq(KwcContractProxyGoods::getDelFlag, 0));
+        if (Objects.nonNull(kwcContractProxyGoods)) {
+            KwcContractProxy kwcContractProxy = kwcContractProxyMapper.selectById(kwcContractProxyGoods.getContractId());
+            if (Objects.nonNull(kwcContractProxy)) {
+                return new ProxyContractVo(kwcContractProxy.getId(), kwcContractProxy.getContractNo(), kwcContractProxy.getStatus());
+            }
+        }
+        return null;
+    }
+
 }

+ 17 - 6
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/impl/KwcContractProxyServiceImpl.java

@@ -18,6 +18,7 @@ import com.sckw.contract.service.KwcContractProxyService;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.result.PageDataResult;
+import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import lombok.RequiredArgsConstructor;
@@ -47,6 +48,8 @@ public class KwcContractProxyServiceImpl implements KwcContractProxyService {
     private final KwcContractProxyGoodsRepository proxyGoodsRepository;
     @DubboReference(version = "1.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private GoodsInfoService goodsInfoService;
 
     @Override
     public PageDataResult<ProxyContractListResp> queryListByPage(ProxyContractPageReq req) {
@@ -214,6 +217,12 @@ public class KwcContractProxyServiceImpl implements KwcContractProxyService {
         proxy.setUpdateBy(LoginUserHolder.getUserId());
         proxy.setUpdateTime(LocalDateTime.now());
         proxyRepository.saveOrUpdateProxy(proxy);
+        //更新商品的代理企业
+        if (Objects.equals(auditStatus, 1)) {
+            List<KwcContractProxyGoods> kwcContractProxyGoods = proxyGoodsRepository.queryByContractId(proxy.getId());
+            List<Long> list = kwcContractProxyGoods.stream().map(KwcContractProxyGoods::getGoodsId).toList();
+            goodsInfoService.insertProxyGoods(list,proxy.getProxyId());
+        }
         return Boolean.TRUE;
     }
 
@@ -355,12 +364,14 @@ public class KwcContractProxyServiceImpl implements KwcContractProxyService {
         if (proxy == null) {
             throw new BusinessException("代理合同不存在");
         }
-
-        proxy.setStatus(ProxyStatusEnum.SUCCESS.getValue());
-        proxy.setUpdateBy(LoginUserHolder.getUserId());
-        proxy.setUpdateTime(LocalDateTime.now());
-        proxyRepository.updateById(proxy);
-        return Boolean.TRUE;
+        if (Objects.equals(proxy.getStatus(), ProxyStatusEnum.SIGN.getValue())) {
+            proxy.setStatus(ProxyStatusEnum.SUCCESS.getValue());
+            proxy.setUpdateBy(LoginUserHolder.getUserId());
+            proxy.setUpdateTime(LocalDateTime.now());
+            proxyRepository.updateById(proxy);
+            return Boolean.TRUE;
+        }
+        return false;
     }
 
 }

+ 43 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/task/SynchronousContractStatusTask.java

@@ -1,24 +1,35 @@
 package com.sckw.contract.task;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.sckw.contract.dao.KwcContractLogisticsMapper;
+import com.sckw.contract.dao.KwcContractProxyGoodsMapper;
+import com.sckw.contract.dao.KwcContractProxyMapper;
 import com.sckw.contract.dao.KwcContractTradeMapper;
+import com.sckw.contract.model.KwcContractProxy;
+import com.sckw.contract.model.KwcContractProxyGoods;
 import com.sckw.contract.model.entity.KwcContractLogistics;
 import com.sckw.contract.model.entity.KwcContractTrade;
+import com.sckw.contract.model.enums.ProxyStatusEnum;
 import com.sckw.contract.model.vo.req.ESignCallBackReqVo;
 import com.sckw.contract.service.CommonBusinessService;
 import com.sckw.core.model.enums.ContractStatusEnum;
 import com.sckw.core.utils.CollectionUtils;
+import com.sckw.product.api.dubbo.GoodsInfoService;
+import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,9 +52,14 @@ public class SynchronousContractStatusTask {
 
     @Autowired
     private CommonBusinessService commonBusinessService;
-
+    @Resource
+    private KwcContractProxyMapper kwcContractProxyMapper;
+    @Resource
+    private KwcContractProxyGoodsMapper kwcContractProxyGoodsMapper;
     @Value("${eSignDetail}")
     private String eSignDetail;
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    private GoodsInfoService goodsInfoService;
 
     @Scheduled(cron = "0/10 * * * * ?")
     private void process() {
@@ -110,4 +126,30 @@ public class SynchronousContractStatusTask {
             }
         }
     }
+
+    //12小时一次
+    @Scheduled(cron = "0 0 0/12 * * ? ")
+    public void proxyTask() {
+        LocalDateTime now = LocalDateTime.now();
+        LambdaQueryWrapper<KwcContractProxy> wrapper = Wrappers.lambdaQuery(KwcContractProxy.class);
+        wrapper.lt(KwcContractProxy::getEndTime, now);
+        wrapper.eq(KwcContractProxy::getStatus, ProxyStatusEnum.ISSUE.getValue());
+        List<KwcContractProxy> kwcContractProxies = kwcContractProxyMapper.selectList(wrapper);
+        if (CollUtil.isNotEmpty(kwcContractProxies)) {
+            for (KwcContractProxy kwcContractProxy : kwcContractProxies) {
+                Long id = kwcContractProxy.getId();
+                KwcContractProxy kwcContractProxy1 = new KwcContractProxy();
+                kwcContractProxy1.setId(id);
+                kwcContractProxy1.setStatus(ProxyStatusEnum.SUCCESS.getValue());
+                kwcContractProxy1.setUpdateTime(LocalDateTime.now());
+                kwcContractProxyMapper.updateById(kwcContractProxy1);
+
+                List<KwcContractProxyGoods> kwcContractProxyGoods = kwcContractProxyGoodsMapper.selectList(Wrappers.lambdaQuery(KwcContractProxyGoods.class).eq(KwcContractProxyGoods::getContractId, id).eq(KwcContractProxyGoods::getDelFlag, 0));
+                List<Long> list = kwcContractProxyGoods.stream().map(KwcContractProxyGoods::getGoodsId).toList();
+                if (CollUtil.isNotEmpty(list)) {
+                    goodsInfoService.deleteProxyGoods(list);
+                }
+            }
+        }
+    }
 }

+ 18 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/dubbo/GoodsInfoServiceImpl.java

@@ -13,6 +13,7 @@ import com.sckw.product.api.model.GoodsDetails;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.product.dao.KwpGoodsAddressMapper;
 import com.sckw.product.model.KwpGoodsAddress;
+import com.sckw.product.model.vo.req.AddProxyGoods;
 import com.sckw.product.repository.KwpGoodsRepository;
 import com.sckw.product.service.KwpGoodsService;
 import com.sckw.redis.constant.RedisConstant;
@@ -202,4 +203,21 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
                 .map(GoodsInfoServiceImpl::getKwpGoods)
                 .collect(Collectors.toList());
     }
+
+    @Override
+    public void insertProxyGoods(List<Long> list, Long entId) {
+        for (Long l : list) {
+            AddProxyGoods addProxyGoods = new AddProxyGoods();
+            addProxyGoods.setGoodsId(l);
+            addProxyGoods.setProxyEntId(entId);
+            kwpGoodsService.addGoods(addProxyGoods);
+
+        }
+
+    }
+
+    @Override
+    public void deleteProxyGoods(List<Long> list) {
+        kwpGoodsService.deleteGoods(list);
+    }
 }

+ 2 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/KwpGoods.java

@@ -37,6 +37,7 @@ public class KwpGoods extends BaseModel implements Serializable {
      * 供应单位
      */
     private Long supplyEntId;
+    private Long agentEntId;
 
     /**
      * 商品编号
@@ -113,6 +114,7 @@ public class KwpGoods extends BaseModel implements Serializable {
      */
     private String thumb;
 
+    private Integer isAgent;
 
     /**
      * 是否删除

+ 15 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/AddProxyGoods.java

@@ -0,0 +1,15 @@
+package com.sckw.product.model.vo.req;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+
+@Getter
+@Setter
+@ToString
+public class AddProxyGoods {
+   private Long goodsId;
+   private Long proxyEntId;
+
+}

+ 2 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/ExportStatisticGoodsListParam.java

@@ -23,5 +23,7 @@ public class ExportStatisticGoodsListParam extends StatisticGoodsListParam {
      * 状态
      */
     private Integer status;
+    private Integer isAgent;
+
 
 }

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

@@ -29,5 +29,6 @@ public class SelectGoodsListParam extends StatisticGoodsListParam {
      */
     @Schema(description = "状态")
     private Integer status;
+    private Integer isAgent;
 
 }

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

@@ -132,6 +132,11 @@ public class GoodsList {
      */
     @Schema(description = "供应企业")
     private String supplyEnt;
+    /**
+     * 代理企业
+     */
+    @Schema(description = "代理企业")
+    private String agentEnt;
 
     /**
      * 创建人

+ 169 - 5
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.sckw.contract.api.RemoteContractService;
+import com.sckw.contract.api.model.dto.res.ProxyContractVo;
 import com.sckw.contract.api.model.vo.TradeContractGoodsDto;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
@@ -161,6 +162,128 @@ public class KwpGoodsService {
         addGoodsOtherInfo(goods.getId(), param);
     }
 
+    /**
+     * @desc: 添加代理商品
+     * @return: void
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void addGoods(AddProxyGoods param) {
+        Long goodsId = param.getGoodsId();
+        Long proxyEntId = param.getProxyEntId();
+        if (Objects.isNull(goodsId) || Objects.isNull(proxyEntId)) {
+            throw new BusinessException("参数异常");
+        }
+
+        KwpGoods goods = kwpGoodsMapper.selectById(goodsId);
+        if (Objects.isNull(goods) || !Objects.equals(goods.getDelFlag(), Global.NO)) {
+            throw new BusinessException("当前商品不存在!");
+        }
+
+        if (!Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode())) {
+            throw new BusinessException("仅支持对已上架商品添加代理商品");
+        }
+//        if (Boolean.TRUE.equals(nameDuplicationJudgment(goods.getName(), proxyEntId, null))) {
+//            throw new BusinessException("已存在相同商品名称!");
+//        }
+
+        Date now = new Date();
+        KwpGoods proxyGoods = BeanUtils.copyProperties(goods, KwpGoods.class);
+        proxyGoods.setId(null);
+        proxyGoods.setAgentEntId(proxyEntId);
+        proxyGoods.setIsAgent(Global.YES);
+        proxyGoods.setStatus(GoodsStatusEnum.SAVED.getCode());
+        proxyGoods.setAddedTime(null);
+        proxyGoods.setShelfTime(null);
+        proxyGoods.setCreateBy(LoginUserHolder.getUserId());
+        proxyGoods.setCreateTime(now);
+        proxyGoods.setUpdateBy(LoginUserHolder.getUserId());
+        proxyGoods.setUpdateTime(now);
+        proxyGoods.setDelFlag(Global.NO);
+        kwpGoodsMapper.insert(proxyGoods);
+
+        Long newGoodsId = proxyGoods.getId();
+
+        KwpGoodsAddress address = kwpGoodsAddressService.getByGoodsId(goodsId);
+        if (Objects.nonNull(address)) {
+            KwpGoodsAddress newAddress = BeanUtils.copyProperties(address, KwpGoodsAddress.class);
+            newAddress.setId(null);
+            newAddress.setGoodsId(newGoodsId);
+            newAddress.setCreateBy(LoginUserHolder.getUserId());
+            newAddress.setCreateTime(now);
+            newAddress.setUpdateBy(LoginUserHolder.getUserId());
+            newAddress.setUpdateTime(now);
+            newAddress.setDelFlag(Global.NO);
+            kwpGoodsAddressService.insert(newAddress);
+        }
+
+        List<KwpGoodsAttribute> attributes = kwpGoodsAttributeService.getByGoodsId(goodsId);
+        if (CollectionUtils.isNotEmpty(attributes)) {
+            List<KwpGoodsAttribute> newAttributes = new ArrayList<>(attributes.size());
+            for (KwpGoodsAttribute e : attributes) {
+                KwpGoodsAttribute attribute = BeanUtils.copyProperties(e, KwpGoodsAttribute.class);
+                attribute.setId(null);
+                attribute.setGoodsId(newGoodsId);
+                attribute.setCreateBy(LoginUserHolder.getUserId());
+                attribute.setCreateTime(now);
+                attribute.setUpdateBy(LoginUserHolder.getUserId());
+                attribute.setUpdateTime(now);
+                attribute.setDelFlag(Global.NO);
+                newAttributes.add(attribute);
+            }
+            kwpGoodsAttributeService.insertBatch(newAttributes);
+        }
+
+        List<KwpGoodsImage> images = kwpGoodsImageService.getByGoodsId(goodsId);
+        if (CollectionUtils.isNotEmpty(images)) {
+            List<KwpGoodsImage> newImages = new ArrayList<>(images.size());
+            for (KwpGoodsImage e : images) {
+                KwpGoodsImage image = BeanUtils.copyProperties(e, KwpGoodsImage.class);
+                image.setId(null);
+                image.setGoodsId(newGoodsId);
+                image.setImage(FileUtils.replaceAll(e.getImage()));
+                image.setCreateBy(LoginUserHolder.getUserId());
+                image.setCreateTime(now);
+                image.setUpdateBy(LoginUserHolder.getUserId());
+                image.setUpdateTime(now);
+                image.setDelFlag(Global.NO);
+                newImages.add(image);
+            }
+            kwpGoodsImageService.insertBatch(newImages);
+        }
+
+        List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(goodsId);
+        if (CollectionUtils.isNotEmpty(priceRanges)) {
+            List<KwpGoodsPriceRange> newPriceRanges = new ArrayList<>(priceRanges.size());
+            for (KwpGoodsPriceRange e : priceRanges) {
+                KwpGoodsPriceRange priceRange = BeanUtils.copyProperties(e, KwpGoodsPriceRange.class);
+                priceRange.setId(null);
+                priceRange.setGoodsId(newGoodsId);
+                priceRange.setCreateBy(LoginUserHolder.getUserId());
+                priceRange.setCreateTime(now);
+                priceRange.setUpdateBy(LoginUserHolder.getUserId());
+                priceRange.setUpdateTime(now);
+                priceRange.setDelFlag(Global.NO);
+                newPriceRanges.add(priceRange);
+            }
+            kwpGoodsPriceRangeService.insertBatch(newPriceRanges);
+        }
+
+        List<GoodsUnitDetail> unitDetails = kwpGoodsUnitService.findGoodsUnit(goodsId);
+        if (CollectionUtils.isNotEmpty(unitDetails)) {
+            List<KwpGoodsUnit> units = new ArrayList<>(unitDetails.size());
+            for (GoodsUnitDetail e : unitDetails) {
+                KwpGoodsUnit unit = new KwpGoodsUnit();
+                unit.setGoodsId(newGoodsId);
+                unit.setFromUnit(e.getFromUnit());
+                unit.setToUnit(e.getToUnit());
+                unit.setConversionValue(e.getConversionValue());
+                unit.setDelFlag(Global.NO);
+                units.add(unit);
+            }
+            kwpGoodsUnitService.insertBatch(units);
+        }
+    }
+
     /**
      * @desc: 添加商品其他信息
      * @author: yzc
@@ -690,6 +813,16 @@ public class KwpGoodsService {
             List<Long> ids = StringUtils.splitStrToList(params.getIds(), ",", Long.class);
             wrapper.in(KwpGoods::getId, ids);
         } else {
+            wrapper.eq(Objects.nonNull(params.getIsAgent()), KwpGoods::getIsAgent, params.getIsAgent());
+            //代理商看自己。供应商可看代理商商品
+            Long entId = LoginUserHolder.getEntId();
+            Integer entTypes = LoginUserHolder.getEntTypes();
+            if (Objects.equals(entTypes, EntTypeEnum.PROXY.getCode())) {
+                wrapper.eq(KwpGoods::getAgentEntId, entId);
+            }
+            if (Objects.equals(entTypes, EntTypeEnum.SUPPLIER.getCode())) {
+                wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId());
+            }
             if (Objects.nonNull(params.getStartCreateTime())) {
                 wrapper.ge(KwpGoods::getCreateTime, params.getStartCreateTime());
             }
@@ -710,7 +843,7 @@ public class KwpGoodsService {
                 wrapper.and(e -> e.like(KwpGoods::getName, keywords.trim()).or().like(KwpGoods::getAddressName, keywords.trim()));
             }
         }
-        wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getCreateTime);
+        wrapper.eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getCreateTime);
         return wrapper;
     }
 
@@ -725,12 +858,16 @@ public class KwpGoodsService {
         List<GoodsList> result = new ArrayList<>(list.size());
         List<Long> goodsIds = new ArrayList<>(list.size());
         List<Long> supplyEntIds = new ArrayList<>(list.size());
+        List<Long> proxyEntIds = 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.getAgentEntId())) {
+                proxyEntIds.add(e.getAgentEntId());
+            }
             if (Objects.nonNull(e.getManager())) {
                 userIds.add(e.getManager());
             }
@@ -748,6 +885,10 @@ public class KwpGoodsService {
         if (CollectionUtils.isNotEmpty(supplyEntIds)) {
             entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         }
+        List<EntCacheResDto> entList2 = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(proxyEntIds)) {
+            entList2 = remoteSystemService.queryEntCacheByIds(proxyEntIds);
+        }
         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.GOODS_SPEC.getType()));
         Map<String, String> productNameMap, unitMap, goodsStatusMap, goodsSpecMap;
         if (CollectionUtils.isNotEmpty(dict)) {
@@ -762,12 +903,13 @@ public class KwpGoodsService {
             goodsSpecMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+        Map<Long, String> entMap2 = entList2.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 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).setSpecLabel(CollectionUtils.isNotEmpty(goodsSpecMap) ? goodsSpecMap.get(goodsList.getSpec()) : null).setSupplyEnt(entMap.get(e.getSupplyEntId())).setThumb(FileUtils.splice(e.getThumb())).setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
-
+            goodsList.setAgentEnt(entMap2.get(e.getAgentEntId()));
             List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
             BigDecimal price = Optional.ofNullable(priceRanges).filter(priceRangeList -> !priceRangeList.isEmpty()).map(priceRangeList -> priceRangeList.get(0)).map(KwpGoodsPriceRange::getPrice).orElse(null);
             goodsList.setPrice(price);
@@ -812,15 +954,25 @@ public class KwpGoodsService {
                 if (StringUtils.isNotBlank(msg)) {
                     throw new CustomPromptException(HttpStatus.GOODS_PUT_ON_SHELVES_FAIL_CODE, msg);
                 }
+                //判断代理合同是否签约
+                if (Objects.equals(goods.getIsAgent(), 1)) {
+                    ProxyContractVo proxyContractVo = remoteContractService.queryProxyContract(goods.getId());
+                    if (Objects.isNull(proxyContractVo)) {
+                        throw new BusinessException("代理合同不存在");
+                    }
+                    if (!Objects.equals(proxyContractVo.getStatus(), 2)) {
+                        throw new BusinessException(String.format("商品对应代理合同【%s】暂未签约,不能上架", proxyContractVo.getContractNo()));
+                    }
+                }
             }
 
             LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
             updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).set(KwpGoods::getAddedTime, new Date()).eq(KwpGoods::getId, goods.getId());
             kwpGoodsMapper.update(null, updateWrapper);
         }
-        goodsList.forEach(e -> {
-            sendMsg(MessageEnum.PRODUCT_ON_SHELVES, e);
-        });
+//        goodsList.forEach(e -> {
+//            sendMsg(MessageEnum.PRODUCT_ON_SHELVES, e);
+//        });
     }
 
     /**
@@ -1514,4 +1666,16 @@ public class KwpGoodsService {
 
         return detail;
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteGoods(List<Long> list) {
+        kwpGoodsMapper.deleteBatchIds(list);
+
+        kwpGoodsAddressService.delByGoodsIds(list);
+        kwpGoodsAttributeService.delByGoodsIds(list);
+
+        kwpGoodsImageService.delByGoodsIds(list);
+        kwpGoodsPriceRangeService.delByGoodsIds(list);
+        kwpGoodsUnitService.delByGoodsIds(list);
+    }
 }

+ 2 - 2
sckw-modules/sckw-product/src/main/resources/mapper/KwpGoodsMapper.xml

@@ -5,7 +5,7 @@
 
     <select id="getGoodsLists" resultType="com.sckw.product.model.KwpGoods">
         select
-        id, ent_id,supply_ent_id,code,name, type_id, amount, unit, spec, tax_rate, trading, advance_price, manager,
+        id, ent_id,supply_ent_id,agent_ent_id,code,name, type_id, amount, unit, spec, tax_rate, trading, advance_price, manager,is_agent,
         performed_amount,thumb,added_time,shelf_time,remark,status, create_by, create_time, update_by, update_time,del_flag
         from kwp_goods
         <where>
@@ -43,4 +43,4 @@
 
 
     </select>
-</mapper>
+</mapper>