Authored by mali

Merge branch 'dev'

... ... @@ -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 {
... ... @@ -518,23 +536,15 @@ public class PaymentServiceImpl implements IPaymentService {
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();
private void addTradeBills(TradeBills record) {
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);
tradeBillsMapper.insert(record);
} catch (Exception e) {
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
... ... @@ -550,7 +560,6 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 增加流水记录
TradeBills record = new TradeBills();
try {
record.setUid(uid);
record.setOrderCode(orderCode);
record.setUserType(2);// 1:买家uid; 2:卖家uid
... ... @@ -569,10 +578,7 @@ public class PaymentServiceImpl implements IPaymentService {
record.setSystemAmount(amount);// 有货收入
record.setTradeStatus(0);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
tradeBillsMapper.insert(record);
} catch (Exception e) {
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
}
addTradeBills(record);
}
// 支付货款流水记录
... ... @@ -584,7 +590,6 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 增加流水记录
TradeBills record = new TradeBills();
try {
record.setUid(uid);
record.setOrderCode(orderCode);
record.setUserType(1);// 1:买家uid; 2:卖家uid
... ... @@ -603,14 +608,11 @@ public class PaymentServiceImpl implements IPaymentService {
record.setSystemAmount(amount);// 有货收入
record.setTradeStatus(0);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
tradeBillsMapper.insert(record);
} catch (Exception e) {
logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
}
addTradeBills(record);
}
// 退保证金流水记录
public void backPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payType, BigDecimal amount) {
public void backPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payType, BigDecimal amount, Integer tradeStatus) {
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, "fee");
if (meta == null) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
... ... @@ -618,7 +620,6 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 增加流水记录
TradeBills record = new TradeBills();
try {
record.setUid(uid);
record.setOrderCode(orderCode);
record.setUserType(2);// 1:买家uid; 2:卖家uid
... ... @@ -635,16 +636,13 @@ public class PaymentServiceImpl implements IPaymentService {
return;
}
record.setSystemAmount(amount);// 有货收入
record.setTradeStatus(1);//0:订单未完结;1:订单完结
record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
tradeBillsMapper.insert(record);
} catch (Exception e) {
logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
}
addTradeBills(record);
}
// 退付货款流水记录
public void backPayBuyRecord(Integer uid, Integer sellerUid, Integer skup, Long orderCode, Integer payType, BigDecimal amount) {
public void backPayBuyRecord(Integer uid, Integer sellerUid, Integer skup, Long orderCode, Integer payType, BigDecimal amount, Integer tradeStatus) {
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
if (meta == null) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);
... ... @@ -652,7 +650,6 @@ public class PaymentServiceImpl implements IPaymentService {
}
// 增加流水记录
TradeBills record = new TradeBills();
try {
record.setUid(uid);
record.setOrderCode(orderCode);
record.setUserType(1);// 1:买家uid; 2:卖家uid
... ... @@ -669,12 +666,9 @@ public class PaymentServiceImpl implements IPaymentService {
}
record.setAmount(amount);
record.setSystemAmount(amount);// 有货收入
record.setTradeStatus(0);//0:订单未完结;1:订单完结
record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
tradeBillsMapper.insert(record);
} catch (Exception e) {
logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
}
addTradeBills(record);
}
private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) {
... ...
... ... @@ -93,6 +93,15 @@
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-client-simple</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-server</artifactId>
</dependency>
<dependency>
<groupId>com.yohoufo.fore</groupId>
<artifactId>yohoufo-fore-inboxclient</artifactId>
</dependency>
... ...