| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.goods.domain.*; |
| | |
| | | */ |
| | | @GetMapping("/exchangeRecord") |
| | | @ApiOperation(value = "兑换记录", tags = {"兑换记录"}) |
| | | public AjaxResult<List<TOrder>> exchangeRecord() { |
| | | return AjaxResult.success(orderService.lambdaQuery().eq(TOrder::getUserId, tokenService.getLoginUserStudy().getUserid()) |
| | | public R<List<TOrder>> exchangeRecord() { |
| | | return R.ok(orderService.lambdaQuery().eq(TOrder::getUserId, tokenService.getLoginUserStudy().getUserid()) |
| | | .orderByDesc(TOrder::getCreateTime).list()); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true) |
| | | }) |
| | | public AjaxResult confirm(@RequestParam Integer id) { |
| | | public R<Boolean> confirm(@RequestParam Integer id) { |
| | | TOrder byId = orderService.getById(id); |
| | | byId.setState(3); |
| | | return AjaxResult.success(orderService.updateById(byId)); |
| | | return R.ok(orderService.updateById(byId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/shopAddress") |
| | | @ApiOperation(value = "获取用户收货地址", tags = {"获取用户收货地址"}) |
| | | public AjaxResult<List<Recipient>> shopAddress() { |
| | | return AjaxResult.success(recipientService.lambdaQuery().eq(Recipient::getUserId, |
| | | public R<List<Recipient>> shopAddress() { |
| | | return R.ok(recipientService.lambdaQuery().eq(Recipient::getUserId, |
| | | tokenService.getLoginUserStudy().getUserid()).list()); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PostMapping("/addressSaveOrUpdate") |
| | | @ApiOperation(value = "新增收货地址/修改收货地址", tags = {"新增收货地址/修改收货地址"}) |
| | | public AjaxResult<String> addressSave(@RequestBody Recipient recipient) { |
| | | public R<String> addressSave(@RequestBody Recipient recipient) { |
| | | recipient.setUserId(tokenService.getLoginUserStudy().getUserid()); |
| | | return AjaxResult.success(recipientService.addressSaveOrUpdate(recipient)); |
| | | return R.ok(recipientService.addressSaveOrUpdate(recipient)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true) |
| | | }) |
| | | public AjaxResult<String> addressDelete(@RequestParam String id) { |
| | | return AjaxResult.success(recipientService.removeById(id) ? "删除成功!" : "删除失败!"); |
| | | public R<String> addressDelete(@RequestParam String id) { |
| | | return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "String", required = true), |
| | | @ApiImplicitParam(value = "完整收货地址", name = "address", dataType = "String", required = true) |
| | | }) |
| | | public AjaxResult<Boolean> updateOrderAddress(@RequestParam String orderId, |
| | | public R<Boolean> updateOrderAddress(@RequestParam String orderId, |
| | | @RequestParam String address) { |
| | | return AjaxResult.success(orderService.lambdaUpdate().set(TOrder::getConsigneeAddress, address) |
| | | return R.ok(orderService.lambdaUpdate().set(TOrder::getConsigneeAddress, address) |
| | | .eq(TOrder::getId, orderId).eq(TOrder::getState, 1).update()); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/addressTree") |
| | | @ApiOperation(value = "收货地址省市区三级联动", tags = {"收货地址省市区三级联动"}) |
| | | public AjaxResult<List<Region>> addressTree() { |
| | | return AjaxResult.success(regionService.addressTree()); |
| | | public R<List<Region>> addressTree() { |
| | | return R.ok(regionService.addressTree()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) |
| | | }) |
| | | public AjaxResult<GoodDetailVO> goodDetail(@RequestParam String goodId) { |
| | | public R<GoodDetailVO> goodDetail(@RequestParam String goodId) { |
| | | // 商品详情 |
| | | TGoods goods = goodsService.lambdaQuery().eq(TGoods::getId, goodId).one(); |
| | | // 商品分类详情 |
| | | List<TGoodsType> goodsTypes = goodsTypeService.lambdaQuery().in(TGoodsType::getId, Arrays.asList(goods.getTypeIds().split(","))).list(); |
| | | // 已兑换人数 |
| | | int number = goods.getBasicCount() + orderService.getGoodBuyNumber(goods.getId()); |
| | | return AjaxResult.success(new GoodDetailVO(goods, goodsTypes, number)); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) |
| | | }) |
| | | public AjaxResult<GoodDetailVO> redeemNow(@RequestParam String goodId) { |
| | | public R<GoodDetailVO> redeemNow(@RequestParam String goodId) { |
| | | Recipient recipient = recipientService.lambdaQuery() |
| | | .eq(Recipient::getUserId, tokenService.getLoginUserStudy().getUserid()) |
| | | .eq(Recipient::getIsDefault, 1).one(); |
| | | return AjaxResult.success(goodsService.redeemNow(goodId, recipient)); |
| | | return R.ok(goodsService.redeemNow(goodId, recipient)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/goodExchange") |
| | | @ApiOperation(value = "商品兑换-确认", tags = {"商品兑换-确认"}) |
| | | public AjaxResult<Object> goodExchange(@RequestBody GoodExchangeDTO goodExchange) { |
| | | public R<Boolean> goodExchange(@RequestBody GoodExchangeDTO goodExchange) { |
| | | Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); |
| | | return AjaxResult.success(goodsService.goodExchange(goodExchange, recipient)); |
| | | return R.ok(goodsService.goodExchange(goodExchange, recipient)); |
| | | } |
| | | |
| | | } |