| | |
| | | package com.ruoyi.goods.controller.business; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | |
| | | import com.ruoyi.goods.domain.dto.MgtSelectGoodsPageDto; |
| | | import com.ruoyi.goods.domain.vo.MerGoodsPageVo; |
| | | import com.ruoyi.goods.service.goods.GoodsService; |
| | | import com.ruoyi.goods.service.goods.ShopGoodsService; |
| | | import com.ruoyi.system.api.domain.dto.MerBaseDto; |
| | | import com.ruoyi.system.api.domain.poji.goods.ShopGoods; |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.vo.MgtSelectGoodsPageVo; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | @RestController |
| | | @RequestMapping("/mer/goods") |
| | | public class MerGoodsController { |
| | | |
| | | |
| | | @Resource |
| | | private GoodsService goodsService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | | @Resource |
| | | private ShopGoodsService shopGoodsService; |
| | | |
| | | |
| | | @RequestMapping(value = "/pageMerShopGoods", method = RequestMethod.POST) |
| | | @ApiOperation(value = "分页获取商户商品列表") |
| | | @ApiOperation(value = "分页获取商户商品列表【2.0】") |
| | | public R<Page<MerGoodsPageVo>> pageMerShopGoods(@RequestBody MerGoodsPageDto merGoodsPageDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Page<MerGoodsPageVo> page = new Page<>(); |
| | | page.setSize(merGoodsPageDto.getPageSize()); |
| | | page.setCurrent(merGoodsPageDto.getPageNum()); |
| | | page.setOptimizeCountSql(false); |
| | | List<MerGoodsPageVo> merGoodsPageVoList = goodsService.pageMerShopGoods(page,merGoodsPageDto); |
| | | List<MerGoodsPageVo> merGoodsPageVoList = goodsService.pageMerShopGoods(page, merGoodsPageDto); |
| | | Shop shop = remoteShopService.getShop(merGoodsPageDto.getShopId()).getData(); |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | merGoodsPageVoList.forEach(merGoodsPageVo -> { |
| | | ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(belongShop.getShopId(), merGoodsPageVo.getGoodsId()); |
| | | //后台开启经销商统一售价,且经销商设置了统一售价,加盟商不能修改价格 |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | merGoodsPageVo.setModifyPricePermission(0); |
| | | merGoodsPageVo.setIsUnifiedPrice(1); |
| | | merGoodsPageVo.setUnifiedPrice(shopGoods.getSalesPrice()); |
| | | merGoodsPageVo.setUnifiedServerNum(shopGoods.getServiceNum()); |
| | | } else { |
| | | merGoodsPageVo.setModifyPricePermission(1); |
| | | merGoodsPageVo.setIsUnifiedPrice(0); |
| | | } |
| | | }); |
| | | return R.ok(page.setRecords(merGoodsPageVoList)); |
| | | } |
| | | |
| | |
| | | List<MerGoodsPageVo> merGoodsPageVoList = goodsService.listMerCycleGoods(merBaseDto.getShopId()); |
| | | return R.ok(merGoodsPageVoList); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/editMerShopGoods", method = RequestMethod.POST) |
| | | @ApiOperation(value = "编辑商户商品价格") |
| | | @ApiOperation(value = "编辑商户商品价格【2.0】") |
| | | public R editMerShopGoods(@RequestBody MerShopGoodsEditDto merShopGoodsEditDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | merShopGoodsEditDto.setUserId(userId); |
| | | goodsService.editMerShopGoods(merShopGoodsEditDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/cancelUniformPrice", method = RequestMethod.POST) |
| | | @ApiOperation(value = "取消统一售价【2.0】") |
| | | public R cancelUniformPrice(@RequestBody MerShopGoodsEditDto merShopGoodsEditDto) { |
| | | shopGoodsService.remove(new LambdaUpdateWrapper<ShopGoods>().eq(ShopGoods::getShopId, merShopGoodsEditDto.getShopId()) |
| | | .eq(ShopGoods::getGoodsId, merShopGoodsEditDto.getGoodsId())); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/pageMerSelectGoods", method = RequestMethod.POST) |
| | | @ApiOperation(value = "分页获取商品选择列表") |
| | | public R<Page<MgtSelectGoodsPageVo>> pageMerSelectGoods(@RequestBody MgtSelectGoodsPageDto mgtSelectGoodsPageDto) { |
| | |
| | | page.setSize(mgtSelectGoodsPageDto.getPageSize()); |
| | | page.setCurrent(mgtSelectGoodsPageDto.getPageNum()); |
| | | page.setOptimizeCountSql(false); |
| | | List<MgtSelectGoodsPageVo> mgtSelectGoodsPageVos = goodsService.pageMgtSelectGoods(page,mgtSelectGoodsPageDto); |
| | | List<MgtSelectGoodsPageVo> mgtSelectGoodsPageVos = goodsService.pageMgtSelectGoods(page, mgtSelectGoodsPageDto); |
| | | return R.ok(page.setRecords(mgtSelectGoodsPageVos)); |
| | | } |
| | | } |