zoujiajian пре 2 година
родитељ
комит
006d4c0194

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

@@ -23,9 +23,9 @@ public interface Constant {
 
 	/**
 	 * 实物类型
-	 * 2实物、3潮玩好物
+	 * 2实物、3潮玩好物、4租赁商品
 	 */
-	List<Integer> realGoodsType = List.of(2, 3);
+	List<Integer> realGoodsType = List.of(2, 3, 4);
 
 	/**
 	 * 平台类型

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/OrderDon.java

@@ -59,6 +59,11 @@ public class OrderDon extends BaseEntity implements Serializable {
     /** 金额 */
     private BigDecimal money;
 
+    /**
+     * 押金
+     */
+    private BigDecimal deposit;
+
     /**
      * 加购商品金额
      */

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/request/ReqGoodsSkuSpec.java

@@ -26,6 +26,11 @@ public class ReqGoodsSkuSpec {
 
         private BigDecimal price;
 
+        /**
+         * 租赁押金
+         */
+        private BigDecimal deposit;
+
         /**
          * 预览图
          */

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/manage/request/ReqGoodsSpuInsert.java

@@ -62,7 +62,7 @@ public class ReqGoodsSpuInsert {
     private Boolean deleted;
 
     /**
-     * 类型 1账号 2.实物
+     * 类型 1账号 2.实物 3.潮玩 4.租赁
      */
     private Integer type;
 

+ 4 - 0
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSpecServiceImpl.java

@@ -106,6 +106,10 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
 				if (goods.getType() == 2 && insert.getId()  == null && (e.getPrice() == null || e.getPrice().compareTo(BigDecimal.ZERO) < 0)) {
 					throw BusinessRuntimeException.getInstance("实物规格:{0}对应价格请输入", e.getValue());
 				}
+				//租赁规格
+				if (goods.getType() == 4 && insert.getId() == null && (e.getDeposit() == null || e.getDeposit().compareTo(BigDecimal.ZERO) < 0)) {
+					throw BusinessRuntimeException.getInstance("规格:{0}对应押金请输入", e.getValue());
+				}
 
 				if (null == map) {
 					map = new HashMap<>(16);

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

@@ -54,6 +54,7 @@ import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.dto.ChannelBaiDuDiscountDto;
 import com.cyksj.model.manage.dto.GiftCardDto;
+import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.manage.views.OrderDonView;
 import com.cyksj.model.request.*;
@@ -131,6 +132,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 	private final GoodsDonMapper goodsDonMapper;
 
+	private final GoodsDonSpecMapper goodsDonSpecMapper;
+
 	private final GroupsRelationMapper groupsRelationMapper;
 
 	private final BeanSearcher beanSearcher;
@@ -399,6 +402,18 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			payRequest.setDonMoney(sku.getPrice());
 		}
 
+		//租赁商品
+		if (goodsDon.getType() == 4) {
+			//租赁商品押金
+			BigDecimal rentGoodsDonDeposit = getRentGoodsDonDeposit(goodsId, sku.getSpecIds());
+			if (rentGoodsDonDeposit == null) throw BusinessRuntimeException.getInstance("应付押金异常..");
+			BigDecimal sPay = rentGoodsDonDeposit.add(sku.getPrice());
+			if (payRequest.getDonMoney().compareTo(sPay) < 0) {
+				payRequest.setDonMoney(sPay);
+			}
+			orderDon.setDeposit(rentGoodsDonDeposit);
+		}
+
 		orderDon.setMoney(payRequest.getDonMoney());
 		orderDon.setRealMoney(payRequest.getDonMoney());
 		orderDon.setOriMoney(sku.getPrice());
@@ -457,7 +472,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				throw BusinessRuntimeException.getInstance("车位与车队规格不一致");
 			}
 		}
-		if (sku != null) {
+		//租赁商品不参与优惠
+		if (sku != null && goodsDon.getType() != 4) {
 			//扣除使用优惠券、余额的订单金额
 			deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType(), payRequest.getGcCash(), payRequest.getGcpIds(), payRequest.getIsAcReduce());
 		}
@@ -2780,4 +2796,26 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			userBenefitsService.recordBalanceBySource(user.getId(), BigDecimal.valueOf(-subBalance.longValue()), UserBalanceSourceRecord.Source.payment);
 		}
 	}
+
+	/**
+	 * 获取租赁商品的应付押金
+	 */
+	private BigDecimal getRentGoodsDonDeposit(Long goodsId, String specIdsStr) throws Exception {
+		GoodsDonSpec rentGoodsDonSpec = goodsDonSpecMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSpec.class)
+				.eq(GoodsDonSpec::getGoodsId, goodsId)
+				.last("limit 1"));
+		List<Long> specIds = Jsons.parseList(specIdsStr, Long.class);
+		String specsJson = rentGoodsDonSpec.getSpecsJson();
+		List<ReqGoodsSkuSpec> reqGoodsSkuSpec = Jsons.parseList(specsJson, ReqGoodsSkuSpec.class);
+		for (ReqGoodsSkuSpec spec : reqGoodsSkuSpec) {
+			if (spec.getKey().contains("版本")) {
+				for (ReqGoodsSkuSpec.Node value : spec.getValues()) {
+					if (specIds.contains(value.getId())) {
+						return value.getDeposit();
+					}
+				}
+			}
+		}
+		return null;
+	}
 }

+ 2 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/CmsOrderController.java

@@ -281,6 +281,8 @@ public class CmsOrderController {
 				data.setRealGoodName("路由器");
 			} else if (data.getGoodsDonType() == Constant.realGoodsType.get(1)) {
 				data.setRealGoodName("银河潮玩");
+			} else if (data.getGoodsDonType() == Constant.realGoodsType.get(2)) {
+				data.setRealGoodName("Apple Vision Pro");
 			}
 //			data.setIndex(index.getAndIncrement());
 		});

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderCommentFrontController.java

@@ -58,7 +58,7 @@ public class OrderCommentFrontController {
 		String userIdsStr = userIds.toString().replace("[", "(")
 				.replace("]", ")");
 		String conditionSql = "where status not in ('close','noPayment','refund')";
-		if (Constant.realGoodsType.contains(type)) {
+		if (type != 4 && Constant.realGoodsType.contains(type)) {
 			conditionSql = "where status = 'transport'";
 		}
 		conditionSql += String.format(" and user_id in %s", userIdsStr);