Authored by tanling

后台发货

... ... @@ -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
... ...
... ... @@ -17,6 +17,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yohobuy.ufo.model.order.common.*;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.service.*;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
... ... @@ -46,14 +47,6 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.constant.EnumPlatformDeliveryStatus;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.ExpressRecordMapper;
import com.yohoufo.dal.order.QualityCheckMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.StorageDepositMapper;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.RefundCase;
... ... @@ -195,7 +188,13 @@ public class AppraiseService {
private DepositService depositService;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
AppraiseOrderMapper appraiseOrderMapper;
@Autowired
AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
@Autowired
AppraiseOrderStorageMapper appraiseOrderStorageMapper;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
... ... @@ -505,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();
}
/**
* 无法鉴定退回
*
... ...
... ... @@ -317,6 +317,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);
}
}
/**
* 交易关闭:买家支付完成,卖家取消
*
... ...