zoujiajian 2 år sedan
förälder
incheckning
b7e39b30ed

+ 14 - 8
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsYhShopCommonServiceImpl.java

@@ -159,17 +159,23 @@ public class CmsYhShopCommonServiceImpl implements CmsYhShopCommonService {
 		Long id = yhShop.getId();
 		YhShop dbShop = yhShopMapper.selectById(id);
 		Assert.notNull(dbShop, "请检查店铺是否存在");
-		if (businessId != null) {
+		if (businessId == null && dbShop.getBusinessId() == 0) {
+			return;
+		}
+		if (businessId == null && dbShop.getBusinessId() != 0) {
+			yhShopMapper.update(null, Wrappers.lambdaUpdate(YhShop.class)
+					.set(YhShop::getBusinessId, 0)
+					.set(YhShop::getBusinessBindTime, null)
+					.eq(YhShop::getId, id));
+		}
+		if (!dbShop.getBusinessId().equals(businessId)) {
 			if (!userBusinessRateService.isBusiness(businessId)) {
-				throw BusinessRuntimeException.getInstance("请选择对应的商务人员");
+				throw BusinessRuntimeException.getInstance("请选择正确的商务人员");
 			}
+			dbShop.setBusinessId(businessId);
+			dbShop.setBusinessBindTime(DateTime.now());
+			yhShopMapper.updateById(dbShop);
 		}
-		yhShopMapper.update(null, Wrappers.lambdaUpdate(YhShop.class)
-				.set(businessId == null, YhShop::getBusinessId, 0)
-				.set(businessId == null, YhShop::getBusinessBindTime, null)
-				.set(businessId != null, YhShop::getBusinessId, businessId)
-				.set(businessId != null, YhShop::getBusinessBindTime, DateTime.now())
-				.eq(YhShop::getId, id));
 	}
 
 	@Override

+ 16 - 7
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/CmsYhShopGoodsController.java

@@ -236,13 +236,11 @@ public class CmsYhShopGoodsController {
     @PutMapping("/set/rate")
     public Result<String> setYhShopGoodsRate(@RequestBody @Validated YhShopUserPlatDistributeRateReq req) {
         Long businessId = req.getBusinessId();
-        if (businessId != null) {
-            YhShop yhShop = new YhShop();
-            yhShop.setId(req.getId());
-            yhShop.setBusinessId(businessId);
-            yhShop.setRemark(req.getRemark());
-            cmsYhShopCommonService.setYhShopBusiness(yhShop);
-        }
+        YhShop yhShop = new YhShop();
+        yhShop.setId(req.getId());
+        yhShop.setBusinessId(businessId);
+        yhShop.setRemark(req.getRemark());
+        cmsYhShopCommonService.setYhShopBusiness(yhShop);
         List<YhShopUserPlatDistributeRate> yhShopUserPlatDistributeRates = req.getRates();
         if (CollUtil.isEmpty(yhShopUserPlatDistributeRates)) {
             throw BusinessRuntimeException.getInstance("请选择店铺用户对应平台比例");
@@ -251,6 +249,17 @@ public class CmsYhShopGoodsController {
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
 
+    /**
+     * 店铺提成比例详情
+     */
+    @GetMapping("/get/detail/{userId}")
+    public Result<List<YhShopUserPlatDistributeRate>> getDetailById(@PathVariable Long userId) {
+        return GatewayResponse.SUCCESS.newBuilder().toResult(beanSearcher.searchAll(YhShopUserPlatDistributeRate.class, MapUtils.builder()
+                .field(YhShopUserPlatDistributeRate::getUserId, userId).op(Operator.Equal)
+                .orderBy(YhShopUserPlatDistributeRate::getGoodsId).asc()
+                .build()));
+    }
+
     /**
      * 店铺注册人数列表
      */