فهرست منبع

Merge branch 'feature-goods-river' of http://git.dayaedu.com/yonge/mec into zouxuan

zouxuan 5 سال پیش
والد
کامیت
b8e5ca1505

+ 22 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -1,17 +1,30 @@
 package com.ym.mec.biz.dal.dto;
 
 import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * 学团注册支付
  */
 public class RegisterPayDto {
+    //总金额
     private BigDecimal amount;
+    //报名id
     private Integer registerId;
+    //打包商品ids
     private String goodsGroupIds;
+    //单独商品ids
     private String goodsIds;
+    //教谱ids
     private String otherGoodsIds;
-    Boolean isUseBalancePayment = false;
+    //乐器id->type
+    private Map<Integer,String> goodsGroups;
+
+    //是否余额支付
+    private Boolean isUseBalancePayment = false;
+
 
     public Integer getRegisterId() {
         return registerId;
@@ -60,4 +73,12 @@ public class RegisterPayDto {
 	public void setIsUseBalancePayment(Boolean isUseBalancePayment) {
 		this.isUseBalancePayment = isUseBalancePayment;
 	}
+
+    public Map<Integer, String> getGoodsGroups() {
+        return goodsGroups;
+    }
+
+    public void setGoodsGroups(Map<Integer, String> goodsGroups) {
+        this.goodsGroups = goodsGroups;
+    }
 }

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupSubjectGoodsGroup.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.enums.GoodsType;
 
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -45,6 +46,15 @@ public class MusicGroupSubjectGoodsGroup {
 	//团购减免课程费用
 	private BigDecimal remissionCourseFee;
 
+	//租赁押金
+	private BigDecimal depositFee;
+
+	//购买方式
+	private KitGroupPurchaseTypeEnum kitGroupPurchaseType;
+
+	//购买方式-减免金额 json
+	private String kitGroupPurchaseTypeJson;
+
 
 	/**  */
 	private java.util.Date createTime;
@@ -152,6 +162,31 @@ public class MusicGroupSubjectGoodsGroup {
 		this.remissionCourseFee = remissionCourseFee;
 	}
 
+	public BigDecimal getDepositFee() {
+		return depositFee;
+	}
+
+	public void setDepositFee(BigDecimal depositFee) {
+		this.depositFee = depositFee;
+	}
+
+	public KitGroupPurchaseTypeEnum getKitGroupPurchaseType() {
+		return kitGroupPurchaseType;
+	}
+
+	public void setKitGroupPurchaseType(KitGroupPurchaseTypeEnum kitGroupPurchaseType) {
+		this.kitGroupPurchaseType = kitGroupPurchaseType;
+	}
+
+
+	public String getKitGroupPurchaseTypeJson() {
+		return kitGroupPurchaseTypeJson;
+	}
+
+	public void setKitGroupPurchaseTypeJson(String kitGroupPurchaseTypeJson) {
+		this.kitGroupPurchaseTypeJson = kitGroupPurchaseTypeJson;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 71 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -415,6 +415,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;
 
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
@@ -444,7 +445,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
                 orderAmount = orderAmount.add(orderDetail.getPrice());
             }
-        } else if (studentRegistration.getTemporaryCourseFee() == null && StringUtils.isNoneBlank(registerPayDto.getGoodsGroupIds())) {
+        } else if (StringUtils.isNoneBlank(registerPayDto.getGoodsGroupIds())) {
             goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
@@ -467,6 +468,42 @@ 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(key -> key.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("乐器提供方式不存在");
+                    }
+                    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.subtract(remitFee);
         }
 
         //单独辅件
@@ -507,7 +544,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         	if(userCashAccount == null){
         		throw new BizException("用户账户找不到");
         	}
-        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
+        	if(userCashAccount.getBalance().subtract(amount).doubleValue() >= 0){
         		// 更新订单信息
         		studentPaymentOrder.setBalancePaymentAmount(amount);
         		studentPaymentOrder.setOrganId(musicGroup.getOrganId());
@@ -705,7 +742,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         		throw new BizException("用户账户找不到");
         	}
             studentPaymentOrder.setPaymentChannel("BALANCE");
-        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
+        	if(userCashAccount.getBalance().subtract(amount).doubleValue() >= 0){
         		// 更新订单信息
         		studentPaymentOrder.setBalancePaymentAmount(amount);
         		studentPaymentOrder.setOrganId(musicGroup.getOrganId());
@@ -1451,7 +1488,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		if (orderList == null || orderList.size() == 0) {
 			throw new BizException("请走报名缴费流程");
 		}*/
-        
+
         // 判断当前是否是续费状态
         if (musicGroupStudentFee.getPaymentStatus() != PaymentStatus.NON_PAYMENT) {
             throw new BizException("已缴费");
@@ -1771,44 +1808,44 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Date date = new Date();
         List<Integer> months = subFeeSettingDto.getMonths();
-        
+
         //判断缴费日历是否修改
-		boolean isModifiedOfCalender = false;
-
-		List<MusicGroupPaymentCalender> calenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
-		if (months.size() == calenderList.size()) {
-			for (MusicGroupPaymentCalender cal : calenderList) {
-				if (!months.contains(cal.getPaymentMonth())) {
-					isModifiedOfCalender = true;
-					break;
-				}
-			}
-		} else {
-			isModifiedOfCalender = true;
-		}
+        boolean isModifiedOfCalender = false;
 
-		if (isModifiedOfCalender) {
-			
-			Integer num = musicGroupStudentFeeDao.countStudentNoPayNum(musicGroupId);
-			if (num > 0) {
-				throw new BizException("缴费周期更新失败,当前乐团有未缴费的学员");
-			}
-			
-			// 删除乐团相关付费周期
-			musicGroupPaymentCalenderDao.delByGroupId(musicGroupId);
-			musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId,0);
-			if (months != null && months.size() > 0) {
-				// 批量插入
-				musicGroupPaymentCalenderDao.batchAdd(months, musicGroupId);
-			}
-			if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
+        List<MusicGroupPaymentCalender> calenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+        if (months.size() == calenderList.size()) {
+            for (MusicGroupPaymentCalender cal : calenderList) {
+                if (!months.contains(cal.getPaymentMonth())) {
+                    isModifiedOfCalender = true;
+                    break;
+                }
+            }
+        } else {
+            isModifiedOfCalender = true;
+        }
+
+        if (isModifiedOfCalender) {
+
+            Integer num = musicGroupStudentFeeDao.countStudentNoPayNum(musicGroupId);
+            if (num > 0) {
+                throw new BizException("缴费周期更新失败,当前乐团有未缴费的学员");
+            }
+
+            // 删除乐团相关付费周期
+            musicGroupPaymentCalenderDao.delByGroupId(musicGroupId);
+            musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId,0);
+            if (months != null && months.size() > 0) {
+                // 批量插入
+                musicGroupPaymentCalenderDao.batchAdd(months, musicGroupId);
+            }
+            if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
                 //生成学员费用表
                 List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
                 if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
                     musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null),"PAID_COMPLETED");
                 }
             }
