|
@@ -2,14 +2,14 @@ package com.ym.mec.collectfee.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.collectfee.common.sms.SmsExample;
|
|
|
import com.ym.mec.collectfee.common.web.BaseController;
|
|
|
import com.ym.mec.collectfee.entity.*;
|
|
|
import com.ym.mec.collectfee.service.*;
|
|
|
+import com.ym.mec.collectfee.utils.Constants;
|
|
|
import com.ym.mec.collectfee.utils.GenerateNum;
|
|
|
-import com.ym.mec.collectfee.utils.yqpay.Intfc;
|
|
|
-import com.ym.mec.collectfee.utils.yqpay.Msg;
|
|
|
-import com.ym.mec.collectfee.utils.yqpay.NotifyMsg;
|
|
|
-import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
|
|
|
+import com.ym.mec.collectfee.utils.ShortUrlUtil;
|
|
|
+import com.ym.mec.collectfee.utils.yqpay.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import sun.plugin2.util.NativeLibLoader;
|
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.math.BigDecimal;
|
|
@@ -66,6 +67,10 @@ public class YqPayController extends BaseController {
|
|
|
@Transactional
|
|
|
public Object toPay(@ModelAttribute @Validated Order order) throws Exception {
|
|
|
BigDecimal amount = new BigDecimal("0");
|
|
|
+ School school = schoolService.get(order.getClassId());
|
|
|
+ //计划招生人数有更新,更新
|
|
|
+ orderService.getSchoolDetail(school.getSchoolId(), order.getClassId());
|
|
|
+
|
|
|
//1、判断已报名人数
|
|
|
CourseGroupInfo courseGroupInfo = CourseGroupInfoService.get(order.getCourseId());
|
|
|
if (courseGroupInfo.getRegNum().compareTo(courseGroupInfo.getPlanNum()) >= 0) {
|
|
@@ -111,6 +116,8 @@ public class YqPayController extends BaseController {
|
|
|
}
|
|
|
amount = amount.add(adjunctPrice);
|
|
|
|
|
|
+ ApplyInfo applyInfo = applyInfoService.get(order.getUserId());
|
|
|
+
|
|
|
order.setGroupId(courseGroupInfo.getId());
|
|
|
order.setAmount(amount);
|
|
|
order.setRemark(instrumentName);
|
|
@@ -118,6 +125,8 @@ public class YqPayController extends BaseController {
|
|
|
order.setGoodsFee(instrumentPrice);
|
|
|
order.setSdName(adjunctName + "教材|琴谱");
|
|
|
order.setSdFee(adjunctPrice);
|
|
|
+ order.setType(1);
|
|
|
+ order.setUserName(applyInfo.getName());
|
|
|
|
|
|
|
|
|
String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
@@ -125,39 +134,13 @@ public class YqPayController extends BaseController {
|
|
|
order.setCreateTime(new Date()); //订单提交时间
|
|
|
order.setStatus(1); //订单状态
|
|
|
|
|
|
- School school = schoolService.get(order.getClassId());
|
|
|
- String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
|
|
|
- String returnUrl = "http://pay.dayaedu.com/#/login?schoolId=" + school.getSchoolId() + "&classId=" + order.getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
|
|
|
- String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付跳转页
|
|
|
- String payChannels = "{\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"fastpayXy\":true,\"aliPayMobile\":false,\"balancePay\":false}";//支付方式配置
|
|
|
-
|
|
|
- //获取支付成功跟支付中的订单数
|
|
|
+ //获取分佣账户
|
|
|
Integer branchId = 1001;//order.getBranchId();
|
|
|
- int payOrderNums = orderService.getPayOrderNums();
|
|
|
- //分佣账户(1、每10笔,前四笔收入私户 2、私户每个商户最多收款400万)
|
|
|
- if ((payOrderNums + 1) % 10 <= 4) { //私人账户
|
|
|
- branchId = 0;
|
|
|
- }
|
|
|
+ Account routingAccount = accountService.getRoutingAccount(branchId);
|
|
|
|
|
|
- //获取分佣账户
|
|
|
- Account account = accountService.getAccountByBranchId(branchId);
|
|
|
- if (account == null) {
|
|
|
- return failed("机构没有设置收款账户");
|
|
|
- }
|
|
|
- String routingMerNo = account.getSellerNo();
|
|
|
- BigDecimal HasRouting = account.getHasRouting().add(order.getAmount());
|
|
|
- account.setHasRouting(HasRouting);
|
|
|
-
|
|
|
- List<Map> tempRoutingList = new ArrayList();
|
|
|
- if (branchId.equals(0)) {
|
|
|
- Map<String, Object> routingList = new HashMap<>();
|
|
|
- routingList.put("routingMerNo", routingMerNo);//分佣账户
|
|
|
- routingList.put("routingFee", amount); //分佣金额
|
|
|
- tempRoutingList.add(routingList);
|
|
|
- }
|
|
|
+ order.setAccount(routingAccount.getSellerNo());
|
|
|
+ order.setUAccount(routingAccount.getId().toString());
|
|
|
|
|
|
- order.setUAccount(account.getId().toString());
|
|
|
- order.setAccount(routingMerNo);
|
|
|
|
|
|
//1、插入订单
|
|
|
orderService.insert(order);
|
|
@@ -165,32 +148,13 @@ public class YqPayController extends BaseController {
|
|
|
courseGroupInfo.setRegNum(courseGroupInfo.getRegNum() + 1);
|
|
|
CourseGroupInfoService.upByIdAndVersion(courseGroupInfo);
|
|
|
//3、修改分佣账户已收金额
|
|
|
- accountService.upByIdAndVersion(account);
|
|
|
-
|
|
|
-
|
|
|
- /*订单信息*/
|
|
|
- String orderBody = "大雅乐盟培训课程";
|
|
|
- /*订单标题*/
|
|
|
- String orderSubject = "培训订单";
|
|
|
-
|
|
|
+ BigDecimal HasRouting = routingAccount.getHasRouting().add(order.getAmount());
|
|
|
+ routingAccount.setHasRouting(HasRouting);
|
|
|
+ accountService.upByIdAndVersion(routingAccount);
|
|
|
|
|
|
- order.setAmount(new BigDecimal("2")); //测试设置金额
|
|
|
+ order.setAmount(new BigDecimal("2")); //测试账户设置金额
|
|
|
|
|
|
- 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); //前台页面地址
|
|
|
- if (branchId.equals(0)) {
|
|
|
- resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
|
|
|
- }
|
|
|
- Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
- rqMap.put("host", payUrl);
|
|
|
+ Map rqMap = orderService.getPayMap(routingAccount, order, school); //获取支付map
|
|
|
|
|
|
return succeed(rqMap);
|
|
|
}
|
|
@@ -224,8 +188,8 @@ public class YqPayController extends BaseController {
|
|
|
|
|
|
//classType 小课1 大课2
|
|
|
Integer buyCount = mecCourse4json.getBuyCount();
|
|
|
- if (buyCount <= 0) {
|
|
|
- return failed("购买次数不能小于1");
|
|
|
+ if (buyCount <= 0 || buyCount > 20) {
|
|
|
+ return failed("购买课程次数不能小于1,大于20");
|
|
|
}
|
|
|
BigDecimal amount = new BigDecimal("0"); //课程总价
|
|
|
String remark = "";
|
|
@@ -244,68 +208,18 @@ public class YqPayController extends BaseController {
|
|
|
}
|
|
|
if (pickCourses.size() == 0) {
|
|
|
return failed("请选择续费课程");
|
|
|
- }
|
|
|
-
|
|
|
- School school = schoolService.get(pickCourses.get(0).getClassId());
|
|
|
- if (school == null) {
|
|
|
- return failed("报名学校不存在");
|
|
|
- }
|
|
|
- String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
|
|
|
- String returnUrl = "http://pay.dayaedu.com/#/login?schoolId=" + school.getSchoolId() + "&classId=" + pickCourses.get(0).getClassId() + "&cityId=" + school.getCityId();//支付后返回页面
|
|
|
- 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(); //自己系统订单号
|
|
|
+ //获取分佣账户
|
|
|
+ Integer branchId = 1001;//order.getBranchId();
|
|
|
+ Account routingAccount = accountService.getRoutingAccount(branchId);
|
|
|
|
|
|
- //获取支付成功跟支付中的订单数
|
|
|
- Integer branchId = 1001;//renewals.getBranchId();
|
|
|
- int payOrderNums = orderService.getPayOrderNums();
|
|
|
- //分佣账户(1、每10笔,前四笔收入私户 2、私户每个商户最多收款400万)
|
|
|
- if ((payOrderNums + 1) % 10 <= 4) { //私人账户
|
|
|
- branchId = 0;
|
|
|
- }
|
|
|
+ Order order = renewalsService.addRenewalsOrder(renewals, amount, orderNo, pickCourses, routingAccount, remark);
|
|
|
|
|
|
- //获取分佣账户
|
|
|
- Account account = accountService.getAccountByBranchId(branchId);
|
|
|
- if (account == null) {
|
|
|
- return failed("机构没有设置收款账户");
|
|
|
- }
|
|
|
- String routingMerNo = account.getSellerNo();
|
|
|
- BigDecimal HasRouting = account.getHasRouting().add(amount);
|
|
|
- account.setHasRouting(HasRouting);
|
|
|
-
|
|
|
- List<Map> tempRoutingList = new ArrayList();
|
|
|
- if (branchId.equals(0)) {
|
|
|
- Map<String, Object> routingList = new HashMap<>();
|
|
|
- routingList.put("routingMerNo", routingMerNo);//分佣账户
|
|
|
- routingList.put("routingFee", amount); //分佣金额
|
|
|
- tempRoutingList.add(routingList);
|
|
|
- }
|
|
|
+ order.setAmount(new BigDecimal("2")); //测试账户设置金额
|
|
|
|
|
|
- renewalsService.addRenewalsOrder(renewals, amount, orderNo, pickCourses, routingMerNo, account.getId(), remark);
|
|
|
-
|
|
|
- /*订单信息*/
|
|
|
- String orderBody = "大雅乐盟培训课程";
|
|
|
- /*订单标题*/
|
|
|
- String orderSubject = "培训订单";
|
|
|
-
|
|
|
- //测试用
|
|
|
- amount = new BigDecimal("2");
|
|
|
- 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); //前台页面地址
|
|
|
- if (branchId.equals(0)) {
|
|
|
- resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
|
|
|
- }
|
|
|
- Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
- rqMap.put("host", payUrl);
|
|
|
+ Map rqMap = orderService.getPayMap(routingAccount, order, null); //获取支付map
|
|
|
return succeed(rqMap);
|
|
|
}
|
|
|
|
|
@@ -514,6 +428,9 @@ public class YqPayController extends BaseController {
|
|
|
public void updateOrder(Map<String, String> rpMap) {
|
|
|
int status = rpMap.get("tradeState").equals("1") ? 2 : 0;
|
|
|
Order order = orderService.getOrderByOrderNo(rpMap.get("merOrderNo"));
|
|
|
+ if (order == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
order.setStatus(status);
|
|
|
order.setBank(rpMap.get("channelType"));
|
|
|
|
|
@@ -524,11 +441,12 @@ public class YqPayController extends BaseController {
|
|
|
order.setPay(order.getAmount());
|
|
|
order.setPayTime(new Date());
|
|
|
//推送mec
|
|
|
+ ApplyInfo applyInfo = applyInfoService.get(order.getUserId());
|
|
|
if (order.getTuiFee() != null) { //乐团报名
|
|
|
- ApplyInfo applyInfo = applyInfoService.get(order.getUserId());
|
|
|
applyInfo.setStatus(1);
|
|
|
applyInfoService.update(applyInfo);
|
|
|
applyInfoService.userRegister(applyInfo.getPatriarchPhone(), order.getId()); //推送mec
|
|
|
+ schoolService.sendPayMsg(applyInfo.getPatriarchPhone(), order.getAmount().toString());
|
|
|
} else {
|
|
|
Renewals renewals = renewalsService.getRenewalsByOrderId(order.getId());
|
|
|
RenewBean renewBean = new RenewBean();
|