Authored by chenchao

add seller cache because batch no

... ... @@ -109,7 +109,8 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderInfo.getOrderCode()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderInfo.getOrderCode())));
}
... ...
... ... @@ -93,14 +93,16 @@ public class SellerOrderPaymentService extends AbstractOrderPaymentService {
String prdName = null;
int sellerUid;
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCode(orderInfo.getOrderCode());
SellerOrderGoods sellerOrderGoods = null;
if (Objects.nonNull(sellerOrder)){
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
prdName = sellerOrderGoods.getProductName();
}
inBoxFacade.sellerPaidEarnestMoney(sellerUid=orderInfo.getUid(), prdName);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderInfo.getOrderCode())
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), sellerOrder.getOrderCode())
));
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yoho.core.redis.cluster.annotation.Redis;
import com.yoho.core.redis.cluster.operations.nosync.YHRedisTemplate;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
... ... @@ -35,6 +36,12 @@ public class CacheCleaner {
delete(keyBuilders);
}
public void cleanSellerDetail(SellerOrderGoods sog){
RedisKeyBuilder detailKB = CacheKeyBuilder.sellerOrderDetailKey(sog);
List<RedisKeyBuilder> keyBuilders = Lists.newArrayList(detailKB);
delete(keyBuilders);
}
/**
* 批量删除key
* @param keyBuilders
... ...
package com.yohoufo.order.service.cache;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import org.slf4j.helpers.MessageFormatter;
import java.math.BigDecimal;
import java.util.Objects;
/**
* Created by chenchao on 2018/10/16.
*/
... ... @@ -40,8 +45,9 @@ public class CacheKeyBuilder {
ORDER_LIST("ufo:order:orderList:","uid:{}:tabType:{}"),
ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:orderCode:{}");
ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:orderCode:{}"),
SELLER_ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:batchNo:{}:price{}:status{}");
private String fix;
private String placeHolder;
... ... @@ -79,6 +85,18 @@ public class CacheKeyBuilder {
return PatternKeyTemplate.ORDER_LIST_COUNT.getKeyPattern();
}
public static RedisKeyBuilder sellerOrderDetailKey(SellerOrderGoods sog){
if (Objects.isNull(sog)){
return null;
}
String actor = TabType.SELL.getValue();
int uid = sog.getUid();
long batchNo = sog.getBatchNo();
BigDecimal price = sog.getGoodsPrice();
Integer status = sog.getStatus();
return KeyTemp.SELLER_ORDER_DETAIL.builderKey(new Object[]{uid, actor, batchNo, price, status});
}
public static RedisKeyBuilder orderDetailKey(int uid, String actor, long orderCode){
return KeyTemp.ORDER_DETAIL.builderKey(new Object[]{uid, actor, orderCode});
... ...
... ... @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.common.cache.CacheClient;
import com.yohoufo.common.cache.SnappyZipUtils;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
import org.apache.commons.lang3.StringUtils;
... ... @@ -77,6 +78,19 @@ public class OrderCacheService {
}
}
public void cacheSellerOrderDetailInfo(SellerOrderGoods sog, OrderDetailInfo orderDetailInfo){
RedisKeyBuilder kb = CacheKeyBuilder.sellerOrderDetailKey(sog);
cacheClient.set(kb.getKey(), ExpiredTime.ORDER_DETAIL , orderDetailInfo);
logger.info("put seller OrderDetail cache ,info {}", sog);
}
public OrderDetailInfo getSellerOrderDetailInfo(SellerOrderGoods sog){
RedisKeyBuilder kb = CacheKeyBuilder.sellerOrderDetailKey(sog);
logger.info("get seller OrderDetail cache ,info {}", sog);
OrderDetailInfo orderDetailInfo = cacheClient.get(kb.getKey(), OrderDetailInfo.class);
return orderDetailInfo;
}
public void cacheOrderDetailInfo(int uid, long orderCode,TabType actor, OrderDetailInfo orderDetailInfo){
RedisKeyBuilder kb = CacheKeyBuilder.orderDetailKey(uid, actor.getValue(), orderCode);
... ...
... ... @@ -162,6 +162,8 @@ public class AppraiseService {
.buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
.payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
.skup(skup);
SellerOrderGoods sellerOrderGoods;
sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
try {
payRefundService.refund(req, bleb);
//通知卖家退还保证金
... ... @@ -170,7 +172,7 @@ public class AppraiseService {
//记录物流信息
expressInfoService.appraiseSuccess(buyerUid, expressCompanyId, orderCode, wayBillCode, depotNum);
//平台已发货给买家
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
inBoxFacade.depotDeliver2Buyer(buyerUid, orderCode,sellerOrderGoods.getProductName());
}catch (Exception ex){
LOGGER.warn("in appraiseSuccess,refund fail, req {}", req, ex);
... ... @@ -188,6 +190,7 @@ public class AppraiseService {
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode)));
... ... @@ -285,9 +288,10 @@ public class AppraiseService {
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
tso.setExceptStatus(expectSOStatus.getCode());
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
... ... @@ -324,7 +328,7 @@ public class AppraiseService {
try{
payRefundService.refund(req, bleb);
//
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
inBoxFacade.noticeSellerWhenAppraiseFail(sellerUid, sellerOrderGoods.getProductName());
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
}catch (Exception ex){
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.OrderCouponMapper;
... ... @@ -21,6 +22,8 @@ import com.yohoufo.order.model.bo.CouponBo;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.request.TransferMoneyRequest;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
import com.yohoufo.order.service.proxy.CouponProxyService;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -30,6 +33,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
... ... @@ -65,18 +69,24 @@ public class BuyerOrderCancelService {
@Autowired
private PayRefundService payRefundService;
@Autowired
private CacheCleaner cacheCleaner;
public void cancel(BeforeSellerDeliverEvent bsdEvent){
OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN();
logger.info("in buyer cancel BeforeSellerDeliver, event {} compensate {}", bsdEvent, compensate);
int buyerUid = bsdEvent.getBuyerUid();
int sellerUid = bsdEvent.getSellerUid();
long orderCode = bsdEvent.getOrderCode();
OrderStatus target = bsdEvent.getTarget();
OrderStatus expected = bsdEvent.getExpected();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
if (rows>0) {
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
int skup = bsdEvent.getSkup();
SellerOrderGoods targetGoods = new SellerOrderGoods();
targetGoods.setId(skup);
... ... @@ -92,7 +102,12 @@ public class BuyerOrderCancelService {
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
compensate, transferCase);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
logger.info("use one thread to execute buyer cancel BeforeSellerDeliver buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, compensate, transferCase);
}
... ... @@ -106,10 +121,14 @@ public class BuyerOrderCancelService {
OrderStatus target = bdrEvent.getTarget();
OrderStatus expected = bdrEvent.getExpected();
int buyerUid = bdrEvent.getBuyerUid();
int sellerUid = bdrEvent.getSellerUid();
long orderCode = bdrEvent.getOrderCode();
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
if (rows>0) {
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
int skup = bdrEvent.getSkup();
SellerOrderGoods targetGoods = new SellerOrderGoods();
targetGoods.setId(skup);
... ... @@ -125,7 +144,12 @@ public class BuyerOrderCancelService {
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
compensate, transferCase);
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
logger.info("use one thread to execute buyer cancel BeforeDepotReceive buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, compensate, transferCase);
}
... ...
... ... @@ -93,9 +93,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
expectStatus.getCode(),
OrderStatus.DONE.getCode(),
DateUtil.getCurrentTimeSecond())) {
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sog = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode)));
} else {
... ... @@ -141,8 +144,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
case WAITING_PAY:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_PAY;
cancelBeforePaid(orderRequest, node, expectStatus, targetStatus);
//退还优惠券
buyerOrderCancelService.refundCouponIfNeed(orderRequest.getUid(),orderRequest.getOrderCode());
break;
case HAS_PAYED:
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(orderRequest.getUid(),
... ... @@ -167,8 +168,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
.expected(expectStatus).target(targetStatus).skup(skup).sellerUid(buyerOrder.getSellerUid())
.build();
buyerOrderCancelService.cancel(bdre);
//退还优惠券
buyerOrderCancelService.refundCouponIfNeed(orderRequest.getUid(),orderRequest.getOrderCode());
break;
}
... ... @@ -200,8 +199,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
tsog.setStatus(SkupStatus.CAN_SELL.getCode());
sellerOrderGoodsMapper.updateByPrimaryKeySelective(tsog);
// 恢复product skup的库存
boolean isReturnSuccess = productProxyService.returnStorage(skup);
//
... ... @@ -212,6 +209,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
//
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
... ... @@ -371,10 +369,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
int sellerUid = buyerOrder.getSellerUid();
buyerOrderMapper.updateStatusByOrderCode(orderCode, uid, expectStatus.getCode(),
targetStatus.getCode(), DateUtil.getCurrentTimeSecond());
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(uid, orderCode);
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(bog.getSkup());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode)));
}
... ...
... ... @@ -117,12 +117,13 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
//根据skup ,更新鉴定中心
int skup;
SellerOrderGoods sellerOrderGoods=new SellerOrderGoods();
sellerOrderGoods.setId(buyerOrderGoods.getSkup());
sellerOrderGoods.setId(skup=buyerOrderGoods.getSkup());
sellerOrderGoods.setDepotNo(depotNum);
sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods);
productProxyService.setDepotNum(buyerOrderGoods.getSkup(),depotNum);
productProxyService.setDepotNum(skup,depotNum);
// 更新买家订单状态
int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerOrder.getUid(),
... ... @@ -139,10 +140,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
LOGGER.info("deliverToDepot update buyer order status result {} ",updateBuyerCnt);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
//
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode)));
}
... ...
... ... @@ -241,7 +241,8 @@ public class SellerOrderCancelService {
}
cacheCleaner.cleanList(uid, TabType.SELL.getValue());
cacheCleaner.cleanDetail(uid, orderCode, TabType.SELL);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
cacheCleaner.cleanSellerDetail(psog);
}
return result;
... ... @@ -328,8 +329,10 @@ public class SellerOrderCancelService {
tbo.setUpdateTime(DateUtil.getCurrentTimeSecond());
result += buyerOrderMapper.updateByOrderCode(tbo);
if(result > 0) {
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), buyerOrderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), buyerOrderCode)));
... ... @@ -360,7 +363,7 @@ public class SellerOrderCancelService {
.type(transferCase.getCode()).transferCase(transferCase).build();
transferService.transfer(tmReq);
PayRefundBo refundResp = payRefundService.refund(refundReq, bleb);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
//异步
inBoxFacade.noticeBuyerWhenSellerCancelAfterPaid(buyerUid, buyerOrderCode, psog.getProductName());
inBoxFacade.sellerCancelAfterBuyerPaid(sellerUid, psog.getProductName());
... ... @@ -497,7 +500,7 @@ public class SellerOrderCancelService {
sellerOrderMapper.updateByOrderCode(tso);
//
cacheCleaner.cleanList(sellerUid, TabType.SELL.getValue());
cacheCleaner.cleanDetail(sellerUid, orderCode, TabType.SELL);
cacheCleaner.cleanSellerDetail(psog);
double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
PaymentRequest refundReq = PaymentRequest.builder().uid(sellerOrder.getUid())
.orderCode(orderCode)
... ...
... ... @@ -106,24 +106,25 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
logger.warn("getOrderDetail orderCode illegal, req {}", orderRequest);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
OrderDetailInfo orderDetailInfo = orderCacheService.getOrderDetailInfo(uid, orderCode, TabType.SELL);
if (Objects.isNull(orderDetailInfo)){
OrderDetailInfo orderDetailInfo ;
boolean fromCache = true;
if( SELLER_TYPES.contains(codeMeta.getType())){
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(sellerOrder)){
logger.warn("can not find seller order, req {}", orderRequest);
return null;
}
Integer skup = sellerOrder.getSkup();
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
orderDetailInfo = orderCacheService.getSellerOrderDetailInfo(sellerOrderGoods);
if (Objects.isNull(orderDetailInfo)){
fromCache = false;
boolean isEntry = userProxyService.isEntryShop(uid)
&& Objects.nonNull(sellerOrder.getPayment())
&& OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType() == sellerOrder.getPayment();
SellerType sellerType = isEntry ? SellerType.ENTRY : SellerType.COMMON;
Integer skup = sellerOrder.getSkup();
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
Integer skupStatusCode = sellerOrderGoods.getStatus();
SellerOrderGoods sogc = new SellerOrderGoods();
... ... @@ -136,14 +137,19 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
SkupStatus skupStatus = SkupStatus.getSkupStatus(skupStatusCode);
AddressInfo addressInfo = sellerAddressService.getHiddenAddressInfo(uid, skup);
orderDetailInfo = buildOrderDetail(sellerOrder, skupStatus, tsog, addressInfo, sellerType);
}else{
orderDetailInfo = super.getOrderDetail(orderRequest);
orderCacheService.cacheSellerOrderDetailInfo(tsog, orderDetailInfo);
}
if (Objects.nonNull(orderDetailInfo)){
}else {
orderDetailInfo = orderCacheService.getOrderDetailInfo(uid, orderCode, TabType.SELL);
if (Objects.isNull(orderDetailInfo)) {
fromCache = false;
orderDetailInfo = super.getOrderDetail(orderRequest);
orderCacheService.cacheOrderDetailInfo(uid, orderCode, TabType.SELL, orderDetailInfo);
}
}else{//fetch from cache
}
if (fromCache){//fetch from cache
resetDynamicProporties(orderDetailInfo);
}
... ...
... ... @@ -43,6 +43,7 @@ import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.MerchantOrderPaymentService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
... ... @@ -232,11 +233,13 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
if(isEntryShop){
log.info("in publishPrd use batchPublishPrds, req {}", req);
resp = batchPublishPrds(context, req);
}else{
log.info("in publishPrd use publishSinglePrd, req {}", req);
resp = publishSinglePrd(req, context);
}
cacheCleaner.cleanList(req.getUid(), TabType.SELL.getValue());
}
return resp;
}
... ... @@ -351,8 +354,11 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
List<OrderInfo> orderList = soList.parallelStream().map(so->OrderInfo.builder()
.orderCode(so.getOrderCode()).amount(so.getEarnestMoney()).build()).collect(Collectors.toList());;
merchantOrderPaymentService.unshelveAddWalletDetail(sellerWallet, orderList);
SkupDto skupDto = tskupMap.values().iterator().next();
//clean cache
cacheCleaner.cleanList(req.getUid(), TabType.SELL.getValue());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(skupDto.getSellerOrderGoods())
));
}
result = true;
... ... @@ -581,7 +587,10 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
merchantOrderPaymentService.changePriceAddWalletDetail(sellerWallet, orderList );
successCnt = skupMap.size();
cacheCleaner.cleanList(req.getUid(), TabType.SELL.getValue());
SkupDto skupDto = skupMap.values().iterator().next();
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(req.getUid(), TabType.SELL.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(skupDto.getSellerOrderGoods())
));
}else {
//1.2 划账失败后
failCnt = skupMap.size();
... ... @@ -623,6 +632,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
SellerOrderSubmitHandler.ForkJoinResult fjr = null;
try {
fjr = orderSubmitHandler.submitMultiple(ctx, num);
cacheCleaner.cleanList(uid, TabType.SELL.getValue());
// (异步实现)记录保证金流水
//(异步实现)同步数据到prd,记录支付,
BatchPublishTailEvent bpte = BatchPublishTailEvent.builder().fjr(fjr).sellerWallet(sellerWallet).build();
... ...
... ... @@ -6,6 +6,7 @@ import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.TradeBillsMapper;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.dal.order.model.TradeBills;
import com.yohoufo.order.common.Payment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -37,6 +38,9 @@ public class TradeBillsService {
*/
public void backPayEnsureRecord(Integer uid, Integer skup, Long orderCode,
Integer payType, Integer tradeStatus) {
if(payType != null && Payment.WALLET.getCode() == payType){
return;
}
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(uid, skup, "fee");
if (meta == null) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, uid = {}, skup={}", uid, skup);
... ... @@ -82,6 +86,11 @@ public class TradeBillsService {
public void backPayBuyRecord(Integer uid, Integer sellerUid, Integer skup,
Long orderCode, Integer payType, BigDecimal amount,
Integer tradeStatus) {
if(payType != null && Payment.WALLET.getCode() == payType){
return;
}
SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
if (meta == null) {
logger.error("PayRecordErr记录交易到数据库出错 err=meta费率信息未查到, selleruid = {}, skup={}", sellerUid, skup);
... ...
... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.req.SellerOrderBatchCancelReq;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.dto.SkupDto;
import lombok.Data;
... ... @@ -36,6 +37,8 @@ public class SellerBatchCancelPrepareProcessor {
@Data
public static class DataNode{
SellerOrderGoods sampleSellerOrderGoods;
Long batchNo;
List<Integer> needOffShelveSkups;
... ...