Showing
8 changed files
with
137 additions
and
90 deletions
1 | package com.cjs.site.action.user.fund; | 1 | package com.cjs.site.action.user.fund; |
2 | 2 | ||
3 | import com.cjs.site.biz.user.pick.PickPayBiz; | 3 | import com.cjs.site.biz.user.pick.PickPayBiz; |
4 | +import com.cjs.site.model.union.QueryBill; | ||
5 | +import com.cjs.site.model.union.UnionResponse; | ||
6 | +import com.cjs.site.util.lang.DateEnum; | ||
7 | +import com.cjs.site.util.lang.DateUtil; | ||
4 | import com.cjs.site.util.lang.JsonUtil; | 8 | import com.cjs.site.util.lang.JsonUtil; |
9 | +import com.cjs.site.util.union.UnionConstants; | ||
5 | import com.cjs.site.util.union.UnionPayUtil; | 10 | import com.cjs.site.util.union.UnionPayUtil; |
6 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
7 | import org.springframework.stereotype.Controller; | 12 | import org.springframework.stereotype.Controller; |
8 | -import org.springframework.web.bind.annotation.RequestBody; | 13 | +import org.springframework.web.bind.annotation.*; |
9 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
10 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
11 | -import org.springframework.web.bind.annotation.ResponseBody; | ||
12 | 14 | ||
13 | import javax.servlet.http.HttpServletRequest; | 15 | import javax.servlet.http.HttpServletRequest; |
14 | import javax.servlet.http.HttpSession; | 16 | import javax.servlet.http.HttpSession; |
17 | +import java.util.HashMap; | ||
15 | import java.util.Map; | 18 | import java.util.Map; |
16 | 19 | ||
17 | /** | 20 | /** |
18 | * Created by bruce on 2019-05-14 13:41 | 21 | * Created by bruce on 2019-05-14 13:41 |
19 | */ | 22 | */ |
20 | @Controller | 23 | @Controller |
21 | -@RequestMapping("/pick/pay") | 24 | +@RequestMapping("/pick/unionPay") |
22 | public class PickPayAction { | 25 | public class PickPayAction { |
23 | 26 | ||
24 | @Autowired | 27 | @Autowired |
25 | private PickPayBiz pickPayBiz; | 28 | private PickPayBiz pickPayBiz; |
26 | 29 | ||
27 | //创建订单 | 30 | //创建订单 |
28 | - @RequestMapping(value = "/createOrder", method = RequestMethod.GET) | 31 | + @RequestMapping(value = "createOrder", method = RequestMethod.GET) |
29 | @ResponseBody | 32 | @ResponseBody |
30 | public Object createOrder(HttpSession session) { | 33 | public Object createOrder(HttpSession session) { |
31 | return pickPayBiz.createOrder(session); | 34 | return pickPayBiz.createOrder(session); |
... | @@ -35,21 +38,29 @@ public class PickPayAction { | ... | @@ -35,21 +38,29 @@ public class PickPayAction { |
35 | @RequestMapping(value = "notify", method = RequestMethod.POST) | 38 | @RequestMapping(value = "notify", method = RequestMethod.POST) |
36 | @ResponseBody | 39 | @ResponseBody |
37 | public String notify(HttpServletRequest request) { | 40 | public String notify(HttpServletRequest request) { |
38 | - Map<String,String> params = UnionPayUtil.getRequestParams(request); | 41 | + Map<String, String> params = UnionPayUtil.getRequestParams(request); |
39 | - System.out.println("银联支付推送回调参数:"+JsonUtil.toJson(params)); | 42 | + System.out.println("银联支付推送回调参数:" + JsonUtil.toJson(params)); |
40 | - if (pickPayBiz.isValidNotify(params)){ | 43 | + if (pickPayBiz.isValidNotify(params)) { |
41 | return "SUCCESS"; | 44 | return "SUCCESS"; |
42 | } | 45 | } |
43 | return "FAILED"; | 46 | return "FAILED"; |
44 | } | 47 | } |
45 | 48 | ||
46 | - @RequestMapping(value = "test", method = RequestMethod.POST) | 49 | + @RequestMapping(value = "query", method = RequestMethod.GET) |
47 | @ResponseBody | 50 | @ResponseBody |
48 | - public String notify(@RequestBody Map<String,String> params) { | 51 | + public Object returnPage(String billNo) { |
49 | - if (pickPayBiz.isValidNotify(params)){ | 52 | + QueryBill queryBill = new QueryBill(); |
50 | - return "SUCCESS"; | 53 | + queryBill.setBillDate(DateUtil.getNow(DateEnum.DATE)); |
51 | - } | 54 | + queryBill.setRequestTimestamp(DateUtil.getNow()); |
52 | - return "FAILED"; | 55 | + queryBill.setBillNo(billNo); |
56 | + @SuppressWarnings("unchecked") | ||
57 | + Map<String, String> params = JsonUtil.fromJson(JsonUtil.toJson(queryBill), Map.class); | ||
58 | + String result = UnionPayUtil.sendPost(UnionConstants.CREATE_ORDER, params); | ||
59 | + UnionResponse response = JsonUtil.fromJson(result, UnionResponse.class); | ||
60 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
61 | + map.put("status", response.getBillStatus()); | ||
62 | + map.put("code", response.getErrCode()); | ||
63 | + return map; | ||
53 | } | 64 | } |
54 | 65 | ||
55 | } | 66 | } | ... | ... |
... | @@ -76,6 +76,7 @@ public class PickPayBiz { | ... | @@ -76,6 +76,7 @@ public class PickPayBiz { |
76 | UnionResponse response = JsonUtil.fromJson(json, UnionResponse.class); | 76 | UnionResponse response = JsonUtil.fromJson(json, UnionResponse.class); |
77 | if (response != null && response.getErrCode().equals(UnionConstants.SUCCESS_CODE)) { | 77 | if (response != null && response.getErrCode().equals(UnionConstants.SUCCESS_CODE)) { |
78 | result.put("qrCode", UnionPayUtil.createQrCode(createQrCode.getQrCodeId())); | 78 | result.put("qrCode", UnionPayUtil.createQrCode(createQrCode.getQrCodeId())); |
79 | + result.put("billNo", createQrCode.getBillNo()); | ||
79 | insertPickPay(userId, createQrCode.getBillNo(), createQrCode.getSrcReserve(),totalAmount.toString(),DateUtil.getTrustCycle()); | 80 | insertPickPay(userId, createQrCode.getBillNo(), createQrCode.getSrcReserve(),totalAmount.toString(),DateUtil.getTrustCycle()); |
80 | } else { | 81 | } else { |
81 | result.put("code", false); | 82 | result.put("code", false); | ... | ... |
1 | +package com.cjs.site.model.union; | ||
2 | + | ||
3 | +import com.cjs.site.util.union.UnionConstants; | ||
4 | + | ||
5 | +import java.io.Serializable; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by bruce on 2019-05-27 9:50 | ||
9 | + */ | ||
10 | +public class BaseRequest implements Serializable { | ||
11 | + | ||
12 | + private static final long serialVersionUID = 6996666421495567155L; | ||
13 | + | ||
14 | + private String msgSrc = "WWW.TEST.COM"; | ||
15 | + private String requestTimestamp; | ||
16 | + private String mid = UnionConstants.MID; | ||
17 | + private String tid = UnionConstants.TID; | ||
18 | + private String instMid = "QRPAYDEFAULT"; | ||
19 | + private String billNo; | ||
20 | + private String billDate; | ||
21 | + | ||
22 | + public String getMsgSrc() { | ||
23 | + return msgSrc; | ||
24 | + } | ||
25 | + | ||
26 | + public void setMsgSrc(String msgSrc) { | ||
27 | + this.msgSrc = msgSrc; | ||
28 | + } | ||
29 | + | ||
30 | + public String getRequestTimestamp() { | ||
31 | + return requestTimestamp; | ||
32 | + } | ||
33 | + | ||
34 | + public void setRequestTimestamp(String requestTimestamp) { | ||
35 | + this.requestTimestamp = requestTimestamp; | ||
36 | + } | ||
37 | + | ||
38 | + public String getMid() { | ||
39 | + return mid; | ||
40 | + } | ||
41 | + | ||
42 | + public void setMid(String mid) { | ||
43 | + this.mid = mid; | ||
44 | + } | ||
45 | + | ||
46 | + public String getTid() { | ||
47 | + return tid; | ||
48 | + } | ||
49 | + | ||
50 | + public void setTid(String tid) { | ||
51 | + this.tid = tid; | ||
52 | + } | ||
53 | + | ||
54 | + public String getInstMid() { | ||
55 | + return instMid; | ||
56 | + } | ||
57 | + | ||
58 | + public void setInstMid(String instMid) { | ||
59 | + this.instMid = instMid; | ||
60 | + } | ||
61 | + | ||
62 | + public String getBillNo() { | ||
63 | + return billNo; | ||
64 | + } | ||
65 | + | ||
66 | + public void setBillNo(String billNo) { | ||
67 | + this.billNo = billNo; | ||
68 | + } | ||
69 | + | ||
70 | + public String getBillDate() { | ||
71 | + return billDate; | ||
72 | + } | ||
73 | + | ||
74 | + public void setBillDate(String billDate) { | ||
75 | + this.billDate = billDate; | ||
76 | + } | ||
77 | +} |
... | @@ -7,31 +7,15 @@ import java.io.Serializable; | ... | @@ -7,31 +7,15 @@ import java.io.Serializable; |
7 | /** | 7 | /** |
8 | * Created by bruce on 2019-05-14 11:00 | 8 | * Created by bruce on 2019-05-14 11:00 |
9 | */ | 9 | */ |
10 | -public class CreateQrCode implements Serializable { | 10 | +public class CreateQrCode extends BaseRequest implements Serializable { |
11 | 11 | ||
12 | private static final long serialVersionUID = 4945657951041450816L; | 12 | private static final long serialVersionUID = 4945657951041450816L; |
13 | 13 | ||
14 | - private String msgSrc = "WWW.TEST.COM"; | ||
15 | private String msgType = "bills.getQRCode"; | 14 | private String msgType = "bills.getQRCode"; |
16 | - private String requestTimestamp; | ||
17 | private String srcReserve; | 15 | private String srcReserve; |
18 | - private String mid = UnionConstants.MID; | ||
19 | - private String tid = UnionConstants.TID; | ||
20 | - private String instMid = "QRPAYDEFAULT"; | ||
21 | - private String billNo; | ||
22 | - private String billDate; | ||
23 | private String totalAmount; | 16 | private String totalAmount; |
24 | private String qrCodeId; | 17 | private String qrCodeId; |
25 | - private String returnUrl = UnionConstants.NOTIFY_DOMAIN + "/user/pick/record"; | 18 | + private String notifyUrl = UnionConstants.DOMAIN + "/pick/unionPay/notify"; |
26 | - private String notifyUrl = UnionConstants.NOTIFY_DOMAIN + "/pick/pay/notify"; | ||
27 | - | ||
28 | - public String getMsgSrc() { | ||
29 | - return msgSrc; | ||
30 | - } | ||
31 | - | ||
32 | - public void setMsgSrc(String msgSrc) { | ||
33 | - this.msgSrc = msgSrc; | ||
34 | - } | ||
35 | 19 | ||
36 | public String getMsgType() { | 20 | public String getMsgType() { |
37 | return msgType; | 21 | return msgType; |
... | @@ -41,14 +25,6 @@ public class CreateQrCode implements Serializable { | ... | @@ -41,14 +25,6 @@ public class CreateQrCode implements Serializable { |
41 | this.msgType = msgType; | 25 | this.msgType = msgType; |
42 | } | 26 | } |
43 | 27 | ||
44 | - public String getRequestTimestamp() { | ||
45 | - return requestTimestamp; | ||
46 | - } | ||
47 | - | ||
48 | - public void setRequestTimestamp(String requestTimestamp) { | ||
49 | - this.requestTimestamp = requestTimestamp; | ||
50 | - } | ||
51 | - | ||
52 | public String getSrcReserve() { | 28 | public String getSrcReserve() { |
53 | return srcReserve; | 29 | return srcReserve; |
54 | } | 30 | } |
... | @@ -57,46 +33,6 @@ public class CreateQrCode implements Serializable { | ... | @@ -57,46 +33,6 @@ public class CreateQrCode implements Serializable { |
57 | this.srcReserve = srcReserve; | 33 | this.srcReserve = srcReserve; |
58 | } | 34 | } |
59 | 35 | ||
60 | - public String getMid() { | ||
61 | - return mid; | ||
62 | - } | ||
63 | - | ||
64 | - public void setMid(String mid) { | ||
65 | - this.mid = mid; | ||
66 | - } | ||
67 | - | ||
68 | - public String getTid() { | ||
69 | - return tid; | ||
70 | - } | ||
71 | - | ||
72 | - public void setTid(String tid) { | ||
73 | - this.tid = tid; | ||
74 | - } | ||
75 | - | ||
76 | - public String getInstMid() { | ||
77 | - return instMid; | ||
78 | - } | ||
79 | - | ||
80 | - public void setInstMid(String instMid) { | ||
81 | - this.instMid = instMid; | ||
82 | - } | ||
83 | - | ||
84 | - public String getBillNo() { | ||
85 | - return billNo; | ||
86 | - } | ||
87 | - | ||
88 | - public void setBillNo(String billNo) { | ||
89 | - this.billNo = billNo; | ||
90 | - } | ||
91 | - | ||
92 | - public String getBillDate() { | ||
93 | - return billDate; | ||
94 | - } | ||
95 | - | ||
96 | - public void setBillDate(String billDate) { | ||
97 | - this.billDate = billDate; | ||
98 | - } | ||
99 | - | ||
100 | public String getTotalAmount() { | 36 | public String getTotalAmount() { |
101 | return totalAmount; | 37 | return totalAmount; |
102 | } | 38 | } |
... | @@ -113,14 +49,6 @@ public class CreateQrCode implements Serializable { | ... | @@ -113,14 +49,6 @@ public class CreateQrCode implements Serializable { |
113 | this.qrCodeId = qrCodeId; | 49 | this.qrCodeId = qrCodeId; |
114 | } | 50 | } |
115 | 51 | ||
116 | - public String getReturnUrl() { | ||
117 | - return returnUrl; | ||
118 | - } | ||
119 | - | ||
120 | - public void setReturnUrl(String returnUrl) { | ||
121 | - this.returnUrl = returnUrl; | ||
122 | - } | ||
123 | - | ||
124 | public String getNotifyUrl() { | 52 | public String getNotifyUrl() { |
125 | return notifyUrl; | 53 | return notifyUrl; |
126 | } | 54 | } | ... | ... |
1 | +package com.cjs.site.model.union; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-05-27 9:47 | ||
7 | + */ | ||
8 | +public class QueryBill extends BaseRequest implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = -7327860744879948066L; | ||
11 | + | ||
12 | + private String msgType = "bills.query"; | ||
13 | + | ||
14 | + public String getMsgType() { | ||
15 | + return msgType; | ||
16 | + } | ||
17 | + | ||
18 | + public void setMsgType(String msgType) { | ||
19 | + this.msgType = msgType; | ||
20 | + } | ||
21 | +} |
... | @@ -15,6 +15,7 @@ public class UnionResponse implements Serializable { | ... | @@ -15,6 +15,7 @@ public class UnionResponse implements Serializable { |
15 | private String responseTimestamp; | 15 | private String responseTimestamp; |
16 | private String srcReserve; | 16 | private String srcReserve; |
17 | private String sign; | 17 | private String sign; |
18 | + private String billStatus; | ||
18 | 19 | ||
19 | public String getErrCode() { | 20 | public String getErrCode() { |
20 | return errCode; | 21 | return errCode; |
... | @@ -63,4 +64,12 @@ public class UnionResponse implements Serializable { | ... | @@ -63,4 +64,12 @@ public class UnionResponse implements Serializable { |
63 | public void setSign(String sign) { | 64 | public void setSign(String sign) { |
64 | this.sign = sign; | 65 | this.sign = sign; |
65 | } | 66 | } |
67 | + | ||
68 | + public String getBillStatus() { | ||
69 | + return billStatus; | ||
70 | + } | ||
71 | + | ||
72 | + public void setBillStatus(String billStatus) { | ||
73 | + this.billStatus = billStatus; | ||
74 | + } | ||
66 | } | 75 | } | ... | ... |
... | @@ -42,6 +42,6 @@ public class UnionConstants { | ... | @@ -42,6 +42,6 @@ public class UnionConstants { |
42 | */ | 42 | */ |
43 | public static final String NOTIFY_PAY_STATUS = "PAID"; | 43 | public static final String NOTIFY_PAY_STATUS = "PAID"; |
44 | 44 | ||
45 | - public static final String NOTIFY_DOMAIN = "http://zyn.yocung.com"; | 45 | + public static final String DOMAIN = "http://zyn.yocung.com"; |
46 | 46 | ||
47 | } | 47 | } | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment