...
|
...
|
@@ -447,15 +447,28 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
logger.warn("transferMonErr uid {} 不合法", targetUid);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]不合法");
|
|
|
}
|
|
|
int now = (int) (System.currentTimeMillis()/1000);
|
|
|
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(targetUid);
|
|
|
record.setOrderCode(transferType == 1 ? sellerOrderCode : buyerOrderCode);
|
|
|
record.setUserType(transferType == 1 ? 2 : 1);
|
|
|
record.setPayType(1);
|
|
|
record.setTradeType(transferType == 1 ? 2 : 3);
|
|
|
record.setIncomeOutcome(1);
|
|
|
record.setTradeStatus(transferType == 1 ? 0 : 1);
|
|
|
record.setCreateTime(now);
|
|
|
|
|
|
String alipayAccount = getAlipayAccount(targetUid);
|
|
|
if (StringUtils.isBlank(alipayAccount)) {
|
|
|
logger.warn("transferMonErr uid {} 没有获取到有效的支付宝账号", targetUid);
|
|
|
record.setTradeStatus(201);
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "uid[" + targetUid + "]没有获取到有效的支付宝账号");
|
|
|
}
|
|
|
logger.info("transferMon参数检查成功!");
|
|
|
|
|
|
int now = (int) (System.currentTimeMillis()/1000);
|
|
|
|
|
|
OrdersPayTransfer transfer = new OrdersPayTransfer();
|
|
|
transfer.setBuyerOrderCode(buyerOrderCode);
|
|
|
transfer.setSellerOrderCode(sellerOrderCode);
|
...
|
...
|
@@ -482,9 +495,14 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
logger.info("transferMon计算费用结果为 {}", transferAmount);
|
|
|
if (transferAmount == null || transferAmount.compareTo(new BigDecimal("0.1")) < 0) {
|
|
|
logger.warn("transferMonErr transferMon计算费用结果为 {}, 不合法的金额", transferAmount);
|
|
|
throw new ServiceException(400, "不合法的金额");
|
|
|
record.setTradeStatus(202);
|
|
|
addTradeBills(record);
|
|
|
throw new ServiceException(400, "不合法的金额:" + transferAmount);
|
|
|
}
|
|
|
transfer.setAmount(transferAmount);
|
|
|
record.setAmount(transferAmount);
|
|
|
// 因为转账支付宝扣费累计计算,使用转账额
|
|
|
record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1")));
|
|
|
|
|
|
// 转账
|
|
|
try {
|
...
|
...
|
@@ -515,26 +533,18 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
logger.warn("transferMonErr 转账失败 , orderCode is {}, msg is {}", buyerOrderCode, e.getMessage());
|
|
|
throw new ServiceException(500, "转账失败");
|
|
|
} finally {
|
|
|
logger.info("transferMon最后更新状态 status= {}", transfer.getStatus());
|
|
|
logger.info("transferMon最后更新状态 status= {}", transfer.getStatus());
|
|
|
transfer.setUpdateTime(now);
|
|
|
ordersPayTransferMapper.updateByPrimaryKeySelective(transfer);
|
|
|
// 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败
|
|
|
record.setTradeStatus(transfer.getStatus() == 1 ? 100 : 299);
|
|
|
addTradeBills(record);
|
|
|
logger.info("transferMon最后更新状态完成,转账结束, buyerOrderCode is {}!", buyerOrderCode);
|
|
|
}
|
|
|
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
try {
|
|
|
record.setUid(targetUid);
|
|
|
record.setOrderCode(transferType == 1 ? sellerOrderCode : buyerOrderCode);
|
|
|
record.setUserType(transferType == 1 ? 2 : 1);
|
|
|
record.setPayType(1);
|
|
|
record.setTradeType(transferType == 1 ? 2 : 3);
|
|
|
record.setIncomeOutcome(1);
|
|
|
record.setAmount(transferAmount);
|
|
|
// 因为转账支付宝扣费累计计算,使用转账额
|
|
|
record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1")));
|
|
|
record.setTradeStatus(transferType == 1 ? 0 : 1);
|
|
|
record.setCreateTime(now);
|
|
|
}
|
|
|
|
|
|
private void addTradeBills(TradeBills record) {
|
|
|
try {
|
|
|
tradeBillsMapper.insert(record);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
|
...
|
...
|
@@ -550,29 +560,25 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(2);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
|
|
|
record.setAmount(amount);
|
|
|
try {
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(2);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
|
|
|
record.setAmount(amount);
|
|
|
try {
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
tradeBillsMapper.insert(record);
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
|
|
|
|
|
// 支付货款流水记录
|
...
|
...
|
@@ -584,29 +590,25 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(1);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(2);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
|
|
|
try {
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(1);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(2);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
|
|
|
try {
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setAmount(amount);
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
tradeBillsMapper.insert(record);
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setAmount(amount);
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
|
|
|
|
|
// 退保证金流水记录
|
...
|
...
|
@@ -618,29 +620,25 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(2);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
|
|
|
record.setAmount(amount);
|
|
|
try {
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(2);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
|
|
|
record.setAmount(amount);
|
|
|
try {
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(1);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
tradeBillsMapper.insert(record);
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(1);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
|
|
|
|
|
// 退付货款流水记录
|
...
|
...
|
@@ -652,29 +650,25 @@ public class PaymentServiceImpl implements IPaymentService { |
|
|
}
|
|
|
// 增加流水记录
|
|
|
TradeBills record = new TradeBills();
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(1);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(2);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
|
|
|
try {
|
|
|
record.setUid(uid);
|
|
|
record.setOrderCode(orderCode);
|
|
|
record.setUserType(1);// 1:买家uid; 2:卖家uid
|
|
|
record.setPayType(payType);// 1:支付宝; 2:微信
|
|
|
record.setTradeType(2);//1:保证金;2:货款;3:补偿款
|
|
|
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
|
|
|
try {
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setAmount(amount);
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
tradeBillsMapper.insert(record);
|
|
|
JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
|
|
|
BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
|
|
|
amount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
|
|
|
logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
|
|
|
return;
|
|
|
}
|
|
|
record.setAmount(amount);
|
|
|
record.setSystemAmount(amount);// 有货收入
|
|
|
record.setTradeStatus(0);//0:订单未完结;1:订单完结
|
|
|
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
|
|
addTradeBills(record);
|
|
|
}
|
|
|
|
|
|
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
|
...
|
...
|
|