Authored by LUOXC

Merge branch 'test6.9.10' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.10

# Conflicts:
#	order/src/main/java/com/yohoufo/order/service/impl/TradeBillsService.java
@@ -15,8 +15,20 @@ public interface AppraiseOrderMetaMapper { @@ -15,8 +15,20 @@ public interface AppraiseOrderMetaMapper {
15 15
16 AppraiseOrderMeta selectByPrimaryKey(Integer id); 16 AppraiseOrderMeta selectByPrimaryKey(Integer id);
17 17
  18 + /**
  19 + * 只适用子订单,使用子订单查询
  20 + * @param condition
  21 + * @return
  22 + */
18 AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition); 23 AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition);
19 24
  25 + /**
  26 + * 适用于卖家鉴定订单 根据父订单查询
  27 + * @param condition
  28 + * @return
  29 + */
  30 + List<AppraiseOrderMeta> selectAllByParentOrderCode(AppraiseOrderMeta condition);
  31 +
20 List<AppraiseOrderMeta> selectByOrderCodeMetaKeys(@Param("orderCode") long orderCode, 32 List<AppraiseOrderMeta> selectByOrderCodeMetaKeys(@Param("orderCode") long orderCode,
21 @Param("metaKeys") Collection<String> metaKeys); 33 @Param("metaKeys") Collection<String> metaKeys);
22 34
@@ -147,6 +147,7 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService { @@ -147,6 +147,7 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
147 AppraiseOrderStatus.HAS_PAYED.getCode(), 147 AppraiseOrderStatus.HAS_PAYED.getCode(),
148 AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode(), 148 AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode(),
149 AppraiseOrderStatus.JUDGE_PASS_WAIT_WAREHOUSE.getCode(), 149 AppraiseOrderStatus.JUDGE_PASS_WAIT_WAREHOUSE.getCode(),
  150 + AppraiseOrderStatus.CANCEL_BEFORE_DELIVER.getCode(),
150 AppraiseOrderStatus.SHAM_SEND_OUT.getCode(), 151 AppraiseOrderStatus.SHAM_SEND_OUT.getCode(),
151 AppraiseOrderStatus.SEND_OUT_TIMEOUT.getCode() 152 AppraiseOrderStatus.SEND_OUT_TIMEOUT.getCode()
152 ); 153 );
@@ -22,7 +22,7 @@ public class AppraiseExpressStageBuilder { @@ -22,7 +22,7 @@ public class AppraiseExpressStageBuilder {
22 /** 22 /**
23 * 平台确认收货 23 * 平台确认收货
24 * 24 *
25 - * 1卖家发货 == 2平台鉴定 点亮1 25 + * 1卖家发货 == 2平台鉴定 点亮2
26 */ 26 */
27 private static final int DEPOSIT_PLATFORM_RECEIPT = 11; 27 private static final int DEPOSIT_PLATFORM_RECEIPT = 11;
28 28
@@ -16,6 +16,7 @@ import java.util.stream.Collectors; @@ -16,6 +16,7 @@ import java.util.stream.Collectors;
16 16
17 import javax.annotation.Resource; 17 import javax.annotation.Resource;
18 18
  19 +import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
19 import com.yohobuy.ufo.model.order.common.*; 20 import com.yohobuy.ufo.model.order.common.*;
20 import com.yohoufo.dal.order.*; 21 import com.yohoufo.dal.order.*;
21 import com.yohoufo.dal.order.model.*; 22 import com.yohoufo.dal.order.model.*;
@@ -504,9 +505,9 @@ public class AppraiseService { @@ -504,9 +505,9 @@ public class AppraiseService {
504 return apiResponse; 505 return apiResponse;
505 } 506 }
506 507
507 - // 1.瑕疵,鉴定为假,虚假发货,质检不通过取消 508 + // 1.鉴定为假,质检不通过
508 List<Integer> APPRAISE_FAIL_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.CHECKING_FAKE.getCode(), 509 List<Integer> APPRAISE_FAIL_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.CHECKING_FAKE.getCode(),
509 - AppraiseOrderStatus.SHAM_SEND_OUT.getCode(), AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode()); 510 + AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode());
510 511
511 // 2.无法鉴定 512 // 2.无法鉴定
512 List<Integer> CANNOT_APPRAISE_STATUS_CODE = Lists.newArrayList( 513 List<Integer> CANNOT_APPRAISE_STATUS_CODE = Lists.newArrayList(
@@ -588,9 +589,21 @@ public class AppraiseService { @@ -588,9 +589,21 @@ public class AppraiseService {
588 589
589 // 子订单对应商品 1:1 590 // 子订单对应商品 1:1
590 AppraiseOrderGoods oneAppraiseOrderGood = appraiseOrderGoods.get(0); 591 AppraiseOrderGoods oneAppraiseOrderGood = appraiseOrderGoods.get(0);
591 - inBoxFacade.sendInboxSmsWhenAppraiseFinished(uid, oneAppraiseOrderGood.getProductName(),  
592 - oneAppraiseOrderGood.getProductCode(),  
593 - wayBillCode); 592 +
  593 + if (APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())
  594 + || APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getStatus())){
  595 + inBoxFacade.sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum.INBOX_DELIVERY_APPRAISE_FINISHED,
  596 + InboxBusinessTypeEnum.SMS_DELIVERY_APPRAISE_FINISHED,
  597 + uid, oneAppraiseOrderGood.getProductName(),
  598 + oneAppraiseOrderGood.getProductCode(),
  599 + wayBillCode);
  600 + }else if(CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())){
  601 + inBoxFacade.sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum.INBOX_DELIVERY_CANNOT_APPRAISE,
  602 + InboxBusinessTypeEnum.SMS_DELIVERY_CANNOT_APPRAISE,
  603 + uid, oneAppraiseOrderGood.getProductName(),
  604 + oneAppraiseOrderGood.getProductCode(),
  605 + wayBillCode);
  606 + }
