fix:硬件模块bug

This commit is contained in:
dzc committed 2025-01-17 13:19:35 +08:00
1 parent a6a407e87a
commit 4c53c8360e
13 files changed
+54 -22

No files matched your search

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.hard.api.dto.HardGroupDto;
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
import com.bsd.pjcloud.hard.service.HardGroupService;
@@ -41,7 +43,7 @@ public class HardGroupController {
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('hard_hardGroup_view')")
public R pageJoin(@ParameterObject Page page, @ParameterObject HardGroupDto dto) {
return R.ok(hardGroupService.pageJoin(page, dto));
return R.ok(hardGroupService.scopePageList(page, dto));
}
@Operation(summary = "分页查询", description = "分页查询")
@@ -64,7 +66,8 @@ public class HardGroupController {
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardGroup_add')")
public R save(@RequestBody HardGroupEntity hardGroup) {
return R.ok(hardGroupService.save(hardGroup));
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardGroupService.create(hardGroup, user));
}
@Operation(summary = "修改设备分组", description = "修改设备分组")
@@ -72,7 +75,8 @@ public class HardGroupController {
@PutMapping
@PreAuthorize("@pms.hasPermission('hard_hardGroup_edit')")
public R updateById(@RequestBody HardGroupEntity hardGroup) {
return R.ok(hardGroupService.updateById(hardGroup));
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardGroupService.edit(hardGroup, user));
}
@Operation(summary = "通过id删除设备分组", description = "通过id删除设备分组")
@@ -19,7 +19,7 @@ public interface HardGroupMapper extends PjcloudBaseMapper<HardGroupEntity> {
default Page<HardGroupVo> pageJoin(Page page, HardGroupDto dto) {
MPJLambdaWrapper<HardGroupEntity> wrapper = new MPJLambdaWrapper<HardGroupEntity>()
.like(HardGroupEntity::getName, dto.getName());
.like(ObjectUtil.isNotEmpty(dto.getName()),HardGroupEntity::getName, dto.getName());
return selectJoinPage(page, HardGroupVo.class, wrapper);
}
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.dto.HardGroupDto;
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
import com.bsd.pjcloud.hard.api.vo.HardGroupVo;
@@ -12,4 +13,7 @@ public interface HardGroupService extends IService<HardGroupEntity> {
Page<HardGroupVo> scopePageList(Page page, HardGroupDto dto);
Long create(HardGroupEntity hardGroup, PjcloudUser user);
Boolean edit(HardGroupEntity hardGroup, PjcloudUser user);
}
@@ -7,10 +7,10 @@ import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.dto.HardGroupDto;
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
import com.bsd.pjcloud.hard.api.vo.HardGroupVo;
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
import com.bsd.pjcloud.hard.mapper.HardGroupMapper;
import com.bsd.pjcloud.hard.service.HardGroupService;
import lombok.RequiredArgsConstructor;
@@ -66,4 +66,21 @@ public class HardGroupServiceImpl extends ServiceImpl<HardGroupMapper, HardGroup
}
return list;
}
@Override
public Long create(HardGroupEntity hardGroup, PjcloudUser user) {
if (ObjectUtil.isNotEmpty(hardGroup.getDeptId())) {
hardGroup.setDeptId(hardGroup.getDeptId());
}
baseMapper.insert(hardGroup);
return hardGroup.getId();
}
@Override
public Boolean edit(HardGroupEntity hardGroup, PjcloudUser user) {
if (ObjectUtil.isNotEmpty(hardGroup.getDeptId())) {
hardGroup.setDeptId(hardGroup.getDeptId());
}
return baseMapper.updateById(hardGroup) > 0;
}
}
@@ -125,7 +125,7 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
throw new RuntimeException("请设置顶级部门硬件分组");
}
dto.setHardGroupId(deptHardGroup.getHardGroupId());
dto.setDeptId(user.getDeptId());
dto.setDeptId(mch.getDeptId());
// mq地址和端口
dto.setMqSocketAddress(mqttConfig.getAndroidAddress());
dto.setMqSocketPort(mqttConfig.getAndroidPort());
@@ -160,6 +160,7 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
if (ObjectUtil.isEmpty(deptHardGroup)) {
throw new RuntimeException("请设置顶级部门硬件分组");
}
dto.setDeptId(mch.getDeptId());
dto.setHardGroupId(deptHardGroup.getHardGroupId());
if (!ObjectUtil.equals(dto.getMerchantId(), detail.getMerchantId())) {
// topic
@@ -229,7 +229,7 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
}
@Override
@GlobalTransactional
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Boolean agreeAfterSale(Long userId, Long id) {
HardAfterSaleEntity afterSale = validateAfterSaleAuditable(id);
@@ -241,7 +241,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
/* ************************************* start 支付相关 start ************************************* */
@Override
@GlobalTransactional
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Long createOrder(HardCreateOrderDto dto) {
if (!validateCreateOrderDto(dto)) return null;
@@ -269,8 +269,12 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
totalPrice = hardCarService.computerCarTotalPrice(dto.getSysType(), dto.getOrderType(), dto.getList());
if (isExtraPrice) extraPrice = computeExtraPrice(totalPrice);
payPrice = totalPrice + extraPrice;
// 判断余额够不够支付
if (isPay && wallet.getBalance() < payPrice) throw new RuntimeException("钱包余额不足");
if (isPay) {
// 如果是支付的话,不能小于等于0
if (payPrice <= 0) throw new RuntimeException("支付金额为0元");
// 判断余额够不够支付
if (wallet.getBalance() < payPrice) throw new RuntimeException("钱包余额不足");
}
// 添加购物车
Long parentCarId = hardCarService.createCard(dto.getUserId(), dto.getMerchantId(), dto.getSysType(), dto.getOrderType(), dto.getList());
// 获取商品描述
@@ -305,7 +309,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
@Override
@GlobalTransactional
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Long appCreateOrder(@Valid HardAppCreateOrderDto dto) {
// 钱包
@@ -424,7 +428,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
@Override
@GlobalTransactional
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public void cancelCode(HardOrderEntity order) {
HardOrderTypeEnum orderTypeEnum = HardOrderTypeEnum.valueOfByType(order.getOrderType());
@@ -43,7 +43,9 @@ public class MqttService {
options.setCleanSession(true);
options.setUserName(mqttConfig.getUsername());
options.setPassword(mqttConfig.getPassword().toCharArray());
// crtAuth(options);
if (mqttConfig.getHostUrl().contains("ssl:")) {
crtAuth(options);
}
client.setCallback(mqttCallBack);
client.connect(options);
if (!client.isConnected()) {
@@ -33,9 +33,9 @@ public class MchManageEntity extends Model<MchManageEntity> {
private Long id;
/**
* 绑定的部门id
* 绑定的部门id - 商户的部门id
*/
@Schema(description="绑定的部门id")
@Schema(description="商户的部门id")
private Long deptId;
/**
@@ -95,7 +95,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
}
@Override
@CacheEvict(value = CacheConstants.WALLET_MCH, key = "#dto.getId()", condition = "#dto.getId() != null")
// @CacheEvict(value = CacheConstants.WALLET_MCH, key = "#dto.getId()", condition = "#dto.getId() != null")
public void edit(MchManageEntity dto) {
if (existName(dto.getName(), dto.getId())) {
throw new CheckedException("商户名不能重复");
@@ -105,7 +105,7 @@ public class WalletCodeUseServiceImpl extends ServiceImpl<WalletCodeUseMapper, W
}
@Override
@GlobalTransactional
// @GlobalTransactional
@Transactional(rollbackFor = Exception.class)
public Boolean cancelCode(Long id) {
WalletCodeUseEntity codeUse = baseMapper.selectOne(new LambdaQueryWrapper<WalletCodeUseEntity>()
@@ -30,7 +30,7 @@ import java.util.List;
public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, WalletSettingEntity> implements WalletSettingService {
@Override
@Cacheable(value = CacheConstants.WALLET_SETTING_DETAIL)
// @Cacheable(value = CacheConstants.WALLET_SETTING_DETAIL)
public WalletSettingVo getSetting() {
WalletSettingEntity setting = baseMapper.selectOne(new QueryWrapper<>());
if (ObjectUtil.isEmpty(setting)) {
@@ -42,7 +42,7 @@ public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, W
}
@Override
@CacheEvict(value = CacheConstants.WALLET_SETTING_DETAIL, allEntries = true)
// @CacheEvict(value = CacheConstants.WALLET_SETTING_DETAIL, allEntries = true)
public void edit(WalletSettingDto dto) {
WalletSettingEntity setting = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(setting)) {
@@ -69,7 +69,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
// @CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
WalletManageEntity wallet = walletManageService.getById(walletId);
if (ObjectUtil.isEmpty(wallet)) {
@@ -97,7 +97,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
// @CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
public WalletTransactionEntity addWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
WalletManageEntity wallet = walletManageService.getById(walletId);
if (ObjectUtil.isEmpty(wallet)) {
@@ -133,7 +133,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
}
@Override
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#dto.getWalletId()")
// @CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#dto.getWalletId()")
public Boolean updateWalletBalance(WalletTransactionDto dto) {
WalletManageEntity wallet = walletManageService.getWallet(dto.getWalletId());
if (ObjectUtil.isEmpty(wallet)) {