Procházet zdrojové kódy

Merge branch 'master' of http://git.dayaedu.com/yonge/collect_fee

zouxuan před 6 roky
rodič
revize
03f5bb1e88

+ 21 - 6
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);
@@ -168,6 +170,8 @@ public class YqPayController extends BaseController {
         String orderSubject = "培训订单";
 
 
+        order.setAmount(new BigDecimal("2")); //测试设置金额
+
         Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
         resultMap.put("sellerNo", "0021677"); //收款商户号
         resultMap.put("payChannels", payChannels); //支付方式
@@ -196,23 +200,34 @@ public class YqPayController extends BaseController {
     @PostMapping("/renewalsPay")
 
     public Object renewalsPay(@ModelAttribute @Validated Renewals renewals) throws Exception {
-        renewals.setUserId(1000015);
+        MecUser mecUser = applyInfoService.findMecUser(renewals.getUserId());
+        renewals.setBranchId(mecUser.getBranchId());
 
         //课程组价格
         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";//支付后返回页面

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

@@ -21,7 +21,7 @@ public class Renewals {
 	private Integer classId;
 
 	/** 分部id */
-	@ApiModelProperty(name = "branchId", value = "分部id",required = true)
+	@ApiModelProperty(name = "branchId", value = "分部id",hidden = true)
 	private Integer branchId;
 	
 	/** 支付方式 */
@@ -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){