liujie
2025-12-10 5de3eb7cffc91bc446666b9bb819b8418aa170f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.ruoyi.web.controller.api;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.model.TPhysicalGoods;
import com.ruoyi.system.model.TPhysicalGoodsOrder;
import com.ruoyi.system.query.BigGiftPackageQuery;
import com.ruoyi.system.service.TPhysicalGoodsOrderService;
import com.ruoyi.system.service.TPhysicalGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 * 实物商品订单 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-12-08
 */
@RestController
@RequestMapping("/t-physical-goods-order")
@Api(tags = "(嘉视达)实物商品订单")
public class TPhysicalGoodsOrderController {
    private final TPhysicalGoodsOrderService tPhysicalGoodsOrderService;
    private final TPhysicalGoodsService tPhysicalGoodsService;
 
    public TPhysicalGoodsOrderController(TPhysicalGoodsOrderService tPhysicalGoodsOrderService, TPhysicalGoodsService tPhysicalGoodsService) {
        this.tPhysicalGoodsOrderService = tPhysicalGoodsOrderService;
        this.tPhysicalGoodsService = tPhysicalGoodsService;
    }
 
 
    @ApiOperation(value = "实物商品订单列表")
    @PostMapping(value = "/pageList")
    public R<Page<TPhysicalGoodsOrder>> pageList(@RequestBody BigGiftPackageQuery query) {
        Page<TPhysicalGoodsOrder> page = tPhysicalGoodsOrderService.pageList(query);
        return R.ok(page);
    }
 
 
    @ApiOperation(value = "实物商品订单详情")
    @GetMapping(value = "/detail/{id}")
    public R<TPhysicalGoodsOrder> detail(@PathVariable("id") Long id) {
        TPhysicalGoodsOrder order = tPhysicalGoodsOrderService.getById(id);
        TPhysicalGoods goods = tPhysicalGoodsService.getById(order.getPhysicalGoodsId());
        order.setPhysicalGoodsName(goods.getName());
        order.setPhysicalGoodsCover(goods.getCoverImage());
        order.setPhysicalGoodsPrice(goods.getTotalPrice());
        order.setPhysicalGoodsIntro(goods.getIntroduction());
        return R.ok(order);
    }
 
 
    @ApiOperation(value = "实物商品订单编辑")
    @PostMapping(value = "/edit")
    @Log(title = "实物商品订单-编辑", businessType = BusinessType.UPDATE)
    public R<String> edit(@RequestBody TPhysicalGoodsOrder order) {
        TPhysicalGoodsOrder goodsOrder = tPhysicalGoodsOrderService.getById(order.getId());
        if(goodsOrder.getStatus()!=1){
            return R.fail("待付款状态才可以编辑");
        }
        goodsOrder.setOrderPrice(order.getOrderPrice());
 
        boolean b = tPhysicalGoodsOrderService.updateById(goodsOrder);
        return R.ok("操作成功");
    }
 
 
    @ApiOperation(value = "实物商品订单删除")
    @DeleteMapping(value = "/delete/{id}")
    @Log(title = "实物商品订单-删除", businessType = BusinessType.DELETE)
    public R<String> delete(@PathVariable("id") Integer id) {
        TPhysicalGoodsOrder order = tPhysicalGoodsOrderService.getById(id);
        order.setDelFlag(1);
        boolean b = tPhysicalGoodsOrderService.updateById(order);
        return R.ok("操作成功");
    }
 
 
 
}