Преглед изворни кода

奈飞限购用户白名单; 订单补差价扣除分销提成

zoujiajian пре 1 година
родитељ
комит
5568f44812

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -425,4 +425,9 @@ public interface Constant {
 	 * 批发通知短信模板
 	 */
 	String GOODS_WHOLESALE_MSG = "用户%s批发%s个%s账号,请尽快配置账号【银河录像局】";
+
+	/**
+	 * 奈飞限购用户白名单
+	 */
+	String NF_PURCHASE_LIMIT_WHITE_KEY = "nf_purchase_Limit_white_key";
 }

+ 5 - 5
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -1300,11 +1300,11 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             orderDon.setRefundMoney(orderRefundMoney.add(refundMoney));
             orderDonMapper.updateById(orderDon);
 
-//            //补差价金额 扣除对应分销提成金额
-//            orderDon.setRefundMoney(refundMoney);
-//            deductDsPoints(orderDon);
-//            //店铺分销提成金额扣除
-//            yhShopDistributeService.deductDsMoney(orderDon);
+            //补差价金额 扣除对应分销提成金额
+            orderDon.setRefundMoney(refundMoney);
+            deductDsPoints(orderDon);
+            //店铺分销提成金额扣除
+            yhShopDistributeService.deductDsMoney(orderDon);
 
         } else {
             BigDecimal refundBalance = refundMoney;

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

@@ -396,17 +396,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				throw new BusinessRuntimeException("您有未支付订单.");
 			}
 		}
-		if (goodsId != null && goodsId == 1) {
-			List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
-			Integer selectCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
-					.in(OrderDon::getUserId, userIdList)
-					.eq(OrderDon::getGoodsId, 1)
-					.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
-					.ge(OrderDon::getCreatedTime, DateUtil.offsetMonth(DateTime.now(), -1)));
-			if (selectCount > 0) {
-				throw BusinessRuntimeException.getInstance("奈飞近30天内限购一单");
-			}
-		}
+		//校验奈飞限购信息
+		checkNfPayLimit(goodsId, userId);
 		GroupsRelation relation = null;
 		String orderPhone = payRequest.getPhone();
 		if (StrUtil.isNotBlank(orderPhone)) {
@@ -1291,16 +1282,28 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 		//单个支付每月限购2单奈飞
 		if (orderDon.getGoodsId() == 1) {
-			Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
-					.eq(OrderDon::getBuyerId, orderDon.getBuyerId())
-					.eq(OrderDon::getGoodsId, 1)
-					.ne(OrderDon::getId, orderDon.getId())
-					.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
-					.ge(OrderDon::getCreatedTime, DateUtil.offsetMonth(DateTime.now(), -1)));
-			//超过2单 自动退款
-			if (count > 0) {
-				notifyRefundOrder(orderDon, goodsDon, sku);
-				return;
+			Boolean isCheck = true;
+			SysConfig one = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+					.eq(SysConfig::getSysKey, Constant.NF_PURCHASE_LIMIT_WHITE_KEY)
+					.last("limit 1"));
+			if (one != null && StrUtil.isNotBlank(one.getSysValue())) {
+				List<Long> whiteUserIds = Jsons.parseList(one.getSysValue(), Long.class);
+				if (whiteUserIds.contains(orderDon.getUserId())) {
+					isCheck = false;
+				}
+			}
+			if (isCheck) {
+				Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+						.eq(OrderDon::getBuyerId, orderDon.getBuyerId())
+						.eq(OrderDon::getGoodsId, 1)
+						.ne(OrderDon::getId, orderDon.getId())
+						.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
+						.ge(OrderDon::getCreatedTime, DateUtil.offsetMonth(DateTime.now(), -1)));
+				//超过1单 自动退款
+				if (count > 0) {
+					notifyRefundOrder(orderDon, goodsDon, sku);
+					return;
+				}
 			}
 		}
 
@@ -4317,4 +4320,30 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		}
 		return false;
 	}
+
+	private void checkNfPayLimit(Long goodsId, Long userId) throws Exception {
+		if (goodsId != null && goodsId == 1) {
+			Boolean isCheck = true;
+			SysConfig nfLimitPayWhiteConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
+					.eq(SysConfig::getSysKey, Constant.NF_PURCHASE_LIMIT_WHITE_KEY)
+					.last("limit 1"));
+			if (nfLimitPayWhiteConfig != null && StrUtil.isNotBlank(nfLimitPayWhiteConfig.getSysValue())) {
+				List<Long> whiteUserIds = Jsons.parseList(nfLimitPayWhiteConfig.getSysValue(), Long.class);
+				if (whiteUserIds.contains(userId)) {
+					isCheck = false;
+				}
+			}
+			if (isCheck) {
+				List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+				Integer selectCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
+						.in(OrderDon::getUserId, userIdList)
+						.eq(OrderDon::getGoodsId, 1)
+						.notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
+						.ge(OrderDon::getCreatedTime, DateUtil.offsetMonth(DateTime.now(), -1)));
+				if (selectCount > 0) {
+					throw BusinessRuntimeException.getInstance("奈飞近30天内限购一单");
+				}
+			}
+		}
+	}
 }