| | |
| | | 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.goods.domain.vo.AppShoppingCartVo; |
| | | import com.ruoyi.system.api.domain.dto.AppBaseBathDto; |
| | | import com.ruoyi.goods.domain.dto.AppGoodsInfoGetDto; |
| | | import com.ruoyi.goods.domain.dto.AppShoppingCartAddDto; |
| | | import com.ruoyi.goods.domain.dto.AppShoppingCartChangeDto; |
| | | import com.ruoyi.goods.domain.vo.AppGoodsInfoVo; |
| | | import com.ruoyi.goods.domain.vo.AppShoppingCartVo; |
| | | import com.ruoyi.goods.service.goods.GoodsService; |
| | | import com.ruoyi.goods.service.goods.ShoppingCartService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.dto.AppBaseBathDto; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | @RequestMapping("/app/goods") |
| | | public class AppGoodsController extends BaseController { |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private RemoteMemberService memberService; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private ShoppingCartService shoppingCartService; |
| | | |
| | | @RequestMapping(value = "/getGoodsInfo", method = RequestMethod.POST) |
| | |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | appGoodsInfoGetDto.setShopId(member.getRelationShopId()); |
| | | }else{ |
| | | throw new ServiceException("请先获取附近商户定位"); |
| | | appGoodsInfoGetDto.setShopId(appGoodsInfoGetDto.getPositionShopId()); |
| | | } |
| | | } |
| | | if(appGoodsInfoGetDto.getShopId()==null){ |
| | | throw new ServiceException(AppErrorConstant.NO_POSITION); |
| | | } |
| | | AppGoodsInfoVo appGoodsInfoVo = goodsService.getGoodsInfo(appGoodsInfoGetDto); |
| | | return R.ok(appGoodsInfoVo); |
| | |
| | | if(userId != null){ |
| | | Member member = memberService.getMember(userId).getData(); |
| | | appShoppingCartAddDto.setUserId(userId); |
| | | if(appShoppingCartAddDto.getShopId()==null&&member!=null&&member.getRelationShopId()!=null){ |
| | | if(member!=null&&member.getBindingFlag()==1&&member.getRelationShopId()!=null){ |
| | | appShoppingCartAddDto.setShopId(member.getRelationShopId()); |
| | | } |
| | | } |
| | |
| | | if(userId!=null){ |
| | | Member member = memberService.getMember(userId).getData(); |
| | | appShoppingCartChangeDto.setUserId(userId); |
| | | if(member!=null&&member.getRelationShopId()!=null){ |
| | | if(member!=null&&member.getBindingFlag()==1&&member.getRelationShopId()!=null){ |
| | | appShoppingCartChangeDto.setShopId(member.getRelationShopId()); |
| | | } |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/countShoppingCart", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取购物车数量") |
| | | public R<Integer> countShoppingCart() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Member member = memberService.getMember(userId).getData(); |
| | | Long shopId = member.getRelationShopId(); |
| | | Integer count = shoppingCartService.countShoppingCart(userId, shopId); |
| | | return R.ok(count); |
| | | } |
| | | |
| | | } |