| | |
| | | import io.swagger.annotations.ApiOperationSupport; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | TOrder byId = orderService.getById(id); |
| | | byId.setState(3); |
| | | byId.setCompleteTime(new Date()); |
| | | return R.ok(orderService.updateById(byId)); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) |
| | | }) |
| | | public R<GoodDetailVO> goodDetail(@RequestParam String goodId) { |
| | | if (tokenService.getLoginUserStudy() == null) { |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | // 商品详情 |
| | | TGoods goods = goodsService.lambdaQuery().eq(TGoods::getId, goodId).one(); |
| | | if (null == goods) { |
| | |
| | | } |
| | | Recipient recipient = recipientService.lambdaQuery() |
| | | .eq(Recipient::getUserId, tokenService.getLoginUserStudy().getUserid()) |
| | | .eq(Recipient::getIsDefault, 1).one(); |
| | | .eq(Recipient::getIsDefault, 1) |
| | | .eq(Recipient::getDisabled, 0).one(); |
| | | GoodDetailVO goodDetailVO = goodsService.redeemNow(goodId, recipient); |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | // 格式化日期和时间信息 |
| | |
| | | Random random = new Random(); |
| | | StringBuilder randomPart = new StringBuilder(); |
| | | for (int i = 0; i < 3; i++) { |
| | | randomPart.append((char) (random.nextInt(26) + 'A')); // 大写字母 |
| | | // 大写字母 |
| | | randomPart.append((char) (random.nextInt(26) + 'A')); |
| | | } |
| | | // 组合订单编号 |
| | | String orderNumber = formattedDateTime + randomPart.toString(); |
| | | String orderNumber = formattedDateTime + randomPart; |
| | | goodDetailVO.setOrderNumber(orderNumber); |
| | | return R.ok(goodDetailVO); |
| | | } |
| | |
| | | @PostMapping("/goodExchangeStudy") |
| | | @ApiOperation(value = "商品兑换确认", tags = {"学习端-商城"}) |
| | | @ApiOperationSupport(order = 42) |
| | | public R goodExchangeStudy(@RequestBody GoodExchangeDTO goodExchange) { |
| | | public R<String> goodExchangeStudy(@RequestBody @Validated GoodExchangeDTO goodExchange) { |
| | | Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); |
| | | return goodsService.goodExchange(goodExchange, recipient); |
| | | } |