diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java index f8a4e92cf..389380323 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java @@ -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)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java index 3d89e4eee..9259db0fd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java @@ -66,4 +66,11 @@ public interface FleetInfoService { * @return */ FleetInfoUniVo queryByStoreId(Integer storeId); + + /** + * 新增车队信息(小程序) + * @param fleetInfo + * @return + */ + int addFleetInfo(FleetInfo fleetInfo); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java index ae3c8eec7..b1025ab0a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java @@ -158,10 +158,12 @@ public class FleetInfoServiceImpl extends ServiceImpl if (insert > 0) { // fleet_member表新增一条记录 FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper() - .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 public FleetInfoUniVo queryByStoreId(Integer storeId) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); - LambdaQueryWrapper 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() + .eq(FleetInfo::getStoreId, storeId) + .eq(FleetInfo::getUserId, nowAccountInfo.getId()) + .last("limit 1")); - LambdaQueryWrapper 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() + .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() + .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("新增车队信息失败"); + } + } + /** * 创建用户的基础信息 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java index faa88d4ae..f3ba7d0e0 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java @@ -129,6 +129,7 @@ public class FleetMemberServiceImpl extends ServiceImpl