|
@@ -453,7 +453,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
StaticLog.info("getPaymentData:{}", JSONUtil.toJsonStr(htTradeSettlement));
|
|
|
PaymentDto paymentDto = new PaymentDto();
|
|
|
BeanUtils.copyProperties(htTradeSettlement, paymentDto);
|
|
|
-
|
|
|
+ paymentDto.setId(tbOrder.getId());
|
|
|
paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
paymentDto.setCodeTs(tbOrder.getCodeTs());
|
|
|
paymentDto.setBuyQty(tbOrder.getBuyQty());
|
|
@@ -559,6 +559,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
.setSxb010StatusTime(new Date());
|
|
|
} else if (1 == SXB010Status) {//扣款成功
|
|
|
tbOrder.setSxb010Status(1)
|
|
|
+ .setRefundStatus(0)
|
|
|
.setSxb010StatusTime(new Date());
|
|
|
//如果已经过了卡三,则补发送一次通关报文给银行
|
|
|
if (tbOrder.getFinishStatus() == 1) {
|
|
@@ -725,11 +726,18 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
*/
|
|
|
public boolean orderRefund(Long id) {
|
|
|
TbOrder order = getById(id);
|
|
|
- if (order.getPeopleConfirmStatus() != 1 || order.getSxb010Status() != 1 || order.getFinishStatus() == 1 || order.getRefundStatus() != 0)
|
|
|
- throw new ServiceException("当前订单状态已改变,不可做退款操作,请刷新后操作!");
|
|
|
+ int refundStatus = order.getRefundStatus();
|
|
|
+ if (refundStatus == 1 || refundStatus == 3) {
|
|
|
+ StaticLog.error("\n---------退货退款失败:{}已退货退款", id);
|
|
|
+ throw new AjaxError("订单已退款或者退款中");
|
|
|
+ }
|
|
|
+ int sx010Status = order.getSxb010Status();
|
|
|
+ if (sx010Status != 1) {
|
|
|
+ StaticLog.error("\n---------退货退款失败:{}银行��边民的款未成功", id);
|
|
|
+ throw new AjaxError("银行扣边民的款未成功");
|
|
|
+ }
|
|
|
|
|
|
PaymentDto paymentDto = this.getPaymentData(order);
|
|
|
- StaticLog.info("\nsendSXB013(边民退货退款)——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendSXB013(paymentDto);
|
|
|
|
|
|
LambdaUpdateWrapper<TbOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
|
@@ -737,6 +745,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
updateWrapper.set(TbOrder::getRefundTime, new Date());//退款时间
|
|
|
updateWrapper.eq(TbOrder::getId, id);
|
|
|
boolean update = this.update(updateWrapper);
|
|
|
+ StaticLog.info("\nsendSXB013(边民退货退款)——PaymentDto——:{},{}", update, JSONUtil.toJsonStr(paymentDto));
|
|
|
|
|
|
return update;
|
|
|
}
|
|
@@ -748,19 +757,43 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
TbOrder tbOrder = getById(id);
|
|
|
if (tbOrder == null) {
|
|
|
StaticLog.error("\n---------补扣款失败:{}不存在", id);
|
|
|
- return false;
|
|
|
+ throw new AjaxError("订单不存在");
|
|
|
+ }
|
|
|
+ if (tbOrder.getSxb010Status() == 1 && tbOrder.getRefundStatus() == 0) {
|
|
|
+ StaticLog.error("\n---------补扣款失败:{}已扣款", id);
|
|
|
+ throw new AjaxError("订单已扣款");
|
|
|
+ }
|
|
|
+ if (tbOrder.getSxb010Status() == 3) {
|
|
|
+ StaticLog.error("\n---------补扣款失败:{}退款中", id);
|
|
|
+ throw new AjaxError("订单退款中");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(tbOrder.getGoodsNames())) {
|
|
|
+ StaticLog.error("\n---------无商品信息:{}", id);
|
|
|
+ throw new AjaxError("订单无商品信息");
|
|
|
+ }
|
|
|
+ Integer deductionCount = tbOrder.getDeductionCount() + 1;
|
|
|
+ if (tbOrder.getRefundStatus() != 0) {
|
|
|
+ String tradeNo = tbOrder.getTradeNo();
|
|
|
+ int len = tradeNo.length();
|
|
|
+ if (StrUtil.contains(tradeNo, "_")) {
|
|
|
+ tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
|
|
|
+ } else {
|
|
|
+ tradeNo = tradeNo.substring(0, len - 1);
|
|
|
+ }
|
|
|
+ tradeNo = tradeNo + deductionCount;
|
|
|
+ tbOrder.setTradeNo(tradeNo);
|
|
|
}
|
|
|
-
|
|
|
PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
|
StaticLog.info("\n---订单补扣款---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendSXB010(paymentDto);
|
|
|
-
|
|
|
- tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
|
|
|
- tbOrder.setDeductionTime(new Date());
|
|
|
+ tbOrder.setDeductionCount(deductionCount);
|
|
|
+ tbOrder.setDeductionTime(new Date())
|
|
|
+ .setSxb010Status(3);
|
|
|
|
|
|
return super.updateById(tbOrder);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 订单补扣款——按车,并且未扣款
|
|
|
*/
|
|
@@ -768,15 +801,28 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(TbOrder::getVeNo, veNo);
|
|
|
wrapper.eq(TbOrder::getSaleMainId, id);
|
|
|
- wrapper.ne(TbOrder::getSxb010Status, 1).orderByDesc(TbOrder::getCreateTime);
|
|
|
+ wrapper.and(i -> i.ne(TbOrder::getSxb010Status, 1).ne(TbOrder::getSxb010Status, 3))
|
|
|
+ .orderByDesc(TbOrder::getCreateTime);
|
|
|
List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
|
|
|
if (!tbOrders.isEmpty()) {
|
|
|
for (TbOrder tbOrder : tbOrders) {
|
|
|
+ Integer deductionCount = tbOrder.getDeductionCount() + 1;
|
|
|
+ if (tbOrder.getRefundStatus() != 0) {
|
|
|
+ String tradeNo = tbOrder.getTradeNo();
|
|
|
+ int len = tradeNo.length();
|
|
|
+ if (StrUtil.contains(tradeNo, "_")) {
|
|
|
+ tradeNo = tradeNo.substring(0, tradeNo.lastIndexOf("_"));
|
|
|
+ } else {
|
|
|
+ tradeNo = tradeNo.substring(0, len - 1);
|
|
|
+ }
|
|
|
+ tradeNo = tradeNo + deductionCount;
|
|
|
+ tbOrder.setTradeNo(tradeNo);
|
|
|
+ }
|
|
|
PaymentDto paymentDto = this.getPaymentData(tbOrder);
|
|
|
StaticLog.info("\n---订单补扣款——按车---sendSXB010——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendSXB010(paymentDto);
|
|
|
|
|
|
- tbOrder.setDeductionCount(tbOrder.getDeductionCount() + 1);
|
|
|
+ tbOrder.setDeductionCount(deductionCount);
|
|
|
tbOrder.setDeductionTime(new Date());
|
|
|
}
|
|
|
}
|
|
@@ -793,7 +839,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
return tbOrders;
|
|
|
}
|
|
|
|
|
|
- /*----- 正常业务逻辑 rpc远程调用 -----*/
|
|
|
+ /*----- 正常业务逻辑👆👆 rpc远程调用👇👇 -----*/
|
|
|
|
|
|
/**
|
|
|
* 航通发起的退单
|
|
@@ -860,7 +906,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
if (2 == SXB013Status) {//退款失败
|
|
|
tbOrder.setRefundStatus(2).setRefundReason(note).setRefundTime(new Date());
|
|
|
} else if (1 == SXB013Status) {//退款成功
|
|
|
- tbOrder.setRefundStatus(1).setRefundReason(note).setRefundTime(new Date());
|
|
|
+ tbOrder.setRefundStatus(1)
|
|
|
+ .setRefundReason(note)
|
|
|
+ .setSxb010Status(0)
|
|
|
+ .setRefundTime(new Date());
|
|
|
}
|
|
|
return updateById(tbOrder);
|
|
|
}
|
|
@@ -881,6 +930,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
PaymentDto paymentDto = new PaymentDto();
|
|
|
paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
|
|
|
+ paymentDto.setFieldCode(htTradeSettlement.getFieldCode());
|
|
|
+ paymentDto.setChannelNo(tbOrder.getChannelNo());
|
|
|
+ paymentDto.setTrans(tbOrder.getPlatSeqNo());
|
|
|
StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendCXB001(paymentDto);
|
|
|
|
|
@@ -922,6 +974,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
//todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
paymentDto.setDeclTime(htTradeSettlement.getDeclTime());
|
|
|
+
|
|
|
+ paymentDto.setFieldCode(htTradeSettlement.getFieldCode());
|
|
|
+ paymentDto.setChannelNo(tbOrder.getChannelNo());
|
|
|
+ paymentDto.setTrans(tbOrder.getPlatSeqNo());
|
|
|
StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
log.info("log sendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendCXB001(paymentDto);
|
|
@@ -970,10 +1026,14 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
//收到007结关信息后边民即可上架订单,不需等收到打款给外籍商户的成功回执SXB017才能完成订单
|
|
|
tbOrder.setFinishTime(new Date());
|
|
|
tbOrder.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
+ tbOrder.setChannelNo(htPassCardDTO.getChannelNo());
|
|
|
|
|
|
//todo: 收到航通007报文即收到海关结关信息,转发结关信息给到银行
|
|
|
paymentDto.setTradeNo(tbOrder.getTradeNo());
|
|
|
paymentDto.setDeclTime(htPassCardDTO.getCheckTime());
|
|
|
+ paymentDto.setFieldCode(htPassCardDTO.getAreaNo());
|
|
|
+ paymentDto.setChannelNo(htPassCardDTO.getChannelNo());
|
|
|
+ paymentDto.setTrans(tbOrder.getPlatSeqNo());
|
|
|
StaticLog.info("\nsendCXB001——PaymentDto——:{}", JSONUtil.toJsonStr(paymentDto));
|
|
|
paymentServerInterface.sendCXB001(paymentDto);
|
|
|
}
|
|
@@ -1159,6 +1219,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
if (i != 1) {
|
|
|
throw new AjaxError("上架失败");
|
|
|
}
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(tbOrder.getSaleMainId());
|
|
|
+ htTradeSettlement.setUpCount(htTradeSettlement.getUpCount() + 1);
|
|
|
+ htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
}
|
|
|
|
|
|
public void down(Long id) {
|
|
@@ -1171,6 +1234,9 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
|
|
|
}
|
|
|
db.setUpStatus(1);
|
|
|
this.updateById(db);
|
|
|
+ HtTradeSettlement htTradeSettlement = htTradeSettlementService.getById(db.getSaleMainId());
|
|
|
+ htTradeSettlement.setUpCount(htTradeSettlement.getUpCount() - 1);
|
|
|
+ htTradeSettlementService.updateById(htTradeSettlement);
|
|
|
}
|
|
|
|
|
|
public List<OrderDto> getOrderListByMainIds(String mainIds) {
|