修改支付方式返回订单金额
This commit is contained in:
parent
a647071d8e
commit
252f9cf723
|
|
@ -15,7 +15,7 @@ import com.mdd.common.plugin.wechat.WxPayDriver;
|
||||||
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.vo.PayWayListedVo;
|
import com.mdd.front.vo.pay.PayWayListVo;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/pay")
|
@RequestMapping("/api/pay")
|
||||||
|
|
@ -40,10 +39,11 @@ public class PayController {
|
||||||
|
|
||||||
@GetMapping("/payWay")
|
@GetMapping("/payWay")
|
||||||
@ApiOperation("支付方式")
|
@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();
|
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||||
|
|
||||||
List<PayWayListedVo> list = iPayService.payWay(from, terminal);
|
PayWayListVo list = iPayService.payWay(from, orderId, terminal);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IUserService;
|
import com.mdd.front.service.IUserService;
|
||||||
import com.mdd.front.validate.users.*;
|
import com.mdd.front.validate.users.*;
|
||||||
import com.mdd.front.vo.users.UserCenterVo;
|
import com.mdd.front.vo.user.UserCenterVo;
|
||||||
import com.mdd.front.vo.users.UserInfoVo;
|
import com.mdd.front.vo.user.UserInfoVo;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ package com.mdd.front.service;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.mdd.front.validate.PaymentValidate;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -15,10 +16,11 @@ public interface IPayService {
|
||||||
* 支付方式
|
* 支付方式
|
||||||
*
|
*
|
||||||
* @param from 场景
|
* @param from 场景
|
||||||
|
* @param orderId 订单ID
|
||||||
* @param terminal 终端
|
* @param terminal 终端
|
||||||
* @return List<PayWayListedVo>
|
* @return List<PayWayListedVo>
|
||||||
*/
|
*/
|
||||||
List<PayWayListedVo> payWay(String from, Integer terminal);
|
PayWayListVo payWay(String from, Integer orderId, Integer terminal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发起支付
|
* 发起支付
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
import com.mdd.front.validate.users.*;
|
import com.mdd.front.validate.users.*;
|
||||||
import com.mdd.front.vo.users.UserCenterVo;
|
import com.mdd.front.vo.user.UserCenterVo;
|
||||||
import com.mdd.front.vo.users.UserInfoVo;
|
import com.mdd.front.vo.user.UserInfoVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务接口类
|
* 用户服务接口类
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ import com.mdd.common.plugin.wechat.request.PaymentRequestV3;
|
||||||
import com.mdd.common.util.*;
|
import com.mdd.common.util.*;
|
||||||
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.vo.PayWayListedVo;
|
import com.mdd.front.vo.pay.PayWayInfoVo;
|
||||||
|
import com.mdd.front.vo.pay.PayWayListVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -57,34 +58,41 @@ public class PayServiceImpl implements IPayService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param from 场景
|
* @param from 场景
|
||||||
* @param terminal 总端
|
* @param orderId 订单ID
|
||||||
|
* @param terminal 终端
|
||||||
* @return List<PayWayListedVo>
|
* @return List<PayWayListedVo>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PayWayListedVo> payWay(String from, Integer terminal) {
|
public PayWayListVo payWay(String from, Integer orderId, Integer terminal) {
|
||||||
List<DevPayWay> devPayWays = devPayWayMapper.selectList(
|
List<DevPayWay> devPayWays = devPayWayMapper.selectList(
|
||||||
new QueryWrapper<DevPayWay>()
|
new QueryWrapper<DevPayWay>()
|
||||||
.eq("scene", terminal)
|
.eq("scene", terminal)
|
||||||
.eq("status", 1));
|
.eq("status", 1));
|
||||||
|
|
||||||
Integer walletType = PaymentEnum.WALLET_PAY.getCode();
|
PayWayListVo vo = new PayWayListVo();
|
||||||
List<PayWayListedVo> list = new LinkedList<>();
|
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) {
|
for (DevPayWay way : devPayWays) {
|
||||||
if (from.equals("recharge") && way.getPayConfigId().equals(walletType)) {
|
if (from.equals("recharge") && way.getPayConfigId().equals(walletType)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevPayConfig devPayConfig = devPayConfigMapper.selectById(way.getPayConfigId());
|
DevPayConfig devPayConfig = devPayConfigMapper.selectById(way.getPayConfigId());
|
||||||
PayWayListedVo vo = new PayWayListedVo();
|
PayWayInfoVo infoVo = new PayWayInfoVo();
|
||||||
vo.setId(devPayConfig.getId());
|
infoVo.setId(devPayConfig.getId());
|
||||||
vo.setName(devPayConfig.getName());
|
infoVo.setName(devPayConfig.getName());
|
||||||
vo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
|
infoVo.setIcon(UrlUtils.toAbsoluteUrl(devPayConfig.getIcon()));
|
||||||
vo.setIsDefault(way.getIsDefault());
|
infoVo.setIsDefault(way.getIsDefault());
|
||||||
list.add(vo);
|
list.add(infoVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
vo.setList(list);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import com.mdd.common.util.*;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IUserService;
|
import com.mdd.front.service.IUserService;
|
||||||
import com.mdd.front.validate.users.*;
|
import com.mdd.front.validate.users.*;
|
||||||
import com.mdd.front.vo.users.UserCenterVo;
|
import com.mdd.front.vo.user.UserCenterVo;
|
||||||
import com.mdd.front.vo.users.UserInfoVo;
|
import com.mdd.front.vo.user.UserInfoVo;
|
||||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mdd.front.vo;
|
package com.mdd.front.vo.pay;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -7,8 +7,8 @@ import lombok.Data;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "支付方式列表Vo")
|
@ApiModel(value = "支付方式信息Vo")
|
||||||
public class PayWayListedVo implements Serializable {
|
public class PayWayInfoVo implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
Loading…
Reference in New Issue