Authored by Lixiaodi

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

Showing 28 changed files with 931 additions and 138 deletions
@@ -11,4 +11,6 @@ public class PriceFormater { @@ -11,4 +11,6 @@ public class PriceFormater {
11 } 11 }
12 12
13 13
  14 +
  15 +
14 } 16 }
@@ -17,9 +17,13 @@ public interface AppraiseOrderMetaMapper { @@ -17,9 +17,13 @@ public interface AppraiseOrderMetaMapper {
17 17
18 AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition); 18 AppraiseOrderMeta selectByOrderCode(AppraiseOrderMeta condition);
19 19
  20 + List<AppraiseOrderMeta> selectByOrderCodeMetaKeys(@Param("orderCode") long orderCode,
  21 + @Param("metaKeys") Collection<String> metaKeys);
20 22
21 AppraiseOrderMeta selectByOrderCodeStorageId(AppraiseOrderMeta condition); 23 AppraiseOrderMeta selectByOrderCodeStorageId(AppraiseOrderMeta condition);
22 24
23 List<AppraiseOrderMeta> selectByOrderCodeStorageIds(@Param("condition") AppraiseOrderMeta condition, 25 List<AppraiseOrderMeta> selectByOrderCodeStorageIds(@Param("condition") AppraiseOrderMeta condition,
24 @Param("storageIds")Collection<Integer> storageIds); 26 @Param("storageIds")Collection<Integer> storageIds);
  27 +
  28 + int updateMetaValueByOrderCodeAndMetaKey(AppraiseOrderMeta condition);
25 } 29 }
@@ -54,7 +54,9 @@ public class SellerWalletDetail { @@ -54,7 +54,9 @@ public class SellerWalletDetail {
54 BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42), 54 BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42),
55 APPRAISE_OK("鉴定通过", 51), 55 APPRAISE_OK("鉴定通过", 51),
56 APPRAISE_UNSURE("商品无法鉴定", 52), 56 APPRAISE_UNSURE("商品无法鉴定", 52),
57 - MERCHANT_EXIT("商家退出入驻", 61); 57 + MERCHANT_EXIT("商家退出入驻", 61),
  58 + CANCEL_DELIVER("不寄了", 71),
  59 + FLAW("瑕疵品",72);
58 60
59 private String name; 61 private String name;
60 private int value; 62 private int value;
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 <select id="selectCntByOrderType" resultType="java.lang.Integer"> 40 <select id="selectCntByOrderType" resultType="java.lang.Integer">
41 select count(*) from appraise_order 41 select count(*) from appraise_order
42 where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER} 42 where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
  43 + and is_del = 1
43 and status in 44 and status in
44 <foreach collection="statusList" item="status" open="(" close=")" separator=","> 45 <foreach collection="statusList" item="status" open="(" close=")" separator=",">
45 #{status,jdbcType=TINYINT} 46 #{status,jdbcType=TINYINT}
@@ -51,6 +52,7 @@ @@ -51,6 +52,7 @@
51 <include refid="Base_Column_List" /> 52 <include refid="Base_Column_List" />
52 from appraise_order 53 from appraise_order
53 where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER} 54 where uid = #{uid,jdbcType=INTEGER} and attributes = #{attributes,jdbcType=INTEGER}
  55 + and is_del = 1
54 and status in 56 and status in
55 <foreach collection="statusList" item="status" open="(" close=")" separator=","> 57 <foreach collection="statusList" item="status" open="(" close=")" separator=",">
56 #{status,jdbcType=TINYINT} 58 #{status,jdbcType=TINYINT}
@@ -83,6 +83,18 @@ @@ -83,6 +83,18 @@
83 and meta_key = #{metaKey,jdbcType=VARCHAR} 83 and meta_key = #{metaKey,jdbcType=VARCHAR}
84 </select> 84 </select>
85 85
  86 + <select id="selectByOrderCodeMetaKeys" resultMap="BaseResultMap">
  87 + select
  88 + <include refid="Base_Column_List" />
  89 + from appraise_order_meta
  90 + where order_code = #{orderCode,jdbcType=INTEGER}
  91 + and meta_key in
  92 + <foreach collection="metaKeys" item="metaKey" open="(" close=")" separator=",">
  93 + #{metaKey,jdbcType=VARCHAR}
  94 + </foreach>
  95 +
  96 + </select>
  97 +
86 <select id="selectByOrderCodeStorageId" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta" resultMap="BaseResultMap"> 98 <select id="selectByOrderCodeStorageId" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta" resultMap="BaseResultMap">
87 select 99 select
88 <include refid="Base_Column_List" /> 100 <include refid="Base_Column_List" />
@@ -104,4 +116,10 @@ @@ -104,4 +116,10 @@
104 and meta_key = #{condition.metaKey,jdbcType=VARCHAR} 116 and meta_key = #{condition.metaKey,jdbcType=VARCHAR}
105 </select> 117 </select>
106 118
  119 +
  120 + <update id="updateMetaValueByOrderCodeAndMetaKey" parameterType="com.yohoufo.dal.order.model.AppraiseOrderMeta">
  121 + update appraise_order_meta set meta_value = #{metaValue,jdbcType=VARCHAR}
  122 + where order_code = #{orderCode,jdbcType=BIGINT} and meta_key = #{metaKey,jdbcType=VARCHAR}
  123 + </update>
  124 +
107 </mapper> 125 </mapper>
@@ -218,4 +218,32 @@ public class SellerDepositOrderController { @@ -218,4 +218,32 @@ public class SellerDepositOrderController {
218 .build(); 218 .build();
219 } 219 }
220 220
  221 +
  222 + @RequestMapping(params = "method=ufo.depositOrder.addOrModifyAddress")
  223 + public ApiResponse addOrModifyAddress(@RequestParam(name = "uid")int uid,
  224 + @RequestParam(name = "orderCode")long orderCode,
  225 + @RequestParam(value = "addressId") String addressId
  226 + ){
  227 +
  228 + logger.info("in method=ufo.depositOrder.addOrModifyAddress orderCode {} addressId {}", orderCode, addressId);
  229 + sellerDepositOrderService.addOrModifyAddress(uid, orderCode, addressId);
  230 + return new ApiResponse.ApiResponseBuilder()
  231 + .code(200)
  232 + .message("地址修改成功")
  233 + .build();
  234 + }
  235 +
  236 +
  237 + @RequestMapping(params = "method=ufo.depositOrder.delete")
  238 + public ApiResponse deleteVisuable(@RequestParam(name = "uid")int uid,
  239 + @RequestParam(name = "orderCode")long orderCode
  240 + ){
  241 +
  242 + logger.info("in method=ufo.depositOrder.addOrModifyAddress orderCode {} uid {}", orderCode, uid);
  243 + sellerDepositOrderService.deleteVisuable(uid, orderCode);
  244 + return new ApiResponse.ApiResponseBuilder()
  245 + .code(200)
  246 + .message("成功")
  247 + .build();
  248 + }
221 } 249 }
@@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.vo.GoodsVo; @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.vo.GoodsVo;
6 import com.yohobuy.ufo.model.order.vo.ProductVo; 6 import com.yohobuy.ufo.model.order.vo.ProductVo;
7 import com.yohobuy.ufo.model.response.StorageDataResp; 7 import com.yohobuy.ufo.model.response.StorageDataResp;
8 import com.yohoufo.common.helper.ImageUrlAssist; 8 import com.yohoufo.common.helper.ImageUrlAssist;
  9 +import com.yohoufo.common.utils.BigDecimalHelper;
9 import com.yohoufo.dal.order.model.AppraiseOrderGoods; 10 import com.yohoufo.dal.order.model.AppraiseOrderGoods;
10 import com.yohoufo.dal.order.model.AppraiseOrderStorage; 11 import com.yohoufo.dal.order.model.AppraiseOrderStorage;
11 12
@@ -26,7 +27,7 @@ public final class ProductConvertor { @@ -26,7 +27,7 @@ public final class ProductConvertor {
26 .sizeName(storageDataResp.getSize().getSizeName()) 27 .sizeName(storageDataResp.getSize().getSizeName())
27 .num(num) 28 .num(num)
28 .totalEM(totalEM) 29 .totalEM(totalEM)
29 - .earnestMoney(SellerOrderConvertor.formatFee(totalEM)) 30 + .earnestMoney(BigDecimalHelper.formatNumber(totalEM, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT))
30 .build(); 31 .build();
31 } 32 }
32 33
@@ -37,6 +37,14 @@ public class AlarmEventBuilder { @@ -37,6 +37,14 @@ public class AlarmEventBuilder {
37 return smsAlarmEvent; 37 return smsAlarmEvent;
38 } 38 }
39 39
  40 + public static SmsAlarmEvent buildRefundEarnestMoneyAlarmEvent(Integer sellerUid,
  41 + Long buyerOrderCode){
  42 +
  43 + SmsAlarmEvent smsAlarmEvent ;
  44 + String content = "用户服务类订单"+ buyerOrderCode +",uid" + sellerUid + "退款失败";
  45 + smsAlarmEvent = new SmsAlarmEvent("ServiceOrder.finish", "finish", content);
  46 + return smsAlarmEvent;
  47 + }
