| | |
| | | @PostMapping("/addGoods") |
| | | @ApiOperation(value = "添加", tags = {"后台-商品管理"}) |
| | | public R addGoods(@RequestBody TGoods dto) { |
| | | if (dto.getTotal()!=null){ |
| | | dto.setSurplus(dto.getTotal()); |
| | | }else{ |
| | | dto.setSurplus(0); |
| | | } |
| | | goodsService.save(dto); |
| | | return R.ok("添加成功"); |
| | | } |
| | |
| | | @PostMapping("/updateGoods") |
| | | @ApiOperation(value = "修改", tags = {"后台-商品管理"}) |
| | | public R updateGoods(@RequestBody TGoods dto) { |
| | | if (dto.getTotal()!=null){ |
| | | dto.setSurplus(dto.getTotal()); |
| | | }else{ |
| | | dto.setSurplus(0); |
| | | } |
| | | goodsService.updateById(dto); |
| | | return R.ok("修改成功"); |
| | | } |
| | |
| | | // 商品分类详情 |
| | | List<TGoodsType> goodsTypes = goodsTypeService.lambdaQuery().in(TGoodsType::getId, Arrays.asList(goods.getTypeIds().split(","))).list(); |
| | | // 已兑换人数 |
| | | int number = goods.getBasicCount() + orderService.getGoodBuyNumber(goods.getId()); |
| | | int number = 0; |
| | | if (null != goods.getBasicCount()) { |
| | | number += goods.getBasicCount(); |
| | | } |
| | | number += orderService.getGoodBuyNumber(goods.getId()); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | } |
| | | |
| | |
| | | @PostMapping("/goodExchange") |
| | | @ApiOperation(value = "家长端-商品兑换确认", tags = {"家长端-商品兑换确认"}) |
| | | public R goodExchange(@RequestBody GoodExchangeDTO goodExchange) { |
| | | System.err.println("家长兑换:"); |
| | | Recipient recipient = recipientService.getById(Integer.valueOf(goodExchange.getRecipientId())); |
| | | return goodsService.goodExchange1(goodExchange, recipient); |
| | | } |
| | |
| | | @ApiOperation(value = "商品兑换确认", tags = {"学习端-商城"}) |
| | | @ApiOperationSupport(order = 42) |
| | | public R<String> goodExchangeStudy(@RequestBody @Validated GoodExchangeDTO goodExchange) { |
| | | System.err.println("学习兑换:"); |
| | | Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); |
| | | return goodsService.goodExchange(goodExchange, recipient); |
| | | } |