Authored by chenchao

1. rebuild modify address's button of detail and list

2. fix: buyer self modify address miss update time
... ... @@ -156,7 +156,8 @@ public class BuyerOrderController {
LOG.info("in ufo.order.buyerModifyAddress, uid {},orderCode {} request addressInfo {} ", addressInfo.getUid(),orderCode,addressInfo);
//如果地址信息没有变化,返回false,有变化返回true
boolean changed = buyerOrderService.buyerModifyAddress(addressInfo.getUid(),orderCode,addressInfo);
final boolean fromPlatform = false;
boolean changed = buyerOrderService.buyerModifyAddress(addressInfo.getUid(),orderCode,addressInfo, fromPlatform);
String info = StringUtils.EMPTY;
if(changed){
info = "修改成功";
... ...
... ... @@ -62,28 +62,42 @@ public class AddressInfoConvertor {
addressInfo.setMobile(orderAddressReq.getMobile());
return addressInfo;
}
public static void mergeChangedAddress4NoHidden(AddressInfo noHiddenAddress,
AddressInfo changedAddress,
OrderAddressReq req){
private static void mergeChangedAddress4NoHidden(AddressInfo noHiddenAddress,
AddressInfo changedAddress){
noHiddenAddress.setAreaCode(changedAddress.getAreaCode());
noHiddenAddress.setArea(changedAddress.getArea());
noHiddenAddress.setMobile(changedAddress.getMobile());
noHiddenAddress.setConsignee(changedAddress.getConsignee());
noHiddenAddress.setAddress(changedAddress.getAddress());
noHiddenAddress.setSelfModifyTimes(calSelfModifyTimes(req.isFromPlatform()));
}
public static void mergeChangedAddress4NoHidden(AddressInfo noHiddenAddress,
AddressInfo changedAddress,
boolean isFromPlatform){
mergeChangedAddress4NoHidden(noHiddenAddress, changedAddress);
Integer selfModifyTimes = calSelfModifyTimes(isFromPlatform);
if (Objects.nonNull(selfModifyTimes)){
noHiddenAddress.setSelfModifyTimes(selfModifyTimes);
}
}
public static void mergeChangedAddress4Hidden(AddressInfo hiddenAddress,
OrderAddressReq req,
private static void mergeChangedAddress4Hidden(AddressInfo hiddenAddress,
AddressInfo hiddenAddressTemp){
hiddenAddress.setArea(hiddenAddressTemp.getArea());
hiddenAddress.setAreaCode(hiddenAddressTemp.getAreaCode());
hiddenAddress.setMobile(hiddenAddressTemp.getMobile());
hiddenAddress.setConsignee(hiddenAddressTemp.getConsignee());
hiddenAddress.setAddress(hiddenAddressTemp.getAddress());
hiddenAddress.setSelfModifyTimes(calSelfModifyTimes(req.isFromPlatform()));
}
public static void mergeChangedAddress4Hidden(AddressInfo hiddenAddress,
boolean isFromPlatform,
AddressInfo hiddenAddressTemp){
mergeChangedAddress4Hidden(hiddenAddress, hiddenAddressTemp);
Integer selfModifyTimes = calSelfModifyTimes(isFromPlatform);
if (Objects.nonNull(selfModifyTimes)){
hiddenAddress.setSelfModifyTimes(selfModifyTimes);
}
}
public static Integer calSelfModifyTimes(boolean isFromPlatform){
... ...
... ... @@ -3,11 +3,13 @@ package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.model.BuyerOrder;
public interface IBuyerOrderMetaService {
String updateDeliveryAddress(BuyerOrderMetaUpdateReq req, BuyerOrder pbo);
boolean buyerSelfModifyAddress(int uid, long orderCode,
AddressInfo changedAddress,
final boolean fromPlatform);
String updateDeliveryAddressByErp(BuyerOrderMetaUpdateReq req);
... ...
... ... @@ -52,7 +52,7 @@ public interface IBuyerOrderService {
* 买家修改收货地址
* 如果地址信息没有变化,返回false,有变化返回true
*/
boolean buyerModifyAddress(int uid, long orderCode,AddressInfo changedAddress);
boolean buyerModifyAddress(int uid, long orderCode,AddressInfo changedAddress,final boolean fromPlatform);
boolean delete(int uid, long orderCode);
... ...
... ... @@ -82,6 +82,11 @@ public class CacheCleaner {
delete(keyBuilders);
}
public void cleanBuyerOrderDetailAndList(int buyerUid, Long buyerOrderCode){
List<RedisKeyBuilder> keyBuilders = buildBuyerOrderDetailAndList(buyerUid, buyerOrderCode);
delete(keyBuilders);
}
public void cleanSellerAndBuyerOrderDetailAndList(int sellerUid,int buyerUid, Long buyerOrderCode){
List<RedisKeyBuilder> keyBuilders = buildSellerAndBuyerOrderKeys(sellerUid, buyerUid, buyerOrderCode);
delete(keyBuilders);
... ... @@ -100,4 +105,13 @@ public class CacheCleaner {
CacheKeyBuilder.orderNumSummaryKey(buyerUid, buyerType.getValue()));
return keyBuilders;
}
public static List<RedisKeyBuilder> buildBuyerOrderDetailAndList(int buyerUid, Long buyerOrderCode){
TabType sellType = TabType.SELL, buyerType = TabType.BUY;
List<RedisKeyBuilder> keyBuilders = Arrays.asList(
CacheKeyBuilder.orderListKey(buyerUid, buyerType.getValue()),
CacheKeyBuilder.orderDetailKey(buyerUid, buyerType.getValue(), buyerOrderCode)
);
return keyBuilders;
}
}
... ...
... ... @@ -94,6 +94,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest) {
BuildNode buildNode = prepareBuild(orderRequest);
OrderDetailInfo orderDetailInfo = buildOrderDetail(buildNode);
afterProcess(orderDetailInfo);
return orderDetailInfo;
}
... ... @@ -187,6 +188,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
String appraiseVideoUrl;
List<BuyerOrderMeta> buyerOrderMetas;
}
protected abstract void afterProcess(OrderDetailInfo orderDetailInfo);
OrderDetailInfo buildOrderDetail(BuildNode buildNode) {
TabType tabType = buildNode.tabType;
... ...
... ... @@ -9,6 +9,7 @@ import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.QualityCheckMapper;
... ... @@ -75,6 +76,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
*/
abstract Map<Long,String> getAppraiseVideo(List<BuyerOrder> buyerOrderList);
abstract void afterProcess(OrderListInfo orderListInfo);
/**TODO next step split isPlatform from this method, create new replace
* 订单列表
... ... @@ -95,7 +97,11 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
ListPreparedNode lpNode = prepare(request);
total = lpNode.total;
buyerOrderList = lpNode.buyerOrderList;
convertFunc = (buyerOrder) -> convertOrderInfo(buyerOrder, lpNode);
convertFunc = (buyerOrder) -> {
OrderListInfo orderListInfo = convertOrderInfo(buyerOrder, lpNode);
afterProcess(orderListInfo);
return orderListInfo;
};
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.bo.BidDepositInfo;
import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.TimeoutBo;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
... ... @@ -83,10 +84,12 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
}
BuildNode buildNode = super.prepareBuild(orderRequest);
orderDetailInfo = super.buildOrderDetail(buildNode);
//刷新动态数据
refreshGoodsInfoIfNeed(orderDetailInfo);
if(Objects.nonNull(orderDetailInfo)){
afterProcess(orderDetailInfo);
Integer oac;
if ((oac=orderDetailInfo.getAttributes()) == OrderAttributes.DEPOSITE.getCode()){
SellerOrderGoods psog = buildNode.sellerOrderGoods;
... ... @@ -95,12 +98,23 @@ public class BuyerOrderDetailService extends AbsOrderDetailService implements IO
String depositTips = OrderDetailDescHelper.getDepositTipsOfOrderDetail(targetSkupType);
orderDetailInfo.setDepositTips(depositTips);
}
orderCacheService.cacheOrderDetailInfo(uid, orderCode, actor, orderDetailInfo);
}
return orderDetailInfo;
}
@Override
protected void afterProcess(OrderDetailInfo orderDetailInfo) {
AddressInfo addressInfo = orderDetailInfo.getUserAddress();
if (Objects.nonNull(addressInfo)){
Integer selfModifyTimes;
if ((selfModifyTimes=addressInfo.getSelfModifyTimes())!= null && selfModifyTimes>0){
orderDetailInfo.getButtons().removeIf(x-> x!=null && ButtonShow.MODIFY_ADDRESS.getCode().equals(x.getCode()));
}
}
}
@Override
BuyerOrder getBuyerOrder(int uid, long orderCode) {
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.GoodsInfo;
import com.yohobuy.ufo.model.order.bo.TimeoutBo;
import com.yohobuy.ufo.model.order.common.ButtonShow;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.TabType;
... ... @@ -36,10 +37,7 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static com.yohobuy.ufo.model.order.common.OrderStatus.DONE;
... ... @@ -152,6 +150,17 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
return qiniuLiveRecordService.getAppraiseVideoUrl(orderCodes);
}
@Override
void afterProcess(OrderListInfo orderListInfo) {
AddressInfo addressInfo = orderListInfo.getAddressInfo();
if (Objects.nonNull(addressInfo)){
Integer selfModifyTimes;
if ((selfModifyTimes=addressInfo.getSelfModifyTimes())!= null && selfModifyTimes>0){
orderListInfo.getButtons().removeIf(x-> x!=null && ButtonShow.MODIFY_ADDRESS.getCode().equals(x.getCode()));
}
}
}
private void processButtons(List<OrderListInfo> list){
new BuyerOrderButtonsHandler(list)
.loadBuyerOrderDS(buyerOrderMapper::selectByOrderCodes,buyerOrderGoodsMapper::selectByOrderCodeList)
... ... @@ -219,7 +228,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
if (!ActionStatusHold.buyerCanModifyAddress(orderStauts)){
return null;
}
return buyerOrderMetaService.getHiddenAddressInfo(uid, orderCode);
AddressInfo addressInfo = buyerOrderMetaService.getHiddenAddressInfo(uid, orderCode);
return addressInfo;
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.CustomsClearanceResult;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
... ... @@ -14,6 +16,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderMeta;
import com.yohoufo.order.common.ActionStatusHold;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.AddressInfoConvertor;
import com.yohoufo.order.service.IBuyerOrderMetaService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.utils.LoggerUtils;
... ... @@ -42,44 +45,133 @@ public class BuyerOrderMetaServiceImpl implements IBuyerOrderMetaService {
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Override
public String updateDeliveryAddress(BuyerOrderMetaUpdateReq req,BuyerOrder pbo){
String noHiddenAddressStr = req.getAddress();
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress parse address {} ", noHiddenAddressStr);
JSONObject jsonObject = JSON.parseObject(noHiddenAddressStr);
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress parse json address {} ",jsonObject);
String str_address=jsonObject.getString("address");
String str_consignee=jsonObject.getString("consignee");
String str_mobile=jsonObject.getString("mobile");
OrderAddressReq orderAddressReq = OrderAddressReq.builder()
.address(str_address)
.consignee(str_consignee)
.mobile(str_mobile)
.fromPlatform(req.isFromPlatform())
.build();
commomAddressService.checkAddressContent(orderAddressReq);
private static class PreparedNode{
BuyerOrder buyerOrder;
}
public boolean buyerSelfModifyAddress(int uid, long orderCode,
AddressInfo changedAddress,
final boolean fromPlatform){
//参数检查和状态检查
PreparedNode preparedNode = paramAndStatusCheck4BuyerModifyAddress(uid,orderCode,changedAddress);
AddressInfo dbAddressInfo = getAddressInfo(uid,orderCode);
if(dbAddressInfo==null){
logger.warn("dbAddressInfo is null ,uid {} ,orderCode {}",uid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
AddressInfo hiddenAddressInDB = getHiddenAddressInfo(uid,orderCode);
if(hiddenAddressInDB==null){
logger.warn("hiddenAddressInDB is null ,uid {} ,orderCode {}",uid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
boolean changed = commomAddressService.convertAddressInfoFrontRequest(uid, orderCode, fromPlatform, dbAddressInfo,hiddenAddressInDB,changedAddress);
//至少有一个要更新,否则直接返回
if(!changed){
logger.warn("buyer self ModifyAddress no change address return now! uid {} orderCode {} changeAddress {} fromPlatform {}",
uid, orderCode, changedAddress, fromPlatform);
//throw new UfoServiceException(400,"地址信息无变化");
return false;
}
logger.info("buyerModifyAddress begin update address,uid {},orderCode {},update address info {}",
uid, orderCode ,changedAddress);
updateDeliveryAddress(uid,orderCode,changedAddress, dbAddressInfo, hiddenAddressInDB, fromPlatform);
//clean cache of seller and buyer order detail
cacheCleaner.cleanDetail(uid, orderCode, TabType.BUY);
return true;
}
/**
* 基本参数检查
* 状态校验
* @param uid
* @param orderCode
* @param changedAddress
* @return
*/
private PreparedNode paramAndStatusCheck4BuyerModifyAddress(int uid, long orderCode, AddressInfo changedAddress){
//入参
if(uid <= 0){
throw new UfoServiceException(400,"参数错误:uid错误");
}
if(orderCode <= 0L){
throw new UfoServiceException(400,"参数错误:订单号错误");
}
///// 检查隐藏的内容是否有变化,带*
if(StringUtils.isBlank(changedAddress.getAddress())||StringUtils.isBlank(changedAddress.getConsignee())
||StringUtils.isBlank(changedAddress.getMobile())
||StringUtils.isBlank(changedAddress.getArea())
||StringUtils.isBlank(changedAddress.getAreaCode())){
throw new UfoServiceException(400,"地址信息填写错误");
}
//检查订单
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode,uid);
if(buyerOrder==null){
logger.warn("buyerModifyAddress check orderCode exist, uid is {}, orderCode is {}",
uid, orderCode );
throw new ServiceException(ServiceError.ORDER_NULL);
}
if(buyerOrder.getStatus()==null){
logger.warn("buyerModifyAddress check orderCode status is null, uid is {}, orderCode is {} ,status is {}",
uid, orderCode,buyerOrder.getStatus() );
throw new UfoServiceException(400,"订单状态已变,不允许修改地址");
}
//买家已付款,卖家已发货,只有这两种状态的情况下,才允许改地址
boolean allowChange = ActionStatusHold.buyerCanModifyAddress(buyerOrder.getStatus());
if(!allowChange){
logger.warn("buyerModifyAddress check orderCode status not invalid, uid is {}, orderCode is {} ,status is {}",
uid, orderCode,buyerOrder.getStatus() );
throw new UfoServiceException(400,"订单状态变更,不允许修改地址");
}
PreparedNode preparedNode = new PreparedNode();
preparedNode.buyerOrder = buyerOrder;
return preparedNode;
}
private String updateDeliveryAddress(int buyerUid, long orderCode,
AddressInfo changedAddressFromReq,
AddressInfo noHiddenAddress,
AddressInfo hiddenAddress,
boolean isFromPlatform){
Integer selfModifyTimes = AddressInfoConvertor.calSelfModifyTimes(isFromPlatform);
//set noHiddenAddress in no hidden
if (!isFromPlatform){
noHiddenAddress.setSelfModifyTimes(selfModifyTimes);
}
AddressInfoConvertor.mergeChangedAddress4NoHidden(noHiddenAddress, changedAddressFromReq, isFromPlatform);
String str_address = noHiddenAddress.getAddress();
String str_consignee = noHiddenAddress.getConsignee();
String str_mobile = noHiddenAddress.getMobile();
AddressInfo changedAddress = new AddressInfo();
changedAddress.setAddress(str_address);
changedAddress.setConsignee(str_consignee);
changedAddress.setMobile(str_mobile);
AddressInfo hiddenAddress = commomAddressService.buildHiddenAddress(changedAddress);
AddressInfo hiddenAddressOfChanged = commomAddressService.buildHiddenAddress(changedAddress);
AddressInfoConvertor.mergeChangedAddress4Hidden(hiddenAddress, isFromPlatform, hiddenAddressOfChanged);
String rtn="";
int updateRowNum=0;
jsonObject.put("address", hiddenAddress.getAddress());
jsonObject.put("consignee", hiddenAddress.getConsignee());
jsonObject.put("mobile", hiddenAddress.getMobile());
if (Objects.nonNull(req.getSelfModifyTimes())){
jsonObject.put("selfModifyTimes", req.getSelfModifyTimes());
if (Objects.nonNull(selfModifyTimes)){
hiddenAddress.setSelfModifyTimes(selfModifyTimes);
}
int buyerUid;
//hidden address
BuyerOrderMeta meta_hiddenAddress=new BuyerOrderMeta();
meta_hiddenAddress.setUid(buyerUid=req.getUid());
meta_hiddenAddress.setOrderCode(req.getOrderCode());
BuyerOrderMeta meta_hiddenAddress = new BuyerOrderMeta();
meta_hiddenAddress.setUid(buyerUid);
meta_hiddenAddress.setOrderCode(orderCode);
meta_hiddenAddress.setMetaKey(MetaKey.BUYER_DELIVERY_HIDDEN_ADDRESS);
meta_hiddenAddress.setMetaValue(jsonObject.toJSONString());
meta_hiddenAddress.setMetaValue(JSONObject.toJSONString(hiddenAddress));
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress_hidden meta param {} begin ",meta_hiddenAddress);
updateRowNum = buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(meta_hiddenAddress);
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress_hidden meta param {} end, updateRowNum {} ",meta_hiddenAddress,updateRowNum);
... ... @@ -87,39 +179,69 @@ public class BuyerOrderMetaServiceImpl implements IBuyerOrderMetaService {
//no hidden address
BuyerOrderMeta meta=new BuyerOrderMeta();
meta.setUid(buyerUid);
meta.setOrderCode(req.getOrderCode());
meta.setOrderCode(orderCode);
meta.setMetaKey(MetaKey.BUYER_DELIVERY_ADDRESS);
meta.setMetaValue(req.getAddress());
meta.setMetaValue(JSONObject.toJSONString(noHiddenAddress));
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress meta param {} begin ",meta);
updateRowNum = buyerOrderMetaMapper.updateMetaValueByUidAndOrderCodeAndMetaKey(meta);
logger.info("BuyerOrderMetaServiceImpl updateDeliveryAddress meta param {} end, updateRowNum {} ",meta,updateRowNum);
rtn += (" address update:" + updateRowNum);
//clean cache of seller and buyer order detail
cacheCleaner.cleanDetail(buyerUid, req.getOrderCode(), TabType.BUY);
Integer sellerUid = pbo.getSellerUid();
cacheCleaner.cleanSellerAndBuyerOrderDetailAndList(sellerUid, buyerUid, req.getOrderCode());
cacheCleaner.cleanBuyerOrderDetailAndList(buyerUid, orderCode);
return rtn;
}
@Override
public String updateDeliveryAddressByErp(BuyerOrderMetaUpdateReq req) {
int buyerUid;
long orderCode;
String addressOfJson;
//检查
if(req.getUid()<=0||req.getOrderCode()<=0|| StringUtils.isBlank(req.getAddress())){
if((buyerUid=req.getUid())<=0
||(orderCode=req.getOrderCode())<=0
|| StringUtils.isBlank(addressOfJson=req.getAddress())){
throw new UfoServiceException(400, "参数校验不通过");
}
// check status
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(req.getOrderCode());
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder==null){
throw new UfoServiceException(400, "订单不存在");
}
Integer status;
if((status=buyerOrder.getStatus())==null
||!ActionStatusHold.erpCanModifyBuyerAddress(status.intValue())){
logger.warn("BuyerOrderMeta4PlatformController updateDeliveryAddress not allow status {} param req is {}",buyerOrder.getStatus(), req);
throw new UfoServiceException(400, "订单状态不允许变更地址");
}
return updateDeliveryAddress(req, buyerOrder);
try {
AddressInfo changedAddress = JSONObject.parseObject(addressOfJson, AddressInfo.class);
OrderAddressReq orderAddressReq = OrderAddressReq.builder()
.address(changedAddress.getAddress())
.consignee(changedAddress.getConsignee())
.mobile(changedAddress.getMobile())
.fromPlatform(req.isFromPlatform())
.build();
commomAddressService.checkAddressContent(orderAddressReq);
AddressInfo dbAddressInfo = getAddressInfo(buyerUid,orderCode);
if(dbAddressInfo==null){
logger.warn("dbAddressInfo is null ,uid {} ,orderCode {}",buyerUid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
AddressInfo hiddenAddressInDB = getHiddenAddressInfo(buyerUid,orderCode);
if(hiddenAddressInDB==null){
logger.warn("hiddenAddressInDB is null ,uid {} ,orderCode {}",buyerUid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
return updateDeliveryAddress(buyerUid,orderCode,changedAddress,dbAddressInfo, hiddenAddressInDB, req.isFromPlatform());
}catch (Exception ex){
logger.warn("updateDeliveryAddressByErp occur exception req {} error {}", req, Throwables.getStackTraceAsString(ex));
}
return null;
}
BuyerOrderMeta getBuyerOrderMeta(int uid, long orderCode, String metaKey) {
... ...
... ... @@ -209,105 +209,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
* 如果地址信息没有变化,返回false,有变化返回true
*/
@Override
public boolean buyerModifyAddress(int uid, long orderCode,AddressInfo changedAddress){
final boolean fromPlatform = false;
//参数检查和状态检查
PreparedNode preparedNode = paramAndStatusCheck4BuyerModifyAddress(uid,orderCode,changedAddress);
AddressInfo dbAddressInfo = buyerOrderMetaService.getAddressInfo(uid,orderCode);
if(dbAddressInfo==null){
logger.warn("dbAddressInfo is null ,uid {} ,orderCode {}",uid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
AddressInfo hiddenAddressInDB = buyerOrderMetaService.getHiddenAddressInfo(uid,orderCode);
if(hiddenAddressInDB==null){
logger.warn("hiddenAddressInDB is null ,uid {} ,orderCode {}",uid,orderCode);
throw new UfoServiceException(400,"找不到地址信息");
}
public boolean buyerModifyAddress(int uid, long orderCode,
AddressInfo changedAddress,
final boolean fromPlatform){
boolean changed = commomAddressService.convertAddressInfoFrontRequest(uid, orderCode, fromPlatform, dbAddressInfo,hiddenAddressInDB,changedAddress);
//至少有一个要更新,否则直接返回
if(!changed){
logger.warn("buyerModifyAddress no change address return now!");
//throw new UfoServiceException(400,"地址信息无变化");
return false;
}
Integer selfModifyTimes = AddressInfoConvertor.calSelfModifyTimes(fromPlatform);
dbAddressInfo.setSelfModifyTimes(selfModifyTimes);
//更新收货地址:明文地址 . 隐藏地址
JSONObject jo_address = (JSONObject)JSON.toJSON(dbAddressInfo);
jo_address.remove("uid");
String jo_address_string = jo_address.toJSONString();
BuyerOrderMetaUpdateReq updateInfo = new BuyerOrderMetaUpdateReq();
updateInfo.setUid(uid);
updateInfo.setOrderCode(orderCode);
updateInfo.setAddress(jo_address_string);
updateInfo.setSelfModifyTimes(selfModifyTimes);
logger.info("buyerModifyAddress begin update address , uid is {}, orderCode is {},update address info {}",
uid, orderCode ,jo_address_string);
buyerOrderMetaService.updateDeliveryAddress(updateInfo, preparedNode.buyerOrder);
//clean cache of seller and buyer order detail
cacheCleaner.cleanDetail(uid, orderCode, TabType.BUY);
return true;
boolean result = buyerOrderMetaService.buyerSelfModifyAddress(uid, orderCode,changedAddress, fromPlatform);
return result;
}
private static class PreparedNode{
BuyerOrder buyerOrder;
}
/**
* 基本参数检查
* 状态校验
* @param uid
* @param orderCode
* @param changedAddress
* @return
*/
private PreparedNode paramAndStatusCheck4BuyerModifyAddress(int uid, long orderCode, AddressInfo changedAddress){
//入参
if(uid <= 0){
throw new UfoServiceException(400,"参数错误:uid错误");
}
if(orderCode <= 0L){
throw new UfoServiceException(400,"参数错误:订单号错误");
}
///// 检查隐藏的内容是否有变化,带*
if(StringUtils.isBlank(changedAddress.getAddress())||StringUtils.isBlank(changedAddress.getConsignee())
||StringUtils.isBlank(changedAddress.getMobile())
||StringUtils.isBlank(changedAddress.getArea())
||StringUtils.isBlank(changedAddress.getAreaCode())){
throw new UfoServiceException(400,"地址信息填写错误");
}
//检查订单
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode,uid);
if(buyerOrder==null){
logger.warn("buyerModifyAddress check orderCode exist, uid is {}, orderCode is {}",
uid, orderCode );
throw new ServiceException(ServiceError.ORDER_NULL);
}
if(buyerOrder.getStatus()==null){
logger.warn("buyerModifyAddress check orderCode status is null, uid is {}, orderCode is {} ,status is {}",
uid, orderCode,buyerOrder.getStatus() );
throw new UfoServiceException(400,"订单状态已变,不允许修改地址");
}
//买家已付款,卖家已发货,只有这两种状态的情况下,才允许改地址
boolean allowChange = ActionStatusHold.buyerCanModifyAddress(buyerOrder.getStatus());
if(!allowChange){
logger.warn("buyerModifyAddress check orderCode status not invalid, uid is {}, orderCode is {} ,status is {}",
uid, orderCode,buyerOrder.getStatus() );
throw new UfoServiceException(400,"订单状态变更,不允许修改地址");
}
PreparedNode preparedNode = new PreparedNode();
preparedNode.buyerOrder = buyerOrder;
return preparedNode;
}
... ...
... ... @@ -212,6 +212,11 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
return orderDetailInfo;
}
@Override
protected void afterProcess(OrderDetailInfo orderDetailInfo) {
}
void assembleSoldPrdCompute(OrderDetailInfo orderDetailInfo, int uid, int skup){
SellerOrderMeta feeMeta = somMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);
... ...
... ... @@ -382,6 +382,11 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
@Override
void afterProcess(OrderListInfo orderListInfo) {
}
@Override
public Logger getLogger() {
return log;
}
... ...
... ... @@ -172,11 +172,11 @@ public class SellerAddressService {
AddressInfo hiddenAddressTemp = commomAddressService.buildHiddenAddress(changedAddress);
//hidden
AddressInfoConvertor.mergeChangedAddress4Hidden(hiddenAddress, req, hiddenAddressTemp);
AddressInfoConvertor.mergeChangedAddress4Hidden(hiddenAddress, req.isFromPlatform(), hiddenAddressTemp);
rows += updateHiddenAddress(skup, hiddenAddress);
//no hidden
AddressInfoConvertor.mergeChangedAddress4NoHidden(noHiddenAddress, changedAddress, req);
AddressInfoConvertor.mergeChangedAddress4NoHidden(noHiddenAddress, changedAddress, req.isFromPlatform());
rows += updateNoHiddenAddress(skup, noHiddenAddress);
logger.info("updateSellerDeliveryAddressByBuyerOrderCode finish req {} rows {}", req, rows);
break;
... ...