594 } 607 }
595 608
596 if (appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode()) { // 鉴定寄存的订单,需要同步修改寄存表的状态 609 if (appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode()) { // 鉴定寄存的订单,需要同步修改寄存表的状态
@@ -1741,13 +1754,14 @@ public class AppraiseService { @@ -1741,13 +1754,14 @@ public class AppraiseService {
1741 List<Integer> skupList = buyerOrderGoodses.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList()); 1754 List<Integer> skupList = buyerOrderGoodses.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
1742 1755
1743 sellerOrderGoodsMapper.updateDeptNoBySkups(skupList, appraiseExpressInfoBo.getDepotNum()); 1756 sellerOrderGoodsMapper.updateDeptNoBySkups(skupList, appraiseExpressInfoBo.getDepotNum());
1744 - expressRecordMapper.updateDeptNoByOrder(orderCodeList, EnumExpressType.EXPRESS_TYPE_1.getCode(), appraiseExpressInfoBo.getDepotNum());  
1745 1757
1746 productProxyService.setBatchDepotNum(skupList, appraiseExpressInfoBo.getDepotNum()); 1758 productProxyService.setBatchDepotNum(skupList, appraiseExpressInfoBo.getDepotNum());
1747 } 1759 }
1748 1760
1749 // 更新鉴定订单的鉴定室 1761 // 更新鉴定订单的鉴定室
1750 appraiseOrderGoodsMapper.updateBatchDepotNo(orderCodeList, appraiseExpressInfoBo.getDepotNum()); 1762 appraiseOrderGoodsMapper.updateBatchDepotNo(orderCodeList, appraiseExpressInfoBo.getDepotNum());
  1763 +
  1764 + expressRecordMapper.updateDeptNoByOrder(orderCodeList, EnumExpressType.EXPRESS_TYPE_1.getCode(), appraiseExpressInfoBo.getDepotNum());
1751 } 1765 }
1752 } 1766 }
1753 1767
@@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.ProductInfo; @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.ProductInfo;
6 import com.yohobuy.ufo.model.order.bo.DepositProductBo; 6 import com.yohobuy.ufo.model.order.bo.DepositProductBo;
7 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus; 7 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
8 import com.yohobuy.ufo.model.order.common.OrderAttributes; 8 import com.yohobuy.ufo.model.order.common.OrderAttributes;
  9 +import com.yohobuy.ufo.model.order.constants.DepositSourceEnum;
9 import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp; 10 import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
10 import com.yohobuy.ufo.model.order.resp.OrderDetailInfo; 11 import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
11 import com.yohobuy.ufo.model.response.StorageDataResp; 12 import com.yohobuy.ufo.model.response.StorageDataResp;
@@ -15,11 +16,9 @@ import com.yohoufo.common.utils.AppVersion; @@ -15,11 +16,9 @@ import com.yohoufo.common.utils.AppVersion;
15 import com.yohoufo.common.utils.DateUtil; 16 import com.yohoufo.common.utils.DateUtil;
16 import com.yohoufo.common.utils.StringUtil; 17 import com.yohoufo.common.utils.StringUtil;
17 import com.yohoufo.dal.order.AppraiseOrderMapper; 18 import com.yohoufo.dal.order.AppraiseOrderMapper;
  19 +import com.yohoufo.dal.order.BuyerOrderMapper;
18 import com.yohoufo.dal.order.DepositCodeMapper; 20 import com.yohoufo.dal.order.DepositCodeMapper;
19 -import com.yohoufo.dal.order.model.AppraiseOrder;  
20 -import com.yohoufo.dal.order.model.DepositCode;  
21 -import com.yohoufo.dal.order.model.SellerOrderGoods;  
22 -import com.yohoufo.dal.order.model.StorageDepositCount; 21 +import com.yohoufo.dal.order.model.*;
23 import org.apache.commons.collections.CollectionUtils; 22 import org.apache.commons.collections.CollectionUtils;
24 import org.apache.commons.lang3.StringUtils; 23 import org.apache.commons.lang3.StringUtils;
25 import org.slf4j.Logger; 24 import org.slf4j.Logger;
@@ -27,10 +26,9 @@ import org.slf4j.LoggerFactory; @@ -27,10 +26,9 @@ import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Service; 27 import org.springframework.stereotype.Service;
29 28
30 -import java.util.HashMap;  
31 -import java.util.Iterator;  
32 -import java.util.List;  
33 -import java.util.Map; 29 +import java.math.BigDecimal;
  30 +import java.util.*;
  31 +import java.util.function.Function;
34 import java.util.stream.Collectors; 32 import java.util.stream.Collectors;
35 33
36 /** 34 /**
@@ -49,6 +47,9 @@ public class DepositHelpService { @@ -49,6 +47,9 @@ public class DepositHelpService {
49 @Autowired 47 @Autowired
50 private AppraiseOrderMapper appraiseOrderMapper; 48 private AppraiseOrderMapper appraiseOrderMapper;
51 49
  50 + @Autowired
  51 + private BuyerOrderMapper buyerOrderMapper;
  52 +
52 // 是否 24小时反馈时间 如果是则返回true 53 // 是否 24小时反馈时间 如果是则返回true
53 public boolean isFeedback(int depositRemainDay) { 54 public boolean isFeedback(int depositRemainDay) {
54 return -1 * DepositOrderComputeResp.FEEDBACK_DAY <= depositRemainDay && depositRemainDay <= 0; 55 return -1 * DepositOrderComputeResp.FEEDBACK_DAY <= depositRemainDay && depositRemainDay <= 0;
@@ -249,4 +250,27 @@ public class DepositHelpService { @@ -249,4 +250,27 @@ public class DepositHelpService {
249 public String queryEarnestMoneyStatus(Integer status) { 250 public String queryEarnestMoneyStatus(Integer status) {
250 return Integer.valueOf(AppraiseOrderStatus.CHECKING_FAKE.getCode()).equals(status) ? "已扣除" : "原路退还"; 251 return Integer.valueOf(AppraiseOrderStatus.CHECKING_FAKE.getCode()).equals(status) ? "已扣除" : "原路退还";
251 } 252 }
  253 +
  254 + /**
  255 + * 获取入手价
  256 + * @param countInfoList
  257 + * @return
  258 + */
  259 + public Map<Long, BuyerOrder> getOrderAmountMap(List<StorageDeposit> depositList) {
  260 + if (CollectionUtils.isEmpty(depositList)) {
  261 + return Maps.newHashMap();
  262 + }
  263 +
  264 + Collection<Long> orderCodeList = depositList.stream()
  265 + .filter(item -> DepositSourceEnum.SOURCE_BUYER.getCode().equals(item.getSource())).map(StorageDeposit::getOrderCode).collect(Collectors.toList());
  266 +
  267 + if (CollectionUtils.isEmpty(orderCodeList)) {
  268 + return Maps.newHashMap();
  269 + }
  270 +
  271 + List<BuyerOrder> buyerGoodsList = buyerOrderMapper.selectByOrderCodes(orderCodeList, null);
  272 + Map<Long, BuyerOrder> buyerGoodsMap = buyerGoodsList.stream().map(Function.identity()).collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
  273 +
  274 + return buyerGoodsMap;
  275 + }