40 48
41 public static SmsAlarmEvent buildRefundSellerEarnestMoneyAlarmEvent(OrderStatus orderStatus,Integer sellerUid, 49 public static SmsAlarmEvent buildRefundSellerEarnestMoneyAlarmEvent(OrderStatus orderStatus,Integer sellerUid,
42 Long buyerOrderCode){ 50 Long buyerOrderCode){
  1 +package com.yohoufo.order.event;
  2 +
  3 +import lombok.Getter;
  4 +import lombok.Setter;
  5 +import lombok.ToString;
  6 +
  7 +import java.util.function.Function;
  8 +@ToString(of = {"uid", "orderCode"})
  9 +public class SellerDepositOrderCancelAsyncEvent extends AsyncEvent {
  10 + @Getter@Setter
  11 + private int uid;
  12 + @Getter@Setter
  13 + private long orderCode;
  14 +
  15 + public SellerDepositOrderCancelAsyncEvent(Function<SellerDepositOrderCancelAsyncEvent,Boolean> function) {
  16 + super(function);
  17 + }
  18 +
  19 + @Override
  20 + AsyncEvent getAsyncEvent() {
  21 + return this;
  22 + }
  23 +}
@@ -28,4 +28,6 @@ public interface DelayTime { @@ -28,4 +28,6 @@ public interface DelayTime {
28 int CANCEL_SHAM_DELIVERY_TIME_MINUTE=48*60; 28 int CANCEL_SHAM_DELIVERY_TIME_MINUTE=48*60;
29 29
30 int MINUTES_120_HOURS = 120 * 60; 30 int MINUTES_120_HOURS = 120 * 60;
  31 +
  32 + int SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT = 10;
31 } 33 }
@@ -63,4 +63,7 @@ public interface TopicConstants { @@ -63,4 +63,7 @@ public interface TopicConstants {
63 */ 63 */
64 String DEPOSIT_FINISH_DELIVERY = "deposit.finishDelivery"; 64 String DEPOSIT_FINISH_DELIVERY = "deposit.finishDelivery";
65 65
  66 +
  67 + String SELLER_DEPOSIT_ORDER_AUTO_CANCEL = "sellerDepositOrder.autoCancel";
  68 +
66 } 69 }
  1 +package com.yohoufo.order.mq.consumer;
  2 +
  3 +import com.yohoufo.order.event.OrderCancelEvent;
  4 +import com.yohoufo.order.mq.TopicConstants;
  5 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +@Component
  10 +public class SellerDepositOrderAutoCancelMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
  11 +
  12 + @Autowired
  13 + private SellerDepositOrderService sellerDepositOrderService;
  14 +
  15 + @Override
  16 + public String getTopic() {
  17 + return TopicConstants.SELLER_DEPOSIT_ORDER_AUTO_CANCEL;
  18 + }
  19 +
  20 + @Override
  21 + public void cancel(OrderCancelEvent event) {
  22 + sellerDepositOrderService.cancelByTimeout(event);
  23 + }
  24 +
  25 + @Override
  26 + public void sendAgain(OrderCancelEvent cancelBean) {
  27 + producerTemplate.send(getTopic(), cancelBean, null, cancelBean.getPayExpire());
  28 + }
  29 +}
@@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo; @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
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.common.OrderCodeType; 9 import com.yohobuy.ufo.model.order.common.OrderCodeType;
  10 +import com.yohoufo.common.alarm.EventBusPublisher;
10 import com.yohoufo.common.exception.UfoServiceException; 11 import com.yohoufo.common.exception.UfoServiceException;
11 import com.yohoufo.common.utils.DateUtil; 12 import com.yohoufo.common.utils.DateUtil;
12 import com.yohoufo.dal.order.AppraiseOrderMapper; 13 import com.yohoufo.dal.order.AppraiseOrderMapper;
@@ -14,9 +15,12 @@ import com.yohoufo.dal.order.AppraiseOrderMetaMapper; @@ -14,9 +15,12 @@ import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
14 import com.yohoufo.dal.order.model.AppraiseOrder; 15 import com.yohoufo.dal.order.model.AppraiseOrder;
15 import com.yohoufo.dal.order.model.AppraiseOrderMeta; 16 import com.yohoufo.dal.order.model.AppraiseOrderMeta;
16 import com.yohoufo.order.constants.MetaKey; 17 import com.yohoufo.order.constants.MetaKey;
  18 +import com.yohoufo.order.event.EventHandlerContainer;
  19 +import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
17 import com.yohoufo.order.model.request.PaymentRequest; 20 import com.yohoufo.order.model.request.PaymentRequest;
18 import com.yohoufo.order.model.response.PrepayResponse; 21 import com.yohoufo.order.model.response.PrepayResponse;
19 import com.yohoufo.order.mq.DelayTime; 22 import com.yohoufo.order.mq.DelayTime;
  23 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
20 import org.slf4j.Logger; 24 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory; 25 import org.slf4j.LoggerFactory;
22 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +39,9 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService { @@ -35,6 +39,9 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
35 @Autowired 39 @Autowired
36 private AppraiseOrderMetaMapper appraiseOrderMetaMapper; 40 private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
37 41
  42 + @Autowired
  43 + private SellerDepositOrderService sellerDepositOrderService;
  44 +
38 @Override 45 @Override
39 public boolean isTimeoutCancelStatus(OrderInfo orderInfo) { 46 public boolean isTimeoutCancelStatus(OrderInfo orderInfo) {
40 if (orderInfo.getStatus() != null 47 if (orderInfo.getStatus() != null
@@ -158,5 +165,18 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService { @@ -158,5 +165,18 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
158 @Override 165 @Override
159 public void processAfterPay(OrderInfo orderInfo) { 166 public void processAfterPay(OrderInfo orderInfo) {
160 167
  168 + OrderAttributes oa = OrderAttributes.getOrderAttributes(orderInfo.getAttributes());
  169 + switch (oa){
  170 + case APPRAISE:
  171 +
  172 + break;
  173 + case DEPOSITE:
  174 + SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(sellerDepositOrderService::handleOrderCancelAsyncEvent);
  175 + event.setUid(orderInfo.getUid());
  176 + event.setOrderCode(orderInfo.getOrderCode());
  177 + EventBusPublisher.publishEvent(event);
  178 + logger.info("processAfterPay seller deposit order , SellerDepositOrderCancelAsyncEvent send out");
  179 + break;
  180 + }
161 } 181 }
162 } 182 }
@@ -2,6 +2,7 @@ package com.yohoufo.order.service; @@ -2,6 +2,7 @@ package com.yohoufo.order.service;
2 2
3 import com.yohobuy.ufo.model.order.common.OrderAttributes; 3 import com.yohobuy.ufo.model.order.common.OrderAttributes;
4 import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; 4 import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
  5 +import com.yohoufo.dal.order.model.AppraiseOrder;
5 6
6 public interface IGoodsService { 7 public interface IGoodsService {
7 8
@@ -23,21 +24,35 @@ public interface IGoodsService { @@ -23,21 +24,35 @@ public interface IGoodsService {
23 24
24 /** 25 /**
25 * 鉴定通过 26 * 鉴定通过
26 - * @param orderCode 27 + * @param appraiseOrder
27 */ 28 */
28 - int appraisePass(long orderCode); 29 + int appraisePass(AppraiseOrder appraiseOrder);
29 30
30 /** 31 /**
31 * 鉴别为假 32 * 鉴别为假
32 - * @param orderCode 33 + * @param appraiseOrder
33 */ 34 */
34 - int appraiseFake(long orderCode); 35 + int appraiseFake(AppraiseOrder appraiseOrder);
35 36
36 /** 37 /**
37 * 无法鉴别 38 * 无法鉴别
38 - * @param orderCode 39 + * @param appraiseOrder
39 */ 40 */
40 - int unsure(long orderCode); 41 + int unsure(AppraiseOrder appraiseOrder);
41 42
42 OrderAttributes getOrderAttributes(); 43 OrderAttributes getOrderAttributes();
  44 +
  45 + /**
  46 + * 虚假发货
  47 + * @param appraiseOrder
  48 + * @return
  49 + */
  50 + int shamDeliver(AppraiseOrder appraiseOrder);
  51 +
  52 + /**
  53 + * 瑕疵
  54 + * @param appraiseOrder
  55 + * @return
  56 + */
  57 + int findFlaw(AppraiseOrder appraiseOrder);
43 } 58 }
  1 +package com.yohoufo.order.service.handler;
  2 +
  3 +import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
  4 +import com.yohoufo.common.alarm.EventBusPublisher;
  5 +import com.yohoufo.common.alarm.SmsAlarmEvent;
  6 +import com.yohoufo.common.exception.UfoServiceException;
  7 +import com.yohoufo.dal.order.model.SellerWalletDetail;
  8 +import com.yohoufo.order.common.BillTradeStatus;
  9 +import com.yohoufo.order.common.RefundCase;
  10 +import com.yohoufo.order.convert.builder.AlarmEventBuilder;
  11 +import com.yohoufo.order.event.BillLogEvent;
  12 +import com.yohoufo.order.model.request.PaymentRequest;
  13 +import org.slf4j.Logger;
  14 +
  15 +import java.math.BigDecimal;
  16 +import java.util.function.BiConsumer;
  17 +
  18 +public class GoodsServiceRefundHandler extends AbsRefundOrderHandler {
  19 + private long orderCode;
  20 +
  21 + private Long paidOrderCode;
  22 +
  23 + private int uid;
  24 +
  25 + private BigDecimal refundEarnestMoney;
  26 +
  27 + private SellerWalletDetail.Type type;
  28 +
  29 + private Integer payment;
  30 +
  31 + public GoodsServiceRefundHandler loadLogger(Logger logger){
  32 + this.logger = logger;
  33 + return this;
  34 + }
  35 +
  36 +
  37 + public GoodsServiceRefundHandler loadRefundAction(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> refundConsumer){
  38 + this.refundConsumer = refundConsumer;
  39 + return this;
  40 + }
  41 +
  42 + public GoodsServiceRefundHandler loadUser(int uid){
  43 + this.uid = uid;
  44 + return this;
  45 + }
  46 +
  47 + public GoodsServiceRefundHandler loadOrder(Long orderCode,
  48 + Long paidOrderCode,
  49 + Integer payment,
  50 + BigDecimal refundEarnestMoney){
  51 + this.orderCode = orderCode;
  52 + this.paidOrderCode = paidOrderCode;
  53 + this.refundEarnestMoney = refundEarnestMoney;
  54 + this.payment = payment;
  55 + return this;
  56 + }
  57 +
  58 + public GoodsServiceRefundHandler loadActionCase(SellerWalletDetail.Type type){
  59 + this.type = type;
  60 + return this;
  61 + }
  62 +
  63 + @Override
  64 + public boolean refund() {
  65 + if (paidOrderCode == null){
  66 + throw new UfoServiceException(400, "退款订单不存在");
  67 + }
  68 +
  69 + try {
  70 + MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder()
  71 + .uid(uid)
  72 + .orderCode(orderCode).earnestMoney(this.refundEarnestMoney)
  73 + .type(type.getValue()).build();
  74 +
  75 + PaymentRequest request = PaymentRequest.builder().orderCode(this.orderCode)
  76 + .paidOrderCode(this.paidOrderCode)
  77 + .refundAmount(this.refundEarnestMoney.doubleValue())
  78 + .refundattch(moai).build();
  79 +
  80 + BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
  81 + .buyerUid(uid).sellerUid(uid).orderCode(orderCode)
  82 + .payType(payment).refundCase(RefundCase.SELLER_EARNEST_MONEY)
  83 + ;
  84 + refundConsumer.accept(request, bleb);
  85 + return true;
  86 + }catch (Exception ex){
  87 + logger.warn("in refund earnest money fail orderCode {} refundEarnestMoney {} ex {}",
  88 + orderCode, refundEarnestMoney, ex);
  89 + BillLogEvent buyerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
  90 + EventBusPublisher.publishEvent(buyerBillLogEvent);
  91 + SmsAlarmEvent smsAlarmEvent = AlarmEventBuilder.buildRefundEarnestMoneyAlarmEvent( uid, orderCode);
  92 + EventBusPublisher.publishEvent(smsAlarmEvent);
  93 + return false;
  94 + }
  95 + }
  96 +}
@@ -3,9 +3,7 @@ package com.yohoufo.order.service.handler; @@ -3,9 +3,7 @@ package com.yohoufo.order.service.handler;
3 import com.google.common.eventbus.Subscribe; 3 import com.google.common.eventbus.Subscribe;
4 import com.yoho.core.dal.datasource.annotation.Database; 4 import com.yoho.core.dal.datasource.annotation.Database;
5 import com.yohobuy.ufo.model.order.common.EntrySellerType; 5 import com.yohobuy.ufo.model.order.common.EntrySellerType;
6 -import com.yohoufo.common.alarm.EventBusPublisher;  
7 import com.yohoufo.common.alarm.IEventHandler; 6 import com.yohoufo.common.alarm.IEventHandler;
8 -import com.yohoufo.common.alarm.SmsAlarmEvent;  
9 import com.yohoufo.common.utils.DateUtil; 7 import com.yohoufo.common.utils.DateUtil;
10 import com.yohoufo.dal.order.model.SellerOrderStatsResult; 8 import com.yohoufo.dal.order.model.SellerOrderStatsResult;
11 import com.yohoufo.order.event.SellerEnterTypeChangeEvent; 9 import com.yohoufo.order.event.SellerEnterTypeChangeEvent;
@@ -66,7 +64,7 @@ public class SellerEnterTypeChangeEventHandler implements IEventHandler<SellerEn @@ -66,7 +64,7 @@ public class SellerEnterTypeChangeEventHandler implements IEventHandler<SellerEn
66 case QUIT: 64 case QUIT:
67 if (storedSellerService.isStoredSeller(sellerUid)) { 65 if (storedSellerService.isStoredSeller(sellerUid)) {
68 logger.warn("[{}] is stored seller yet,can't handle quit event", sellerUid); 66 logger.warn("[{}] is stored seller yet,can't handle quit event", sellerUid);
69 - EventBusPublisher.publishEvent(new SmsAlarmEvent("seller.enterQuitEvent", "handle_exception", "seller(" + sellerUid +") is stored seller yet")); 67 + return false;
70 } else { 68 } else {
71 //退出入驻,需要更新当前周期,以及下个周期的统计数据 69 //退出入驻,需要更新当前周期,以及下个周期的统计数据
72 handleQuitEvent(sellerUid, entrySellerType); 70 handleQuitEvent(sellerUid, entrySellerType);
@@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
5 import com.yohoufo.common.utils.DateUtil; 5 import com.yohoufo.common.utils.DateUtil;
6 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 6 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
7 import com.yohoufo.dal.order.AppraiseOrderMapper; 7 import com.yohoufo.dal.order.AppraiseOrderMapper;
  8 +import com.yohoufo.dal.order.model.AppraiseOrder;
8 import com.yohoufo.dal.order.model.AppraiseOrderGoods; 9 import com.yohoufo.dal.order.model.AppraiseOrderGoods;
9 import com.yohoufo.order.service.IGoodsService; 10 import com.yohoufo.order.service.IGoodsService;
10 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 11 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
@@ -41,7 +42,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -41,7 +42,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
41 return rows; 42 return rows;
42 } 43 }
43 44
44 - private int triggerStatusChange(Long orderCode, AppraiseOrderStatus targetStatus, AppraiseOrderStatus expectedStatus){ 45 + public int triggerStatusChange(Long orderCode, AppraiseOrderStatus targetStatus, AppraiseOrderStatus expectedStatus){
45 int cdt = DateUtil.getCurrentTimeSecond(); 46 int cdt = DateUtil.getCurrentTimeSecond();
46 int rows = appraiseOrderMapper.updateStatusByOrderCode(orderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt); 47 int rows = appraiseOrderMapper.updateStatusByOrderCode(orderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt);
47 if (rows==0){ 48 if (rows==0){
@@ -83,10 +84,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -83,10 +84,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
83 84
84 /** 85 /**
85 * 鉴定通过 86 * 鉴定通过
86 - * @param orderCode 87 + * @param appraiseOrder
87 */ 88 */
88 @Override 89 @Override
89 - public int appraisePass(long orderCode){ 90 + public int appraisePass(AppraiseOrder appraiseOrder){
  91 + long orderCode = appraiseOrder.getOrderCode();
90 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.JUDGE_PASS, 92 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.JUDGE_PASS,
91 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING; 93 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING;
92 94
@@ -97,11 +99,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -97,11 +99,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
97 99
98 /** 100 /**
99 * 鉴别为假 101 * 鉴别为假
100 - * @param orderCode 102 + * @param appraiseOrder
101 */ 103 */
102 @Override 104 @Override
103 - public int appraiseFake(long orderCode){  
104 - 105 + public int appraiseFake(AppraiseOrder appraiseOrder){
  106 + long orderCode = appraiseOrder.getOrderCode();
105 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.CHECKING_FAKE, 107 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.CHECKING_FAKE,
106 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING; 108 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING;
107 109
@@ -112,10 +114,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -112,10 +114,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
112 114
113 /** 115 /**
114 * 无法鉴别 116 * 无法鉴别
115 - * @param orderCode 117 + * @param appraiseOrder
116 */ 118 */
117 @Override 119 @Override
118 - public int unsure(long orderCode){ 120 + public int unsure(AppraiseOrder appraiseOrder){
  121 + long orderCode = appraiseOrder.getOrderCode();
119 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE, 122 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE,
120 expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE; 123 expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
121 124
@@ -123,4 +126,26 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -123,4 +126,26 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
123 logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows); 126 logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
124 return rows; 127 return rows;
125 } 128 }
  129 +
  130 + @Override
  131 + public int shamDeliver(AppraiseOrder appraiseOrder){
  132 + long orderCode = appraiseOrder.getOrderCode();
  133 + AppraiseOrderStatus targetStatus = AppraiseOrderStatus.SHAM_SEND_OUT,
  134 + expectedStatus = AppraiseOrderStatus.SELLER_SEND_OUT;
  135 +
  136 + int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
  137 + logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
  138 + return rows;
  139 + }
  140 +
  141 + @Override
  142 + public int findFlaw(AppraiseOrder appraiseOrder){
  143 + long orderCode = appraiseOrder.getOrderCode();
  144 + AppraiseOrderStatus targetStatus = AppraiseOrderStatus.QUALITY_CHECK_FAKE,
  145 + expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
  146 +
  147 + int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
  148 + logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
  149 + return rows;
  150 + }
126 } 151 }
@@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.order.resp.*; @@ -13,6 +13,7 @@ import com.yohobuy.ufo.model.order.resp.*;
13 import com.yohobuy.ufo.model.order.vo.AddressInfo; 13 import com.yohobuy.ufo.model.order.vo.AddressInfo;
14 import com.yohoufo.common.exception.UfoServiceException; 14 import com.yohoufo.common.exception.UfoServiceException;
15 import com.yohoufo.common.utils.AddressUtil; 15 import com.yohoufo.common.utils.AddressUtil;
  16 +import com.yohoufo.common.utils.BigDecimalHelper;
16 import com.yohoufo.common.utils.DateUtil; 17 import com.yohoufo.common.utils.DateUtil;
17 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 18 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
18 import com.yohoufo.dal.order.AppraiseOrderMapper; 19 import com.yohoufo.dal.order.AppraiseOrderMapper;
@@ -327,7 +328,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements @@ -327,7 +328,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
327 } 328 }
328 AppraiseOrderDetailResp aodResp = AppraiseOrderDetailResp.builder() 329 AppraiseOrderDetailResp aodResp = AppraiseOrderDetailResp.builder()
329 .uid(uid).orderCode(orderCode) 330 .uid(uid).orderCode(orderCode)
330 - .amount(SellerOrderConvertor.formatFee(pao.getAmount())) 331 + .amount(BigDecimalHelper.formatNumber(pao.getAmount(), BigDecimalHelper.FORMAT_TWOBITAFTERPOINT))
331 .statusDetail(statusDetail) 332 .statusDetail(statusDetail)
332 .createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS)) 333 .createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))
333 .goodsInfo(AppraiseOrderGoodsConvertor.do2Bo(paog)) 334 .goodsInfo(AppraiseOrderGoodsConvertor.do2Bo(paog))
@@ -337,46 +338,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements @@ -337,46 +338,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
337 return aodResp; 338 return aodResp;
338 } 339 }
339 340
340 - /**  
341 - * 是否付费鉴定 or 卖家寄存订单  
342 - * @param orderCode  
343 - * @return  
344 - */  
345 - public ExistenceNode isAppraiseOrder(long orderCode){  
346 - AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);  
347 - boolean flag = Objects.nonNull(pao);  
348 - Integer aoac = flag ? pao.getAttributes() : null;  
349 - logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",  
350 - orderCode, aoac, flag);  
351 - return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();  
352 - }  
353 -  
354 - @Data  
355 - @Builder  
356 - public static class ExistenceNode{  
357 - boolean isExisted;  
358 - AppraiseOrder appraiseOrder;  
359 -  
360 - }  
361 341
362 - /**  
363 - * 是否付费鉴定订单  
364 - * @param uid  
365 - * @param orderCode  
366 - * @return  
367 - */  
368 - public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){  
369 - AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);  
370 - Integer aoac = null;  
371 - OrderAttributes oa = null;  
372 - boolean flag = Objects.nonNull(pao)  
373 - && Objects.nonNull(aoac=pao.getAttributes())  
374 - && Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))  
375 - && Objects.equals(oa, OrderAttributes.APPRAISE);  
376 - logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",  
377 - uid, orderCode, aoac, oa, flag);  
378 - return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();  
379 - }  
380 342
381 /** 343 /**
382 * 发货 344 * 发货
@@ -399,28 +361,30 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements @@ -399,28 +361,30 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
399 361
400 /** 362 /**
401 * 鉴定通过 363 * 鉴定通过
402 - * @param orderCode 364 + * @param appraiseOrder
403 */ 365 */
404 @Override 366 @Override
405 - public int appraisePass(long orderCode){  
406 - return super.appraisePass(orderCode); 367 + public int appraisePass(AppraiseOrder appraiseOrder){
  368 + return super.appraisePass(appraiseOrder);
407 } 369 }
408 370
409 /** 371 /**
410 * 鉴别为假 372 * 鉴别为假
411 - * @param orderCode 373 + * @param appraiseOrder
412 */ 374 */
413 @Override 375 @Override
414 - public int appraiseFake(long orderCode){  
415 - return super.appraiseFake(orderCode); 376 + public int appraiseFake(AppraiseOrder appraiseOrder){
  377 + return super.appraiseFake(appraiseOrder);
416 } 378 }
417 379
418 /** 380 /**
419 * 无法鉴别 381 * 无法鉴别
420 - * @param orderCode 382 + * @param appraiseOrder
421 */ 383 */
422 @Override 384 @Override
423 - public int unsure(long orderCode){  
424 - return super.unsure(orderCode); 385 + public int unsure(AppraiseOrder appraiseOrder){
  386 + return super.unsure(appraiseOrder);
425 } 387 }
  388 +
  389 +
