非加价单调整完毕

This commit is contained in:
kuang.yife 2022-11-23 11:34:02 +08:00
parent 3bfcafa2ba
commit 4882e59be9
5 changed files with 27 additions and 7 deletions

View File

@ -295,15 +295,25 @@ public class OrderDetailServiceImpl implements OrderDetailService {
public synchronized void finish(Long orderDetailId) throws BaseAdaPayException { public synchronized void finish(Long orderDetailId) throws BaseAdaPayException {
// 校验订单 // 校验订单
OrderDetail orderDetail = selectById(orderDetailId); OrderDetail orderDetail = selectById(orderDetailId);
Assert.notNull(orderDetail, "找不到对应的子订单"); if(orderDetail == null){
throw new BaseException("找不到对应的子订单");
}
Assert.isTrue(!orderDetail.getOrderStatus().equals(OrderStatus.FINISH.code()), "订单已经是完成状态"); Assert.isTrue(!orderDetail.getOrderStatus().equals(OrderStatus.FINISH.code()), "订单已经是完成状态");
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderDetail.getOrderMasterId()); FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderDetail.getOrderMasterId());
Assert.notNull(financialMaster, "找不到主财务单"); if(financialMaster == null){
throw new BaseException("找不到主财务单");
}
PaymentDTO payment = financialMasterService.selectPaymentById(financialMaster.getPaymentId()); PaymentDTO payment = financialMasterService.selectPaymentById(financialMaster.getPaymentId());
Assert.notNull(payment, "找不到支付记录"); if(payment == null){
throw new BaseException("找不到支付记录");
}
List<FinancialDetail> financialDetail = financialDetailService.selectListByOrderDetailId(orderDetailId); List<FinancialDetail> financialDetail = financialDetailService.selectListByOrderDetailId(orderDetailId);
Assert.notNull(financialDetail, "找不到子财务单"); if(financialDetail == null){
Assert.isTrue(financialDetail.get(0).getPayStatus() == 1, "订单不是“已支付”状态"); throw new BaseException("找不到子财务单");
}
if(financialDetail.get(0).getPayStatus() != 1){
throw new BaseException("订单不是“已支付”状态");
}
// 更新订单状态 // 更新订单状态
orderDetailMapper.updateStatus(orderDetailId, OrderStatus.FINISH.code()); orderDetailMapper.updateStatus(orderDetailId, OrderStatus.FINISH.code());
// 分账账户信息 // 分账账户信息

View File

@ -50,7 +50,7 @@ public interface FinancialMasterMapper {
* @param id ID * @param id ID
* @param payType 支付渠道 * @param payType 支付渠道
*/ */
void paySucceeded(@Param(value = "id") Long id, @Param(value = "payType") int payType); void paySucceeded(@Param(value = "paymentId")String paymentId, @Param(value = "id") Long id, @Param(value = "payType") int payType);
/** /**
* 支付成功 * 支付成功

View File

@ -19,6 +19,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeFormatterBuilder;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -105,7 +106,13 @@ public class FinancialMasterServiceImpl implements FinancialMasterService {
List<FinancialMaster> result = financialMasterMapper.selectFinancialMasterList(param); List<FinancialMaster> result = financialMasterMapper.selectFinancialMasterList(param);
if(!CollectionUtils.isEmpty(result)){ if(!CollectionUtils.isEmpty(result)){
financialMasterMapper.updateOrderStatus(result.get(0).getOrderMasterCode(), PayStatus.PAID.getCode()); financialMasterMapper.updateOrderStatus(result.get(0).getOrderMasterCode(), PayStatus.PAID.getCode());
financialMasterMapper.paySucceeded(result.get(0).getId(), payType); financialMasterMapper.paySucceeded(paymentId, result.get(0).getId(), payType);
FinancialDetail request = new FinancialDetail();
request.setFinancialMasterId(result.get(0).getId());
request.setPayStatus(PayStatus.PAID.getCode());
request.setPayType(payType);
request.setPayTime(new Date());
financialDetailService.updateByFinancialMasterId(request);
}else { }else {
logger.error("原单不存在!"); logger.error("原单不存在!");
} }

View File

@ -17,6 +17,7 @@ import com.ghy.payment.service.FinancialMasterService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -44,6 +45,7 @@ public class PayCallbackService implements CallBackService {
FinancialChangeRecordService financialChangeRecordService; FinancialChangeRecordService financialChangeRecordService;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void onCallback(Event event) { public void onCallback(Event event) {
logger.info("支付回调: {}", event); logger.info("支付回调: {}", event);
String data = event.getData(); String data = event.getData();

View File

@ -111,6 +111,7 @@
<update id="paySucceeded"> <update id="paySucceeded">
UPDATE financial_master SET UPDATE financial_master SET
payment_id = #{paymentId},
pay_status = 1 , pay_status = 1 ,
pay_type = #{payType}, pay_type = #{payType},
pay_time = SYSDATE(), pay_time = SYSDATE(),