|
@@ -6,21 +6,26 @@ import com.txz.mall.core.Result;
|
|
|
import com.txz.mall.core.ResultCode;
|
|
|
import com.txz.mall.model.StoreOrder;
|
|
|
import com.txz.mall.service.StoreOrderService;
|
|
|
+import com.txz.mall.vo.StoreOrderCountItemVO;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.hibernate.validator.constraints.Range;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
+import tk.mybatis.mapper.entity.Example;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by CodeGenerator on 2025/07/15.
|
|
|
*/
|
|
|
-@Api(tags = "[后台]storeOrder管理")
|
|
|
+@Api(tags = "[后台]订单管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/store/order")
|
|
|
public class StoreOrderController {
|
|
@@ -31,7 +36,7 @@ public class StoreOrderController {
|
|
|
private StoreOrderService storeOrderService;
|
|
|
|
|
|
@PostMapping("/add")
|
|
|
- @ApiOperation(value = "storeOrder新增")
|
|
|
+ @ApiOperation(value = "订单新增")
|
|
|
public Result add(@RequestBody StoreOrder storeOrder) {
|
|
|
if (storeOrder == null) {
|
|
|
return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
@@ -48,7 +53,7 @@ public class StoreOrderController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
- @ApiOperation(value = "storeOrder删除")
|
|
|
+ @ApiOperation(value = "订单删除")
|
|
|
public Result delete(@RequestParam Long id) {
|
|
|
if (id == null) {
|
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
@@ -66,7 +71,7 @@ public class StoreOrderController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
- @ApiOperation(value = "storeOrder更新")
|
|
|
+ @ApiOperation(value = "订单更新")
|
|
|
public Result update(@RequestBody StoreOrder storeOrder) {
|
|
|
if (storeOrder == null) {
|
|
|
return Result.fail(ResultCode.OBJECT_IS_NULL);
|
|
@@ -86,7 +91,7 @@ public class StoreOrderController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/detail")
|
|
|
- @ApiOperation(value = "storeOrder获取详情")
|
|
|
+ @ApiOperation(value = "订单获取详情")
|
|
|
public Result<StoreOrder> detail(@RequestParam Long id) {
|
|
|
if (id == null) {
|
|
|
return Result.fail(ResultCode.ID_IS_NULL);
|
|
@@ -102,16 +107,19 @@ public class StoreOrderController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
- @ApiOperation(value = "storeOrder获取列表")
|
|
|
+ @ApiOperation(value = "订单获取列表")
|
|
|
public Result<List<StoreOrder>> list(@RequestBody StoreOrder storeOrder, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
|
Condition condition = new Condition(storeOrder.getClass());
|
|
|
-// Criteria criteria = condition.createCriteria();
|
|
|
-// criteria.andEqualTo("name", city.getName());
|
|
|
+ Example.Criteria criteria = condition.createCriteria();
|
|
|
+ criteria.andEqualTo("isDelete", 0);
|
|
|
PageInfo pageInfo = null;
|
|
|
try {
|
|
|
List<StoreOrder> list = storeOrderService.findByCondition(condition);
|
|
|
+ list = list.stream()
|
|
|
+ .sorted(Comparator.comparing(StoreOrder::getCreateTime).reversed())
|
|
|
+ .collect(Collectors.toList());
|
|
|
pageInfo = new PageInfo(list);
|
|
|
} catch (Exception e) {
|
|
|
log.error("查询对象操作异常e:{}", e);
|
|
@@ -119,4 +127,12 @@ public class StoreOrderController {
|
|
|
}
|
|
|
return Result.success(pageInfo);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取订单各状态数量")
|
|
|
+ @GetMapping(value = "/status/num")
|
|
|
+ public Result<StoreOrderCountItemVO> getOrderStatusNum(
|
|
|
+ @RequestParam(value = "dateLimit", defaultValue = "") String dateLimit,
|
|
|
+ @RequestParam(value = "type", defaultValue = "2") @Range(min = 0, max = 2, message = "未知的订单类型") Integer type) {
|
|
|
+ return Result.success(storeOrderService.getOrderStatusNum(dateLimit, type));
|
|
|
+ }
|
|
|
}
|