HeliPayNonOrderApi.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. package com.caimei365.order.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei365.order.model.ResponseJson;
  4. import com.caimei365.order.model.dto.HeliDto;
  5. import com.caimei365.order.model.dto.PayCouponDto;
  6. import com.caimei365.order.model.dto.PayVipDto;
  7. import com.caimei365.order.model.vo.NotifyResponseVo;
  8. import com.caimei365.order.model.vo.UnionResVo;
  9. import com.caimei365.order.service.HeliPayNonOrderService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.RequiredArgsConstructor;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.http.HttpHeaders;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.beans.IntrospectionException;
  17. import java.lang.reflect.InvocationTargetException;
  18. import java.security.NoSuchAlgorithmException;
  19. import java.security.spec.InvalidKeySpecException;
  20. /**
  21. * @author zzj
  22. * 合利宝非订单
  23. */
  24. @Api(tags = "其他(非订单)支付API")
  25. @RestController
  26. @RequiredArgsConstructor
  27. @RequestMapping("/order/pay")
  28. public class HeliPayNonOrderApi {
  29. private final HeliPayNonOrderService payNonOrderService;
  30. /**
  31. * 二手发布-微信线上支付
  32. *
  33. * @param heliDto {
  34. * productId 二手发布商品id
  35. * returnUrl 页面回调地址
  36. * code 微信小程序code
  37. * state 微信公众号state参数
  38. * }
  39. */
  40. @ApiOperation("二手发布-微信线上支付(旧:/PayOrder/appletsSecondHandPay)(/PayOrder/secondHandPay[WEIXIN])")
  41. @PostMapping("/second/wechat")
  42. public ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  43. if (StringUtils.isBlank(heliDto.getPayType())) {
  44. return ResponseJson.error("支付类型不能为空!", null);
  45. }
  46. if (null == heliDto.getProductId()) {
  47. return ResponseJson.error("二手商品Id不能为空!", null);
  48. }
  49. if (StringUtils.isEmpty(heliDto.getCode())) {
  50. return ResponseJson.error("微信code不能为空!", null);
  51. }
  52. return payNonOrderService.paySecondByWeChat(heliDto, headers);
  53. }
  54. /**
  55. * 二手发布-支付宝二维码
  56. *
  57. * @param heliDto {
  58. * productId 二手发布商品id
  59. * returnUrl 页面回调地址
  60. * }
  61. */
  62. @ApiOperation("二手发布-支付宝线上支付(旧:/PayOrder/secondHandPay[ALIPAY])")
  63. @PostMapping("/second/scan")
  64. public ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  65. if (StringUtils.isBlank(heliDto.getPayType())) {
  66. return ResponseJson.error("支付类型不能为空!", null);
  67. }
  68. if (null == heliDto.getProductId()) {
  69. return ResponseJson.error("二手商品Id不能为空!", null);
  70. }
  71. if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
  72. return ResponseJson.error("回调地址不能为空!", null);
  73. }
  74. return payNonOrderService.paySecondByAlipay(heliDto, headers);
  75. }
  76. /**
  77. * 二手发布-支付回调
  78. */
  79. @ApiOperation("二手发布-支付回调(旧:/PayOrder/secondHandPayCallBack)")
  80. @PostMapping("/second/callback")
  81. public String paymentSecondCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  82. if (null == res) {
  83. return "回调参数失败";
  84. }
  85. return payNonOrderService.paymentSecondCallback(res);
  86. }
  87. @ApiOperation("购买价值优惠券-获取购买记录id")
  88. @PostMapping("/coupon/record")
  89. public ResponseJson<PayCouponDto> payCouponGetRecord(PayCouponDto payCouponDto, @RequestHeader HttpHeaders headers) {
  90. if (null == payCouponDto.getCouponId()) {
  91. return ResponseJson.error("优惠券Id不能为空!", null);
  92. }
  93. if (null == payCouponDto.getUserId()) {
  94. return ResponseJson.error("userId不能为空!", null);
  95. }
  96. return payNonOrderService.getCouponRecord(payCouponDto, headers);
  97. }
  98. /**
  99. * 购买优惠券-查询是否购买成功
  100. */
  101. @ApiOperation("购买优惠券-查询是否购买成功")
  102. @GetMapping("/coupon/check")
  103. public ResponseJson couponCheck(Integer couponRecordId) {
  104. if (null == couponRecordId) {
  105. return ResponseJson.error("购买记录id不能为空!", null);
  106. }
  107. return payNonOrderService.couponCheck(couponRecordId);
  108. }
  109. /**
  110. * 购买优惠券-微信线上支付
  111. *
  112. * @param heliDto {
  113. * couponId 购买优惠券Id
  114. * userId userId
  115. * couponRecordId 购买记录id
  116. * returnUrl 页面回调地址
  117. * code 微信小程序code
  118. * state 微信公众号state参数
  119. * }
  120. */
  121. @ApiOperation("购买价值优惠券-微信支付")
  122. @PostMapping("/coupon/wechat")
  123. public ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  124. if (StringUtils.isBlank(heliDto.getPayType())) {
  125. return ResponseJson.error("支付类型不能为空!", null);
  126. }
  127. if (null == heliDto.getCouponRecordId()) {
  128. return ResponseJson.error("购买记录id不能为空!", null);
  129. }
  130. if (null == heliDto.getSource()) {
  131. return ResponseJson.error("领取渠道不能为空!", null);
  132. }
  133. if (null == heliDto.getCouponId()) {
  134. return ResponseJson.error("优惠券Id不能为空!", null);
  135. }
  136. if (null == heliDto.getUserId()) {
  137. return ResponseJson.error("userId不能为空!", null);
  138. }
  139. if (StringUtils.isEmpty(heliDto.getCode())) {
  140. return ResponseJson.error("微信code不能为空!", null);
  141. }
  142. return payNonOrderService.payCouponByWeChat(heliDto, headers);
  143. }
  144. @ApiOperation("购买价值优惠券-网银线上支付")
  145. @PostMapping("/coupon/union")
  146. public ResponseJson<String> payCouponByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  147. if (StringUtils.isBlank(heliDto.getPayType())) {
  148. return ResponseJson.error("支付类型不能为空!", null);
  149. }
  150. if (null == heliDto.getCouponRecordId()) {
  151. return ResponseJson.error("购买记录id不能为空!", null);
  152. }
  153. if (StringUtils.isEmpty(heliDto.getBankCode())) {
  154. return ResponseJson.error("银行编码不能为空!", null);
  155. }
  156. if (StringUtils.isEmpty(heliDto.getUserType())) {
  157. return ResponseJson.error("银行用户类型不能为空!", null);
  158. }
  159. if (null == heliDto.getSource()) {
  160. return ResponseJson.error("领取渠道不能为空!", null);
  161. }
  162. if (null == heliDto.getCouponId()) {
  163. return ResponseJson.error("优惠券Id不能为空!", null);
  164. }
  165. if (null == heliDto.getUserId()) {
  166. return ResponseJson.error("userId不能为空!", null);
  167. }
  168. return payNonOrderService.couponUnionPay(heliDto, headers);
  169. }
  170. /**
  171. * 购买价值优惠券-微信/支付宝二维码
  172. *
  173. * @param heliDto {
  174. * couponId 购买优惠券Id
  175. * userId userId
  176. * couponRecordId 购买记录id
  177. * returnUrl 页面回调地址
  178. * state 微信公众号state参数
  179. * }
  180. */
  181. @ApiOperation("购买价值优惠券-支付宝线上支付")
  182. @PostMapping("/coupon/scan")
  183. public ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  184. if (StringUtils.isBlank(heliDto.getPayType())) {
  185. return ResponseJson.error("支付类型不能为空!", null);
  186. }
  187. if (null == heliDto.getCouponRecordId()) {
  188. return ResponseJson.error("购买记录id不能为空!", null);
  189. }
  190. if (null == heliDto.getSource()) {
  191. return ResponseJson.error("领取渠道不能为空!", null);
  192. }
  193. if (null == heliDto.getCouponId()) {
  194. return ResponseJson.error("优惠券Id不能为空!", null);
  195. }
  196. if (null == heliDto.getUserId()) {
  197. return ResponseJson.error("userId不能为空!", null);
  198. }
  199. return payNonOrderService.payCouponByAlipay(heliDto, headers);
  200. }
  201. /**
  202. * 购买优惠券-支付回调
  203. */
  204. @ApiOperation("购买优惠券-支付回调")
  205. @GetMapping("/coupon/callback")
  206. public String couponCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  207. if (null == res) {
  208. return "回调参数失败";
  209. }
  210. return payNonOrderService.couponCallback(res);
  211. }
  212. /**
  213. * 二手发布-网银支付回调
  214. */
  215. @ApiOperation("二手发布-网银支付回调")
  216. @PostMapping("/second/callback/union")
  217. public String paymentSecondCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  218. if (null == res) {
  219. return "回调参数失败";
  220. }
  221. return payNonOrderService.unionSecondCallback(res);
  222. }
  223. @ApiOperation("升级超级会员-网银线上支付")
  224. @PostMapping("/vip/union")
  225. public ResponseJson<String> paySuperVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  226. if (StringUtils.isBlank(heliDto.getPayType())) {
  227. return ResponseJson.error("支付类型不能为空!", null);
  228. }
  229. if (null == heliDto.getVipRecordId()) {
  230. return ResponseJson.error("会员购买记录Id不能为空!", null);
  231. }
  232. if (StringUtils.isEmpty(heliDto.getBankCode())) {
  233. return ResponseJson.error("银行编码不能为空!", null);
  234. }
  235. if (StringUtils.isEmpty(heliDto.getUserType())) {
  236. return ResponseJson.error("银行用户类型不能为空!", null);
  237. }
  238. return payNonOrderService.unionPay(heliDto, headers);
  239. }
  240. @ApiOperation("二手发布-网银线上支付(旧:/PayOrder/secondHandPay[UNIONPAY])")
  241. @PostMapping("/second/union")
  242. public ResponseJson<String> paySecondByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  243. if (StringUtils.isBlank(heliDto.getPayType())) {
  244. return ResponseJson.error("支付类型不能为空!", null);
  245. }
  246. if (null == heliDto.getProductId()) {
  247. return ResponseJson.error("二手商品Id不能为空!", null);
  248. }
  249. if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
  250. return ResponseJson.error("回调地址不能为空!", null);
  251. }
  252. if (StringUtils.isEmpty(heliDto.getBankCode())) {
  253. return ResponseJson.error("银行编码不能为空!", null);
  254. }
  255. if (StringUtils.isEmpty(heliDto.getUserType())) {
  256. return ResponseJson.error("银行用户类型不能为空!", null);
  257. }
  258. return payNonOrderService.unionPaySecond(heliDto, headers);
  259. }
  260. /**
  261. * 升级超级会员-微信线上支付
  262. *
  263. * @param heliDto {
  264. * vipRecordId 会员购买记录Id
  265. * returnUrl 页面回调地址
  266. * code 微信小程序code
  267. * state 微信公众号state参数
  268. * }
  269. */
  270. @ApiOperation("升级超级会员-微信线上支付")
  271. @PostMapping("/vip/wechat")
  272. public ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  273. if (StringUtils.isBlank(heliDto.getPayType())) {
  274. return ResponseJson.error("支付类型不能为空!", null);
  275. }
  276. if (null == heliDto.getVipRecordId()) {
  277. return ResponseJson.error("会员购买记录Id不能为空!", null);
  278. }
  279. if (StringUtils.isEmpty(heliDto.getCode())) {
  280. return ResponseJson.error("微信code不能为空!", null);
  281. }
  282. return payNonOrderService.paySuperVipByWeChat(heliDto, headers);
  283. }
  284. /**
  285. * 升级超级会员-微信/支付宝二维码
  286. *
  287. * @param heliDto {
  288. * vipRecordId 会员购买记录Id
  289. * returnUrl 页面回调地址
  290. * }
  291. */
  292. @ApiOperation("升级超级会员-支付宝线上支付")
  293. @PostMapping("/vip/scan")
  294. public ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  295. if (StringUtils.isBlank(heliDto.getPayType())) {
  296. return ResponseJson.error("支付类型不能为空!", null);
  297. }
  298. if (null == heliDto.getVipRecordId()) {
  299. return ResponseJson.error("会员购买记录Id不能为空!", null);
  300. }
  301. if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
  302. return ResponseJson.error("回调地址不能为空!", null);
  303. }
  304. return payNonOrderService.paySuperVipByAlipay(heliDto, headers);
  305. }
  306. /**
  307. * 升级超级会员-支付回调
  308. */
  309. @ApiOperation("升级超级会员-支付回调")
  310. @PostMapping("/vip/callback")
  311. public String paymentSuperVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException {
  312. if (null == data) {
  313. return "回调参数失败";
  314. }
  315. return payNonOrderService.paymentSuperVipCallback(data);
  316. }
  317. /**
  318. * 升级超级会员-网银支付回调
  319. */
  320. @ApiOperation("升级超级会员-网银支付回调")
  321. @PostMapping("/vip/callback/union")
  322. public String paymentSuperVipCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  323. if (null == data) {
  324. return "回调参数失败";
  325. }
  326. return payNonOrderService.unionVipCallback(data);
  327. }
  328. /**
  329. * 升级超级会员-网银支付回调
  330. */
  331. @ApiOperation("升级超级会员-网银支付回调")
  332. @PostMapping("/coupon/callback/union")
  333. public String couponUnionCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  334. if (null == data) {
  335. return "回调参数失败";
  336. }
  337. return payNonOrderService.unionCouponCallback(data);
  338. }
  339. @ApiOperation("开通认证通会员-网银线上支付")
  340. @PostMapping("/auth/vip/union")
  341. public ResponseJson<String> payAuthVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers){
  342. if (StringUtils.isEmpty(heliDto.getPayType())) {
  343. return ResponseJson.error("支付类型不能为空", null);
  344. }
  345. if (null == heliDto.getVipRecordId()) {
  346. return ResponseJson.error("会员购买记录Id不能为空!", null);
  347. }
  348. if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
  349. return ResponseJson.error("回调地址不能为空!", null);
  350. }
  351. if (StringUtils.isEmpty(heliDto.getBankCode())) {
  352. return ResponseJson.error("银行编码不能为空!", null);
  353. }
  354. if (StringUtils.isEmpty(heliDto.getUserType())) {
  355. return ResponseJson.error("银行用户类型不能为空!", null);
  356. }
  357. return payNonOrderService.authVipUnionPay(heliDto, headers);
  358. }
  359. /**
  360. * 开通认证通会员-微信线上支付
  361. *
  362. * @param heliDto {
  363. * vipRecordId 会员购买记录Id
  364. * returnUrl 页面回调地址
  365. * code 微信小程序code
  366. * state 微信公众号state参数
  367. * }
  368. */
  369. @ApiOperation("升级认证通会员-微信线上支付")
  370. @PostMapping("/auth/vip/wechat")
  371. public ResponseJson<JSONObject> payAuthVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
  372. if (StringUtils.isEmpty(heliDto.getPayType())) {
  373. return ResponseJson.error("支付类型不能为空", null);
  374. }
  375. if (null == heliDto.getVipRecordId()) {
  376. return ResponseJson.error("会员购买记录Id不能为空!", null);
  377. }
  378. if (StringUtils.isEmpty(heliDto.getCode())) {
  379. return ResponseJson.error("微信code不能为空!", null);
  380. }
  381. return payNonOrderService.payAuthVipByWeChat(heliDto, headers);
  382. }
  383. /**
  384. * 开通认证通会员-微信/支付宝二维码
  385. *
  386. * @param heliDto {
  387. * vipRecordId 会员购买记录Id
  388. * returnUrl 页面回调地址
  389. * }
  390. */
  391. @ApiOperation("升级认证通会员-支付宝线上支付")
  392. @PostMapping("/auth/vip/scan")
  393. public ResponseJson<JSONObject> payAuthVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
  394. if (StringUtils.isEmpty(heliDto.getPayType())) {
  395. return ResponseJson.error("支付类型不能为空", null);
  396. }
  397. if (null == heliDto.getVipRecordId()) {
  398. return ResponseJson.error("会员购买记录Id不能为空!", null);
  399. }
  400. if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
  401. return ResponseJson.error("回调地址不能为空!", null);
  402. }
  403. return payNonOrderService.payAuthVipByAlipay(heliDto, headers);
  404. }
  405. /**
  406. * 开通认证通会员-网银支付回调
  407. */
  408. @ApiOperation("开通认证通会员-网银支付回调")
  409. @PostMapping("/auth/vip/callback/union")
  410. public String paymentAuthVipCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  411. if (null == data) {
  412. return "回调参数失败";
  413. }
  414. return payNonOrderService.unionAuthVipCallback(data);
  415. }
  416. /**
  417. * 开通认证通会员-支付回调
  418. */
  419. @ApiOperation("开通认证通会员-支付回调")
  420. @PostMapping("/auth/vip/callback")
  421. public String paymentAuthVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException {
  422. if (null == data) {
  423. return "回调参数失败";
  424. }
  425. return payNonOrderService.paymentAuthVipCallback(data);
  426. }
  427. @ApiOperation("购买认证通会员-查询是否购买成功")
  428. @GetMapping("/auth/vip/check")
  429. public ResponseJson authVipCheck(Integer vipRecordId) {
  430. if (null == vipRecordId) {
  431. return ResponseJson.error("购买记录id不能为空!", null);
  432. }
  433. return payNonOrderService.authVipCheck(vipRecordId);
  434. }
  435. }