| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.dto.AppPageDto; |
| | | import com.ruoyi.goods.domain.dto.AppRecommendGoodsPageDto; |
| | | import com.ruoyi.goods.domain.dto.AppSearchGoodsPageDto; |
| | | import com.ruoyi.goods.domain.dto.AppShopGoodsPageDto; |
| | | import com.ruoyi.goods.domain.vo.AppHomeActivityVo; |
| | | import com.ruoyi.goods.domain.vo.AppSimpleActivityGoodsVo; |
| | | import com.ruoyi.goods.domain.vo.AppSimpleGoodsVo; |
| | | import com.ruoyi.goods.service.goods.GoodsService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.service.RemoteMemberService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class AppHomeController extends BaseController { |
| | | |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RemoteMemberService memberService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | |
| | | |
| | | @RequestMapping(value = "/pageActivityGoods", method = RequestMethod.POST) |
| | | @ApiOperation(value = "热门活动") |
| | | public R<AppHomeActivityVo> pageActivityGoods(@RequestBody AppRecommendGoodsPageDto appRecommendGoodsPageDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Long shopId = null; |
| | | Member member = null; |
| | | if(userId!=null){ |
| | | member = memberService.getMember(userId).getData(); |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | shopId = member.getRelationShopId(); |
| | | } |
| | | } |
| | | if(shopId==null){ |
| | | shopId = appRecommendGoodsPageDto.getPositionShopId(); |
| | | } |
| | | if(shopId==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | // if(member!=null&&member.getBindingFlag()==0){ |
| | | // shopId = null; |
| | | // } |
| | | AppHomeActivityVo homeActivityVo = goodsService.pageActivityGoods(shopId); |
| | | return R.ok(homeActivityVo); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pageRecommendGoods", method = RequestMethod.POST) |
| | | @ApiOperation(value = "推荐商品") |
| | | public R<Page<AppSimpleGoodsVo>> pageRecommendGoods(@RequestBody AppPageDto appPageDto) { |
| | | @ApiOperation(value = "商城精选") |
| | | public R<Page<AppSimpleGoodsVo>> pageRecommendGoods(@RequestBody AppRecommendGoodsPageDto appRecommendGoodsPageDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | logger.info("userId-----"+userId.toString()); |
| | | Long shopId = null; |
| | | if(userId!=null){ |
| | | Member member = memberService.getMember(userId).getData(); |
| | |
| | | } |
| | | } |
| | | if(shopId==null){ |
| | | shopId = 1L; |
| | | shopId = appRecommendGoodsPageDto.getPositionShopId(); |
| | | } |
| | | if(shopId==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | Page<AppSimpleGoodsVo> page = new Page<>(); |
| | | page.setSize(appPageDto.getPageSize()); |
| | | page.setCurrent(appPageDto.getPageNum()); |
| | | //logger.info("shopId"+shopId.toString()); |
| | | page.setSize(appRecommendGoodsPageDto.getPageSize()); |
| | | page.setCurrent(appRecommendGoodsPageDto.getPageNum()); |
| | | List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsService.pageRecommendGoods(page,shopId); |
| | | //logger.info("appSimpleGoodsVoList"+appSimpleGoodsVoList.toString()); |
| | | return R.ok(page.setRecords(appSimpleGoodsVoList)); |
| | | } |
| | | |
| | |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | appShopGoodsPageDto.setShopId(member.getRelationShopId()); |
| | | }else{ |
| | | appShopGoodsPageDto.setShopId(1L); |
| | | appShopGoodsPageDto.setShopId(appShopGoodsPageDto.getPositionShopId()); |
| | | } |
| | | } |
| | | if(appShopGoodsPageDto.getShopId()==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | Page<AppSimpleGoodsVo> page = new Page<>(); |
| | | page.setSize(appShopGoodsPageDto.getPageSize()); |
| | |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | appSearchGoodsPageDto.setShopId(member.getRelationShopId()); |
| | | }else{ |
| | | appSearchGoodsPageDto.setShopId(1L); |
| | | appSearchGoodsPageDto.setShopId(appSearchGoodsPageDto.getPositionShopId()); |
| | | } |
| | | } |
| | | if(appSearchGoodsPageDto.getShopId()==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | Page<AppSimpleGoodsVo> page = new Page<>(); |
| | | page.setSize(appSearchGoodsPageDto.getPageSize()); |
| | |
| | | @ApiOperation(value = "搜索活动商品") |
| | | public R<Page<AppSimpleActivityGoodsVo>> pageSearchActivityGoods(@RequestBody AppSearchGoodsPageDto appSearchGoodsPageDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Member member = null; |
| | | if(userId!=null){ |
| | | Member member = memberService.getMember(userId).getData(); |
| | | member = memberService.getMember(userId).getData(); |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | appSearchGoodsPageDto.setShopId(member.getRelationShopId()); |
| | | }else{ |
| | | appSearchGoodsPageDto.setShopId(1L); |
| | | appSearchGoodsPageDto.setShopId(appSearchGoodsPageDto.getPositionShopId()); |
| | | } |
| | | } |
| | | if(appSearchGoodsPageDto.getShopId()==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | if(member!=null&&member.getBindingFlag()==0){ |
| | | appSearchGoodsPageDto.setShopId(null); |
| | | } |
| | | Page<AppSimpleActivityGoodsVo> page = new Page<>(); |
| | | page.setSize(appSearchGoodsPageDto.getPageSize()); |
| | | page.setCurrent(appSearchGoodsPageDto.getPageNum()); |