|
@@ -4,9 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qs.mp.admin.domain.Goods;
|
|
|
import com.qs.mp.admin.domain.vo.GoodsVO;
|
|
|
import com.qs.mp.admin.service.IGoodsService;
|
|
|
+import com.qs.mp.channel.domain.ChannelGoods;
|
|
|
+import com.qs.mp.channel.domain.param.SiteGoodsForChannelQueryParam;
|
|
|
import com.qs.mp.channel.domain.param.SiteGoodsQueryParam;
|
|
|
+import com.qs.mp.channel.domain.vo.ChannelGoodsVO;
|
|
|
+import com.qs.mp.channel.service.IChannelGoodsService;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
+import com.qs.mp.common.enums.ChannelGoodsSettleStatusTypeEnum;
|
|
|
+import com.qs.mp.utils.SecurityUtils;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -18,7 +24,11 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author zhangkaikai
|
|
@@ -33,6 +43,9 @@ public class ChannelGoodsController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IGoodsService goodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IChannelGoodsService channelGoodsService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private MapperFacade mapperFacade;
|
|
|
|
|
@@ -43,9 +56,10 @@ public class ChannelGoodsController extends BaseApiController {
|
|
|
)
|
|
|
public TableDataInfo siteGoodsList(@RequestBody SiteGoodsQueryParam param) {
|
|
|
|
|
|
+ startPage();
|
|
|
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
|
|
|
queryWrapper.eq("type", param.getType())
|
|
|
- .orderByDesc("create_time");
|
|
|
+ .orderByDesc("created_time");
|
|
|
List<Goods> goodsList = goodsService.list(queryWrapper);
|
|
|
|
|
|
List<GoodsVO> goodsVOList = mapperFacade.mapAsList(goodsList, GoodsVO.class);
|
|
@@ -64,6 +78,55 @@ public class ChannelGoodsController extends BaseApiController {
|
|
|
return AjaxResult.success(goodsVO);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/goods/list/channel")
|
|
|
+ @ApiOperation("门店铺设商品列表")
|
|
|
+ @ApiResponses(
|
|
|
+
|
|
|
+ @ApiResponse(code = 200, message = "成功", response = ChannelGoodsVO.class)
|
|
|
+ )
|
|
|
+ public TableDataInfo goodsListChannel(@RequestBody SiteGoodsForChannelQueryParam param) {
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+
|
|
|
+ QueryWrapper<ChannelGoods> wrapper = new QueryWrapper<ChannelGoods>().eq("t1.channel_id", channelId).eq("t1.status", param.getSettleStatus());
|
|
|
+ if (ChannelGoodsSettleStatusTypeEnum.NO.getValue().equals(param.getSettleStatus())) {
|
|
|
+ wrapper.orderByAsc("t1.remain_qty");
|
|
|
+ wrapper.orderByDesc("t1.create_time");
|
|
|
+ } else {
|
|
|
+ wrapper.orderByDesc("t1.settle_time");
|
|
|
+ }
|
|
|
+ List<ChannelGoodsVO> channelGoodsList = channelGoodsService.listChannelGoods(wrapper);
|
|
|
+ return getDataTable(channelGoodsList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("goods/list/under/channel")
|
|
|
+ @ApiOperation("渠道下门店库存列表")
|
|
|
+ public TableDataInfo goodsListUnderChannel() {
|
|
|
+ startPage();
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ QueryWrapper<ChannelGoods> wrapper = new QueryWrapper<ChannelGoods>().eq("t3.channel_id", channelId);
|
|
|
+ List<ChannelGoodsVO> channelGoodsVOs = channelGoodsService.listChannelGoodsUnderChannel(wrapper);
|
|
|
+ Map<Long, List<ChannelGoodsVO>> map = channelGoodsVOs.stream().collect(Collectors.groupingBy(ChannelGoodsVO::getChannelId));
|
|
|
+ List<ChannelGoodsVO> channelGoodsVOList = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, List<ChannelGoodsVO>> entry : map.entrySet()) {
|
|
|
+ ChannelGoodsVO channelGoodsVO = new ChannelGoodsVO();
|
|
|
+ List<ChannelGoodsVO> value = entry.getValue();
|
|
|
+ int totalQuantity = value.stream().mapToInt(ChannelGoods::getQuantity).sum();
|
|
|
+ int totalVerQuantity = value.stream().mapToInt(ChannelGoods::getVerifyQty).sum();
|
|
|
+ int remainTotalQuantity = value.stream().mapToInt(ChannelGoodsVO::getRemainQty).sum();
|
|
|
+ int deepQuantity = value.stream().mapToInt(ChannelGoods::getRemainQty).min().getAsInt();
|
|
|
+ channelGoodsVO.setTotalQuantity(totalQuantity);
|
|
|
+ channelGoodsVO.setTotalVerQuantity(totalVerQuantity);
|
|
|
+ channelGoodsVO.setRemainTotalQuantity(remainTotalQuantity);
|
|
|
+ channelGoodsVO.setDeepQuantity(deepQuantity);
|
|
|
+ channelGoodsVO.setChannelId(value.get(0).getChannelId());
|
|
|
+ channelGoodsVO.setChannelName(value.get(0).getChannelName());
|
|
|
+ channelGoodsVOList.add(channelGoodsVO);
|
|
|
+ }
|
|
|
+ TableDataInfo info = getDataTable(channelGoodsVOs);
|
|
|
+ info.setRows(channelGoodsVOList);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|