426 } 390 }
@@ -849,7 +849,9 @@ public class AppraiseService { @@ -849,7 +849,9 @@ public class AppraiseService {
849 Long orderCode = appraiseExpressInfoBo.getOrderCode(); 849 Long orderCode = appraiseExpressInfoBo.getOrderCode();
850 ApiResponse apiResponse = new ApiResponse(); 850 ApiResponse apiResponse = new ApiResponse();
851 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 851 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
852 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 852 + LOGGER.info("appraiseFailAndDelivery isGoodsServiceOrder, appraiseNotPassFlag {}", appraiseExpressInfoBo);
  853 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  854 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
853 apiResponse.setCode(200); 855 apiResponse.setCode(200);
854 return apiResponse; 856 return apiResponse;
855 } 857 }
@@ -1098,7 +1100,8 @@ public class AppraiseService { @@ -1098,7 +1100,8 @@ public class AppraiseService {
1098 LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode); 1100 LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode);
1099 ApiResponse apiResponse = new ApiResponse(); 1101 ApiResponse apiResponse = new ApiResponse();
1100 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1102 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1101 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 1103 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1104 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
1102 apiResponse.setCode(200); 1105 apiResponse.setCode(200);
1103 return apiResponse; 1106 return apiResponse;
1104 } 1107 }
@@ -1181,7 +1184,8 @@ public class AppraiseService { @@ -1181,7 +1184,8 @@ public class AppraiseService {
1181 ApiResponse apiResponse = new ApiResponse(); 1184 ApiResponse apiResponse = new ApiResponse();
1182 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1185 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1183 LOGGER.info("qualityCheckReject isGoodsServiceOrder order code {}", orderCode); 1186 LOGGER.info("qualityCheckReject isGoodsServiceOrder order code {}", orderCode);
1184 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 1187 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1188 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
1185 apiResponse.setCode(200); 1189 apiResponse.setCode(200);
1186 return apiResponse; 1190 return apiResponse;
1187 } 1191 }
@@ -1280,7 +1284,8 @@ public class AppraiseService { @@ -1280,7 +1284,8 @@ public class AppraiseService {
1280 ApiResponse apiResponse = new ApiResponse(); 1284 ApiResponse apiResponse = new ApiResponse();
1281 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1285 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1282 LOGGER.info("judgeCenterPass isGoodsServiceOrder orderCode {}", orderCode); 1286 LOGGER.info("judgeCenterPass isGoodsServiceOrder orderCode {}", orderCode);
1283 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraisePass(orderCode); 1287 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1288 + existenceNode.getGoodsService().appraisePass(existenceNode.getAppraiseOrder());
1284 apiResponse.setCode(200); 1289 apiResponse.setCode(200);
1285 return apiResponse; 1290 return apiResponse;
1286 } 1291 }
@@ -1537,7 +1542,9 @@ public class AppraiseService { @@ -1537,7 +1542,9 @@ public class AppraiseService {
1537 public void appraiseUnsure(Integer uid, Long orderCode) { 1542 public void appraiseUnsure(Integer uid, Long orderCode) {
1538 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1543 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1539 LOGGER.info("in appraiseUnsure isGoodsServiceOrder ordercode {}", orderCode); 1544 LOGGER.info("in appraiseUnsure isGoodsServiceOrder ordercode {}", orderCode);
1540 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).unsure(orderCode); 1545 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1546 + existenceNode.getGoodsService().unsure(existenceNode.getAppraiseOrder());
  1547 + return;
1541 } 1548 }
1542 1549
1543 1550
@@ -132,6 +132,9 @@ public class BuyerOrderCancelService { @@ -132,6 +132,9 @@ public class BuyerOrderCancelService {
132 @Autowired 132 @Autowired
133 private ExpressInfoMapper expressInfoMapper; 133 private ExpressInfoMapper expressInfoMapper;
134 134
  135 + @Autowired
  136 + private ServiceOrderProcessor serviceOrderProcessor;
  137 +
135 @Resource(name = "tradeMqProducer") 138 @Resource(name = "tradeMqProducer")
136 private YhProducer tradeMqProducer; 139 private YhProducer tradeMqProducer;
137 140
@@ -250,6 +253,13 @@ public class BuyerOrderCancelService { @@ -250,6 +253,13 @@ public class BuyerOrderCancelService {
250 } 253 }
251 254
252 public void cancelForSellerShamSendOut(int uid, long orderCode,OrderStatus targetStatus) { 255 public void cancelForSellerShamSendOut(int uid, long orderCode,OrderStatus targetStatus) {
  256 +
  257 + if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
  258 + logger.info("cancelForSellerShamSendOut isGoodsServiceOrder orderCode {}", orderCode);
  259 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  260 + existenceNode.getGoodsService().shamDeliver(existenceNode.getAppraiseOrder());
  261 + }
  262 +
253 new BuyerOrderCancelHandler(uid, orderCode) 263 new BuyerOrderCancelHandler(uid, orderCode)
254 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper) 264 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
255 .withSellerOrderSupplier(sellerOrderGoodsMapper,sellerOrderMetaMapper) 265 .withSellerOrderSupplier(sellerOrderGoodsMapper,sellerOrderMetaMapper)
@@ -39,6 +39,7 @@ import com.yohoufo.order.service.listener.BuyerOrderChangeEvent; @@ -39,6 +39,7 @@ import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
39 import com.yohoufo.order.service.listener.OrderChangeListenerContainer; 39 import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
40 import com.yohoufo.order.service.pay.AbstractPayService; 40 import com.yohoufo.order.service.pay.AbstractPayService;
41 import com.yohoufo.order.service.proxy.*; 41 import com.yohoufo.order.service.proxy.*;
  42 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
42 import com.yohoufo.order.utils.BuyerOrderUtils; 43 import com.yohoufo.order.utils.BuyerOrderUtils;
43 import com.yohoufo.order.utils.LoggerUtils; 44 import com.yohoufo.order.utils.LoggerUtils;
44 import com.yohoufo.order.utils.SellerGoodsHelper; 45 import com.yohoufo.order.utils.SellerGoodsHelper;
@@ -108,6 +109,15 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -108,6 +109,15 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
108 @Autowired 109 @Autowired
109 protected ServiceOrderProcessor serviceOrderProcessor; 110 protected ServiceOrderProcessor serviceOrderProcessor;
110 111
  112 + @Autowired
  113 + private BuyerOrderMetaMapper buyerOrderMetaMapper;
  114 +
  115 + @Autowired
  116 + private UserProxyService userProxyService;
  117 +
  118 + @Autowired
  119 + private SellerDepositOrderService sellerDepositOrderService;
  120 +
111 /** 121 /**
112 * 提交订单 122 * 提交订单
113 * @param orderRequest 123 * @param orderRequest
@@ -825,15 +835,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -825,15 +835,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
825 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode()); 835 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
826 } 836 }
827 } 837 }
828 - @Autowired  
829 - private BuyerOrderMetaMapper buyerOrderMetaMapper;  
830 838
831 - @Autowired  
832 - private UserProxyService userProxyService; 839 +
833 840
834 841
835 @Override 842 @Override
836 public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr) { 843 public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr) {
  844 + if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
  845 + sellerDepositOrderService.addOrModifyAddress(uid, orderCode, addressIdstr);
  846 + return;
  847 + }
  848 +
837 int addressId = AddressUtil.getDecryptStr(addressIdstr); 849 int addressId = AddressUtil.getDecryptStr(addressIdstr);
838 if (addressId < 0){ 850 if (addressId < 0){
839 logger.warn("modifyAddressOfDepositOrder addressId invalidate, uid {}, orderCode {}, addressId is {}", 851 logger.warn("modifyAddressOfDepositOrder addressId invalidate, uid {}, orderCode {}, addressId is {}",
@@ -853,57 +865,75 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -853,57 +865,75 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
853 return; 865 return;
854 } 866 }
855 867
  868 + MetaAddressService.ActionCallBack<BuyerOrderMeta> callBack = new MetaAddressService.ActionCallBack<BuyerOrderMeta>() {
  869 + @Override
  870 + public List selectByMetaKeys(int uid, long orderCode, List metaKeys) {
  871 + List<BuyerOrderMeta> pboms = buyerOrderMetaMapper.selectByMetaKeys(uid, orderCode, metaKeys);
  872 + return pboms;
  873 + }
  874 +
  875 + @Override
  876 + public void insertBatch(List<BuyerOrderMeta> list) {
  877 + buyerOrderMetaMapper.insertBatch(list);
  878 + }
  879 +
  880 + @Override
  881 + public void insert(BuyerOrderMeta o) {
  882 + buyerOrderMetaMapper.insert(o);
  883 + }
856 884
857 - //the address of send back 2 seller 885 + @Override
  886 + public void updateMetaVal(BuyerOrderMeta o) {
  887 + buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(o);
  888 + }
  889 +
  890 + @Override
  891 + public AddressInfo hiddenBackAddress(int uid, int addressId) {
858 AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId); 892 AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
  893 +
  894 + return hiddenBackAddress;
  895 + }
  896 +
  897 + @Override
  898 + public AddressInfo noHiddenBackAddress(int uid, int addressId) {
859 AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId); 899 AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
860 - final String key = MetaKey.RECALL_ADDRESS, hiiden_key = MetaKey.RECALL_HIDDEN_ADDRESS; 900 + return noHiddenBackAddress;
  901 + }
  902 +
  903 + @Override
  904 + public BuyerOrderMeta buildnoHiddenAddressMeta(int uid, long orderCode, String key, AddressInfo noHiddenBackAddress) {
861 BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta(); 905 BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta();
862 noHiddenAddressMeta.setUid(uid); 906 noHiddenAddressMeta.setUid(uid);
863 noHiddenAddressMeta.setOrderCode(orderCode); 907 noHiddenAddressMeta.setOrderCode(orderCode);
864 noHiddenAddressMeta.setMetaKey(key); 908 noHiddenAddressMeta.setMetaKey(key);
865 noHiddenAddressMeta.setMetaValue(JSONObject.toJSONString(noHiddenBackAddress)); 909 noHiddenAddressMeta.setMetaValue(JSONObject.toJSONString(noHiddenBackAddress));
866 - //hidden address 910 + return noHiddenAddressMeta;
  911 + }
  912 +
  913 + @Override
  914 + public BuyerOrderMeta buildHiddenAddressMeta(int uid, long orderCode, String hiddenKey, AddressInfo hiddenBackAddress) {
867 BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta(); 915 BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta();
868 hiddenAddressMeta.setUid(uid); 916 hiddenAddressMeta.setUid(uid);
869 hiddenAddressMeta.setOrderCode(orderCode); 917 hiddenAddressMeta.setOrderCode(orderCode);
870 - hiddenAddressMeta.setMetaKey(hiiden_key); 918 + hiddenAddressMeta.setMetaKey(hiddenKey);
871 hiddenAddressMeta.setMetaValue(JSONObject.toJSONString(hiddenBackAddress)); 919 hiddenAddressMeta.setMetaValue(JSONObject.toJSONString(hiddenBackAddress));
872 - //  
873 - List<BuyerOrderMeta> boms = new ArrayList<>(2);  
874 - boms.add(noHiddenAddressMeta);  
875 - boms.add(hiddenAddressMeta);  
876 -  
877 -  
878 - List<BuyerOrderMeta> pboms = buyerOrderMetaMapper.selectByMetaKeys(uid, orderCode, Arrays.asList(key, hiiden_key));  
879 -  
880 - if(CollectionUtils.isEmpty(pboms)){  
881 - buyerOrderMetaMapper.insertBatch(boms);  
882 - }else{  
883 - boolean hitNoHidden = false;  
884 - boolean hitHidden = false;  
885 - for (BuyerOrderMeta pbom : pboms){  
886 - if (pbom.getMetaKey().equals(hiiden_key)){  
887 - hitHidden = true; 920 + return hiddenAddressMeta;
888 } 921 }
889 922
890 - if (pbom.getMetaKey().equals(key)){  
891 - hitNoHidden = true;  
892 - } 923 + @Override
  924 + public boolean hitHidden(BuyerOrderMeta buyerOrderMeta, String hidden_key) {
  925 + return buyerOrderMeta.getMetaKey().equals(hidden_key);
893 } 926 }
894 - doPersistent4AddessMeta(hitHidden, hiddenAddressMeta);  
895 - doPersistent4AddessMeta(hitNoHidden, noHiddenAddressMeta); 927 +
  928 + @Override
  929 + public boolean hitNoHidden(BuyerOrderMeta buyerOrderMeta, String noHiddenKey) {
  930 + return buyerOrderMeta.getMetaKey().equals(noHiddenKey);
896 } 931 }
  932 + };
  933 + new MetaAddressService().modifyAddressOfDepositOrder(uid, orderCode, addressIdstr, callBack);
897 } 934 }
898 935
899 - private void doPersistent4AddessMeta(boolean isExisted, BuyerOrderMeta bom){  
900 - if (isExisted){  
901 - buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(bom);  
902 - }else {  
903 - buyerOrderMetaMapper.insert(bom);  
904 - }  
905 936
906 - }  
907 937
908 938
909 //清理缓存 939 //清理缓存
@@ -135,6 +135,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -135,6 +135,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
135 @Autowired 135 @Autowired
136 private OrderCodeGenerator orderCodeGenerator; 136 private OrderCodeGenerator orderCodeGenerator;
137 137
  138 + @Autowired
  139 + private ServiceOrderProcessor serviceOrderProcessor;
  140 +
138 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data"; 141 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
139 142
140 //物流文案设置 143 //物流文案设置
@@ -146,8 +149,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -146,8 +149,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
146 @Autowired 149 @Autowired
147 private SkupService skupService; 150 private SkupService skupService;
148 151
149 - @Autowired  
150 - private ServiceOrderProcessor serviceOrderProcessor;  
151 152
152 153
153 private int processBuyerOrder(BuyerOrder buyerOrder, 154 private int processBuyerOrder(BuyerOrder buyerOrder,
@@ -1089,7 +1090,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -1089,7 +1090,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
1089 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); 1090 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
1090 AppraiseAddressResp resp = null; 1091 AppraiseAddressResp resp = null;
1091 if (OrderCodeType.GOODS_SERVICE.equals(orderCodeType)){ 1092 if (OrderCodeType.GOODS_SERVICE.equals(orderCodeType)){
1092 - AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode); 1093 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
1093 if (!existenceNode.isExisted()){ 1094 if (!existenceNode.isExisted()){
1094 throwServiceException(400,"订单不存在"); 1095 throwServiceException(400,"订单不存在");
1095 } 1096 }
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yoho.error.ServiceError;
  4 +import com.yoho.error.exception.ServiceException;
  5 +import com.yohobuy.ufo.model.order.vo.AddressInfo;
  6 +import com.yohoufo.common.utils.AddressUtil;
  7 +import com.yohoufo.order.constants.MetaKey;
  8 +import com.yohoufo.order.utils.LoggerUtils;
  9 +import org.apache.commons.collections.CollectionUtils;
  10 +import org.slf4j.Logger;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.Arrays;
  14 +import java.util.List;
  15 +
  16 +
  17 +public class MetaAddressService<E> {
  18 +
  19 + private final Logger logger = LoggerUtils.getBuyerOrderLogger();
  20 +
  21 +
  22 +
  23 + public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr, ActionCallBack<E> callBack) {
  24 +
  25 + int addressId = AddressUtil.getDecryptStr(addressIdstr);
  26 + if (addressId < 0){
  27 + logger.warn("addOrModifyAddress addressId invalidate, uid {}, orderCode {}, addressId is {}",
  28 + uid, orderCode, addressIdstr);
  29 + throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
  30 + }
  31 +
  32 + //the address of send back 2 seller
  33 + AddressInfo hiddenBackAddress = callBack.hiddenBackAddress(uid, addressId);
  34 + AddressInfo noHiddenBackAddress = callBack.noHiddenBackAddress(uid, addressId);
  35 + final String key = MetaKey.RECALL_ADDRESS, hiiden_key = MetaKey.RECALL_HIDDEN_ADDRESS;
  36 + E noHiddenAddressMeta= callBack.buildnoHiddenAddressMeta(uid, orderCode, key, noHiddenBackAddress);
  37 +
  38 + //hidden address
  39 + E hiddenAddressMeta= callBack.buildHiddenAddressMeta(uid, orderCode, hiiden_key, hiddenBackAddress);
  40 + //
  41 + List<E> boms = new ArrayList<>(2);
  42 + boms.add(noHiddenAddressMeta);
  43 + boms.add(hiddenAddressMeta);
  44 +
  45 +
  46 + List<E> pboms = callBack.selectByMetaKeys(uid, orderCode, Arrays.asList(key, hiiden_key));
  47 +
  48 + if(CollectionUtils.isEmpty(pboms)){
  49 + callBack.insertBatch(boms);
  50 + }else{
  51 + boolean hitNoHidden = false;
  52 + boolean hitHidden = false;
  53 + for (E pbom : pboms){
  54 + if (callBack.hitHidden(pbom, hiiden_key)){
  55 + hitHidden = true;
  56 + }
  57 +
  58 + if (callBack.hitNoHidden(pbom, key)){
  59 + hitNoHidden = true;
  60 + }
  61 + }
  62 + doPersistent4AddessMeta(hitHidden, hiddenAddressMeta, callBack);
  63 + doPersistent4AddessMeta(hitNoHidden, noHiddenAddressMeta, callBack);
  64 + }
  65 + }
  66 +
  67 + private void doPersistent4AddessMeta(boolean isExisted, E bom, ActionCallBack callBack){
  68 + if (isExisted){
  69 + callBack.updateMetaVal(bom);
  70 + }else {
  71 + callBack.insert(bom);
  72 + }
  73 +
  74 + }
  75 +
  76 +
  77 +
  78 + public interface ActionCallBack<E>{
  79 +
  80 + List<E> selectByMetaKeys(int uid, long orderCode, List<String> metaKeys);
  81 +
  82 + void insertBatch(List<E> list);
  83 +
  84 + void insert(E e);
  85 +
  86 + void updateMetaVal(E e);
  87 +
  88 + AddressInfo hiddenBackAddress(int uid, int addressId);
  89 +
  90 + AddressInfo noHiddenBackAddress(int uid, int addressId);
  91 +
  92 + E buildnoHiddenAddressMeta(int uid, long orderCode, String key, AddressInfo noHiddenBackAddress);
  93 +
  94 +
  95 + E buildHiddenAddressMeta(int uid, long orderCode, String hiddenKey, AddressInfo hiddenBackAddress);
  96 +
  97 +
  98 + boolean hitHidden(E e, String hidden_key);
  99 +
  100 + boolean hitNoHidden(E e, String noHiddenKey);
  101 +
  102 + }
  103 +
  104 +}
@@ -5,22 +5,30 @@ import com.yoho.error.exception.ServiceException; @@ -5,22 +5,30 @@ import com.yoho.error.exception.ServiceException;
5 import com.yohobuy.ufo.model.order.common.OrderAttributes; 5 import com.yohobuy.ufo.model.order.common.OrderAttributes;
6 import com.yohobuy.ufo.model.order.common.OrderCodeType; 6 import com.yohobuy.ufo.model.order.common.OrderCodeType;
7 import com.yohoufo.common.exception.UfoServiceException; 7 import com.yohoufo.common.exception.UfoServiceException;
  8 +import com.yohoufo.dal.order.AppraiseOrderMapper;
8 import com.yohoufo.dal.order.model.AppraiseOrder; 9 import com.yohoufo.dal.order.model.AppraiseOrder;
9 import com.yohoufo.order.service.IGoodsService; 10 import com.yohoufo.order.service.IGoodsService;
10 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService; 11 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
11 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 12 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
12 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 13 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
13 import com.yohoufo.order.utils.LoggerUtils; 14 import com.yohoufo.order.utils.LoggerUtils;
  15 +import lombok.Builder;
  16 +import lombok.Data;
14 import org.slf4j.Logger; 17 import org.slf4j.Logger;
15 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
17 20
  21 +import java.util.Objects;
  22 +
18 @Service 23 @Service
19 public class ServiceOrderProcessor { 24 public class ServiceOrderProcessor {
20 25
21 private final Logger logger = LoggerUtils.getSellerOrderLogger(); 26 private final Logger logger = LoggerUtils.getSellerOrderLogger();
22 27
23 @Autowired 28 @Autowired
  29 + private AppraiseOrderMapper appraiseOrderMapper;
  30 +
  31 + @Autowired
24 private AppraiseOrderService appraiseOrderService; 32 private AppraiseOrderService appraiseOrderService;
25 33
26 @Autowired 34 @Autowired
@@ -54,7 +62,7 @@ public class ServiceOrderProcessor { @@ -54,7 +62,7 @@ public class ServiceOrderProcessor {
54 62
55 63
56 public IGoodsService findGoodsServiceInstance(long orderCode){ 64 public IGoodsService findGoodsServiceInstance(long orderCode){
57 - AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode); 65 + ExistenceNode existenceNode = isAppraiseOrder(orderCode);
58 if (!existenceNode.isExisted) { 66 if (!existenceNode.isExisted) {
59 logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode); 67 logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
60 throw new ServiceException(ServiceError.ORDER_NULL); 68 throw new ServiceException(ServiceError.ORDER_NULL);
@@ -63,4 +71,60 @@ public class ServiceOrderProcessor { @@ -63,4 +71,60 @@ public class ServiceOrderProcessor {
63 IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes()); 71 IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
64 return goodsService; 72 return goodsService;
65 } 73 }
  74 +
  75 +
  76 + public ExistenceNode findGoodsServiceInstanceAndExt(long orderCode){
  77 + ExistenceNode existenceNode = isAppraiseOrder(orderCode);
  78 + if (!existenceNode.isExisted) {
  79 + logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
  80 + throw new ServiceException(ServiceError.ORDER_NULL);
  81 + }
  82 + AppraiseOrder appraiseOrder = existenceNode.appraiseOrder;
  83 + IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
  84 + existenceNode.setGoodsService(goodsService);
  85 + return existenceNode;
  86 + }
  87 +
  88 + /**
  89 + * 是否付费鉴定 or 卖家寄存订单
  90 + * @param orderCode
  91 + * @return
  92 + */
  93 + public ExistenceNode isAppraiseOrder(long orderCode){
  94 + AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
  95 + boolean flag = Objects.nonNull(pao);
  96 + Integer aoac = flag ? pao.getAttributes() : null;
  97 + logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",
  98 + orderCode, aoac, flag);
  99 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
  100 + }
  101 +
  102 +
  103 +
  104 + /**
  105 + * 是否付费鉴定订单
  106 + * @param uid
  107 + * @param orderCode
  108 + * @return
  109 + */
  110 + public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){
  111 + AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
  112 + Integer aoac = null;
  113 + OrderAttributes oa = null;
  114 + boolean flag = Objects.nonNull(pao)
  115 + && Objects.nonNull(aoac=pao.getAttributes())
  116 + && Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))
  117 + && Objects.equals(oa, OrderAttributes.APPRAISE);
  118 + logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
  119 + uid, orderCode, aoac, oa, flag);
  120 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
  121 + }
  122 +
  123 + @Data
  124 + @Builder
  125 + public static class ExistenceNode{
  126 + boolean isExisted;
  127 + AppraiseOrder appraiseOrder;
  128 + IGoodsService goodsService;
  129 + }
