开通产品,修改订单状态

This commit is contained in:
2024-11-21 11:47:34 +08:00
parent ecedfe6971
commit 4ac03ac65d
2 changed files with 22 additions and 2 deletions

View File

@@ -133,8 +133,6 @@ public class OrderController extends BaseController {
return fail("添加失败"); return fail("添加失败");
} }
@PreAuthorize("hasAuthority('sys:order:update')")
@OperationLog
@ApiOperation("修改订单") @ApiOperation("修改订单")
@PutMapping() @PutMapping()
public ApiResult<?> update(@RequestBody Order order) { public ApiResult<?> update(@RequestBody Order order) {

View File

@@ -1,13 +1,17 @@
package com.gxwebsoft.common.system.controller; package com.gxwebsoft.common.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.entity.OrderGoods; import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.param.OrderGoodsParam; import com.gxwebsoft.common.system.param.OrderGoodsParam;
import com.gxwebsoft.common.system.service.OrderGoodsService; import com.gxwebsoft.common.system.service.OrderGoodsService;
import com.gxwebsoft.common.system.service.OrderService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -28,6 +32,8 @@ import java.util.List;
public class OrderGoodsController extends BaseController { public class OrderGoodsController extends BaseController {
@Resource @Resource
private OrderGoodsService orderGoodsService; private OrderGoodsService orderGoodsService;
@Resource
private OrderService orderService;
@ApiOperation("分页查询订单商品") @ApiOperation("分页查询订单商品")
@GetMapping("/page") @GetMapping("/page")
@@ -85,6 +91,22 @@ public class OrderGoodsController extends BaseController {
return fail("修改失败"); return fail("修改失败");
} }
@ApiOperation("修改订单商品状态")
@PutMapping("/updateOrderStatus")
public ApiResult<?> updateOrderStatus(@RequestBody OrderGoods orderGoods) {
final User loginUser = getLoginUser();
if (loginUser == null) {
return fail("请先登录");
}
if (orderGoodsService.updateById(orderGoods)) {
if (orderGoodsService.count(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderStatus,0).eq(OrderGoods::getOrderId,orderGoods.getOrderId())) == 0) {
orderService.update(new LambdaUpdateWrapper<Order>().eq(Order::getOrderId,orderGoods.getOrderId()).set(Order::getOrderStatus,1));
}
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')") @PreAuthorize("hasAuthority('sys:order:remove')")
@ApiOperation("删除订单商品") @ApiOperation("删除订单商品")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")