Authored by chenchao

support update address when recall deposit product

... ... @@ -22,6 +22,11 @@ public interface MetaKey {
*/
String ACTIVITY_KEY = "activity";
String RECALL_ADDRESS = "recall_address",
RECALL_HIDDEN_ADDRESS ="recall_hidden_address";
/**
* 金额明细
*/
... ...
... ... @@ -136,7 +136,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
Integer skup = null;
try {
depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid());
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), true);
}catch (Exception ex){
logger.warn("pay successful, processDepositOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
... ... @@ -196,9 +196,23 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
orderOverTimeService.insertDeliveryTime(new OrderOverTime(orderCode, ts + secondsOfLimit, minutes));
}
private void processQuickDeliverOrder(BuyerOrder orderInfo, SellerOrderGoods sellerOrderGoods){
private void processQuickDeliverOrder(BuyerOrder buyerOrder, SellerOrderGoods sellerOrderGoods){
//寄存订单 & 闪购商品
if (SkupType.QUICK_DELIVER.getCode() == sellerOrderGoods.getAttributes()){
Integer sellerUid = null;
Integer buyerUid = null;
Long orderCode = null;
Integer skup = null;
try {
depositService.changeOwner(sellerUid = buyerOrder.getSellerUid(), skup = sellerOrderGoods.getId(),
orderCode = buyerOrder.getOrderCode(), buyerUid = buyerOrder.getUid(), false);
}catch (Exception ex){
logger.warn("pay successful, processQuickDeliverOrder invoke depositService.changeOwner fail, sellerUid {}, buyerUid {},orderCode {},skup {}",
sellerUid, buyerUid, orderCode, skup);
}
}
//todo notice
}
@Override
... ...
... ... @@ -2,7 +2,6 @@ package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.model.request.OrderRequest;
... ... @@ -62,7 +61,12 @@ public interface IBuyerOrderService {
void miniFaultCreate(SaveQualityCheckInfoRequest request);
void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr);
OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType);
}
... ...
... ... @@ -11,17 +11,16 @@ import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.UserInfoHiddenHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.QualityCheckMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.ProductMapper;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.request.OrderRequest;
... ... @@ -40,6 +39,7 @@ import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.utils.BuyerOrderUtils;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -775,6 +775,85 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
}
}
@Autowired
private BuyerOrderMetaMapper buyerOrderMetaMapper;
@Autowired
private UserProxyService userProxyService;
@Override
public void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr) {
int addressId = AddressUtil.getDecryptStr(addressIdstr);
if (addressId < 0){
logger.warn("modifyAddressOfDepositOrder addressId invalidate, uid {}, orderCode {}, addressId is {}",
uid, orderCode, addressIdstr);
throw new ServiceException(ServiceError.ORDER_ADDRESSID_INVALIDATE);
}
BuyerOrder pbo = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (pbo == null ){
logger.warn("in modifyAddressOfDepositOrder BuyerOrder is null,uid {} orderCode {} addressIdstr {}",
uid, orderCode, addressIdstr);
return;
}
Integer oa;
if (OrderAttributes.DEPOSITE.getCode() != (oa=pbo.getAttributes())){
logger.warn("in modifyAddressOfDepositOrder BuyerOrder.Attributes is {},uid {} orderCode {} addressIdstr {}",
oa, uid, orderCode, addressIdstr);
return;
}
//the address of send back 2 seller
AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
final String key = MetaKey.RECALL_ADDRESS, hiiden_key = MetaKey.RECALL_HIDDEN_ADDRESS;
BuyerOrderMeta noHiddenAddressMeta=new BuyerOrderMeta();
noHiddenAddressMeta.setUid(uid);
noHiddenAddressMeta.setOrderCode(orderCode);
noHiddenAddressMeta.setMetaKey(key);
noHiddenAddressMeta.setMetaValue(JSONObject.toJSONString(noHiddenBackAddress));
//hidden address
BuyerOrderMeta hiddenAddressMeta=new BuyerOrderMeta();
hiddenAddressMeta.setUid(uid);
hiddenAddressMeta.setOrderCode(orderCode);
hiddenAddressMeta.setMetaKey(hiiden_key);
hiddenAddressMeta.setMetaValue(JSONObject.toJSONString(hiddenBackAddress));
//
List<BuyerOrderMeta> boms = new ArrayList<>(2);
boms.add(noHiddenAddressMeta);
boms.add(hiddenAddressMeta);
List<BuyerOrderMeta> pboms = buyerOrderMetaMapper.selectByMetaKeys(uid, orderCode, Arrays.asList(key, hiiden_key));
if(CollectionUtils.isEmpty(pboms)){
buyerOrderMetaMapper.insertBatch(boms);
}else{
boolean hitNoHidden = false;
boolean hitHidden = false;
for (BuyerOrderMeta pbom : pboms){
if (pbom.getMetaKey().equals(hiiden_key)){
hitHidden = true;
}
if (pbom.getMetaKey().equals(key)){
hitNoHidden = true;
}
}
doPersistent4AddessMeta(hitHidden, hiddenAddressMeta);
doPersistent4AddessMeta(hitNoHidden, noHiddenAddressMeta);
}
}
private void doPersistent4AddessMeta(boolean isExisted, BuyerOrderMeta bom){
if (isExisted){
buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(bom);
}else {
buyerOrderMetaMapper.insert(bom);
}
}
//清理缓存
... ...