package com.yuanchu.mom.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.pojo.dto.vo.SaleVo; import org.json.JSONException; import org.json.JSONObject; import com.yuanchu.mom.pojo.dto.SaleDto; import com.yuanchu.mom.service.SaleService; import com.yuanchu.mom.utils.Jwt; import com.yuanchu.mom.vo.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** *

* 销售单 前端控制器 *

* * @author 江苏鵷雏网络科技有限公司 * @since 2023-08-08 */ @Api(tags = "销售管理") @RestController @RequestMapping("/sale") public class SaleController { @Resource SaleService saleService; @Resource Jwt jwt; @ApiOperation(value = "查询销售单列表") @ApiImplicitParams(value = { @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), @ApiImplicitParam(name = "orderNumber", value = "订单编号", dataTypeClass = String.class), @ApiImplicitParam(name = "name", value = "产品名称", dataTypeClass = String.class), @ApiImplicitParam(name = "type", value = "状态(为空=全部)", dataTypeClass = Integer.class), @ApiImplicitParam(name = "delTime", value = "交货日期", dataTypeClass = String.class) }) @GetMapping("/selectSaleList") public Result selectSaleList(Integer pageSize, Integer countSize, String orderNumber, String name, Integer type, String delTime) { IPage> salePage = saleService.selectSaleList(new Page(pageSize, countSize), orderNumber, name, type, delTime); Map map = new HashMap<>(); map.put("total", salePage.getTotal()); map.put("row", salePage.getRecords()); return Result.success(map); } @ApiOperation(value = "新增销售单") @PostMapping("/addSale") public Result addSale(@RequestHeader("token") String token, @RequestBody SaleDto saleDto) throws JSONException { Map map = jwt.readJWT(token); String data = map.get("data"); JSONObject jsonObject = new JSONObject(data); String saleman = jsonObject.getString("name"); saleService.addSale(saleman, saleDto); return Result.success("新增成功!"); } @ApiOperation(value = "根据销售单id查看详情") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true) }) @GetMapping("/selectSaleDatilById") public Result selectSaleDatil(Integer id) { return Result.success(saleService.selectSaleDatil(id)); } @ApiOperation(value = "根据销售单id修改详情信息") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true) }) @PostMapping("/updateSaleById") public Result updateSaleById(@RequestHeader("token") String token, Integer id, @RequestBody SaleVo saleVo) throws JSONException { Map map = jwt.readJWT(token); String data = map.get("data"); JSONObject jsonObject = new JSONObject(data); String saleman = jsonObject.getString("name"); saleService.updateSaleById(saleman,id, saleVo); return Result.success("修改成功!"); } @ApiOperation(value = "根据销售单id删除") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true) }) @PostMapping("/delSale") public Result delSale(Integer id) { saleService.delSale(id); return Result.success(); } @ApiOperation(value = "批量删除") @ApiImplicitParams(value = { @ApiImplicitParam(name = "ids", value = "销售单id", dataTypeClass = String.class, dataType = "List", required = true) }) @PostMapping("/delAllSale") public Result delAllSale( List ids) { saleService.delAllSale(ids); return Result.success(); } @ApiOperation(value = "审核") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "销售单id", dataTypeClass = Integer.class, required = true), @ApiImplicitParam(name = "type", value = "状态", dataTypeClass = Integer.class, required = true) }) @PostMapping("/check") public Result check(@RequestHeader("token") String token,Integer id,Integer type) throws JSONException { Map map = jwt.readJWT(token); String data = map.get("data"); JSONObject jsonObject = new JSONObject(data); String checkname = jsonObject.getString("name"); saleService.check(checkname,id,type); return Result.success("审核成功"); } }