zoujiajian пре 2 година
родитељ
комит
6239e00159

+ 6 - 1
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java

@@ -18,7 +18,7 @@ import java.util.List;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don",
-		where = ":condition:")
+        where = ":condition:")
 public class GoodsDon extends BaseEntity {
 
 
@@ -188,6 +188,11 @@ public class GoodsDon extends BaseEntity {
      */
     private Boolean isSp;
 
+    /**
+     * 是否参与分销 默认参与
+     */
+    private Boolean isDistribute;
+
     @AllArgsConstructor
     @Getter
     public enum SpecialType {

+ 21 - 39
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -273,6 +273,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		if (goodsDon == null || !goodsDon.getStatus()) {
 			throw new BusinessRuntimeException("商品已下架");
 		}
+		//是否参与店铺分销
+		if (yhsId > 0 && !goodsDon.getIsDistribute()) {
+			throw new BusinessRuntimeException("系统异常,请刷新页面重试");
+		}
 		if (isGiftCardPay.get() && (goodsDon.getSpecialType() == null || goodsDon.getSpecialType() != GoodsDon.SpecialType.giftCard)) {
 			throw BusinessRuntimeException.getInstance("非礼品卡类型商品");
 		}
@@ -755,7 +759,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						if (groupsRelation.getUserId() != 0) {
 							User user = userMapper.selectById(orderDon.getUserId());
 							if (user != null) {
-								checkIsSameUser(groupsRelation.getUserId(), orderDon.getUserId(), user.getOpenId(), user.getLoginPhone());
+								checkIsSameUser(groupsRelation.getUserId(), user);
 							}
 						}
 						//throw new BusinessRuntimeException("订单用户与车位用户不匹配!");
@@ -763,7 +767,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						if (GroupsRelation.Status.locking == groupsRelation.getStatus() || GroupsRelation.Status.outside == groupsRelation.getStatus()) {
 							log.info("清理用户userId:{}未支付订单", orderDon.getUserId());
 							groupsRelation.setUserId(0L);
-							if (GroupsRelation.Status.outside != groupsRelation.getStatus()) {
+							Long groupsId = groupsRelation.getGroupsId();
+							GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
+							if (groupsRelation.getNum() > groupsTrips.getNum()) {
+								groupsRelation.setStatus(GroupsRelation.Status.outside);
+							} else {
 								groupsRelation.setStatus(GroupsRelation.Status.none);
 							}
 							groupsRelation.setYhsId(0l);
@@ -841,7 +849,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 		//todo 多账号同一用户绑定 续费
 		if (!relation.getUserId().equals(user.getId())) {
-			checkIsSameUser(relation.getUserId(), userId, user.getOpenId(), user.getLoginPhone());
+			checkIsSameUser(relation.getUserId(), user);
 		}
 		GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
 		if (groupsTrips == null) {
@@ -1217,7 +1225,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
 			if (GroupsRelation.Status.locking.equals(relation.getStatus()) || GroupsRelation.Status.validity.equals(relation.getStatus()) || GroupsRelation.Status.outside.equals(relation.getStatus())) {
 				log.info("订单号orderNo:{}开始修改车位:{}状态", order.getOrderNo(), relation.getId());
-				if (relation.getStatus() != GroupsRelation.Status.outside) {
+				if (relation.getNum() > groupsTrips.getNum()) {
+					relation.setStatus(GroupsRelation.Status.outside);
+				} else {
 					relation.setStatus(GroupsRelation.Status.validity);
 				}
 				//续费后,下一次续费意愿状态为false
@@ -1368,6 +1378,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 					log.info("用户{}邀请{},产生分销订单分发积分记录入库", userDistributeShared.getSharedId(), order.getUserId());
 					distributeWaitingSendPoints.setSendStatus(DistributeWaitingSendPoints.Status.waiting);
 					distributeWaitingSendPoints.setSendTime(DateUtil.offsetDay(order.getPayTime(), 3));
+					distributeWaitingSendPoints.setRate(rate);
 					distributeWaitingSendPointsMapper.insert(distributeWaitingSendPoints);
 					//暂定虚物 商务可首单提成
 					if (businessId != null) {
@@ -1747,38 +1758,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		return orderDon.getStatus();
 	}
 
-	public void checkIsSameUser(Long relationUserId, Long userId, String openId, String loginPhone) {
-		//手机用户与微信用户
-		LambdaQueryWrapper<UserBindDetail> wrapper = Wrappers.lambdaQuery(UserBindDetail.class);
-		Boolean isPcUser = false;
-		if (StrUtil.isNotBlank(openId)) {
-			wrapper.eq(UserBindDetail::getUserId, userId);
-		} else {
-			isPcUser = true;
-			wrapper.eq(UserBindDetail::getPhone, loginPhone);
-		}
-		UserBindDetail userBindDetail = userBindDetailMapper.selectOne(wrapper.last("limit 1"));
-		if (userBindDetail == null) {
-			throw new BusinessRuntimeException("");
-		}
-		if (userBindDetail != null) {
-			if (isPcUser) {
-				if (!relationUserId.equals(userBindDetail.getUserId())) {
-					throw new BusinessRuntimeException("");
-				}
-			} else {
-				if (StrUtil.isEmpty(userBindDetail.getPhone())) {
-					throw new BusinessRuntimeException("");
-				}
-				User otherUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
-						.eq(User::getLoginPhone, userBindDetail.getPhone()).last("limit 1"));
-				if (otherUser == null) {
-					throw new BusinessRuntimeException("");
-				}
-				if (!relationUserId.equals(otherUser.getId())) {
-					throw new BusinessRuntimeException("");
-				}
-			}
+	public void checkIsSameUser(Long relationUserId, User renewUser) {
+		List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(renewUser.getId(), renewUser);
+		if (!relationUserIdList.contains(relationUserId)) {
+			throw BusinessRuntimeException.getInstance("");
 		}
 	}
 
@@ -1937,9 +1920,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		//锁定座位
 		setRelation(relation.getId(), relation.getGroupsId(), userId, sku.getGoodsId(), isLoginPopularize, relation.getStatus());
 		relation.setUserId(userId);
-		if (relation.getStatus() != GroupsRelation.Status.outside) {
-			relation.setStatus(GroupsRelation.Status.locking);
-		}
+		//重新置为锁定
+		relation.setStatus(GroupsRelation.Status.locking);
 		relation.setYhsId(yhsId);
 		groupsRelationMapper.updateById(relation);
 		redisService.del(RedisKey.GROUPS_RELATION_NUM_KEY + relation.getId());