|
@@ -1,26 +1,29 @@
|
|
|
package com.qs.mp.web.controller.api.channel;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.qs.mp.admin.domain.TicketPackage;
|
|
|
+import com.qs.mp.admin.service.ITicketPackageService;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.domain.ChannelOrderDetail;
|
|
|
import com.qs.mp.channel.domain.ChannelTicketTransfer;
|
|
|
import com.qs.mp.channel.domain.param.ChannelMyTicketQueryParam;
|
|
|
import com.qs.mp.channel.domain.param.ChannelTicketTransferParam;
|
|
|
import com.qs.mp.channel.domain.vo.ChannelMyTicketVO;
|
|
|
import com.qs.mp.channel.service.IChannelOrderDetailService;
|
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
|
+import com.qs.mp.channel.service.IChannelTicketTransferService;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
+import com.qs.mp.common.enums.ChannelCertifyStatusEnum;
|
|
|
import com.qs.mp.common.enums.TicketPkgSaleStatusEnum;
|
|
|
import com.qs.mp.common.utils.StringUtils;
|
|
|
import com.qs.mp.utils.SecurityUtils;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiResponse;
|
|
|
-import io.swagger.annotations.ApiResponses;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 我的盲票相关接口
|
|
@@ -38,6 +41,12 @@ public class ChannelMyTicketController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IChannelService channelService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IChannelTicketTransferService channelTicketTransferService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITicketPackageService ticketPackageService;
|
|
|
+
|
|
|
@PostMapping("list")
|
|
|
@ApiOperation("我的盲票列表")
|
|
|
@ApiResponses(
|
|
@@ -58,10 +67,13 @@ public class ChannelMyTicketController extends BaseApiController {
|
|
|
|
|
|
@PostMapping("/channel/mobile")
|
|
|
@ApiOperation("根据手机号获取经销商信息")
|
|
|
+ @ApiImplicitParams(
|
|
|
+ @ApiImplicitParam(name = "mobile", value = "手机号", required = true, dataType = "String", paramType = "query")
|
|
|
+ )
|
|
|
@ApiResponses(
|
|
|
@ApiResponse(code = 200, message = "成功", response = Channel.class)
|
|
|
)
|
|
|
- public AjaxResult channelInfoByMobile(@RequestBody String mobile) {
|
|
|
+ public AjaxResult channelInfoByMobile(@RequestParam String mobile) {
|
|
|
Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
if (channelId == null) {
|
|
|
return AjaxResult.error("非法调用");
|
|
@@ -69,7 +81,9 @@ public class ChannelMyTicketController extends BaseApiController {
|
|
|
if (StringUtils.isBlank(mobile)) {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
- Channel channel = channelService.getOne(new LambdaQueryWrapper<Channel>().eq(Channel::getMobile, mobile));
|
|
|
+ Channel channel = channelService.getOne(new LambdaQueryWrapper<Channel>()
|
|
|
+ .eq(Channel::getMobile, mobile)
|
|
|
+ .eq(Channel::getLevel, 0));
|
|
|
|
|
|
return AjaxResult.success(channel);
|
|
|
}
|
|
@@ -77,5 +91,55 @@ public class ChannelMyTicketController extends BaseApiController {
|
|
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("/transfer/save")
|
|
|
+ @ApiOperation("盲票转让")
|
|
|
+ public AjaxResult transfer(@RequestBody ChannelTicketTransferParam channelTicketTransferParam) {
|
|
|
+ // 自己为转让人
|
|
|
+ Long transferChannelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ if (transferChannelId == null) {
|
|
|
+ return AjaxResult.error("非法调用");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(channelTicketTransferParam.getBoxId()) ||
|
|
|
+ StringUtils.isBlank(channelTicketTransferParam.getPkgId()) ||
|
|
|
+ Objects.isNull(channelTicketTransferParam.getChannelId()) ||
|
|
|
+ StringUtils.isBlank(channelTicketTransferParam.getMobile())) {
|
|
|
+ return AjaxResult.error("转让参数不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验受让人信息
|
|
|
+ Channel channel = channelService.getOne(new LambdaQueryWrapper<Channel>()
|
|
|
+ .eq(Channel::getChannelId, channelTicketTransferParam.getChannelId())
|
|
|
+ .eq(Channel::getLevel, 0));
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ return AjaxResult.error("受让人信息不存在");
|
|
|
+ }
|
|
|
+ if (ChannelCertifyStatusEnum.NOT_CERTIFIED.equals(channel.getCertifyStatus())) {
|
|
|
+ return AjaxResult.error("受让人未认证");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验当前操作的盲票是否为自己的盲票
|
|
|
+ int count = channelOrderDetailService.count(new LambdaQueryWrapper<ChannelOrderDetail>()
|
|
|
+ .eq(ChannelOrderDetail::getChannelId, transferChannelId)
|
|
|
+ .eq(ChannelOrderDetail::getPkgId, channelTicketTransferParam.getPkgId()));
|
|
|
+ if (count == 0) {
|
|
|
+ return AjaxResult.error("非法操作他人盲票");
|
|
|
+ }
|
|
|
+ // 校验票包是否为待售状态
|
|
|
+ count = ticketPackageService.count(new LambdaQueryWrapper<TicketPackage>().eq(TicketPackage::getPkgId, channelTicketTransferParam.getPkgId())
|
|
|
+ .eq(TicketPackage::getSaleStatus, TicketPkgSaleStatusEnum.WAIT_SALE));
|
|
|
+ if (count == 0) {
|
|
|
+ return AjaxResult.error("票包不为待售状态");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转让盲票
|
|
|
+ boolean flag = channelTicketTransferService.transferTicket(transferChannelId, channelTicketTransferParam);
|
|
|
+
|
|
|
+ return AjaxResult.success(flag);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|