Commit 4dd100e3 authored by shiyu's avatar shiyu

换藏订单数量统计

parent f6e6a537
......@@ -166,5 +166,13 @@ public interface DistributionOrderDao {
List<DistributionOrderNum> countGroupByStateForUser(long userId);
/**
* 统计换藏订单各状态数量
* @param userId
* @return
*/
List<DistributionOrderNum> countGroupByStateForExchange(long userId);
boolean isBuyItem(long buyerId, long itemId);
}
......@@ -230,6 +230,11 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
return distributionOrderMapper.countGroupByStateForUser(userId);
}
@Override
public List<DistributionOrderNum> countGroupByStateForExchange(long userId) {
return distributionOrderMapper.countGroupByStateForExchange(userId);
}
@Override
public boolean isBuyItem(long buyerId, long itemId) {
DistributionOrderExample example = new DistributionOrderExample();
......
......@@ -90,8 +90,6 @@ public interface DistributionOrderMapper {
*/
long sumAmountByIntroducer(@Param("introducerId")Long introducerId, @Param("sellerId")Long sellerId);
/**
* 统计用户各状态的订单数量
* @param userId
......@@ -99,6 +97,13 @@ public interface DistributionOrderMapper {
*/
List<DistributionOrderNum> countGroupByStateForUser(@Param("buyerId")Long userId);
/**
* 统计换藏订单各状态订单数量
* @param userId
* @return
*/
List<DistributionOrderNum> countGroupByStateForExchange(@Param("buyerId")Long userId);
Long countSelledNum(@Param("itemId")Long itemId);
......
......@@ -779,15 +779,21 @@
limit 1
</select>
<select id="countGroupByStateForDistributor" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where seller_id = #{sellerId} group by state
select state, count(distribution_order_id) as num from distribution_order where seller_id = #{sellerId} and type != 7 group by state
</select>
<select id="countGroupByStateForCollector" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where seller_id = #{sellerId} group by state
select state, count(distribution_order_id) as num from distribution_order where seller_id = #{sellerId} and type != 7 group by state
</select>
<!--排除换藏订单,换藏订单单独列出来-->
<select id="countGroupByStateForUser" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where buyer_id = #{buyerId} group by state
select state, count(distribution_order_id) as num from distribution_order where buyer_id = #{buyerId} and type != 7 group by state
</select>
<!--换藏订单单独列出来-->
<select id="countGroupByStateForExchange" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where buyer_id = #{buyerId} and type = 7 and state in (6, 8, 10, 20) group by state
</select>
<select id="countSelledNum" parameterType="java.lang.Long" resultType="java.lang.Long">
......
......@@ -55,16 +55,25 @@ public class SelfPageInfoVo implements Entity {
*/
private List<DistributionOrderNum> orderNum;
/**
* 换藏订单各状态数量
*/
private List<DistributionOrderNum> exchangeOrderNum;
/**
* 商家卖出去的商品订单
*/
private List<DistributionOrderNum> orderNumForDistributor;
/**
* 藏家卖出去的商品订单
*/
private List<DistributionOrderNum> orderNumForCollector;
/**
* 交换申请单数量
*/
private Long exchangeApplyOrderNum;
}
......@@ -14,6 +14,7 @@ import com.wwdz.ch.db.dao.FollowFansRecordDao;
import com.wwdz.ch.db.dao.SwitchDao;
import com.wwdz.ch.db.dao.UserDao;
import com.wwdz.ch.db.dao.distribution.*;
import com.wwdz.ch.db.dao.exchange.ExchangeApplyOrderDao;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.AuctionConfig;
import com.wwdz.ch.db.domain.distribution.AuctionRecord;
......@@ -41,10 +42,7 @@ import org.springframework.util.ObjectUtils;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -84,15 +82,23 @@ public class SelfPageServiceImpl implements SelfPageService {
@Autowired
UserDao userDao;
@Reference
ShopReadService shopReadService;
@Autowired
ShopWhiteListDao shopWhiteListDao;
@Autowired
CollectorWhiteListDao collectorWhiteListDao;
@Autowired
ExchangeApplyOrderDao exchangeApplyOrderDao;
/**
* PRE_EXCHANGE(6, "待寄至平台"),
* PRE_INSPECTION(8, "待平台验货"),
* PRE_SEND(10, "待发货"),
* PRE_SIGNED(20, "待收货"),
*/
private final static List<Integer> EXCHANGE_ORDER_STATE_LIST = Arrays.asList(6, 8, 10, 20);
@Override
public Result getDistributorPageInfo(SelfPageRequestDto dto) {
......@@ -184,6 +190,28 @@ public class SelfPageServiceImpl implements SelfPageService {
});
selfPageInfoVo.setOrderNum(selfBuyNumList);
//换藏订单各状态数量统计
List<DistributionOrderNum> exchangeOrderNumList = distributionOrderDao.countGroupByStateForExchange(dto.getUserId());
List<Integer> exchangeOrderStateList = exchangeOrderNumList.stream().map(DistributionOrderNum::getState).collect(Collectors.toList());
exchangeOrderNumList.forEach(s -> {
s.setStateName(DistributionEnum.DistributionOrderStateEnum.getNameByCode(s.getState()));
});
for (int state : EXCHANGE_ORDER_STATE_LIST) {
if (!exchangeOrderStateList.contains(state)) {
DistributionOrderNum distributionOrderNum = new DistributionOrderNum();
distributionOrderNum.setState(state);
distributionOrderNum.setStateName(DistributionEnum.DistributionOrderStateEnum.getNameByCode(state));
distributionOrderNum.setNum(0);
exchangeOrderNumList.add(distributionOrderNum);
}
}
selfPageInfoVo.setExchangeOrderNum(exchangeOrderNumList);
//统计申请单数量,我提交的和我收到的
long commitNum = exchangeApplyOrderDao.countPreHandleOrderOfCommit(dto.getUserId());
long receiveNum = exchangeApplyOrderDao.countPreHandleOrderOfReceive(dto.getUserId());
selfPageInfoVo.setExchangeApplyOrderNum(commitNum + receiveNum);
//查询4天内出价记录
Date now = new Date();
Instant instant = now.toInstant().minus(Duration.ofDays(4));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment