feat:android机器硬件管理接口

This commit is contained in:
dzc committed 2025-01-06 16:13:03 +08:00
1 parent f922ddf09b
commit d1db95452e
46 files changed
+1440 -316

No files matched your search

@@ -12,6 +12,7 @@ public enum WalletBizEnum {
UPDATE("1", "更新余额"),
BATCH("2", "批量更新余额"),
RECHARGE("3", "充值"),
PAYMENT("4", "支付"),
;
private final String code;
@@ -0,0 +1,28 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@Builder
@AllArgsConstructor
@NotEmpty
@Data
public class WalletBalanceTransactionDto {
@NotNull(message = "钱包id不能为空")
private Long walletId;
@NotNull(message = "操作金额不能为空")
private Integer price;
@NotEmpty(message = "业务类型关联id不能为空")
private String bizId;
@NotNull(message = "业务类型不能为空")
private WalletBizEnum bizType;
}
@@ -24,10 +24,10 @@ public class WalletSettingEntity extends Model<WalletSettingEntity> {
/**
* 创建者
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="创建者")
@Schema(description="编号")
private Long id;
/**
@@ -0,0 +1,24 @@
package com.bsd.pjcloud.wallet.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "remoteWalletTransactionService", value = ServiceNameConstants.WALLET_SERVICE)
public interface RemoteWalletTransactionService {
@NoToken
@GetMapping("/wallet-transaction/add-balance")
R<WalletTransactionEntity> addWalletBalance(@RequestBody WalletBalanceTransactionDto dto);
@NoToken
@GetMapping("/wallet-transaction/reduce-balance")
R<WalletTransactionEntity> reduceWalletBalance(@RequestBody WalletBalanceTransactionDto dto);
}
@@ -1,4 +1,5 @@
com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService
com.bsd.pjcloud.wallet.api.feign.RemoteWalletTransactionService
@@ -46,9 +46,9 @@ public class MchManageController {
@Inner
@GetMapping("/get-by-id")
public R<MchManageVo> getById(@RequestParam Long id) {
MchManageEntity mchManage = mchManageService.getById(id);
if (ObjectUtil.isEmpty(mchManage)) return R.failed("商户不存在");
return R.ok(BeanUtils.toBean(mchManage, MchManageVo.class));
MchManageVo mchManageVo = mchManageService.join(id);
if (ObjectUtil.isEmpty(mchManageVo)) return R.failed("商户不存在");
return R.ok(mchManageVo);
}
@Inner
@@ -45,7 +45,6 @@ public class WalletManageController {
private final WalletManageService walletManageService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-or-create-wallet")
public R getOrCreateWallet(@RequestParam Long userId, @RequestParam WalletTypeCodeEnum walletTypeCode) {
@@ -79,15 +78,13 @@ public class WalletManageController {
return R.ok(walletManageService.delWalletByUserIds(userIds));
}
@Inner
@GetMapping("/add-price")
public R<Object> addPrice(@RequestParam("userIds") List<Long> userIds){
return R.ok(walletManageService.delWalletByUserIds(userIds));
}
/* ************************************* start 远程调用 start ************************************* */
/**
* 分页查询
*
* @param page 分页对象
* @param walletManage 钱包管理
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_view')")
@@ -103,13 +100,6 @@ public class WalletManageController {
return walletManageService.pageJoin(page, dto);
}
/**
* 通过id查询钱包管理
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_view')")
@@ -117,12 +107,6 @@ public class WalletManageController {
return R.ok(walletManageService.getWallet(id));
}
/**
* 新增钱包管理
*
* @param walletManage 钱包管理
* @return R
*/
@Operation(summary = "新增钱包管理", description = "新增钱包管理")
@SysLog("新增钱包管理")
@PostMapping
@@ -131,12 +115,6 @@ public class WalletManageController {
return R.ok(walletManageService.save(walletManage));
}
/**
* 修改钱包管理
*
* @param walletManage 钱包管理
* @return R
*/
@Operation(summary = "修改钱包管理", description = "修改钱包管理")
@SysLog("修改钱包管理")
@PutMapping
@@ -145,12 +123,6 @@ public class WalletManageController {
return R.ok(walletManageService.updateById(walletManage));
}
/**
* 通过id删除钱包管理
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除钱包管理", description = "通过id删除钱包管理")
@SysLog("通过id删除钱包管理")
@DeleteMapping
@@ -159,14 +131,6 @@ public class WalletManageController {
return R.ok(walletManageService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param walletManage 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_export')")
@@ -8,11 +8,15 @@ 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.annotation.Inner;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -33,26 +37,37 @@ import java.util.List;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/walletTransaction")
@Tag(description = "walletTransaction", name = "会员钱包流水表管理")
@RequestMapping("/wallet-transaction")
@Tag(description = "wallet-transaction", name = "会员钱包流水表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletTransactionController {
private final WalletTransactionService walletTransactionService;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@PostMapping("/add-balance")
public R<WalletTransactionEntity> addWalletBalance(@Valid @RequestBody WalletBalanceTransactionDto dto) {
WalletTransactionEntity walletTransaction = walletTransactionService.addWalletBalance(dto.getWalletId(), dto.getPrice(), dto.getBizId(), dto.getBizType());
if (ObjectUtil.isEmpty(walletTransaction)) return R.failed("增加钱包余额错误");
return R.ok(walletTransaction);
}
@Inner
@PostMapping("/reduce-balance")
public R<WalletTransactionEntity> reduceWalletBalance(@Valid @RequestBody WalletBalanceTransactionDto dto) {
WalletTransactionEntity walletTransaction = walletTransactionService.reduceWalletBalance(dto.getWalletId(), dto.getPrice(), dto.getBizId(), dto.getBizType());
if (ObjectUtil.isEmpty(walletTransaction)) return R.failed("扣减钱包余额");
return R.ok(walletTransaction);
}
/* ************************************* end 远程调用 end ************************************* */
@PutMapping("/update-balance")
@Operation(summary = "更新会员用户余额")
public R<Boolean> updateWalletBalance(@RequestBody WalletTransactionDto dto) {
return R.ok(walletTransactionService.updateWalletBalance(dto));
}
/**
* 分页查询
*
* @param page 分页对象
* @param dto 会员钱包流水表
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_view')")
@@ -68,13 +83,6 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.pageJoin(page, dto));
}
/**
* 通过id查询会员钱包流水表
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_view')")
@@ -82,12 +90,6 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.getById(id));
}
/**
* 新增会员钱包流水表
*
* @param walletTransaction 会员钱包流水表
* @return R
*/
@Operation(summary = "新增会员钱包流水表", description = "新增会员钱包流水表")
@SysLog("新增会员钱包流水表")
@PostMapping
@@ -96,12 +98,6 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.save(walletTransaction));
}
/**
* 修改会员钱包流水表
*
* @param walletTransaction 会员钱包流水表
* @return R
*/
@Operation(summary = "修改会员钱包流水表", description = "修改会员钱包流水表")
@SysLog("修改会员钱包流水表")
@PutMapping
@@ -110,12 +106,6 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.updateById(walletTransaction));
}
/**
* 通过id删除会员钱包流水表
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除会员钱包流水表", description = "通过id删除会员钱包流水表")
@SysLog("通过id删除会员钱包流水表")
@DeleteMapping
@@ -124,14 +114,6 @@ public class WalletTransactionController {
return R.ok(walletTransactionService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param walletTransaction 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletTransaction_export')")
@@ -31,4 +31,11 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
.in(ObjectUtil.isNotEmpty(dto.getIds()), MchManageEntity::getId, dto.getIds());
return selectJoinList(MchManageVo.class, wrapper);
}
default MchManageVo join(Long id) {
MPJLambdaQueryWrapper<MchManageEntity> wrapper = new MPJLambdaQueryWrapper<MchManageEntity>()
.selectAll(MchManageEntity.class)
.eq(MchManageEntity::getId, id);
return selectJoinOne(MchManageVo.class, wrapper);
}
}
@@ -19,6 +19,8 @@ public interface MchManageService extends IService<MchManageEntity> {
Page<MchManageVo> pageJoin(Page page, MchManageDto dto);
MchManageVo join(Long id);
List<MchManageVo> list(MchManageDto dto);
MchManageVo getByDeptId(Long deptId);
@@ -20,7 +20,7 @@ public interface WalletTransactionService extends IService<WalletTransactionEnti
* @param bizType 业务关联分类
* @return 钱包流水
*/
WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, Long bizId, WalletBizEnum bizType);
WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType);
/**
@@ -129,6 +129,19 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
return list;
}
@Override
public MchManageVo join(Long id) {
MchManageVo detail = baseMapper.join(id);
if (ObjectUtil.isNotEmpty(detail)) {
// 部门
SysDept dept = remoteDeptService.getDeptByDeptId(id).getData();
if (ObjectUtil.isNotEmpty(dept)) {
DataUtil.convertDept(detail, dept);
}
}
return detail;
}
@Override
public List<MchManageVo> list(MchManageDto dto) {
return baseMapper.list(dto);
@@ -59,6 +59,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
private final StringRedisTemplate redisTemplate;
@Override
@Transactional(rollbackFor = Exception.class)
public void createWallet(Long userId, Boolean checkPermission) {
@@ -1,20 +1,24 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.wallet.api.dto.WalletSettingDto;
import com.bsd.pjcloud.wallet.api.entity.WalletSettingEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.mapper.WalletSettingMapper;
import com.bsd.pjcloud.wallet.service.WalletSettingService;
import lombok.Data;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* 支付设置
*
@@ -25,14 +29,19 @@ import org.springframework.stereotype.Service;
public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, WalletSettingEntity> implements WalletSettingService {
@Override
@Cacheable(value = CacheConstants.WALLET_SETTING_DETAIL, unless = "#result == null")
@Cacheable(value = CacheConstants.WALLET_SETTING_DETAIL)
public WalletSettingVo getSetting() {
WalletSettingEntity setting = baseMapper.selectOne(new QueryWrapper<>());
if (ObjectUtil.isEmpty(setting)) {
DefaultWalletSetting defaultWalletSetting = new DefaultWalletSetting();
baseMapper.insert(defaultWalletSetting);
return BeanUtils.toBean(defaultWalletSetting, WalletSettingVo.class);
}
return BeanUtils.toBean(setting, WalletSettingVo.class);
}
@Override
@CachePut(value = CacheConstants.WALLET_SETTING_DETAIL, condition = "dto.getId() != null", unless = "#result == null")
@CacheEvict(value = CacheConstants.WALLET_SETTING_DETAIL, allEntries = true)
public void edit(WalletSettingDto dto) {
WalletSettingEntity setting = baseMapper.selectById(dto.getId());
if (ObjectUtil.isEmpty(setting)) {
@@ -42,4 +51,52 @@ public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, W
baseMapper.updateById(updateObj);
}
@Data
private class DefaultWalletSetting extends WalletSettingEntity {
/**
* 编号
*/
private Long id = null;
/**
* 每一餐的上限(分)
*/
private Integer payAmountMealLimit = 20;
/**
* 每一餐的倍数
*/
private BigDecimal payAmountMealTimes = BigDecimal.valueOf(1.5);
/**
* 是否开启每一餐的额外缴费
*/
private String payAmountEnable = YesNoEnum.NO.getCode();
/**
* 是否开启钱包二维码刷新
*/
private String refreshQrCodeEnable = YesNoEnum.NO.getCode();
/**
* 二维码刷新频率
*/
private Integer refreshQrCodeFre = 60;
/**
* 是否开启离线订单的审批
*/
private String offLineOrderApplyEnable = YesNoEnum.YES.getCode();
/**
* 退款理由
*/
private String afterSaleRefundReasons = "";
/**
* 退货理由
*/
private String afterSaleReturnReasons = "";
}
}
@@ -52,7 +52,7 @@ public class WalletTransactionServiceImpl extends ServiceImpl<WalletTransactionM
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CacheConstants.WALLET_DETAIL, key = "#walletId")
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, Long bizId, WalletBizEnum bizType) {
public WalletTransactionEntity reduceWalletBalance(Long walletId, Integer price, String bizId, WalletBizEnum bizType) {
WalletManageEntity wallet = walletManageService.getById(walletId);
if (ObjectUtil.isEmpty(wallet)) {
log.error("|{}|,用户钱包id({})不存在.", TAG, walletId);