123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- package com.caimei365.order.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei365.order.model.ResponseJson;
- import com.caimei365.order.model.dto.HeliDto;
- import com.caimei365.order.model.dto.PayCouponDto;
- import com.caimei365.order.model.dto.PayVipDto;
- import com.caimei365.order.model.vo.NotifyResponseVo;
- import com.caimei365.order.model.vo.UnionResVo;
- import com.caimei365.order.service.HeliPayNonOrderService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.http.HttpHeaders;
- import org.springframework.web.bind.annotation.*;
- import java.beans.IntrospectionException;
- import java.lang.reflect.InvocationTargetException;
- import java.security.NoSuchAlgorithmException;
- import java.security.spec.InvalidKeySpecException;
- /**
- * @author zzj
- * 合利宝非订单
- */
- @Api(tags = "其他(非订单)支付API")
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/order/pay")
- public class HeliPayNonOrderApi {
- private final HeliPayNonOrderService payNonOrderService;
- /**
- * 二手发布-微信线上支付
- *
- * @param heliDto {
- * productId 二手发布商品id
- * returnUrl 页面回调地址
- * code 微信小程序code
- * state 微信公众号state参数
- * }
- */
- @ApiOperation("二手发布-微信线上支付(旧:/PayOrder/appletsSecondHandPay)(/PayOrder/secondHandPay[WEIXIN])")
- @PostMapping("/second/wechat")
- public ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getProductId()) {
- return ResponseJson.error("二手商品Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getCode())) {
- return ResponseJson.error("微信code不能为空!", null);
- }
- return payNonOrderService.paySecondByWeChat(heliDto, headers);
- }
- /**
- * 二手发布-支付宝二维码
- *
- * @param heliDto {
- * productId 二手发布商品id
- * returnUrl 页面回调地址
- * }
- */
- @ApiOperation("二手发布-支付宝线上支付(旧:/PayOrder/secondHandPay[ALIPAY])")
- @PostMapping("/second/scan")
- public ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getProductId()) {
- return ResponseJson.error("二手商品Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
- return ResponseJson.error("回调地址不能为空!", null);
- }
- return payNonOrderService.paySecondByAlipay(heliDto, headers);
- }
- /**
- * 二手发布-支付回调
- */
- @ApiOperation("二手发布-支付回调(旧:/PayOrder/secondHandPayCallBack)")
- @PostMapping("/second/callback")
- public String paymentSecondCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == res) {
- return "回调参数失败";
- }
- return payNonOrderService.paymentSecondCallback(res);
- }
- @ApiOperation("购买价值优惠券-获取购买记录id")
- @PostMapping("/coupon/record")
- public ResponseJson<PayCouponDto> payCouponGetRecord(PayCouponDto payCouponDto, @RequestHeader HttpHeaders headers) {
- if (null == payCouponDto.getCouponId()) {
- return ResponseJson.error("优惠券Id不能为空!", null);
- }
- if (null == payCouponDto.getUserId()) {
- return ResponseJson.error("userId不能为空!", null);
- }
- return payNonOrderService.getCouponRecord(payCouponDto, headers);
- }
- /**
- * 购买优惠券-查询是否购买成功
- */
- @ApiOperation("购买优惠券-查询是否购买成功")
- @GetMapping("/coupon/check")
- public ResponseJson couponCheck(Integer couponRecordId) {
- if (null == couponRecordId) {
- return ResponseJson.error("购买记录id不能为空!", null);
- }
- return payNonOrderService.couponCheck(couponRecordId);
- }
- /**
- * 购买优惠券-微信线上支付
- *
- * @param heliDto {
- * couponId 购买优惠券Id
- * userId userId
- * couponRecordId 购买记录id
- * returnUrl 页面回调地址
- * code 微信小程序code
- * state 微信公众号state参数
- * }
- */
- @ApiOperation("购买价值优惠券-微信支付")
- @PostMapping("/coupon/wechat")
- public ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getCouponRecordId()) {
- return ResponseJson.error("购买记录id不能为空!", null);
- }
- if (null == heliDto.getSource()) {
- return ResponseJson.error("领取渠道不能为空!", null);
- }
- if (null == heliDto.getCouponId()) {
- return ResponseJson.error("优惠券Id不能为空!", null);
- }
- if (null == heliDto.getUserId()) {
- return ResponseJson.error("userId不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getCode())) {
- return ResponseJson.error("微信code不能为空!", null);
- }
- return payNonOrderService.payCouponByWeChat(heliDto, headers);
- }
- @ApiOperation("购买价值优惠券-网银线上支付")
- @PostMapping("/coupon/union")
- public ResponseJson<String> payCouponByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getCouponRecordId()) {
- return ResponseJson.error("购买记录id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getBankCode())) {
- return ResponseJson.error("银行编码不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getUserType())) {
- return ResponseJson.error("银行用户类型不能为空!", null);
- }
- if (null == heliDto.getSource()) {
- return ResponseJson.error("领取渠道不能为空!", null);
- }
- if (null == heliDto.getCouponId()) {
- return ResponseJson.error("优惠券Id不能为空!", null);
- }
- if (null == heliDto.getUserId()) {
- return ResponseJson.error("userId不能为空!", null);
- }
- return payNonOrderService.couponUnionPay(heliDto, headers);
- }
- /**
- * 购买价值优惠券-微信/支付宝二维码
- *
- * @param heliDto {
- * couponId 购买优惠券Id
- * userId userId
- * couponRecordId 购买记录id
- * returnUrl 页面回调地址
- * state 微信公众号state参数
- * }
- */
- @ApiOperation("购买价值优惠券-支付宝线上支付")
- @PostMapping("/coupon/scan")
- public ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getCouponRecordId()) {
- return ResponseJson.error("购买记录id不能为空!", null);
- }
- if (null == heliDto.getSource()) {
- return ResponseJson.error("领取渠道不能为空!", null);
- }
- if (null == heliDto.getCouponId()) {
- return ResponseJson.error("优惠券Id不能为空!", null);
- }
- if (null == heliDto.getUserId()) {
- return ResponseJson.error("userId不能为空!", null);
- }
- return payNonOrderService.payCouponByAlipay(heliDto, headers);
- }
- /**
- * 购买优惠券-支付回调
- */
- @ApiOperation("购买优惠券-支付回调")
- @GetMapping("/coupon/callback")
- public String couponCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == res) {
- return "回调参数失败";
- }
- return payNonOrderService.couponCallback(res);
- }
- /**
- * 二手发布-网银支付回调
- */
- @ApiOperation("二手发布-网银支付回调")
- @PostMapping("/second/callback/union")
- public String paymentSecondCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == res) {
- return "回调参数失败";
- }
- return payNonOrderService.unionSecondCallback(res);
- }
- @ApiOperation("升级超级会员-网银线上支付")
- @PostMapping("/vip/union")
- public ResponseJson<String> paySuperVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getBankCode())) {
- return ResponseJson.error("银行编码不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getUserType())) {
- return ResponseJson.error("银行用户类型不能为空!", null);
- }
- return payNonOrderService.unionPay(heliDto, headers);
- }
- @ApiOperation("二手发布-网银线上支付(旧:/PayOrder/secondHandPay[UNIONPAY])")
- @PostMapping("/second/union")
- public ResponseJson<String> paySecondByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getProductId()) {
- return ResponseJson.error("二手商品Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
- return ResponseJson.error("回调地址不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getBankCode())) {
- return ResponseJson.error("银行编码不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getUserType())) {
- return ResponseJson.error("银行用户类型不能为空!", null);
- }
- return payNonOrderService.unionPaySecond(heliDto, headers);
- }
- /**
- * 升级超级会员-微信线上支付
- *
- * @param heliDto {
- * vipRecordId 会员购买记录Id
- * returnUrl 页面回调地址
- * code 微信小程序code
- * state 微信公众号state参数
- * }
- */
- @ApiOperation("升级超级会员-微信线上支付")
- @PostMapping("/vip/wechat")
- public ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getCode())) {
- return ResponseJson.error("微信code不能为空!", null);
- }
- return payNonOrderService.paySuperVipByWeChat(heliDto, headers);
- }
- /**
- * 升级超级会员-微信/支付宝二维码
- *
- * @param heliDto {
- * vipRecordId 会员购买记录Id
- * returnUrl 页面回调地址
- * }
- */
- @ApiOperation("升级超级会员-支付宝线上支付")
- @PostMapping("/vip/scan")
- public ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (StringUtils.isBlank(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空!", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
- return ResponseJson.error("回调地址不能为空!", null);
- }
- return payNonOrderService.paySuperVipByAlipay(heliDto, headers);
- }
- /**
- * 升级超级会员-支付回调
- */
- @ApiOperation("升级超级会员-支付回调")
- @PostMapping("/vip/callback")
- public String paymentSuperVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == data) {
- return "回调参数失败";
- }
- return payNonOrderService.paymentSuperVipCallback(data);
- }
- /**
- * 升级超级会员-网银支付回调
- */
- @ApiOperation("升级超级会员-网银支付回调")
- @PostMapping("/vip/callback/union")
- public String paymentSuperVipCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == data) {
- return "回调参数失败";
- }
- return payNonOrderService.unionVipCallback(data);
- }
- /**
- * 升级超级会员-网银支付回调
- */
- @ApiOperation("升级超级会员-网银支付回调")
- @PostMapping("/coupon/callback/union")
- public String couponUnionCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == data) {
- return "回调参数失败";
- }
- return payNonOrderService.unionCouponCallback(data);
- }
- @ApiOperation("开通认证通会员-网银线上支付")
- @PostMapping("/auth/vip/union")
- public ResponseJson<String> payAuthVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers){
- if (StringUtils.isEmpty(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
- return ResponseJson.error("回调地址不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getBankCode())) {
- return ResponseJson.error("银行编码不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getUserType())) {
- return ResponseJson.error("银行用户类型不能为空!", null);
- }
- return payNonOrderService.authVipUnionPay(heliDto, headers);
- }
- /**
- * 开通认证通会员-微信线上支付
- *
- * @param heliDto {
- * vipRecordId 会员购买记录Id
- * returnUrl 页面回调地址
- * code 微信小程序code
- * state 微信公众号state参数
- * }
- */
- @ApiOperation("升级认证通会员-微信线上支付")
- @PostMapping("/auth/vip/wechat")
- public ResponseJson<JSONObject> payAuthVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
- if (StringUtils.isEmpty(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getCode())) {
- return ResponseJson.error("微信code不能为空!", null);
- }
- return payNonOrderService.payAuthVipByWeChat(heliDto, headers);
- }
- /**
- * 开通认证通会员-微信/支付宝二维码
- *
- * @param heliDto {
- * vipRecordId 会员购买记录Id
- * returnUrl 页面回调地址
- * }
- */
- @ApiOperation("升级认证通会员-支付宝线上支付")
- @PostMapping("/auth/vip/scan")
- public ResponseJson<JSONObject> payAuthVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
- if (StringUtils.isEmpty(heliDto.getPayType())) {
- return ResponseJson.error("支付类型不能为空", null);
- }
- if (null == heliDto.getVipRecordId()) {
- return ResponseJson.error("会员购买记录Id不能为空!", null);
- }
- if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
- return ResponseJson.error("回调地址不能为空!", null);
- }
- return payNonOrderService.payAuthVipByAlipay(heliDto, headers);
- }
- /**
- * 开通认证通会员-网银支付回调
- */
- @ApiOperation("开通认证通会员-网银支付回调")
- @PostMapping("/auth/vip/callback/union")
- public String paymentAuthVipCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == data) {
- return "回调参数失败";
- }
- return payNonOrderService.unionAuthVipCallback(data);
- }
- /**
- * 开通认证通会员-支付回调
- */
- @ApiOperation("开通认证通会员-支付回调")
- @PostMapping("/auth/vip/callback")
- public String paymentAuthVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (null == data) {
- return "回调参数失败";
- }
- return payNonOrderService.paymentAuthVipCallback(data);
- }
- @ApiOperation("购买认证通会员-查询是否购买成功")
- @GetMapping("/auth/vip/check")
- public ResponseJson authVipCheck(Integer vipRecordId) {
- if (null == vipRecordId) {
- return ResponseJson.error("购买记录id不能为空!", null);
- }
- return payNonOrderService.authVipCheck(vipRecordId);
- }
- }
|