Commit b80635d9 by lpx

# 优化

parent b9a24601
...@@ -41,13 +41,13 @@ public class PlainTypeController extends BaseController { ...@@ -41,13 +41,13 @@ public class PlainTypeController extends BaseController {
private PlainTypeService plainTypeService; private PlainTypeService plainTypeService;
/** /**
* 飞机型号表分页列表 * app端飞机型号表分页列表
*/ */
@GetMapping("/getAllMap") @GetMapping("/getAllMap")
@OperationLog(name = "分组获取飞机型号列表", type = OperationLogType.PAGE) @OperationLog(name = "分组获取飞机型号列表", type = OperationLogType.PAGE)
@ApiOperation(value = "分组获取飞机型号列表", response = PlainTypeQueryVo.class) @ApiOperation(value = "分组获取飞机型号列表", response = PlainTypeQueryVo.class)
public ApiResult<List<PlainTypeBo>> getAllMap() throws Exception { public ApiResult<List<PlainTypeBo>> getAllMap() throws Exception {
List<PlainType> plainTypeList = plainTypeService.getAllMap(); List<PlainType> plainTypeList = plainTypeService.getAppPlainTypePageList();
Map<Integer, List<PlainType>> resultMap; Map<Integer, List<PlainType>> resultMap;
List<PlainTypeBo> plainTypeBoList = new ArrayList<>(); List<PlainTypeBo> plainTypeBoList = new ArrayList<>();
if (!CollectionUtils.isEmpty(plainTypeList)) { if (!CollectionUtils.isEmpty(plainTypeList)) {
......
...@@ -48,5 +48,16 @@ public class McPlainTypeController extends BaseController { ...@@ -48,5 +48,16 @@ public class McPlainTypeController extends BaseController {
return ApiResult.ok(plainTypeList); return ApiResult.ok(plainTypeList);
} }
/**
* 获取空闲飞机型号列表
*/
@GetMapping("/mcPageList")
@OperationLog(name = "获取空闲飞机型号列表", type = OperationLogType.PAGE)
@ApiOperation(value = "获取空闲飞机型号列表", response = PlainTypeQueryVo.class)
@RequiresPermissions("merchant:aircraft:management:view")
public ApiResult<List<PlainType> > getMcPlainTypePageList() throws Exception {
List<PlainType> plainTypePageList = plainTypeService.getAppPlainTypePageList();
return ApiResult.ok(plainTypePageList);
}
} }
package com.jumeirah.api.merchant.controller.order; package com.jumeirah.api.merchant.controller.order;
import com.jumeirah.api.merchant.entity.param.StrokeCompleteParam; import com.jumeirah.common.param.StrokeCompleteParam;
import com.jumeirah.api.merchant.entity.param.StrokeConfirmPaymentParam; import com.jumeirah.api.merchant.entity.param.StrokeConfirmPaymentParam;
import com.jumeirah.api.merchant.entity.param.StrokeDiscountCheckParam; import com.jumeirah.api.merchant.entity.param.StrokeDiscountCheckParam;
import com.jumeirah.api.merchant.entity.param.StrokeQuotedPriceParam;
import com.jumeirah.common.entity.AppUser; import com.jumeirah.common.entity.AppUser;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.enums.StatePaymentStatusEnum; import com.jumeirah.common.enums.StatePaymentStatusEnum;
import com.jumeirah.common.enums.StrokeStatusEnum; import com.jumeirah.common.enums.StrokeStatusEnum;
import com.jumeirah.common.factory.PushFactory; import com.jumeirah.common.factory.PushFactory;
import com.jumeirah.common.param.McStrokePageParam; import com.jumeirah.common.param.McStrokePageParam;
import com.jumeirah.common.param.StrokeQuotedPriceParam;
import com.jumeirah.common.service.AppUserService; import com.jumeirah.common.service.AppUserService;
import com.jumeirah.common.service.StrokeService; import com.jumeirah.common.service.StrokeService;
import com.jumeirah.common.vo.McStrokeQueryVo; import com.jumeirah.common.vo.McStrokeQueryVo;
...@@ -23,7 +23,6 @@ import io.swagger.annotations.Api; ...@@ -23,7 +23,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -61,13 +60,11 @@ public class McStrokeController extends BaseController { ...@@ -61,13 +60,11 @@ public class McStrokeController extends BaseController {
@ApiOperation(value = "完成行程接口", response = ApiResult.class) @ApiOperation(value = "完成行程接口", response = ApiResult.class)
@RequiresPermissions("merchant:order:edit") @RequiresPermissions("merchant:order:edit")
public ApiResult<Boolean> completeStroke(@Validated @RequestBody StrokeCompleteParam strokeCompleteParam) throws Exception { public ApiResult<Boolean> completeStroke(@Validated @RequestBody StrokeCompleteParam strokeCompleteParam) throws Exception {
Stroke stroke = new Stroke(); ApiResult<Boolean> result = strokeService.completeStroke(strokeCompleteParam);
stroke.setId(strokeCompleteParam.getId()) if (result.getData()) {
.setUpdateTime(new Timestamp(System.currentTimeMillis())) sendAppMsg(strokeCompleteParam.getId(), "3", "您的订单已完成");
.setStatus(StrokeStatusEnum.COMPLETED.getCode()); }
boolean flag = strokeService.updateStroke(stroke); return result;
sendAppMsg(strokeCompleteParam.getId(), "3", "您的订单已完成");
return ApiResult.result(flag);
} }
/** /**
...@@ -92,7 +89,7 @@ public class McStrokeController extends BaseController { ...@@ -92,7 +89,7 @@ public class McStrokeController extends BaseController {
@ApiOperation(value = "行程分页列表") @ApiOperation(value = "行程分页列表")
@RequiresPermissions("merchant:order:view") @RequiresPermissions("merchant:order:view")
public ApiResult<Paging<McStrokeQueryVo>> getMyStrokePageList(@Validated @RequestBody McStrokePageParam mcStrokePageParam, @RequestHeader(required = false) String language) throws Exception { public ApiResult<Paging<McStrokeQueryVo>> getMyStrokePageList(@Validated @RequestBody McStrokePageParam mcStrokePageParam, @RequestHeader(required = false) String language) throws Exception {
Paging<McStrokeQueryVo> paging = strokeService.getMcStrokePageList(mcStrokePageParam,language); Paging<McStrokeQueryVo> paging = strokeService.getMcStrokePageList(mcStrokePageParam, language);
return ApiResult.ok(paging); return ApiResult.ok(paging);
} }
...@@ -104,12 +101,11 @@ public class McStrokeController extends BaseController { ...@@ -104,12 +101,11 @@ public class McStrokeController extends BaseController {
@ApiOperation(value = "行程报价接口", response = ApiResult.class) @ApiOperation(value = "行程报价接口", response = ApiResult.class)
@RequiresPermissions("merchant:order:edit") @RequiresPermissions("merchant:order:edit")
public ApiResult<Boolean> updateStroke(@Validated @RequestBody StrokeQuotedPriceParam strokeQuotedPriceParam) throws Exception { public ApiResult<Boolean> updateStroke(@Validated @RequestBody StrokeQuotedPriceParam strokeQuotedPriceParam) throws Exception {
Stroke stroke = new Stroke(); ApiResult<Boolean> result = strokeService.quotedPrice(strokeQuotedPriceParam);
BeanUtils.copyProperties(strokeQuotedPriceParam, stroke); if (result.getData()) {
stroke.setUpdateTime(new Timestamp(System.currentTimeMillis())); sendAppMsg(strokeQuotedPriceParam.getId(), "2", "您的订单已报价");
boolean flag = strokeService.updateStroke(stroke); }
sendAppMsg(strokeQuotedPriceParam.getId(), "2", "您的订单已报价"); return result;
return ApiResult.result(flag);
} }
/** /**
......
package com.jumeirah.api.merchant.controller.plain; package com.jumeirah.api.merchant.controller.plain;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jumeirah.api.merchant.entity.param.McPlainAddParam; import com.jumeirah.api.merchant.entity.param.McPlainAddParam;
import com.jumeirah.common.entity.McPlain; import com.jumeirah.common.entity.McPlain;
import com.jumeirah.common.entity.PlainType; import com.jumeirah.common.entity.PlainType;
...@@ -60,10 +61,15 @@ public class McPlainController extends BaseController { ...@@ -60,10 +61,15 @@ public class McPlainController extends BaseController {
if (checkPtId(mcPlainAddParam)) { if (checkPtId(mcPlainAddParam)) {
return ApiResult.result(ApiCode.PLAIN_TYPE_NOT_FOUND, null); return ApiResult.result(ApiCode.PLAIN_TYPE_NOT_FOUND, null);
} }
//先判断商家此机型是否已经添加过
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
if (checkMcPlain(mcPlainAddParam.getPtId(), jwtToken.getMcId())) {
return ApiResult.result(ApiCode.MC_PLANE_EXISTED, false);
}
McPlain mcPlain = new McPlain(); McPlain mcPlain = new McPlain();
BeanUtils.copyProperties(mcPlainAddParam, mcPlain); BeanUtils.copyProperties(mcPlainAddParam, mcPlain);
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal(); mcPlain.setMcId(jwtToken.getMcId())
mcPlain.setMcId(jwtToken.getMcId()); .setIdleNum(mcPlainAddParam.getAmount());
boolean flag = mcPlainService.saveMcPlain(mcPlain); boolean flag = mcPlainService.saveMcPlain(mcPlain);
return ApiResult.result(flag); return ApiResult.result(flag);
} }
...@@ -87,12 +93,41 @@ public class McPlainController extends BaseController { ...@@ -87,12 +93,41 @@ public class McPlainController extends BaseController {
if (checkPtId(mcPlainAddParam)) { if (checkPtId(mcPlainAddParam)) {
return ApiResult.result(ApiCode.PLAIN_TYPE_NOT_FOUND, null); return ApiResult.result(ApiCode.PLAIN_TYPE_NOT_FOUND, null);
} }
//先判断商家此机型是否已经添加过
McPlain oldMcPlain = mcPlainService.getById(mcPlainAddParam.getId());
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
if (oldMcPlain.getPtId().longValue() != mcPlainAddParam.getPtId().longValue()) {
if (checkMcPlain(mcPlainAddParam.getPtId(), jwtToken.getMcId())) {
return ApiResult.result(ApiCode.MC_PLANE_EXISTED, false);
}
}
int idleNum = oldMcPlain.getIdleNum();
if (mcPlainAddParam.getAmount() < oldMcPlain.getAmount()) {
//减少数量
idleNum = oldMcPlain.getIdleNum() - (oldMcPlain.getAmount() - mcPlainAddParam.getAmount());
idleNum = idleNum >= 0 ? idleNum : 0;
} else if (oldMcPlain.getAmount() < mcPlainAddParam.getAmount()) {
//增加数量
idleNum = oldMcPlain.getIdleNum() + (mcPlainAddParam.getAmount() - oldMcPlain.getAmount());
idleNum = idleNum >= mcPlainAddParam.getAmount() ? mcPlainAddParam.getAmount() : idleNum;
}
McPlain mcPlain = new McPlain(); McPlain mcPlain = new McPlain();
BeanUtils.copyProperties(mcPlainAddParam, mcPlain); BeanUtils.copyProperties(mcPlainAddParam, mcPlain);
mcPlain.setIdleNum(idleNum);
boolean flag = mcPlainService.updateMcPlain(mcPlain); boolean flag = mcPlainService.updateMcPlain(mcPlain);
return ApiResult.result(flag); return ApiResult.result(flag);
} }
private boolean checkMcPlain(Long ptId, Long mcId) {
McPlain oldMcPlain = mcPlainService.getOne(new QueryWrapper<McPlain>().lambda()
.eq(McPlain::getPtId, ptId)
.eq(McPlain::getMcId, mcId));
if (oldMcPlain != null) {
return true;
}
return false;
}
/** /**
* 删除商家飞机表 * 删除商家飞机表
*/ */
......
...@@ -58,4 +58,7 @@ public class McPlain extends BaseEntity { ...@@ -58,4 +58,7 @@ public class McPlain extends BaseEntity {
@ApiModelProperty("所在地城市ID") @ApiModelProperty("所在地城市ID")
private Long cityId; private Long cityId;
@ApiModelProperty("空闲数量")
private Integer idleNum;
} }
...@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 飞机型号表 Mapper 接口 * 飞机型号表 Mapper 接口
...@@ -39,4 +40,10 @@ public interface PlainTypeMapper extends BaseMapper<PlainType> { ...@@ -39,4 +40,10 @@ public interface PlainTypeMapper extends BaseMapper<PlainType> {
*/ */
IPage<PlainTypeQueryVo> getPlainTypePageList(@Param("page") Page page, @Param("param") PlainTypePageParam plainTypePageParam); IPage<PlainTypeQueryVo> getPlainTypePageList(@Param("page") Page page, @Param("param") PlainTypePageParam plainTypePageParam);
/**
* app端飞机型号表分页列表
* @return
*/
List<PlainType> getAppPlainTypePageList();
} }
package com.jumeirah.api.merchant.entity.param; package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity; import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
......
package com.jumeirah.api.merchant.entity.param; package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity; import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
......
...@@ -66,4 +66,11 @@ public interface PlainTypeService extends BaseService<PlainType> { ...@@ -66,4 +66,11 @@ public interface PlainTypeService extends BaseService<PlainType> {
* @return * @return
*/ */
List<PlainType> getAllMap(); List<PlainType> getAllMap();
/**
* 飞机型号表分页列表
* @return
*/
List<PlainType> getAppPlainTypePageList();
} }
...@@ -3,11 +3,14 @@ package com.jumeirah.common.service; ...@@ -3,11 +3,14 @@ package com.jumeirah.common.service;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.param.McStrokePageParam; import com.jumeirah.common.param.McStrokePageParam;
import com.jumeirah.common.param.McStrokePaymentPageParam; import com.jumeirah.common.param.McStrokePaymentPageParam;
import com.jumeirah.common.param.StrokeCompleteParam;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import com.jumeirah.common.param.StrokeQuotedPriceParam;
import com.jumeirah.common.vo.McStrokePaymentQueryVo; import com.jumeirah.common.vo.McStrokePaymentQueryVo;
import com.jumeirah.common.vo.McStrokeQueryVo; import com.jumeirah.common.vo.McStrokeQueryVo;
import com.jumeirah.common.vo.StrokeDetailVo; import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService; import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
...@@ -85,4 +88,18 @@ public interface StrokeService extends BaseService<Stroke> { ...@@ -85,4 +88,18 @@ public interface StrokeService extends BaseService<Stroke> {
* @return * @return
*/ */
Paging<McStrokePaymentQueryVo> getPaymentPageList(McStrokePaymentPageParam mcStrokePaymentPageParam); Paging<McStrokePaymentQueryVo> getPaymentPageList(McStrokePaymentPageParam mcStrokePaymentPageParam);
/**
* 商家端行程报价接口
* @param strokeQuotedPriceParam
* @return
*/
ApiResult<Boolean> quotedPrice(StrokeQuotedPriceParam strokeQuotedPriceParam) throws Exception;
/**
* 完成行程接口
* @param strokeCompleteParam
* @return
*/
ApiResult<Boolean> completeStroke(StrokeCompleteParam strokeCompleteParam) throws Exception;
} }
...@@ -71,4 +71,9 @@ public class PlainTypeServiceImpl extends BaseServiceImpl<PlainTypeMapper, Plain ...@@ -71,4 +71,9 @@ public class PlainTypeServiceImpl extends BaseServiceImpl<PlainTypeMapper, Plain
); );
} }
@Override
public List<PlainType> getAppPlainTypePageList() {
return plainTypeMapper.getAppPlainTypePageList();
}
} }
package com.jumeirah.common.service.impl; package com.jumeirah.common.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumeirah.common.entity.McPlain;
import com.jumeirah.common.entity.Stroke; import com.jumeirah.common.entity.Stroke;
import com.jumeirah.common.enums.StrokeStatusEnum; import com.jumeirah.common.enums.StrokeStatusEnum;
import com.jumeirah.common.mapper.StrokeMapper; import com.jumeirah.common.mapper.StrokeMapper;
import com.jumeirah.common.mq.Queue; import com.jumeirah.common.mq.Queue;
import com.jumeirah.common.param.McStrokePageParam; import com.jumeirah.common.param.McStrokePageParam;
import com.jumeirah.common.param.McStrokePaymentPageParam; import com.jumeirah.common.param.McStrokePaymentPageParam;
import com.jumeirah.common.param.StrokeCompleteParam;
import com.jumeirah.common.param.StrokePageParam; import com.jumeirah.common.param.StrokePageParam;
import com.jumeirah.common.param.StrokeQuotedPriceParam;
import com.jumeirah.common.service.StrokeService; import com.jumeirah.common.service.StrokeService;
import com.jumeirah.common.vo.McStrokePaymentQueryVo; import com.jumeirah.common.vo.McStrokePaymentQueryVo;
import com.jumeirah.common.vo.McStrokeQueryVo; import com.jumeirah.common.vo.McStrokeQueryVo;
import com.jumeirah.common.vo.StrokeDetailVo; import com.jumeirah.common.vo.StrokeDetailVo;
import com.jumeirah.common.vo.StrokeQueryVo; import com.jumeirah.common.vo.StrokeQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl; import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo; import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken; import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
/** /**
* 行程表 服务实现类 * 行程表 服务实现类
* *
...@@ -40,6 +49,8 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp ...@@ -40,6 +49,8 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
@Autowired @Autowired
private StrokeMapper strokeMapper; private StrokeMapper strokeMapper;
@Autowired
private McPlainServiceImpl mcPlainService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -124,4 +135,57 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp ...@@ -124,4 +135,57 @@ public class StrokeServiceImpl extends BaseServiceImpl<StrokeMapper, Stroke> imp
IPage<McStrokePaymentQueryVo> mcStrokePageList = strokeMapper.getPaymentPageList(page, mcStrokePaymentPageParam, jwtToken.getMcId()); IPage<McStrokePaymentQueryVo> mcStrokePageList = strokeMapper.getPaymentPageList(page, mcStrokePaymentPageParam, jwtToken.getMcId());
return new Paging<McStrokePaymentQueryVo>(mcStrokePageList); return new Paging<McStrokePaymentQueryVo>(mcStrokePageList);
} }
@Transactional(rollbackFor = Exception.class)
@Override
public ApiResult<Boolean> quotedPrice(StrokeQuotedPriceParam strokeQuotedPriceParam) throws Exception {
//先判断商家机型是否空闲
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
McPlain mcPlain = mcPlainService.getOne(new QueryWrapper<McPlain>().lambda()
.eq(McPlain::getPtId, strokeQuotedPriceParam.getPlainTypeId())
.eq(McPlain::getMcId, jwtToken.getMcId())
.gt(McPlain::getIdleNum, 0)
.eq(McPlain::getStatus, 0)
);
if (mcPlain == null) {
return ApiResult.result(ApiCode.MC_PLANE_NOT_AVAILABLE, false);
}
Stroke stroke = new Stroke();
BeanUtils.copyProperties(strokeQuotedPriceParam, stroke);
stroke.setUpdateTime(new Timestamp(System.currentTimeMillis()));
boolean flag = this.updateStroke(stroke);
if (flag) {
//报价完成后,商家飞机表空闲数量-1
McPlain newMcPlain = new McPlain();
newMcPlain.setId(mcPlain.getId())
.setIdleNum((mcPlain.getIdleNum() - 1) >= 0 ? (mcPlain.getIdleNum() - 1) : 0);
flag = mcPlainService.updateMcPlain(newMcPlain);
}
return ApiResult.result(flag);
}
@Override
public ApiResult<Boolean> completeStroke(StrokeCompleteParam strokeCompleteParam) throws Exception {
Stroke stroke = new Stroke();
stroke.setId(strokeCompleteParam.getId())
.setUpdateTime(new Timestamp(System.currentTimeMillis()))
.setStatus(StrokeStatusEnum.COMPLETED.getCode());
boolean flag = this.updateStroke(stroke);
Stroke newStroke = this.getById(strokeCompleteParam.getId());
//先判断商家机型是否存在
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
McPlain mcPlain = mcPlainService.getOne(new QueryWrapper<McPlain>().lambda()
.eq(McPlain::getPtId, newStroke.getPlainTypeId())
.eq(McPlain::getMcId, jwtToken.getMcId())
);
if (mcPlain != null) {
//行程完成后需要给商家飞机空闲数量+1
McPlain newMcPlain = new McPlain();
newMcPlain.setId(mcPlain.getId())
.setIdleNum((mcPlain.getIdleNum() + 1) > newMcPlain.getAmount() ? newMcPlain.getAmount()
: (mcPlain.getIdleNum() + 1));
flag = mcPlainService.updateMcPlain(newMcPlain);
}
return ApiResult.result(flag);
}
} }
...@@ -19,5 +19,13 @@ ...@@ -19,5 +19,13 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from plain_type from plain_type
</select> </select>
<select id="getAppPlainTypePageList" resultType="com.jumeirah.common.entity.PlainType">
SELECT
pt.*
FROM
( SELECT DISTINCT mp.pt_id FROM mc_plain mp WHERE mp.idle_num > 0 AND `status` = 0 ) a
LEFT JOIN plain_type pt ON pt.id = a.pt_id
WHERE pt.`status`= 0
</select>
</mapper> </mapper>
...@@ -79,3 +79,5 @@ api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error ...@@ -79,3 +79,5 @@ api.response.code.user.PWD_OR_USERNAME_ERROR=password or phone number error
api.response.code.user.SMS_CODE_ERROR=sms code error api.response.code.user.SMS_CODE_ERROR=sms code error
api.response.code.user.USER_NOT_FOUND=user not found api.response.code.user.USER_NOT_FOUND=user not found
api.response.code.user.PLAIN_TYPE_NOT_FOUND=plain type not found api.response.code.user.PLAIN_TYPE_NOT_FOUND=plain type not found
api.response.code.user.MC_PLANE_NOT_AVAILABLE=This type of aircraft is not available
api.response.code.user.MC_PLANE_EXISTED=This aircraft already exists
...@@ -79,3 +79,5 @@ api.response.code.user.PWD_OR_USERNAME_ERROR=账号或密码错误 ...@@ -79,3 +79,5 @@ api.response.code.user.PWD_OR_USERNAME_ERROR=账号或密码错误
api.response.code.user.SMS_CODE_ERROR=验证码错误 api.response.code.user.SMS_CODE_ERROR=验证码错误
api.response.code.user.USER_NOT_FOUND=用户不存在 api.response.code.user.USER_NOT_FOUND=用户不存在
api.response.code.user.PLAIN_TYPE_NOT_FOUND=飞机类型不存在 api.response.code.user.PLAIN_TYPE_NOT_FOUND=飞机类型不存在
api.response.code.user.MC_PLANE_NOT_AVAILABLE=此机型飞机暂无空闲
api.response.code.user.MC_PLANE_EXISTED=商家此机型飞机已存在
...@@ -121,6 +121,14 @@ public enum ApiCode { ...@@ -121,6 +121,14 @@ public enum ApiCode {
* 飞机类型不存在 * 飞机类型不存在
*/ */
PLAIN_TYPE_NOT_FOUND(6004, "api.response.code.user.PLAIN_TYPE_NOT_FOUND"), PLAIN_TYPE_NOT_FOUND(6004, "api.response.code.user.PLAIN_TYPE_NOT_FOUND"),
/**
* 此机型飞机暂无空闲
*/
MC_PLANE_NOT_AVAILABLE(6005, "api.response.code.user.MC_PLANE_NOT_AVAILABLE"),
/**
* 商家此机型飞机已存在
*/
MC_PLANE_EXISTED(6006, "api.response.code.user.MC_PLANE_EXISTED"),
; ;
private final int code; private final int code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment