支付功能
This commit is contained in:
parent
3456eb65d4
commit
3fc536eb1c
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.mdd.common.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付枚举
|
||||||
|
*/
|
||||||
|
public enum PaymentEnum {
|
||||||
|
|
||||||
|
UN_PAID(1, "未支付"),
|
||||||
|
OK_PAID(0, "已支付"),
|
||||||
|
|
||||||
|
WALLET_PAY(1, "余额支付"),
|
||||||
|
WX_PAY(2, "微信支付"),
|
||||||
|
ALI_PAY(3, "支付宝支付");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造方法
|
||||||
|
*/
|
||||||
|
private final int code;
|
||||||
|
private final String msg;
|
||||||
|
PaymentEnum(int code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态码
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return Long
|
||||||
|
*/
|
||||||
|
public int getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取提示
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getMsg() {
|
||||||
|
return this.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,12 +5,12 @@ import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
||||||
import com.mdd.common.aop.NotLogin;
|
import com.mdd.common.aop.NotLogin;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.entity.RechargeOrder;
|
import com.mdd.common.entity.RechargeOrder;
|
||||||
|
import com.mdd.common.enums.PaymentEnum;
|
||||||
import com.mdd.common.exception.OperateException;
|
import com.mdd.common.exception.OperateException;
|
||||||
import com.mdd.common.mapper.RechargeOrderMapper;
|
import com.mdd.common.mapper.RechargeOrderMapper;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IPayService;
|
import com.mdd.front.service.IPayService;
|
||||||
import com.mdd.front.validate.PaymentValidate;
|
import com.mdd.front.validate.PaymentValidate;
|
||||||
import com.mdd.front.validate.users.UserUpdateValidate;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -20,8 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/pay")
|
@RequestMapping("/api/pay")
|
||||||
|
|
@ -41,8 +39,8 @@ public class PayController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/prepay")
|
@PostMapping("/prepay")
|
||||||
public AjaxResult<Object> prepay(@Validated @RequestBody PaymentValidate paymentValidate) {
|
public AjaxResult<Object> prepay(@Validated @RequestBody PaymentValidate paymentValidate) {
|
||||||
String scene = paymentValidate.getScene();
|
String scene = paymentValidate.getScene();
|
||||||
Integer payWay = paymentValidate.getPayWay();
|
int payWay = paymentValidate.getPayWay();
|
||||||
Integer orderId = paymentValidate.getOrderId();
|
Integer orderId = paymentValidate.getOrderId();
|
||||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||||
|
|
||||||
|
|
@ -75,16 +73,13 @@ public class PayController {
|
||||||
|
|
||||||
// 发起支付
|
// 发起支付
|
||||||
try {
|
try {
|
||||||
switch (payWay) {
|
if (payWay == PaymentEnum.WALLET_PAY.getCode()) {
|
||||||
case 1:
|
iPayService.walletPay();
|
||||||
iPayService.walletPay();
|
} else if (payWay == PaymentEnum.WX_PAY.getCode()) {
|
||||||
break;
|
WxPayUnifiedOrderV3Result.JsapiResult result = iPayService.wxPay(paymentValidate, terminal);
|
||||||
case 2:
|
return AjaxResult.success(result);
|
||||||
WxPayUnifiedOrderV3Result.JsapiResult result = iPayService.wxPay(paymentValidate, terminal);
|
} else if (payWay == PaymentEnum.ALI_PAY.getCode()) {
|
||||||
return AjaxResult.success(result);
|
iPayService.aliPay();
|
||||||
case 3:
|
|
||||||
iPayService.aliPay();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new OperateException(e.getMessage());
|
throw new OperateException(e.getMessage());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue