Commit cd42f1bf by caiyt

周度提交

parent b0471a51
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import java.util.List;
import com.soss.system.domain.Goods;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.soss.common.annotation.Log; import com.soss.common.annotation.Log;
import com.soss.common.core.controller.BaseController; import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType; import com.soss.common.enums.BusinessType;
import com.soss.system.domain.Goods;
import com.soss.system.domain.ShopRecommend; import com.soss.system.domain.ShopRecommend;
import com.soss.system.service.IGoodsService;
import com.soss.system.service.IShopRecommendService; import com.soss.system.service.IShopRecommendService;
import com.soss.common.core.page.TableDataInfo; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* 推荐和今日特惠Controller * 推荐和今日特惠Controller
* *
* @author zxq * @author zxq
* @date 2022-04-28 * @date 2022-04-28
*/ */
@RestController @RestController
@RequestMapping("/system/recommend") @RequestMapping("/system/recommend")
public class ShopRecommendController extends BaseController public class ShopRecommendController extends BaseController {
{
@Autowired @Autowired
private IShopRecommendService shopRecommendService; private IShopRecommendService shopRecommendService;
@Autowired
private IGoodsService goodsService;
@GetMapping("/turn") @GetMapping("/turn")
public AjaxResult turn(Long shopId,String goodsId,String pointer,String type) public AjaxResult turn(Long shopId, String goodsId, String pointer, String type) {
{ return AjaxResult.success(shopRecommendService.turn(shopId, goodsId, pointer, type));
return AjaxResult.success(shopRecommendService.turn(shopId,goodsId,pointer,type));
} }
/** /**
* 查询推荐和今日特惠列表 * 查询推荐和今日特惠列表
*/ */
// @PreAuthorize("@ss.hasPermi('system:recommend:list')") // @PreAuthorize("@ss.hasPermi('system:recommend:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(ShopRecommend shopRecommend) public TableDataInfo list(ShopRecommend shopRecommend) {
{
startPage(); startPage();
List<Goods> list = shopRecommendService.selectShopRecommendList(shopRecommend); List<Goods> list = shopRecommendService.selectShopRecommendList(shopRecommend);
goodsService.resolverCategoryName(list);
goodsService.resolverGoodsVolume(Long.parseLong(shopRecommend.getShopId()), list);
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 获取推荐和今日特惠详细信息 * 获取推荐和今日特惠详细信息
*/ */
......
...@@ -74,4 +74,9 @@ public interface OrderDetailMapper { ...@@ -74,4 +74,9 @@ public interface OrderDetailMapper {
void bindRefund(@Param("refundId") Long refundId, @Param("ids") List<Long> ids); void bindRefund(@Param("refundId") Long refundId, @Param("ids") List<Long> ids);
void updateRefundState(@Param("refundId") Long refundId, @Param("refundTime") Date refundTime); void updateRefundState(@Param("refundId") Long refundId, @Param("refundTime") Date refundTime);
/**
* 查询店铺商品销量
*/
List<OrderDetail> selectGoodsSalesVolume(@Param("shopId") Long shopId, @Param("goodsIds") List<Long> goodsIds);
} }
...@@ -32,6 +32,8 @@ public interface IGoodsService ...@@ -32,6 +32,8 @@ public interface IGoodsService
*/ */
public List<Goods> selectGoodsList(Goods goods); public List<Goods> selectGoodsList(Goods goods);
void resolverGoodsVolume(Long shopId, List<Goods> goodsList);
void resolverCategoryName(List<Goods> goodsList); void resolverCategoryName(List<Goods> goodsList);
/** /**
......
...@@ -48,6 +48,8 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -48,6 +48,8 @@ public class GoodsServiceImpl implements IGoodsService
@Autowired @Autowired
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Autowired @Autowired
private OrderDetailMapper orderDetailMapper;
@Autowired
private GoodsCategoryMapper goodsCategoryMapper; private GoodsCategoryMapper goodsCategoryMapper;
@Autowired @Autowired
private ShopRecommendMapper shopRecommendMapper; private ShopRecommendMapper shopRecommendMapper;
...@@ -91,18 +93,39 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -91,18 +93,39 @@ public class GoodsServiceImpl implements IGoodsService
public List<Goods> selectGoodsList(Goods goods) { public List<Goods> selectGoodsList(Goods goods) {
List<Goods> goodsList = goodsMapper.selectGoodsList(goods); List<Goods> goodsList = goodsMapper.selectGoodsList(goods);
this.resolverCategoryName(goodsList); this.resolverCategoryName(goodsList);
for (Goods good : goodsList) { this.resolverGoodsVolume(null, goodsList);
/*for (Goods good : goodsList) {
int count = orderMapper.selectSalesVolume(null, good.getId()); int count = orderMapper.selectSalesVolume(null, good.getId());
good.setSalesVolume(count); good.setSalesVolume(count);
} }*/
return goodsList; return goodsList;
} }
@Override @Override
public void resolverGoodsVolume(Long shopId, List<Goods> goodsList) {
if (CollectionUtils.isEmpty(goodsList)) {
return;
}
/** 销量解析 */
List<Long> goodsIds = goodsList.stream().map(Goods::getId).collect(Collectors.toList());
List<OrderDetail> orderDetails = orderDetailMapper.selectGoodsSalesVolume(shopId, goodsIds);
Map<Long, String> goodsVolumeMap = orderDetails.stream().collect(Collectors.toMap(OrderDetail::getGoodsId, OrderDetail::getNum));
goodsList.forEach(goods -> {
String volumeVal = goodsVolumeMap.get(goods.getId());
Integer volume = StringUtils.isNotEmpty(volumeVal) ? Integer.parseInt(volumeVal) : 0;
goods.setSalesVolume(volume);
});
}
@Override
public void resolverCategoryName(List<Goods> goodsList) { public void resolverCategoryName(List<Goods> goodsList) {
if (CollectionUtils.isEmpty(goodsList)) { if (CollectionUtils.isEmpty(goodsList)) {
return; return;
} }
/** 品类解析 */
List<Long> categoryIds = new ArrayList<>(16); List<Long> categoryIds = new ArrayList<>(16);
goodsList.forEach(good -> { goodsList.forEach(good -> {
String[] categoryIdArr = good.getCategory().split(StringPool.COMMA); String[] categoryIdArr = good.getCategory().split(StringPool.COMMA);
...@@ -117,6 +140,7 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -117,6 +140,7 @@ public class GoodsServiceImpl implements IGoodsService
}); });
List<GoodsCategory> categories = goodsCategoryMapper.selectGoodsCategoryByIds(categoryIds); List<GoodsCategory> categories = goodsCategoryMapper.selectGoodsCategoryByIds(categoryIds);
Map<Long, String> categoryMap = categories.stream().collect(Collectors.toMap(GoodsCategory::getId, GoodsCategory::getName)); Map<Long, String> categoryMap = categories.stream().collect(Collectors.toMap(GoodsCategory::getId, GoodsCategory::getName));
goodsList.forEach(good -> { goodsList.forEach(good -> {
String categoryName = Arrays.stream(good.getCategory().split(StringPool.COMMA)).filter(StringUtils::isNotEmpty) String categoryName = Arrays.stream(good.getCategory().split(StringPool.COMMA)).filter(StringUtils::isNotEmpty)
.map(Long::parseLong).map(categoryMap::get) .map(Long::parseLong).map(categoryMap::get)
......
...@@ -14,6 +14,7 @@ import org.springframework.util.CollectionUtils; ...@@ -14,6 +14,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -68,7 +69,14 @@ public class OrderTakingServiceImpl { ...@@ -68,7 +69,14 @@ public class OrderTakingServiceImpl {
orderTakingVo.setShopState(shop.getState()); orderTakingVo.setShopState(shop.getState());
ImagesVo imagesVo = new ImagesVo(); ImagesVo imagesVo = new ImagesVo();
orderTakingVo.setImages(imagesVo); orderTakingVo.setImages(imagesVo);
imagesVo.setLeft(JSONArray.parseArray(sysConfigService.selectConfigByKey("menu.left"))); String menuLeft = sysConfigService.selectConfigByKey("menu.left");
if (StringUtils.isNotEmpty(menuLeft)) {
if (menuLeft.startsWith("[")) {
imagesVo.setLeft(JSONArray.parseArray(menuLeft));
} else {
imagesVo.setLeft(JSONArray.parseArray(JSONArray.toJSONString(Collections.singletonList(menuLeft))));
}
}
// imagesVo.setRight(JSONObject.parseObject(sysConfigService.selectConfigByKey("menu.right"))); // imagesVo.setRight(JSONObject.parseObject(sysConfigService.selectConfigByKey("menu.right")));
orderTakingVo.setCountOfOrder(sysConfigService.selectConfigByKey("goods.limit")); orderTakingVo.setCountOfOrder(sysConfigService.selectConfigByKey("goods.limit"));
orderTakingVo.setTips(sysConfigService.selectConfigByKey("tips.address")); orderTakingVo.setTips(sysConfigService.selectConfigByKey("tips.address"));
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.Goods; import com.soss.system.domain.Goods;
import com.soss.system.domain.Machine; import com.soss.system.domain.Machine;
import com.soss.system.domain.ShopGoods; import com.soss.system.domain.ShopRecommend;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.mapper.GoodsCategoryMapper; import com.soss.system.mapper.GoodsCategoryMapper;
import com.soss.system.mapper.MachineMapper; import com.soss.system.mapper.MachineMapper;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.soss.system.mapper.ShopRecommendMapper; import com.soss.system.mapper.ShopRecommendMapper;
import com.soss.system.domain.ShopRecommend;
import com.soss.system.service.IShopRecommendService; import com.soss.system.service.IShopRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 推荐和今日特惠Service业务层处理 * 推荐和今日特惠Service业务层处理
...@@ -61,10 +60,10 @@ public class ShopRecommendServiceImpl implements IShopRecommendService ...@@ -61,10 +60,10 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
{ {
List<Goods> goodsList = shopRecommendMapper.selectShopRecommendGoods(shopRecommend.getShopId(),shopRecommend.getType()); List<Goods> goodsList = shopRecommendMapper.selectShopRecommendGoods(shopRecommend.getShopId(),shopRecommend.getType());
goodsList = goodsList.stream().distinct().collect(Collectors.toList()); goodsList = goodsList.stream().distinct().collect(Collectors.toList());
for (Goods goods : goodsList) { /*for (Goods goods : goodsList) {
goods.setCategoryName(goodsCategoryMapper.selectGoodsCategoryById(String.valueOf(goods.getCategory())).getName()); goods.setCategoryName(goodsCategoryMapper.selectGoodsCategoryById(String.valueOf(goods.getCategory())).getName());
goods.setSalesVolume(orderMapper.selectSalesVolume(Long.parseLong(shopRecommend.getShopId()),goods.getId())); goods.setSalesVolume(orderMapper.selectSalesVolume(Long.parseLong(shopRecommend.getShopId()),goods.getId()));
} }*/
return goodsList; return goodsList;
} }
......
...@@ -167,9 +167,9 @@ public class ShopServiceImpl implements IShopService ...@@ -167,9 +167,9 @@ public class ShopServiceImpl implements IShopService
@Override @Override
public int updateShop(Shop shop) { public int updateShop(Shop shop) {
shop.setUpdatedAt(new Date()); shop.setUpdatedAt(new Date());
/*if(1 == shop.getIsDefault()){ if (1 == shop.getIsDefault()) {
shopMapper.updateNoDefault(); shopMapper.updateNoDefault();
}*/ }
if (shop.getDistanceLimit() == null) { if (shop.getDistanceLimit() == null) {
shop.setDistanceLimit(0.0); shop.setDistanceLimit(0.0);
} }
......
...@@ -163,4 +163,17 @@ ...@@ -163,4 +163,17 @@
</choose> </choose>
where refund_id = #{refundId} where refund_id = #{refundId}
</update> </update>
<select id="selectGoodsSalesVolume" resultMap="OrderDetailResult">
select od.goods_id, sum(od.num) num
FROM `order` o join order_detail od on o.id = od.order_id
<where>
<if test="goodsIds != null and goodsIds.size() > 0">
and od.goods_id in
<foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">#{goodsId}</foreach>
</if>
<if test="shopId != null">and o.shop_id = #{shopId}</if>
</where>
group by od.goods_id
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
<if test="shopId !=null"> <if test="shopId !=null">
and o.shop_id=#{shopId} and o.shop_id=#{shopId}
</if> </if>
and o.state in ('6','7','12','13','14','15')) a and o.state in (6,7,12,13,14,15)) a
</select> </select>
<select id="selectSalesAmount" resultType="java.math.BigDecimal"> <select id="selectSalesAmount" resultType="java.math.BigDecimal">
select select
......
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