252 } 276 }
@@ -131,14 +131,13 @@ public class DepositServiceImpl implements DepositService { @@ -131,14 +131,13 @@ public class DepositServiceImpl implements DepositService {
131 } 131 }
132 // 召回或者到期退回的 132 // 召回或者到期退回的
133 List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit); 133 List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
134 - List<BuyerOrder> buyerGoodsList = buyerOrderMapper.selectByOrderCodes(depositList.stream()  
135 - .filter(item -> DepositSourceEnum.SOURCE_BUYER.getCode().equals(item.getSource())).map(StorageDeposit::getOrderCode).collect(Collectors.toList()), null); 134 +
136 135
137 // 查询现货寄存订单的状态 136 // 查询现货寄存订单的状态
138 Map<Long, String> appraiseOrderStatusMap = depositHelpService.queryAppraiseOrderStatus(depositList.stream() 137 Map<Long, String> appraiseOrderStatusMap = depositHelpService.queryAppraiseOrderStatus(depositList.stream()
139 .filter(item -> DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode().equals(item.getOutType())).map(StorageDeposit::getOrderCode).collect(Collectors.toList())); 138 .filter(item -> DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode().equals(item.getOutType())).map(StorageDeposit::getOrderCode).collect(Collectors.toList()));
140 139
141 - Map<Long, BuyerOrder> buyerGoodsMap = buyerGoodsList.stream().map(Function.identity()).collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity())); 140 + Map<Long, BuyerOrder> buyerGoodsMap = depositHelpService.getOrderAmountMap(depositList);
142 141
143 142
144 List<Integer> storageList = depositList.stream().map(StorageDeposit::getStorageId).collect(Collectors.toList()); 143 List<Integer> storageList = depositList.stream().map(StorageDeposit::getStorageId).collect(Collectors.toList());
@@ -258,6 +258,7 @@ public class QiniuLiveRecordService { @@ -258,6 +258,7 @@ public class QiniuLiveRecordService {
258 resp.setProductId(item.getProductId()); 258 resp.setProductId(item.getProductId());
259 resp.setProductPicUrl(null == orderVideoResp ? "" : orderVideoResp.getProductPicUrl()); 259 resp.setProductPicUrl(null == orderVideoResp ? "" : orderVideoResp.getProductPicUrl());
260 resp.setAppraise_result(item.getAppraiseResult()); 260 resp.setAppraise_result(item.getAppraiseResult());
  261 + resp.setOrderCode(item.getOrderCode());
261 result.add(resp); 262 result.add(resp);
262 }); 263 });
263 264
1 -package com.yohoufo.order.service.impl;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject;  
5 -import com.yohoufo.common.alarm.CommonAlarmEventPublisher;  
6 -import com.yohoufo.common.utils.BigDecimalHelper;  
7 -import com.yohoufo.common.utils.DateUtil;  
8 -import com.yohoufo.dal.order.AppraiseOrderMetaMapper;  
9 -import com.yohoufo.dal.order.SellerOrderMetaMapper;  
10 -import com.yohoufo.dal.order.TradeBillsMapper;  
11 -import com.yohoufo.dal.order.model.AppraiseOrderMeta;  
12 -import com.yohoufo.dal.order.model.SellerOrder;  
13 -import com.yohoufo.dal.order.model.SellerOrderMeta;  
14 -import com.yohoufo.dal.order.model.TradeBills;  
15 -import com.yohobuy.ufo.model.order.common.Payment;  
16 -import com.yohoufo.order.common.BillTradeStatus;  
17 -import com.yohoufo.order.constants.MetaKey;  
18 -import com.yohoufo.order.model.dto.SellerOrderComputeResult;  
19 -import org.apache.commons.lang3.ObjectUtils;  
20 -import org.slf4j.Logger;  
21 -import org.slf4j.LoggerFactory;  
22 -import org.springframework.beans.factory.annotation.Autowired;  
23 -import org.springframework.stereotype.Service;  
24 -  
25 -import java.math.BigDecimal;  
26 -import java.util.List;  
27 -import java.util.Objects;  
28 -  
29 -/**  
30 - * Created by chenchao on 2018/10/10.  
31 - */  
32 -@Service  
33 -public class TradeBillsService {  
34 -  
35 - final Logger logger = LoggerFactory.getLogger(getClass());  
36 -  
37 - @Autowired  
38 - SellerOrderMetaMapper sellerOrderMetaMapper;  
39 -  
40 - @Autowired  
41 - TradeBillsMapper tradeBillsMapper;  
42 -  
43 - @Autowired  
44 - private ServiceOrderProcessor serviceOrderProcessor;  
45 -  
46 - @Autowired  
47 - private AppraiseOrderMetaMapper appraiseOrderMetaMapper;  
48 -  
49 - /**  
50 - * 退保证金流水记录  
51 - *  
52 - * @param uid  
53 - * @param skup  
54 - * @param orderCode  
55 - * @param payType  
56 - * @param tradeStatus  
57 - */  
58 - public void backPayEnsureRecord(Integer uid,  
59 - Integer skup,  
60 - Long orderCode,  
61 - Long paidOrderCode,  
62 - Integer payType,  
63 - Integer tradeStatus) {  
64 -  
65 -  
66 - String computeResultVal = null;  
67 -  
68 - if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){  
69 - AppraiseOrderMeta feeCondition = new AppraiseOrderMeta();  
70 - feeCondition.setOrderCode(orderCode);  
71 - feeCondition.setMetaKey(MetaKey.SELLER_FEE);  
72 - AppraiseOrderMeta feeMeta = appraiseOrderMetaMapper.selectByOrderCode(feeCondition);  
73 - computeResultVal = Objects.nonNull(feeMeta) ? feeMeta.getMetaValue() : null;  
74 - logger.info("in backPayEnsureRecord isGoodsServiceOrder orderCode {} computeResultVal {}", orderCode, computeResultVal);  
75 - }else {  
76 - SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);  
77 - computeResultVal = Objects.nonNull(meta) ? meta.getMetaValue() : null;  
78 - logger.info("in backPayEnsureRecord buyerorder orderCode {} computeResultVal {}", orderCode, computeResultVal);  
79 - }  
80 -  
81 - if (Objects.isNull(computeResultVal)) {  
82 - logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);  
83 - return;  
84 - }  
85 - try{  
86 - SellerOrderComputeResult socr = JSONObject.parseObject(computeResultVal, SellerOrderComputeResult.class);  
87 - BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();  
88 - BigDecimal systemAmount = calSystemAmountByComputeResult(socr);  
89 - backPayEnsureRecord0(uid, orderCode, paidOrderCode, payType, tradeStatus, earnestMoney, systemAmount);  
90 -  
91 - }catch (Exception ex){  
92 - logger.error("backPayEnsureRecord error, uid {},orderCode {} computeResultVal {}",  
93 - uid, orderCode, computeResultVal, ex);  
94 - }  
95 -  
96 -  
97 - }  
98 -  
99 -  
100 - private void backPayEnsureRecord0(Integer uid,  
101 - Long orderCode,  
102 - Long paidOrderCode,  
103 - Integer payType,  
104 - Integer tradeStatus,  
105 - BigDecimal earnestMoney,  
106 - BigDecimal systemAmount  
107 - ) {  
108 - if (payType != null && Payment.WALLET.getCode() == payType) {  
109 - return;  
110 - }  
111 -  
112 -  
113 - // 增加流水记录  
114 - TradeBills record = new TradeBills();  
115 - record.setUid(uid);  
116 - record.setOrderCode(orderCode);  
117 - record.setPaidOrderCode(ObjectUtils.defaultIfNull(paidOrderCode, 0L));  
118 - record.setUserType(2);// 1:买家uid; 2:卖家uid  
119 - record.setPayType(payType);// 1:支付宝; 2:微信  
120 - record.setTradeType(1);//1:保证金;2:货款;3:补偿款  
121 - record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出  
122 - record.setAmount(earnestMoney);  
123 - record.setSystemAmount(systemAmount);// 有货收入  
124 - record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结  
125 - record.setCreateTime((int) (System.currentTimeMillis() / 1000));  
126 - addTradeBills(record);  
127 - }  
128 -  
129 -  
130 - BigDecimal calSystemAmountByComputeResult(SellerOrderComputeResult socr){  
131 - BigDecimal amount = BigDecimal.ZERO;  
132 - try {  
133 - BigDecimal rate = socr.getServiceFeeRate().getPayChannelRate();  
134 - BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();  
135 - amount = BigDecimalHelper.halfUp(earnestMoney.multiply(BigDecimal.ONE.subtract(rate)).negate());  
136 - } catch (Exception e) {  
137 - logger.warn("calSystemAmountByComputeResult fail SellerOrderComputeResult {}", socr);  
138 - }  
139 - return amount;  
140 - }  
141 -  
142 - /**  
143 - * 退付货款流水记录  
144 - *  
145 - * @param uid  
146 - * @param sellerUid  
147 - * @param skup  
148 - * @param orderCode  
149 - * @param payType  
150 - * @param amount  
151 - * @param tradeStatus  
152 - */  
153 - public void backPayBuyRecord(Integer uid, Integer sellerUid, Integer skup,  
154 - Long orderCode, Long paidOrderCode, Integer payType, BigDecimal amount,  
155 - Integer tradeStatus) {  
156 -  
157 - if (payType != null && Payment.WALLET.getCode() == payType) {  
158 - return;  
159 - }  
160 -  
161 - SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");  
162 - if (meta == null) {  
163 - logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);  
164 - return;  
165 - }  
166 - // 增加流水记录  
167 - TradeBills record = new TradeBills();  
168 - record.setUid(uid);  
169 - record.setOrderCode(orderCode);  
170 - record.setPaidOrderCode(ObjectUtils.defaultIfNull(paidOrderCode, 0L));  
171 - record.setUserType(1);// 1:买家uid; 2:卖家uid  
172 - record.setPayType(payType);// 1:支付宝; 2:微信  
173 - record.setTradeType(2);//1:保证金;2:货款;3:补偿款  
174 - record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出  
175 - record.setAmount(amount);  
176 - try {  
177 - JSONObject metavalue = JSON.parseObject(meta.getMetaValue());  
178 - BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");  
179 - BigDecimal samount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);  
180 - record.setSystemAmount(samount);// 有货收入  
181 - } catch (Exception e) {  
182 - logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());  
183 - // return;  
184 - }  
185 -  
186 - record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结  
187 - record.setCreateTime((int) (System.currentTimeMillis() / 1000));  
188 - addTradeBills(record);  
189 - }  
190 -  
191 -  
192 - public void addTradeBills(TradeBills record) {  
193 - try {  
194 - tradeBillsMapper.insert(record);  
195 - } catch (Exception e) {  
196 - logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);  
197 - alarm("记录流水到数据库出错", "ufo.order.addTradeBills",  
198 - "流水信息:" + record.toString() + ",msg=" + e.getMessage());  
199 - }  
200 - }  
201 -  
202 - private void alarm(String name, String type, String content) {  
203 - CommonAlarmEventPublisher.publish(name, type, content);  
204 - }  
205 -  
206 - public double queryBuyerPenaltyAmount(Long orderCode){  
207 - TradeBills condition = new TradeBills();  
208 - condition.setOrderCode(orderCode);  
209 - condition.setTradeType(3);  
210 - List<TradeBills> tbs = tradeBillsMapper.selectByKeyProps(condition);  
211 - double penaltyAmount = 0D;  
212 - if (tbs != null && tbs.size() > 0){  
213 - TradeBills ptb = tbs.get(0);  
214 - penaltyAmount = ptb.getAmount() == null ? penaltyAmount : ptb.getAmount().doubleValue();  
215 - }  
216 - return penaltyAmount;  
217 - }  
218 -  
219 - private Integer adaptPayType(Integer payment){  
220 - // 流水记录表支付方式适配  
221 - Integer recordPayment = payment;  
222 - if (recordPayment != null) {  
223 - if (recordPayment == 1) {  
224 - recordPayment = 2;  
225 - } else if (recordPayment == 2) {  
226 - recordPayment = 1;  
227 - }  
228 - }  
229 - return recordPayment;  
230 - }  
231 -  
232 -  
233 - /**  
234 - * 支付货款流水记录  
235 - * @param uid  
236 - * @param sellerUid  
237 - * @param skup  
238 - * @param orderCode  
239 - * @param payment  
240 - * @param amount  
241 - */  
242 - public void addPayBuyRecord(Integer uid, Integer sellerUid, Integer skup, Long orderCode, Integer payment, BigDecimal amount) {  
243 - SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");  
244 - if (meta == null) {  
245 - logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);  
246 - return;  
247 - }  
248 - Integer payType = adaptPayType(payment);  
249 - // 增加流水记录  
250 - TradeBills record = new TradeBills();  
251 - record.setUid(uid);  
252 - record.setOrderCode(orderCode);  
253 - record.setPaidOrderCode(0L);  
254 - record.setUserType(1);// 1:买家uid; 2:卖家uid  
255 - record.setPayType(payType);// 1:支付宝; 2:微信  
256 - record.setTradeType(2);//1:保证金;2:货款;3:补偿款  
257 - record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出  
258 - record.setAmount(amount);  
259 - try {  
260 - JSONObject metavalue = JSON.parseObject(meta.getMetaValue());  
261 - BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");  
262 - amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);  
263 - } catch (Exception e) {  
264 - logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());  
265 - return;  
266 - }  
267 -  
268 - record.setSystemAmount(amount);// 有货收入  
269 - record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());  
270 - record.setCreateTime((int) (System.currentTimeMillis() / 1000));  
271 - addTradeBills(record);  
272 - }  
273 -  
274 - /**  
275 - * 支付保证金流水记录  
276 - * @param uid  
277 - * @param skup  
278 - * @param orderCode  
279 - * @param payment  
280 - * @param amount  
281 - */  
282 - public void addPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payment, BigDecimal amount) {  
283 - SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, "fee");  
284 - if (meta == null) {  
285 - logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);  
286 - return;  
287 - }  
288 - Integer payType = adaptPayType(payment);  
289 - // 增加流水记录  
290 - TradeBills record = new TradeBills();  
291 - record.setUid(uid);  
292 - record.setOrderCode(orderCode);  
293 - record.setPaidOrderCode(0L);  
294 - record.setUserType(2);// 1:买家uid; 2:卖家uid  
295 - record.setPayType(payType);// 1:支付宝; 2:微信  
296 - record.setTradeType(1);//1:保证金;2:货款;3:补偿款  
297 - record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出  
298 - record.setAmount(amount);  
299 - try {  
300 - JSONObject metavalue = JSON.parseObject(meta.getMetaValue());  
301 - BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");  
302 - amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);  
303 - } catch (Exception e) {  
304 - logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());  
305 - return;  
306 - }  
307 - record.setSystemAmount(amount);// 有货收入  
308 - record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());  
309 - record.setCreateTime((int) (System.currentTimeMillis() / 1000));  
310 - addTradeBills(record);  
311 - }  
312 -  
313 - /**  
314 - * 添加充值保证金流水  
315 - * @param uid  
316 - * @param orderCode  
317 - * @param payment  
318 - * @param amount  
319 - */  
320 - public void addPayRechargeEnsureRecord(Integer uid, Long orderCode, Integer payment, BigDecimal amount) {  
321 -  
322 - Integer payType = adaptPayType(payment);  
323 - TradeBills record = new TradeBills();  
324 - record.setUid(uid);  
325 - record.setOrderCode(orderCode);  
326 - record.setPaidOrderCode(0L);  
327 - record.setUserType(2);// 1:买家uid; 2:卖家uid  
328 - record.setPayType(payType);// 1:支付宝; 2:微信  
329 - record.setTradeType(1);//1:保证金;2:货款;3:补偿款  
330 - record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出  
331 - record.setAmount(amount);  
332 - record.setSystemAmount(amount);// 有货收入  
333 - record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());  
334 - record.setCreateTime(DateUtil.getCurrentTimeSecond());  
335 - addTradeBills(record);  
336 - }  
337 -} 1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.yohobuy.ufo.model.order.common.Payment;
  6 +import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
  7 +import com.yohoufo.common.utils.BigDecimalHelper;
  8 +import com.yohoufo.common.utils.DateUtil;
  9 +import com.yohoufo.dal.order.SellerOrderMetaMapper;
  10 +import com.yohoufo.dal.order.TradeBillsMapper;
  11 +import com.yohoufo.dal.order.model.SellerOrderMeta;
  12 +import com.yohoufo.dal.order.model.TradeBills;
  13 +import com.yohoufo.order.common.BillTradeStatus;
  14 +import com.yohoufo.order.constants.MetaKey;
  15 +import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  16 +import org.apache.commons.lang3.ObjectUtils;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Service;
  21 +
  22 +import java.math.BigDecimal;
  23 +import java.util.List;
  24 +import java.util.Objects;
  25 +
  26 +/**
  27 + * Created by chenchao on 2018/10/10.
  28 + */
  29 +@Service
  30 +public class TradeBillsService {
  31 +
  32 + final Logger logger = LoggerFactory.getLogger(getClass());
  33 +
  34 + @Autowired
  35 + SellerOrderMetaMapper sellerOrderMetaMapper;
  36 +
  37 + @Autowired
  38 + TradeBillsMapper tradeBillsMapper;
  39 +
  40 + @Autowired
  41 + private ServiceOrderProcessor serviceOrderProcessor;
  42 +
  43 +
  44 + /**
  45 + * 退保证金流水记录
  46 + *
  47 + * @param uid
  48 + * @param skup
  49 + * @param orderCode
  50 + * @param payType
  51 + * @param tradeStatus
  52 + */
  53 + public void backPayEnsureRecord(Integer uid,
  54 + Integer skup,
  55 + Long orderCode,
  56 + Long paidOrderCode,
  57 + Integer payType,
  58 + Integer tradeStatus) {
  59 +
  60 +
  61 + String computeResultVal = null;
  62 +
  63 + BigDecimal earnestMoney = null;
  64 + BigDecimal systemAmount = null;
  65 + if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
  66 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
  67 + if(!existenceNode.isExisted()){
  68 + return;
  69 + }
  70 + earnestMoney = existenceNode.getAppraiseOrder().getAmount();
  71 + systemAmount = earnestMoney.negate();
  72 + logger.info("in backPayEnsureRecord isGoodsServiceOrder orderCode {} earnestMoney {}", orderCode, computeResultVal);
  73 + }else {
  74 + SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);
  75 + computeResultVal = Objects.nonNull(meta) ? meta.getMetaValue() : null;
  76 + logger.info("in backPayEnsureRecord buyerorder orderCode {} computeResultVal {}", orderCode, computeResultVal);
  77 + SellerOrderComputeResult socr = JSONObject.parseObject(computeResultVal, SellerOrderComputeResult.class);
  78 + earnestMoney = socr.getEarnestMoney().getEarnestMoney();
  79 + systemAmount = calSystemAmountByComputeResult(socr);
  80 + }
  81 +
  82 + if (Objects.isNull(systemAmount) || Objects.isNull(systemAmount)) {
  83 + logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, orderCode {}", uid, orderCode);
  84 + return;
  85 + }
  86 + try{
  87 +
  88 + backPayEnsureRecord0(uid, orderCode,paidOrderCode, payType, tradeStatus, earnestMoney, systemAmount);
  89 +
  90 + }catch (Exception ex){
  91 + logger.error("backPayEnsureRecord error, uid {},orderCode {} computeResultVal {}",
  92 + uid, orderCode, computeResultVal, ex);
  93 + }
  94 +
  95 +
  96 + }
  97 +
  98 +
  99 + private void backPayEnsureRecord0(Integer uid,
  100 + Long orderCode,
  101 + Long paidOrderCode,
  102 + Integer payType,
  103 + Integer tradeStatus,
  104 + BigDecimal earnestMoney,
  105 + BigDecimal systemAmount
  106 + ) {
  107 + if (payType != null && Payment.WALLET.getCode() == payType) {
  108 + return;
  109 + }
  110 +
  111 +
  112 + // 增加流水记录
  113 + TradeBills record = new TradeBills();
  114 + record.setUid(uid);
  115 + record.setOrderCode(orderCode);
  116 + record.setPaidOrderCode(ObjectUtils.defaultIfNull(paidOrderCode, 0L));
  117 + record.setUserType(2);// 1:买家uid; 2:卖家uid
  118 + record.setPayType(payType);// 1:支付宝; 2:微信
  119 + record.setTradeType(1);//1:保证金;2:货款;3:补偿款
  120 + record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
  121 + record.setAmount(earnestMoney);
  122 + record.setSystemAmount(systemAmount);// 有货收入
  123 + record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
  124 + record.setCreateTime((int) (System.currentTimeMillis() / 1000));
  125 + addTradeBills(record);
  126 + }
  127 +
  128 +
  129 + BigDecimal calSystemAmountByComputeResult(SellerOrderComputeResult socr){
  130 + BigDecimal amount = BigDecimal.ZERO;
  131 + try {
  132 + BigDecimal rate = socr.getServiceFeeRate().getPayChannelRate();
  133 + BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();
  134 + amount = BigDecimalHelper.halfUp(earnestMoney.multiply(BigDecimal.ONE.subtract(rate)).negate());
  135 + } catch (Exception e) {
  136 + logger.warn("calSystemAmountByComputeResult fail SellerOrderComputeResult {}", socr);
  137 + }
  138 + return amount;
  139 + }
  140 +
  141 + /**
  142 + * 退付货款流水记录
  143 + *
  144 + * @param uid
  145 + * @param sellerUid
  146 + * @param skup
  147 + * @param orderCode
  148 + * @param payType
  149 + * @param amount
  150 + * @param tradeStatus
  151 + */
  152 + public void backPayBuyRecord(Integer uid, Integer sellerUid, Integer skup,
  153 + Long orderCode, Long paidOrderCode, Integer payType, BigDecimal amount,
  154 + Integer tradeStatus) {
  155 +
  156 + if (payType != null && Payment.WALLET.getCode() == payType) {
  157 + return;
  158 + }
  159 +
  160 + SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
  161 + if (meta == null) {
  162 + logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);
  163 + return;
  164 + }
  165 + // 增加流水记录
  166 + TradeBills record = new TradeBills();
  167 + record.setUid(uid);
  168 + record.setOrderCode(orderCode);
  169 + record.setPaidOrderCode(ObjectUtils.defaultIfNull(paidOrderCode, 0L));
  170 + record.setUserType(1);// 1:买家uid; 2:卖家uid
  171 + record.setPayType(payType);// 1:支付宝; 2:微信
  172 + record.setTradeType(2);//1:保证金;2:货款;3:补偿款
  173 + record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
  174 + record.setAmount(amount);
  175 + try {
  176 + JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
  177 + BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
  178 + BigDecimal samount = amount.multiply(BigDecimal.ONE.subtract(rate)).multiply(new BigDecimal("-1")).setScale(2, BigDecimal.ROUND_HALF_UP);
  179 + record.setSystemAmount(samount);// 有货收入
  180 + } catch (Exception e) {
  181 + logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
  182 + // return;
  183 + }
  184 +
  185 + record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
  186 + record.setCreateTime((int) (System.currentTimeMillis() / 1000));
  187 + addTradeBills(record);
  188 + }
  189 +
  190 +
  191 + public void addTradeBills(TradeBills record) {
  192 + try {
  193 + tradeBillsMapper.insert(record);
  194 + } catch (Exception e) {
  195 + logger.error("PayRecordErr记录交易到数据库出错 err={}, rec = {}", e.getMessage(), record);
  196 + alarm("记录流水到数据库出错", "ufo.order.addTradeBills",
  197 + "流水信息:" + record.toString() + ",msg=" + e.getMessage());
  198 + }
  199 + }
  200 +
  201 + private void alarm(String name, String type, String content) {
  202 + CommonAlarmEventPublisher.publish(name, type, content);
  203 + }
  204 +
  205 + public double queryBuyerPenaltyAmount(Long orderCode){
  206 + TradeBills condition = new TradeBills();
  207 + condition.setOrderCode(orderCode);
  208 + condition.setTradeType(3);
  209 + List<TradeBills> tbs = tradeBillsMapper.selectByKeyProps(condition);
  210 + double penaltyAmount = 0D;
  211 + if (tbs != null && tbs.size() > 0){
  212 + TradeBills ptb = tbs.get(0);
  213 + penaltyAmount = ptb.getAmount() == null ? penaltyAmount : ptb.getAmount().doubleValue();
  214 + }
  215 + return penaltyAmount;
  216 + }
  217 +
  218 + private Integer adaptPayType(Integer payment){
  219 + // 流水记录表支付方式适配
  220 + Integer recordPayment = payment;
  221 + if (recordPayment != null) {
  222 + if (recordPayment == 1) {
  223 + recordPayment = 2;
  224 + } else if (recordPayment == 2) {
  225 + recordPayment = 1;
  226 + }
  227 + }
  228 + return recordPayment;
  229 + }
  230 +
  231 +
  232 + /**
  233 + * 支付货款流水记录
  234 + * @param uid
  235 + * @param sellerUid
  236 + * @param skup
  237 + * @param orderCode
  238 + * @param payment
  239 + * @param amount
  240 + */
  241 + public void addPayBuyRecord(Integer uid, Integer sellerUid, Integer skup, Long orderCode, Integer payment, BigDecimal amount) {
  242 + SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
  243 + if (meta == null) {
  244 + logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);
  245 + return;
  246 + }
  247 + Integer payType = adaptPayType(payment);
  248 + // 增加流水记录
  249 + TradeBills record = new TradeBills();
  250 + record.setUid(uid);
  251 + record.setOrderCode(orderCode);
  252 + record.setPaidOrderCode(0L);
  253 + record.setUserType(1);// 1:买家uid; 2:卖家uid
  254 + record.setPayType(payType);// 1:支付宝; 2:微信
  255 + record.setTradeType(2);//1:保证金;2:货款;3:补偿款
  256 + record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
  257 + record.setAmount(amount);
  258 + try {
  259 + JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
  260 + BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
  261 + amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
  262 + } catch (Exception e) {
  263 + logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
  264 + return;
  265 + }
  266 +
  267 + record.setSystemAmount(amount);// 有货收入
  268 + record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
  269 + record.setCreateTime((int) (System.currentTimeMillis() / 1000));
  270 + addTradeBills(record);
  271 + }
  272 +
  273 + /**
  274 + * 支付保证金流水记录
  275 + * @param uid
  276 + * @param skup
  277 + * @param orderCode
  278 + * @param payment
  279 + * @param amount
  280 + */
  281 + public void addPayEnsureRecord(Integer uid, Integer skup, Long orderCode, Integer payment, BigDecimal amount) {
  282 + SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, "fee");
  283 + if (meta == null) {
  284 + logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
  285 + return;
  286 + }
  287 + Integer payType = adaptPayType(payment);
  288 + // 增加流水记录
  289 + TradeBills record = new TradeBills();
  290 + record.setUid(uid);
  291 + record.setOrderCode(orderCode);
  292 + record.setPaidOrderCode(0L);
  293 + record.setUserType(2);// 1:买家uid; 2:卖家uid
  294 + record.setPayType(payType);// 1:支付宝; 2:微信
  295 + record.setTradeType(1);//1:保证金;2:货款;3:补偿款
  296 + record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
  297 + record.setAmount(amount);
  298 + try {
  299 + JSONObject metavalue = JSON.parseObject(meta.getMetaValue());
  300 + BigDecimal rate = metavalue.getJSONObject("serviceFeeRate").getBigDecimal("payChannelRate");
  301 + amount = amount.multiply(BigDecimal.ONE.subtract(rate)).setScale(2, BigDecimal.ROUND_HALF_UP);
  302 + } catch (Exception e) {
  303 + logger.error("PayRecordErr计费信息不完整, uid is {}, skup is {}, err is {}", uid, skup, e.getMessage());
  304 + return;
  305 + }
  306 + record.setSystemAmount(amount);// 有货收入
  307 + record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
  308 + record.setCreateTime((int) (System.currentTimeMillis() / 1000));
  309 + addTradeBills(record);
  310 + }
  311 +
  312 + /**
  313 + * 添加充值保证金流水
  314 + * @param uid
  315 + * @param orderCode
  316 + * @param payment
  317 + * @param amount
  318 + */
  319 + public void addPayRechargeEnsureRecord(Integer uid, Long orderCode, Integer payment, BigDecimal amount) {
  320 + Integer payType = adaptPayType(payment);
  321 + TradeBills record = new TradeBills();
  322 + record.setUid(uid);
  323 + record.setOrderCode(orderCode);
  324 + record.setPaidOrderCode(0L);
  325 + record.setUserType(2);// 1:买家uid; 2:卖家uid
  326 + record.setPayType(payType);// 1:支付宝; 2:微信
  327 + record.setTradeType(1);//1:保证金;2:货款;3:补偿款
  328 + record.setIncomeOutcome(2);// 1:用户收入; 2:用户支出
  329 + record.setAmount(amount);
  330 + record.setSystemAmount(amount);// 有货收入
  331 + record.setTradeStatus(BillTradeStatus.SUCCESS.getCode());
  332 + record.setCreateTime(DateUtil.getCurrentTimeSecond());
  333 + addTradeBills(record);
  334 + }
  335 +}
