Authored by caoyan

鉴定服务

package com.yoho.ufo.service.impl;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
... ... @@ -44,6 +45,9 @@ public class UserProxyService {
@Value("${uic.url:http://uic.yohoops.org/uic}")
private String uicUrl;
@Value("${ip.port.uic.server}")
private String uicServerIpAndPort;
/**
* 获取用户信息
* @param uid
... ... @@ -117,6 +121,9 @@ public class UserProxyService {
public static final String PRFILE_API = "/profile/getProfile";
public static final String GET_USER_PROFILES_BY_UIDS = "/profile/getUserProfilesByUids";
private static final String UIC_GETUSERPROFILE_URL = "/uic/profile/getUserProfile";
public String getMobile(int uid){
String url = uicUrl + PRFILE_API;
Map<String,Object> params = Maps.newHashMap();
... ... @@ -166,6 +173,24 @@ public class UserProxyService {
}
public String getUserNameByUid(Integer uid) {
Map<String,Integer> request = Collections.singletonMap("uid", uid);
String url = "http://" + uicServerIpAndPort + UIC_GETUSERPROFILE_URL;
JSONObject jsonObject;
try {
jsonObject = serviceCaller.post("uic.getUserProfileAction", url, request, JSONObject.class, null).get(1);
} catch (Exception e) {
logger.error("call"+ url + " fail!!! uid is {}", uid);
return "";
}
if(null != jsonObject) {
return jsonObject.getString("profile_name");
}
return "";
}
private String getUidStrs(List<Integer> uidList) {
List<String> uidStrList = Lists.newArrayList();
for(Integer uid : uidList) {
... ...
package com.yoho.order.dal;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.AppraiseOrderMeta;
/**
* Created by caoyan on 2019/8/7.
*/
public interface AppraiseOrderMetaMapper {
AppraiseOrderMeta selectByOrderCodeAndMetaKey(@Param("orderCode") String orderCode, @Param("metaKey") String metaKey);
}
... ...
package com.yoho.order.model;
import java.io.Serializable;
import lombok.ToString;
/**
* @author caoyan
* @date 2019/8/7
*/
@ToString
public class AppraiseOrderMeta implements Serializable {
private static final long serialVersionUID = 2607922995706119816L;
private Integer id;
private Integer uid;
private String orderCode;
private Integer storageId;
private String metaKey;
private String metaValue;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public Integer getStorageId() {
return storageId;
}
public void setStorageId(Integer storageId) {
this.storageId = storageId;
}
public String getMetaKey() {
return metaKey;
}
public void setMetaKey(String metaKey) {
this.metaKey = metaKey;
}
public String getMetaValue() {
return metaValue;
}
public void setMetaValue(String metaValue) {
this.metaValue = metaValue;
}
}
... ...
... ... @@ -35,4 +35,26 @@ public class AppraiseOrderResp extends PageRequestBO{
private String attributesStr;
private String createTimeStr;
private String platformWaybillCode;
private Integer payMethod;
private String sellerName;
private String sellerRebackAddressDetail;
private String sellerRebackAddress;
private String sellerRebackMobile;
private String depositCode;
private String shelfCode;
private Integer depositStatus;
private String abnormalTypeStr;
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.order.dal.AppraiseOrderMetaMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.AppraiseOrderMeta">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="storage_id" property="storageId" jdbcType="INTEGER" />
<result column="meta_key" property="metaKey" jdbcType="VARCHAR" />
<result column="meta_value" property="metaValue" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, storage_id, meta_key, meta_value
</sql>
<select id="selectByOrderCodeAndMetaKey" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from appraise_order_goods where order_code =#{orderCode} and meta_key=#{metaKey}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -15,6 +15,7 @@ import com.yoho.ufo.order.service.IAppraiseOrderService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.QcOrderDetailResp;
@RestController
@RequestMapping(value = "/appraiseOrder")
... ... @@ -44,4 +45,11 @@ public class AppraiseOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(null == result ? new PageResponseBO<BuyerOrderResp>() : result).build();
}
@RequestMapping(value = "/getOrderDetail")
public ApiResponse getOrderDetail(AppraiseOrderReq req) {
LOGGER.info("getOrderDetail in. param is {}", req);
AppraiseOrderResp result = appraiseOrderService.getOrderDetail(req.getOrderCode());
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
... ... @@ -11,4 +11,6 @@ public interface IAppraiseOrderService {
PageResponseBO<AppraiseOrderResp> queryOrderListByStatus(AppraiseOrderReq req);
AppraiseOrderResp getOrderDetail(String orderCode);
}
... ...
... ... @@ -13,23 +13,34 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.order.dal.AbnormalOrderMapper;
import com.yoho.order.dal.AppraiseOrderGoodsMapper;
import com.yoho.order.dal.AppraiseOrderMapper;
import com.yoho.order.dal.AppraiseOrderMetaMapper;
import com.yoho.order.dal.AppraiseOrderStorageMapper;
import com.yoho.order.dal.ExpressRecordMapper;
import com.yoho.order.dal.StorageDepositMapper;
import com.yoho.order.model.AbnormalOrder;
import com.yoho.order.model.AppraiseOrder;
import com.yoho.order.model.AppraiseOrderGoods;
import com.yoho.order.model.AppraiseOrderMeta;
import com.yoho.order.model.AppraiseOrderReq;
import com.yoho.order.model.AppraiseOrderResp;
import com.yoho.order.model.AppraiseOrderStorage;
import com.yoho.order.model.ExpressRecord;
import com.yoho.order.model.StorageDeposit;
import com.yoho.ufo.order.constant.Constant;
import com.yoho.ufo.order.constant.OrderAbnormalTypeEnum;
import com.yoho.ufo.order.constant.OrderConfigConstant;
import com.yoho.ufo.order.service.IAppraiseOrderService;
import com.yoho.ufo.service.impl.UserProxyService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.DateUtil;
import com.yoho.ufo.util.ImagesConstant;
import com.yoho.ufo.util.ImagesHelper;
import com.yohobuy.ufo.model.order.common.EnumExpressType;
import com.yohobuy.ufo.model.order.constants.DepositOutTypeEnum;
import com.yohobuy.ufo.model.order.constants.RegionEnum;
@Service
... ... @@ -46,8 +57,20 @@ public class AppraiseOrderServiceImpl implements IAppraiseOrderService{
private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
@Autowired
private ExpressRecordMapper expressRecordMapper;
@Autowired
private StorageDepositMapper storageDepositMapper;
@Autowired
private AbnormalOrderMapper abnormalOrderMapper;
@Autowired
private UserProxyService userProxyService;
//已收货
private static final Byte QC_STATUS_RECEIVED = 0;
... ... @@ -57,26 +80,25 @@ public class AppraiseOrderServiceImpl implements IAppraiseOrderService{
//已发货
private static final Byte QC_STATUS_ALREADY_DELIVER = 2;
private static final Integer PAY_METHOD_MONTHLY = 1;//寄付月结
private static final Integer PAY_METHOD_FREIGHT_COLLECT = 2;//到付
private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address";
//待处理
private static final List<Byte> receivedList = Lists.newArrayList(Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal(),//卖家已发货
Constant.BUYER_ORDER_STATUS_PLATFORM_RECEIVE.getByteVal(),//平台质检中
Constant.BUYER_ORDER_STATUS_JUDGE_PASS_WAIT_WAREHOUSE.getByteVal()); //鉴定通过待寄存
Constant.BUYER_ORDER_STATUS_JUDGING.getByteVal());//平台鉴定中
//待发货
private static final List<Byte> processingList = Lists.newArrayList(Constant.CANCEL_QUALITY_CHECK_FAKE.getByteVal(),//已取消(商品质检不通过)
Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal(),//平台鉴定通过
private static final List<Byte> processingList = Lists.newArrayList(Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal(),//平台鉴定通过
Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal(),//已取消(商品鉴定不通过)
Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal(),//无法鉴定
Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal());//已取消(买家在卖家发货后取消)
Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal());//无法鉴定
//已发货
private static final List<Byte> alreadyDeliverList = Lists.newArrayList(Constant.BUYER_ORDER_STATUS_TO_BE_RECEIVED.getByteVal(),//平台已发货
private static final List<Byte> alreadyDeliverList = Lists.newArrayList(Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal(),//平台鉴定通过
Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal(),//已取消(鉴定不通过)
Constant.CANCEL_QUALITY_CHECK_FAKE.getByteVal(),//已取消(质检不通过)
Constant.CANCEL_MINI_FAULT_REJECT.getByteVal(),//已取消(瑕疵确认不通过)
Constant.CANCEL_MINI_FAULT_OUT_TIME_REJECT.getByteVal(),//已取消(瑕疵确认超时)
Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal(),//无法鉴定
Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal());//已取消(买家在卖家发货后取消)
Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE.getByteVal());//无法鉴定
public Map<String, Integer> getCountByStatus(AppraiseOrderReq req){
... ... @@ -144,6 +166,115 @@ public class AppraiseOrderServiceImpl implements IAppraiseOrderService{
return result;
}
@Override
public AppraiseOrderResp getOrderDetail(String orderCode) {
AppraiseOrder order = appraiseOrderMapper.selectByOrderCode(orderCode);
if(null == order) {
return null;
}
AppraiseOrderResp resp = new AppraiseOrderResp();
resp.setOrderCode(order.getOrderCode());
resp.setStatus(order.getStatus());
resp.setStatusStr(Constant.convertOrderStatusStr(order.getStatus()));
resp.setCreateTimeStr(DateUtil.int2DateStr(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
resp.setAttributes(order.getAttributes());
//卖家物流单号
ExpressRecord sellerExpressRecord = expressRecordMapper.selectByOrderCodeAndType(order.getOrderCode(),
order.getUid(), EnumExpressType.EXPRESS_TYPE_1.getCode());
if(null != sellerExpressRecord) {
resp.setSellerWaybillCode(sellerExpressRecord.getWaybillCode());
}
//查询平台快递单号
List<ExpressRecord> platformExpressList = expressRecordMapper.selectByOrderCodeListAndType(Lists.newArrayList(order.getOrderCode()),
Lists.newArrayList(EnumExpressType.EXPRESS_TYPE_3.getCode(),EnumExpressType.EXPRESS_TYPE_REBACK.getCode()));
if(CollectionUtils.isNotEmpty(platformExpressList)){
resp.setPlatformWaybillCode(platformExpressList.get(0).getWaybillCode());
}
//查询appraise_order_goods
AppraiseOrderGoods goods = appraiseOrderGoodsMapper.selectByOrderCode(Long.valueOf(order.getOrderCode()));
if(null == goods) {
return resp;
}
//查询appraise_order_storage
List<AppraiseOrderStorage> storageList = appraiseOrderStorageMapper.selectByOrderCodes(Lists.newArrayList(order.getOrderCode()));
if(CollectionUtils.isEmpty(storageList)) {
return resp;
}
AppraiseOrderStorage storage = storageList.get(0);
//商品信息
resp.setProductImage(ImagesHelper.getImageAbsoluteUrl(goods.getImageUrl(), ImagesConstant.BUCKET_GOODS_IMG));
resp.setProductName(goods.getProductName());
resp.setSizeName(storage.getSizeName());
resp.setProductCode(goods.getProductCode());
rebuildOrderDetailResp(order, resp);
queryStorageDeposit(resp, order.getOrderCode()); //查询寄存信息
queryAbnormalOrder(resp, order.getOrderCode());//查询异常订单信息
resp.setAttributesStr(OrderConfigConstant.getOrderAttributeStr(order.getAttributes(), RegionEnum.MAINLAND.getCode()));
return resp;
}
private void queryAbnormalOrder(AppraiseOrderResp resp, String orderCode) { // 查询异常订单信息
AbnormalOrder order = abnormalOrderMapper.selectByOrderCode(orderCode);
if(null == order) {
return;
}
resp.setAbnormalTypeStr(OrderAbnormalTypeEnum.convertAbnormalTypeStr(order.getType().byteValue()));
}
private void queryStorageDeposit(AppraiseOrderResp resp, String orderCode) { // 查询寄存信息
StorageDeposit deposit = storageDepositMapper.selectByOrderCode(orderCode);
if(null == deposit) {
return;
}
resp.setDepositCode(deposit.getDepositCode());
resp.setShelfCode(deposit.getShelfCode());
resp.setDepositStatus(deposit.getStatus());
String extraInfo = "";
resp.setPayMethod(PAY_METHOD_MONTHLY);
if(null != deposit.getOutType()) {
if(deposit.getOutType().equals(DepositOutTypeEnum.OUTTYPE_DEPOSIT_RECALL.getCode())) {
extraInfo = "(召回出库)";
}else if(deposit.getOutType().equals(DepositOutTypeEnum.OUTTYPE_DEPOSIT_FLASH_PURCHASE.getCode())) {
extraInfo = "(闪购出库)";
}else if(deposit.getOutType().equals(DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode())) {
extraInfo = "(逾期出库)";
resp.setPayMethod(PAY_METHOD_FREIGHT_COLLECT);
}
}
resp.setStatusStr(resp.getStatusStr() + extraInfo);
}
private void rebuildOrderDetailResp(AppraiseOrder order, AppraiseOrderResp resp) {
//卖家信息
resp.setSellerName(userProxyService.getUserNameByUid(order.getUid()));
AppraiseOrderMeta meta = appraiseOrderMetaMapper.selectByOrderCodeAndMetaKey(order.getOrderCode(), SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS);
if(meta != null){
JSONObject metaValue = JSONObject.parseObject(meta.getMetaValue());
resp.setSellerRebackAddressDetail(metaValue.getString("address"));
resp.setSellerRebackAddress(metaValue.getString("area"));
resp.setSellerRebackMobile(metaValue.getString("mobile"));
}
//快递结算方式
if(order.getStatus().equals(Constant.BUYER_ORDER_STATUS_APPRAISE_UNSURE)) {//寄付月结
resp.setPayMethod(PAY_METHOD_MONTHLY);
}else {
resp.setPayMethod(PAY_METHOD_FREIGHT_COLLECT);//到付
}
}
private PageResponseBO<AppraiseOrderResp> queryOrderListByStatusAndQueryStr(String queryStr, Integer depotNo,
List<Byte> checkStatusList, String platformExpressInfoFlag, String sortRule){
//先按订单号来查
... ...
... ... @@ -65,6 +65,8 @@ datasources:
- com.yoho.order.dal.AbnormalOrderMapper
- com.yoho.order.dal.AppraiseOrderMapper
- com.yoho.order.dal.AppraiseOrderGoodsMapper
- com.yoho.order.dal.AppraiseOrderStorageMapper
- com.yoho.order.dal.AppraiseOrderMetaMapper
ufo_resource:
servers:
... ...
... ... @@ -66,6 +66,8 @@ datasources:
- com.yoho.order.dal.AbnormalOrderMapper
- com.yoho.order.dal.AppraiseOrderMapper
- com.yoho.order.dal.AppraiseOrderGoodsMapper
- com.yoho.order.dal.AppraiseOrderStorageMapper
- com.yoho.order.dal.AppraiseOrderMetaMapper
ufo_resource:
servers:
... ...