Browse Source

乐器提供方式增加多种提供方式

周箭河 5 years ago
parent
commit
eb0aa75dca

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -38,6 +39,9 @@ public class StudentPaymentOrderDetail {
 	@ApiModelProperty(value = "订单编号",required = true)
 	private Long paymentOrderId;
 
+	//购买方式
+	private KitGroupPurchaseTypeEnum kitGroupPurchaseType;
+
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -99,4 +103,11 @@ public class StudentPaymentOrderDetail {
 		return ToStringBuilder.reflectionToString(this);
 	}
 
+	public KitGroupPurchaseTypeEnum getKitGroupPurchaseType() {
+		return kitGroupPurchaseType;
+	}
+
+	public void setKitGroupPurchaseType(KitGroupPurchaseTypeEnum kitGroupPurchaseType) {
+		this.kitGroupPurchaseType = kitGroupPurchaseType;
+	}
 }

+ 39 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -446,6 +446,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     if(!groupType.containsKey("GROUP")){
                         throw new BizException("乐器提供方式不存在");
                     }
+                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.GROUP);
                     remitFee = new BigDecimal((String) groupType.get("GROUP"));
                 }
                 if (registerPayDto.getGoodsGroups().get(goodsGroup.getId()).equals("LEASE")) {
@@ -613,6 +614,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         BigDecimal instrumentFee = BigDecimal.ZERO;
         BigDecimal accessoriesFee = BigDecimal.ZERO;
         BigDecimal otherFee = BigDecimal.ZERO;
+        BigDecimal remitFee = BigDecimal.ZERO;
 
 
         //乐器及打包辅件
@@ -666,6 +668,43 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     courseFee.subtract(goodsGroup.getRemissionCourseFee());
                 }
             }
+        } else if (registerPayDto.getGoodsGroups() != null && registerPayDto.getGoodsGroups().size() > 0) {
+            String goodsGroupIds = registerPayDto.getGoodsGroups().keySet().stream().map(Object::toString).collect(Collectors.joining(","));
+            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(goodsGroupIds);
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                Map groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), HashMap.class);
+                if (registerPayDto.getGoodsGroups().get(goodsGroup.getId()).equals("GROUP")) {
+                    if(!groupType.containsKey("GROUP")){
+                        throw new BizException("乐器提供方式不存在");
+                    }
+                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.GROUP);
+                    remitFee = new BigDecimal((String) groupType.get("GROUP"));
+                }
+                if (registerPayDto.getGoodsGroups().get(goodsGroup.getId()).equals("LEASE")) {
+                    if(!groupType.containsKey("LEASE")){
+                        throw new BizException("乐器提供方式不存在");
+                    }
+                    goodsGroup.setPrice(goodsGroup.getDepositFee());
+                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.LEASE);
+                    remitFee = new BigDecimal((String) groupType.get("LEASE"));
+                }
+                if (registerPayDto.getGoodsGroups().get(goodsGroup.getId()).equals("FREE")) {
+                    if(!groupType.containsKey("FREE")){
+                        throw new BizException("乐器提供方式不存在");
+                    }
+                    goodsGroup.setPrice(new BigDecimal(0));
+                    remitFee = new BigDecimal((String) groupType.get("FREE"));
+                }
+                if(goodsGroup.getType().equals(GoodsType.INSTRUMENT)){
+                    instrumentFee = instrumentFee.add(goodsGroup.getPrice());
+                }else if(goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    accessoriesFee = accessoriesFee.add(goodsGroup.getPrice());
+                }else {
+                    otherFee = otherFee.add(goodsGroup.getPrice());
+                }
+                orderAmount = orderAmount.add(goodsGroup.getPrice());
+            }
+            orderAmount = orderAmount.subtract(remitFee);
         }
 
         //单独辅件

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -355,6 +355,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetail4goodsGroup.setCreateTime(date);
                 studentPaymentOrderDetail4goodsGroup.setUpdateTime(date);
                 studentPaymentOrderDetail4goodsGroup.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetail4goodsGroup.setKitGroupPurchaseType(goodsGroup.getKitGroupPurchaseType());
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goodsGroup);
             }
         }