|
@@ -0,0 +1,268 @@
|
|
|
+package org.springblade.factory.api.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.cloud.commons.lang.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.factory.entity.PcBladeCustomerAddress;
|
|
|
+import org.springblade.factory.entity.ViewItemSel;
|
|
|
+import org.springblade.factory.entity.ViewWhqohSel;
|
|
|
+import org.springblade.factory.service.PcBladeCustomerAddressService;
|
|
|
+import org.springblade.factory.service.ZcrmViewItemSelService;
|
|
|
+import org.springblade.factory.service.ZcrmViewWhqohSelService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+// System.out.println(AuthUtil.getTenantId());
|
|
|
+// System.out.println(AuthUtil.getClientId());
|
|
|
+// System.out.println(AuthUtil.getDeptId());
|
|
|
+// System.out.println(AuthUtil.getHeader());
|
|
|
+// System.out.println(AuthUtil.getNickName());
|
|
|
+// System.out.println(AuthUtil.getOauthId());
|
|
|
+// System.out.println(AuthUtil.getPostId());
|
|
|
+// System.out.println(AuthUtil.getUser());
|
|
|
+// System.out.println(AuthUtil.getUserAccount());
|
|
|
+
|
|
|
+/**
|
|
|
+ * 销售订单接口 控制器
|
|
|
+ *
|
|
|
+ * @author horizon
|
|
|
+ * @since 2025-08-05
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/factory/salesOrder")
|
|
|
+@AllArgsConstructor
|
|
|
+public class SalesOrderController {
|
|
|
+
|
|
|
+ /* ========== 收获地址管理 ========== */
|
|
|
+ private final PcBladeCustomerAddressService pcBladeCustomerAddressService;
|
|
|
+ /**
|
|
|
+ * 获取下单人收获地址列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getAddressList")
|
|
|
+ public R<List<PcBladeCustomerAddress>> getAddressList() {
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ if (userId == null) {
|
|
|
+ return R.fail("未获取到用户信息");
|
|
|
+ }
|
|
|
+ List<PcBladeCustomerAddress> addressList = pcBladeCustomerAddressService.getByCreateUser(userId.toString());
|
|
|
+ return R.data(addressList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加收货地址
|
|
|
+ * @param address 地址信息
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @PostMapping("/addAddress")
|
|
|
+ public R<String> addAddress(@RequestBody PcBladeCustomerAddress address) {
|
|
|
+ // 简单的参数校验
|
|
|
+ if (StringUtils.isEmpty(address.getReceiverName()) || StringUtils.isEmpty(address.getReceiverPhone())) {
|
|
|
+ return R.fail("收件人姓名和电话不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证用户是否登录
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ if (userId == null) {
|
|
|
+ return R.fail("请先登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用服务层添加地址
|
|
|
+ boolean success = pcBladeCustomerAddressService.addAddress(address);
|
|
|
+ return success ? R.data("200", "地址添加成功") : R.fail("地址添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改收货地址
|
|
|
+ * @param address 地址信息
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @PutMapping("/updateAddress")
|
|
|
+ public R<String> updateAddress(@RequestBody PcBladeCustomerAddress address) {
|
|
|
+ // 简单的参数校验
|
|
|
+ if (StringUtils.isEmpty(address.getReceiverName()) || StringUtils.isEmpty(address.getReceiverPhone())) {
|
|
|
+ return R.fail("收件人姓名和电话不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (address.getId() == null) {
|
|
|
+ return R.fail("编辑地址不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证用户是否登录
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ if (userId == null) {
|
|
|
+ return R.fail("请先登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用服务层添加地址
|
|
|
+ boolean success = pcBladeCustomerAddressService.updateAddress(address);
|
|
|
+ if (success) {
|
|
|
+ return R.data(200,"", "地址添加成功");
|
|
|
+ } else {
|
|
|
+ return R.fail("地址添加失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单独修改地址的默认状态
|
|
|
+ * @param addressId 要设为默认的地址ID
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @PutMapping("/setDefaultAddress")
|
|
|
+ public R<String> setDefaultAddress(@RequestParam Long addressId) {
|
|
|
+ if (addressId == null || addressId <= 0) {
|
|
|
+ return R.fail("地址ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean success = pcBladeCustomerAddressService.setDefaultAddress(addressId);
|
|
|
+ if (success) {
|
|
|
+ return R.data(200,"", "设置默认地址成功");
|
|
|
+ } else {
|
|
|
+ return R.fail("设置默认地址失败,请检查地址是否存在或您是否有权限");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除指定地址
|
|
|
+ * @param addressId 要删除的地址ID
|
|
|
+ * @return 操作结果
|
|
|
+ */
|
|
|
+ @DeleteMapping("/deleteAddress")
|
|
|
+ public R<String> deleteAddress(@RequestParam Long addressId) {
|
|
|
+ if (addressId == null || addressId <= 0) {
|
|
|
+ return R.fail("地址ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean success = pcBladeCustomerAddressService.deleteAddress(addressId);
|
|
|
+ if (success) {
|
|
|
+ return R.data(200, "", "地址删除成功");
|
|
|
+ } else {
|
|
|
+ return R.fail("地址删除失败,请检查地址是否存在或您是否有权限");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* ========== 订单提交 ========== */
|
|
|
+
|
|
|
+
|
|
|
+ /* ========== 订单修改 ========== */
|
|
|
+
|
|
|
+
|
|
|
+ /* ========== 创建订单 ========== */
|
|
|
+ @Autowired
|
|
|
+ private ZcrmViewWhqohSelService whqohService;
|
|
|
+ // 获取品牌 -- 接口
|
|
|
+
|
|
|
+ // 检查库存 -- 接口
|
|
|
+ /**
|
|
|
+ * 仓库库存列表
|
|
|
+ */
|
|
|
+ @GetMapping("/whqoh/list")
|
|
|
+ @ApiOperation(value = "仓库库存列表", notes = "")
|
|
|
+ public R<IPage<ViewWhqohSel>> whqohList(
|
|
|
+ @ApiIgnore @RequestParam Map<String, Object> params,
|
|
|
+ Query query,
|
|
|
+ ViewWhqohSel viewWhqohSel) {
|
|
|
+ // 1. 构建基础查询条件
|
|
|
+ QueryWrapper<ViewWhqohSel> queryWrapper = Condition.getQueryWrapper(params, ViewWhqohSel.class);
|
|
|
+ // 2. 执行分页查询
|
|
|
+ IPage<ViewWhqohSel> pages = whqohService.page(Condition.getPage(query), queryWrapper);
|
|
|
+ // 3. 返回结果
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 仓库库存全量查询(不分页)
|
|
|
+ */
|
|
|
+ @GetMapping("/whqoh/fullList")
|
|
|
+ @ApiOperation(value = "仓库库存全量查询", notes = "查询所有仓库库存数据,不分页")
|
|
|
+ public R<List<ViewWhqohSel>> whqohFullList(
|
|
|
+ @ApiIgnore @RequestParam Map<String, Object> params,
|
|
|
+ ViewWhqohSel viewWhqohSel) {
|
|
|
+ // 1. 构建查询条件(复用参数处理逻辑)
|
|
|
+ QueryWrapper<ViewWhqohSel> queryWrapper = Condition.getQueryWrapper(params, ViewWhqohSel.class);
|
|
|
+
|
|
|
+ // 2. 执行全量查询(不使用分页)
|
|
|
+ List<ViewWhqohSel> list = whqohService.list(queryWrapper);
|
|
|
+
|
|
|
+ // 3. 返回结果
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单条查询
|
|
|
+ */
|
|
|
+ @GetMapping("/whqoh/{id}")
|
|
|
+ public R<ViewWhqohSel> whqohGet(@PathVariable("id") Long id) {
|
|
|
+ ViewWhqohSel whqoh = whqohService.selectZcrmViewWhqohSelById(id);
|
|
|
+ return R.data(whqoh);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 获取物料列表 -- 接口
|
|
|
+ @Autowired
|
|
|
+ private ZcrmViewItemSelService itemService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 料品档案列表
|
|
|
+ */
|
|
|
+ @GetMapping("/item/list")
|
|
|
+ @ApiOperation(value = "料品档案列表", notes = "")
|
|
|
+ public R<IPage<ViewItemSel>> itemList(
|
|
|
+ @ApiIgnore @RequestParam Map<String, Object> params,
|
|
|
+ Query query,
|
|
|
+ ViewItemSel zcrmViewItemSel) {
|
|
|
+ // 1. 构建基础查询条件
|
|
|
+ QueryWrapper<ViewItemSel> queryWrapper = Condition.getQueryWrapper(params, ViewItemSel.class);
|
|
|
+ // 2. 执行分页查询
|
|
|
+ IPage<ViewItemSel> pages = itemService.page(Condition.getPage(query), queryWrapper);
|
|
|
+ // 3. 返回结果
|
|
|
+ return R.data(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 料品档案全量查询(不分页)
|
|
|
+ */
|
|
|
+ @GetMapping("/item/fullList")
|
|
|
+ @ApiOperation(value = "料品档案全量查询", notes = "查询所有符合条件的料品档案数据,不分页")
|
|
|
+ public R<List<ViewItemSel>> itemFullList(
|
|
|
+ @ApiIgnore @RequestParam Map<String, Object> params,
|
|
|
+ ViewItemSel zcrmViewItemSel) {
|
|
|
+ // 1. 构建查询条件(复用参数处理逻辑)
|
|
|
+ QueryWrapper<ViewItemSel> queryWrapper = Condition.getQueryWrapper(params, ViewItemSel.class);
|
|
|
+
|
|
|
+ // 2. 执行全量查询(不使用分页)
|
|
|
+ List<ViewItemSel> list = itemService.list(queryWrapper);
|
|
|
+
|
|
|
+ // 3. 返回结果
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单条查询
|
|
|
+ */
|
|
|
+ @GetMapping("/item/{id}")
|
|
|
+ public R<ViewItemSel> itemGet(@PathVariable("id") Long id) {
|
|
|
+ ViewItemSel item = itemService.selectZcrmViewItemSelById(id);
|
|
|
+ return R.data(item);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|