Authored by chenchao

add statistic 4 all sub order of one order

... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.yoho.message.sdk.common.model.SendMessageRspBo;
import com.yoho.message.sdk.service.ufo.IUFOSendService;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.bo.DepositOrderStatisticInfo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohobuy.ufo.model.order.vo.GoodsVo;
... ... @@ -18,6 +19,7 @@ import com.yohoufo.inboxclient.model.InBoxResponse;
import com.yohoufo.inboxclient.model.InboxReqVO;
import com.yohoufo.inboxclient.sdk.InBoxSDK;
import com.yohoufo.order.service.impl.function.BuyerNoticeSender;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import com.yohoufo.order.utils.NamedThreadFactory;
import com.yohoufo.order.utils.PaymentHelper;
import lombok.NonNull;
... ... @@ -77,6 +79,9 @@ public class InBoxFacade extends BaseNoticeFacade{
@Autowired
private BuyerNoticeFacade buyerNoticeFacade;
@Autowired
private SellerDepositOrderService sellerDepositOrderService;
@Override
public Logger getLogger() {
return log;
... ... @@ -1033,6 +1038,8 @@ public class InBoxFacade extends BaseNoticeFacade{
.build();
}
public void sellerDepositOrderNotice(int uid,long orderCode, AppraiseOrderStatus targetStatus){
log.info("enter sellerDepositOrderNotice uid {} orderCode {} targetStatus {}", uid, orderCode, targetStatus);
try {
... ... @@ -1112,11 +1119,15 @@ public class InBoxFacade extends BaseNoticeFacade{
break;
case FINISH:
//订单编号{},申请{}件,实收{}件,鉴定通过{}件,鉴定为假{}件,无法鉴定{}件,鉴定瑕疵{}件
DepositOrderStatisticInfo statisticInfo = sellerDepositOrderService.getAppraiseProgress(uid, orderCode);
inboxType = InboxBusinessTypeEnum.NOTICE_SELLER_DEPOSIT_ORDER_FINISH_APPRAISE_SUMMARY;
inboxParams = new Object[]{orderCode};
inboxParams = new Object[]{orderCode, statisticInfo.getApplyTotal(), statisticInfo.getReceiveTotal(),
statisticInfo.getPassNum(), statisticInfo.getFakeNum(), statisticInfo.getUnsureNum(),
statisticInfo.getFlawNum()};
//sms
smsType = InboxBusinessTypeEnum.SMS_NOTICE_SELLER_DEPOSIT_ORDER_FINISH_APPRAISE_SUMMARY;
smsParams = new Object[]{orderCode};
smsParams = inboxParams;
break;
}
... ...
... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderBo;
import com.yohobuy.ufo.model.order.bo.DepositOrderStatisticInfo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
... ... @@ -53,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
... ... @@ -594,17 +596,77 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
public List<AppraiseOrderBo> getSubOrderStatistic(long orderCode){
List<AppraiseOrder> paoList = buildSubOrderStatisticList(orderCode);
return paoList.parallelStream().map(pao->AppraiseOrderBo.builder()
.parentOrderCode(pao.getParentOrderCode())
.orderCode(orderCode).status(pao.getStatus()).statusCnt(pao.getStatusCnt()).build())
.collect(Collectors.toList());
}
private List<AppraiseOrder> buildSubOrderStatisticList(long orderCode){
AppraiseOrder appraiseOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
if (Objects.isNull(appraiseOrder)){
logger.warn("in getSubOrderStatistic selectByOrderCode null, orderCode {}", orderCode);
return null;
return new ArrayList<>(0);
}
long occ = appraiseOrder.getParentOrderCode()==null ? orderCode : appraiseOrder.getParentOrderCode();
List<AppraiseOrder> paoList = appraiseOrderMapper.selectSubOrderStatistic(occ);
logger.info("getSubOrderStatistic orderCode {} ParentOrderCode {} AppraiseOrder list {}", orderCode, occ, paoList);
return paoList.parallelStream().map(pao->AppraiseOrderBo.builder()
.parentOrderCode(pao.getParentOrderCode())
.orderCode(orderCode).status(pao.getStatus()).statusCnt(pao.getStatusCnt()).build())
.collect(Collectors.toList());
return paoList;
}
public DepositOrderStatisticInfo getAppraiseProgress(int uid, long orderCode){
List<AppraiseOrder> paoList = buildSubOrderStatisticList(orderCode);
//申请
int applyTotal = 0;
int shamNum = 0;
//鉴定为假
Integer fakeNum = 0;
//无法鉴定
Integer unsureNum = 0;
//鉴定通过
Integer passNum = 0;
//鉴定瑕疵
Integer flawNum = 0;
int waitingAppraiseNum = 0;
for (AppraiseOrder pao : paoList){
int cnt = pao.getStatusCnt();
AppraiseOrderStatus orderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
switch (orderStatus){
case SHAM_SEND_OUT:
shamNum = cnt;
break;
case PLATFORM_APPRAISE_UNSURE:
unsureNum = cnt;
break;
case JUDGE_PASS:
passNum = cnt;
break;
case CHECKING_FAKE:
fakeNum = cnt;
break;
case QUALITY_CHECK_FAKE:
flawNum = cnt;
break;
case PLATFORM_RECEIVE:
waitingAppraiseNum = cnt;
break;
}
applyTotal += cnt;
}
//实收
Integer receiveTotal = applyTotal - shamNum;
DepositOrderStatisticInfo dosi = DepositOrderStatisticInfo.builder()
.applyTotal(applyTotal)
.unsureNum(unsureNum)
.passNum(passNum)
.fakeNum(fakeNum)
.flawNum(flawNum)
.receiveTotal(receiveTotal)
.waitingAppraiseNum(waitingAppraiseNum)
.build();
return dosi;
}
}
... ...