Authored by caoyan

质检优化

package com.yoho.order.dal;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.AbnormalOrder;
/**
* Created by caoyan on 2019/7/29.
*/
public interface AbnormalOrderMapper {
AbnormalOrder selectByOrderCode(@Param("orderCode") String orderCode);
int insert(AbnormalOrder abnormalOrder);
int update(AbnormalOrder abnormalOrder);
}
... ...
package com.yoho.order.model;
import java.io.Serializable;
/**
* @author caoyan
* @date 2019/7/29
*/
public class AbnormalOrder implements Serializable {
private static final long serialVersionUID = 2607922995706119816L;
private Integer id;
private String orderCode;
private Integer type;
private Integer createTime;
private Integer operateUid;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getOperateUid() {
return operateUid;
}
public void setOperateUid(Integer operateUid) {
this.operateUid = operateUid;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "AbnormalOrder{" +
"id=" + id +
", orderCode='" + orderCode + '\'' +
", type='" + type + '\'' +
", createTime='" + createTime + '\'' +
", operateUid='" + operateUid + '\'' +
", updateTime='" + updateTime + '\'' +
'}';
}
}
... ...
... ... @@ -136,4 +136,6 @@ public class BuyerOrderReq extends PageRequestBO{
private Integer region;//0:大陆 1:香港
private String settleFailReason;
private Integer abnormalType;//订单异常类型,1:卖家多发货 2:卖家少发货 3:卖家发错货
}
... ...
<?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.AbnormalOrderMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.AbnormalOrder">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="operate_uid" property="operateUid" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, order_code, type, create_time, operate_uid, update_time
</sql>
<insert id="insert" parameterType="com.yoho.order.model.AbnormalOrder">
insert into abnormal_order(order_code, type, create_time, operate_uid, update_time)
values (#{orderCode}, #{type}, #{createTime}, #{operateUid}, #{updateTime})
</insert>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from abnormal_order where order_code = #{orderCode}
</select>
<update id="update" parameterType="com.yoho.order.model.AbnormalOrder">
update abnormal_order set type=#{type}, operate_uid=#{operateUid}, update_time=#{updateTime}
where order_code=#{orderCode}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -673,4 +673,14 @@ public class BuyerOrderController {
boolean result = buyerOrderService.queryIsDepotNoDiffer(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/updateAbnormalOrder")
public ApiResponse updateAbnormalOrder(BuyerOrderReq req) {
LOGGER.info("updateAbnormalOrder in. param is {}", req);
if(StringUtils.isEmpty(req.getOrderCode()) || null == req.getAbnormalType()) {
return new ApiResponse.ApiResponseBuilder().data("").code(400).message("订单号或异常类型不能为空").build();
}
int result = buyerOrderService.updateAbnormalOrder(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("操作成功").data(result).build();
}
}
... ...
... ... @@ -156,4 +156,6 @@ public interface IBuyerOrderService {
int updateAbnormalPackageToDealed(String sellerWaybillCode);
boolean queryIsDepotNoDiffer(BuyerOrderReq req);
int updateAbnormalOrder(BuyerOrderReq req);
}
... ...
... ... @@ -45,6 +45,7 @@ import com.yoho.core.redis.cluster.operations.nosync.YHValueOperations;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.AbnormalOrderMapper;
import com.yoho.order.dal.AbnormalPackageMapper;
import com.yoho.order.dal.AppraiseAddressMapper;
import com.yoho.order.dal.BuyerOrderGoodsMapper;
... ... @@ -68,6 +69,7 @@ import com.yoho.order.dal.SignForPackageMapper;
import com.yoho.order.dal.StorageDepositMapper;
import com.yoho.order.dal.StoredSellerMapper;
import com.yoho.order.dal.ZhimaCertMapper;
import com.yoho.order.model.AbnormalOrder;
import com.yoho.order.model.AbnormalPackage;
import com.yoho.order.model.AppraiseAddress;
import com.yoho.order.model.BuyerOrder;
... ... @@ -273,6 +275,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
private ProductSortMapper productSortMapper;
@Autowired
private AbnormalOrderMapper abnormalOrderMapper;
@Autowired
private ClearanceRecordService clearanceRecordService;
private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
... ... @@ -1218,15 +1223,36 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
return true;//一致
}
@Override
public int updateAbnormalOrder(BuyerOrderReq req) {
AbnormalOrder order = abnormalOrderMapper.selectByOrderCode(req.getOrderCode());
int num = 0;
if(null != order) {
order.setOperateUid(new UserHelper().getUserId());
order.setUpdateTime(DateUtil.getCurrentTimeSeconds());
order.setType(req.getAbnormalType());
num = abnormalOrderMapper.update(order);
}else {
order = new AbnormalOrder();
order.setOrderCode(req.getOrderCode());
order.setType(req.getAbnormalType());
order.setCreateTime(DateUtil.getCurrentTimeSeconds());
order.setOperateUid(new UserHelper().getUserId());
abnormalOrderMapper.insert(order);
}
return num;
}
private String convertDepotNoStr(Integer depotNo) {
if(null == depotNo) {
return "";
}
if(depotNo.equals(DEPOT_NO_BEIJING)) {
return "南京";
}else if(depotNo.equals(DEPOT_NO_NANJING)) {
return "北京";
}else if(depotNo.equals(DEPOT_NO_NANJING)) {
return "南京";
}else if(depotNo.equals(DEPOT_NO_HONGKONG)) {
return "香港";
}
... ... @@ -2485,6 +2511,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
queryProductLimitInfo(resp, sellerGoods.getProductId(), buyerOrder.getSellerUid()); // 独家标识
queryStorageDeposit(resp, buyerOrder.getOrderCode()); //查询寄存信息
queryAbnormalOrder(resp, buyerOrder.getOrderCode());//查询异常订单信息
resp.setAttributesStr(OrderConfigConstant.getOrderAttributeStr(buyerOrder.getAttributes(), sellerGoods.getRegion()));
... ... @@ -3939,7 +3967,24 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
}
resp.setStatusStr(resp.getStatusStr() + extraInfo);
}
private void queryAbnormalOrder(QcOrderDetailResp resp, String orderCode) { // 查询异常订单信息
AbnormalOrder order = abnormalOrderMapper.selectByOrderCode(orderCode);
if(null == order) {
return;
}
resp.setAbnormalTypeStr(convertAbnormalType(order.getType()));
}
private String convertAbnormalType(Integer type) {
switch(type) {
case 1: return "卖家多发货";
case 2: return "卖家少发货";
case 3: return "卖家发错货";
default: return "";
}
}
/**
* 根据订单号查询具体的物流公司
... ...
... ... @@ -252,10 +252,9 @@ public class StorageDepositServiceImpl implements IStorageDepositService, IBusin
}
}
//4、校验货位号是否存在
DepositShelfCode shelfCodeDb = depositShelfCodeMapper.selectByShelfCode(shelfCode);
if(null == shelfCodeDb || !shelfCode.startsWith("U")) {
throw new ServiceException(400, "货位号:"+shelfCode+"不存在或格式错误");
//4、校验货位号格式
if(StringUtils.isNotEmpty(shelfCode) && !shelfCode.startsWith("U")) {
throw new ServiceException(400, "货位号:"+shelfCode+"格式错误");
}
String orderNoStr = shelfCode.replace("U", "").replace("-", "");
... ... @@ -534,6 +533,13 @@ public class StorageDepositServiceImpl implements IStorageDepositService, IBusin
req.setDepotNo(depotNo);
req.setSize(100);
list = storageDepositMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(list)){//按货位号来查
req = new StorageDepositReq();
req.setShelfCode(queryStr);
req.setDepotNo(depotNo);
req.setSize(100);
list = storageDepositMapper.selectByCondition(req);
}
if(CollectionUtils.isEmpty(list)){
return Lists.newArrayList();
}
... ...
... ... @@ -62,6 +62,7 @@ datasources:
- com.yoho.order.dal.ClearanceRecordMapper
- com.yoho.order.dal.ProductSizeMapper
- com.yoho.order.dal.DepositShelfCodeMapper
- com.yoho.order.dal.AbnormalOrderMapper
ufo_resource:
servers:
... ...
... ... @@ -63,6 +63,7 @@ datasources:
- com.yoho.order.dal.ClearanceRecordMapper
- com.yoho.order.dal.ProductSizeMapper
- com.yoho.order.dal.DepositShelfCodeMapper
- com.yoho.order.dal.AbnormalOrderMapper
ufo_resource:
servers:
... ...