hjl
2024-06-19 aa34f5b4a80eec408185cc36500149679e1a71c9
ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -25,6 +25,7 @@
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;
@@ -287,6 +288,7 @@
        }
        TOrder byId = orderService.getById(id);
        byId.setState(3);
        byId.setCompleteTime(new Date());
        return R.ok(orderService.updateById(byId));
    }
@@ -615,6 +617,9 @@
            @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) {
@@ -673,7 +678,8 @@
        }
        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();
        // 格式化日期和时间信息
@@ -683,10 +689,11 @@
        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);
    }
@@ -750,7 +757,7 @@
    @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);
    }