| | |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.ShoppingGoodsCategory; |
| | | import com.matrix.system.hive.bean.SysOrder; |
| | | import com.matrix.system.hive.bean.SysOrderItem; |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | 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 com.matrix.system.hive.service.ShoppingGoodsCategoryService; |
| | | import com.matrix.system.hive.service.ShoppingGoodsService; |
| | |
| | | @ApiOperation(value = "创建订单", notes = "创建订单") |
| | | @PostMapping(value = "/createOrder") |
| | | public AjaxResult createOrder(@RequestBody @Validated CreateOrderDto createOrderDto) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | SysOrder order=new SysOrder(); |
| | | order.setVipId(createOrderDto.getVipId()); |
| | | ShoppingCarItemsVo car = new ShoppingCarItemsVo(); |
| | | car.setVipId(createOrderDto.getVipId()); |
| | | |
| | | if (CollectionUtils.isNotEmpty(createOrderDto.getItems())) { |
| | | List<ShoppingCarItem> list = new ArrayList<>(); |
| | | List<SysOrderItem> list = new ArrayList<>(); |
| | | for (CreateOderItemDto item : createOrderDto.getItems()) { |
| | | ShoppingCarItem carItem = new ShoppingCarItem(); |
| | | carItem.setCount(item.getCount()); |
| | | carItem.setGoodsId(item.getGoodsId()); |
| | | carItem.setIsFree(item.getIsFree()); |
| | | carItem.setType(item.getGoodsType()); |
| | | |
| | | carItem.setShoppingGoods(shoppingGoodsService.findById(item.getGoodsId())); |
| | | list.add(carItem); |
| | | SysOrderItem orderItem = new SysOrderItem(); |
| | | orderItem.setCount(item.getCount()); |
| | | orderItem.setGoodsId(item.getGoodsId()); |
| | | orderItem.setIsFree(item.getIsFree()); |
| | | //jyytodo 这个字段可以不传 |
| | | orderItem.setType(item.getGoodsType()); |
| | | list.add(orderItem); |
| | | } |
| | | car.setCarItems(list); |
| | | order.setItems(list); |
| | | } |
| | | int i = sysOrderService.createOrder(WebUtil.getSession(), car); |
| | | if (i > 0) { |
| | | return AjaxResult.buildSuccessInstance("下单成功"); |
| | | } |
| | | |
| | | return AjaxResult.buildFailInstance("下单失败"); |
| | | sysOrderService.checkAndSaveOrder(order); |
| | | return AjaxResult.buildSuccessInstance("下单成功"); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取订单列表", notes = "获取订单列表") |