更新9.27

This commit is contained in:
许允枞 2024-09-27 17:30:52 +08:00
parent c5f27ed0f9
commit d0d804734b
4 changed files with 105 additions and 24 deletions

View File

@ -63,6 +63,7 @@ public class FleetInfoController extends BaseController {
return getSuccessResult(fleetInfoService.insert(fleetInfo)); return getSuccessResult(fleetInfoService.insert(fleetInfo));
} }
/** /**
* 编辑数据 * 编辑数据
* *
@ -74,6 +75,7 @@ public class FleetInfoController extends BaseController {
return getSuccessResult(fleetInfoService.update(fleetInfo)); return getSuccessResult(fleetInfoService.update(fleetInfo));
} }
/** /**
* 删除数据 * 删除数据
* *
@ -105,6 +107,17 @@ public class FleetInfoController extends BaseController {
return getSuccessResult(fleetInfoService.addFleetInfo(fleetInfo)); return getSuccessResult(fleetInfoService.addFleetInfo(fleetInfo));
} }
/**
* 编辑数据(小程序)
*
* @param fleetInfo 实体
* @return 编辑结果
*/
@PutMapping("edit")
public ResponseObject editXcx(@RequestBody FleetInfo fleetInfo) {
return getSuccessResult(fleetInfoService.editFleetInfo(fleetInfo));
}
/** /**
* 根据车队id查询车队信息 * 根据车队id查询车队信息
* @param fleetId * @param fleetId

View File

@ -84,4 +84,11 @@ public interface FleetInfoService {
* @return * @return
*/ */
Double selectRemainCreditLimit(Integer fleetId); Double selectRemainCreditLimit(Integer fleetId);
/**
* 编辑车队信息(小程序)
* @param fleetInfo
* @return
*/
int editFleetInfo(FleetInfo fleetInfo);
} }

View File

