Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

zoujiajian 2 éve
szülő
commit
d3d420b21a

+ 0 - 1
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonSkuFrontView.java

@@ -106,6 +106,5 @@ public class GoodsDonSkuFrontView {
 	/**
 	 * 特定购买平台
 	 */
-	@JsonIgnore
 	private String specificGoodsIds;
 }

+ 40 - 2
netflix-service/src/main/java/com/cyksj/service/distribute/impl/DistributeServiceImpl.java

@@ -13,6 +13,8 @@ import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeSharedMapper;
 import com.cyksj.mapper.manage.distribute.UserPlatDistributeRateMapper;
 import com.cyksj.mapper.market.task.TaskTypeMapper;
+import com.cyksj.mapper.shop.YhShopMapper;
+import com.cyksj.mapper.shop.YhShopUserPlatDistributeRateMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.UserDistributeReq;
 import com.cyksj.redis.RedisService;
@@ -56,6 +58,10 @@ public class DistributeServiceImpl implements DistributeService {
 
 	private final CouponDistributePopularizeMapper couponDistributePopularizeMapper;
 
+	private final YhShopUserPlatDistributeRateMapper yhShopUserPlatDistributeRateMapper;
+
+	private final YhShopMapper yhShopMapper;
+
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	public void insertDistribute(UserDistributeReq userDistributeReq) {
@@ -99,7 +105,11 @@ public class DistributeServiceImpl implements DistributeService {
 		if (userDistributeReq.getId() == null || userDistributeReq.getId() < 1) {
 			throw BusinessRuntimeException.getInstance("id错误");
 		}
-		UserDistribute userDistribute = new UserDistribute();
+		Long id = userDistributeReq.getId();
+		UserDistribute userDistribute = userDistributeMapper.selectById(id);
+		if (userDistribute == null || !userDistribute.getDeleted()) {
+			return;
+		}
 		userDistribute.setId(userDistributeReq.getId());
 		userDistribute.setRemark(userDistributeReq.getRemark());
 		Long businessId = userDistributeReq.getBusinessId();
@@ -112,6 +122,9 @@ public class DistributeServiceImpl implements DistributeService {
 			userDistribute.setBusinessId(businessId);
 		}
 		userDistributeMapper.updateById(userDistribute);
+		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getUserId, userDistribute.getUserId())
+				.eq(YhShop::getVerifyStatus, YhShop.Status.success).last("limit 1"));
 		for (UserPlatDistributeRate rate : userDistributeReq.getRates()) {
 			if (rate.getRate() < 0 || rate.getRate() > 100) {
 				throw new BusinessRuntimeException("比例错误");
@@ -133,10 +146,35 @@ public class DistributeServiceImpl implements DistributeService {
 				try {
 					userPlatDistributeRateMapper.insert(rate);
 				} catch (DuplicateKeyException e) {
-
+					userPlatDistributeRateMapper.update(null, Wrappers.lambdaUpdate(UserPlatDistributeRate.class)
+							.eq(UserPlatDistributeRate::getDistributeId, userDistribute.getId())
+							.eq(UserPlatDistributeRate::getGoodsId, rate.getGoodsId())
+							.set(UserPlatDistributeRate::getRate, rate.getRate()));
+				}
+				if (yhShop != null) {
+					try {
+						YhShopUserPlatDistributeRate yhShopUserPlatDistributeRate = new YhShopUserPlatDistributeRate();
+						yhShopUserPlatDistributeRate.setRate(rate.getRate());
+						yhShopUserPlatDistributeRate.setGoodsId(rate.getGoodsId());
+						yhShopUserPlatDistributeRate.setUserId(userDistribute.getUserId());
+						yhShopUserPlatDistributeRateMapper.insert(yhShopUserPlatDistributeRate);
+					} catch (DuplicateKeyException e) {
+						//同步店铺分销比例
+						yhShopUserPlatDistributeRateMapper.update(null, Wrappers.lambdaUpdate(YhShopUserPlatDistributeRate.class)
+								.eq(YhShopUserPlatDistributeRate::getUserId, userDistribute.getUserId())
+								.eq(YhShopUserPlatDistributeRate::getGoodsId, rate.getGoodsId())
+								.set(YhShopUserPlatDistributeRate::getRate, rate.getRate()));
+					}
 				}
 			} else {
 				userPlatDistributeRateMapper.updateById(rate);
+				if (yhShop != null) {
+					//同步店铺分销比例
+					yhShopUserPlatDistributeRateMapper.update(null, Wrappers.lambdaUpdate(YhShopUserPlatDistributeRate.class)
+							.eq(YhShopUserPlatDistributeRate::getUserId, userDistribute.getUserId())
+							.eq(YhShopUserPlatDistributeRate::getGoodsId, rate.getGoodsId())
+							.set(YhShopUserPlatDistributeRate::getRate, rate.getRate()));
+				}
 			}
 		}
 	}

+ 0 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1924,7 +1924,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		relation.setStatus(GroupsRelation.Status.locking);
 		relation.setYhsId(yhsId);
 		groupsRelationMapper.updateById(relation);
-		redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relation.getId());
 		return relation;
 	}
 

