From c5f27ed0f97eaf4884dba50c6de5dde33c9f7df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Fri, 27 Sep 2024 15:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B09.27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FleetMemberController.java | 10 +++ .../fleet/mapper/FleetMemberMapper.java | 2 + .../fleet/mapper/xml/FleetMemberMapper.xml | 6 ++ .../fleet/service/FleetInfoService.java | 7 ++ .../fleet/service/FleetMemberService.java | 7 ++ .../service/impl/FleetInfoServiceImpl.java | 56 +++++++++----- .../service/impl/FleetMemberServiceImpl.java | 74 +++++++++++++++++-- 7 files changed, 135 insertions(+), 27 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetMemberController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetMemberController.java index c96fb1a1e..a0aaedcbf 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetMemberController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetMemberController.java @@ -103,6 +103,16 @@ public class FleetMemberController extends BaseController { public ResponseObject edit(@RequestBody FleetMember fleetMember) { return getSuccessResult(fleetMemberService.update(fleetMember)); } + /** + * 额度调整(pc) + * + * @param fleetMember 实体 + * @return 编辑结果 + */ + @PutMapping("editLimitPC") + public ResponseObject editLimitPC(@RequestBody FleetMember fleetMember) { + return getSuccessResult(fleetMemberService.editLimitPC(fleetMember)); + } /** * 删除数据 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/FleetMemberMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/FleetMemberMapper.java index 8e8dc939b..6d4316cf3 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/FleetMemberMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/FleetMemberMapper.java @@ -10,4 +10,6 @@ import org.apache.ibatis.annotations.Param; public interface FleetMemberMapper extends BaseMapper { IPage queryPage(Page page, @Param("entity") FleetMemberVo fleetMember); IPage queryPageByNameOrMobile(Page page, @Param("entity") FleetMemberVo fleetMember); + + Double selectRemainCreditLimitByFleetId(Integer fleetId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/xml/FleetMemberMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/xml/FleetMemberMapper.xml index 27ddb40c6..e1339718b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/xml/FleetMemberMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/mapper/xml/FleetMemberMapper.xml @@ -63,5 +63,11 @@ ORDER BY create_time DESC + 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 b68f4f509..51b586d3a 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 @@ -77,4 +77,11 @@ public interface FleetInfoService { int addFleetInfo(FleetInfo fleetInfo); FleetInfoUniVo queryByFleetId(Integer fleetId); + + /** + * 通过fleetId查询当前车队剩余可分配的额度 + * @param fleetId + * @return + */ + Double selectRemainCreditLimit(Integer fleetId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetMemberService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetMemberService.java index a4d66c229..0ac7a28fb 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetMemberService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetMemberService.java @@ -87,4 +87,11 @@ public interface FleetMemberService { * @return */ int editLimit(FleetMember fleetMember); + + /** + * PC端额度调整 + * @param fleetMember + * @return + */ + int editLimitPC(FleetMember fleetMember); } 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 c9fa819a6..4c8300b59 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 @@ -50,7 +50,7 @@ import java.util.stream.Collectors; * @since 2024-08-02 10:32:54 */ @Service("fleetInfoService") -public class FleetInfoServiceImpl extends ServiceImpl implements FleetInfoService { +public class FleetInfoServiceImpl extends ServiceImpl implements FleetInfoService { @Autowired private ILJStaffService mtStaffService; @@ -84,12 +84,12 @@ public class FleetInfoServiceImpl extends ServiceImpl IPage fleetInfoVoIPage = baseMapper.queryPage(page, fleetInfo); List list = mtStaffService.queryStaffList(); for (FleetInfoVo record : fleetInfoVoIPage.getRecords()) { - if (ObjectUtil.isNotEmpty(record.getStaffId())){ + if (ObjectUtil.isNotEmpty(record.getStaffId())) { String oilHead = ""; String[] split = record.getStaffId().split(","); for (String staffId : split) { for (LJStaff ljStaff : list) { - if (staffId.equals(ljStaff.getId().toString())){ + if (staffId.equals(ljStaff.getId().toString())) { oilHead += ljStaff.getRealName() + ","; } } @@ -114,7 +114,7 @@ public class FleetInfoServiceImpl extends ServiceImpl @Override public FleetInfo selectByName(String fleetName) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("fleet_name",fleetName); + queryWrapper.eq("fleet_name", fleetName); return baseMapper.selectOne(queryWrapper); } @@ -128,7 +128,7 @@ public class FleetInfoServiceImpl extends ServiceImpl public int insert(FleetInfo fleetInfo) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); FleetInfo fleetInfo1 = selectByName(fleetInfo.getFleetName()); - if (ObjectUtil.isNotEmpty(fleetInfo1)){ + if (ObjectUtil.isNotEmpty(fleetInfo1)) { return 0; } //判断当前车队负责人是否存在账号 @@ -150,13 +150,13 @@ public class FleetInfoServiceImpl extends ServiceImpl .eq(MtUser::getMobile, fleetInfo.getMobile()) .last("limit 1")); createVaseInfo(mtUser, nowAccountInfo.getStoreId().toString(), fleetInfo.getStaffId(), null); - }else { + } else { //判断当前用户是否已加入车队 FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper() .eq(FleetInfo::getUserId, mtUser.getId()) .eq(FleetInfo::getStoreId, nowAccountInfo.getStoreId()) .last("limit 1")); - if (ObjectUtil.isNotEmpty(fleetInfo2)){ + if (ObjectUtil.isNotEmpty(fleetInfo2)) { throw new RuntimeException("当前用户已创建车队"); } } @@ -179,9 +179,9 @@ public class FleetInfoServiceImpl extends ServiceImpl fleetMember.setUserId(mtUser.getId()); fleetMember.setMobile(fleetInfo.getMobile()); fleetMember.setName(fleetInfo.getFleetLeader()); - return fleetMemberMapper.insert(fleetMember); + fleetMemberMapper.insert(fleetMember); } - return 0; + return fleetInfo.getId(); } /** @@ -193,7 +193,7 @@ public class FleetInfoServiceImpl extends ServiceImpl @Override public int update(FleetInfo fleetInfo) { FleetInfo fleetInfo1 = selectByName(fleetInfo.getFleetName()); - if (ObjectUtil.isNotEmpty(fleetInfo1) && !Objects.equals(fleetInfo1.getId(), fleetInfo.getId())){ + if (ObjectUtil.isNotEmpty(fleetInfo1) && !Objects.equals(fleetInfo1.getId(), fleetInfo.getId())) { return 0; } if (ObjectUtil.isNotEmpty(fleetInfo.getRechargeAmount1()) && ObjectUtil.isNotEmpty(fleetInfo.getGiveAmount1())) { @@ -258,7 +258,7 @@ public class FleetInfoServiceImpl extends ServiceImpl public int addFleetInfo(FleetInfo fleetInfo) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); FleetInfo fleetInfo1 = selectByName(fleetInfo.getFleetName()); - if (ObjectUtil.isNotEmpty(fleetInfo1)){ + if (ObjectUtil.isNotEmpty(fleetInfo1)) { return 0; } @@ -267,7 +267,7 @@ public class FleetInfoServiceImpl extends ServiceImpl FleetInfo fleetInfo3 = baseMapper.selectOne(new LambdaQueryWrapper() .eq(FleetInfo::getUserId, nowAccountInfo.getId()) .eq(FleetInfo::getStoreId, fleetInfo.getStoreId())); - if (ObjectUtil.isNotEmpty(fleetInfo3)){ + if (ObjectUtil.isNotEmpty(fleetInfo3)) { throw new RuntimeException("在本店铺已经存在车队"); } //查询当前登陆人 @@ -291,7 +291,7 @@ public class FleetInfoServiceImpl extends ServiceImpl fleetMember.setMobile(mtUser.getMobile()); fleetMember.setName(mtUser.getName()); return fleetMemberMapper.insert(fleetMember); - }else { + } else { throw new RuntimeException("新增车队信息失败"); } } @@ -313,17 +313,32 @@ public class FleetInfoServiceImpl extends ServiceImpl .eq(FleetInfo::getId, fleetId)); - FleetInfoUniVo fleetInfoUniVo = BeanUtil.copyProperties(fleetInfo, FleetInfoUniVo.class); - fleetInfoUniVo.setStoreName(mtStoreMapper.selectById(fleetInfo.getStoreId()).getName()); + FleetInfoUniVo fleetInfoUniVo = BeanUtil.copyProperties(fleetInfo, FleetInfoUniVo.class); + fleetInfoUniVo.setStoreName(mtStoreMapper.selectById(fleetInfo.getStoreId()).getName()); return fleetInfoUniVo; } + /** + * 通过fleetId查询当前车队剩余可分配的额度 + * + * @param fleetId + * @return + */ + @Override + public Double selectRemainCreditLimit(Integer fleetId) { + Double result = fleetMemberMapper.selectRemainCreditLimitByFleetId(fleetId); + //查询当前车队所剩的余额 + FleetInfo fleetInfo = baseMapper.selectById(fleetId); + result = fleetInfo.getTotalBalance() - result; + return result; + } + /** * 创建用户的基础信息 */ - private void createVaseInfo (MtUser mtUser, String storeId,String staffId, String inviterId) { + private void createVaseInfo(MtUser mtUser, String storeId, String staffId, String inviterId) { LJStore store = iljStoreService.selectStoreByStoreId(Integer.parseInt(storeId)); // 根据userid和连锁店id查询是否存在对应的余额信息 @@ -348,7 +363,7 @@ public class FleetInfoServiceImpl extends ServiceImpl } // 新增会员余额信息 userBalanceService.insertUserBalance(userBalanceAdd); - }else { + } else { LJUserGrade ljUserGrade = ljUserGradeService.selectUserGradeByStoreId(Integer.parseInt(storeId)); if (ObjectUtil.isNotEmpty(ljUserGrade) && ObjectUtil.isNotEmpty(ljUserGrade.getId())) { userBalance.setGradeId(ljUserGrade.getId()); @@ -361,21 +376,22 @@ public class FleetInfoServiceImpl extends ServiceImpl MtInvitation mtInvitation = new MtInvitation(); mtInvitation.setUserId(mtUser.getId()); mtInvitation.setStoreId(Integer.parseInt(storeId)); - if (ObjectUtil.isNotEmpty(staffId) && staffId !="") { + if (ObjectUtil.isNotEmpty(staffId) && staffId != "") { mtInvitation.setStaffId(Integer.parseInt(staffId)); } - if (ObjectUtil.isNotEmpty(inviterId) && inviterId !="") { + if (ObjectUtil.isNotEmpty(inviterId) && inviterId != "") { mtInvitation.setInviterId(Integer.parseInt(inviterId)); } - if (!ObjectUtil.isEmpty(store)){ + if (!ObjectUtil.isEmpty(store)) { mtInvitation.setChainStoreId(store.getChainStoreId()); } mtInvitationMapper.insert(mtInvitation); } } + //生成用户编号 private String editUserNo() { Random random = new Random(); 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 0b7fa254d..b7974cdf0 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 @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.business.fleet.entity.FleetInfo; import com.fuint.business.fleet.entity.FleetLinesChange; import com.fuint.business.fleet.entity.FleetMember; +import com.fuint.business.fleet.mapper.FleetInfoMapper; import com.fuint.business.fleet.mapper.FleetLinesChangeMapper; import com.fuint.business.fleet.mapper.FleetMemberMapper; import com.fuint.business.fleet.service.FleetInfoService; @@ -70,6 +71,9 @@ public class FleetMemberServiceImpl extends ServiceImpl queryPage(Page page, FleetMemberVo fleetMember) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); @@ -120,10 +124,10 @@ public class FleetMemberServiceImpl extends ServiceImpl() .eq(FleetMember::getMobile, fleetMember.getMobile()) @@ -212,9 +216,11 @@ public class FleetMemberServiceImpl extends ServiceImpl