超市优化
This commit is contained in:
@ -28,8 +28,6 @@ import javax.annotation.Resource;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.locks.Lock;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -48,20 +46,17 @@ public class AppStoreOrderController {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberAsyncService memberAsyncService;
|
private MemberAsyncService memberAsyncService;
|
||||||
|
|
||||||
private final Lock createLock = new ReentrantLock();
|
|
||||||
|
|
||||||
private final Lock cancelLock = new ReentrantLock();
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得商品订单分页")
|
@Operation(summary = "获得商品订单分页")
|
||||||
public CommonResult<PageResult<StoreOrderRespVO>> getStoreOrderPage(@Valid StoreOrderPageReqVO pageReqVO) {
|
public CommonResult<PageResult<StoreOrderRespVO>> getStoreOrderPage(@Valid StoreOrderPageReqVO pageReqVO) {
|
||||||
if(pageReqVO.getUserId()==null){
|
if (pageReqVO.getUserId() == null) {
|
||||||
pageReqVO.setStatus(StoreOrderStatusEnum.COMPLETE.getCode());
|
pageReqVO.setStatus(StoreOrderStatusEnum.COMPLETE.getCode());
|
||||||
}
|
}
|
||||||
PageResult<StoreOrderDO> pageResult = storeOrderService.getStoreOrderPage(pageReqVO);
|
PageResult<StoreOrderDO> pageResult = storeOrderService.getStoreOrderPage(pageReqVO);
|
||||||
PageResult<StoreOrderRespVO> bean = BeanUtils.toBean(pageResult, StoreOrderRespVO.class);
|
PageResult<StoreOrderRespVO> bean = BeanUtils.toBean(pageResult, StoreOrderRespVO.class);
|
||||||
//处理订单详情
|
//处理订单详情
|
||||||
for (StoreOrderRespVO vo: bean.getList()) {
|
for (StoreOrderRespVO vo : bean.getList()) {
|
||||||
List<AppStoreOrderDetailVo> listByOrderNo = orderDetailService.getListByOrderNo(vo.getOrderId());
|
List<AppStoreOrderDetailVo> listByOrderNo = orderDetailService.getListByOrderNo(vo.getOrderId());
|
||||||
vo.setDetailDOS(listByOrderNo);
|
vo.setDetailDOS(listByOrderNo);
|
||||||
vo.setStoresName(carteenApi.getCarteenById(vo.getCarteenId()).getStoresName());
|
vo.setStoresName(carteenApi.getCarteenById(vo.getCarteenId()).getStoresName());
|
||||||
@ -71,15 +66,13 @@ public class AppStoreOrderController {
|
|||||||
|
|
||||||
@PostMapping("/appCreate")
|
@PostMapping("/appCreate")
|
||||||
@Operation(summary = "购物车订单")
|
@Operation(summary = "购物车订单")
|
||||||
public CommonResult<Boolean> appCreate(@RequestBody CardDto dto) {
|
public synchronized CommonResult<Boolean> appCreate(@RequestBody CardDto dto) {
|
||||||
createLock.lock();
|
|
||||||
try {
|
|
||||||
AddReqVO addReqVO= storeOrderService.appCreate(dto);
|
AddReqVO addReqVO = storeOrderService.appCreate(dto);
|
||||||
//记录
|
//记录
|
||||||
memberAsyncService.batchRecord(addReqVO);
|
memberAsyncService.batchRecord(addReqVO);
|
||||||
}finally {
|
|
||||||
createLock.unlock();
|
|
||||||
}
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,15 +96,12 @@ public class AppStoreOrderController {
|
|||||||
|
|
||||||
@GetMapping("/cancel")
|
@GetMapping("/cancel")
|
||||||
@Operation(summary = "取消订单")
|
@Operation(summary = "取消订单")
|
||||||
public CommonResult<Boolean> cancel(Integer orderId) {
|
public synchronized CommonResult<Boolean> cancel(Integer orderId) {
|
||||||
cancelLock.lock();
|
|
||||||
try {
|
AddReqVO cancel = storeOrderService.cancel(orderId);
|
||||||
AddReqVO cancel = storeOrderService.cancel(orderId);
|
//记录
|
||||||
//记录
|
memberAsyncService.batchRecord(cancel);
|
||||||
memberAsyncService.batchRecord(cancel);
|
|
||||||
}finally {
|
|
||||||
cancelLock.unlock();
|
|
||||||
}
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +113,8 @@ public class AppStoreOrderController {
|
|||||||
|
|
||||||
@GetMapping("/reduction")
|
@GetMapping("/reduction")
|
||||||
@Operation(summary = "减免")
|
@Operation(summary = "减免")
|
||||||
public CommonResult<Boolean> reduction(Long orderId, BigDecimal money){
|
public CommonResult<Boolean> reduction(Long orderId, BigDecimal money) {
|
||||||
storeOrderService.reduction(orderId,money);
|
storeOrderService.reduction(orderId, money);
|
||||||
return CommonResult.success(true);
|
return CommonResult.success(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user