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 {
AppraiseOrderMeta selectByPrimaryKey(Integer id);
/**
* 只适用子订单,使用子订单查询
* @param condition
* @return
*/
AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition);
/**
* 适用于卖家鉴定订单 根据父订单查询
* @param condition
* @return
*/
List<AppraiseOrderMeta> selectAllByParentOrderCode(AppraiseOrderMeta condition);
List<AppraiseOrderMeta> selectByOrderCodeMetaKeys(@Param("orderCode") long orderCode,
@Param("metaKeys") Collection<String> metaKeys);
... ...
... ... @@ -147,6 +147,7 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
AppraiseOrderStatus.HAS_PAYED.getCode(),
AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode(),
AppraiseOrderStatus.JUDGE_PASS_WAIT_WAREHOUSE.getCode(),
AppraiseOrderStatus.CANCEL_BEFORE_DELIVER.getCode(),
AppraiseOrderStatus.SHAM_SEND_OUT.getCode(),
AppraiseOrderStatus.SEND_OUT_TIMEOUT.getCode()
);
... ...
... ... @@ -22,7 +22,7 @@ public class AppraiseExpressStageBuilder {
/**
* 平台确认收货
*
* 1卖家发货 == 2平台鉴定 点亮1
* 1卖家发货 == 2平台鉴定 点亮2
*/
private static final int DEPOSIT_PLATFORM_RECEIPT = 11;
... ...
... ... @@ -16,6 +16,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.*;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
... ... @@ -504,9 +505,9 @@ public class AppraiseService {
return apiResponse;
}
// 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
// 1.鉴定为假,质检不通过
List<Integer> APPRAISE_FAIL_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.CHECKING_FAKE.getCode(),
AppraiseOrderStatus.SHAM_SEND_OUT.getCode(), AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode());
AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode());
// 2.无法鉴定
List<Integer> CANNOT_APPRAISE_STATUS_CODE = Lists.newArrayList(
... ... @@ -588,10 +589,22 @@ public class AppraiseService {
// 子订单对应商品 1:1
AppraiseOrderGoods oneAppraiseOrderGood = appraiseOrderGoods.get(0);
inBoxFacade.sendInboxSmsWhenAppraiseFinished(uid, oneAppraiseOrderGood.getProductName(),
if (APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())
|| APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getStatus())){
inBoxFacade.sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum.INBOX_DELIVERY_APPRAISE_FINISHED,
InboxBusinessTypeEnum.SMS_DELIVERY_APPRAISE_FINISHED,
uid, oneAppraiseOrderGood.getProductName(),
oneAppraiseOrderGood.getProductCode(),
wayBillCode);
}else if(CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())){
inBoxFacade.sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum.INBOX_DELIVERY_CANNOT_APPRAISE,
InboxBusinessTypeEnum.SMS_DELIVERY_CANNOT_APPRAISE,
uid, oneAppraiseOrderGood.getProductName(),
oneAppraiseOrderGood.getProductCode(),
wayBillCode);
}
}
if (appraiseOrder.getAttributes() == OrderAttributes.DEPOSITE.getCode()) { // 鉴定寄存的订单,需要同步修改寄存表的状态
setDepositStatus(orderCode);
... ... @@ -1741,13 +1754,14 @@ public class AppraiseService {
List<Integer> skupList = buyerOrderGoodses.stream().map(BuyerOrderGoods::getSkup).collect(Collectors.toList());
sellerOrderGoodsMapper.updateDeptNoBySkups(skupList, appraiseExpressInfoBo.getDepotNum());
expressRecordMapper.updateDeptNoByOrder(orderCodeList, EnumExpressType.EXPRESS_TYPE_1.getCode(), appraiseExpressInfoBo.getDepotNum());
productProxyService.setBatchDepotNum(skupList, appraiseExpressInfoBo.getDepotNum());
}
// 更新鉴定订单的鉴定室
appraiseOrderGoodsMapper.updateBatchDepotNo(orderCodeList, appraiseExpressInfoBo.getDepotNum());
expressRecordMapper.updateDeptNoByOrder(orderCodeList, EnumExpressType.EXPRESS_TYPE_1.getCode(), appraiseExpressInfoBo.getDepotNum());
}
}
... ...
... ... @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.DepositSourceEnum;
import com.yohobuy.ufo.model.order.resp.DepositOrderComputeResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
import com.yohobuy.ufo.model.response.StorageDataResp;
... ... @@ -15,11 +16,9 @@ import com.yohoufo.common.utils.AppVersion;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.StringUtil;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.DepositCodeMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.DepositCode;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.StorageDepositCount;
import com.yohoufo.dal.order.model.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -27,10 +26,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
... ... @@ -49,6 +47,9 @@ public class DepositHelpService {
@Autowired
private AppraiseOrderMapper appraiseOrderMapper;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
// 是否 24小时反馈时间 如果是则返回true
public boolean isFeedback(int depositRemainDay) {
return -1 * DepositOrderComputeResp.FEEDBACK_DAY <= depositRemainDay && depositRemainDay <= 0;
... ... @@ -249,4 +250,27 @@ public class DepositHelpService {
public String queryEarnestMoneyStatus(Integer status) {
return Integer.valueOf(AppraiseOrderStatus.CHECKING_FAKE.getCode()).equals(status) ? "已扣除" : "原路退还";
}
/**
* 获取入手价
* @param countInfoList
* @return
*/
public Map<Long, BuyerOrder> getOrderAmountMap(List<StorageDeposit> depositList) {
if (CollectionUtils.isEmpty(depositList)) {
return Maps.newHashMap();
}
Collection<Long> orderCodeList = depositList.stream()
.filter(item -> DepositSourceEnum.SOURCE_BUYER.getCode().equals(item.getSource())).map(StorageDeposit::getOrderCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(orderCodeList)) {
return Maps.newHashMap();
}
List<BuyerOrder> buyerGoodsList = buyerOrderMapper.selectByOrderCodes(orderCodeList, null);
Map<Long, BuyerOrder> buyerGoodsMap = buyerGoodsList.stream().map(Function.identity()).collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
return buyerGoodsMap;
}
}
... ...
... ... @@ -131,14 +131,13 @@ public class DepositServiceImpl implements DepositService {
}
// 召回或者到期退回的
List<StorageDeposit> depositList = storageDepositMapper.queryUserDopositBack(uid, (page - 1) * limit, limit);
List<BuyerOrder> buyerGoodsList = buyerOrderMapper.selectByOrderCodes(depositList.stream()
.filter(item -> DepositSourceEnum.SOURCE_BUYER.getCode().equals(item.getSource())).map(StorageDeposit::getOrderCode).collect(Collectors.toList()), null);
// 查询现货寄存订单的状态
Map<Long, String> appraiseOrderStatusMap = depositHelpService.queryAppraiseOrderStatus(depositList.stream()
.filter(item -> DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode().equals(item.getOutType())).map(StorageDeposit::getOrderCode).collect(Collectors.toList()));
Map<Long, BuyerOrder> buyerGoodsMap = buyerGoodsList.stream().map(Function.identity()).collect(Collectors.toMap(BuyerOrder::getOrderCode, Function.identity()));
Map<Long, BuyerOrder> buyerGoodsMap = depositHelpService.getOrderAmountMap(depositList);
List<Integer> storageList = depositList.stream().map(StorageDeposit::getStorageId).collect(Collectors.toList());
... ...
... ... @@ -258,6 +258,7 @@ public class QiniuLiveRecordService {
resp.setProductId(item.getProductId());
resp.setProductPicUrl(null == orderVideoResp ? "" : orderVideoResp.getProductPicUrl());
resp.setAppraise_result(item.getAppraiseResult());
resp.setOrderCode(item.getOrderCode());
result.add(resp);
});
... ...
... ... @@ -2,17 +2,14 @@ package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.TradeBillsMapper;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.dal.order.model.TradeBills;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.common.BillTradeStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
... ... @@ -43,8 +40,6 @@ public class TradeBillsService {
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
/**
* 退保证金流水记录
... ... @@ -65,28 +60,32 @@ public class TradeBillsService {
String computeResultVal = null;
BigDecimal earnestMoney = null;
BigDecimal systemAmount = null;
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
AppraiseOrderMeta feeCondition = new AppraiseOrderMeta();
feeCondition.setOrderCode(orderCode);
feeCondition.setMetaKey(MetaKey.SELLER_FEE);
AppraiseOrderMeta feeMeta = appraiseOrderMetaMapper.selectByOrderCode(feeCondition);
computeResultVal = Objects.nonNull(feeMeta) ? feeMeta.getMetaValue() : null;
logger.info("in backPayEnsureRecord isGoodsServiceOrder orderCode {} computeResultVal {}", orderCode, computeResultVal);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
if(!existenceNode.isExisted()){
return;
}
earnestMoney = existenceNode.getAppraiseOrder().getAmount();
systemAmount = earnestMoney.negate();
logger.info("in backPayEnsureRecord isGoodsServiceOrder orderCode {} earnestMoney {}", orderCode, computeResultVal);
}else {
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);
computeResultVal = Objects.nonNull(meta) ? meta.getMetaValue() : null;
logger.info("in backPayEnsureRecord buyerorder orderCode {} computeResultVal {}", orderCode, computeResultVal);
SellerOrderComputeResult socr = JSONObject.parseObject(computeResultVal, SellerOrderComputeResult.class);
earnestMoney = socr.getEarnestMoney().getEarnestMoney();
systemAmount = calSystemAmountByComputeResult(socr);
}
if (Objects.isNull(computeResultVal)) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
if (Objects.isNull(systemAmount) || Objects.isNull(systemAmount)) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, orderCode {}", uid, orderCode);
return;
}
try{
SellerOrderComputeResult socr = JSONObject.parseObject(computeResultVal, SellerOrderComputeResult.class);
BigDecimal earnestMoney = socr.getEarnestMoney().getEarnestMoney();
BigDecimal systemAmount = calSystemAmountByComputeResult(socr);
backPayEnsureRecord0(uid, orderCode, paidOrderCode, payType, tradeStatus, earnestMoney, systemAmount);
backPayEnsureRecord0(uid, orderCode,paidOrderCode, payType, tradeStatus, earnestMoney, systemAmount);
}catch (Exception ex){
logger.error("backPayEnsureRecord error, uid {},orderCode {} computeResultVal {}",
... ... @@ -318,7 +317,6 @@ public class TradeBillsService {
* @param amount
*/
public void addPayRechargeEnsureRecord(Integer uid, Long orderCode, Integer payment, BigDecimal amount) {
Integer payType = adaptPayType(payment);
TradeBills record = new TradeBills();
record.setUid(uid);
... ...
... ... @@ -339,12 +339,13 @@ public class InBoxFacade extends BaseNoticeFacade{
* @param productCode
* @param wayBillCode
*/
public void sendInboxSmsWhenAppraiseFinished(int uid, String prdName, String productCode,String wayBillCode){
public void sendInboxSmsWhenAppraiseFinished(InboxBusinessTypeEnum inbox, InboxBusinessTypeEnum sms,
int uid, String prdName, String productCode,String wayBillCode){
try {
executorService.execute(() -> {
String params = buildParams(prdName, productCode);
InboxReqVO req = buildInboxReqVO(uid, params, InboxBusinessTypeEnum.INBOX_DELIVERY_APPRAISE_FINISHED);
InboxReqVO req = buildInboxReqVO(uid, params, inbox);
InBoxResponse resp = inBoxSDK.addInbox(req);
log.info("record sendInboxSmsWhenAppraiseFinished inbox msg, uid {}, prdName {}, wayBillCode {}, resp {}", uid, prdName, wayBillCode, resp);
... ... @@ -356,7 +357,7 @@ public class InBoxFacade extends BaseNoticeFacade{
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_DELIVERY_APPRAISE_FINISHED.getContent(), prdName ,productCode,wayBillCode);
String content = getReplacedContent(sms.getContent(), prdName ,productCode,wayBillCode);
sendSmsService.smsSendByMobile(content, mobileList);
log.info("sendInboxSmsWhenAppraiseFinished sms content {}, mobileList {}", content, mobileList);
});
... ...
... ... @@ -6,10 +6,7 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo;
import com.yohobuy.ufo.model.order.bo.DepositOrderStatisticInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp;
... ... @@ -38,6 +35,7 @@ import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
... ... @@ -66,7 +64,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
@Autowired
private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
private IExpressInfoService expressInfoService;
@Autowired
private SellerDepositOrderPrepareService sellerDepositOrderPrepareService;
... ... @@ -697,7 +695,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
case PLATFORM_APPRAISE_UNSURE:
unsureNum = cnt;
break;
case JUDGE_PASS:
case JUDGE_PASS_WAIT_WAREHOUSE:
passNum = cnt;
break;
case CHECKING_FAKE:
... ... @@ -758,6 +756,13 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
logger.info("detectAppraiseFinish event {},parentOrderCode {} PLATFORM_RECEIVE count {}", event, parentOrderCode, cnt);
if (cnt == 0){
int prows = platformFinishAppraiseGoods(parentOrderCode);
// 鉴定已经完成的物流信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.appraise_finished;
expressInfoService.saveOperateTransferExpressInfo(appraiseOrder.getUid(), orderCode ,expressType.getCode(),expressDataType,operateTransferCode);
logger.info("detectAppraiseFinish platformFinishReceiveGoods, orderCode {},parentOrderCode {} parent count {}",
orderCode, parentOrderCode, prows);
if (prows>0){
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.seller.deposit;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.event.OrderCancelEvent;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -20,4 +21,12 @@ public class SellerDepositOrderServiceTest extends BaseWebTest {
List<AppraiseOrderBo> list = sellerDepositOrderService.getSubOrderStatistic(orderCode);
System.out.println("in testGetSubOrderStatistic result" + JSONObject.toJSONString(list));
}
@Test
public void testcancelByTimeout(){
String json = "{\"orderCode\":36379748458307,\"payExpire\":10,\"retry\":0,\"uid\":500031424}";
OrderCancelEvent orderCancelEvent = JSONObject.parseObject(json, OrderCancelEvent.class);
sellerDepositOrderService.cancelByTimeout(orderCancelEvent);
}
}
... ...