提交 f528742a 作者: zhenjie

商城订单支付修改

上级 df265922
......@@ -65,7 +65,7 @@ public class UavOrderController extends BaseController {
return uavOrderService.listByUid(uavOrderQO, this.getCurrentAccount(request));
}
@ApiOperation(value = "支付")
@ApiOperation(value = "支付", hidden = true)
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("pay")
public ResultBody pay(@RequestParam Integer id, HttpServletRequest request) {
......
......@@ -21,6 +21,8 @@ public interface UavOrderDao {
UavOrderDO detail(Integer id);
UavOrderDO detailByNo(String orderNo);
List<UavOrderPayDO> listUavOrderPay(Integer uavOrderId);
List<UavOrderSkuDO> listUavOrderSkuDO(Integer uavOrderId);
......@@ -34,4 +36,8 @@ public interface UavOrderDao {
int countList(UavOrderQO uavOrderQO);
List<UavOrderDO> list(UavOrderQO uavOrderQO);
void addOrderPay(UavOrderPayDO uavOrderPayDO);
void updateUavOrderPayInfo(UavOrderDO uavOrderDO);
}
......@@ -38,13 +38,13 @@ public class UavOrderDO implements Serializable {
private String companyName;
@ApiModelProperty("订单实付总额")
private BigDecimal orderTotalAmount;
@ApiModelProperty("抵扣钱包余额")
private BigDecimal walletAmount;
@ApiModelProperty("抵扣佣金余额")
private BigDecimal salaryAmount;
@ApiModelProperty("抵扣云享金余额")
private BigDecimal shareAmount;
@ApiModelProperty("其他方式支付额度")
private BigDecimal otherAmount;
@ApiModelProperty("支付方式,wechatpay微信,alipay支付宝")
@ApiModelProperty("wechatpay微信,alipay支付宝,offline线下")
private String payType;
@ApiModelProperty("订单类型,0正常订单、1意向订单")
private Integer orderType;
......@@ -73,7 +73,7 @@ public class UavOrderDO implements Serializable {
public UavOrderDTO buildUavOrderDTO(){
return UavOrderDTO.builder().id(this.id).version(this.version).orderNo(this.orderNo).statusCode(this.statusCode).userAccountId(this.userAccountId)
.thirdBackUserAccountId(this.thirdBackUserAccountId).companyName(this.companyName).orderTotalAmount(this.orderTotalAmount).walletAmount(this.walletAmount)
.thirdBackUserAccountId(this.thirdBackUserAccountId).companyName(this.companyName).orderTotalAmount(this.orderTotalAmount).salaryAmount(this.salaryAmount)
.shareAmount(this.shareAmount).otherAmount(this.otherAmount).payType(this.payType).orderType(this.orderType).deliveryTime(this.deliveryTime).userAddressId(this.userAddressId)
.userRemark(this.userRemark).sellerRemark(this.sellerRemark).createTime(this.createTime).payTime(this.payTime).confirmReceiptTime(this.confirmReceiptTime)
.remarkStatus(this.remarkStatus).updateTime(this.updateTime).skuDTOList(CollectionUtils.isEmpty(skuDOS) ? null :
......
......@@ -2,11 +2,13 @@ package com.mmc.oms.entity.uav;
import com.mmc.oms.model.dto.uav.UavOrderPayDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -23,14 +25,17 @@ public class UavOrderPayDO implements Serializable {
private Integer uavOrderId;
private String payImgList;
private Integer checkStatus;
private Integer payType;
private String payRemark;
private String refuseReason;
private Date createTime;
private Date checkTime;
private BigDecimal payAmount;
public UavOrderPayDTO buildUavOrderPayDTO(){
return UavOrderPayDTO.builder().id(this.id).uavOrderId(this.uavOrderId).payImgList(this.payImgList).checkStatus(this.checkStatus)
.payRemark(this.payRemark).refuseReason(this.refuseReason).createTime(this.createTime).build();
.payRemark(this.payRemark).refuseReason(this.refuseReason).createTime(this.createTime).payType(this.payType)
.payAmount(this.payAmount).build();
}
}
......@@ -2,10 +2,14 @@ package com.mmc.oms.feign;
import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.feign.hystrix.UserAppApiHystrix;
import com.mmc.oms.model.dto.uav.PayWalletDTO;
import com.mmc.oms.model.vo.uav.PayUavWalletVO;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
/**
* @author: zj
......@@ -16,4 +20,10 @@ public interface UserAppApi {
@PostMapping("pay/feignTopUpCash")
public ResultBody feignTopUpCash(@RequestBody TopUpOrderVO topUpOrderVO);
@GetMapping("pay/getCurrentUserPayWalletInfo")
public ResultBody<PayWalletDTO> getCurrentUserPayWalletInfo(@RequestHeader String token);
@PostMapping("pay/feignPayUavWallet")
public ResultBody feignPayUavWallet(@RequestBody PayUavWalletVO payUavWalletVO, @RequestHeader String token);
}
package com.mmc.oms.feign.hystrix;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.feign.UserAppApi;
import com.mmc.oms.model.dto.uav.PayWalletDTO;
import com.mmc.oms.model.vo.uav.PayUavWalletVO;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import lombok.extern.slf4j.Slf4j;
......@@ -17,4 +20,16 @@ public class UserAppApiHystrix implements UserAppApi {
log.error("熔断:UserAppApiHystrix.feignTopUpCash==error==>param:{}", topUpOrderVO);
return ResultBody.error("-1", "远程调用失败");
}
@Override
public ResultBody<PayWalletDTO> getCurrentUserPayWalletInfo(String token) {
log.error("熔断:UserAppApiHystrix.getCurrentUserPayWalletInfo==error");
return ResultBody.error("-1", "远程调用失败");
}
@Override
public ResultBody feignPayUavWallet(PayUavWalletVO payUavWalletVO, String token) {
log.error("熔断:UserAppApiHystrix.feignPayUavWallet==error==>param:{}", JSONObject.toJSONString(payUavWalletVO));
return ResultBody.error("-1", "远程调用失败");
}
}
package com.mmc.oms.model.dto.uav;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author 作者 lw
* @version 创建时间:2023.08.18 下午13:31:12
* @explain 类说明
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PayWalletDTO implements Serializable {
private static final long serialVersionUID = 75097833899496576L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "用户ID")
private Integer userAccountId;
@ApiModelProperty(value = "用户姓名")
private String userName;
@ApiModelProperty(value = "云享金余额")
private BigDecimal cashAmt;
@ApiModelProperty(value = "云享金总金额")
private BigDecimal totalCash;
@ApiModelProperty(value = "已冻结云享金")
private BigDecimal cashFreeze;
@ApiModelProperty(value = "佣金余额")
private BigDecimal salaryAmt;
@ApiModelProperty(value = "已冻结佣金")
private BigDecimal salaryFreeze;
@ApiModelProperty(value = "佣金总额度")
private BigDecimal totalSalary;
@ApiModelProperty(value = "已提现的金额")
private BigDecimal rebateWdl;
@ApiModelProperty(value = "提现冻结金额")
private BigDecimal wdlFreeze;
@ApiModelProperty(value = "冻结总额")
private BigDecimal totalFreeze;
@ApiModelProperty(value = "总金额")
private BigDecimal totalAmount;
public void mathTotal() {
// 总冻结余额
this.totalFreeze = BigDecimal.ZERO;
if (this.cashFreeze != null) {
this.totalFreeze = this.totalFreeze.add(this.cashFreeze);
}
if (this.salaryFreeze != null) {
this.totalFreeze = this.totalFreeze.add(this.salaryFreeze);
}
// 总云享金余额
this.totalCash = BigDecimal.ZERO;
if (this.cashAmt != null) {
this.totalCash = this.totalCash.add(this.cashAmt);
}
if (this.cashFreeze != null) {
this.totalCash = this.totalCash.add(this.cashFreeze);
}
// 总佣金余额
this.totalSalary = BigDecimal.ZERO;
if (this.salaryAmt != null) {
this.totalSalary = this.totalSalary.add(this.salaryAmt);
}
if (this.salaryFreeze != null) {
this.totalSalary = this.totalSalary.add(this.salaryFreeze);
}
// 总金额
this.totalAmount = BigDecimal.ZERO;
this.totalAmount = this.totalAmount.add(this.totalCash);
this.totalAmount = this.totalAmount.add(this.totalSalary);
}
}
......@@ -38,13 +38,13 @@ public class UavOrderDTO implements Serializable {
private String companyName;
@ApiModelProperty("订单实付总额")
private BigDecimal orderTotalAmount;
@ApiModelProperty("抵扣钱包余额")
private BigDecimal walletAmount;
@ApiModelProperty("抵扣佣金余额")
private BigDecimal salaryAmount;
@ApiModelProperty("抵扣云享金余额")
private BigDecimal shareAmount;
@ApiModelProperty("其他方式支付额度")
private BigDecimal otherAmount;
@ApiModelProperty("支付方式,wechatpay微信,alipay支付宝")
@ApiModelProperty("wechatpay微信,alipay支付宝,offline线下")
private String payType;
@ApiModelProperty("订单类型,0正常订单、1意向订单")
private Integer orderType;
......
......@@ -8,6 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
......@@ -35,4 +36,8 @@ public class UavOrderPayDTO implements Serializable {
private String refuseReason;
@ApiModelProperty(value = "提交时间")
private Date createTime;
@ApiModelProperty(value = "0微信支付,1支付宝,2线下支付凭证")
private Integer payType;
@ApiModelProperty(value = "支付金额")
private BigDecimal payAmount;
}
......@@ -28,16 +28,22 @@ public class AddUavOrderVO implements Serializable {
private Integer userAddressId;
@ApiModelProperty("订单类型,0正常直接支付订单,1意向沟通订单")
private Integer orderType;
@ApiModelProperty("订单实付总额")
@ApiModelProperty(value = "订单实付总额", hidden = true)
private BigDecimal orderTotalAmount;
@ApiModelProperty("抵扣钱包余额")
@ApiModelProperty(value = "抵扣钱包余额", hidden = true)
private BigDecimal walletAmount;
@ApiModelProperty("抵扣云享金余额")
@ApiModelProperty(value = "抵扣云享金余额", hidden = true)
private BigDecimal shareAmount;
@ApiModelProperty("其他方式支付额度")
@ApiModelProperty(value = "其他方式支付额度", hidden = true)
private BigDecimal otherAmount;
@ApiModelProperty("用户备注")
private String userRemark;
@ApiModelProperty("规格列表")
private List<UavOrderSkuVO> skuVOS;
@ApiModelProperty("是否抵扣云享金,0否,1是")
private Integer deductShareAmount;
@ApiModelProperty("是否抵扣余额,0否,1是")
private Integer deductSalaryAmount;
}
package com.mmc.oms.model.vo.uav;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author LW
* @date 2023/9/7 16:07
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PayUavWalletVO implements Serializable {
private static final long serialVersionUID = 1683979749411588941L;
@ApiModelProperty(value = "用户ID")
private Integer userAccountId;
@ApiModelProperty(value = "云享金")
private BigDecimal cashAmount;
@ApiModelProperty(value = "佣金")
private BigDecimal salaryAmount;
@ApiModelProperty(value = "订单状态 100:订单支付 1400:商城订单退款")
private Integer orderStatus;
}
......@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -18,17 +19,22 @@ import java.math.BigDecimal;
public class UavOrderSkuVO implements Serializable {
private static final long serialVersionUID = 6034392498890957390L;
@ApiModelProperty("商品规格id")
@NotNull(message = "商品规格id必传")
private Integer priceStockId;
@ApiModelProperty("商品规格")
@NotNull(message = "商品规格必传")
private String productSpec;
@ApiModelProperty("购买数量")
@NotNull(message = "购买数量图片必传")
private Integer orderNum;
@ApiModelProperty(value = "单价", hidden = true)
private BigDecimal unitPrice;
@ApiModelProperty("商品规格图片")
@NotNull(message = "商品规格图片必传")
private String skuImage;
@ApiModelProperty("商品规格编号")
private String skuNo;
@ApiModelProperty("客户提交订单的单价")
@NotNull(message = "价格必传")
private BigDecimal salePrice;
}
......@@ -5,9 +5,9 @@ package com.mmc.oms.mq.constant;
* @Date: 2023/8/23 11:26
*/
public class RabbitmqConstant {
public final static String USER_TOP_UP_DIRECT_EXCHANGE = "USER_TOP_UP_DIRECT_EXCHANGE";
public final static String USER_TOP_UP_DIRECT_QUEUE = "USER_TOP_UP_DIRECT_QUEUE";
public final static String USER_TOP_UP_ROUTING_KEY = "USER_TOP_UP_ROUTING_KEY";
public final static String PAY_UAV_ORDER_SUCCESS_QUEUE = "PAY_UAV_ORDER_SUCCESS_QUEUE";
}
......@@ -5,6 +5,7 @@ import com.mmc.oms.dao.topup.TopUpOrderDao;
import com.mmc.oms.entity.topup.TopUpOrderDO;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import com.mmc.oms.mq.constant.RabbitmqConstant;
import com.mmc.oms.service.uav.UavOrderService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
......@@ -24,6 +25,9 @@ public class MqConsumer {
@Resource
TopUpOrderDao topUpOrderDao;
@Resource
private UavOrderService uavOrderService;
@RabbitListener(queues = RabbitmqConstant.USER_TOP_UP_DIRECT_QUEUE)
public void subscribeDirectQueue(@Payload String topUpOrder, Channel channel, Message message) {
TopUpOrderVO topUpOrderVO = JSONObject.parseObject(topUpOrder, TopUpOrderVO.class);
......@@ -36,4 +40,13 @@ public class MqConsumer {
topUpOrderDao.updateTopUpOrderInfo(topUpOrderDO);
log.info("<==========用户充值订单消费结束==========>");
}
@RabbitListener(queues = RabbitmqConstant.PAY_UAV_ORDER_SUCCESS_QUEUE)
public void subscribePayUavOrderDirectQueue(@Payload String topUpOrder, Channel channel, Message message) {
TopUpOrderVO topUpOrderVO = JSONObject.parseObject(topUpOrder, TopUpOrderVO.class);
log.info("<==========商城支付消费开始:信息是---->{}==========>", topUpOrderVO);
// 根据支付消息修改订单状态
uavOrderService.payUavOrder(topUpOrderVO);
log.info("<==========用户充值订单消费结束==========>");
}
}
......@@ -10,10 +10,15 @@ import com.mmc.oms.controller.demand.util.EmojiUtils;
import com.mmc.oms.dao.demand.DemandReleaseOrderDao;
import com.mmc.oms.dao.demand.PublishServiceOrderDao;
import com.mmc.oms.dao.topup.TopUpOrderDao;
import com.mmc.oms.dao.uav.UavOrderDao;
import com.mmc.oms.entity.demand.DemandReleaseOrderDO;
import com.mmc.oms.entity.demand.GetOrderNumberDO;
import com.mmc.oms.entity.demand.GetOrderNumberDTO;
import com.mmc.oms.entity.topup.TopUpOrderDO;
import com.mmc.oms.entity.uav.UavOrderDO;
import com.mmc.oms.enums.UavOrderStatus;
import com.mmc.oms.feign.UserAppApi;
import com.mmc.oms.model.dto.uav.PayWalletDTO;
import com.mmc.oms.model.vo.demand.CommonPaymentVO;
import com.mmc.oms.model.vo.demand.DemandReleaseOrderVO;
import com.mmc.oms.model.vo.demand.OrderRequestParamsVO;
......@@ -32,6 +37,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -53,6 +59,9 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
private DemandReleaseOrderDao releaseOrderDao;
@Autowired
private UavOrderDao uavOrderDao;
@Autowired
private RestTemplate restTemplate;
@Value("${payment.url}")
......@@ -64,6 +73,9 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
@Resource
private TopUpOrderDao topUpOrderDao;
@Autowired
private UserAppApi userAppApi;
@Override
public ResultBody publish(DemandReleaseOrderVO demandReleaseOrderVO, HttpServletRequest request) {
DemandReleaseOrderDO requirementsInfoDO = new DemandReleaseOrderDO(demandReleaseOrderVO);
......@@ -91,11 +103,16 @@ public class DemandReleaseOrderServiceImpl implements DemandReleaseOrderService
}
public ResultBody payUavOrder(CommonPaymentVO commonPaymentVO, String token) {
UavOrderDO uavOrderDO = uavOrderDao.detailByNo(commonPaymentVO.getOrderNumber());
if (!uavOrderDO.getOtherAmount().multiply(BigDecimal.valueOf(100)).equals(commonPaymentVO.getAmount())){
return ResultBody.error("发起支付金额不正确");
}
OrderRequestParamsVO orderRequestParamsVO = new OrderRequestParamsVO();
orderRequestParamsVO.setOrderNo(commonPaymentVO.getOrderNumber());
orderRequestParamsVO.setAmount(commonPaymentVO.getAmount());
orderRequestParamsVO.setAttach("PAY_UAV_ORDER");
orderRequestParamsVO.setDescription(commonPaymentVO.getDescription());
orderRequestParamsVO.setOrderPort(commonPaymentVO.getOrderPort());
ResultBody resultBody = releaseOrder(orderRequestParamsVO, token);
if (!"200".equals(resultBody.getCode())) {
throw new RuntimeException("调用微信支付方法失败!");
......
......@@ -7,6 +7,7 @@ import com.mmc.oms.model.vo.uav.AddUavOrderVO;
import com.mmc.oms.model.vo.uav.UavOrderExpressVO;
import com.mmc.oms.model.vo.uav.UavOrderPayVO;
import com.mmc.oms.model.vo.uav.UavOrderRemarkVO;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import javax.servlet.http.HttpServletRequest;
......@@ -40,4 +41,6 @@ public interface UavOrderService {
ResultBody upLoadPay(UavOrderPayVO uavOrderPayVO);
ResultBody checkPay(UavOrderPayVO uavOrderPayVO);
void payUavOrder(TopUpOrderVO topUpOrderVO);
}
package com.mmc.oms.service.uav.impl;
import com.mmc.oms.client.PmsClient;
import com.mmc.oms.common.ResultEnum;
import com.mmc.oms.common.json.JsonUtil;
import com.mmc.oms.common.result.PageResult;
import com.mmc.oms.common.result.ResultBody;
......@@ -15,14 +16,12 @@ import com.mmc.oms.enums.UavOrderStatus;
import com.mmc.oms.feign.UserAppApi;
import com.mmc.oms.model.dto.kdn.KdnExpDTO;
import com.mmc.oms.model.dto.order.ExpStationsDTO;
import com.mmc.oms.model.dto.uav.UavOrderDTO;
import com.mmc.oms.model.dto.uav.UavOrderPayDTO;
import com.mmc.oms.model.dto.uav.UavOrderSkuDTO;
import com.mmc.oms.model.dto.uav.UavOrderStatusDTO;
import com.mmc.oms.model.dto.uav.*;
import com.mmc.oms.model.dto.user.BaseAccountDTO;
import com.mmc.oms.model.qo.uav.UavOrderQO;
import com.mmc.oms.model.vo.demand.CommonPaymentVO;
import com.mmc.oms.model.vo.uav.*;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
import com.mmc.oms.service.demand.DemandReleaseOrderService;
import com.mmc.oms.service.uav.UavOrderService;
import org.apache.commons.collections4.CollectionUtils;
......@@ -94,38 +93,76 @@ public class UavOrderServiceImpl implements UavOrderService {
}
String orderNo = CodeUtil.uavOrderCode();
BigDecimal orderTotalAmount = BigDecimal.ZERO;
BigDecimal otherAmount = BigDecimal.ZERO;
for (UavOrderSkuVO skuVO : param.getSkuVOS()) {
// 计算规格金额
BigDecimal skuAmount = BigDecimal.valueOf(skuVO.getOrderNum()).multiply(skuVO.getUnitPrice());
orderTotalAmount = orderTotalAmount.add(skuAmount);
}
if (orderTotalAmount.compareTo(param.getOrderTotalAmount()) != 0) {
return ResultBody.error("价格有变动,请重新选择规格后下单!");
otherAmount = otherAmount.add(orderTotalAmount);
// 校验云享金、钱包余额是否足够抵扣
BigDecimal shareAmount = BigDecimal.ZERO;
BigDecimal salaryAmount = BigDecimal.ZERO;
ResultBody<PayWalletDTO> payResInfo = userAppApi.getCurrentUserPayWalletInfo(currentAccount.getToken());
if (!payResInfo.getCode().equals(ResultEnum.SUCCESS.getResultCode()) || payResInfo.getResult() == null){
return payResInfo;
}
PayWalletDTO payWalletDTO = payResInfo.getResult();
if (param.getDeductShareAmount().equals(1)){
if (otherAmount.compareTo(payWalletDTO.getCashAmt()) >= 0) {
// 抵扣云享金小于等于订单总额时,直接使用云享金
shareAmount = payWalletDTO.getCashAmt();
}else {
// 余额超过订单金额时,订单总额使用余额支付
shareAmount = otherAmount;
}
}
otherAmount = otherAmount.subtract(shareAmount);
Integer statusCode = null;
// 支付完成
if (otherAmount.compareTo(BigDecimal.ZERO) ==0 ){
statusCode = UavOrderStatus.WAITING_DELIVER_GOODS.getCode();
}else {
if (param.getDeductSalaryAmount().equals(1)){
if (otherAmount.compareTo(payWalletDTO.getSalaryAmt()) >= 0) {
// 抵扣余额小于等于订单总额时,直接使用余额
salaryAmount = payWalletDTO.getSalaryAmt();
}else {
// 余额超过订单金额时,订单总额使用余额支付
salaryAmount = otherAmount;
}
}
otherAmount = otherAmount.subtract(salaryAmount);
if (otherAmount.compareTo(BigDecimal.ZERO) == 0) {
statusCode = UavOrderStatus.WAITING_DELIVER_GOODS.getCode();
}
}
PayUavWalletVO payUavWalletVO = new PayUavWalletVO();
payUavWalletVO.setCashAmount(shareAmount);
payUavWalletVO.setSalaryAmount(salaryAmount);
payUavWalletVO.setOrderStatus(100);
payUavWalletVO.setUserAccountId(currentAccount.getUserAccountId());
ResultBody resultBody = userAppApi.feignPayUavWallet(payUavWalletVO, currentAccount.getToken());
if (!resultBody.getCode().equals(ResultEnum.SUCCESS.getResultCode())){
return resultBody;
}
// TODO 校验云享金、钱包余额是否足够抵扣
param.getShareAmount();
param.getWalletAmount();
// 添加总订单表
UavOrderDO uavOrderDO = new UavOrderDO();
uavOrderDO.setOrderNo(orderNo);
uavOrderDO.setOrderTotalAmount(orderTotalAmount);
uavOrderDO.setOrderType(param.getOrderType());
if (param.getOrderType().equals(0)){
uavOrderDO.setPayType("wechatpay");
uavOrderDO.setStatusCode(UavOrderStatus.PAYING.getCode());
}else {
uavOrderDO.setStatusCode(UavOrderStatus.CONTACT.getCode());
}
// TODO 意向订单待处理
uavOrderDO.setStatusCode(otherAmount.compareTo(BigDecimal.ZERO) > 0 ? UavOrderStatus.PAYING.getCode() : statusCode);
uavOrderDO.setUserAccountId(currentAccount.getUserAccountId());
uavOrderDO.setThirdBackUserAccountId(param.getThirdBackUserAccountId());
uavOrderDO.setCompanyName(param.getCompanyName());
uavOrderDO.setWalletAmount(param.getWalletAmount());
uavOrderDO.setShareAmount(param.getShareAmount());
uavOrderDO.setOtherAmount(param.getOtherAmount());
uavOrderDO.setSalaryAmount(salaryAmount);
uavOrderDO.setShareAmount(shareAmount);
uavOrderDO.setOtherAmount(otherAmount);
uavOrderDO.setUserAddressId(param.getUserAddressId());
uavOrderDO.setUserRemark(param.getUserRemark());
uavOrderDao.addOrder(uavOrderDO);
List<UavOrderSkuDO> skuDOS = new ArrayList<>();
for (UavOrderSkuVO skuVO : param.getSkuVOS()) {
UavOrderSkuDO uavOrderSkuDO = new UavOrderSkuDO();
......@@ -239,10 +276,9 @@ public class UavOrderServiceImpl implements UavOrderService {
return ResultBody.error("操作有误,请重试!");
}
CommonPaymentVO commonPaymentVO = new CommonPaymentVO();
//
int shouldPay = uavOrderDO.getOtherAmount().multiply(BigDecimal.valueOf(100)).intValue();
if (shouldPay <= 0) {
return ResultBody.error("已支付完成");
return ResultBody.success("已支付完成");
}
List<UavOrderSkuDO> orderSkuDOS = uavOrderDao.listUavOrderSkuDO(id);
StringBuffer sb = new StringBuffer();
......@@ -321,4 +357,27 @@ public class UavOrderServiceImpl implements UavOrderService {
public ResultBody checkPay(UavOrderPayVO uavOrderPayVO) {
return null;
}
@Transactional
@Override
public void payUavOrder(TopUpOrderVO topUpOrderVO) {
// 添加支付凭证、记录支付方式
UavOrderDO uavOrderDO = uavOrderDao.detailByNo(topUpOrderVO.getOrderNo());
if (uavOrderDO == null) {
throw new RuntimeException();
}
this.updateUavOrderStatus(uavOrderDO.getId(), UavOrderStatus.WAITING_DELIVER_GOODS);
// 修改订单信息
uavOrderDO.setPayType("wechatpay");
uavOrderDO.setPayTime(new Date());
uavOrderDao.updateUavOrderPayInfo(uavOrderDO);
UavOrderPayDO uavOrderPayDO = new UavOrderPayDO();
uavOrderPayDO.setUavOrderId(uavOrderDO.getId());
uavOrderPayDO.setPayRemark(topUpOrderVO.getTradeStateDesc());
uavOrderPayDO.setPayType(0);
uavOrderPayDO.setPayAmount(BigDecimal.valueOf(topUpOrderVO.getAmount()).divide(BigDecimal.valueOf(100)));
uavOrderPayDO.setCheckStatus(1);
uavOrderPayDO.setCreateTime(new Date());
uavOrderDao.addOrderPay(uavOrderPayDO);
}
}
......@@ -11,7 +11,7 @@
<result property="thirdBackUserAccountId" column="third_back_user_account_id" />
<result property="companyName" column="company_name" />
<result property="orderTotalAmount" column="order_total_amount" />
<result property="walletAmount" column="wallet_amount" />
<result property="salaryAmount" column="salary_amount" />
<result property="shareAmount" column="share_amount" />
<result property="otherAmount" column="other_amount" />
<result property="payType" column="pay_type" />
......@@ -33,17 +33,17 @@
</resultMap>
<sql id="uav_order_column">
id, order_no, status_code, user_account_id, third_back_user_account_id, company_name, order_total_amount, wallet_amount,
id, order_no, status_code, user_account_id, third_back_user_account_id, company_name, order_total_amount, salary_amount,
share_amount, other_amount, pay_type, order_type, delivery_time, user_address_id, user_remark, seller_remark, create_time,
pay_time, confirm_receipt_time, version, remark_status, update_time
</sql>
<insert id="addOrder" parameterType="com.mmc.oms.entity.uav.UavOrderDO" useGeneratedKeys="true" keyProperty="id">
insert into uav_order(order_no, status_code, user_account_id, third_back_user_account_id, company_name, order_total_amount,
wallet_amount, share_amount, other_amount, pay_type, order_type, user_address_id, user_remark, seller_remark, create_time
salary_amount, share_amount, other_amount, pay_type, order_type, user_address_id, user_remark, seller_remark, create_time
)
values( #{orderNo}, #{statusCode}, #{userAccountId}, #{thirdBackUserAccountId}, #{companyName}, #{orderTotalAmount},
#{walletAmount}, #{shareAmount}, #{otherAmount}, #{payType}, #{orderType}, #{userAddressId}, #{userRemark}, #{sellerRemark},
#{salaryAmount}, #{shareAmount}, #{otherAmount}, #{payType}, #{orderType}, #{userAddressId}, #{userRemark}, #{sellerRemark},
NOW()
);
</insert>
......@@ -57,6 +57,22 @@
</foreach>
</insert>
<insert id="addOrderPay" parameterType="com.mmc.oms.entity.uav.UavOrderPayDO" useGeneratedKeys="true" keyProperty="id">
insert into uav_order_pay(
uav_order_id,
order_no,
pay_type,
pay_amount,
pay_img_list,
check_status,
pay_remark,
refuse_reason,
create_time,
check_time
)
values(#{uavOrderId}, #{orderNo}, #{payType}, #{payAmount}, #{payImgList}, #{checkStatus}, #{payRemark}, #{refuseReason}, NOW(), #{checkTime})
</insert>
<update id="sellerRemark">
update uav_order set seller_remark = #{content} where id = #{id}
</update>
......@@ -65,6 +81,10 @@
update uav_order set status_code = #{nextCode} where id = #{id}
</update>
<update id="updateUavOrderPayInfo" parameterType="com.mmc.oms.entity.uav.UavOrderDO">
update uav_order set pay_time = #{payTime}, pay_type = #{payType} where id = #{id}
</update>
<select id="detail" resultType="com.mmc.oms.entity.uav.UavOrderDO">
select <include refid="uav_order_column" /> from uav_order where id = #{id}
</select>
......@@ -166,4 +186,8 @@
limit #{pageNo}, #{pageSize}
</select>
<select id="detailByNo" resultType="com.mmc.oms.entity.uav.UavOrderDO">
select <include refid="uav_order_column" /> from uav_order where order_no = #{orderNo}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论