| | |
| | | package com.matrix.system.app.action; |
| | | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.WebUtil; |
| | |
| | | import com.matrix.system.app.vo.ShoppingGoodsListVo; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.tools.DataAuthUtil; |
| | | import com.matrix.system.hive.bean.ShoppingGoodsCategory; |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItem; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private SysOrderService sysOrderService; |
| | | |
| | | @Autowired |
| | | private SysShopInfoDao shopInfoDao; |
| | | |
| | | @ApiOperation(value = "获取商品类型列表", notes = "获取商品类型列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "ok", response = ShoppingGoodsCategory.class) |
| | |
| | | public AjaxResult findShoppingGoodsType() { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | SysShopInfo zbShop = shopInfoDao.selectZbShop(user.getCompanyId()); |
| | | ShoppingGoodsCategory category = new ShoppingGoodsCategory(); |
| | | category.setShopId(user.getShopId()); |
| | | return AjaxResult.buildSuccessInstance(shoppingGoodsCategoryService.findByModel(category)); |
| | | category.setShopId(zbShop.getId()); |
| | | List<ShoppingGoodsCategory> list = new ArrayList<>(); |
| | | List<ShoppingGoodsCategory> byModel = shoppingGoodsCategoryService.findByModel(category); |
| | | ShoppingGoodsCategory type = new ShoppingGoodsCategory(); |
| | | type.setName("全部"); |
| | | type.setParentId(0L); |
| | | list.add(type); |
| | | list.addAll(byModel); |
| | | return AjaxResult.buildSuccessInstance(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取商品列表", notes = "获取商品列表") |
| | |
| | | }) |
| | | @PostMapping(value = "/findShoppingGoods") |
| | | public AjaxResult findShoppingGoods(@RequestBody @Validated ShoppingGoodsListDto shoppingGoodsListDto) { |
| | | |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | if (!DataAuthUtil.hasAllShopAuth()) { |
| | | shoppingGoodsListDto.setShopId(user.getShopId()); |
| | | } |
| | | QueryUtil.setQueryLimitCom(shoppingGoodsListDto); |
| | | return AjaxResult.buildSuccessInstance(shoppingGoodsService.findShoppingGoodsListForApi(shoppingGoodsListDto), shoppingGoodsService.findShoppingGoodsListTotalForApi(shoppingGoodsListDto)); |
| | | } |
| | | |
| | |
| | | if (!DataAuthUtil.hasAllShopAuth()) { |
| | | orderListDto.setShopId(user.getShopId()); |
| | | } |
| | | QueryUtil.setQueryLimitCom(orderListDto); |
| | | return AjaxResult.buildSuccessInstance(sysOrderService.findApiOrderListInPage(orderListDto, pageVo), sysOrderService.findApiOrderListTotal(orderListDto)); |
| | | } |
| | | |
| | |
| | | return ajaxResult; |
| | | } |
| | | |
| | | @ApiOperation(value = "取消订单", notes = "取消订单") |
| | | @GetMapping(value = "/cancelOrder/{orderId}") |
| | | public AjaxResult cancelOrder(@PathVariable("orderId") Long orderId) { |
| | | SysOrder order = sysOrderService.findById(orderId); |
| | | if (order == null) { |
| | | throw new GlobleException("订单不存在"); |
| | | } |
| | | |
| | | |
| | | int i = sysOrderService.cancelOrder(orderId); |
| | | if (i > 0) { |
| | | return AjaxResult.buildSuccessInstance("取消成功"); |
| | | } |
| | | return AjaxResult.buildFailInstance("取消失败"); |
| | | } |
| | | |
| | | } |