...
|
...
|
@@ -19,6 +19,7 @@ import com.yohoufo.common.utils.TimeUtils; |
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohobuy.ufo.model.order.common.Payment;
|
|
|
import com.yohoufo.order.common.BillTradeStatus;
|
|
|
import com.yohoufo.order.common.HbfqEnum;
|
|
|
import com.yohoufo.order.common.TransferCase;
|
|
|
import com.yohoufo.order.constants.RefundContant;
|
...
|
...
|
@@ -356,7 +357,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (tradeBills == null) {
|
|
|
throw new ServiceException(400, "transferSuccess:流水不存在");
|
|
|
}
|
|
|
if (tradeBills.getTradeStatus() != TradeBills.Status.TRANSFER_WAITING.getCode()) {
|
|
|
if (tradeBills.getTradeStatus() != BillTradeStatus.TRANSFER_WAITING.getCode()) {
|
|
|
throw new ServiceException(400, "transferSuccess:该流水不是异步转账的");
|
|
|
}
|
|
|
OrdersPayTransfer transfer = ordersPayTransferMapper.selectByPrimaryKey(transferId);
|
...
|
...
|
@@ -382,7 +383,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
// 加新流水
|
|
|
tradeBills.setDealRelateId(tradeBills.getId());
|
|
|
tradeBills.setId(null);
|
|
|
tradeBills.setTradeStatus(100);
|
|
|
tradeBills.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
tradeBills.setCreateTime(now);
|
|
|
addTradeBills(tradeBills);
|
|
|
|
...
|
...
|
@@ -399,7 +400,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
TradeBills fail = new TradeBills();
|
|
|
fail.setId(tradeBills.getId());
|
|
|
fail.setDealStatus(0);
|
|
|
fail.setTradeStatus(299);
|
|
|
fail.setTradeStatus(BillTradeStatus.TRANSFER_FAIL.getCode());
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(fail);
|
|
|
logger.info("transferSuccess 旧流水(失败)更新成功,准备改转账表 tradeBillsId={}, tradeBillsId={}, orderCode={}", tradeBillsId, tradeBillsId, orderCode);
|
|
|
|
...
|
...
|
@@ -663,7 +664,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (transferAmount == null) {
|
|
|
logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额");
|
|
|
alarm("转账金额不合法", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferCase.getCode() + ")计算金额结果为null");
|
|
|
record.setTradeStatus(202);
|
|
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "计算金额错误!:");
|
|
|
}
|
...
|
...
|
@@ -674,7 +675,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (transferAmount.compareTo(new BigDecimal("0.1")) < 0) {
|
|
|
logger.warn("transferMonErr transferMon计算费用结果为 {}, 小于0.1", transferAmount);
|
|
|
alarm("转账金额小于0.1", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferCase.getCode() + ")计算金额结果为" + transferAmount);
|
|
|
record.setTradeStatus(202);
|
|
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "不合法的金额:" + transferAmount);
|
|
|
}
|
...
|
...
|
@@ -683,7 +684,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (account == null ||
|
|
|
(StringUtils.isBlank(account.getAlipayAccount()) && StringUtils.isBlank(account.getAlipayId()))) {
|
|
|
logger.warn("transferMonErr uid {} 没有获取到有效的支付宝账号", targetUid);
|
|
|
record.setTradeStatus(201);
|
|
|
record.setTradeStatus(BillTradeStatus.NOT_EXIST_ALI_ACCOUNT.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]没有获取到有效的支付宝账号");
|
|
|
}
|
...
|
...
|
@@ -775,8 +776,9 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
logger.info("transferMon最后更新状态 status= {}", transfer.getStatus());
|
|
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
|
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
|
|
record.setTradeStatus(transfer.getStatus() == 1 ? 100 : 299);
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
|
|
BillTradeStatus bts = transfer.getStatus() == 1 ? BillTradeStatus.SUCCESS : BillTradeStatus.TRANSFER_FAIL;
|
|
|
record.setTradeStatus(bts.getCode());
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
|
|
logger.info("transferMon最后更新状态完成,转账结束, buyerOrderCode is {}!", buyerOrderCode);
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -813,14 +815,14 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (amount == null || amount.compareTo(new BigDecimal("0.1")) < 0) {
|
|
|
logger.warn("transAllEarnestErr transferMon计算费用结果为 {}, 小于0.1或为null", amount);
|
|
|
alarm("转账金额小于0.1或为null", "ufo.order.transAllEarnest", "退还商家入驻所有金额,订单号:" + orderCode + "操作类型(" + 6 + ")计算金额结果为" + amount);
|
|
|
record.setTradeStatus(202);
|
|
|
record.setTradeStatus(BillTradeStatus.AMOUNT_IS_ILLEGAL.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "不合法的金额:" + amount);
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isBlank(aliPayAccount.getAlipayAccount()) && StringUtils.isBlank(aliPayAccount.getAlipayId()) ) {
|
|
|
logger.warn("transAllEarnestErr uid {} 支付宝账号不合法", account);
|
|
|
record.setTradeStatus(201);
|
|
|
record.setTradeStatus(BillTradeStatus.NOT_EXIST_ALI_ACCOUNT.getCode());
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "uid[" + uid + "]支付宝账号不合法");
|
|
|
}
|
...
|
...
|
@@ -907,7 +909,8 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
transfer.setUpdateTime(now);
|
|
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
|
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
|
|
record.setTradeStatus(transfer.getStatus() == 1 ? 100 : 299);
|
|
|
BillTradeStatus bts = transfer.getStatus() == 1 ? BillTradeStatus.SUCCESS : BillTradeStatus.TRANSFER_FAIL;
|
|
|
record.setTradeStatus( bts.getCode() );
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(record);
|
|
|
logger.info("transAllEarnest最后更新状态完成,转账结束, orderCode is {}!", orderCode);
|
|
|
}
|
...
|
...
|
@@ -989,7 +992,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
if (tradeBills == null) {
|
|
|
throw new ServiceException(400, "manualDeal:流水不存在");
|
|
|
}
|
|
|
if (tradeBills.getTradeStatus() == 100) {
|
|
|
if (tradeBills.getTradeStatus() == BillTradeStatus.SUCCESS.getCode()) {
|
|
|
throw new ServiceException(400, "manualDeal:该流水不是失败的");
|
|
|
}
|
|
|
if (tradeBills.getIncomeOutcome()==null || tradeBills.getIncomeOutcome()!=1) {
|
...
|
...
|
@@ -1072,7 +1075,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
// 加新流水
|
|
|
tradeBills.setDealRelateId(tradeBills.getId());
|
|
|
tradeBills.setId(null);
|
|
|
tradeBills.setTradeStatus(100);
|
|
|
tradeBills.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
tradeBills.setCreateTime(now);
|
|
|
addTradeBills(tradeBills);
|
|
|
return;
|
...
|
...
|
@@ -1133,7 +1136,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
// 加新流水
|
|
|
tradeBills.setDealRelateId(tradeBills.getId());
|
|
|
tradeBills.setId(null);
|
|
|
tradeBills.setTradeStatus(100);
|
|
|
tradeBills.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
tradeBills.setCreateTime(now);
|
|
|
addTradeBills(tradeBills);
|
|
|
|
...
|
...
|
@@ -1181,7 +1184,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
// success to wait
|
|
|
if (StringUtils.equals("T", mapResult.get("is_success"))) {
|
|
|
tradeBills.setDealStatus(0);
|
|
|
tradeBills.setTradeStatus(TradeBills.Status.TRANSFER_WAITING.getCode());
|
|
|
tradeBills.setTradeStatus(BillTradeStatus.TRANSFER_WAITING.getCode());
|
|
|
// wait
|
|
|
tradeBillsMapper.updateSelectiveByPrimaryKey(tradeBills);
|
|
|
}
|
...
|
...
|
@@ -1338,7 +1341,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
return;
|
|
|
}
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(100);
|
|
|
record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
...
|
...
|
@@ -1354,7 +1357,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
|
|
|
record.setAmount(amount);
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(100);
|
|
|
record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
...
|
...
|
@@ -1385,7 +1388,7 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(100);
|
|
|
record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
...
|
...
|
|