支付功能
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.core.AjaxResult;
|
||||
import com.mdd.common.entity.RechargeOrder;
|
||||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.RechargeOrderMapper;
|
||||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.service.IPayService;
|
||||
import com.mdd.front.validate.PaymentValidate;
|
||||
import com.mdd.front.validate.users.UserUpdateValidate;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.util.Assert;
|
||||
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 javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pay")
|
||||
|
|
@ -41,8 +39,8 @@ public class PayController {
|
|||
*/
|
||||
@PostMapping("/prepay")
|
||||
public AjaxResult<Object> prepay(@Validated @RequestBody PaymentValidate paymentValidate) {
|
||||
String scene = paymentValidate.getScene();
|
||||
Integer payWay = paymentValidate.getPayWay();
|
||||
String scene = paymentValidate.getScene();
|
||||
int payWay = paymentValidate.getPayWay();
|
||||
Integer orderId = paymentValidate.getOrderId();
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
|
||||
|
|
@ -75,16 +73,13 @@ public class PayController {
|
|||
|
||||
// 发起支付
|
||||
try {
|
||||
switch (payWay) {
|
||||
case 1:
|
||||
iPayService.walletPay();
|
||||
break;
|
||||
case 2:
|
||||
WxPayUnifiedOrderV3Result.JsapiResult result = iPayService.wxPay(paymentValidate, terminal);
|
||||
return AjaxResult.success(result);
|
||||
case 3:
|
||||
iPayService.aliPay();
|
||||
break;
|
||||
if (payWay == PaymentEnum.WALLET_PAY.getCode()) {
|
||||
iPayService.walletPay();
|
||||
} else if (payWay == PaymentEnum.WX_PAY.getCode()) {
|
||||
WxPayUnifiedOrderV3Result.JsapiResult result = iPayService.wxPay(paymentValidate, terminal);
|
||||
return AjaxResult.success(result);
|
||||
} else if (payWay == PaymentEnum.ALI_PAY.getCode()) {
|
||||
iPayService.aliPay();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new OperateException(e.getMessage());
|
||||
|
|
|
|||
Loading…
Reference in New Issue