增加支付方式接口
This commit is contained in:
parent
1088d305c5
commit
6d52d34e41
|
|
@ -17,6 +17,7 @@ import com.mdd.common.plugin.wechat.WxPayDriver;
|
|||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.service.IPayService;
|
||||
import com.mdd.front.validate.PaymentValidate;
|
||||
import com.mdd.front.vo.PayWayListedVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -25,6 +26,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/pay")
|
||||
|
|
@ -38,8 +41,12 @@ public class PayController {
|
|||
IPayService iPayService;
|
||||
|
||||
@GetMapping("/payWay")
|
||||
public AjaxResult<Object> payWay() {
|
||||
return AjaxResult.success();
|
||||
@ApiOperation("支付方式")
|
||||
public AjaxResult<List<PayWayListedVo>> payWay(@Validated @NotNull(message = "from参数丢失") @RequestParam String from) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
|
||||
List<PayWayListedVo> list = iPayService.payWay(from, terminal);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/prepay")
|
||||
|
|
|
|||
|
|
@ -4,12 +4,24 @@ import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
|||
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.mdd.front.validate.PaymentValidate;
|
||||
import com.mdd.front.vo.PayWayListedVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付接口服务类
|
||||
*/
|
||||
public interface IPayService {
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*
|
||||
* @param from 场景
|
||||
* @param terminal 总端
|
||||
* @return List<PayWayListedVo>
|
||||
*/
|
||||
List<PayWayListedVo> payWay(String from, Integer terminal);
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,25 +6,33 @@ import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
|||
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.mdd.common.entity.RechargeOrder;
|
||||
import com.mdd.common.entity.setting.DevPayConfig;
|
||||
import com.mdd.common.entity.setting.DevPayWay;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.mapper.RechargeOrderMapper;
|
||||
import com.mdd.common.mapper.setting.DevPayConfigMapper;
|
||||
import com.mdd.common.mapper.setting.DevPayWayMapper;
|
||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.plugin.wechat.WxPayDriver;
|
||||
import com.mdd.common.util.AmountUtil;
|
||||
import com.mdd.common.util.IpUtils;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
import com.mdd.common.util.UrlUtils;
|
||||
import com.mdd.front.service.IPayService;
|
||||
import com.mdd.front.validate.PaymentValidate;
|
||||
import com.mdd.front.vo.PayWayListedVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
@ -39,6 +47,39 @@ public class PayServiceImpl implements IPayService {
|
|||
@Resource
|
||||
RechargeOrderMapper rechargeOrderMapper;
|
||||
|
||||
@Resource
|
||||
DevPayWayMapper devPayWayMapper;
|
||||
|
||||
@Resource
|
||||
DevPayConfigMapper devPayConfigMapper;
|
||||
|
||||
@Override
|
||||
public List<PayWayListedVo> payWay(String from, Integer terminal) {
|
||||
List<DevPayWay> devPayWays = devPayWayMapper.selectList(
|
||||
new QueryWrapper<DevPayWay>()
|
||||
.eq("scene", terminal)
|
||||
.eq("status", 1));
|
||||
|
||||
Integer walletType = PaymentEnum.WALLET_PAY.getCode();
|
||||
List<PayWayListedVo> list = new LinkedList<>();
|
||||
|
||||
for (DevPayWay way : devPayWays) {
|
||||
if (from.equals("recharge") && way.getPayConfigId().equals(walletType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DevPayConfig devPayConfig = devPayConfigMapper.selectById(way.getPayConfigId());
|
||||
PayWayListedVo vo = new PayWayListedVo();
|
||||
vo.setId(devPayConfig.getId());
|
||||
vo.setName(devPayConfig.getName());
|
||||
vo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
|
||||
vo.setIsDefault(way.getIsDefault());
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.mdd.front.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "支付方式列表Vo")
|
||||
public class PayWayListedVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "图标")
|
||||
private String icon;
|
||||
|
||||
@ApiModelProperty(value = "是否默认: [0=否, 1=是]")
|
||||
private Integer isDefault;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue