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 6d6121793..5a40cb6a9 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 @@ -63,6 +63,7 @@ public class FleetInfoController extends BaseController { return getSuccessResult(fleetInfoService.insert(fleetInfo)); } + /** * 编辑数据 * @@ -74,6 +75,7 @@ public class FleetInfoController extends BaseController { return getSuccessResult(fleetInfoService.update(fleetInfo)); } + /** * 删除数据 * @@ -105,6 +107,17 @@ public class FleetInfoController extends BaseController { return getSuccessResult(fleetInfoService.addFleetInfo(fleetInfo)); } + /** + * 编辑数据(小程序) + * + * @param fleetInfo 实体 + * @return 编辑结果 + */ + @PutMapping("edit") + public ResponseObject editXcx(@RequestBody FleetInfo fleetInfo) { + return getSuccessResult(fleetInfoService.editFleetInfo(fleetInfo)); + } + /** * 根据车队id查询车队信息 * @param fleetId 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 51b586d3a..49573e489 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 @@ -84,4 +84,11 @@ public interface FleetInfoService { * @return */ Double selectRemainCreditLimit(Integer fleetId); + + /** + * 编辑车队信息(小程序) + * @param fleetInfo + * @return + */ + int editFleetInfo(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 4c8300b59..367c39aed 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 @@ -179,9 +179,9 @@ public class FleetInfoServiceImpl extends ServiceImpl() + .eq(MtUser::getMobile, fleetInfo.getMobile()) + .last("limit 1")); + if (ObjectUtil.isEmpty(mtUser)) { + mtUser = new MtUser(); + mtUser.setUserNo(editUserNo()); + mtUser.setMobile(fleetInfo.getMobile()); + mtUser.setName(fleetInfo.getFleetLeader()); + mtUser.setDescription("车队信息自动注册"); + mtUser.setCreateTime(DateUtil.date()); + mtUserMapper.insert(mtUser); - //判断当前申请人在本店铺是否有车队 - FleetInfo fleetInfo3 = baseMapper.selectOne(new LambdaQueryWrapper() - .eq(FleetInfo::getUserId, nowAccountInfo.getId()) - .eq(FleetInfo::getStoreId, fleetInfo.getStoreId())); - if (ObjectUtil.isNotEmpty(fleetInfo3)) { - throw new RuntimeException("在本店铺已经存在车队"); + //注册完成后再查询一次 + mtUser = mtUserMapper.selectOne(new LambdaQueryWrapper() + .eq(MtUser::getMobile, fleetInfo.getMobile()) + .last("limit 1")); + createVaseInfo(mtUser, nowAccountInfo.getStoreId().toString(), fleetInfo.getStaffId(), null); + } else { + //判断当前用户是否已加入车队 + FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetInfo::getUserId, mtUser.getId()) + .eq(FleetInfo::getStoreId, nowAccountInfo.getStoreId()) + .last("limit 1")); + if (ObjectUtil.isNotEmpty(fleetInfo2)) { + throw new RuntimeException("当前用户已创建车队"); + } } - //查询当前登陆人 - MtUser mtUser = mtUserMapper.selectById(nowAccountInfo.getId()); - fleetInfo.setUserId(nowAccountInfo.getId()); - fleetInfo.setStoreId(fleetInfo.getStoreId()); - fleetInfo.setFleetLeader(mtUser.getName()); + fleetInfo.setUserId(mtUser.getId()); + + fleetInfo.setStoreId(nowAccountInfo.getStoreId()); + fleetInfo.setChainStoreId(nowAccountInfo.getChainStoreId()); 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())); + .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(mtUser.getMobile()); - fleetMember.setName(mtUser.getName()); - return fleetMemberMapper.insert(fleetMember); - } else { - throw new RuntimeException("新增车队信息失败"); + fleetMember.setMobile(fleetInfo.getMobile()); + fleetMember.setName(fleetInfo.getFleetLeader()); + fleetMemberMapper.insert(fleetMember); } + return fleetInfo.getId(); } @Override @@ -334,6 +352,31 @@ public class FleetInfoServiceImpl extends ServiceImpl 0) { + return fleetInfo.getId(); + }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 b7974cdf0..d03f1114e 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 @@ -72,7 +72,7 @@ public class FleetMemberServiceImpl extends ServiceImpl queryPage(Page page, FleetMemberVo fleetMember) { @@ -286,7 +286,7 @@ public class FleetMemberServiceImpl extends ServiceImpl