加价单付款操作
This commit is contained in:
parent
05c6c97aad
commit
a0c414dbd0
|
|
@ -3,20 +3,23 @@ package com.ghy.web.controller.pay;
|
||||||
import com.ghy.common.adapay.model.PayParam;
|
import com.ghy.common.adapay.model.PayParam;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
import com.ghy.common.enums.PayStatus;
|
||||||
|
import com.ghy.order.domain.OrderDetail;
|
||||||
import com.ghy.order.domain.OrderMaster;
|
import com.ghy.order.domain.OrderMaster;
|
||||||
|
import com.ghy.order.service.OrderDetailService;
|
||||||
import com.ghy.order.service.OrderMasterService;
|
import com.ghy.order.service.OrderMasterService;
|
||||||
|
import com.ghy.payment.domain.FinancialChangeRecord;
|
||||||
import com.ghy.payment.domain.FinancialMaster;
|
import com.ghy.payment.domain.FinancialMaster;
|
||||||
import com.ghy.payment.service.AdapayService;
|
import com.ghy.payment.service.AdapayService;
|
||||||
|
import com.ghy.payment.service.FinancialChangeRecordService;
|
||||||
import com.ghy.payment.service.FinancialMasterService;
|
import com.ghy.payment.service.FinancialMasterService;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝支付API
|
* 支付宝支付API
|
||||||
|
|
@ -34,6 +37,12 @@ public class AlipayController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private FinancialMasterService financialMasterService;
|
private FinancialMasterService financialMasterService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderDetailService orderDetailService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FinancialChangeRecordService financialChangeRecordService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝正扫支付
|
* 支付宝正扫支付
|
||||||
*/
|
*/
|
||||||
|
|
@ -59,4 +68,42 @@ public class AlipayController extends BaseController {
|
||||||
}
|
}
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addQr")
|
||||||
|
public AjaxResult addQrPay(@RequestBody Long orderDetailId) {
|
||||||
|
BigDecimal payMoney = BigDecimal.ZERO;
|
||||||
|
Map<String, Object> map;
|
||||||
|
// 查询回原子单
|
||||||
|
OrderDetail orderDetail = orderDetailService.selectById(orderDetailId);
|
||||||
|
if (orderDetail == null) {
|
||||||
|
return AjaxResult.error("子订单不存在!");
|
||||||
|
}
|
||||||
|
OrderMaster orderMaster = orderMasterService.selectById(orderDetail.getOrderMasterId());
|
||||||
|
if (orderMaster == null) {
|
||||||
|
return AjaxResult.error("主订单不存在!");
|
||||||
|
}
|
||||||
|
// 查询主单是否有未支付的付款单
|
||||||
|
FinancialMaster fm = financialMasterService.selectByOrderMasterId(orderDetail.getOrderMasterId());
|
||||||
|
if (fm == null) {
|
||||||
|
return AjaxResult.error("财务单不存在!");
|
||||||
|
}
|
||||||
|
// 主单是否付款
|
||||||
|
if (Objects.equals(fm.getPayStatus(), PayStatus.WAIT_PAY.getCode())) {
|
||||||
|
payMoney = payMoney.add(fm.getPayMoney());
|
||||||
|
}
|
||||||
|
// 查询关联的加价单
|
||||||
|
FinancialChangeRecord financialChangeRecord = financialChangeRecordService.selectNotPayRecordByDetailId(orderDetailId);
|
||||||
|
if (financialChangeRecord != null) {
|
||||||
|
payMoney = payMoney.add(financialChangeRecord.getChangeMoney());
|
||||||
|
}
|
||||||
|
// 付款
|
||||||
|
PayParam payParam = PayParam.delayPayParam(orderMaster.getCode() + "_" + System.currentTimeMillis(), payMoney.setScale(2, BigDecimal.ROUND_UNNECESSARY).toString(), "加价付款", "叮咚到家服务");
|
||||||
|
try {
|
||||||
|
map = adapayService.alipayQrPay(orderMaster.getDeptId(), payParam, null, null, null);
|
||||||
|
} catch (BaseAdaPayException e) {
|
||||||
|
logger.error("创建支付失败", e);
|
||||||
|
return AjaxResult.error("网络不佳 请稍后再试");
|
||||||
|
}
|
||||||
|
return AjaxResult.success(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface FinancialChangeRecordMapper {
|
public interface FinancialChangeRecordMapper {
|
||||||
|
|
||||||
|
public FinancialChangeRecord selectNotPayRecordByDetailId(Long orderDetailId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询改价记录
|
* 查询改价记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface FinancialChangeRecordService {
|
public interface FinancialChangeRecordService {
|
||||||
|
|
||||||
|
public FinancialChangeRecord selectNotPayRecordByDetailId(Long orderDetailId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询改价记录
|
* 查询改价记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@ public class FinancialChangeRecordServiceImpl implements FinancialChangeRecordSe
|
||||||
@Autowired
|
@Autowired
|
||||||
private FinancialChangeRecordMapper financialChangeRecordMapper;
|
private FinancialChangeRecordMapper financialChangeRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FinancialChangeRecord selectNotPayRecordByDetailId(Long orderDetailId) {
|
||||||
|
return financialChangeRecordMapper.selectNotPayRecordByDetailId(orderDetailId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询改价记录
|
* 查询改价记录
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@
|
||||||
select id, order_detail_id, change_money, status, pay_status, type, remark from financial_change_record
|
select id, order_detail_id, change_money, status, pay_status, type, remark from financial_change_record
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectNotPayRecordByDetailId" parameterType="String" resultMap="FinancialChangeRecordResult">
|
||||||
|
<include refid="selectFinancialChangeRecordVo" />
|
||||||
|
where order_detail_id = #{orderDetailId} and pay_status = 0;
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectFinancialChangeRecordList" parameterType="FinancialChangeRecord" resultMap="FinancialChangeRecordResult">
|
<select id="selectFinancialChangeRecordList" parameterType="FinancialChangeRecord" resultMap="FinancialChangeRecordResult">
|
||||||
<include refid="selectFinancialChangeRecordVo"/>
|
<include refid="selectFinancialChangeRecordVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue