|
@@ -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;
|
|
@@ -50,6 +52,9 @@ public class YqPayController extends BaseController {
|
|
|
@Autowired
|
|
|
private ApplyInfoService applyInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RenewalsService renewalsService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 统一下单(乐团缴费)
|
|
@@ -89,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);
|
|
@@ -118,7 +123,7 @@ public class YqPayController extends BaseController {
|
|
|
String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
|
|
|
String returnUrl = "http://dev.dayaedu.com";//支付后返回页面
|
|
|
String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
|
|
|
- String payChannels = "{\"fastpayXy\":true,\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
|
|
|
+ String payChannels = "{\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"fastpayXy\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
|
|
|
|
|
|
String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
|
order.setOrderNo(orderNo);
|
|
@@ -135,6 +140,9 @@ public class YqPayController extends BaseController {
|
|
|
|
|
|
//获取分佣账户
|
|
|
Account account = accountService.getAccountByBranchId(branchId);
|
|
|
+ if (account == null) {
|
|
|
+ return failed("机构没有设置收款账户");
|
|
|
+ }
|
|
|
String routingMerNo = account.getSellerNo();
|
|
|
BigDecimal HasRouting = account.getHasRouting().add(order.getAmount());
|
|
|
account.setHasRouting(HasRouting);
|
|
@@ -162,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); //支付方式
|
|
@@ -186,123 +196,90 @@ public class YqPayController extends BaseController {
|
|
|
* @return String
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- @ApiOperation(value = "续费支付", notes = "易乾支付统一下单")
|
|
|
+ @ApiOperation(value = "续费支付", notes = "续费支付")
|
|
|
@PostMapping("/renewalsPay")
|
|
|
- @Transactional
|
|
|
- //applyInfoService.queryUserCourse(userId) //获取续费课程
|
|
|
-// public Object renewalsPay(@ModelAttribute @Validated Renewals renewals) throws Exception {
|
|
|
-// BigDecimal amount = new BigDecimal("0");
|
|
|
-//
|
|
|
-// //课程组价格
|
|
|
-// BigDecimal courseFee = courseGroupInfo.getFeeAmount();
|
|
|
-// amount = amount.add(courseFee);
|
|
|
-//
|
|
|
-// ClassPathResource classPathResource = new ClassPathResource("instruments.json");
|
|
|
-//
|
|
|
-// BigDecimal instrumentPrice = new BigDecimal("0");//乐器价格
|
|
|
-// String instrumentName = "";//乐器名称
|
|
|
-//
|
|
|
-// //获取乐器的价格
|
|
|
-// String instrumentId = order.getInstrument();
|
|
|
-// String jsonString = IOUtils.toString(new InputStreamReader(classPathResource.getInputStream(), "UTF-8"));
|
|
|
-// Instrument instrument = JSONObject.parseObject(jsonString, Instrument.class);
|
|
|
-//
|
|
|
-// if (order.getInstrument() != null && !order.getInstrument().isEmpty()) {
|
|
|
-// instrumentPrice = new BigDecimal(instrument.getInstruments().get(instrumentId).get("referencePrice"));
|
|
|
-// instrumentName = (String) instrument.getInstruments().get(instrumentId).get("index") + "-" +
|
|
|
-// (String) instrument.getInstruments().get(instrumentId).get("name");
|
|
|
-// }
|
|
|
-//
|
|
|
-// //2 版本为3.0( 26),不收乐器费用,收押金800放乐器费用
|
|
|
-// if (courseGroupInfo.getFeeType().equals("26")) {
|
|
|
-// instrumentPrice = new BigDecimal("800");
|
|
|
-// }
|
|
|
-// amount = amount.add(instrumentPrice);
|
|
|
-//
|
|
|
-// //辅件价格
|
|
|
-// String adjunctIds = order.getAdjunct();
|
|
|
-// BigDecimal adjunctPrice = new BigDecimal("0");//辅件价格
|
|
|
-// String adjunctName = "";//辅件名称
|
|
|
-// if (adjunctIds != null && !adjunctIds.isEmpty()) {
|
|
|
-// String[] adjunctIdArr = adjunctIds.split(",");
|
|
|
-// for (String adjunctId : adjunctIdArr) {
|
|
|
-// adjunctPrice = adjunctPrice.add(new BigDecimal(instrument.getAuxiliaries().get(adjunctId).get("referencePrice")));
|
|
|
-// adjunctName += (String) instrument.getAuxiliaries().get(adjunctId).get("name") + "|";
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// amount = amount.add(adjunctPrice);
|
|
|
-// order.setAmount(amount);
|
|
|
-// order.setRemark(instrumentName);
|
|
|
-// order.setTuiFee(courseFee);
|
|
|
-// order.setGoodsFee(instrumentPrice);
|
|
|
-// order.setSdName(adjunctName + "教材|琴谱");
|
|
|
-// order.setSdFee(adjunctPrice);
|
|
|
-//
|
|
|
-//
|
|
|
-// String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
|
|
|
-// String returnUrl = "http://dev.dayaedu.com";//支付后返回页面
|
|
|
-// String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
|
|
|
-// String payChannels = "{\"fastpayXy\":true,\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"aliPayMobile\":true,\"balancePay\":false}";//支付方式配置
|
|
|
-//
|
|
|
-// String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
|
-// order.setOrderNo(orderNo);
|
|
|
-// order.setCreateTime(new Date()); //订单提交时间
|
|
|
-// order.setStatus(1); //订单状态
|
|
|
-//
|
|
|
-// //获取支付成功跟支付中的订单数
|
|
|
-// int branchId = order.getBranchId();
|
|
|
-// int payOrderNums = orderService.getPayOrderNums();
|
|
|
-// //分佣账户(1、每10笔,前四笔收入私户 2、私户每个商户最多收款400万)
|
|
|
-// if ((payOrderNums + 1) % 10 <= 4) { //私人账户
|
|
|
-// branchId = 0;
|
|
|
-// }
|
|
|
-//
|
|
|
-// //获取分佣账户
|
|
|
-// Account account = accountService.getAccountByBranchId(branchId);
|
|
|
-// String routingMerNo = account.getSellerNo();
|
|
|
-// BigDecimal HasRouting = account.getHasRouting().add(order.getAmount());
|
|
|
-// account.setHasRouting(HasRouting);
|
|
|
-//
|
|
|
-// Map<String, Object> routingList = new LinkedHashMap<String, Object>();
|
|
|
-// routingList.put("routingMerNo", routingMerNo);//分佣账户
|
|
|
-// routingList.put("routingFee", order.getAmount()); //分佣金额
|
|
|
-// List<Map> tempRoutingList = new ArrayList();
|
|
|
-// tempRoutingList.add(routingList);
|
|
|
-//
|
|
|
-// order.setAccount(routingMerNo);
|
|
|
-//
|
|
|
-// //1、插入订单
|
|
|
-// orderService.insert(order);
|
|
|
-// //2、修改已报名人数
|
|
|
-// courseGroupInfo.setRegNum(courseGroupInfo.getRegNum() + 1);
|
|
|
-// CourseGroupInfoService.upByIdAndVersion(courseGroupInfo);
|
|
|
-// //3、修改分佣账户已收金额
|
|
|
-// accountService.upByIdAndVersion(account);
|
|
|
-//
|
|
|
-//
|
|
|
-// /*订单信息*/
|
|
|
-// String orderBody = "大雅乐盟培训课程";
|
|
|
-// /*订单标题*/
|
|
|
-// String orderSubject = "培训订单";
|
|
|
-//
|
|
|
-//
|
|
|
-// Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
|
|
|
-// resultMap.put("sellerNo", "0021677"); //收款商户号
|
|
|
-// resultMap.put("payChannels", payChannels); //支付方式
|
|
|
-// resultMap.put("orderBody", orderBody); //订单信息
|
|
|
-// resultMap.put("payAmount", order.getAmount()); //支付金额
|
|
|
-// resultMap.put("apiPayType", "1"); //*API支付类型1-即时支付,2-担保支付,3-预授权支付*/
|
|
|
-// resultMap.put("tradeType", "0"); //*交易类型1—充值,0—收款*
|
|
|
-// resultMap.put("merMerOrderNo", orderNo); //商户订单号
|
|
|
-// resultMap.put("orderSubject", orderSubject); //订单标题
|
|
|
-// resultMap.put("returnUrl", returnUrl); //前台页面地址
|
|
|
-// resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
|
|
|
-// Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
-// rqMap.put("host", payUrl);
|
|
|
-//
|
|
|
-// return succeed(rqMap);
|
|
|
-// }
|
|
|
+
|
|
|
+ public Object renewalsPay(@ModelAttribute @Validated Renewals renewals) throws Exception {
|
|
|
+ MecUser mecUser = applyInfoService.findMecUser(renewals.getUserId());
|
|
|
+ renewals.setBranchId(mecUser.getBranchId());
|
|
|
+
|
|
|
+ //课程组价格
|
|
|
+ ArrayList<MecCourse> courses = (ArrayList<MecCourse>) applyInfoService.queryUserCourse(renewals.getUserId());//获取续费课程
|
|
|
+ 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 (mecCourse4json.getCourseId().equals(course.getCourseId())) {
|
|
|
+ BigDecimal price = course.getClassType() == 1 ? course.getPrice().multiply(BigDecimal.valueOf(buyCount)) : mecCourse4json.getPrice();
|
|
|
+ amount = amount.add(price);
|
|
|
+ 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";//支付后返回页面
|
|
|
+ String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
|
|
|
+ String payChannels = "{\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"fastpayXy\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
|
|
|
+
|
|
|
+ String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
|
+
|
|
|
+ //获取支付成功跟支付中的订单数
|
|
|
+ int branchId = renewals.getBranchId();
|
|
|
+ int payOrderNums = orderService.getPayOrderNums();
|
|
|
+ //分佣账户(1、每10笔,前四笔收入私户 2、私户每个商户最多收款400万)
|
|
|
+ if ((payOrderNums + 1) % 10 <= 4) { //私人账户
|
|
|
+ branchId = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取分佣账户
|
|
|
+ Account account = accountService.getAccountByBranchId(branchId);
|
|
|
+ if (account == null) {
|
|
|
+ return failed("机构没有设置收款账户");
|
|
|
+ }
|
|
|
+ String routingMerNo = account.getSellerNo();
|
|
|
+ BigDecimal HasRouting = account.getHasRouting().add(amount);
|
|
|
+ account.setHasRouting(HasRouting);
|
|
|
+
|
|
|
+ Map<String, Object> routingList = new LinkedHashMap<String, Object>();
|
|
|
+ routingList.put("routingMerNo", routingMerNo);//分佣账户
|
|
|
+ routingList.put("routingFee", amount); //分佣金额
|
|
|
+ List<Map> tempRoutingList = new ArrayList();
|
|
|
+ tempRoutingList.add(routingList);
|
|
|
+
|
|
|
+ renewalsService.addRenewalsOrder(renewals, amount, orderNo, courses, routingMerNo, remark);
|
|
|
+
|
|
|
+ /*订单信息*/
|
|
|
+ String orderBody = "大雅乐盟培训课程";
|
|
|
+ /*订单标题*/
|
|
|
+ String orderSubject = "培训订单";
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
|
|
|
+ resultMap.put("sellerNo", "0021677"); //收款商户号
|
|
|
+ resultMap.put("payChannels", payChannels); //支付方式
|
|
|
+ resultMap.put("orderBody", orderBody); //订单信息
|
|
|
+ resultMap.put("payAmount", amount); //支付金额
|
|
|
+ resultMap.put("apiPayType", "1"); //*API支付类型1-即时支付,2-担保支付,3-预授权支付*/
|
|
|
+ resultMap.put("tradeType", "0"); //*交易类型1—充值,0—收款*
|
|
|
+ resultMap.put("merMerOrderNo", orderNo); //商户订单号
|
|
|
+ resultMap.put("orderSubject", orderSubject); //订单标题
|
|
|
+ resultMap.put("returnUrl", returnUrl); //前台页面地址
|
|
|
+ resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
|
|
|
+ Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
+ rqMap.put("host", payUrl);
|
|
|
+ return succeed(rqMap);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 交易查询
|
|
@@ -447,12 +424,12 @@ public class YqPayController extends BaseController {
|
|
|
//支付中订单存在,更新状态
|
|
|
if (order != null && msg.getResponseType().equals("1")) {
|
|
|
//更新订单状态
|
|
|
- int status = msg.getCode().equals("88") ? 0 : 2;
|
|
|
+ int status = msg.getCode().equals("88") ? 2 : 0;
|
|
|
order.setStatus(status);
|
|
|
if (order.getOrderNo().isEmpty()) {
|
|
|
order.setPayId(notifyMsg.getOrderNo()); //更新易乾付订单号
|
|
|
}
|
|
|
- if (status == 0) {
|
|
|
+ if (status == 2) {
|
|
|
order.setPay(notifyMsg.getPayAmount());
|
|
|
order.setPayTime(new Date());
|
|
|
}
|