更新9.24
This commit is contained in:
parent
f2d74fa386
commit
c7670d1b27
@ -94,5 +94,15 @@ public class FleetInfoController extends BaseController {
|
||||
return getSuccessResult(fleetInfoService.queryByStoreId(storeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据(小程序端)
|
||||
*
|
||||
* @param fleetInfo 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping("/addFleetInfo")
|
||||
public ResponseObject addFleetInfo(@RequestBody FleetInfo fleetInfo) {
|
||||
return getSuccessResult(fleetInfoService.addFleetInfo(fleetInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,4 +66,11 @@ public interface FleetInfoService {
|
||||
* @return
|
||||
*/
|
||||
FleetInfoUniVo queryByStoreId(Integer storeId);
|
||||
|
||||
/**
|
||||
* 新增车队信息(小程序)
|
||||
* @param fleetInfo
|
||||
* @return
|
||||
*/
|
||||
int addFleetInfo(FleetInfo fleetInfo);
|
||||
}
|
||||
|
@ -158,10 +158,12 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper,FleetInfo>
|
||||
if (insert > 0) {
|
||||
// fleet_member表新增一条记录
|
||||
FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
|
||||
.eq(FleetInfo::getUserId, mtUser.getId()));
|
||||
.eq(FleetInfo::getUserId, mtUser.getId())
|
||||
.eq(FleetInfo::getStoreId, nowAccountInfo.getStoreId()));
|
||||
FleetMember fleetMember = new FleetMember();
|
||||
BeanUtil.copyProperties(fleetInfo, fleetMember);
|
||||
fleetMember.setFleetId(fleetInfo2.getId());
|
||||
fleetMember.setCarNum(mtUser.getCarNo());
|
||||
fleetMember.setUserId(mtUser.getId());
|
||||
fleetMember.setMobile(fleetInfo.getMobile());
|
||||
fleetMember.setName(fleetInfo.getFleetLeader());
|
||||
@ -211,28 +213,69 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper,FleetInfo>
|
||||
public FleetInfoUniVo queryByStoreId(Integer storeId) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
|
||||
LambdaQueryWrapper<MtUser> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper1.eq(MtUser::getStoreId, storeId);
|
||||
lambdaQueryWrapper1.eq(MtUser::getId, nowAccountInfo.getId());
|
||||
lambdaQueryWrapper1.last("limit 1");
|
||||
MtUser mtUser = mtUserMapper.selectOne(lambdaQueryWrapper1);
|
||||
FleetInfo fleetInfo = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
|
||||
.eq(FleetInfo::getStoreId, storeId)
|
||||
.eq(FleetInfo::getUserId, nowAccountInfo.getId())
|
||||
.last("limit 1"));
|
||||
|
||||
LambdaQueryWrapper<FleetMember> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(FleetMember::getStoreId, storeId);
|
||||
lambdaQueryWrapper.eq(FleetMember::getUserCardNum, mtUser.getUserNo());
|
||||
lambdaQueryWrapper.last("limit 1");
|
||||
FleetMember fleetMember = fleetMemberMapper.selectOne(lambdaQueryWrapper);
|
||||
|
||||
if (ObjectUtil.isEmpty(fleetMember)) {
|
||||
if (ObjectUtil.isEmpty(fleetInfo)) {
|
||||
throw new RuntimeException("该会员未绑定车队");
|
||||
}
|
||||
|
||||
FleetInfo fleetInfo = baseMapper.selectById(fleetMember.getFleetId());
|
||||
// FleetInfo fleetInfo = baseMapper.selectById(fleetMember.getFleetId());
|
||||
FleetInfoUniVo fleetInfoUniVo = BeanUtil.copyProperties(fleetInfo, FleetInfoUniVo.class);
|
||||
fleetInfoUniVo.setStoreName(mtStoreMapper.selectById(storeId).getName());
|
||||
return fleetInfoUniVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车队信息(小程序)
|
||||
*
|
||||
* @param fleetInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addFleetInfo(FleetInfo fleetInfo) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
FleetInfo fleetInfo1 = selectByName(fleetInfo.getFleetName());
|
||||
if (ObjectUtil.isNotEmpty(fleetInfo1)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//判断当前申请人在本店铺是否有车队
|
||||
FleetInfo fleetInfo3 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
|
||||
.eq(FleetInfo::getUserId, nowAccountInfo.getId())
|
||||
.eq(FleetInfo::getStoreId, fleetInfo.getStoreId()));
|
||||
if (ObjectUtil.isNotEmpty(fleetInfo3)){
|
||||
throw new RuntimeException("在本店铺已经存在车队");
|
||||
}
|
||||
//查询当前登陆人
|
||||
MtUser mtUser = mtUserMapper.selectById(nowAccountInfo.getId());
|
||||
|
||||
|
||||
fleetInfo.setUserId(nowAccountInfo.getId());
|
||||
fleetInfo.setStoreId(fleetInfo.getStoreId());
|
||||
fleetInfo.setFleetLeader(mtUser.getName());
|
||||
int insert = baseMapper.insert(fleetInfo);
|
||||
if (insert > 0) {
|
||||
// fleet_member表新增一条记录
|
||||
FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
|
||||
.eq(FleetInfo::getUserId, nowAccountInfo.getId())
|
||||
.eq(FleetInfo::getStoreId, fleetInfo.getStoreId()));
|
||||
FleetMember fleetMember = new FleetMember();
|
||||
BeanUtil.copyProperties(fleetInfo, fleetMember);
|
||||
fleetMember.setFleetId(fleetInfo2.getId());
|
||||
fleetMember.setCarNum(mtUser.getCarNo());
|
||||
fleetMember.setUserId(mtUser.getId());
|
||||
fleetMember.setMobile(mtUser.getMobile());
|
||||
fleetMember.setName(mtUser.getName());
|
||||
return fleetMemberMapper.insert(fleetMember);
|
||||
}else {
|
||||
throw new RuntimeException("新增车队信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建用户的基础信息
|
||||
|
@ -129,6 +129,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper,FleetM
|
||||
}
|
||||
|
||||
fleetMember.setUserId(mtUser.getId());
|
||||
fleetMember.setCarNum(mtUser.getCarNo());
|
||||
fleetMember.setStoreId(nowAccountInfo.getStoreId());
|
||||
fleetMember.setChainStoreId(nowAccountInfo.getChainStoreId());
|
||||
return baseMapper.insert(fleetMember);
|
||||
|
Loading…
Reference in New Issue
Block a user