Authored by mali

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

... ... @@ -4,7 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.message.sdk.service.ufo.UFOBidMessageService;
import com.yoho.message.sdk.common.constants.UFOMessageScene;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -16,15 +17,12 @@ import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.event.BuyerOrderUnpaidDelayReminderEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.proxy.BuyerNoticeFacade;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import static com.yoho.message.sdk.service.ufo.UFOBidMessageService.Scene.*;
import java.util.LinkedHashMap;
@Component
public class BuyerOrderUnpaidReminderDelayMsgConsumer implements YhConsumer {
... ... @@ -44,7 +42,7 @@ public class BuyerOrderUnpaidReminderDelayMsgConsumer implements YhConsumer {
protected ProductMapper productMapper;
@Autowired
protected UFOBidMessageService ufoBidMessageService;
protected BuyerNoticeFacade buyerNoticeFacade;
public String getTopic() {
... ... @@ -89,13 +87,17 @@ public class BuyerOrderUnpaidReminderDelayMsgConsumer implements YhConsumer {
Product product = findProduct(sellerOrderGoods);
String productCode = product.getProductCode();
Map<String, Object> parameters = new HashMap<>();
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
parameters.put("productName", prdName);
parameters.put("sizeName", sizeName);
parameters.put("productCode", productCode);
parameters.put("remainingHour", remainingHour);
parameters.put("orderCode", buyerOrder.getOrderCode());
ufoBidMessageService.sendMessage(String.valueOf(buyerOrder.getUid()), UFO_BUYER_BID_PAY_REMINDER, parameters);
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.BUYER_BID_PAY_REMINDER,
InboxBusinessTypeEnum.SMS_BUYER_BID_PAY_REMINDER,
UFOMessageScene.UFO_BUYER_BID_PAY_REMINDER,
parameters);
}
protected SellerOrderGoods findSellerOrderGoods(BuyerOrder buyerOrder) {
... ...
... ... @@ -2,7 +2,6 @@ package com.yohoufo.order.service;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.message.sdk.service.ufo.UFOBidMessageService;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.common.alarm.EventBusPublisher;
... ... @@ -23,6 +22,7 @@ import com.yohoufo.order.model.bo.BidOrderMetaBo;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
import com.yohoufo.order.service.proxy.BidProductProxyService;
import com.yohoufo.order.service.proxy.BuyerNoticeFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.support.BuyerOrderMetaMapperSupport;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -91,7 +91,7 @@ public abstract class AbstractBuyerOrderStateChanger<T extends RequestedStatusCh
protected ProductMapper productMapper;
@Autowired
protected UFOBidMessageService ufoBidMessageService;
protected BuyerNoticeFacade buyerNoticeFacade;
/**
* 变更
... ...
package com.yohoufo.order.service.impl.statechange;
import com.google.common.collect.Lists;
import com.yoho.message.sdk.service.ufo.UFOBidMessageService;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
... ... @@ -16,10 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.LinkedHashMap;
import static com.yoho.message.sdk.service.ufo.UFOBidMessageService.Scene.*;
import static com.yoho.message.sdk.common.constants.UFOMessageScene.*;
import static com.yohobuy.ufo.model.order.common.OrderStatus.*;
import static com.yohoufo.order.common.RefundCase.SELLER_EARNEST_MONEY;
... ... @@ -93,29 +92,26 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
Product product = findProduct(sellerOrderGoods);
String productCode = product.getProductCode();
Map<String, Object> parameters = new HashMap<>();
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
parameters.put("productName", prdName);
parameters.put("sizeName", sizeName);
parameters.put("productCode", productCode);
parameters.put("orderCode", buyerOrder.getOrderCode());
UFOBidMessageService.Scene scene;
switch (targetStatus) {
case BUYER_CLOSE_BID:
scene = UFO_BUYER_CLOSE_BID;
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.BUYER_CLOSE_BID, null, null, parameters);
break;
case SYSTEM_CLOSE_BID:
scene = UFO_SYSTEM_CLOSE_BID;
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.SYSTEM_CLOSE_BID, InboxBusinessTypeEnum.SMS_SYSTEM_CLOSE_BID, UFO_SYSTEM_CLOSE_BID, parameters);
break;
case PLATFORM_CLOSE_BID:
scene = UFO_PLATFORM_CLOSE_BID;
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.PLATFORM_CLOSE_BID, InboxBusinessTypeEnum.SMS_PLATFORM_CLOSE_BID, UFO_PLATFORM_CLOSE_BID, parameters);
break;
default:
scene = null;
break;
}
ufoBidMessageService.sendMessage(String.valueOf(buyerOrder.getUid()), scene, parameters);
}
}
... ...
package com.yohoufo.order.service.impl.statechange;
import com.google.common.collect.Lists;
import com.yoho.message.sdk.common.constants.UFOMessageScene;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -16,10 +18,7 @@ import com.yohoufo.order.service.AbstractBuyerOrderStateChanger;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static com.yoho.message.sdk.service.ufo.UFOBidMessageService.Scene.*;
import java.util.LinkedHashMap;
import static com.yohobuy.ufo.model.order.common.OrderStatus.*;
@Service
... ... @@ -89,13 +88,15 @@ public class BuyerOrderBidingToWaitingPayChanger extends AbstractBuyerOrderState
String productCode = product.getProductCode();
Map<String, Object> parameters = new HashMap<>();
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
parameters.put("productName", prdName);
parameters.put("sizeName", sizeName);
parameters.put("productCode", productCode);
parameters.put("goodsPrice", sellerOrderGoods.getGoodsPrice().toPlainString());
parameters.put("orderCode", buyerOrder.getOrderCode());
ufoBidMessageService.sendMessage(String.valueOf(buyerOrder.getUid()), UFO_BID_SUCCESS, parameters);
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.BID_SUCCESS,
InboxBusinessTypeEnum.SMS_BID_SUCCESS,
UFOMessageScene.UFO_BID_SUCCESS,parameters);
}
}
... ...
package com.yohoufo.order.service.impl.statechange;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.ChangePriceStatus;
import com.yohoufo.common.alarm.EventBusPublisher;
... ... @@ -19,11 +20,9 @@ import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.impl.BuyerChangePriceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import static com.yoho.message.sdk.service.ufo.UFOBidMessageService.Scene.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.LinkedHashMap;
/**
* 支付定金完成
... ... @@ -120,10 +119,10 @@ public class BuyerOrderPayDepositSuccessChanger extends AbstractBuyerOrderStateC
Product product = findProduct(sellerOrderGoods);
String productCode = product.getProductCode();
Map<String, Object> parameters = new HashMap<>();
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
parameters.put("productName", prdName);
parameters.put("sizeName", sizeName);
parameters.put("productCode", productCode);
ufoBidMessageService.sendMessage(String.valueOf(uid), UFO_BUYER_DEPOSIT_PAY_FINISHED, parameters);
buyerNoticeFacade.messageNotice(uid, InboxBusinessTypeEnum.BUYER_DEPOSIT_PAY_FINISHED, null, null, parameters);
}
}
... ...
... ... @@ -3,7 +3,8 @@ package com.yohoufo.order.service.impl.statechange;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.message.sdk.service.ufo.UFOBidMessageService;
import com.yoho.message.sdk.common.constants.UFOMessageScene;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.Payment;
... ... @@ -36,13 +37,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import static com.yoho.message.sdk.service.ufo.UFOBidMessageService.Scene.*;
import static com.yohobuy.ufo.model.order.common.OrderStatus.*;
/**
... ... @@ -175,6 +172,7 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh
/**
* 退还卖家的保证金
*
* @param skup
* @param buyerOrder
* @param targetOrderStatus
... ... @@ -262,26 +260,26 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh
Product product = findProduct(sellerOrderGoods);
String productCode = product.getProductCode();
Map<String, Object> parameters = new HashMap<>();
LinkedHashMap<String, Object> parameters = new LinkedHashMap<>();
parameters.put("productName", prdName);
parameters.put("sizeName", sizeName);
parameters.put("productCode", productCode);
parameters.put("goodsPrice", sellerOrderGoods.getGoodsPrice().toPlainString());
parameters.put("orderCode", buyerOrder.getOrderCode());
UFOBidMessageService.Scene scene;
switch (targetStatus) {
case BUYER_BID_CANCEL_PAY:
scene = UFO_BUYER_BID_CANCEL_PAY;
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.BUYER_BID_CANCEL_PAY,
InboxBusinessTypeEnum.SMS_BUYER_BID_CANCEL_PAY,
null, parameters);
break;
case BUYER_BID_PAY_TIMEOUT:
scene = UFO_BUYER_BID_PAY_TIMEOUT;
buyerNoticeFacade.messageNotice(buyerOrder.getUid(), InboxBusinessTypeEnum.BUYER_BID_PAY_TIMEOUT,
InboxBusinessTypeEnum.SMS_BUYER_BID_PAY_TIMEOUT,
UFOMessageScene.UFO_BUYER_BID_PAY_TIMEOUT, parameters);
break;
default:
scene = null;
break;
}
ufoBidMessageService.sendMessage(String.valueOf(buyerOrder.getUid()), scene, parameters);
}
}
\ No newline at end of file
... ...
... ... @@ -20,9 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
... ... @@ -118,6 +116,13 @@ public class BaseNoticeFacade {
return this;
}
public Notice withSmsIf(boolean condition, Supplier<String> smsContentSupplier) {
if (condition) {
this.smsContentSupplier = smsContentSupplier;
}
return this;
}
public Notice withPush(Supplier<SendMessageRspBo> pushSupplier) {
this.pushSupplier = pushSupplier;
return this;
... ...
package com.yohoufo.order.service.proxy;
import com.yoho.message.sdk.common.constants.UFOMessageScene;
import com.yoho.message.sdk.service.ufo.IUFOSendService;
import com.yoho.message.sdk.service.ufo.UFOBidMessageService;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.dal.order.model.BuyerOrder;
... ... @@ -13,6 +15,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
... ... @@ -27,11 +30,13 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
@Autowired
private ProductMapper productMapper;
@Autowired
private UFOBidMessageService ufoBidMessageService;
@Override
public Logger getLogger() {
return log;
}
/**
* 买家订单未付款
*
... ... @@ -456,4 +461,24 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
// }
// }
/**
*
* @param buyerUid
* @param inbox
* @param sms
* @param push
* @param parameters 保持顺序
*/
public void messageNotice(int buyerUid, InboxBusinessTypeEnum inbox, InboxBusinessTypeEnum sms, UFOMessageScene push, LinkedHashMap<String, Object> parameters) {
log.info("[{}] Buyer Message Notice,inbox:{},sms:{},push:{}", buyerUid, inbox, sms, push);
Object[] params = parameters.values().toArray(new Object[0]);
newNotice(buyerUid)
.withLogPrefix("Buyer Message Notice")
.withInBox(() -> buildInboxContent(inbox, parameters.values().toArray(new Object[0])))
.withSmsIf(sms != null, () -> buildSmsContent(sms, params))
.withPushIf(push != null, () -> ufoBidMessageService.sendMessage(String.valueOf(buyerUid), push, parameters))
.send();
}
}
... ...
... ... @@ -4,6 +4,8 @@ import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.model.RequestedCancelEventStatusChangeBuyerOrder;
import com.yohoufo.order.service.BuyerOrderStateChangers;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
... ... @@ -43,8 +45,21 @@ public class BuyerBidOrderServiceTest extends BaseWebTest {
@Test
public void test_buyer_close_bid() throws Exception {
long orderCode = 10019449511744L;
long orderCode = 10029406388043L;
buyerOrderStateChangers.selectOneToChange(uid, orderCode,OrderStatus.BIDING,OrderStatus.BUYER_CLOSE_BID);
TimeUnit.SECONDS.sleep(100);
}
@Test
public void test_buyer_pay_timeout() throws Exception {
long orderCode = 10029406388043L;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
RequestedCancelEventStatusChangeBuyerOrder statusChangeBuyerOrder = new RequestedCancelEventStatusChangeBuyerOrder(buyerOrder,
OrderStatus.WAITING_PAY,
OrderStatus.BUYER_BID_PAY_TIMEOUT,
Operator.SYSTEM,
null);
buyerOrderStateChangers.selectOneToChange(statusChangeBuyerOrder);
TimeUnit.SECONDS.sleep(100);
}
}
... ...