package com.ruoyi.order.controller.inner;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.enums.OrderStatusEnum;
|
import com.ruoyi.common.core.utils.page.BeanUtils;
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
import com.ruoyi.order.service.IOrderService;
|
import com.ruoyi.system.api.domain.Order;
|
import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO;
|
import com.ruoyi.system.api.domain.dto.OrderDTO;
|
import com.ruoyi.system.api.domain.dto.OrderUpdDTO;
|
import com.ruoyi.system.api.domain.vo.OrderVO;
|
import java.util.Collection;
|
import java.util.List;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.poi.ss.formula.functions.T;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
/**
|
* <p>
|
* 订单表 前端控制器
|
* </p>
|
*
|
* @author mitao
|
* @since 2024-05-16
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/order")
|
@RequiredArgsConstructor
|
public class OrderController {
|
|
private final IOrderService orderService;
|
@PostMapping("/saveOrderOne")
|
@ResponseBody
|
@InnerAuth
|
public R<T> saveOrderOne(@RequestBody OrderDTO OrderDTO) {
|
orderService.saveOrderOne(OrderDTO);
|
return R.ok();
|
|
}
|
|
@PostMapping("/getOrderOne")
|
@ResponseBody
|
@InnerAuth
|
public R<Order> getOrderOne(@RequestBody OrderDTO OrderDTO) {
|
|
LambdaQueryWrapper<Order> wrapper= Wrappers.lambdaQuery();
|
wrapper.eq(Order::getMemberId,OrderDTO.getMemberId());
|
wrapper.eq(Order::getOrderFrom,4);
|
wrapper.eq(Order::getAuctionOrderType,2 );
|
wrapper.eq(Order::getGoodsSkuId,OrderDTO.getGoodsSkuId());
|
wrapper.eq(Order::getDelFlag,0);
|
wrapper.orderByDesc(Order::getCancelTime);
|
Order page1 = orderService.getOne(wrapper);
|
|
return R.ok(page1);
|
|
}
|
|
@PostMapping("/getOrderOne1")
|
@ResponseBody
|
@InnerAuth
|
public R<Order> getOrderOne1(@RequestBody OrderDTO OrderDTO) {
|
|
LambdaQueryWrapper<Order> wrapper= Wrappers.lambdaQuery();
|
wrapper.eq(Order::getMemberId,OrderDTO.getMemberId());
|
wrapper.eq(Order::getOrderFrom,4);
|
wrapper.eq(Order::getAuctionOrderType,1 );
|
wrapper.eq(Order::getGoodsSkuId,OrderDTO.getGoodsSkuId());
|
wrapper.eq(Order::getDelFlag,0);
|
wrapper.orderByDesc(Order::getCancelTime);
|
Order page1 = orderService.getOne(wrapper);
|
|
return R.ok(page1);
|
|
}
|
|
@PostMapping("/getOrderOne2")
|
@ResponseBody
|
@InnerAuth
|
public R<Order> getOrderOne2(@RequestBody OrderDTO OrderDTO) {
|
|
LambdaQueryWrapper<Order> wrapper= Wrappers.lambdaQuery();
|
wrapper.eq(Order::getMemberId,OrderDTO.getMemberId());
|
wrapper.eq(Order::getOrderFrom,OrderDTO.getOrderFrom());
|
wrapper.eq(Order::getGoodsSkuId,OrderDTO.getGoodsSkuId());
|
wrapper.eq(Order::getDelFlag,0);
|
wrapper.orderByDesc(Order::getCancelTime);
|
List<Order> list = orderService.list(wrapper);
|
return R.ok(list.get(0));
|
|
}
|
|
|
/**
|
* 获取某个商品的已购会员数
|
*
|
* @param id 秒杀商品id
|
* @return 已购会员数
|
*/
|
@InnerAuth
|
@GetMapping("/seckill-members/{id}")
|
R<Integer> getSeckillMembers(@PathVariable("id") Long id) {
|
return R.ok(orderService.getSeckillMembers(id));
|
}
|
|
/**
|
* 获取团购商品已购数量
|
*
|
* @param id 团购商品id
|
* @return 团购商品已购数量
|
*/
|
@InnerAuth
|
@GetMapping("/group-purchase-num/{id}")
|
R<Integer> getGroupPurchasesGoodsNum(@PathVariable("id") Long id) {
|
return R.ok(orderService.getGroupPurchasesGoodsNum(id));
|
}
|
|
/**
|
* 获取团购商品已购订单列表
|
*
|
* @param id 团购商品id
|
* @return List<Order> 订单列表
|
*/
|
@InnerAuth
|
@GetMapping("/group-purchase-id/{id}")
|
R<List<Order>> getOrderByGroupPurchaseId(@PathVariable("id") Long id) {
|
return R.ok(orderService.getOrderByGroupPurchaseId(id));
|
}
|
|
@InnerAuth
|
@ResponseBody
|
@PostMapping("/getOrderByGroupPurchaseMemberId")
|
R<Order> getOrderByGroupPurchaseMemberId(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO){
|
return R.ok(orderService.getOrderByGroupPurchaseMemberId(homeGoodsSkuDTO));
|
}
|
@InnerAuth
|
@ResponseBody
|
@PostMapping("/getOrderByGroupPurchaseMemberId1")
|
R<Order> getOrderByGroupPurchaseMemberId1(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO){
|
return R.ok(orderService.getOrderByGroupPurchaseMemberId1(homeGoodsSkuDTO));
|
}
|
|
@InnerAuth
|
@ResponseBody
|
@PostMapping("/getOrderByGroupPurchaseMemberId2")
|
R<Order> getOrderByGroupPurchaseMemberId2(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO){
|
return R.ok(orderService.getOrderByGroupPurchaseMemberId2(homeGoodsSkuDTO));
|
}
|
|
|
@InnerAuth
|
@ResponseBody
|
@PostMapping("/getOrderByGroupPurchaseMemberList")
|
R<List<OrderVO>> getOrderByGroupPurchaseMemberList(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO){
|
return R.ok(orderService.getOrderByGroupPurchaseMemberList(homeGoodsSkuDTO));
|
}
|
|
@InnerAuth
|
@ResponseBody
|
@PostMapping("/getOrderByGroupPurchaseMemberList1")
|
R<List<OrderVO>> getOrderByGroupPurchaseMemberList1(@RequestBody HomeGoodsSkuDTO homeGoodsSkuDTO){
|
return R.ok(orderService.getOrderByGroupPurchaseMemberList1(homeGoodsSkuDTO));
|
}
|
|
|
|
/**
|
* 批量更新订单状态
|
*
|
* @param orderUpdDTOS 订单更新数据传输对象列表
|
*/
|
@PutMapping("/upd-batch")
|
R<?> updateOrderList(@RequestBody List<OrderUpdDTO> orderUpdDTOS) {
|
List<Order> orders = BeanUtils.copyList(orderUpdDTOS, Order.class);
|
orderService.updateBatchById(orders);
|
return R.ok();
|
}
|
|
/**
|
* 根据优惠券id集合查询订单列表
|
*
|
* @param couponIds 优惠券id集合
|
* @return List<Order>
|
*/
|
@PostMapping("/list-by-coupon")
|
R<List<Order>> getOrderByCouponIds(@RequestBody Collection<Long> couponIds) {
|
return R.ok(orderService.getOrderByCouponIds(couponIds));
|
}
|
@InnerAuth
|
@GetMapping("/autoCancelOrder/{id}")
|
R<?> autoCancelOrder(@PathVariable("id") Long oid) {
|
Order byId = orderService.getById(oid);
|
if (byId.getOrderStatus().getCode()==1){
|
byId.setOrderStatus(OrderStatusEnum.CANCELED);
|
orderService.updateById(byId);
|
}
|
return R.ok();
|
}
|
|
@InnerAuth
|
@PostMapping("/getOrderListByMubres")
|
R<List<Order>> getOrderListByMubres(@RequestBody List<String> mubres) {
|
return R.ok(orderService.getOrderListByMubres(mubres));
|
}
|
|
@InnerAuth
|
@PostMapping("/updOrderStatusByMubres")
|
R<?> updateOrderStatusByMubres(@RequestBody List<String> formedGroupMubres) {
|
orderService.updateOrderStatusByMubres(formedGroupMubres);
|
return R.ok();
|
}
|
|
@InnerAuth
|
@PostMapping("/updOrderStatusByMubres1")
|
R<?> updateOrderStatusByMubres1(@RequestBody String formedGroupMubres) {
|
try {
|
Thread.sleep(1000);
|
} catch (InterruptedException e) {
|
throw new RuntimeException(e);
|
}
|
orderService.updateOrderStatusByMubres1(formedGroupMubres);
|
return R.ok();
|
}
|
|
@InnerAuth
|
@PostMapping("/updOrderStatusByMubres2")
|
R<List<Order>> updateOrderStatusByMubres2(@RequestBody String formedGroupMubres) {
|
orderService.updateOrderStatusByMubres2(formedGroupMubres);
|
return R.ok();
|
}
|
}
|