Authored by wujiexiang

需求:检测不通过

... ... @@ -2,8 +2,11 @@ package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.BuyerOrderStatusFlow;
import org.apache.ibatis.annotations.Param;
public interface BuyerOrderStatusFlowMapper {
int insert(BuyerOrderStatusFlow record);
BuyerOrderStatusFlow selectByStatus(@Param("orderCode") long orderCode, @Param("status") int status);
}
\ No newline at end of file
... ...
... ... @@ -17,4 +17,13 @@ public class BuyerOrderStatusFlow {
private Integer createTime;
private String remark;
public static String formatRemarkWithPrefixAndSuffix(BuyerOrderStatusFlow bosf) {
if (bosf == null || bosf.getRemark() == null) {
return "";
} else {
return new StringBuilder().append("因").append(bosf.getRemark()).append("原因").toString();
}
}
}
\ No newline at end of file
... ...
... ... @@ -54,6 +54,7 @@ public class SellerWalletDetail {
BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42),
APPRAISE_OK("鉴定通过", 51),
APPRAISE_UNSURE("商品无法鉴定", 52),
DETECTION_NOT_PASS("商品检测不通过", 53),
MERCHANT_EXIT("商家退出入驻", 61),
CANCEL_DELIVER("不寄了", 71),
FLAW("瑕疵品",72);
... ...
... ... @@ -6,16 +6,24 @@
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, status, create_time
id, order_code, status, create_time, remark
</sql>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.BuyerOrderStatusFlow">
insert into buyer_order_status_flow ( order_code, status,
create_time)
values ( #{orderCode,jdbcType=BIGINT}, #{status,jdbcType=TINYINT},
#{createTime,jdbcType=INTEGER})
insert into buyer_order_status_flow ( order_code, status,create_time, remark)
values ( #{orderCode,jdbcType=BIGINT}, #{status,jdbcType=TINYINT},#{createTime,jdbcType=INTEGER},#{remark,jdbcType=VARCHAR})
</insert>
<select id="selectByStatus">
select
<include refid="Base_Column_List" />
from buyer_order_status_flow
where order_code = #{orderCode,jdbcType=BIGINT}
and status = #{status,jdbcType=TINYINT}
limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -19,6 +19,10 @@ public enum AlarmConfig {
"buyerOrder.transferEarnestMoney",
"buyerOrder.refundGoodsMoney"),
DETECTION_NOT_PASS("商品检测不通过",
"buyerOrder.transferEarnestMoney",
"buyerOrder.refundGoodsMoney"),
SELLER_PLAY_BUYER("卖家取消",
"buyerOrder.transferEarnestMoney",
"buyerOrder.refundGoodsMoney"),
... ...
... ... @@ -152,6 +152,24 @@ public class AppraiseController {
}
/**
* 已取消:商品检测不通过
*
* @return
*/
@RequestMapping(value = "/detectNotPass")
@IgnoreSession
@IgnoreSignature
public ApiResponse detectNotPass(@RequestBody BuyerOrderCancelReq req) {
logger.info("in detectNotPass, req {}", req);
if (req.getUid() <= 0 || req.getOrderCode() <= 0) {
return new ApiResponse.ApiResponseBuilder().code(400).message("参数校验不通过").build();
}
appraiseService.detectNotPass(req.getUid(), req.getOrderCode(), req.getCancelReason());
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
/**
*
... ...
... ... @@ -18,6 +18,7 @@ public class BuyerRefundCouponEvent extends Event {
PAY_TIME_OUT,
APPRAISE_FAIL,
APPRAISE_UNSURE,
DETECTION_NOT_PASS,
SELLER_DELIVER_TIMEOUT,
SELLER_PLAY_BUYER,
/**
... ...
... ... @@ -16,6 +16,7 @@ import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderStatusFlowMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
... ... @@ -54,6 +55,9 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
@Autowired
protected IBuyerOrderMetaService buyerOrderMetaService;
@Autowired
protected BuyerOrderStatusFlowMapper buyerOrderStatusFlowMapper;
abstract BuyerOrder getBuyerOrder(int uid, long orderCode);
... ...
... ... @@ -1691,6 +1691,46 @@ public class AppraiseService {
}
/**
* 鉴定中心 检测不通过
*
* @param uid
* @param orderCode
*/
public void detectNotPass(Integer uid, Long orderCode, String remark) {
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)) {
LOGGER.warn("[{}] not support detect not pass operation for goods service order", orderCode);
//暂不支持
return;
}
new BuyerOrderCancelHandler(uid, orderCode)
.withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
.withSellerOrderSupplier(sellerOrderGoodsMapper, sellerOrderMetaMapper)
// 平台已收货 -> 已取消:商品检测不通过
.withStateTransition(OrderStatus.PLATFORM_RECEIVE, OrderStatus.PLATFORM_DETECTION_NOT_PASS, orderStatusFlowService)
// 退保证金给卖家
.withRefundEarnestMoney(payRefundService::refund, sellerOrderMapper::selectBySkup)
.refundCase(RefundCase.SELLER_EARNEST_MONEY)
.sellerWalletDetailType(SellerWalletDetail.Type.DETECTION_NOT_PASS)
.and()
// 退买家货款
.withRefundGoodsMoney(payRefundService::refund)
.refundCase(RefundCase.BUYER_GOODS_MONEY)
.and()
// 通知卖家商品检测不通过
.withNoticeSeller((soa, code) -> sellerNoticeFacade.detectNotPass(soa, code)).and()
// 通知买家商品检测不通过
.withNoticeBuyer(this::noticeBuyerDetectNotPass).and()
// 记录一条补充物流
.withRecordSuppleExpress(this::addSuppleExpressForDetectionNotPass).and()
// 退优惠券
.withRefundCoupon(BuyerRefundCouponEvent.BizCase.DETECTION_NOT_PASS)
.withCacheCleaner(cacheCleaner::delete)
.withFailAlarm(AlarmConfig.DETECTION_NOT_PASS)
.withOrderChangeListenerContainer(orderChangeListenerContainer)
.cancel(remark);
}
/**
* 无法鉴定时,记录一条补充物流
*/
private void addSuppleExpressForUnsure(Integer uid, long orderCode) {
... ... @@ -1707,6 +1747,22 @@ public class AppraiseService {
}
/**
* 商品检测不通过,记录一条补充物流
*/
private void addSuppleExpressForDetectionNotPass(Integer uid, long orderCode) {
try {
LOGGER.info("addSuppleExpressWhenDetectionNotPass uid={}, orderCode= {}", uid, orderCode);
//记录调拨信息
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.detection_not_pass;
expressInfoService.saveOperateTransferExpressInfo(uid, orderCode, expressType.getCode(), expressDataType, operateTransferCode);
} catch (Exception e) {
LOGGER.error("addSuppleExpressWhenDetectionNotPass error ,uid={}, orderCode= {},error {}", uid, orderCode, e);
}
}
/**
* 通知买家商品无法鉴定(并发券)
*
* @param request
... ... @@ -1735,6 +1791,15 @@ public class AppraiseService {
}
/**
* 通知买家商品检测不通过
*
* @param request
*/
private void noticeBuyerDetectNotPass(BuyerNoticeSender.Request request) {
inBoxFacade.noticeBuyerDetectNotPass(request);
}
/**
* 根据物流单号修改鉴定室
* @param appraiseExpressInfoBo
*/
... ...
... ... @@ -170,6 +170,10 @@ class BuyerOrderCancelHandler {
}
public void cancel() {
this.cancel(null);
}
public void cancel(String remark) {
log.info("cancel order {} from {} to {}", orderCode, expectStatus, targetStatus);
verify();
// 获取买家订单
... ... @@ -195,7 +199,7 @@ class BuyerOrderCancelHandler {
throwServiceException("卖家商品不存在");
}
// 更新订单状态成功
if (updateBuyerOrderStatus()) {
if (updateBuyerOrderStatus(remark)) {
log.info("cancel order {} from {} to {} success", orderCode, expectStatus, targetStatus);
addSuppleExpress(sellerUid);
refundCoupon();
... ... @@ -222,7 +226,7 @@ class BuyerOrderCancelHandler {
Verify.verifyNotNull(buyerOrderMapper, "buyerOrderMapper is null");
}
private boolean updateBuyerOrderStatus() {
private boolean updateBuyerOrderStatus(String remark) {
int rows = buyerOrderMapper.updateStatusByOrderCode(
orderCode,
uid,
... ... @@ -232,7 +236,7 @@ class BuyerOrderCancelHandler {
);
boolean success = rows > 0;
if (success && Objects.nonNull(orderStatusFlowService)) {
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
orderStatusFlowService.addAsy(orderCode, targetStatus.getCode(), remark);
}
return success;
}
... ...
... ... @@ -13,10 +13,7 @@ import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.BuyerOrderMetaMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
... ... @@ -172,6 +169,11 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
}
}
//检测不通过,需要查询原因
if (orderStatus == OrderStatus.PLATFORM_DETECTION_NOT_PASS.getCode()) {
BuyerOrderStatusFlow statusFlow = buyerOrderStatusFlowMapper.selectByStatus(buyerOrder.getOrderCode(), orderStatus);
detailDesc = String.format(temp, BuyerOrderStatusFlow.formatRemarkWithPrefixAndSuffix(statusFlow));
}
}catch (Exception ex){
getLogger().warn("in formatDetailDesc error buyerOrder {} temp {}", buyerOrder, temp, ex);
... ...
... ... @@ -839,6 +839,41 @@ public class InBoxFacade extends BaseNoticeFacade{
}
}
/**
* 通知买家商品无法鉴定
* @param request
*/
public void noticeBuyerDetectNotPass(@NonNull BuyerNoticeSender.Request request){
Integer uid = request.getUid();
Long orderCode = request.getOrderCode();
String params = buildParams(orderCode);
InboxReqVO inboxMessage = buildInboxReqVO(uid, params, InboxBusinessTypeEnum.NOTICE_BUYER_WHEN_DETECTION_NOT_PASS);
String smsContent = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTICE_BUYER_WHEN_DETECTION_NOT_PASS.getContent(), orderCode);
try {
log.info("noticeBuyerDetectNotPass,uid {} request is {}", uid, request);
executorService.execute(() -> {
InBoxResponse inBoxResponse = inBoxSDK.addInbox(inboxMessage);
log.info("noticeBuyerDetectNotPass inbox send success, message is {} res is {}", inboxMessage, inBoxResponse);
//发push todo
SendMessageRspBo bo = ufoSendService.identifyFail(String.valueOf(uid),String.valueOf(orderCode));
log.info("noticeBuyerDetectNotPass push buyer uid is {}, orderCode is {}, result is {}", uid, orderCode, JSON.toJSONString(bo));
//sms
String phone = userProxyService.getMobile(uid);
if (StringUtils.isBlank(phone)) {
log.warn("noticeBuyerDetectNotPass sms send fail,uid {} can not find phone", uid);
return;
}
sendSmsService.smsSendByMobile(smsContent, Arrays.asList(phone));
log.info("noticeBuyerDetectNotPass sms send success,uid {}", uid);
});
} catch (Exception e) {
log.warn("noticeBuyerDetectNotPass fail,uid {}", uid, e);
}
}
public void buyerCancelBeforeDepotReceive(@NonNull BuyerOrder buyerOrder, String compesant, SellerOrderGoods sog) {
buyerNoticeFacade.buyerCancelBeforeDepotReceive(buyerOrder, compesant, sog);
sellerNoticeFacade.buyerCancelBeforeDepotReceive(buyerOrder, sog);
... ...
... ... @@ -37,8 +37,11 @@ public class OrderStatusFlowService {
@Autowired
private OrderCodeGenerator orderCodeGenerator;
public void addAsy(Long orderCode, Integer status) {
addAsy(orderCode, status, null);
}
public void addAsy(Long orderCode, Integer status, String remark) {
try {
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
boolean isBuyerOrderCode = OrderCodeType.BUYER_TYPE.getType() == codeMeta.getType();
... ... @@ -48,6 +51,7 @@ public class OrderStatusFlowService {
buyerOrderStatusFlow.setOrderCode(orderCode);
buyerOrderStatusFlow.setStatus(status);
buyerOrderStatusFlow.setCreateTime(DateUtil.getCurrentTimeSecond());
buyerOrderStatusFlow.setRemark(remark);
logger.info("OrderStatusFlowService add execute , buyerOrderStatusFlow {} ", buyerOrderStatusFlow);
buyerOrderStatusFlowMapper.insert(buyerOrderStatusFlow);
});
... ... @@ -57,7 +61,5 @@ public class OrderStatusFlowService {
} catch (Exception e) {
logger.warn("OrderStatusFlowService add error , status {}, orderCode {} ", status, orderCode, e);
}
}
}
... ...
... ... @@ -2,8 +2,11 @@ package com.yohoufo.order.service.proxy;
import com.yoho.message.sdk.service.ufo.IUFOSendService;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.BuyerOrderStatusFlowMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderStatusFlow;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
... ... @@ -14,6 +17,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;
... ... @@ -27,6 +31,9 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
@Autowired
private ProductMapper productMapper;
@Autowired
private BuyerOrderStatusFlowMapper buyerOrderStatusFlowMapper;
@Override
public Logger getLogger() {
return log;
... ... @@ -247,6 +254,33 @@ public class SellerNoticeFacade extends BaseNoticeFacade {
}
}
/**
* 鉴定中心 检测不通过
*
* @param sog
* @param orderCode 买家订单号
*/
public void detectNotPass(SellerOrderGoods sog, long orderCode) {
String logPrefix = "notice seller detect not pass";
Integer sellerUid = sog.getUid();
String prdName = sog.getProductName();
String sizeName = sog.getSizeName();
String goodsTypeTag = buildGoodsTypeTagForSeller(sog);
try {
BuyerOrderStatusFlow statusFlow = buyerOrderStatusFlowMapper.selectByStatus(orderCode, OrderStatus.PLATFORM_DETECTION_NOT_PASS.getCode());
String remark = BuyerOrderStatusFlow.formatRemarkWithPrefixAndSuffix(statusFlow);
Product product = productMapper.selectByPrimaryKey(sog.getProductId());
String productCode = product.getProductCode();
newNotice(sellerUid)
.withLogPrefix(logPrefix)
.withInBox(InboxBusinessTypeEnum.NOTICE_SELLER_WHEN_DETECTION_NOT_PASS, goodsTypeTag, prdName, sizeName, productCode, remark)
.withSms(InboxBusinessTypeEnum.SMS_NOTICE_SELLER_WHEN_DETECTION_NOT_PASS, goodsTypeTag, prdName, sizeName, productCode, remark, orderCode)
.send();
} catch (Exception e) {
log.warn("{} fail, sellerUid {}, prdName {} ", logPrefix, sellerUid, prdName, e);
}
}
public void sellerDeliverWithTimes(SellerOrderGoods sog, long orderCode, int times, int leftTime, String timeUnit) {
String logPrefix = "notice seller seller deliver";
Integer sellerUid = sog.getUid();
... ...