66 } 130 }
@@ -21,7 +21,6 @@ import com.yohoufo.dal.order.AppraiseOrderMapper; @@ -21,7 +21,6 @@ import com.yohoufo.dal.order.AppraiseOrderMapper;
21 import com.yohoufo.dal.order.AppraiseOrderMetaMapper; 21 import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
22 import com.yohoufo.dal.order.AppraiseOrderStorageMapper; 22 import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
23 import com.yohoufo.dal.order.model.AppraiseOrder; 23 import com.yohoufo.dal.order.model.AppraiseOrder;
24 -import com.yohoufo.dal.order.model.AppraiseOrderGoods;  
25 import com.yohoufo.order.convert.SellerOrderConvertor; 24 import com.yohoufo.order.convert.SellerOrderConvertor;
26 import com.yohoufo.order.model.response.AppraiseAddressResp; 25 import com.yohoufo.order.model.response.AppraiseAddressResp;
27 import com.yohoufo.order.service.impl.AbsOrderViewService; 26 import com.yohoufo.order.service.impl.AbsOrderViewService;
@@ -31,7 +30,6 @@ import org.slf4j.Logger; @@ -31,7 +30,6 @@ import org.slf4j.Logger;
31 import org.springframework.beans.factory.annotation.Autowired; 30 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Service; 31 import org.springframework.stereotype.Service;
33 32
34 -import java.util.Arrays;  
35 import java.util.List; 33 import java.util.List;
36 34
37 @Service 35 @Service
@@ -93,8 +91,6 @@ public class SellerDepositOrderDetailService extends AbsOrderViewService { @@ -93,8 +91,6 @@ public class SellerDepositOrderDetailService extends AbsOrderViewService {
93 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode); 91 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
94 OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes()); 92 OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
95 93
96 - //todo use another page list query  
97 - List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCodes(Arrays.asList(orderCode));  
98 // 94 //
99 TimeoutBo timeout = calTimeout(TabType.BUY, uid, orderCode, pao.getStatus(), 95 TimeoutBo timeout = calTimeout(TabType.BUY, uid, orderCode, pao.getStatus(),
100 pao.getCreateTime(), oa); 96 pao.getCreateTime(), oa);
@@ -133,6 +129,7 @@ public class SellerDepositOrderDetailService extends AbsOrderViewService { @@ -133,6 +129,7 @@ public class SellerDepositOrderDetailService extends AbsOrderViewService {
133 .userAddress(userAddress) 129 .userAddress(userAddress)
134 .appraiseAddress(appraiseAddressInfo) 130 .appraiseAddress(appraiseAddressInfo)
135 .addressUpgradable(addressUpgradable) 131 .addressUpgradable(addressUpgradable)
  132 + .buttons(aos.detailButtons(oa))
136 .build() 133 .build()
137 ; 134 ;
138 } 135 }
@@ -11,6 +11,7 @@ import com.yohobuy.ufo.model.order.resp.SellerDepositOrderListResp; @@ -11,6 +11,7 @@ import com.yohobuy.ufo.model.order.resp.SellerDepositOrderListResp;
11 import com.yohobuy.ufo.model.order.vo.GoodsVo; 11 import com.yohobuy.ufo.model.order.vo.GoodsVo;
12 import com.yohobuy.ufo.model.order.vo.ProductVo; 12 import com.yohobuy.ufo.model.order.vo.ProductVo;
13 import com.yohoufo.common.helper.ImageUrlAssist; 13 import com.yohoufo.common.helper.ImageUrlAssist;
  14 +import com.yohoufo.common.utils.BigDecimalHelper;
