|
@@ -2,6 +2,7 @@ package com.ym.mec.collectfee.controller;
|
|
|
|
|
|
import com.alibaba.druid.sql.visitor.functions.Now;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.collectfee.common.sms.SmsExample;
|
|
|
import com.ym.mec.collectfee.common.web.BaseController;
|
|
@@ -185,15 +186,15 @@ public class YqPayController extends BaseController {
|
|
|
Map rqMap = orderService.getPayMap(routingAccount, order, school); //获取支付map
|
|
|
|
|
|
//订单金额为0,直接成功
|
|
|
- if(order.getAmount().compareTo(new BigDecimal("0")) <= 0){
|
|
|
+ if (order.getAmount().compareTo(new BigDecimal("0")) <= 0) {
|
|
|
HashMap<String, String> notifyMap = new HashMap<>();
|
|
|
- notifyMap.put("tradeState","1");
|
|
|
- notifyMap.put("merOrderNo",order.getOrderNo());
|
|
|
- notifyMap.put("channelType","10");
|
|
|
- notifyMap.put("orderNo","");
|
|
|
- notifyMap.put("totalMoney","0");
|
|
|
+ notifyMap.put("tradeState", "1");
|
|
|
+ notifyMap.put("merOrderNo", order.getOrderNo());
|
|
|
+ notifyMap.put("channelType", "10");
|
|
|
+ notifyMap.put("orderNo", "");
|
|
|
+ notifyMap.put("totalMoney", "0");
|
|
|
this.updateOrder(notifyMap);
|
|
|
- return failed(HttpStatus.CREATED,"恭喜您,报名成功!");
|
|
|
+ return failed(HttpStatus.CREATED, "恭喜您,报名成功!");
|
|
|
}
|
|
|
|
|
|
return succeed(rqMap);
|
|
@@ -611,7 +612,20 @@ public class YqPayController extends BaseController {
|
|
|
if (order.getTuiFee() != null) { //乐团报名
|
|
|
applyInfoService.userRegister(applyInfo.getPatriarchPhone(), order.getId()); //推送mec
|
|
|
schoolService.sendPayMsg(applyInfo.getPatriarchPhone(), order.getAmount().toString());
|
|
|
- } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (order.getPromotionType().equals(1)) {
|
|
|
+ RenewBean renewBean = new RenewBean();
|
|
|
+ renewBean.setUserId(order.getUserId());
|
|
|
+ renewBean.setType(101);
|
|
|
+ renewBean.setIn(order.getAmount());
|
|
|
+ renewBean.setOut(new BigDecimal(0));
|
|
|
+ renewBean.setWay(30);
|
|
|
+ applyInfoService.pushRenew(renewBean);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (order.getType() != null && order.getType() == 3) {
|
|
|
Renewals renewals = renewalsService.getRenewalsByOrderId(order.getId());
|
|
|
RenewBean renewBean = new RenewBean();
|
|
|
// renewBean.setUserId(renewals.getUserId());
|
|
@@ -626,9 +640,7 @@ public class YqPayController extends BaseController {
|
|
|
renewBean.setIn(renewals.getPay());
|
|
|
renewBean.setOut(new BigDecimal(0));
|
|
|
renewBean.setWay(renewals.getWay());
|
|
|
- if(order.getType()!= null && order.getType()==3){
|
|
|
- applyInfoService.pushRenew(renewBean);
|
|
|
- }
|
|
|
+ applyInfoService.pushRenew(renewBean);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -668,9 +680,9 @@ public class YqPayController extends BaseController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 续费支付
|
|
|
+ * 双11活动小课续费支付
|
|
|
*
|
|
|
* @return String
|
|
|
* @throws Exception
|
|
@@ -678,21 +690,53 @@ public class YqPayController extends BaseController {
|
|
|
// @ApiOperation(value = "续费支付", notes = "续费支付")
|
|
|
@PostMapping("/promotionPay")
|
|
|
public Object promotionPay(@ModelAttribute @Validated Renewals renewals) throws Exception {
|
|
|
-// MecUser mecUser = applyInfoService.findMecUser(renewals.getUserId());
|
|
|
-// if (mecUser == null) {
|
|
|
-// return failed("续费用户不存在");
|
|
|
-// }
|
|
|
-// renewals.setBranchId(mecUser.getBranchId());
|
|
|
-//
|
|
|
-// String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
|
-// //获取分佣账户
|
|
|
-// Integer branchId = 1002;//默认分佣账户;
|
|
|
-// Account routingAccount = accountService.getRoutingAccount(branchId, amount);
|
|
|
-//
|
|
|
-// Order order = renewalsService.addRenewalsOrder(renewals, amount, orderNo, pickCourses, routingAccount, remark);
|
|
|
-//
|
|
|
-// Map rqMap = orderService.getPayMap(routingAccount, order, null); //获取支付map
|
|
|
-// return succeed(rqMap);
|
|
|
- return null;
|
|
|
+ MecUser mecUser = applyInfoService.findMecUser(renewals.getUserId());
|
|
|
+ if (mecUser == null) {
|
|
|
+ return failed("续费用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("branchRule.json"); //规则json
|
|
|
+ String branchRuleJson = IOUtils.toString(new InputStreamReader(classPathResource.getInputStream(), "UTF-8"));
|
|
|
+ List<BranchRule> branchRules = JSONArray.parseObject(branchRuleJson, List.class);
|
|
|
+
|
|
|
+ BigDecimal amount = new BigDecimal("0");
|
|
|
+ for (BranchRule branchRule : branchRules) {
|
|
|
+ if (!branchRule.getBranchId().equals(mecUser.getBranchId())) continue;
|
|
|
+ amount = branchRule.getBranchPrice();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!amount.equals(renewals.getPay())) {
|
|
|
+ return failed("金额有误!请勿非法请求");
|
|
|
+ }
|
|
|
+ if (amount.equals(new BigDecimal(0))) {
|
|
|
+ return failed("分部没有相应的活动");
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderNo = GenerateNum.getInstance().GenerateOrderNo(); //自己系统订单号
|
|
|
+
|
|
|
+ //获取分佣账户
|
|
|
+ Integer branchId = 1002;//默认分佣账户;
|
|
|
+ Account routingAccount = accountService.getRoutingAccount(branchId, amount);
|
|
|
+
|
|
|
+ Order order = renewalsService.promotionPay(mecUser, amount, orderNo, routingAccount);
|
|
|
+
|
|
|
+ Map rqMap = orderService.getPayMap(routingAccount, order, null); //获取支付map
|
|
|
+ return succeed(rqMap);
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/getPayStatus")
|
|
|
+ public Object getPayStatus(String orderNo) throws Exception {
|
|
|
+ Order order = orderService.getOrderStatusByOrderNo(orderNo);
|
|
|
+ if(order == null){
|
|
|
+ return failed("订单信息不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus().equals(2)){
|
|
|
+ return succeed("SUCCESS");
|
|
|
+ }
|
|
|
+ if(order.getStatus().equals(1)){
|
|
|
+ return succeed("ING");
|
|
|
+ }
|
|
|
+ return succeed("FAIL");
|
|
|
+ }
|
|
|
+
|
|
|
}
|