-		}
+        }
         musicGroupDao.update(musicGroup);
         //修改课程里面的教学点
         if(!musicGroup.getSchoolId().equals(musicGroup.getSchoolId())){

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -240,7 +240,7 @@ public class MusicGroupController extends BaseController {
             return failed(HttpStatus.CREATED, "恭喜您,报名成功!");
         }
 
-        return succeed(musicGroupService.rePay(registerPayDto));
+        return succeed(payMap);
     }
 
     @ApiOperation(value = "订单状态查询")

+ 17 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -1,10 +1,12 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.Arrays;
@@ -51,6 +53,8 @@ import com.ym.mec.thirdparty.yqpay.YqPayFeignService;
 import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 import com.ym.mec.util.http.HttpUtil;
 
+import javax.servlet.http.HttpServletResponse;
+
 @RequestMapping("studentOrder")
 @Api(tags = "订单回调")
 @RestController
@@ -71,6 +75,8 @@ public class StudentOrderController extends BaseController {
     private YqPayFeignService yqPayFeignService;
     @Autowired
     private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
@@ -273,4 +279,15 @@ public class StudentOrderController extends BaseController {
         }
         return succeed("订单不存在");
     }
+
+
+    @RequestMapping("paymentResult")
+    public void paymentResult(HttpServletResponse response,String orderNo) {
+        try {
+            String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+            response.sendRedirect(baseApiUrl+"/#/paymentresult?orderNo=" + orderNo);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 }