周箭河 6 лет назад
Родитель
Сommit
435ee75388

+ 17 - 5
src/main/java/com/ym/mec/collectfee/controller/YqPayController.java

@@ -2,6 +2,7 @@ package com.ym.mec.collectfee.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.parser.Feature;
 import com.ym.mec.collectfee.common.web.BaseController;
 import com.ym.mec.collectfee.entity.*;
 import com.ym.mec.collectfee.service.*;
@@ -11,6 +12,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.IOUtils;
+import org.apache.ibatis.session.defaults.DefaultSqlSession;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.core.io.ClassPathResource;
@@ -92,7 +94,7 @@ public class YqPayController extends BaseController {
         }
 
         //2 版本为3.0( 26),不收乐器费用,收押金800放乐器费用
-        if (courseGroupInfo.getFeeType().equals("26")) {
+        if (courseGroupInfo.getFeeType().equals(26)) {
             instrumentPrice = new BigDecimal("800");
         }
         amount = amount.add(instrumentPrice);
@@ -200,19 +202,29 @@ public class YqPayController extends BaseController {
 
         //课程组价格
         ArrayList<MecCourse> courses = (ArrayList<MecCourse>) applyInfoService.queryUserCourse(renewals.getUserId());//获取续费课程
-        String[] coursesIdArr = renewals.getCourses().split(",");
+        MecCourse mecCourse4json = JSON.parseObject(renewals.getCourses(), MecCourse.class);
+        if (mecCourse4json == null) {
+            return failed("请选择续费课程");
+        }
+
+        //classType 小课1 大课2
+        Integer buyCount = mecCourse4json.getBuyCount();
         BigDecimal amount = new BigDecimal("0"); //课程总价
         String remark = "";
         for (int i = 0; i < courses.size(); i++) {
             MecCourse course = courses.get(i);
-            if (Arrays.asList(coursesIdArr).contains(course.getCourseId())) {
-                BigDecimal price = course.getPrice().multiply(BigDecimal.valueOf(course.getBuyCount()));
+            if (mecCourse4json.getCourseId().equals(course.getCourseId())) {
+                System.out.println(course);
+                BigDecimal price = course.getClassType() == 1 ? course.getPrice().multiply(BigDecimal.valueOf(buyCount)) : mecCourse4json.getPrice();
                 amount = amount.add(price);
-                remark += course.getClassName() + "|";
+                remark += course.getClassName();
             } else {
                 courses.remove(i);
             }
         }
+        if (courses.size() == 0) {
+            return failed("请选择续费课程");
+        }
 
         String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
         String returnUrl = "http://dev.dayaedu.com";//支付后返回页面

+ 2 - 2
src/main/java/com/ym/mec/collectfee/entity/Renewals.java

@@ -52,8 +52,8 @@ public class Renewals {
 	@ApiModelProperty(name = "orderId", value = "订单号",hidden = true)
 	private Integer orderId;
 
-	/** 订单号 */
-	@ApiModelProperty(name = "buy", value = "购买课程,100012,100098",required = true)
+	/** 购买课程 */
+	@ApiModelProperty(name = "courses", value = "购买课程,json格式({\"courseId\":\"100012\",\"buyCount\":\"3\",\"price\":\"300\"})",required = true)
 	private String courses;
 	
 	public void setId(Integer id){