14 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 15 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
15 import com.yohoufo.dal.order.AppraiseOrderMapper; 16 import com.yohoufo.dal.order.AppraiseOrderMapper;
16 import com.yohoufo.dal.order.AppraiseOrderMetaMapper; 17 import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
@@ -78,7 +79,6 @@ public class SellerDepositOrderListService { @@ -78,7 +79,6 @@ public class SellerDepositOrderListService {
78 List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList()); 79 List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
79 List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes); 80 List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
80 81
81 -  
82 Map<Long,List<AppraiseOrderGoods>> orderCodeAOGMap = new HashMap<>(paogs.size()); 82 Map<Long,List<AppraiseOrderGoods>> orderCodeAOGMap = new HashMap<>(paogs.size());
83 for (AppraiseOrderGoods paog : paogs){ 83 for (AppraiseOrderGoods paog : paogs){
84 long orderCode; 84 long orderCode;
@@ -120,6 +120,7 @@ public class SellerDepositOrderListService { @@ -120,6 +120,7 @@ public class SellerDepositOrderListService {
120 return SellerDepositOrderListResp.builder() 120 return SellerDepositOrderListResp.builder()
121 .uid(uid) 121 .uid(uid)
122 .orderCode(orderCode) 122 .orderCode(orderCode)
  123 + .earnestMoney(BigDecimalHelper.formatNumber(pao.getAmount(), BigDecimalHelper.FORMAT_TWOBITAFTERPOINT))
123 .status(status) 124 .status(status)
124 .statuStr(appraiseOrderStatus.statusStr(oa)) 125 .statuStr(appraiseOrderStatus.statusStr(oa))
125 .buttons(appraiseOrderStatus.listButtons(oa)) 126 .buttons(appraiseOrderStatus.listButtons(oa))
@@ -199,7 +200,7 @@ public class SellerDepositOrderListService { @@ -199,7 +200,7 @@ public class SellerDepositOrderListService {
199 Integer storageNum; 200 Integer storageNum;
200 BigDecimal emOfSku = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(storageNum=aos.getNum())); 201 BigDecimal emOfSku = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(storageNum=aos.getNum()));
201 GoodsVo goodsVo = GoodsVo.builder().sizeName(aos.getSizeName()).num(storageNum) 202 GoodsVo goodsVo = GoodsVo.builder().sizeName(aos.getSizeName()).num(storageNum)
202 - .earnestMoney(SellerOrderConvertor.formatFee(emOfSku)).build(); 203 + .earnestMoney(BigDecimalHelper.formatNumber(emOfSku, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT)).build();
203 goodsList.add(goodsVo); 204 goodsList.add(goodsVo);
204 } 205 }
205 206
1 package com.yohoufo.order.service.seller.deposit; 1 package com.yohoufo.order.service.seller.deposit;
2 2
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.error.ServiceError;
  5 +import com.yoho.error.exception.ServiceException;
  6 +import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
3 import com.yohobuy.ufo.model.order.common.OrderAttributes; 7 import com.yohobuy.ufo.model.order.common.OrderAttributes;
4 import com.yohobuy.ufo.model.order.common.OrderCodeType; 8 import com.yohobuy.ufo.model.order.common.OrderCodeType;
  9 +import com.yohobuy.ufo.model.order.common.Payment;
5 import com.yohobuy.ufo.model.order.req.*; 10 import com.yohobuy.ufo.model.order.req.*;
6 import com.yohobuy.ufo.model.order.resp.DepositOrderInStorePrdListResp; 11 import com.yohobuy.ufo.model.order.resp.DepositOrderInStorePrdListResp;
7 import com.yohobuy.ufo.model.order.resp.PageResp; 12 import com.yohobuy.ufo.model.order.resp.PageResp;
8 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp; 13 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp;
9 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp; 14 import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp;
  15 +import com.yohobuy.ufo.model.order.vo.AddressInfo;
10 import com.yohobuy.ufo.model.order.vo.GoodsVo; 16 import com.yohobuy.ufo.model.order.vo.GoodsVo;
11 import com.yohobuy.ufo.model.order.vo.ProductVo; 17 import com.yohobuy.ufo.model.order.vo.ProductVo;
  18 +import com.yohoufo.common.alarm.EventBusPublisher;
  19 +import com.yohoufo.common.exception.UfoServiceException;
  20 +import com.yohoufo.common.utils.AddressUtil;
  21 +import com.yohoufo.common.utils.BigDecimalHelper;
12 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 22 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
13 import com.yohoufo.dal.order.AppraiseOrderMapper; 23 import com.yohoufo.dal.order.AppraiseOrderMapper;
14 import com.yohoufo.dal.order.AppraiseOrderMetaMapper; 24 import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
15 import com.yohoufo.dal.order.AppraiseOrderStorageMapper; 25 import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
16 -import com.yohoufo.dal.order.model.AppraiseOrder;  
17 -import com.yohoufo.dal.order.model.AppraiseOrderGoods;  
18 -import com.yohoufo.dal.order.model.AppraiseOrderStorage; 26 +import com.yohoufo.dal.order.model.*;
19 import com.yohoufo.order.common.ClientType; 27 import com.yohoufo.order.common.ClientType;
20 -import com.yohoufo.order.convert.SellerOrderConvertor; 28 +import com.yohoufo.order.common.DelStatus;
  29 +import com.yohoufo.order.constants.MetaKey;
  30 +import com.yohoufo.order.event.BuyerCancelEvent;
  31 +import com.yohoufo.order.event.OrderCancelEvent;
  32 +import com.yohoufo.order.event.PayConfirmEvent;
  33 +import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
  34 +import com.yohoufo.order.model.PayQueryBo;
  35 +import com.yohoufo.order.model.dto.PlatformFeeDto;
21 import com.yohoufo.order.model.dto.SellerDepositOrderContext; 36 import com.yohoufo.order.model.dto.SellerDepositOrderContext;
22 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext; 37 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
23 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 38 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  39 +import com.yohoufo.order.mq.DelayTime;
  40 +import com.yohoufo.order.mq.TopicConstants;
  41 +import com.yohoufo.order.mq.producer.TradeMqSender;
  42 +import com.yohoufo.order.service.DepositService;
24 import com.yohoufo.order.service.IGoodsService; 43 import com.yohoufo.order.service.IGoodsService;
25 -import com.yohoufo.order.service.impl.AbsGoodsServiceOrderService;  
26 -import com.yohoufo.order.service.impl.AppraiseAddressService;  
27 -import com.yohoufo.order.service.impl.AppraiseOrderCreateService; 44 +import com.yohoufo.order.service.IPaymentService;
  45 +import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
  46 +import com.yohoufo.order.service.impl.*;
  47 +import com.yohoufo.order.service.pay.AbstractPayService;
28 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 48 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
  49 +import com.yohoufo.order.service.proxy.UserProxyService;
29 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 50 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
30 import com.yohoufo.order.utils.LoggerUtils; 51 import com.yohoufo.order.utils.LoggerUtils;
31 import org.slf4j.Logger; 52 import org.slf4j.Logger;
@@ -73,7 +94,14 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -73,7 +94,14 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
73 @Autowired 94 @Autowired
74 private OrderStatusFlowService orderStatusFlowService; 95 private OrderStatusFlowService orderStatusFlowService;
75 96
  97 + @Autowired
  98 + private DepositService depositService;
  99 +
  100 + @Autowired
  101 + private UserProxyService userProxyService;
76 102
  103 + @Autowired
  104 + private PayRefundService payRefundService;
77 105
78 106
79 107
@@ -84,7 +112,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -84,7 +112,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
84 SellerDepositOrderSupport.SummaryNode summaryNode = sdos.buildList(dtNode, 112 SellerDepositOrderSupport.SummaryNode summaryNode = sdos.buildList(dtNode,
85 SellerDepositOrderSupport.buildProductVoTypeRef(), 113 SellerDepositOrderSupport.buildProductVoTypeRef(),
86 SellerDepositOrderSupport.buildgoodsVoTypeRef()); 114 SellerDepositOrderSupport.buildgoodsVoTypeRef());
87 - String earnestMoneystr = SellerOrderConvertor.formatFee(summaryNode.earnestMoney); 115 + String earnestMoneystr = BigDecimalHelper.formatNumber(summaryNode.earnestMoney, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT);
88 String tips = "温馨提示:早支付早发货早寄存早上架早出售"; 116 String tips = "温馨提示:早支付早发货早寄存早上架早出售";
89 SellerDepositOrderComputeResp resp = SellerDepositOrderComputeResp.builder() 117 SellerDepositOrderComputeResp resp = SellerDepositOrderComputeResp.builder()
90 .earnestMoney(earnestMoneystr) 118 .earnestMoney(earnestMoneystr)
@@ -100,7 +128,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -100,7 +128,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
100 SellerDepositOrderPrepareService.DTNode dtNode = sellerDepositOrderPrepareService.checkAndAckquireBySku(req); 128 SellerDepositOrderPrepareService.DTNode dtNode = sellerDepositOrderPrepareService.checkAndAckquireBySku(req);
101 SellerOrderComputeResult socr = dtNode.getStorageIdSOCRMap().get(req.getStorageId()); 129 SellerOrderComputeResult socr = dtNode.getStorageIdSOCRMap().get(req.getStorageId());
102 BigDecimal total = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(req.getNum())); 130 BigDecimal total = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(req.getNum()));
103 - String earnestMoneystr = SellerOrderConvertor.formatFee(total); 131 + String earnestMoneystr = BigDecimalHelper.formatNumber(total, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT);
104 SellerDepositOrderComputeResp resp = SellerDepositOrderComputeResp.builder() 132 SellerDepositOrderComputeResp resp = SellerDepositOrderComputeResp.builder()
105 .earnestMoney(earnestMoneystr) 133 .earnestMoney(earnestMoneystr)
106 .build(); 134 .build();
@@ -156,18 +184,106 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -156,18 +184,106 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
156 return null; 184 return null;
157 } 185 }
158 186
  187 + @Autowired
  188 + private ServiceOrderProcessor serviceOrderProcessor;
