Authored by chenchao

Merge remote-tracking branch 'origin/test6.9.10' into test6.9.10

... ... @@ -45,6 +45,12 @@ public interface AppraiseOrderMapper {
@Param("expectedStatus")int expectedStatus,
@Param("updateTime")int updateTime);
// 修改订单的平台发货状态
int updatePlatformDeliveryStatusByOrderCode(@Param("orderCode")long orderCode,
@Param("uid")int uid,
@Param("targetPlatformDeliveryStatus")int targetPlatformDeliveryStatus,
@Param("currentTime")int currentTime);
/**
* 根据订单列表查询信息列表
* @param orderList
... ...
... ... @@ -234,6 +234,13 @@
</update>
<update id="updatePlatformDeliveryStatusByOrderCode">
update appraise_order set
platform_delivery_status = #{targetPlatformDeliveryStatus,jdbcType=INTEGER}, update_time = #{currentTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
</update>
<update id="updateStatusByOrderCode">
update appraise_order
<set>
... ...
... ... @@ -102,6 +102,26 @@ public class AppraiseController {
return new ApiResponse();
}
/**
* 给付费寄存 and 付费鉴定 发货用<br><br/>
* 鉴定结果为以下场景,寄回
* 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
* 2.无法鉴定
* 3.鉴定通过
*
* 提供给运营平台使用
* @return
*/
@RequestMapping(value="/deliveryForAppraise")
@IgnoreSession
@IgnoreSignature
public ApiResponse deliveryForAppraise(@RequestBody AppraiseExpressInfoBo appraiseExpressInfoBo) {
logger.info("in deliveryForAppraise , req {}", appraiseExpressInfoBo);
appraiseService.deliveryForAppraise(appraiseExpressInfoBo);
return new ApiResponse();
}
/**
* 鉴定通过,鉴定中心发货给买家
* @return
... ...
package com.yohoufo.order.service.deposit;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
... ... @@ -19,6 +20,7 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.*;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.controller.DepositOrderController;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.response.AppraiseAddressResp;
... ... @@ -30,7 +32,9 @@ import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.impl.DepositHelpService;
import com.yohoufo.order.service.impl.MetaConfigService;
import com.yohoufo.order.service.seller.SellerOrderCancelService;
import com.yohoufo.order.service.seller.deposit.AppraiseOrderMetaService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -97,6 +101,9 @@ public class DepositOrderService {
@Autowired
private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
@Autowired
private AppraiseOrderMetaService appraiseOrderMetaService;
/**
* 根据库存货号,计算需要召回的费用
* @param req
... ... @@ -115,7 +122,8 @@ public class DepositOrderService {
GoodsInfo goodsInfo = getGoodsInfo(storageDeposit); // 查询购买商品的详细信息
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode); // 获取用户的地址
AddressInfo addressInfo = getAddressInfo(req, orderCode);
addressInfo.setAddress_id_str(AddressUtil.getEncryptStr(String.valueOf(addressInfo.getAddress_id())));// 加密addressId
... ... @@ -128,6 +136,17 @@ public class DepositOrderService {
.userAddress(addressInfo).priceInfo(priceInfo).goodsInfo(goodsInfo).build();
}
private AddressInfo getAddressInfo(DepositOrderComputeReq req, Long orderCode) {
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
AddressInfo addressInfo = null;
if (OrderCodeType.BUYER_TYPE.getType() == codeMeta.getType()) {
addressInfo = buyerOrderMetaService.getHiddenAddressInfo(req.getUid(), orderCode); // 获取用户的地址
} else {
addressInfo = appraiseOrderMetaService.getHidderUserAddress(orderCode);
}
return addressInfo;
}
/**
* 如果关联了新的skup,代表寄存的主人已上架过库存, 需要 下架SKUP
... ...
... ... @@ -188,7 +188,10 @@ public class AppraiseService {
private DepositService depositService;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
AppraiseOrderMapper appraiseOrderMapper;
@Autowired
AppraiseOrderStorageMapper appraiseOrderStorageMapper;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
... ... @@ -501,6 +504,105 @@ public class AppraiseService {
return apiResponse;
}
// 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
List<Integer> APPRAISE_FAIL_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.FLAW.getCode(),AppraiseOrderStatus.CHECKING_FAKE.getCode(),
AppraiseOrderStatus.SHAM_SEND_OUT.getCode(), AppraiseOrderStatus.QUALITY_CHECK_FAKE.getCode());
// 2.无法鉴定
List<Integer> CANNOT_APPRAISE_STATUS_CODE = Lists.newArrayList(
AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode());
// 3.鉴定通过
List<Integer> APPRAISE_SUCCESS_STATUS_CODE = Lists.newArrayList(AppraiseOrderStatus.JUDGE_PASS.getCode());
/**
* 给付费寄存 and 付费鉴定 发货用<br><br/>
* 鉴定结果为以下场景,寄回
* 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
* 2.无法鉴定
* 3.鉴定通过
*
* 提供给运营平台使用
*/
public ApiResponse deliveryForAppraise(AppraiseExpressInfoBo appraiseExpressInfoBo) {
long orderCode = appraiseExpressInfoBo.getOrderCode();
if (!serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
LOGGER.warn("deliveryForAppraise orderCode is not goodsService, orderCode {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
Integer depotNum = appraiseExpressInfoBo.getDepotNum();
String mobile = appraiseExpressInfoBo.getMobile();
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
// 订单是否为空无需检查,上面调用方法的时候已经检查了
AppraiseOrder appraiseOrder =existenceNode.getAppraiseOrder();
if(!APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())
&& !CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())
&& !APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getOrderCode())){
LOGGER.warn("deliveryForAppraise status {}, orderCode {}", appraiseOrder.getStatus(), orderCode);
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
//记录物流信息
int uid = appraiseOrder.getUid();
executorService.execute(() -> {
// 1.瑕疵,鉴定为假,虚假发货,质检不通过取消
if (APPRAISE_FAIL_STATUS_CODE.contains(appraiseOrder.getStatus())){
expressInfoService.returnBackOrderCauseOfJudgeFailure(uid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile);
}
// 2.无法鉴定
else if(CANNOT_APPRAISE_STATUS_CODE.contains(appraiseOrder.getStatus())){
expressInfoService.returnBackCauseOfBuyerCancelAfterSellerSendOut(uid, expressCompanyId, orderCode, wayBillCode, depotNum, mobile, true);
}
// 3.鉴定通过
else if(APPRAISE_SUCCESS_STATUS_CODE.contains(appraiseOrder.getStatus())){
expressInfoService.deliverGoods(appraiseOrder.getUid(),
appraiseExpressInfoBo.getExpressCompanyId(),
appraiseOrder.getOrderCode(),
appraiseExpressInfoBo.getWayBillCode(),
appraiseExpressInfoBo.getDepotNum(),
appraiseExpressInfoBo.getMobile());
}
//更新平台物流状态为已发货
appraiseOrderMapper.updatePlatformDeliveryStatusByOrderCode(orderCode, appraiseOrder.getUid(),
EnumPlatformDeliveryStatus.delivery_to_seller.getCode(), DateUtil.getCurrentTimeSecond());
});
//发送消息
// 付费鉴定的场合,发货需要消息
if (appraiseOrder.getAttributes() == AppraiseOrderAttributes.PAID_APPRAISE.getCode()){
List<AppraiseOrderGoods> appraiseOrderGoods = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
if (CollectionUtils.isEmpty(appraiseOrderGoods)){
LOGGER.warn("appraise order goods not exist {}", orderCode);
return new ApiResponse();
}
AppraiseOrderStorage appraiseOrderStorage = appraiseOrderStorageMapper.selectByOrderCode(orderCode);
if (appraiseOrderStorage == null){
LOGGER.warn("appraise order storage not exist {}", orderCode);
return new ApiResponse();
}
// 子订单对应商品 1:1
AppraiseOrderGoods oneAppraiseOrderGood = appraiseOrderGoods.get(0);
inBoxFacade.sendInboxSmsWhenAppraiseFinished(uid, oneAppraiseOrderGood.getProductName(),appraiseOrderStorage.getSizeName(), oneAppraiseOrderGood.getProductCode(), wayBillCode);
}
return new ApiResponse();
}
/**
* 无法鉴定退回
*
... ...
package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.order.bo.DepositProductBo;
... ... @@ -187,6 +188,40 @@ public class DepositHelpService {
}
public Map<Long, List<String>> queryAppraiseOrderStatusEx(Long appraiseOrder) {
if (null == appraiseOrder) {
return Maps.newHashMap();
}
AppraiseOrder appraiseOrders = appraiseOrderMapper.selectByOrderCode(appraiseOrder);
if(null == appraiseOrders) {
return Maps.newHashMap();
}
String statusStrByCode = AppraiseOrderStatus.getStatusStrByCode(appraiseOrders.getStatus());
Map<Long,List<String>> result = Maps.newHashMap();
result.put(appraiseOrder, Lists.newArrayList(statusStrByCode, getAppaiseOrderStatusDesc(appraiseOrders.getStatus())));
return result;
}
public String getAppaiseOrderStatusDesc(Integer status) {
switch (status) {
case 23:
return "您的商品无法鉴定,保证金已退还,平台将在1-3个工作日内寄回,请留意物流动态";
case 13:
return "您的商品鉴定未通过,保证金已扣除,平台将在1-3个工作日内到付寄回,请留意物流动态";
case 20:
return "商品质检未通过,保证金已赔付给买家,平台将在1-3个工作日内到付寄回,请留意物流动态";
default:
return "";
}
}
public AppraiseOrder queryAppraiseOrderInfo(Long orderCode) {
if (null == orderCode) {
return null;
... ...
... ... @@ -527,14 +527,16 @@ public class DepositServiceImpl implements DepositService {
.depositCode(storageDeposit.getDepositCode())
.skup(storageDeposit.getSkup())
.status(storageDeposit.getStatus())
.ownerUid(storageDeposit.getOwnerUid())
.depositStatusName(StorageDepositStatusEnum.getAppStatusNameByCode(storageDeposit.getStatus()))
.depositDescName(StorageDepositStatusEnum.getAppStatusDescByCode(storageDeposit.getStatus()));
.ownerUid(storageDeposit.getOwnerUid());
if (DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode().equals(storageDeposit.getOutType())) { // 如果是寄存订单,寄回的商品,则需要查询状态
Map<Long, String> orderStatusStr = depositHelpService.queryAppraiseOrderStatus(Lists.newArrayList(storageDeposit.getOrderCode()));
Map<Long, List<String>> orderStatusStr = depositHelpService.queryAppraiseOrderStatusEx(storageDeposit.getOrderCode());
depositDetailBoBuilder.depositStatusName(orderStatusStr.get(storageDeposit.getOrderCode()));
depositDetailBoBuilder.depositStatusName(CollectionUtils.isNotEmpty(orderStatusStr.get(storageDeposit.getOrderCode())) ? orderStatusStr.get(storageDeposit.getOrderCode()).get(0) : "")
.depositDescName(CollectionUtils.isNotEmpty(orderStatusStr.get(storageDeposit.getOrderCode())) ? orderStatusStr.get(storageDeposit.getOrderCode()).get(1) : "");
} else { // 正常的买家订单召回
depositDetailBoBuilder.depositStatusName(StorageDepositStatusEnum.getAppStatusNameByCode(storageDeposit.getStatus()))
.depositDescName(StorageDepositStatusEnum.getAppStatusDescByCode(storageDeposit.getStatus()));
}
return depositDetailBoBuilder.build();
... ...
... ... @@ -319,6 +319,43 @@ public class InBoxFacade extends BaseNoticeFacade{
}
}
/**
* 鉴定结束发货,发送站内信和短信
* @param uid
* @param prdName
* @param sizeName
* @param productCode
* @param wayBillCode
*/
public void sendInboxSmsWhenAppraiseFinished(int uid, String prdName, String sizeName, String productCode,String wayBillCode){
try {
executorService.execute(() -> {
String params = buildParams(prdName, sizeName, productCode);
InboxReqVO req = buildInboxReqVO(uid, params, InboxBusinessTypeEnum.INBOX_DELIVERY_APPRAISE_FINISHED);
InBoxResponse resp = inBoxSDK.addInbox(req);
log.info("record sendInboxSmsWhenAppraiseFinished inbox msg, uid {}, prdName {}, resp {}",uid, prdName, resp);
//短信
String phone = userProxyService.getMobile(uid);
if (StringUtils.isBlank(phone)){
log.warn("sendInboxSmsComm sms send fail,sellerUid {}, prdName {} timelimitDesc {}",uid, prdName);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(InboxBusinessTypeEnum.SMS_DELIVERY_APPRAISE_FINISHED.getContent(),prdName,sizeName,productCode,wayBillCode);
sendSmsService.smsSendByMobile(content, mobileList);
});
} catch (Exception e) {
log.warn("InBoxFacade sendInboxSmsWhenAppraiseFinished error inbox msg, sellerUid {}, prdName {} ",
uid, prdName, e);
}
}
/**
* 交易关闭:买家支付完成,卖家取消
*
... ...