Showing
1 changed file
with
30 additions
and
36 deletions
@@ -447,15 +447,28 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -447,15 +447,28 @@ public class PaymentServiceImpl implements IPaymentService { | ||
447 | logger.warn("transferMonErr uid {} 不合法", targetUid); | 447 | logger.warn("transferMonErr uid {} 不合法", targetUid); |
448 | throw new ServiceException(400, "uid[" + targetUid + "]不合法"); | 448 | throw new ServiceException(400, "uid[" + targetUid + "]不合法"); |
449 | } | 449 | } |
450 | + int now = (int) (System.currentTimeMillis()/1000); | ||
451 | + | ||
452 | + // 增加流水记录 | ||
453 | + TradeBills record = new TradeBills(); | ||
454 | + record.setUid(targetUid); | ||
455 | + record.setOrderCode(transferType == 1 ? sellerOrderCode : buyerOrderCode); | ||
456 | + record.setUserType(transferType == 1 ? 2 : 1); | ||
457 | + record.setPayType(1); | ||
458 | + record.setTradeType(transferType == 1 ? 2 : 3); | ||
459 | + record.setIncomeOutcome(1); | ||
460 | + record.setTradeStatus(transferType == 1 ? 0 : 1); | ||
461 | + record.setCreateTime(now); | ||
462 | + | ||
450 | String alipayAccount = getAlipayAccount(targetUid); | 463 | String alipayAccount = getAlipayAccount(targetUid); |
451 | if (StringUtils.isBlank(alipayAccount)) { | 464 | if (StringUtils.isBlank(alipayAccount)) { |
452 | logger.warn("transferMonErr uid {} 没有获取到有效的支付宝账号", targetUid); | 465 | logger.warn("transferMonErr uid {} 没有获取到有效的支付宝账号", targetUid); |
466 | + record.setTradeStatus(201); | ||
467 | + addTradeBills(record); | ||
453 | throw new ServiceException(400, "uid[" + targetUid + "]没有获取到有效的支付宝账号"); | 468 | throw new ServiceException(400, "uid[" + targetUid + "]没有获取到有效的支付宝账号"); |
454 | } | 469 | } |
455 | logger.info("transferMon参数检查成功!"); | 470 | logger.info("transferMon参数检查成功!"); |
456 | 471 | ||
457 | - int now = (int) (System.currentTimeMillis()/1000); | ||
458 | - | ||
459 | OrdersPayTransfer transfer = new OrdersPayTransfer(); | 472 | OrdersPayTransfer transfer = new OrdersPayTransfer(); |
460 | transfer.setBuyerOrderCode(buyerOrderCode); | 473 | transfer.setBuyerOrderCode(buyerOrderCode); |
461 | transfer.setSellerOrderCode(sellerOrderCode); | 474 | transfer.setSellerOrderCode(sellerOrderCode); |
@@ -482,9 +495,14 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -482,9 +495,14 @@ public class PaymentServiceImpl implements IPaymentService { | ||
482 | logger.info("transferMon计算费用结果为 {}", transferAmount); | 495 | logger.info("transferMon计算费用结果为 {}", transferAmount); |
483 | if (transferAmount == null || transferAmount.compareTo(new BigDecimal("0.1")) < 0) { | 496 | if (transferAmount == null || transferAmount.compareTo(new BigDecimal("0.1")) < 0) { |
484 | logger.warn("transferMonErr transferMon计算费用结果为 {}, 不合法的金额", transferAmount); | 497 | logger.warn("transferMonErr transferMon计算费用结果为 {}, 不合法的金额", transferAmount); |
485 | - throw new ServiceException(400, "不合法的金额"); | 498 | + record.setTradeStatus(202); |
499 | + addTradeBills(record); | ||
500 | + throw new ServiceException(400, "不合法的金额:" + transferAmount); | ||
486 | } | 501 | } |
487 | transfer.setAmount(transferAmount); | 502 | transfer.setAmount(transferAmount); |
503 | + record.setAmount(transferAmount); | ||
504 | + // 因为转账支付宝扣费累计计算,使用转账额 | ||
505 | + record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1"))); | ||
488 | 506 | ||
489 | // 转账 | 507 | // 转账 |
490 | try { | 508 | try { |
@@ -518,23 +536,15 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -518,23 +536,15 @@ public class PaymentServiceImpl implements IPaymentService { | ||
518 | logger.info("transferMon最后更新状态 status= {}", transfer.getStatus()); | 536 | logger.info("transferMon最后更新状态 status= {}", transfer.getStatus()); |
519 | transfer.setUpdateTime(now); | 537 | transfer.setUpdateTime(now); |
520 | ordersPayTransferMapper.updateByPrimaryKeySelective(transfer); | 538 | ordersPayTransferMapper.updateByPrimaryKeySelective(transfer); |
539 | + // 100:成功;201:没有支付宝账号;202:金额不合法;299:转账失败 | ||
540 | + record.setTradeStatus(transfer.getStatus() == 1 ? 100 : 299); | ||
541 | + addTradeBills(record); | ||
521 | logger.info("transferMon最后更新状态完成,转账结束, buyerOrderCode is {}!", buyerOrderCode); | 542 | logger.info("transferMon最后更新状态完成,转账结束, buyerOrderCode is {}!", buyerOrderCode); |
522 | } | 543 | } |
544 | + } | ||
523 | 545 | ||
524 | - // 增加流水记录 | ||
525 | - TradeBills record = new TradeBills(); | 546 | + private void addTradeBills(TradeBills record) { |
526 | try { | 547 | try { |
527 | - record.setUid(targetUid); | ||
528 | - record.setOrderCode(transferType == 1 ? sellerOrderCode : buyerOrderCode); | ||
529 | - record.setUserType(transferType == 1 ? 2 : 1); | ||
530 | - record.setPayType(1); | ||
531 | - record.setTradeType(transferType == 1 ? 2 : 3); | ||
532 | - record.setIncomeOutcome(1); | ||
533 | - record.setAmount(transferAmount); | ||
534 | - // 因为转账支付宝扣费累计计算,使用转账额 | ||
535 | - record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1"))); | ||
536 | - record.setTradeStatus(transferType == 1 ? 0 : 1); | ||
537 | - record.setCreateTime(now); | ||
538 | tradeBillsMapper.insert(record); | 548 | tradeBillsMapper.insert(record); |
539 | } catch (Exception e) { | 549 | } catch (Exception e) { |
540 | logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); | 550 | logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); |
@@ -550,7 +560,6 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -550,7 +560,6 @@ public class PaymentServiceImpl implements IPaymentService { | ||
550 | } | 560 | } |
551 | // 增加流水记录 | 561 | // 增加流水记录 |
552 | TradeBills record = new TradeBills(); | 562 | TradeBills record = new TradeBills(); |
553 | - try { | ||
554 | record.setUid(uid); | 563 | record.setUid(uid); |
555 | record.setOrderCode(orderCode); | 564 | record.setOrderCode(orderCode); |
556 | record.setUserType(2);// 1:买家uid; 2:卖家uid | 565 | record.setUserType(2);// 1:买家uid; 2:卖家uid |
@@ -569,10 +578,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -569,10 +578,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
569 | record.setSystemAmount(amount);// 有货收入 | 578 | record.setSystemAmount(amount);// 有货收入 |
570 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 | 579 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 |
571 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); | 580 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); |
572 | - tradeBillsMapper.insert(record); | ||
573 | - } catch (Exception e) { | ||
574 | - logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); | ||
575 | - } | 581 | + addTradeBills(record); |
576 | } | 582 | } |
577 | 583 | ||
578 | // 支付货款流水记录 | 584 | // 支付货款流水记录 |
@@ -584,7 +590,6 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -584,7 +590,6 @@ public class PaymentServiceImpl implements IPaymentService { | ||
584 | } | 590 | } |
585 | // 增加流水记录 | 591 | // 增加流水记录 |
586 | TradeBills record = new TradeBills(); | 592 | TradeBills record = new TradeBills(); |
587 | - try { | ||
588 | record.setUid(uid); | 593 | record.setUid(uid); |
589 | record.setOrderCode(orderCode); | 594 | record.setOrderCode(orderCode); |
590 | record.setUserType(1);// 1:买家uid; 2:卖家uid | 595 | record.setUserType(1);// 1:买家uid; 2:卖家uid |
@@ -603,10 +608,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -603,10 +608,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
603 | record.setSystemAmount(amount);// 有货收入 | 608 | record.setSystemAmount(amount);// 有货收入 |
604 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 | 609 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 |
605 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); | 610 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); |
606 | - tradeBillsMapper.insert(record); | ||
607 | - } catch (Exception e) { | ||
608 | - logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); | ||
609 | - } | 611 | + addTradeBills(record); |
610 | } | 612 | } |
611 | 613 | ||
612 | // 退保证金流水记录 | 614 | // 退保证金流水记录 |
@@ -618,7 +620,6 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -618,7 +620,6 @@ public class PaymentServiceImpl implements IPaymentService { | ||
618 | } | 620 | } |
619 | // 增加流水记录 | 621 | // 增加流水记录 |
620 | TradeBills record = new TradeBills(); | 622 | TradeBills record = new TradeBills(); |
621 | - try { | ||
622 | record.setUid(uid); | 623 | record.setUid(uid); |
623 | record.setOrderCode(orderCode); | 624 | record.setOrderCode(orderCode); |
624 | record.setUserType(2);// 1:买家uid; 2:卖家uid | 625 | record.setUserType(2);// 1:买家uid; 2:卖家uid |
@@ -637,10 +638,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -637,10 +638,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
637 | record.setSystemAmount(amount);// 有货收入 | 638 | record.setSystemAmount(amount);// 有货收入 |
638 | record.setTradeStatus(1);//0:订单未完结;1:订单完结 | 639 | record.setTradeStatus(1);//0:订单未完结;1:订单完结 |
639 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); | 640 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); |
640 | - tradeBillsMapper.insert(record); | ||
641 | - } catch (Exception e) { | ||
642 | - logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); | ||
643 | - } | 641 | + addTradeBills(record); |
644 | } | 642 | } |
645 | 643 | ||
646 | // 退付货款流水记录 | 644 | // 退付货款流水记录 |
@@ -652,7 +650,6 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -652,7 +650,6 @@ public class PaymentServiceImpl implements IPaymentService { | ||
652 | } | 650 | } |
653 | // 增加流水记录 | 651 | // 增加流水记录 |
654 | TradeBills record = new TradeBills(); | 652 | TradeBills record = new TradeBills(); |
655 | - try { | ||
656 | record.setUid(uid); | 653 | record.setUid(uid); |
657 | record.setOrderCode(orderCode); | 654 | record.setOrderCode(orderCode); |
658 | record.setUserType(1);// 1:买家uid; 2:卖家uid | 655 | record.setUserType(1);// 1:买家uid; 2:卖家uid |
@@ -671,10 +668,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -671,10 +668,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
671 | record.setSystemAmount(amount);// 有货收入 | 668 | record.setSystemAmount(amount);// 有货收入 |
672 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 | 669 | record.setTradeStatus(0);//0:订单未完结;1:订单完结 |
673 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); | 670 | record.setCreateTime((int) (System.currentTimeMillis() / 1000)); |
674 | - tradeBillsMapper.insert(record); | ||
675 | - } catch (Exception e) { | ||
676 | - logger.error("记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record); | ||
677 | - } | 671 | + addTradeBills(record); |
678 | } | 672 | } |
679 | 673 | ||
680 | private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) { | 674 | private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, int transferType) { |
-
Please register or login to post a comment