+ 52 - 0
netflix-web/src/main/java/com/cyksj/web/controller/goods/GoodsDonController.java

@@ -683,6 +683,55 @@ public class GoodsDonController {
 	    }
     }
 
+	/**
+	 * 设置平台 特定价格
+	 */
+	public void setGcSpecificPrice(GoodsFrontListCategoryView data, Long fUid) {
+		if (fUid != null) {
+			if (data.getIsSp()) {
+				//查找所有特定规格最小价格 满足条件
+				String specificGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "specific:" + data.getId();
+				Object speciObj = redisService.get(specificGoodsKey);
+				List<GoodsDonSku> specificSkus = null;
+				if (speciObj != null) {
+					specificSkus = Jsons.parseList(speciObj, GoodsDonSku.class);
+				} else {
+					specificSkus = goodsDonSkuMapper.selectList(
+							Wrappers.lambdaQuery(GoodsDonSku.class)
+									.eq(GoodsDonSku::getGoodsId, data.getId())
+									.eq(GoodsDonSku::getStatus, true)
+									.gt(GoodsDonSku::getSpecificPrice, 0));
+					redisService.setNx(specificGoodsKey, specificSkus, RedisService.key.YH_HOME_PAGHE_CACHE.getTimeout());
+				}
+				specificSkus.forEach(specificSku -> {
+					String specificGoodsIdsStr = specificSku.getSpecificGoodsIds();
+					if (isPaySpecificGoodsIds(specificGoodsIdsStr, fUid)) {
+						BigDecimal specificPrice = data.getSpecificPrice();
+						BigDecimal skuSpecificPrice = specificSku.getSpecificPrice();
+						Long specificSkuId = specificSku.getId();
+						if (specificPrice == null) {
+							data.setSpecificPrice(skuSpecificPrice);
+							data.setSpecificSkuId(specificSkuId);
+						} else if (specificPrice.compareTo(skuSpecificPrice) > 0) {
+							data.setSpecificPrice(skuSpecificPrice);
+							data.setSpecificSkuId(specificSkuId);
+						}
+					}
+				});
+				List<GoodsDonSkuFrontView> skuList = data.getSkuList();
+				if (CollUtil.isNotEmpty(skuList)) {
+					skuList.forEach(sku -> {
+						//设置特定价格
+						if (!isPaySpecificGoodsIds(sku.getSpecificGoodsIds(), fUid)) {
+							sku.setSpecificGoodsIds(null);
+							sku.setSpecificPrice(null);
+						}
+					});
+				}
+			}
+		}
+	}
+
 	/**
 	 * 获取特定规格
 	 */
@@ -799,6 +848,7 @@ public class GoodsDonController {
 			Result<List<YhShopGoodsFrontCategoryView>> shopGoods = getShopCategoryGoods(yhShopFrontService.getYhsIdByCustomId(customId), cgy);
 			return shopGoods;
 		}
+		Long fUid = StpUserUtil.getUserIdAfterLogin();
 		String categoryGoodsKey = RedisService.key.YH_HOME_PAGHE_CACHE.getEnvName() + "category:goods";
 		if (cgy != null) {
 			categoryGoodsKey += ":" + cgy;
@@ -821,6 +871,8 @@ public class GoodsDonController {
 					.eq(OrderDon::getGoodsId, data.getId()).notIn(OrderDon::getStatus, Constant.noOrderStatus));
 			data.setSold(sold + data.getSold());
 			data.setNotifyMsg(getPayMsgTime(data.getId(), now, 1, null));
+			//设置特定价格
+			setGcSpecificPrice(data, fUid);
 		});
 		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsFrontListViews);
 	}