Authored by chenchao

check real name 4 order of overseas goods when submit

package com.yohoufo.order.constants;
public interface ClientSpecialSemanticCode {
int needRealName = 440;
}
... ...
... ... @@ -14,7 +14,7 @@ public interface IShoppingService {
* @param request
* @return
*/
public PaymentResponse payment(ShoppingRequest request);
PaymentResponse payment(ShoppingRequest request);
/**
... ... @@ -39,5 +39,5 @@ public interface IShoppingService {
* @param shoppingRequest
* @return
*/
public OrderSubmitResponse submit(ShoppingRequest shoppingRequest);
OrderSubmitResponse submit(ShoppingRequest shoppingRequest);
}
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.order.constants.ClientSpecialSemanticCode;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -24,6 +28,9 @@ public class ShoppingRiskWatchDog {
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private UserProxyService userProxyService;
public void checkWaitingPayCnt(int uid){
logger.info("in ShoppingRiskWatchDog.checkWaitingPayCnt uid {}", uid);
List<Integer> statusList = new ArrayList<>(1);
... ... @@ -36,4 +43,14 @@ public class ShoppingRiskWatchDog {
throw new UfoServiceException(512, "您有未支付的订单,支付或取消后可提交新的订单");
}
}
public void checkRealName4OverseasOrder(int uid, int skupTypeCode){
SkupTypeCodeSupport.CodeNode codeNode = SkupTypeCodeSupport.explain(skupTypeCode);
if (codeNode.getRegion() == RegionEnum.HONGKONG.getCode()){
if (!userProxyService.checkRealNameCert(uid)){
logger.warn("in checkRealName4OverseasOrder result false, uid {}", uid);
throw new UfoServiceException(ClientSpecialSemanticCode.needRealName, "请完成实名认证后操作");
}
}
}
}
... ...
... ... @@ -8,6 +8,7 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AmountCutPolicy;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.constants.*;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.promotion.constant.CouponTypeEnum;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
... ... @@ -27,7 +28,6 @@ import com.yohoufo.order.constants.ActivityTypeEnum;
import com.yohoufo.order.event.BuyerCancelEvent;
import com.yohoufo.order.event.ErpBuyerOrderEvent;
import com.yohoufo.order.event.NotPaidNoticeEvent;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.model.bo.ActivityBo;
import com.yohoufo.order.model.bo.AmountDetailBo;
import com.yohoufo.order.model.bo.CouponBo;
... ... @@ -36,8 +36,8 @@ import com.yohoufo.order.model.dto.BuyerOrderSubmitResult;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.model.request.ShoppingRequest;
import com.yohoufo.order.model.response.*;
import com.yohoufo.order.service.ISubmitOrderService;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.ISubmitOrderService;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
... ... @@ -58,13 +58,13 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@Primary
@Service
public class ShoppingServiceImpl implements IShoppingService {
... ... @@ -403,6 +403,7 @@ public class ShoppingServiceImpl implements IShoppingService {
* @param shoppingRequest
* @return
*/
@Override
public OrderSubmitResponse submit(ShoppingRequest shoppingRequest){
int skup;
int uid;
... ... @@ -415,17 +416,18 @@ public class ShoppingServiceImpl implements IShoppingService {
}
shoppingRiskWatchDog.checkWaitingPayCnt(uid);
//查询并校验用户地址
Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest);
// 检查skup是否可售
SellerOrderGoods psog = checkSkupSellOrNot(shoppingRequest.getUid(), shoppingRequest.getSkup());
shoppingRiskWatchDog.checkRealName4OverseasOrder(uid, psog.getAttributes());
checkSkupIsChangePrice(uid, skup);
//活动价格
ActivityPrice activityPrice = checkAndGetActivityPrice(shoppingRequest, psog);
//查询并校验用户地址
Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest);
//算费
ChargeContext chargeContext = buildChargeContext(shoppingRequest, psog, activityPrice, ChargeParam.SUBMIT);
chargeContext.setShipFeeRequird(true);
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.proxy;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.ServiceError;
... ... @@ -33,7 +34,7 @@ import java.util.stream.Collectors;
* Created by chenchao on 2018/9/18.
*/
@Service
public class UserProxyService {
public class UserProxyService extends AbsProxyService{
private Logger logger = LoggerFactory.getLogger(getClass());
... ... @@ -185,4 +186,26 @@ public class UserProxyService {
return Maps.newHashMap();
}
private static final String API_ISREALNAMECERT = "ufo.user.isRealNameCert";
public boolean checkRealNameCert(int uid){
ApiResponse resp;
boolean result ;
String serviceName = API_ISREALNAMECERT;
try{
resp = ufoServiceCaller.call(serviceName, uid);
if (Objects.isNull(resp)){
result = false;
}else{
result = (boolean)resp.getData();
}
}catch (Exception ex){
result = false;
String errorStack = Throwables.getStackTraceAsString(ex);
logger.warn("call {} fail,req {}, error {}", serviceName, uid, errorStack);
}
return result;
}
}
... ...
... ... @@ -54,15 +54,6 @@ public class ShoppingSupport {
}
String buildDeliveryWayCost(String appVersion, double shippingAmount){
if (isLowerVersion(appVersion, "6.9.3")){
return "以实际提交订单金额为准";
}else{
String currencyAmount = MathUtils.formatCurrencyStr( shippingAmount );
return currencyAmount;
}
}
boolean isLowerVersion(String appVersion, String comparedVersion){
return StringUtils.isNotBlank(appVersion) && appVersion.compareTo(comparedVersion) < 0;
... ... @@ -73,9 +64,6 @@ public class ShoppingSupport {
return deliveryWay == DeliveryWayEnum.SELF_FETCH.getCode() ? OrderConstant.DELIVERY_WAY_STORE_NAME : OrderConstant.DELIVERY_WAY_SF_NAME;
}
public boolean isDeliveryWayByStore(int deliveryWay) {
return deliveryWay == DeliveryWayEnum.SELF_FETCH.getCode();
}
/**
... ...