Authored by caoyan

Merge branch 'dev_确认收货优化' into test6.9.7

... ... @@ -5,6 +5,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.AbnormalPackage;
import com.yoho.order.model.BuyerOrderReq;
/**
* Created by caoyan on 2019/6/24.
... ... @@ -19,5 +20,5 @@ public interface AbnormalPackageMapper {
int selectValidCnt();
List<String> selectValidSellerWaybillCodeList();
List<String> selectValidSellerWaybillCodeList(@Param("buyerOrderReq") BuyerOrderReq buyerOrderReq);
}
... ...
... ... @@ -18,13 +18,16 @@
select count(1) from abnormal_package where is_del = 0
</select>
<select id="selectValidSellerWaybillCodeList" resultType="java.lang.String">
<select id="selectValidSellerWaybillCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.BuyerOrderReq">
select seller_waybillCode from abnormal_package where is_del=0
<if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
</select>
<select id="selectBySellerWaybillCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from abnormal_package where seller_waybillCode = #{sellerWaybillCode}
from abnormal_package where is_del=0 and seller_waybillCode = #{sellerWaybillCode}
</select>
<insert id="insert" parameterType="com.yoho.order.model.AbnormalPackage">
... ...
... ... @@ -419,7 +419,14 @@ public class BuyerOrderController {
@RequestMapping(value = "/queryByOrderCodeOrWaybillCode4Qc")
public ApiResponse queryByOrderCodeOrWaybillCode4Qc(BuyerOrderReq req) {
LOGGER.info("queryByOrderCodeOrWaybillCode4Qc in. queryStr is {}", req.getQueryStr());
JSONObject result = buyerOrderService.queryOrderForQc(req.getQueryStr());
PageResponseBO<BuyerOrderResp> result = buyerOrderService.queryOrderForQc(req.getQueryStr());
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/queryByWaybillCode4Qc")
public ApiResponse queryByWaybillCode4Qc(BuyerOrderReq req) {
LOGGER.info("queryByWaybillCode4Qc in. queryStr is {}", req.getSellerWaybillCode());
JSONObject result = buyerOrderService.queryOrderBySellerWaybillCodeForQc(req.getSellerWaybillCode());
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
... ... @@ -516,6 +523,13 @@ public class BuyerOrderController {
}
}
@RequestMapping(value = "/queryAbnormalPackage")
public ApiResponse queryAbnormalPackage(BuyerOrderReq req) {
LOGGER.info("queryAbnormalPackage in. param is {}", req);
PageResponseBO<String> result = buyerOrderService.queryAbnormalPackage(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(null == result ? new PageResponseBO<BuyerOrderResp>() : result).build();
}
@RequestMapping(value = "/queryIdentifyCenter")
public ApiResponse queryIdentifyCenter() {
... ...
... ... @@ -85,7 +85,6 @@ public interface IBuyerOrderService {
PageResponseBO<BuyerOrderResp> queryByOrderCodeOrWaybillCode(String queryStr);
void submitBuyerOrderFeedback(String orderCode, String feedbackContent);
List<BuyerOrderFeedback> queryBuyerOrderFeedback(String orderCode);
... ... @@ -94,7 +93,9 @@ public interface IBuyerOrderService {
QualityCheckResp queryQualityCheck(BuyerOrderReq req);
JSONObject queryOrderForQc(String queryStr);
PageResponseBO<BuyerOrderResp> queryOrderForQc(String queryStr);
JSONObject queryOrderBySellerWaybillCodeForQc(String queryStr);
Map<String, Integer> getCountForQc(BuyerOrderReq req);
... ... @@ -115,4 +116,6 @@ public interface IBuyerOrderService {
List<IdentifyCenterResp> queryIdentifyCenter();
int addAbnormalPackage(String sellerWaybillCode);
PageResponseBO<String> queryAbnormalPackage(BuyerOrderReq req);
}
... ...
... ... @@ -635,39 +635,58 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
@Override
public JSONObject queryOrderForQc(String queryStr) {
JSONObject jsonObject = new JSONObject();
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
jsonObject.put("orderNums", 0);
jsonObject.put("receivedNums", 0);
jsonObject.put("canceledNums", 0);
jsonObject.put("orderList", result);
jsonObject.put("isExistException", 0);
public PageResponseBO<BuyerOrderResp> queryOrderForQc(String queryStr) {
if(StringUtils.isEmpty(queryStr)) {
return jsonObject;
return null;
}
//查询卖家已发货的订单
List<BuyerOrder> orderList = queryOrderByQueryStr(queryStr, null, null);
if(CollectionUtils.isEmpty(orderList)) {
return jsonObject;
return null;
}
jsonObject.replace("orderNums", orderList.size());
List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
if(CollectionUtils.isEmpty(respList)) {
return null;
}
//是否签收
buildIsSignForPackage(respList, queryStr);
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
result.setPage(1);
result.setList(respList);
result.setSize(respList.size());
result.setTotal(respList.size());
//包裹是否已签收
if(isSignedPackage(queryStr)) {
jsonObject.replace("receivedNums", orderList.size());
return result;
}
@Override
public JSONObject queryOrderBySellerWaybillCodeForQc(String sellerWaybillCode) {
JSONObject jsonObject = new JSONObject();
PageResponseBO<BuyerOrderResp> result=new PageResponseBO<>();
jsonObject.put("orderNum", 0);
jsonObject.put("receivedNum", 0);
jsonObject.put("canceledNum", 0);
jsonObject.put("orderList", result);
jsonObject.put("isExceptionPackage", 0);
jsonObject.put("exceptionBtn", 0);
jsonObject.put("receiveBtn", 0);
if(StringUtils.isEmpty(sellerWaybillCode)) {
return jsonObject;
}
//是否存在买家在卖家发货后取消的订单
int excepitonOrderTotal = getExcepitonOrderTotal(orderList);
if(excepitonOrderTotal > 0) {
jsonObject.replace("isExistException", 1);
jsonObject.replace("canceledNums", excepitonOrderTotal);
//查询订单
List<BuyerOrder> orderList = queryOrderByQueryStr(sellerWaybillCode, null, null);
if(CollectionUtils.isEmpty(orderList)) {
return jsonObject;
}
//计算附加信息
buildExtraInfo(jsonObject, orderList, sellerWaybillCode);
List<BuyerOrderResp> respList = buildBuyerOrderRespForQc(orderList);
if(CollectionUtils.isEmpty(respList)) {
return jsonObject;
... ... @@ -681,23 +700,37 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return jsonObject;
}
private int getExcepitonOrderTotal(List<BuyerOrder> orderList) {
int total = 0;
private void buildExtraInfo(JSONObject jsonObject, List<BuyerOrder> orderList, String sellerWaybillCode){
jsonObject.replace("orderNum", orderList.size());
//是否是异常包裹
AbnormalPackage pkg = abnormalPackageMapper.selectBySellerWaybillCode(sellerWaybillCode);
if(null != pkg){
jsonObject.replace("isExceptionPackage", 1);//是异常包裹
}
//是否存在买家在卖家发货后取消的订单
int canceledNum = 0;
int receivedNum = 0;
for(BuyerOrder order : orderList) {
if(order.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())) {
total += 1;
if(order.getStatus().equals(Constant.BUYER_ORDER_STATUS_BUYER_CANCEL_AFTER_SELLER_DELIVERY.getByteVal())
|| order.getStatus().equals(Constant.CS_CANCEL_BEFORE_DEPOT_RECEIVE.getByteVal())) {
canceledNum += 1;
}else if(!order.getStatus().equals(Constant.BUYER_ORDER_STATUS_ALLOCATING.getByteVal())){
receivedNum +=1;
}
}
return total;
if(canceledNum > 0) {
jsonObject.replace("exceptionBtn", jsonObject.getIntValue("isExceptionPackage") == 1 ? 0: 1);//0:按钮不展示 1:按钮展示
jsonObject.replace("canceledNum", canceledNum);
jsonObject.replace("receiveBtn", 0);
}
private boolean isSignedPackage(String sellerWaybillCode){
BuyerOrderReq buyerOrderReq = new BuyerOrderReq();
buyerOrderReq.setSellerWaybillCode(sellerWaybillCode);
List<SignForPackage> sfpList = signForPackageMapper.selectByCondition(buyerOrderReq);
return CollectionUtils.isNotEmpty(sfpList);
jsonObject.replace("receivedNum", receivedNum);
if(orderList.size() - receivedNum - canceledNum > 0 && canceledNum == 0){
jsonObject.replace("receiveBtn", jsonObject.getIntValue("isExceptionPackage") == 1 ? 0: 1);//0:按钮不展示 1:按钮展示
}
}
private void buildIsSignForPackage(List<BuyerOrderResp> respList, String sellerWaybillCode) {
... ... @@ -2505,6 +2538,22 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return abnormalPackageMapper.insert(pkg);
}
@Override
public PageResponseBO<String> queryAbnormalPackage(BuyerOrderReq req){
int total = abnormalPackageMapper.selectValidCnt();
if(total == 0){
return null;
}
List<String> list = abnormalPackageMapper.selectValidSellerWaybillCodeList(req);
PageResponseBO<String> result=new PageResponseBO<>();
result.setPage(req.getPage());
result.setList(list);
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
private JSONObject updateBuyerReceiveInfo(BuyerOrderReq req, String oldMetaValue, Integer buyerUid) {
JSONObject metaValue = JSONObject.parseObject(oldMetaValue);
metaValue.replace("consignee", req.getReceiveName());
... ...