|
@@ -2,18 +2,26 @@ package com.yonge.cooleshow.portal.controller;
|
|
|
|
|
|
import com.yonge.cooleshow.mall.common.api.CommonPage;
|
|
|
import com.yonge.cooleshow.mall.common.api.CommonResult;
|
|
|
+import com.yonge.cooleshow.mbg.mapper.OmsCartItemMapper;
|
|
|
+import com.yonge.cooleshow.mbg.model.OmsCartItem;
|
|
|
+import com.yonge.cooleshow.mbg.model.OmsCartItemExample;
|
|
|
import com.yonge.cooleshow.mbg.model.PmsProduct;
|
|
|
+import com.yonge.cooleshow.mbg.model.PmsSkuStock;
|
|
|
import com.yonge.cooleshow.portal.domain.PmsPortalProductDetail;
|
|
|
import com.yonge.cooleshow.portal.dto.ProductSearch;
|
|
|
import com.yonge.cooleshow.portal.dto.ProductSearchConditionVo;
|
|
|
import com.yonge.cooleshow.portal.service.PmsPortalProductService;
|
|
|
+import com.yonge.cooleshow.portal.service.UmsMemberService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 前台商品管理Controller
|
|
@@ -23,10 +31,14 @@ import java.util.List;
|
|
|
@Api(tags = "PmsPortalProductController 前台商品管理")
|
|
|
@RequestMapping("/product")
|
|
|
public class PmsPortalProductController {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private UmsMemberService umsMemberService;
|
|
|
@Autowired
|
|
|
private PmsPortalProductService portalProductService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OmsCartItemMapper omsCartItemMapper;
|
|
|
+
|
|
|
@ApiOperation(value = "综合搜索、筛选、排序")
|
|
|
@RequestMapping(value = "/search", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
@@ -51,4 +63,30 @@ public class PmsPortalProductController {
|
|
|
PmsPortalProductDetail productDetail = portalProductService.detail(id);
|
|
|
return CommonResult.success(productDetail);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("购物车数量")
|
|
|
+ @RequestMapping(value = "/cart/{id}", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResult cart(@PathVariable Long id) {
|
|
|
+ try {
|
|
|
+ OmsCartItemExample omsCartItemExample = new OmsCartItemExample();
|
|
|
+ omsCartItemExample.createCriteria().andProductSkuIdEqualTo(id)
|
|
|
+ .andHiddenEqualTo(0)
|
|
|
+ .andDeleteStatusEqualTo(0)
|
|
|
+ .andMemberIdEqualTo(umsMemberService.getCurrentMember().getId());
|
|
|
+ List<OmsCartItem> omsCartItems = omsCartItemMapper.selectByExample(omsCartItemExample);
|
|
|
+ if (CollectionUtils.isEmpty(omsCartItems)) {
|
|
|
+ return CommonResult.success(0);
|
|
|
+ } else {
|
|
|
+ return CommonResult.success(omsCartItems.get(0).getQuantity());
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception e) {
|
|
|
+ return CommonResult.success(0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|