| | |
| | | @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("修改成功"); |
| | | } |
| | |
| | | @ApiOperation(value = "可兑换商品推荐", tags = {"学习端-商城"}) |
| | | @ApiOperationSupport(order = 38) |
| | | public R<List<TGoodsVO>> goodRecommend() { |
| | | return R.ok(goodsService.goodRecommend(tokenService.getLoginUserStudy().getUserid())); |
| | | LoginUserParent loginUserStudy = tokenService.getLoginUserStudy(); |
| | | if (null == loginUserStudy) { |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | return R.ok(goodsService.goodRecommend(loginUserStudy.getUserid())); |
| | | } |
| | | |
| | | /** |
| | |
| | | number += goods.getBasicCount(); |
| | | } |
| | | number += orderService.getGoodBuyNumber(goods.getId()); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | // 剩余兑换数量 |
| | | Integer residueNumber = null; |
| | | if (null != goods.getTotal()) { |
| | | // 计算剩余兑换数量 |
| | | List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getGoodsId, goodId) |
| | | .eq(TOrder::getDisabled, 0).list(); |
| | | Integer item = 0; |
| | | for (TOrder order : orderList) { |
| | | item += order.getCount(); |
| | | } |
| | | residueNumber = goods.getTotal() - item; |
| | | } |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number, residueNumber)); |
| | | } |
| | | |
| | | /** |
| | |
| | | number += goods.getBasicCount(); |
| | | } |
| | | number += orderService.getGoodBuyNumber(goods.getId()); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | // 剩余兑换数量 |
| | | Integer residueNumber = null; |
| | | if (null != goods.getTotal()) { |
| | | // 计算剩余兑换数量 |
| | | List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getGoodsId, goodId) |
| | | .eq(TOrder::getDisabled, 0).list(); |
| | | Integer item = 0; |
| | | for (TOrder order : orderList) { |
| | | item += order.getCount(); |
| | | } |
| | | residueNumber = goods.getTotal() - item; |
| | | } |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number, residueNumber)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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); |
| | | } |