修改支付方式返回订单金额

This commit is contained in:
TinyAnts 2023-03-30 14:41:40 +08:00
parent a647071d8e
commit 252f9cf723
10 changed files with 60 additions and 29 deletions

View File

@ -15,7 +15,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 com.mdd.front.vo.pay.PayWayListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.Assert;
@ -25,7 +25,6 @@ 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")
@ -40,10 +39,11 @@ public class PayController {
@GetMapping("/payWay")
@ApiOperation("支付方式")
public AjaxResult<List<PayWayListedVo>> payWay(@Validated @NotNull(message = "from参数丢失") @RequestParam String from) {
public AjaxResult<PayWayListVo> payWay(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
Integer terminal = LikeFrontThreadLocal.getTerminal();
List<PayWayListedVo> list = iPayService.payWay(from, terminal);
PayWayListVo list = iPayService.payWay(from, orderId, terminal);
return AjaxResult.success(list);
}

View File

@ -5,8 +5,8 @@ import com.mdd.common.core.AjaxResult;
import com.mdd.front.LikeFrontThreadLocal;
import com.mdd.front.service.IUserService;
import com.mdd.front.validate.users.*;
import com.mdd.front.vo.users.UserCenterVo;
import com.mdd.front.vo.users.UserInfoVo;
import com.mdd.front.vo.user.UserCenterVo;
import com.mdd.front.vo.user.UserInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;

View File

@ -2,7 +2,8 @@ package com.mdd.front.service;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.mdd.front.validate.PaymentValidate;
import com.mdd.front.vo.PayWayListedVo;
import com.mdd.front.vo.pay.PayWayInfoVo;
import com.mdd.front.vo.pay.PayWayListVo;
import java.util.List;
@ -15,10 +16,11 @@ public interface IPayService {
* 支付方式
*
* @param from 场景
* @param orderId 订单ID
* @param terminal 终端
* @return List<PayWayListedVo>
*/
List<PayWayListedVo> payWay(String from, Integer terminal);
PayWayListVo payWay(String from, Integer orderId, Integer terminal);
/**
* 发起支付

View File

@ -1,8 +1,8 @@
package com.mdd.front.service;
import com.mdd.front.validate.users.*;
import com.mdd.front.vo.users.UserCenterVo;
import com.mdd.front.vo.users.UserInfoVo;
import com.mdd.front.vo.user.UserCenterVo;
import com.mdd.front.vo.user.UserInfoVo;
/**
* 用户服务接口类

View File

@ -20,7 +20,8 @@ import com.mdd.common.plugin.wechat.request.PaymentRequestV3;
import com.mdd.common.util.*;
import com.mdd.front.service.IPayService;
import com.mdd.front.validate.PaymentValidate;
import com.mdd.front.vo.PayWayListedVo;
import com.mdd.front.vo.pay.PayWayInfoVo;
import com.mdd.front.vo.pay.PayWayListVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -57,34 +58,41 @@ public class PayServiceImpl implements IPayService {
*
* @author fzr
* @param from 场景
* @param terminal 总端
* @param orderId 订单ID
* @param terminal 终端
* @return List<PayWayListedVo>
*/
@Override
public List<PayWayListedVo> payWay(String from, Integer terminal) {
public PayWayListVo payWay(String from, Integer orderId, 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<>();
PayWayListVo vo = new PayWayListVo();
if (from.equals("recharge")) {
RechargeOrder rechargeOrder = rechargeOrderMapper.selectById(orderId);
vo.setOrderAmount(rechargeOrder.getOrderAmount());
}
Integer walletType = PaymentEnum.WALLET_PAY.getCode();
List<PayWayInfoVo> 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);
PayWayInfoVo infoVo = new PayWayInfoVo();
infoVo.setId(devPayConfig.getId());
infoVo.setName(devPayConfig.getName());
infoVo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
infoVo.setIsDefault(way.getIsDefault());
list.add(infoVo);
}
return list;
vo.setList(list);
return vo;
}
/**

View File

@ -20,8 +20,8 @@ import com.mdd.common.util.*;
import com.mdd.front.LikeFrontThreadLocal;
import com.mdd.front.service.IUserService;
import com.mdd.front.validate.users.*;
import com.mdd.front.vo.users.UserCenterVo;
import com.mdd.front.vo.users.UserInfoVo;
import com.mdd.front.vo.user.UserCenterVo;
import com.mdd.front.vo.user.UserInfoVo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;

View File

@ -1,4 +1,4 @@
package com.mdd.front.vo;
package com.mdd.front.vo.pay;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -7,8 +7,8 @@ import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "支付方式列表Vo")
public class PayWayListedVo implements Serializable {
@ApiModel(value = "支付方式信息Vo")
public class PayWayInfoVo implements Serializable {
private static final long serialVersionUID = 1L;

View File

@ -0,0 +1,21 @@
package com.mdd.front.vo.pay;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel(value = "支付方式列表Vo")
public class PayWayListVo implements Serializable {
@ApiModelProperty(value = "订单金额")
private BigDecimal orderAmount;
@ApiModelProperty(value = "方式列表")
private List<PayWayInfoVo> list;
}

View File

@ -1,4 +1,4 @@
package com.mdd.front.vo.users;
package com.mdd.front.vo.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package com.mdd.front.vo.users;
package com.mdd.front.vo.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;