|
@@ -24,15 +24,22 @@ import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.redis.RedisCache;
|
|
|
import com.qs.mp.common.enums.BizTypeEnum;
|
|
|
import com.qs.mp.common.enums.CouponUseAreaEnum;
|
|
|
+import com.qs.mp.common.enums.PrizeStorageStatusEnum;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
import com.qs.mp.common.utils.StringUtils;
|
|
|
import com.qs.mp.framework.redis.RedisKey;
|
|
|
import com.qs.mp.pay.service.IWalletService;
|
|
|
+import com.qs.mp.user.domain.UserAddr;
|
|
|
+import com.qs.mp.user.domain.UserPrizeStorage;
|
|
|
import com.qs.mp.user.domain.UserTicketOrder;
|
|
|
+import com.qs.mp.user.domain.param.DeliverOrderParam;
|
|
|
import com.qs.mp.user.domain.param.TicketOrderParam;
|
|
|
+import com.qs.mp.user.domain.vo.DeliverOrderSettleVO;
|
|
|
import com.qs.mp.user.domain.vo.TicketOrderSettleVO;
|
|
|
import com.qs.mp.user.domain.vo.UserCouponVO;
|
|
|
+import com.qs.mp.user.service.IUserAddrService;
|
|
|
import com.qs.mp.user.service.IUserCouponService;
|
|
|
+import com.qs.mp.user.service.IUserPrizeStorageService;
|
|
|
import com.qs.mp.user.service.IUserTicketOrderService;
|
|
|
import com.qs.mp.utils.SecurityUtils;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
@@ -57,21 +64,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@AllArgsConstructor
|
|
|
public class UserDeliverOrderController extends BaseApiController {
|
|
|
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ITicketBoxService ticketBoxService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IUserTicketOrderService userTicketOrderService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ITicketService ticketService;
|
|
|
-
|
|
|
@Autowired
|
|
|
- private IUserCouponService userCouponService;
|
|
|
+ private IUserPrizeStorageService userPrizeStorageService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ICouponTicketService couponTicketService;
|
|
|
+ private IUserAddrService userAddrService;
|
|
|
|
|
|
@Autowired
|
|
|
private IWalletService walletService;
|
|
@@ -84,74 +81,47 @@ public class UserDeliverOrderController extends BaseApiController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 订单结算,每次更换优惠券时需重新请求此接口
|
|
|
+ * 订单结算,每次更换地址时需重新请求此接口
|
|
|
*/
|
|
|
@PostMapping("/order/settle")
|
|
|
- @ApiOperation(value = "订单结算" , notes = "单个盲票商品上点立即购买")
|
|
|
- public AjaxResult settle(@Valid @RequestBody TicketOrderParam param) {
|
|
|
- if (StringUtils.isBlank(param.getTicketId()) && StringUtils.isBlank(param.getBoxId())) {
|
|
|
- return AjaxResult.error("参数缺失");
|
|
|
- }
|
|
|
+ @ApiOperation(value = "订单结算" , notes = "奖品库里点提货")
|
|
|
+ public AjaxResult settle(@Valid @RequestBody DeliverOrderParam param) {
|
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
|
|
- TicketOrderSettleVO orderSettleVO = new TicketOrderSettleVO();
|
|
|
+ DeliverOrderSettleVO orderSettleVO = new DeliverOrderSettleVO();
|
|
|
|
|
|
+ // 收货地址,如果用户选了地址,则此处不做处理
|
|
|
+ if (null == param.getAddrId() || 0 == param.getAddrId()) {
|
|
|
+ //读取默认地址
|
|
|
+ UserAddr addr = userAddrService.getDefaultChannelAddr(userId);
|
|
|
+ if (null != addr) {
|
|
|
+ orderSettleVO.setAddr(addr);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 订单金额计算
|
|
|
Integer orderAmt = 0;
|
|
|
- Integer discountAmt = 0;
|
|
|
- TicketBox ticketBox;
|
|
|
- if (StringUtils.isNotBlank(param.getTicketId())) {
|
|
|
- // 线下扫码购票
|
|
|
- Ticket ticket = ticketService.getById(param.getTicketId());
|
|
|
- ticketBox = ticketBoxService.getById(ticket.getBoxId());
|
|
|
- orderAmt = ticketBox.getSalePrice();
|
|
|
- } else {
|
|
|
- // 线上购票
|
|
|
- ticketBox = ticketBoxService.getById(param.getBoxId());
|
|
|
- orderAmt = ticketBox.getSalePrice() * param.getOrderNum();
|
|
|
- }
|
|
|
+ Integer freightAmt = 0;
|
|
|
+
|
|
|
+ List<UserPrizeStorage> prizeStorageList = userPrizeStorageService.list(new LambdaQueryWrapper<UserPrizeStorage>()
|
|
|
+ .eq(UserPrizeStorage::getUserId, userId).eq(UserPrizeStorage::getStatus, PrizeStorageStatusEnum.NOT_DISTRIBUTED)
|
|
|
+ .in(UserPrizeStorage::getStorageId, param.getIds()));
|
|
|
|
|
|
- if (param.getAutoCoupon() == 1) {
|
|
|
- // 系统自动选择优惠券,按照金额从大到小排序
|
|
|
- List<UserCouponVO> userCouponList = userCouponService.listTicketOrderCoupon(userId);
|
|
|
- for (UserCouponVO userCouponVO : userCouponList) {
|
|
|
- if (orderAmt >= userCouponVO.getMinOrderAmt() && orderAmt >= userCouponVO.getDiscount()) {
|
|
|
- if (userCouponVO.getUseArea() == CouponUseAreaEnum.PRE_SCOPE) {
|
|
|
- // 使用范围验证
|
|
|
- List<CouponTicket> couponTicketList = couponTicketService.list(new LambdaQueryWrapper<CouponTicket>()
|
|
|
- .eq(CouponTicket::getCouponId, userCouponVO.getCouponId()).eq(CouponTicket::getBoxId, ticketBox.getBoxId()));
|
|
|
- if (CollectionUtils.isEmpty(couponTicketList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- orderSettleVO.getCouponList().add(userCouponVO);
|
|
|
- discountAmt = userCouponVO.getDiscount();
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (!CollectionUtils.isEmpty(param.getUserCouponIds())){
|
|
|
- // 查询指定券
|
|
|
- orderSettleVO.setCouponList(userCouponService.listTicketOrderCouponByIds(param.getUserCouponIds()));
|
|
|
- }
|
|
|
|
|
|
orderSettleVO.setOrderAmt(orderAmt);
|
|
|
- orderSettleVO.setDiscountAmt(discountAmt);
|
|
|
- // 当前没有运费和优惠,实付金额=订单金额
|
|
|
- orderSettleVO.setPayAmt(orderAmt - discountAmt);
|
|
|
- orderSettleVO.setOrderNum(param.getOrderNum());
|
|
|
- orderSettleVO.setBoxId(param.getBoxId());
|
|
|
- orderSettleVO.setTicketId(param.getTicketId());
|
|
|
- orderSettleVO.setPicUrl(ticketBox.getPicUrl());
|
|
|
+ orderSettleVO.setFreightAmt(freightAmt);
|
|
|
+ orderSettleVO.setPayAmt(orderAmt + freightAmt);
|
|
|
+ orderSettleVO.setPrizeList(prizeStorageList);
|
|
|
|
|
|
// 缓存订单结算对象
|
|
|
- redisCache.setCacheObject(RedisKey.build(RedisKey.USER_TICKET_ORDER_KEY, userId), orderSettleVO, 10, TimeUnit.MINUTES);
|
|
|
+ redisCache.setCacheObject(RedisKey.build(RedisKey.USER_DELIVER_ORDER_KEY, userId), orderSettleVO, 10, TimeUnit.MINUTES);
|
|
|
return AjaxResult.success(orderSettleVO);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
+/*
|
|
|
+ *//**
|
|
|
* 提交订单
|
|
|
- */
|
|
|
+ *//*
|
|
|
@PostMapping("/order/submit")
|
|
|
@ApiOperation(value = "提交订单" , notes = "在订单确认页面提交")
|
|
|
public AjaxResult submit(@RequestBody UserTicketOrder order) {
|
|
@@ -169,9 +139,9 @@ public class UserDeliverOrderController extends BaseApiController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
+ *//**
|
|
|
* 取消订单
|
|
|
- */
|
|
|
+ *//*
|
|
|
@PostMapping("/order/cancel")
|
|
|
@ApiOperation(value = "取消订单" , notes = "在订单列表页面取消")
|
|
|
public AjaxResult cancel(@RequestBody ChannelOrder order) {
|
|
@@ -179,9 +149,9 @@ public class UserDeliverOrderController extends BaseApiController {
|
|
|
return AjaxResult.success("取消成功");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ *//**
|
|
|
* 订单支付
|
|
|
- */
|
|
|
+ *//*
|
|
|
@PostMapping("/order/pay")
|
|
|
@ApiOperation(value = "订单支付" , notes = "在盲票页面支付")
|
|
|
public AjaxResult pay(@Valid @RequestBody OrderPayParam param) {
|
|
@@ -194,6 +164,6 @@ public class UserDeliverOrderController extends BaseApiController {
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
}
|
|
|
return AjaxResult.success(jsonObject);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
}
|