6 天以前 92d8d06d8ae38c407715a5e9389691b446413e0a
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package com.ruoyi.sales.controller;
 
import javax.servlet.http.HttpServletResponse;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.procurementrecord.dto.ProcurementPageDto;
import com.ruoyi.procurementrecord.dto.ProcurementPageDtoCopy;
import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper;
import com.ruoyi.procurementrecord.mapper.ReturnSaleProductMapper;
import com.ruoyi.procurementrecord.service.ProcurementRecordService;
import com.ruoyi.procurementrecord.service.ReturnManagementService;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.sales.dto.SalesLedgerProductDto;
import com.ruoyi.sales.mapper.ShippingInfoDetailMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShippingInfoDetail;
import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ShippingInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
 
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
 
/**
 * 产品信息Controller
 *
 * @author ruoyi
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/sales/product")
public class SalesLedgerProductController extends BaseController
{
    @Autowired
    private ISalesLedgerProductService salesLedgerProductService;
    @Autowired
    private ProcurementRecordService procurementRecordService;
    @Autowired
    private StockUtils stockUtils;
 
    @Autowired
    private ShippingInfoService shippingInfoService;
 
    @Autowired
    private ReturnManagementService returnManagementService;
 
 
    /**
     * 回款登记分页查询
     */
    @GetMapping("/listPageSalesLedger")
    public AjaxResult listPage(Page page, SalesLedgerProductDto salesLedgerProduct) {
        IPage<SalesLedgerProductDto> list = salesLedgerProductService.listPage(page,salesLedgerProduct);
        return AjaxResult.success(list);
    }
 
 
    /**
     * 付款登记分页查询
     */
    @GetMapping("/listPagePurchaseLedger")
    public AjaxResult listPagePurchaseLedger(Page page, SalesLedgerProductDto salesLedgerProduct) {
        IPage<SalesLedgerProductDto> list = salesLedgerProductService.listPagePurchaseLedger(page,salesLedgerProduct);
        return AjaxResult.success(list);
    }
 
    @ApiOperation("发货退货撤销")
    @PostMapping("/cancelDelivery")
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult cancelDelivery(@RequestBody SalesLedgerProduct salesLedgerProduct) {
        return AjaxResult.success(salesLedgerProductService.cancelDelivery(salesLedgerProduct));
    }
 
 
 
    /**
     * 查询产品信息列表
     */
    @GetMapping("/list")
    public AjaxResult list(SalesLedgerProduct salesLedgerProduct)
    {
        List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
        list.forEach(item -> {
           // 获取发货数量,退货数量
           Map<String, BigDecimal> map = shippingInfoService.getNumberOfSalesLedgerProduct(item.getId());
           item.setShippingNum(map.get("shippingNum"));
           item.setReturnNum(map.get("returnNum"));
            if (item.getFutureTickets().compareTo(BigDecimal.ZERO) == 0) {
                item.setFutureTickets(item.getQuantity());
            }
            if (item.getFutureTicketsAmount().compareTo(BigDecimal.ZERO) == 0) {
                item.setFutureTicketsAmount(item.getTaxInclusiveTotalPrice());
            }
            if (item.getApproveStatus() != 2) {
                if (item.getHasSufficientStock() == 0) {
                    item.setApproveStatus(0);
                }else {
                    item.setApproveStatus(1);
                }
            }
        });
        return AjaxResult.success(list);
    }
 
    /**
     * 导出产品信息列表
     */
    @Log(title = "产品信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SalesLedgerProduct salesLedgerProduct)
    {
        List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct);
        ExcelUtil<SalesLedgerProduct> util = new ExcelUtil<SalesLedgerProduct>(SalesLedgerProduct.class);
        util.exportExcel(response, list, "产品信息数据");
    }
 
    /**
     * 获取产品信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(salesLedgerProductService.selectSalesLedgerProductById(id));
    }
 
    /**
     * 新增修改产品信息
     */
    @Log(title = "产品信息", businessType = BusinessType.INSERT)
    @PostMapping  ("/addOrUpdateSalesLedgerProduct")
    public AjaxResult add(@RequestBody SalesLedgerProduct salesLedgerProduct)
    {
        return toAjax(salesLedgerProductService.addOrUpdateSalesLedgerProduct(salesLedgerProduct));
    }
 
    /**
     * 删除产品信息
     */
    @Log(title = "产品信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/delProduct")
    public AjaxResult remove(@RequestBody Long[] ids)
    {
        if (ids == null || ids.length == 0) {
            return AjaxResult.error("请传入要删除的ID");
        }
        return toAjax(salesLedgerProductService.deleteSalesLedgerProductByIds(ids));
    }
 
    //根据产品id获取bom判断库存是否充足
    @GetMapping("/judgmentInventory")
    public R judgmentInventory(SalesLedgerProduct salesLedgerProduct) {
        return  salesLedgerProductService.judgmentInventory(salesLedgerProduct);
    }
}