소스 검색

增加生成文档注解

周箭河 5 년 전
부모
커밋
26630ae69a

+ 51 - 39
src/main/java/com/ym/mec/collectfee/controller/YqPayController.java

@@ -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());
             }

+ 58 - 2
src/main/java/com/ym/mec/collectfee/controller/YqRegController.java

@@ -1,21 +1,32 @@
 package com.ym.mec.collectfee.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.ym.mec.collectfee.entity.Order;
+import com.ym.mec.collectfee.service.OrderService;
 import com.ym.mec.collectfee.utils.GenerateNum;
 import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
+import org.apache.http.impl.auth.GGSSchemeBase;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import springfox.documentation.annotations.ApiIgnore;
 
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
 
 @ApiIgnore
 @Controller
 @RequestMapping("yqreg")
 public class YqRegController {
 
+    @Autowired
+    private OrderService orderService;
+
     /**
      * 用户(商户)注册
      *
@@ -75,4 +86,49 @@ public class YqRegController {
         return "/reg/register";
     }
 
+    @RequestMapping("/topay")
+    public String toPay(ModelMap map) throws Exception {
+
+        String orderNo = GenerateNum.getInstance().GenerateOrderNo();
+        Order order = new Order();
+        order.setOrderNo(orderNo);
+        order.setCreateTime(new Date());
+        order.setStatus(1);
+        order.setAmount(new BigDecimal(3));
+
+        /*卖家双乾商户号*/
+        String sellerNo = "0021677"; //大雅主体商户号
+        order.setAccount(sellerNo);
+        /*订单信息*/
+        String orderBody = "大雅乐盟培训课程";
+        /*订单标题*/
+        String orderSubject = "培训订单";
+
+        String notifyUrl = "http://47.99.212.176:9000/yqpay/notify";
+        String returnUrl = "http://dev.dayaedu.com";//前台页面通知地址(银联H5必填)
+        String payChannels = "{\"fastpayXy\":true,\"weChatPay\":true,\"weChatPayMobile\":false,\"aliPay\":true,\"aliPayMobile\":true,\"balancePay\":false}";
+
+
+        Map<String, Object> routingList = new LinkedHashMap<String, Object>();
+        routingList.put("routingMerNo", "0022652"); //分佣账户
+        routingList.put("routingFee", "0.1"); //分佣金额
+        List<Map> tempRoutingList = new ArrayList();
+        tempRoutingList.add(routingList);
+
+        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
+        resultMap.put("sellerNo", sellerNo); //收款商户号
+        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();
+        map.put("info", rqMap);
+        return "/reg/order";
+    }
+
 }

+ 5 - 1
src/main/resources/config/mybatis/OrderMapper.xml

@@ -50,7 +50,7 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
 		</selectKey>
 		-->
-		INSERT INTO `order` (tui_fee,goods_fee,sd_name,sd_fee,id,oid,order_no,user_id,amount,pay,bank,account,u_account,pay_id,pay_time,remark,class_id,status,create_time,po_name,voicy_part,balance,batch_num) VALUES(#{tuiFee},#{goodsFee},#{sdName},#{seFee},#{id},#{oid},#{orderNo},#{userId},#{amount},#{pay},#{bank},#{account},#{uAccount},#{payId},#{payTime},#{remark},#{classId},#{status},#{createTime},#{poName},#{voicyPart},#{balance},#{batchNum})
+		INSERT INTO `order` (id,oid,order_no,branch_id,user_id,amount,pay,bank,account,u_account,pay_id,pay_time,remark,class_id,status,create_time,po_name,voicy_part,balance,batch_num) VALUES(#{id},#{oid},#{branchId},#{orderNo},#{userId},#{amount},#{pay},#{bank},#{account},#{uAccount},#{payId},#{payTime},#{remark},#{classId},#{status},#{createTime},#{poName},#{voicyPart},#{balance},#{batchNum})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -91,4 +91,8 @@
     <select id="findOrderByStatus" resultType="com.ym.mec.collectfee.entity.Order">
 		SELECT * FROM `order` WHERE user_id = #{userId} AND status = #{status}
 	</select>
+	<!-- 获取支付中和成功的订单数-->
+	<select id="getPayOrderNums" resultType="java.lang.Integer">
+		SELECT COUNT(*) FROM `order` WHERE status >= 1
+	</select>
 </mapper>