更新9.27
This commit is contained in:
parent
c5f27ed0f9
commit
d0d804734b
@ -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
|
||||
|
@ -84,4 +84,11 @@ public interface FleetInfoService {
|
||||
* @return
|
||||
*/
|
||||
Double selectRemainCreditLimit(Integer fleetId);
|
||||
|
||||
/**
|
||||
* 编辑车队信息(小程序)
|
||||
* @param fleetInfo
|
||||
* @return
|
||||
*/
|
||||
int editFleetInfo(FleetInfo fleetInfo);
|
||||
}
|
||||
|
@ -179,9 +179,9 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
|
||||
fleetMember.setUserId(mtUser.getId());
|
||||
fleetMember.setMobile(fleetInfo.getMobile());
|
||||
fleetMember.setName(fleetInfo.getFleetLeader());
|
||||
fleetMemberMapper.insert(fleetMember);
|
||||
return fleetMemberMapper.insert(fleetMember);
|
||||
}
|
||||
return fleetInfo.getId();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,7 +201,7 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
|
||||
fleetInfo.setGiveAmount(fleetInfo1.getGiveAmount() + fleetInfo.getGiveAmount1());
|
||||
fleetInfo.setTotalBalance(fleetInfo1.getTotalBalance() + fleetInfo.getRechargeAmount1() + fleetInfo.getGiveAmount1());
|
||||
}
|
||||
return baseMapper.updateById(fleetInfo);
|
||||
return baseMapper.updateById(fleetInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,39 +261,57 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo
|
||||
if (ObjectUtil.isNotEmpty(fleetInfo1)) {
|
||||
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>()
|
||||
.eq(FleetInfo::getUserId, nowAccountInfo.getId())
|
||||
.eq(FleetInfo::getStoreId, fleetInfo.getStoreId()));
|
||||
if (ObjectUtil.isNotEmpty(fleetInfo3)) {
|
||||
throw new RuntimeException("在本店铺已经存在车队");
|
||||
//注册完成后再查询一次
|
||||
mtUser = mtUserMapper.selectOne(new LambdaQueryWrapper<MtUser>()
|
||||
.eq(MtUser::getMobile, fleetInfo.getMobile())
|
||||
.last("limit 1"));
|
||||
createVaseInfo(mtUser, nowAccountInfo.getStoreId().toString(), fleetInfo.getStaffId(), null);
|
||||
} 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.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<FleetInfo>()
|
||||
.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<FleetInfoMapper, FleetInfo
|
||||
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("编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建用户的基础信息
|
||||
|
@ -72,7 +72,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
private IFleetLinesChangeService fleetLinesChangeService;
|
||||
|
||||
@Autowired
|
||||
private FleetInfoMapper fleetMemberMapper;
|
||||
private FleetInfoMapper fleetInfoMapper;
|
||||
|
||||
@Override
|
||||
public IPage<FleetMemberVo> queryPage(Page page, FleetMemberVo fleetMember) {
|
||||
@ -286,7 +286,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
FleetInfo fleetInfo = fleetMemberMapper.selectById(fleetMember.getFleetId());
|
||||
FleetInfo fleetInfo = fleetInfoMapper.selectById(fleetMember.getFleetId());
|
||||
if (fleetInfo.getTotalBalance() < fleetMember.getAdjustLimit()) {
|
||||
throw new RuntimeException("当前车队卡剩余额度不足,无法扣除");
|
||||
}
|
||||
@ -302,15 +302,33 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
fleetLinesChange.setAdjustLimit(fleetMember.getAdjustLimit());
|
||||
//剩余额度
|
||||
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")) {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
|
||||
fleetMember.setSecondaryCardLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
|
||||
} else {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
|
||||
fleetMember.setSecondaryCardLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
|
||||
}
|
||||
}
|
||||
fleetLinesChange.setCreateBy(nowAccountInfo.getId().toString());
|
||||
fleetLinesChange.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
fleetLinesChangeService.insertFleetLinesChange(fleetLinesChange);
|
||||
int i = fleetLinesChangeService.insertFleetLinesChange(fleetLinesChange);
|
||||
}
|
||||
return baseMapper.updateById(fleetMember);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user