159 189
  190 + @Autowired
  191 + IPaymentService paymentService;
160 192
161 public void cancel(SellerDepositOrderDetailReq req){ 193 public void cancel(SellerDepositOrderDetailReq req){
  194 + //TODO
  195 + long orderCode = req.getOrderCode();
  196 + if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
  197 + logger.warn("cancel AppraiseOrder not GoodsServiceOrder, orderCode {}", orderCode);
  198 + throw new UfoServiceException(400, "订单已迷路");
  199 + }
  200 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
  201 +
  202 + if (!existenceNode.isExisted()){
  203 + logger.warn("cancel AppraiseOrder not exist, orderCode {}", orderCode);
  204 + throw new UfoServiceException(400, "订单已迷路");
  205 + }
  206 + AppraiseOrder pao = existenceNode.getAppraiseOrder();
  207 +
  208 + OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
  209 + if (!OrderAttributes.DEPOSITE.equals(oa)){
  210 + logger.warn("cancel AppraiseOrder not deposit Order, orderCode {}", orderCode);
  211 + throw new UfoServiceException(400, "订单已迷路");
  212 + }
  213 +
  214 + AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
  215 + switch (appraiseOrderStatus){
  216 + case WAITING_PAY:
  217 + super.triggerStatusChange(orderCode, AppraiseOrderStatus.CANCEL_BEFORE_PAY, appraiseOrderStatus);
  218 + break;
  219 + case HAS_PAYED:
  220 + super.triggerStatusChange(orderCode, AppraiseOrderStatus.CANCEL_BEFORE_DELIVER, appraiseOrderStatus);
  221 + //refund amount
  222 + new GoodsServiceRefundHandler()
  223 + .loadLogger(logger)
  224 + .loadUser(pao.getUid())
  225 + .loadActionCase(SellerWalletDetail.Type.CANCEL_DELIVER)
  226 + .loadRefundAction(payRefundService::refund)
  227 + .loadOrder(orderCode, orderCode, pao.getPayment(), pao.getAmount())
  228 + .refund();
  229 +
  230 + break;
  231 + default:
  232 + throw new UfoServiceException(400, "订单不支持取消");
  233 + }
162 234
163 } 235 }
164 236
  237 + public int cancelByTimeout(OrderCancelEvent orderCancelEvent){
  238 + Long orderCode = orderCancelEvent.getOrderCode();
  239 + int uid = orderCancelEvent.getUid();
  240 + if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
  241 + logger.warn("auto cancel AppraiseOrder not GoodsServiceOrder, orderCode {}", orderCode);
  242 + throw new UfoServiceException(400, "订单已迷路");
  243 + }
  244 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
  245 +
  246 + if (!existenceNode.isExisted()){
  247 + logger.warn("auto cancel AppraiseOrder not exist, orderCode {}", orderCode);
  248 + throw new UfoServiceException(400, "订单已迷路");
  249 + }
  250 + AppraiseOrder pao = existenceNode.getAppraiseOrder();
  251 +
  252 + OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
  253 + if (!OrderAttributes.DEPOSITE.equals(oa)){
  254 + logger.warn("auto cancel AppraiseOrder not deposit Order, orderCode {}", orderCode);
  255 + throw new UfoServiceException(400, "订单已迷路");
  256 + }
  257 + AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
  258 + int rows = 0;
  259 + switch (appraiseOrderStatus){
  260 + case WAITING_PAY:
  261 + Payment payment = Payment.getPayment(pao.getPayment());
  262 + AbstractPayService payService = paymentService.getPayService(payment.getCode());
  263 + PayQueryBo payQueryBo = payService.payQuery(String.valueOf(orderCode), pao.getCreateTime());
  264 +
  265 + if (payQueryBo != null && payQueryBo.isPayStatus()){
  266 + logger.info("seller deposit order auto cancel failed, confirm paid. uid is {}, orderCode is {}", uid, orderCode);
  267 + PayConfirmEvent event = new PayConfirmEvent(uid, orderCode, pao.getPayment());
  268 + EventBusPublisher.publishEvent(event);
  269 + }
  270 + // 如果近1分钟有预支付记录,则发送 自动取消延迟消息
  271 + if ( !orderCancelEvent.isFinalRetry()){
  272 + paymentService.checkPrePay(uid, orderCode);
  273 + }
  274 + rows = super.triggerStatusChange(orderCode, AppraiseOrderStatus.CANCEL_TIMEOUT, appraiseOrderStatus);
  275 + break;
  276 + default:
  277 + throw new UfoServiceException(400, "订单不支持取消");
  278 + }
  279 +
  280 + return rows;
  281 + }
