Browse Source

增加乐器采购清单确认接口

周箭河 5 years ago
parent
commit
b5baae0c2f

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRechargeServiceImpl.java

@@ -120,7 +120,7 @@ public class StudentRechargeServiceImpl extends BaseServiceImpl<String, StudentR
 
 				if ("WXPay".equals(paymentChannel)) {
 					transType = TransTypeEnum.WECHAT;
-				} else if ("Alipay 2.0".equals(paymentChannel)) {
+				} else if ("Alipay".equals(paymentChannel)) {
 					transType = TransTypeEnum.ALIPAY;
 				}
 

+ 15 - 10
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
+
 import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.*;
@@ -112,10 +113,11 @@ public class StudentOrderController extends BaseController {
         //支付中订单存在,更新状态
         if (msg.getResponseType().equals("1") && notifyMap.size() > 0) {
             String tradeState = msg.getCode().equals("88") ? "1" : "0";
+            String channelType = notifyMap.get("channelType").equals("1") ? "WXPay" : (notifyMap.get("channelType").equals("2")?"Alipay":"quickPay");
             notifyMap.put("tradeState", tradeState);
             notifyMap.put("totalMoney", notifyMap.get("payAmount"));
             notifyMap.put("merOrderNo", notifyMap.get("merMerOrderNo"));
-            notifyMap.put("channelType", notifyMap.get("channelType"));
+            notifyMap.put("channelType", channelType);
             updateOrder(notifyMap);
             msg.setCode("000000");
             msg.setMsg("success");
@@ -144,7 +146,7 @@ public class StudentOrderController extends BaseController {
             @ApiImplicitParam(name = "orderNo", value = "订单号", required = true, dataType = "String"),
             @ApiImplicitParam(name = "payChannel", value = "支付方式(alipay-支付宝app支付)", required = true, dataType = "String"),
     })
-    public Object executePayment(BigDecimal amount, String orderNo, String payChannel, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sign,String code) throws Exception {
+    public Object executePayment(BigDecimal amount, String orderNo, String payChannel, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sign, String code) throws Exception {
         String appId = "wxcf8e8b33a9477845";
         String appSecret = "1286452b9c68b13325dece7cdf892645";
         String wxMpOAuth2AccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
@@ -153,25 +155,25 @@ public class StudentOrderController extends BaseController {
 //            return failed("签名验证失败");
 //        }
 
-        String openid="";
-        if(payChannel=="wx_pub"){
-            if(code==null || code.isEmpty()){
+        String openid = "";
+        if (payChannel == "wx_pub") {
+            if (code == null || code.isEmpty()) {
                 return failed("微信支付请先授权");
             }
             wxMpOAuth2AccessTokenUrl = String.format(wxMpOAuth2AccessTokenUrl, appId, appSecret, code);
             Map<String, String> weChatRes = JSON.parseObject(HttpUtil.get(wxMpOAuth2AccessTokenUrl, new HashMap<>()), Map.class);
-            if(!weChatRes.containsKey("openid")){
+            if (!weChatRes.containsKey("openid")) {
                 return failed("授权失败,请重新授权");
             }
             openid = weChatRes.get("openid");
         }
 
         StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
-        if(order == null){
+        if (order == null) {
             return failed("订单不存在");
         }
 
-        Payment payment = new Pay().executePayment(amount, orderNo, payChannel, orderSubject, orderBody,code);
+        Payment payment = new Pay().executePayment(amount, orderNo, payChannel, orderSubject, orderBody, code);
         order.setTransNo(payment.getId());
         studentPaymentOrderService.update(order);
 
@@ -213,6 +215,9 @@ public class StudentOrderController extends BaseController {
             List<Map<String, String>> responseList = JSON.parseObject(responseParameters, List.class);
             for (Map<String, String> response : responseList) {
                 Map<String, String> rpMap = response;
+                String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2")?"Alipay":"quickPay");
+                rpMap.put("channelType",channelType);
+
                 if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
                     updateOrder(rpMap); //更新订单
                 }
@@ -273,7 +278,7 @@ public class StudentOrderController extends BaseController {
 
     }
 
-   // @Scheduled(cron = "0/5 * * * * ?")
+    // @Scheduled(cron = "0/5 * * * * ?")
     public void adaPayQuery() throws Exception {
         List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "ADAPAY");
 
@@ -349,7 +354,7 @@ public class StudentOrderController extends BaseController {
 
         Map<String, String> map = JSON.parseObject(HttpUtil.get(wxMpOAuth2AccessTokenUrl, new HashMap<>()), Map.class);
 
-        if(!map.containsKey("openid")){
+        if (!map.containsKey("openid")) {
             return failed("授权失败,请重新授权");
         }