更新9.27
This commit is contained in:
parent
8cea951790
commit
c5f27ed0f9
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
|
@ -10,4 +10,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
public interface FleetMemberMapper extends BaseMapper<FleetMember> {
|
||||
IPage<FleetMemberVo> queryPage(Page page, @Param("entity") FleetMemberVo fleetMember);
|
||||
IPage<FleetMemberVo> queryPageByNameOrMobile(Page page, @Param("entity") FleetMemberVo fleetMember);
|
||||
|
||||
Double selectRemainCreditLimitByFleetId(Integer fleetId);
|
||||
}
|
||||
|
@ -63,5 +63,11 @@
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
<select id="selectRemainCreditLimitByFleetId" resultType="java.lang.Double"
|
||||
parameterType="java.lang.Integer">
|
||||
select count(remaining_credit_limit)
|
||||
from fleet_member
|
||||
where fleet_id = #{fleetId} and secondary_card_type = 2
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
@ -77,4 +77,11 @@ public interface FleetInfoService {
|
||||
int addFleetInfo(FleetInfo fleetInfo);
|
||||
|
||||
FleetInfoUniVo queryByFleetId(Integer fleetId);
|
||||
|
||||
/**
|
||||
* 通过fleetId查询当前车队剩余可分配的额度
|
||||
* @param fleetId
|
||||
* @return
|
||||
*/
|
||||
Double selectRemainCreditLimit(Integer fleetId);
|
||||
}
|
||||
|
@ -87,4 +87,11 @@ public interface FleetMemberService {
|
||||
* @return
|
||||
*/
|
||||
int editLimit(FleetMember fleetMember);
|
||||
|
||||
/**
|
||||
* PC端额度调整
|
||||
* @param fleetMember
|
||||
* @return
|
||||
*/
|
||||
int editLimitPC(FleetMember fleetMember);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ import java.util.stream.Collectors;
|
||||
* @since 2024-08-02 10:32:54
|
||||
*/
|
||||
@Service("fleetInfoService")
|
||||
public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper,FleetInfo> implements FleetInfoService {
|
||||
public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper, FleetInfo> implements FleetInfoService {
|
||||
|
||||
@Autowired
|
||||
private ILJStaffService mtStaffService;
|
||||
@ -84,12 +84,12 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper,FleetInfo>
|
||||
IPage<FleetInfoVo> fleetInfoVoIPage = baseMapper.queryPage(page, fleetInfo);
|
||||
List<LJStaff> 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<FleetInfoMapper,FleetInfo>
|
||||
@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<FleetInfoMapper,FleetInfo>
|
||||
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<FleetInfoMapper,FleetInfo>
|
||||
.eq(MtUser::getMobile, fleetInfo.getMobile())
|
||||
.last("limit 1"));
|
||||
createVaseInfo(mtUser, nowAccountInfo.getStoreId().toString(), fleetInfo.getStaffId(), null);
|
||||
}else {
|
||||
} 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)){
|
||||
if (ObjectUtil.isNotEmpty(fleetInfo2)) {
|
||||
throw new RuntimeException("当前用户已创建车队");
|
||||
}
|
||||
}
|
||||
@ -179,9 +179,9 @@ public class FleetInfoServiceImpl extends ServiceImpl<FleetInfoMapper,FleetInfo>
|
||||
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<FleetInfoMapper,FleetInfo>
|
||||
@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<FleetInfoMapper,FleetInfo>
|
||||
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<FleetInfoMapper,FleetInfo>
|
||||
FleetInfo fleetInfo3 = baseMapper.selectOne(new LambdaQueryWrapper<FleetInfo>()
|
||||
.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<FleetInfoMapper,FleetInfo>
|
||||
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<FleetInfoMapper,FleetInfo>
|
||||
.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<FleetInfoMapper,FleetInfo>
|
||||
}
|
||||
// 新增会员余额信息
|
||||
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<FleetInfoMapper,FleetInfo>
|
||||
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();
|
||||
|
@ -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<FleetMemberMapper, Fleet
|
||||
@Autowired
|
||||
private IFleetLinesChangeService fleetLinesChangeService;
|
||||
|
||||
@Autowired
|
||||
private FleetInfoMapper fleetMemberMapper;
|
||||
|
||||
@Override
|
||||
public IPage<FleetMemberVo> queryPage(Page page, FleetMemberVo fleetMember) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
@ -120,10 +124,10 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
public int insert(FleetMember fleetMember) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
//判断当前用户是否是车队负责人
|
||||
FleetInfoUniVo fleetInfoUniVo = fleetInfoService.queryByFleetId(fleetMember.getFleetId());
|
||||
if (ObjectUtil.isNotEmpty(fleetInfoUniVo) && (fleetInfoUniVo.getUserId() != nowAccountInfo.getId())) {
|
||||
throw new RuntimeException("请由车队负责人进行此操作");
|
||||
}
|
||||
// FleetInfoUniVo fleetInfoUniVo = fleetInfoService.queryByFleetId(fleetMember.getFleetId());
|
||||
// if (ObjectUtil.isNotEmpty(fleetInfoUniVo) && (fleetInfoUniVo.getUserId() != nowAccountInfo.getId())) {
|
||||
// throw new RuntimeException("请由车队负责人进行此操作");
|
||||
// }
|
||||
//判断用户是否存在选择的车队
|
||||
FleetMember fleetMember2 = baseMapper.selectOne(new LambdaQueryWrapper<FleetMember>()
|
||||
.eq(FleetMember::getMobile, fleetMember.getMobile())
|
||||
@ -212,9 +216,11 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
if (fleetMember.getAdjustType().equals("0")) {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
|
||||
} else {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit());
|
||||
if (fleetMember1.getRemainingCreditLimit() < fleetMember.getAdjustLimit()) {
|
||||
throw new RuntimeException("当前剩余额度不足,无法扣除");
|
||||
}
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
|
||||
}
|
||||
// fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
|
||||
}
|
||||
fleetLinesChange.setCreateBy(nowAccountInfo.getId().toString());
|
||||
fleetLinesChange.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
@ -244,7 +250,7 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
}
|
||||
|
||||
/**
|
||||
* 额度调整
|
||||
* 额度调整(小程序)
|
||||
*
|
||||
* @param fleetMember
|
||||
* @return
|
||||
@ -255,6 +261,60 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* PC端额度调整
|
||||
*
|
||||
* @param fleetMember
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int editLimitPC(FleetMember fleetMember) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
FleetMember fleetMember1 = queryByMobile(fleetMember);
|
||||
if (ObjectUtil.isNotEmpty(fleetMember1) && fleetMember1.getId() != fleetMember.getId()) {
|
||||
return 0;
|
||||
}
|
||||
//判断副卡的类型 1、共享副卡-不限额;2、共享副卡限额;3、独立副卡
|
||||
switch (fleetMember.getSecondaryCardType()) {
|
||||
case 1:
|
||||
throw new RuntimeException("共享副卡-不限额,暂不支持修改");
|
||||
case 2:
|
||||
//查询所有副卡类型为2的,所剩额度的和
|
||||
Double v = fleetInfoService.selectRemainCreditLimit(fleetMember.getFleetId());
|
||||
if (v < fleetMember.getAdjustLimit()) {
|
||||
throw new RuntimeException("当前车队卡剩余额度不足,无法扣除");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
FleetInfo fleetInfo = fleetMemberMapper.selectById(fleetMember.getFleetId());
|
||||
if (fleetInfo.getTotalBalance() < fleetMember.getAdjustLimit()) {
|
||||
throw new RuntimeException("当前车队卡剩余额度不足,无法扣除");
|
||||
}
|
||||
break;
|
||||
}
|
||||
//添加到车队额度变化表
|
||||
FleetLinesChange fleetLinesChange = new FleetLinesChange();
|
||||
if (ObjectUtil.isNotEmpty(fleetMember)) {
|
||||
fleetLinesChange.setFleetId(fleetMember.getFleetId());
|
||||
fleetLinesChange.setUserId(fleetMember.getUserId());
|
||||
fleetLinesChange.setStoreId(fleetMember.getStoreId());
|
||||
fleetLinesChange.setAdjustType(fleetMember.getAdjustType());
|
||||
fleetLinesChange.setAdjustLimit(fleetMember.getAdjustLimit());
|
||||
//剩余额度
|
||||
if (ObjectUtil.isNotEmpty(fleetMember1.getRemainingCreditLimit())) {
|
||||
if (fleetMember.getAdjustType().equals("0")) {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
|
||||
} else {
|
||||
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
|
||||
}
|
||||
}
|
||||
fleetLinesChange.setCreateBy(nowAccountInfo.getId().toString());
|
||||
fleetLinesChange.setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
fleetLinesChangeService.insertFleetLinesChange(fleetLinesChange);
|
||||
}
|
||||
return baseMapper.updateById(fleetMember);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建用户的基础信息
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user