165 282
166 283
167 @Override 284 @Override
168 public int deliver2Depot(DeliverToDepotReq req) { 285 public int deliver2Depot(DeliverToDepotReq req) {
169 // 286 //
170 -  
171 int rows = super.deliver2Depot(req); 287 int rows = super.deliver2Depot(req);
172 if (rows==0){ 288 if (rows==0){
173 return rows; 289 return rows;
@@ -205,31 +321,248 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -205,31 +321,248 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
205 321
206 /** 322 /**
207 * 鉴定通过 323 * 鉴定通过
208 - * @param orderCode 324 + * @param pao
209 */ 325 */
210 @Override 326 @Override
211 - public int appraisePass(long orderCode){  
212 - int rows = super.appraisePass(orderCode); 327 + public int appraisePass(AppraiseOrder pao){
  328 + int rows = super.appraisePass(pao);
  329 + if (rows == 0){
  330 + return rows;
  331 + }
  332 + Long orderCode = pao.getOrderCode();
  333 + Long paidCode = pao.getParentOrderCode();
  334 +
  335 + BigDecimal left = calLeftMoney(pao.getAmount(), orderCode);
  336 + if (left.compareTo(BigDecimal.ZERO)>0){
  337 +
  338 + //refund amount
  339 + new GoodsServiceRefundHandler()
  340 + .loadLogger(logger)
  341 + .loadUser(pao.getUid())
  342 + .loadActionCase(SellerWalletDetail.Type.APPRAISE_OK)
  343 + .loadRefundAction(payRefundService::refund)
  344 + .loadOrder(orderCode, paidCode, pao.getPayment(), left)
  345 + .refund();
  346 + }
  347 +
213 return rows; 348 return rows;
214 } 349 }
215 350
216 /** 351 /**
217 - * 鉴别为假 352 + * 完好正品 仓储费:10元/45天 鉴定费:15元 包装费:6元 剩余保证金退回
  353 + * @param amount
218 * @param orderCode 354 * @param orderCode
  355 + * @return
  356 + */
  357 + private BigDecimal calLeftMoney(BigDecimal amount, Long orderCode){
  358 + AppraiseOrderMeta feeCondition = new AppraiseOrderMeta();
  359 + feeCondition.setOrderCode(orderCode);
  360 + feeCondition.setMetaKey(MetaKey.SELLER_FEE);
  361 + BigDecimal totalOfPlatform = new BigDecimal(35);
  362 + try {
  363 + AppraiseOrderMeta feeMeta = appraiseOrderMetaMapper.selectByOrderCode(feeCondition);
  364 + SellerOrderComputeResult socr = JSONObject.parseObject(feeMeta.getMetaValue(), SellerOrderComputeResult.class);
  365 + PlatformFeeDto platformFeeDto = socr.getPlatformFee();
  366 + totalOfPlatform = platformFeeDto.getTotal();
  367 + }catch (Exception ex){
  368 + logger.warn("calLeftMoney 4 seller deposit order fail use default totalOfPlatform {} orderCode {}", totalOfPlatform, orderCode, ex);
  369 + }
  370 + if (totalOfPlatform.compareTo(BigDecimal.ZERO)<0){
  371 + totalOfPlatform = BigDecimal.ZERO;
  372 + }
  373 + BigDecimal left = amount.subtract(totalOfPlatform);
  374 + if (left.compareTo(BigDecimal.ZERO) <= 0){
  375 + left = BigDecimal.ZERO;
  376 + }else {
  377 + //format
  378 + left = BigDecimalHelper.halfUp(left);
  379 + }
  380 + logger.info("calLeftMoney 4 seller deposit order,orderCode {} ,amount {}, totalOfPlatform {}, left {}",
  381 + orderCode, amount, totalOfPlatform, left);
  382 + return left;
  383 + }
  384 +
  385 + /**
  386 + * 鉴别为假
  387 + * @param appraiseOrder
219 */ 388 */
220 @Override 389 @Override
221 - public int appraiseFake(long orderCode){  
222 - int rows = super.appraiseFake(orderCode); 390 + public int appraiseFake(AppraiseOrder appraiseOrder){
  391 + int rows = super.appraiseFake(appraiseOrder);
  392 + if (rows == 0){
  393 + return rows;
  394 + }
  395 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
223 return rows; 396 return rows;
224 } 397 }
225 398
226 /** 399 /**
227 * 无法鉴别 400 * 无法鉴别
228 - * @param orderCode 401 + * @param appraiseOrder
229 */ 402 */
230 @Override 403 @Override
231 - public int unsure(long orderCode){  
232 - int rows = super.unsure(orderCode); 404 + public int unsure(AppraiseOrder appraiseOrder){
  405 + int rows = super.unsure(appraiseOrder);
  406 + if (rows == 0){
  407 + return rows;
  408 + }
  409 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
  410 + return rows;
  411 + }
  412 +
  413 + /**
  414 + * 确认收货环节发现少件,取消订单保证金原路退回
  415 + * @param appraiseOrder
  416 + * @return
  417 + */
  418 + @Override
  419 + public int shamDeliver(AppraiseOrder appraiseOrder){
  420 + int rows = super.shamDeliver(appraiseOrder);
  421 + if (rows == 0){
  422 + return rows;
  423 + }
  424 + //refund amount
  425 + new GoodsServiceRefundHandler()
  426 + .loadLogger(logger)
  427 + .loadUser(appraiseOrder.getUid())
  428 + .loadActionCase(SellerWalletDetail.Type.SELLER_SHAM_SEND_OUT)
  429 + .loadRefundAction(payRefundService::refund)
  430 + .loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
  431 + .refund();
  432 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
233 return rows; 433 return rows;
234 } 434 }
  435 +
  436 +
  437 + public void addOrModifyAddress(int uid, Long orderCode, String addressIdstr) {
  438 + int addressId = AddressUtil.getDecryptStr(addressIdstr);
  439 + if (addressId < 0){
  440 + logger.warn("addOrModifyAddress addressId invalidate, uid {}, orderCode {}, addressId is {}",
  441 + uid, orderCode, addressIdstr);
  442 + throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
  443 + }
  444 + AppraiseOrder pbo = appraiseOrderMapper.selectByOrderCode(orderCode);
  445 + if (pbo == null ){
  446 + logger.warn("in addOrModifyAddress AppraiseOrder is null,uid {} orderCode {} addressIdstr {}",
  447 + uid, orderCode, addressIdstr);
  448 + return;
  449 + }
  450 + Integer oa;
  451 + if (OrderAttributes.DEPOSITE.getCode() != (oa=pbo.getAttributes())){
  452 + logger.warn("in addOrModifyAddress AppraiseOrder.Attributes is {},uid {} orderCode {} addressIdstr {}",
  453 + oa, uid, orderCode, addressIdstr);
  454 + return;
  455 + }
  456 + MetaAddressService.ActionCallBack<AppraiseOrderMeta> callBack = new MetaAddressService.ActionCallBack<AppraiseOrderMeta>() {
  457 + @Override
  458 + public List<AppraiseOrderMeta> selectByMetaKeys(int uid, long orderCode, List<String> metaKeys) {
  459 + List<AppraiseOrderMeta> pboms = appraiseOrderMetaMapper.selectByOrderCodeMetaKeys(orderCode, metaKeys);
  460 + return pboms;
  461 + }
  462 +
  463 + @Override
  464 + public void insertBatch(List<AppraiseOrderMeta> list) {
  465 + appraiseOrderMetaMapper.insertBatch(list);
  466 + }
  467 +
  468 + @Override
  469 + public void insert(AppraiseOrderMeta appraiseOrderMeta) {
  470 + appraiseOrderMetaMapper.insert(appraiseOrderMeta);
  471 + }
  472 +
  473 + @Override
  474 + public void updateMetaVal(AppraiseOrderMeta appraiseOrderMeta) {
  475 + appraiseOrderMetaMapper.updateMetaValueByOrderCodeAndMetaKey(appraiseOrderMeta);
  476 + }
  477 +
  478 + @Override
  479 + public AddressInfo hiddenBackAddress(int uid, int addressId) {
  480 + return userProxyService.getHiddenAddressInfo(uid, addressId);
  481 + }
  482 +
  483 + @Override
  484 + public AddressInfo noHiddenBackAddress(int uid, int addressId) {
  485 + return userProxyService.getAddressInfoNotHidden(uid, addressId);
  486 + }
  487 +
  488 + @Override
  489 + public AppraiseOrderMeta buildnoHiddenAddressMeta(int uid, long orderCode, String key, AddressInfo noHiddenBackAddress) {
  490 + AppraiseOrderMeta noHiddenAddressMeta = new AppraiseOrderMeta();
  491 + noHiddenAddressMeta.setUid(uid);
  492 + noHiddenAddressMeta.setOrderCode(orderCode);
  493 + noHiddenAddressMeta.setMetaKey(key);
  494 + noHiddenAddressMeta.setMetaValue(JSONObject.toJSONString(noHiddenBackAddress));
  495 + return noHiddenAddressMeta;
  496 + }
  497 +
  498 + @Override
  499 + public AppraiseOrderMeta buildHiddenAddressMeta(int uid, long orderCode, String hiddenKey, AddressInfo hiddenBackAddress) {
  500 + AppraiseOrderMeta hiddenAddressMeta=new AppraiseOrderMeta();
  501 + hiddenAddressMeta.setUid(uid);
  502 + hiddenAddressMeta.setOrderCode(orderCode);
  503 + hiddenAddressMeta.setMetaKey(hiddenKey);
  504 + hiddenAddressMeta.setMetaValue(JSONObject.toJSONString(hiddenBackAddress));
  505 + return hiddenAddressMeta;
  506 + }
  507 +
  508 + @Override
  509 + public boolean hitHidden(AppraiseOrderMeta appraiseOrderMeta, String hidden_key) {
  510 + return appraiseOrderMeta.getMetaKey().equals(hidden_key);
  511 + }
  512 +
  513 + @Override
  514 + public boolean hitNoHidden(AppraiseOrderMeta appraiseOrderMeta, String noHiddenKey) {
  515 + return appraiseOrderMeta.getMetaKey().equals(noHiddenKey);
  516 + }
  517 + };
  518 + new MetaAddressService().modifyAddressOfDepositOrder(uid, orderCode, addressIdstr, callBack);
  519 +
  520 + }
  521 +
  522 + public int deleteVisuable(int uid, long orderCode){
  523 + logger.info("in delete deposit order Visuable uid {} orderCode {}", uid, orderCode);
  524 + AppraiseOrder condition = new AppraiseOrder();
  525 + condition.setOrderCode(orderCode);
  526 + condition.setIsDel(DelStatus.IS_DEL.getCode());
  527 + int rows = appraiseOrderMapper.updateByOrderCode(condition);
  528 + logger.info("in delete deposit order Visuable uid {} orderCode {} rows {}", uid, orderCode, rows);
  529 + return rows;
  530 + }
  531 +
  532 + /**
  533 + * 瑕疵
  534 + * 退回对应保证金至卖家账户
  535 + * @param appraiseOrder
  536 + * @return
  537 + */
  538 + public int findFlaw(AppraiseOrder appraiseOrder){
  539 + int rows = super.findFlaw(appraiseOrder);
  540 + if (rows == 0){
  541 + return rows;
  542 + }
  543 + new GoodsServiceRefundHandler()
  544 + .loadLogger(logger)
  545 + .loadUser(appraiseOrder.getUid())
  546 + .loadActionCase(SellerWalletDetail.Type.FLAW)
  547 + .loadRefundAction(payRefundService::refund)
  548 + .loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
  549 + .refund();
  550 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
  551 + return rows;
  552 + }
  553 +
  554 + @Autowired
  555 + private TradeMqSender tradeMqSender;
  556 +
  557 + public boolean handleOrderCancelAsyncEvent(SellerDepositOrderCancelAsyncEvent event) {
  558 + logger.info("Subscribe Buyer timeout cancel delay msg, event {}", event);
  559 + OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder()
  560 + .uid(event.getUid())
  561 + .orderCode(event.getOrderCode())
  562 + .payExpire(DelayTime.SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT)
  563 + .build();
  564 + tradeMqSender.send(TopicConstants.SELLER_DEPOSIT_ORDER_AUTO_CANCEL, orderCancelEvent, DelayTime.SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT);
  565 + return true;
  566 + }
  567 +
235 } 568 }
@@ -55,6 +55,12 @@ public class QuickDeliverPublishProcessor implements PublishProcessor<QuickDeliv @@ -55,6 +55,12 @@ public class QuickDeliverPublishProcessor implements PublishProcessor<QuickDeliv
55 .num(num=qdosr.getNum()) 55 .num(num=qdosr.getNum())
56 .price(qdosr.getPrice()).skupType(qdosr.getSkupTypeCode()).build(); 56 .price(qdosr.getPrice()).skupType(qdosr.getSkupTypeCode()).build();
57 PriceComputePrepareProcessor.PriceComputeNode icpNode = priceComputePrepareProcessor.checkAndAcquire(socr); 57 PriceComputePrepareProcessor.PriceComputeNode icpNode = priceComputePrepareProcessor.checkAndAcquire(socr);
  58 + if (num>10){
  59 + logger.warn("in buildSellerOrderContext storageId num over limit , qdosr {}", qdosr);
  60 + throw new UfoServiceException(400, "上架数目不能超过10个");
  61 + }
  62 +
  63 +
58 BigDecimal salePrice = icpNode.getSalePrice(); 64 BigDecimal salePrice = icpNode.getSalePrice();
59 SkupType skupType = icpNode.getSkupType(); 65 SkupType skupType = icpNode.getSkupType();
60 //step 1: rpc get product detail by storage id 66 //step 1: rpc get product detail by storage id