Commit cd42f1bf by caiyt

周度提交

parent b0471a51
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.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType;
import com.soss.system.domain.Goods;
import com.soss.system.domain.ShopRecommend;
import com.soss.system.service.IGoodsService;
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
......@@ -22,17 +23,15 @@ import com.soss.common.core.page.TableDataInfo;
*/
@RestController
@RequestMapping("/system/recommend")
public class ShopRecommendController extends BaseController
{
public class ShopRecommendController extends BaseController {
@Autowired
private IShopRecommendService shopRecommendService;
@Autowired
private IGoodsService goodsService;
@GetMapping("/turn")
public AjaxResult turn(Long shopId,String goodsId,String pointer,String type)
{
return AjaxResult.success(shopRecommendService.turn(shopId,goodsId,pointer,type));
public AjaxResult turn(Long shopId, String goodsId, String pointer, String type) {
return AjaxResult.success(shopRecommendService.turn(shopId, goodsId, pointer, type));
}
/**
......@@ -40,15 +39,14 @@ public class ShopRecommendController extends BaseController
*/
// @PreAuthorize("@ss.hasPermi('system:recommend:list')")
@GetMapping("/list")
public TableDataInfo list(ShopRecommend shopRecommend)
{
public TableDataInfo list(ShopRecommend shopRecommend) {
startPage();
List<Goods> list = shopRecommendService.selectShopRecommendList(shopRecommend);
goodsService.resolverCategoryName(list);
goodsService.resolverGoodsVolume(Long.parseLong(shopRecommend.getShopId()), list);
return getDataTable(list);
}
/**
* 获取推荐和今日特惠详细信息
*/
......
......@@ -74,4 +74,9 @@ public interface OrderDetailMapper {
void bindRefund(@Param("refundId") Long refundId, @Param("ids") List<Long> ids);
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
*/
public List<Goods> selectGoodsList(Goods goods);
void resolverGoodsVolume(Long shopId, List<Goods> goodsList);
void resolverCategoryName(List<Goods> goodsList);
/**
......
......@@ -48,6 +48,8 @@ public class GoodsServiceImpl implements IGoodsService
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderDetailMapper orderDetailMapper;
@Autowired
private GoodsCategoryMapper goodsCategoryMapper;
@Autowired
private ShopRecommendMapper shopRecommendMapper;
......@@ -91,18 +93,39 @@ public class GoodsServiceImpl implements IGoodsService
public List<Goods> selectGoodsList(Goods goods) {
List<Goods> goodsList = goodsMapper.selectGoodsList(goods);
this.resolverCategoryName(goodsList);
for (Goods good : goodsList) {
this.resolverGoodsVolume(null, goodsList);
/*for (Goods good : goodsList) {
int count = orderMapper.selectSalesVolume(null, good.getId());
good.setSalesVolume(count);
}
}*/
return goodsList;
}
@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) {
if (CollectionUtils.isEmpty(goodsList)) {
return;
}
/** 品类解析 */
List<Long> categoryIds = new ArrayList<>(16);
goodsList.forEach(good -> {
String[] categoryIdArr = good.getCategory().split(StringPool.COMMA);
......@@ -117,6 +140,7 @@ public class GoodsServiceImpl implements IGoodsService
});
List<GoodsCategory> categories = goodsCategoryMapper.selectGoodsCategoryByIds(categoryIds);
Map<Long, String> categoryMap = categories.stream().collect(Collectors.toMap(GoodsCategory::getId, GoodsCategory::getName));
goodsList.forEach(good -> {
String categoryName = Arrays.stream(good.getCategory().split(StringPool.COMMA)).filter(StringUtils::isNotEmpty)
.map(Long::parseLong).map(categoryMap::get)
......
......@@ -14,6 +14,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
......@@ -68,7 +69,14 @@ public class OrderTakingServiceImpl {
orderTakingVo.setShopState(shop.getState());
ImagesVo imagesVo = new 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")));
orderTakingVo.setCountOfOrder(sysConfigService.selectConfigByKey("goods.limit"));
orderTakingVo.setTips(sysConfigService.selectConfigByKey("tips.address"));
......
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.soss.system.domain.Goods;
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.mapper.GoodsCategoryMapper;
import com.soss.system.mapper.MachineMapper;
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.domain.ShopRecommend;
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业务层处理
......@@ -61,10 +60,10 @@ public class ShopRecommendServiceImpl implements IShopRecommendService
{
List<Goods> goodsList = shopRecommendMapper.selectShopRecommendGoods(shopRecommend.getShopId(),shopRecommend.getType());
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.setSalesVolume(orderMapper.selectSalesVolume(Long.parseLong(shopRecommend.getShopId()),goods.getId()));
}
}*/
return goodsList;
}
......
......@@ -167,9 +167,9 @@ public class ShopServiceImpl implements IShopService
@Override
public int updateShop(Shop shop) {
shop.setUpdatedAt(new Date());
/*if(1 == shop.getIsDefault()){
if (1 == shop.getIsDefault()) {
shopMapper.updateNoDefault();
}*/
}
if (shop.getDistanceLimit() == null) {
shop.setDistanceLimit(0.0);
}
......
......@@ -163,4 +163,17 @@
</choose>
where refund_id = #{refundId}
</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>
\ No newline at end of file
......@@ -182,7 +182,7 @@
<if test="shopId !=null">
and o.shop_id=#{shopId}
</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 id="selectSalesAmount" resultType="java.math.BigDecimal">
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