@@ -339,12 +339,13 @@ public class InBoxFacade extends BaseNoticeFacade{ @@ -339,12 +339,13 @@ public class InBoxFacade extends BaseNoticeFacade{
339 * @param productCode 339 * @param productCode
340 * @param wayBillCode 340 * @param wayBillCode
341 */ 341 */
342 - public void sendInboxSmsWhenAppraiseFinished(int uid, String prdName, String productCode,String wayBillCode){ 342 + public void sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum inbox, InboxBusinessTypeEnum sms,
  343 + int uid, String prdName, String productCode,String wayBillCode){
343 344
344 try { 345 try {
345 executorService.execute(() -> { 346 executorService.execute(() -> {
346 String params = buildParams(prdName, productCode); 347 String params = buildParams(prdName, productCode);
347 - InboxReqVO req = buildInboxReqVO(uid, params, InboxBusinessTypeEnum.INBOX_DELIVERY_APPRAISE_FINISHED); 348 + InboxReqVO req = buildInboxReqVO(uid, params, inbox);
348 349
349 InBoxResponse resp = inBoxSDK.addInbox(req); 350 InBoxResponse resp = inBoxSDK.addInbox(req);
350 log.info("record sendInboxSmsWhenAppraiseFinished inbox msg, uid {}, prdName {}, wayBillCode {}, resp {}", uid, prdName, wayBillCode, resp); 351 log.info("record sendInboxSmsWhenAppraiseFinished inbox msg, uid {}, prdName {}, wayBillCode {}, resp {}", uid, prdName, wayBillCode, resp);
@@ -356,7 +357,7 @@ public class InBoxFacade extends BaseNoticeFacade{ @@ -356,7 +357,7 @@ public class InBoxFacade extends BaseNoticeFacade{
356 return; 357 return;
357 } 358 }
358 List<String> mobileList = Arrays.asList(phone); 359 List<String> mobileList = Arrays.asList(phone);
359 - String content = getReplacedContent(InboxBusinessTypeEnum.SMS_DELIVERY_APPRAISE_FINISHED.getContent(), prdName ,productCode,wayBillCode); 360 + String content = getReplacedContent(sms.getContent(), prdName ,productCode,wayBillCode);
360 sendSmsService.smsSendByMobile(content, mobileList); 361 sendSmsService.smsSendByMobile(content, mobileList);
361 log.info("sendInboxSmsWhenAppraiseFinished sms content {}, mobileList {}", content, mobileList); 362 log.info("sendInboxSmsWhenAppraiseFinished sms content {}, mobileList {}", content, mobileList);
362 }); 363 });
@@ -6,10 +6,7 @@ import com.yoho.error.exception.ServiceException; @@ -6,10 +6,7 @@ import com.yoho.error.exception.ServiceException;
6 import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo; 6 import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo;
7 import com.yohobuy.ufo.model.order.bo.DepositOrderStatisticInfo; 7 import com.yohobuy.ufo.model.order.bo.DepositOrderStatisticInfo;
8 import com.yohobuy.ufo.model.order.bo.OrderInfo; 8 import com.yohobuy.ufo.model.order.bo.OrderInfo;
9 -import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;  
10 -import com.yohobuy.ufo.model.order.common.OrderAttributes;  
11 -import com.yohobuy.ufo.model.order.common.OrderCodeType;  
12 -import com.yohobuy.ufo.model.order.common.Payment; 9 +import com.yohobuy.ufo.model.order.common.*;
13 import com.yohobuy.ufo.model.order.req.*; 10 import com.yohobuy.ufo.model.order.req.*;
14 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp; 11 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp;
15 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp; 12 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp;
@@ -38,6 +35,7 @@ import com.yohoufo.order.mq.DelayTime; @@ -38,6 +35,7 @@ import com.yohoufo.order.mq.DelayTime;
38 import com.yohoufo.order.mq.TopicConstants; 35 import com.yohoufo.order.mq.TopicConstants;
39 import com.yohoufo.order.mq.producer.TradeMqSender; 36 import com.yohoufo.order.mq.producer.TradeMqSender;
40 import com.yohoufo.order.service.DepositService; 37 import com.yohoufo.order.service.DepositService;
  38 +import com.yohoufo.order.service.IExpressInfoService;
41 import com.yohoufo.order.service.IGoodsService; 39 import com.yohoufo.order.service.IGoodsService;
42 import com.yohoufo.order.service.IPaymentService; 40 import com.yohoufo.order.service.IPaymentService;
43 import com.yohoufo.order.service.handler.GoodsServiceRefundHandler; 41 import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
@@ -66,7 +64,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -66,7 +64,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
66 private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper; 64 private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
67 65
68 @Autowired 66 @Autowired
69 - private AppraiseOrderStorageMapper appraiseOrderStorageMapper; 67 + private IExpressInfoService expressInfoService;
70 68
71 @Autowired 69 @Autowired
72 private SellerDepositOrderPrepareService sellerDepositOrderPrepareService; 70 private SellerDepositOrderPrepareService sellerDepositOrderPrepareService;
@@ -697,7 +695,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -697,7 +695,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
697 case PLATFORM_APPRAISE_UNSURE: 695 case PLATFORM_APPRAISE_UNSURE:
698 unsureNum = cnt; 696 unsureNum = cnt;
699 break; 697 break;
700 - case JUDGE_PASS: 698 + case JUDGE_PASS_WAIT_WAREHOUSE:
701 passNum = cnt; 699 passNum = cnt;
702 break; 700 break;
703 case CHECKING_FAKE: 701 case CHECKING_FAKE:
@@ -758,6 +756,13 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -758,6 +756,13 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
758 logger.info("detectAppraiseFinish event {},parentOrderCode {} PLATFORM_RECEIVE count {}", event, parentOrderCode, cnt); 756 logger.info("detectAppraiseFinish event {},parentOrderCode {} PLATFORM_RECEIVE count {}", event, parentOrderCode, cnt);
759 if (cnt == 0){ 757 if (cnt == 0){
760 int prows = platformFinishAppraiseGoods(parentOrderCode); 758 int prows = platformFinishAppraiseGoods(parentOrderCode);
  759 +
  760 + // 鉴定已经完成的物流信息
  761 + EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
  762 + EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
  763 + EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.appraise_finished;
  764 + expressInfoService.saveOperateTransferExpressInfo(appraiseOrder.getUid(), orderCode ,expressType.getCode(),expressDataType,operateTransferCode);
  765 +
761 logger.info("detectAppraiseFinish platformFinishReceiveGoods, orderCode {},parentOrderCode {} parent count {}", 766 logger.info("detectAppraiseFinish platformFinishReceiveGoods, orderCode {},parentOrderCode {} parent count {}",
762 orderCode, parentOrderCode, prows); 767 orderCode, parentOrderCode, prows);
763 if (prows>0){ 768 if (prows>0){
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.seller.deposit; @@ -3,6 +3,7 @@ package com.yohoufo.order.service.seller.deposit;
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo; 4 import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo;
5 import com.yohoufo.order.BaseWebTest; 5 import com.yohoufo.order.BaseWebTest;
  6 +import com.yohoufo.order.event.OrderCancelEvent;
6 import org.junit.Test; 7 import org.junit.Test;
7 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
8 9
@@ -20,4 +21,12 @@ public class SellerDepositOrderServiceTest extends BaseWebTest { @@ -20,4 +21,12 @@ public class SellerDepositOrderServiceTest extends BaseWebTest {
20 List<AppraiseOrderBo> list = sellerDepositOrderService.getSubOrderStatistic(orderCode); 21 List<AppraiseOrderBo> list = sellerDepositOrderService.getSubOrderStatistic(orderCode);
21 System.out.println("in testGetSubOrderStatistic result" + JSONObject.toJSONString(list)); 22 System.out.println("in testGetSubOrderStatistic result" + JSONObject.toJSONString(list));
22 } 23 }
  24 +
  25 + @Test
  26 + public void testcancelByTimeout(){
  27 + String json = "{\"orderCode\":36379748458307,\"payExpire\":10,\"retry\":0,\"uid\":500031424}";
  28 + OrderCancelEvent orderCancelEvent = JSONObject.parseObject(json, OrderCancelEvent.class);
  29 + sellerDepositOrderService.cancelByTimeout(orderCancelEvent);
  30 +
  31 + }
23 } 32 }