|
@@ -1,7 +1,10 @@
|
|
|
package com.ym.mec.collectfee.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.ym.mec.collectfee.common.web.BaseController;
|
|
|
+import com.ym.mec.collectfee.entity.Account;
|
|
|
import com.ym.mec.collectfee.entity.Order;
|
|
|
+import com.ym.mec.collectfee.service.AccountService;
|
|
|
import com.ym.mec.collectfee.service.OrderService;
|
|
|
import com.ym.mec.collectfee.service.YqPayService;
|
|
|
import com.ym.mec.collectfee.service.YqQueryService;
|
|
@@ -12,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
@@ -20,16 +24,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
|
|
|
-@Api(description = "支付")
|
|
|
+@Api("支付")
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
-@RequestMapping("yqPay")
|
|
|
-@ApiIgnore
|
|
|
-public class YqPayController {
|
|
|
+@RequestMapping("yqpay")
|
|
|
+public class YqPayController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
@Lazy
|
|
@@ -39,6 +41,8 @@ public class YqPayController {
|
|
|
private YqQueryService yqQueryService;
|
|
|
@Autowired
|
|
|
private OrderService orderService;
|
|
|
+ @Autowired
|
|
|
+ private AccountService accountService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -50,51 +54,56 @@ public class YqPayController {
|
|
|
@ApiOperation(value = "提交支付", notes = "易乾支付统一下单")
|
|
|
@PostMapping("/toPay")
|
|
|
@Transactional
|
|
|
- public Msg toPay(@ModelAttribute @Validated Order order) throws Exception {
|
|
|
- String orderNo = GenerateNum.getInstance().GenerateOrderNo();
|
|
|
+ public Map toPay(@ModelAttribute @Validated Order order) throws Exception {
|
|
|
+
|
|
|
+ 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);
|
|
|
+ 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();
|
|
|
+
|
|
|
+ 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);
|
|
|
|
|
|
- /*卖家双乾商户号*/
|
|
|
- String sellerNo = "0022652"; //某笔定义到某个商户
|
|
|
- order.setAccount(sellerNo);
|
|
|
- Long id = orderService.insert(order);
|
|
|
/*订单信息*/
|
|
|
String orderBody = "大雅乐盟培训课程";
|
|
|
/*订单标题*/
|
|
|
String orderSubject = "培训订单";
|
|
|
- /*商品列表信息*/
|
|
|
- String goodsDetail = "";
|
|
|
|
|
|
- String notifyUrl = "http://47.99.212.176:9000/yqpay/notify";
|
|
|
- String returnUrl = "http://47.99.212.176:9000/yqpay/notify";//前台页面通知地址(银联H5必填)
|
|
|
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
|
|
|
- resultMap.put("sellerNo", sellerNo); //收款商户号
|
|
|
- resultMap.put("payChannels", order.getBank()); //支付方式(支付渠道)
|
|
|
+ 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); //前台页面通知地址(银联H5必填)
|
|
|
- resultMap.put("mchAppId", returnUrl); //填网站首页地址(银联H5必填)
|
|
|
- resultMap.put("mchAppName", returnUrl); //传wap网站名(银联H5必填)
|
|
|
- resultMap.put("deviceInfo", "AND_WAP"); //设置信息(银联H5必填)
|
|
|
- resultMap.put("clientIp", "27.18.213.149"); //客户端ip地址(银联H5必填)
|
|
|
- resultMap.put("goodsDetail", goodsDetail);
|
|
|
- Map<String, Object> requestMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
- Msg msg = yqPayService.toPay(requestMap);
|
|
|
- if (!msg.getResponseParameters().isEmpty()) {
|
|
|
- RspMsg rspMsg = JSON.parseObject(msg.getResponseParameters(), RspMsg.class);
|
|
|
- String merOrderNo = rspMsg.getMerOrderNo();
|
|
|
- order.setId(id.intValue());
|
|
|
- order.setPayId(merOrderNo); //乾易付订单号
|
|
|
- orderService.update(order);
|
|
|
- }
|
|
|
- return msg;
|
|
|
+ resultMap.put("returnUrl", returnUrl); //前台页面地址
|
|
|
+ resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
|
|
|
+ Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
|
|
|
+ rqMap.put("host", payUrl);
|
|
|
+ return rqMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -104,7 +113,8 @@ public class YqPayController {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- @PostMapping("/query")
|
|
|
+ //@PostMapping("/query")
|
|
|
+ //@Scheduled(cron = "0/3 40 11 * * ?")
|
|
|
public String query(String merOrderNoList) throws Exception {
|
|
|
String notifyUrl = ""; //回调地址
|
|
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
@@ -167,6 +177,7 @@ public class YqPayController {
|
|
|
|
|
|
/**
|
|
|
* 提现短信
|
|
|
+ *
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
@@ -187,6 +198,7 @@ public class YqPayController {
|
|
|
|
|
|
/**
|
|
|
* 提现
|
|
|
+ *
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
@@ -242,7 +254,7 @@ public class YqPayController {
|
|
|
if (order.getOrderNo().isEmpty()) {
|
|
|
order.setPayId(notifyMsg.getOrderNo()); //更新易乾付订单号
|
|
|
}
|
|
|
- if(status == 0){
|
|
|
+ if (status == 0) {
|
|
|
order.setPay(notifyMsg.getPayAmount());
|
|
|
order.setPayTime(new Date());
|
|
|
}
|