@ -179,9 +179,9 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
fleetMember.setUserId(mtUser.getId()); fleetMember.setUserId(mtUser.getId());
fleetMember.setMobile(fleetInfo.getMobile()); fleetMember.setMobile(fleetInfo.getMobile());
fleetMember.setName(fleetInfo.getFleetLeader()); fleetMember.setName(fleetInfo.getFleetLeader());
fleetMemberMapper.insert(fleetMember); return fleetMemberMapper.insert(fleetMember);
} }
return fleetInfo.getId(); return 0;
} }
/** /**
@ -261,39 +261,57 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
if (ObjectUtil.isNotEmpty(fleetInfo1)) { if (ObjectUtil.isNotEmpty(fleetInfo1)) {
return 0; return 0;
} }
//判断当前车队负责人是否存在账号
MtUser mtUser = mtUserMapper.selectOne(new LambdaQueryWrapper<MtUser>()
.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<FleetInfo>() mtUser = mtUserMapper.selectOne(new LambdaQueryWrapper<MtUser>()
.eq(FleetInfo::getUserId, nowAccountInfo.getId()) .eq(MtUser::getMobile, fleetInfo.getMobile())
.eq(FleetInfo::getStoreId, fleetInfo.getStoreId())); .last("limit 1"));
if (ObjectUtil.isNotEmpty(fleetInfo3)) { createVaseInfo(mtUser, nowAccountInfo.getStoreId().toString(), fleetInfo.getStaffId(), null);
throw new RuntimeException("在本店铺已经存在车队"); } else {
//判断当前用户是否已加入车队
FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
.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.setUserId(mtUser.getId());
fleetInfo.setStoreId(fleetInfo.getStoreId());
fleetInfo.setFleetLeader(mtUser.getName()); fleetInfo.setStoreId(nowAccountInfo.getStoreId());
fleetInfo.setChainStoreId(nowAccountInfo.getChainStoreId());
int insert = baseMapper.insert(fleetInfo); int insert = baseMapper.insert(fleetInfo);
if (insert > 0) { if (insert > 0) {
// fleet_member表新增一条记录 // fleet_member表新增一条记录
FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>() FleetInfo fleetInfo2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
.eq(FleetInfo::getUserId, nowAccountInfo.getId()) .eq(FleetInfo::getUserId, mtUser.getId())
.eq(FleetInfo::getStoreId, fleetInfo.getStoreId())); .eq(FleetInfo::getStoreId, nowAccountInfo.getStoreId()));
FleetMember fleetMember = new FleetMember(); FleetMember fleetMember = new FleetMember();
BeanUtil.copyProperties(fleetInfo, fleetMember); BeanUtil.copyProperties(fleetInfo, fleetMember);
fleetMember.setFleetId(fleetInfo2.getId()); fleetMember.setFleetId(fleetInfo2.getId());
fleetMember.setCarNum(mtUser.getCarNo()); fleetMember.setCarNum(mtUser.getCarNo());
fleetMember.setUserId(mtUser.getId()); fleetMember.setUserId(mtUser.getId());
fleetMember.setMobile(mtUser.getMobile()); fleetMember.setMobile(fleetInfo.getMobile());
fleetMember.setName(mtUser.getName()); fleetMember.setName(fleetInfo.getFleetLeader());
return fleetMemberMapper.insert(fleetMember); fleetMemberMapper.insert(fleetMember);
} else {
throw new RuntimeException("新增车队信息失败");
} }
return fleetInfo.getId();
} }
@Override @Override
@ -334,6 +352,31 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
return result; return result;
} }
/**
* 编辑车队信息(小程序)
*
* @param fleetInfo
* @return
*/
@Override
public int editFleetInfo(FleetInfo fleetInfo) {
FleetInfo fleetInfo1 = selectByName(fleetInfo.getFleetName());
if (ObjectUtil.isNotEmpty(fleetInfo1) && !Objects.equals(fleetInfo1.getId(), fleetInfo.getId())) {
return 0;
}
if (ObjectUtil.isNotEmpty(fleetInfo.getRechargeAmount1()) && ObjectUtil.isNotEmpty(fleetInfo.getGiveAmount1())) {
fleetInfo.setRechargeAmount(fleetInfo1.getRechargeAmount() + fleetInfo.getRechargeAmount1());
fleetInfo.setGiveAmount(fleetInfo1.getGiveAmount() + fleetInfo.getGiveAmount1());
fleetInfo.setTotalBalance(fleetInfo1.getTotalBalance() + fleetInfo.getRechargeAmount1() + fleetInfo.getGiveAmount1());
}
int i = baseMapper.updateById(fleetInfo);
if (i > 0) {
return fleetInfo.getId();
}else {
throw new RuntimeException("编辑失败");
}
}
/** /**
* 创建用户的基础信息 * 创建用户的基础信息

View File

@ -72,7 +72,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
private IFleetLinesChangeService fleetLinesChangeService; private IFleetLinesChangeService fleetLinesChangeService;
@Autowired @Autowired
private FleetInfoMapper fleetMemberMapper; private FleetInfoMapper fleetInfoMapper;
@Override @Override
public IPage<FleetMemberVo> queryPage(Page page, FleetMemberVo fleetMember) { public IPage<FleetMemberVo> queryPage(Page page, FleetMemberVo fleetMember) {
@ -286,7 +286,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
} }
break; break;
case 3: case 3:
FleetInfo fleetInfo = fleetMemberMapper.selectById(fleetMember.getFleetId()); FleetInfo fleetInfo = fleetInfoMapper.selectById(fleetMember.getFleetId());
if (fleetInfo.getTotalBalance() < fleetMember.getAdjustLimit()) { if (fleetInfo.getTotalBalance() < fleetMember.getAdjustLimit()) {
throw new RuntimeException("当前车队卡剩余额度不足,无法扣除"); throw new RuntimeException("当前车队卡剩余额度不足,无法扣除");
} }
@ -302,15 +302,33 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
fleetLinesChange.setAdjustLimit(fleetMember.getAdjustLimit()); fleetLinesChange.setAdjustLimit(fleetMember.getAdjustLimit());
//剩余额度 //剩余额度
if (ObjectUtil.isNotEmpty(fleetMember1.getRemainingCreditLimit())) { if (ObjectUtil.isNotEmpty(fleetMember1.getRemainingCreditLimit())) {
if (fleetMember.getSecondaryCardType() == 3) {
//将车队卡的余额扣减到副卡余额上
FleetInfo fleetInfo = fleetInfoMapper.selectById(fleetMember.getFleetId());
double recharge = fleetInfo.getRechargeAmount() / fleetInfo.getTotalBalance();
double give = fleetInfo.getGiveAmount() / fleetInfo.getTotalBalance();
if (fleetMember.getAdjustType().equals("0")) {
fleetInfo.setTotalBalance(fleetInfo.getTotalBalance() - fleetMember.getAdjustLimit());
//计算充值余额与赠送金额的比例然后相减
fleetInfo.setRechargeAmount(fleetInfo.getRechargeAmount() - (fleetMember.getAdjustLimit() * recharge));
fleetInfo.setGiveAmount(fleetInfo.getGiveAmount() - (fleetMember.getAdjustLimit() * give));
} else {
fleetInfo.setTotalBalance(fleetInfo.getTotalBalance() + fleetMember.getAdjustLimit());
fleetInfo.setRechargeAmount(fleetInfo.getRechargeAmount() + (fleetMember.getAdjustLimit() * recharge));
fleetInfo.setGiveAmount(fleetInfo.getGiveAmount() + (fleetMember.getAdjustLimit() * give));
}
}
if (fleetMember.getAdjustType().equals("0")) { if (fleetMember.getAdjustType().equals("0")) {
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit()); fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
fleetMember.setSecondaryCardLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
} else { } else {
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit()); fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
fleetMember.setSecondaryCardLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
} }
} }
fleetLinesChange.setCreateBy(nowAccountInfo.getId().toString()); fleetLinesChange.setCreateBy(nowAccountInfo.getId().toString());
fleetLinesChange.setCreateTime(DateUtil.date().toLocalDateTime()); fleetLinesChange.setCreateTime(DateUtil.date().toLocalDateTime());
fleetLinesChangeService.insertFleetLinesChange(fleetLinesChange); int i = fleetLinesChangeService.insertFleetLinesChange(fleetLinesChange);
} }
return baseMapper.updateById(fleetMember); return baseMapper.updateById(fleetMember);
} }