Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6814d5aaaf
27 files changed
+346
-12
No files matched your search
@@ -259,6 +259,7 @@ DROP TABLE IF EXISTS wallet_rule_transaction;
|
||||
CREATE TABLE wallet_rule_transaction
|
||||
(
|
||||
id BIGINT(19) not null comment '主键',
|
||||
biz_type VARCHAR(32) default null comment '转账类型',
|
||||
source_wallet_id BIGINT(19) not null comment '源钱包id',
|
||||
target_wallet_id BIGINT(19) not null comment '目标钱包id',
|
||||
source_wallet_balance int not null comment '源钱包余额',
|
||||
|
||||
+2
@@ -19,4 +19,6 @@ public class HardCarDto extends HardCarEntity {
|
||||
|
||||
private String hourType;
|
||||
|
||||
private Long merchantId;
|
||||
|
||||
}
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class HardOrderController {
|
||||
// 判断是否为合作超市管理员工
|
||||
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
|
||||
// 查询用户属于的商户
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.CANTEEN).getData();
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.SUPERMARKET).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
|
||||
// 查询商户和下面的子商户
|
||||
List<Long> mchDtoIds = new java.util.ArrayList<>(List.of(mch.getId()));
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ public class HardOrderTotalController {
|
||||
// 判断是否为合作超市管理员工
|
||||
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
|
||||
// 查询用户属于的商户
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.CANTEEN).getData();
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.SUPERMARKET).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
|
||||
List<Long> mchDtoIds = new ArrayList<>(List.of(mch.getId()));
|
||||
// 查询商户和下面的子商户
|
||||
@@ -97,7 +97,7 @@ public class HardOrderTotalController {
|
||||
// 判断是否为合作超市管理员工
|
||||
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
|
||||
// 查询用户属于的商户
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.CANTEEN).getData();
|
||||
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId(), MerchantTypeEnum.SUPERMARKET).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
|
||||
List<Long> mchDtoIds = new ArrayList<>(List.of(mch.getId()));
|
||||
// 查询商户和下面的子商户
|
||||
|
||||
+2
-1
@@ -115,7 +115,8 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
}
|
||||
if (ObjectUtil.isEmpty(entity.getKsSkuId())) {
|
||||
getSelf().submitKsSpu(spuDetail);
|
||||
} else {
|
||||
}
|
||||
if (ObjectUtil.notEqual(spuDetail.getStatus(), HardKsCheckStatusEnum.CHECK_DONE.getType())) {
|
||||
getSelf().editKsSpu(spuDetail);
|
||||
}
|
||||
return entity.getId();
|
||||
|
||||
+3
@@ -138,6 +138,9 @@
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.merchantId != null">
|
||||
and o.merchant_id = #{dto.merchantId}
|
||||
</if>
|
||||
</where>
|
||||
group by a.product_id
|
||||
order by SUM(a.product_count) desc
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bsd.pjcloud.admin.api.feign;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
@FeignClient(contextId = "remoteUserTransaction", value = ServiceNameConstants.UPMS_SERVICE)
|
||||
public interface RemoteUserTransaction {
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/sys-user-transaction/wallet-transaction-callback")
|
||||
void walletTransationCallback(@RequestParam(required = false) String params);
|
||||
|
||||
}
|
||||
+1
@@ -12,4 +12,5 @@ com.bsd.pjcloud.admin.api.feign.RemoteDictService
|
||||
com.bsd.pjcloud.admin.api.feign.RemoteAuditLogService
|
||||
com.bsd.pjcloud.admin.api.feign.RemoteMenuService
|
||||
com.bsd.pjcloud.admin.api.feign.RemoteRouteConfService
|
||||
com.bsd.pjcloud.admin.api.feign.RemoteUserTransaction
|
||||
com.bsd.pjcloud.admin.api.feign.RemoteMessageService
|
||||
+7
@@ -49,6 +49,13 @@ public class SysUserTransactionController {
|
||||
sysUserTransactionService.applyCallback(dto, tenantId);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "离职退休自动转到消费钱包", description = "离职退休自动转到消费钱包")
|
||||
@PostMapping("/wallet-transaction-callback")
|
||||
public void walletTransationCallback(@RequestParam(required = false) String params) {
|
||||
sysUserTransactionService.walletTransationCallback(params);
|
||||
}
|
||||
|
||||
/* ************************************* end callback end ************************************* */
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
|
||||
+4
@@ -9,10 +9,14 @@ import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserTransactionMapper extends PjcloudBaseMapper<SysUserTransactionEntity> {
|
||||
|
||||
Page<SysUserTransactionVo> scopePageJoin(Page page, @Param("dto") SysUserTransactionDto dto, DataScope dataScope);
|
||||
|
||||
SysUserTransactionVo join(@Param("id") Long userTransactionId);
|
||||
|
||||
List<SysUserTransactionEntity> lastTransationList(@Param("dateStr") String dateStr);
|
||||
}
|
||||
+5
@@ -38,4 +38,9 @@ public interface SysUserTransactionService extends IService<SysUserTransactionEn
|
||||
* 回调
|
||||
*/
|
||||
void applyCallback(ProcessNodeRecordAssignUserParamDto dto, Long tenantId);
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
void walletTransationCallback(String params);
|
||||
}
|
||||
+66
@@ -1,13 +1,19 @@
|
||||
package com.bsd.pjcloud.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.constant.UserTransactionEnum;
|
||||
import com.bsd.pjcloud.admin.api.dto.SysUserTransactionDto;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
|
||||
@@ -18,6 +24,7 @@ import com.bsd.pjcloud.admin.service.SysUserService;
|
||||
import com.bsd.pjcloud.admin.service.SysUserTransactionService;
|
||||
import com.bsd.pjcloud.admin.utils.flow.FlowUtil;
|
||||
import com.bsd.pjcloud.admin.utils.flow.dto.UserTransactionFlowDto;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.resolver.ParamResolver;
|
||||
@@ -27,6 +34,7 @@ import com.bsd.pjcloud.flow.task.api.feign.RemoteFlowEngineService;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
|
||||
import com.bsd.pjcloud.flow.task.dto.TaskParamDto;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletRuleTransactionService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletThirdZyService;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -36,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -57,6 +66,7 @@ public class SysUserTransactionServiceImpl extends ServiceImpl<SysUserTransactio
|
||||
private final RemoteFlowEngineService remoteFlowEngineService;
|
||||
private final RemoteWalletThirdZyService remoteWalletThirdZyService;
|
||||
private final RemoteWalletService remoteWalletService;
|
||||
private final RemoteWalletRuleTransactionService walletRuleTransactionService;
|
||||
|
||||
private final FlowUtil flowUtil;
|
||||
|
||||
@@ -221,4 +231,60 @@ public class SysUserTransactionServiceImpl extends ServiceImpl<SysUserTransactio
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
@Override
|
||||
public void walletTransationCallback(String params) {
|
||||
Long days = 0L;
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.minusDays(days);
|
||||
String dateStr = LocalDateTimeUtil.format(localDate, DatePattern.NORM_DATE_PATTERN);
|
||||
List<SysUserTransactionEntity> list = baseMapper.lastTransationList(dateStr);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
log.info("|{}|离职退休自动转到消费钱包,没有需要处理的数据", TAG);
|
||||
return;
|
||||
}
|
||||
// 用户转账逻辑,把饭卡钱包的钱自动转入到消费钱包
|
||||
|
||||
// 离职人员部门id
|
||||
List<String> leaveDeptIds = List.of(ParamResolver.getStr("USER_TRANSACTION_LEAVE"), ParamResolver.getStr("USER_TRANSACTION_TRANSFER"));
|
||||
List<SysUserTransactionEntity> updateList = new ArrayList<>();
|
||||
for (SysUserTransactionEntity v : list) {
|
||||
try {
|
||||
// 判断用户是否有"自动创建钱包权限"
|
||||
SysUser user = sysUserService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUserId, v.getUserId()));
|
||||
if (ObjectUtil.isEmpty(user)) {
|
||||
log.error("|{}|离职退休自动转到消费钱包,用户<{}>不存在", TAG, v.getUserId());
|
||||
continue;
|
||||
}
|
||||
UserInfo userInfo = sysUserService.findUserInfo(user);
|
||||
String[] roleCodes = userInfo.getRoleCodes();
|
||||
if (!ArrayUtil.contains(roleCodes, CommonRoleConstant.AUTO_CREATE_WALLET)) {
|
||||
log.error("|{}|离职退休自动转到消费钱包,用户<{}>没有自动创建钱包权限", TAG, v.getUserId());
|
||||
continue;
|
||||
}
|
||||
// 判断用户现在是否在退休或者离职部门
|
||||
if (!ArrayUtil.contains(leaveDeptIds.toArray(), String.valueOf(user.getDeptId()))) {
|
||||
log.error("|{}|离职退休自动转到消费钱包,用户<{}>不是离职或者退休部门", TAG, v.getUserId());
|
||||
continue;
|
||||
}
|
||||
// 执行转账逻辑
|
||||
Boolean success = walletRuleTransactionService.userAutoWalletTransation(v.getUserId()).getData();
|
||||
if (success) {
|
||||
SysUserTransactionEntity updateObj = new SysUserTransactionEntity();
|
||||
updateObj.setId(v.getId());
|
||||
updateObj.setWalletTransactionTime(LocalDateTime.now());
|
||||
updateList.add(updateObj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("|{}|离职退休自动转到消费钱包,用户<{}>自动转账失败,error:{}", TAG, v.getUserId(), e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(updateList)) {
|
||||
baseMapper.updateById(updateList);
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-2
@@ -73,7 +73,8 @@
|
||||
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.walletTransactionTimeList != null and dto.walletTransactionTimeList.length == 2">
|
||||
and a.wallet_transaction_time between #{dto.walletTransactionTimeList[0]} and #{dto.walletTransactionTimeList[1]}
|
||||
and a.wallet_transaction_time between #{dto.walletTransactionTimeList[0]} and
|
||||
#{dto.walletTransactionTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.processTimeList != null and dto.processTimeList.length == 2">
|
||||
and a.create_time between #{dto.processTimeList[0]} and #{dto.processTimeList[1]}
|
||||
@@ -97,7 +98,7 @@
|
||||
</sql>
|
||||
|
||||
<select id="scopePageJoin" resultType="com.bsd.pjcloud.admin.api.vo.SysUserTransactionVo">
|
||||
<include refid="selectJoin" />
|
||||
<include refid="selectJoin"/>
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
</where>
|
||||
@@ -108,4 +109,22 @@
|
||||
<include refid="selectJoin"/>
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="lastTransationList" resultType="com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity">
|
||||
SELECT *
|
||||
FROM sys_user_transaction AS t1
|
||||
WHERE t1.del_flag = '0'
|
||||
AND t1.wallet_transaction_time is null
|
||||
AND t1.is_wallet_transaction = '1'
|
||||
AND t1.process_status = '2'
|
||||
and t1.id = (SELECT t2.id
|
||||
FROM sys_user_transaction AS t2
|
||||
WHERE t2.del_flag = '0'
|
||||
AND t2.user_id = t1.user_id
|
||||
AND t2.is_wallet_transaction = '1'
|
||||
AND t2.process_status = '2'
|
||||
ORDER BY t2.create_time DESC
|
||||
LIMIT 1)
|
||||
and DATE_FORMAT(t1.create_time, '%Y-%m-%d') <= #{dateStr}
|
||||
</select>
|
||||
</mapper>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.bsd.pjcloud.daemon.quartz.task;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserTransaction;
|
||||
import com.bsd.pjcloud.daemon.quartz.constants.PjcloudQuartzEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Component("umps")
|
||||
@AllArgsConstructor
|
||||
public class UmpsTask {
|
||||
|
||||
private final RemoteUserTransaction remoteUserTransaction;
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String userWalletTransaction(String para) {
|
||||
log.info("离职退休自动转到消费钱包:{},输入参数{}", LocalDateTime.now(), para);
|
||||
try {
|
||||
remoteUserTransaction.walletTransationCallback(para);
|
||||
log.info("离职退休自动转到消费钱包成功:{}", LocalDateTime.now());
|
||||
} catch (Exception e) {
|
||||
log.error("离职退休自动转到消费钱包错误error:{},时间:{}", e.getMessage(), LocalDateTime.now(), e);
|
||||
}
|
||||
return PjcloudQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant.rule;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 用户转账类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WalletRuleTransationTypeEnum {
|
||||
|
||||
USER_CHANGE("10", "用户手动转账"),
|
||||
LEAVE_AUTO("20", "离职退休自动转账"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
public static WalletRuleTransationTypeEnum valueOfByType(String code) {
|
||||
return Arrays.stream(WalletRuleTransationTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getCode(), code))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
public static WalletRuleTransationTypeEnum descOf(String description) {
|
||||
return Arrays.stream(WalletRuleTransationTypeEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -27,6 +27,12 @@ public class WalletRuleTransactionEntity extends Model<WalletRuleTransactionEnti
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@Schema(description = "业务类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 源钱包id
|
||||
*/
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
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 org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
@FeignClient(contextId = "remoteWalletRuleTransactionService", value = ServiceNameConstants.WALLET_SERVICE)
|
||||
public interface RemoteWalletRuleTransactionService {
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/wallet-rule-transaction/inner/auto-transation")
|
||||
R<Boolean> userAutoWalletTransation(@RequestParam Long userId);
|
||||
|
||||
}
|
||||
+1
@@ -2,6 +2,7 @@ com.bsd.pjcloud.wallet.api.feign.RemoteWalletService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteMchRuleJoinService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteCodeUseService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRechargeService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletRuleTransactionService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteMchService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService
|
||||
com.bsd.pjcloud.wallet.api.feign.RemoteWalletThirdZyService
|
||||
|
||||
+1
-2
@@ -160,8 +160,7 @@ public class WalletManageController {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
WalletManageDto dto = new WalletManageDto();
|
||||
dto.setUserId(user.getId());
|
||||
DataScope dataScope = new DataScope();
|
||||
dataScope.func(DataScopeFuncEnum.ALL);
|
||||
DataScope dataScope = null;
|
||||
return R.ok(walletManageService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -79,8 +79,7 @@ public class WalletTransactionController {
|
||||
public R appGetAll(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
dto.setUserId(user.getId());
|
||||
DataScope dataScope = new DataScope();
|
||||
dataScope.func(DataScopeFuncEnum.ALL);
|
||||
DataScope dataScope = null;
|
||||
return R.ok(walletTransactionService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
+2
-1
@@ -117,7 +117,8 @@ public class WalletRechargeApplyController {
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(walletRechargeApplyService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
walletRechargeApplyService.delByIds(CollUtil.toList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+12
@@ -13,6 +13,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
@@ -50,6 +51,17 @@ public class WalletRuleTransactionController {
|
||||
private final WalletRuleTransactionService walletRuleTransactionService;
|
||||
private final WalletTypeService walletTypeService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@Operation(summary = "离职退休自动转到消费钱包", description = "离职退休自动转到消费钱包")
|
||||
@PostMapping("/inner/auto-transation")
|
||||
public R<Boolean> userAutoWalletTransation(@RequestParam Long userId) {
|
||||
return R.ok(walletRuleTransactionService.userAutoWalletTransation(userId));
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/* ************************************* start app start ************************************* */
|
||||
|
||||
@Operation(summary = "app转账", description = "app转账")
|
||||
|
||||
+6
@@ -12,6 +12,7 @@ import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
import org.springframework.validation.BindingResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public interface WalletRechargeApplyService extends IService<WalletRechargeApplyEntity> {
|
||||
@@ -20,6 +21,11 @@ public interface WalletRechargeApplyService extends IService<WalletRechargeApply
|
||||
|
||||
Boolean edit(WalletRechargeApplyDto dto);
|
||||
|
||||
/**
|
||||
* 通过id删除充值/扣款申请
|
||||
*/
|
||||
void delByIds(ArrayList<Long> list);
|
||||
|
||||
Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto);
|
||||
|
||||
Page<WalletRechargeApplyVo> scopePageList(Page page, WalletRechargeApplyDto dto);
|
||||
|
||||
+5
@@ -16,6 +16,11 @@ public interface WalletRuleTransactionService extends IService<WalletRuleTransac
|
||||
*/
|
||||
Page<WalletRuleTransactionVo> scopePageList(Page page, WalletRuleTransactionDto dto, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
Boolean userAutoWalletTransation(Long userId);
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
|
||||
+30
@@ -29,6 +29,7 @@ import com.bsd.pjcloud.flow.task.constant.NodeStatusEnum;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
|
||||
import com.bsd.pjcloud.flow.task.dto.TaskDto;
|
||||
import com.bsd.pjcloud.flow.task.dto.TaskParamDto;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
@@ -37,6 +38,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
@@ -118,6 +120,34 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除充值/扣款申请
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delByIds(ArrayList<Long> list) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
for (Long v : list) {
|
||||
// 只有未审批和审核中能删除
|
||||
WalletRechargeApplyEntity detail = baseMapper.selectById(v);
|
||||
if (ObjectUtil.isEmpty(detail)) continue;
|
||||
if (ObjectUtil.isNotEmpty(detail.getProcessStatus()) && ObjectUtil.notEqual(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
|
||||
UserInfo userInfo = userService.getByUserId(detail.getUserId()).getData();
|
||||
throw new RuntimeException("用户<" + userInfo.getSysUser().getName() + ">发起的审批不能删除");
|
||||
}
|
||||
// 如果是审批中就取消审批
|
||||
if (ObjectUtil.equals(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
|
||||
TaskParamDto dto = new TaskParamDto();
|
||||
dto.setProcessInstanceIdList(List.of(detail.getProcessId()));
|
||||
flowEngineService.stopProcessInstance(dto).getData();
|
||||
}
|
||||
// 删除申请记录
|
||||
baseMapper.deleteById(v);
|
||||
// 删除申请记录条目
|
||||
rechargeImportService.remove(new LambdaQueryWrapper<WalletRechargeImportEntity>().eq(WalletRechargeImportEntity::getApplyId, v));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto) {
|
||||
Page<WalletRechargeApplyVo> list = baseMapper.pageJoin(page, dto);
|
||||
|
||||
+53
@@ -11,8 +11,10 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.rule.WalletRuleTransationTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransferAccountsDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinUserConfigVo;
|
||||
@@ -41,6 +43,8 @@ import java.util.List;
|
||||
@Service
|
||||
public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTransactionMapper, WalletRuleTransactionEntity> implements WalletRuleTransactionService {
|
||||
|
||||
static private final String TAG = "钱包转账记录";
|
||||
|
||||
private final WalletRuleJoinService walletRuleJoinService;
|
||||
private final WalletManageService walletManageService;
|
||||
private final WalletTransactionService walletTransactionService;
|
||||
@@ -57,6 +61,54 @@ public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTran
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 离职退休自动转到消费钱包
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean userAutoWalletTransation(Long userId) {
|
||||
try {
|
||||
// 饭卡钱包
|
||||
WalletManageEntity eatWallet = walletManageService.getWallet(userId, WalletTypeEnum.EAT);
|
||||
if (ObjectUtil.isEmpty(eatWallet)) {
|
||||
String msg = "用户饭卡钱包不存在userId:" + userId;
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// 消费钱包
|
||||
WalletManageEntity payWallet = walletManageService.getWallet(userId, WalletTypeEnum.PAY);
|
||||
if (ObjectUtil.isEmpty(payWallet)) {
|
||||
String msg = "用户消费钱包不存在userId:" + userId;
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
// 转账金额
|
||||
int transationBalance = eatWallet.getBalance();
|
||||
int targetBalance = payWallet.getBalance() + transationBalance;
|
||||
// 创建转账记录
|
||||
WalletRuleTransactionEntity entity = new WalletRuleTransactionEntity();
|
||||
entity.setBizType(WalletRuleTransationTypeEnum.LEAVE_AUTO.getCode());
|
||||
entity.setSourceWalletId(eatWallet.getId());
|
||||
entity.setTargetWalletId(payWallet.getId());
|
||||
entity.setSourceWalletBalance(eatWallet.getBalance());
|
||||
entity.setTargetWalletBalance(targetBalance);
|
||||
entity.setBalance(transationBalance);
|
||||
entity.setAfterBalance(targetBalance);
|
||||
entity.setBalanceMultiple(100);
|
||||
entity.setIsRefund(YesNoEnum.NO.getCode());
|
||||
baseMapper.insert(entity);
|
||||
// 源头钱包扣减
|
||||
walletTransactionService.reduceWalletBalance(eatWallet.getId(), transationBalance, String.valueOf(entity.getId()), WalletBizEnum.TRANSFER_ACCOUNTS, Boolean.FALSE);
|
||||
// 目标钱包增加
|
||||
walletTransactionService.addWalletBalance(payWallet.getId(), transationBalance, String.valueOf(entity.getId()), WalletBizEnum.TRANSFER_ACCOUNTS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("|{}|用户自动转账错误error:|{}|", TAG, e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
@@ -82,6 +134,7 @@ public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTran
|
||||
if (cuurentTotalTransferBalance > userConfig.getMaxTransferBalance()) {
|
||||
throw new RuntimeException("已经超过最大转账金额限制");
|
||||
}
|
||||
entity.setBizType(WalletRuleTransationTypeEnum.USER_CHANGE.getCode());
|
||||
entity.setSourceWalletId(userConfig.getSourceWalletId());
|
||||
entity.setTargetWalletId(userConfig.getTargetWalletId());
|
||||
entity.setSourceWalletBalance(userConfig.getSourceWalletBalance());
|
||||
|
||||
+6
-1
@@ -23,6 +23,7 @@
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.biz_type,
|
||||
a.source_wallet_id,
|
||||
a.target_wallet_id,
|
||||
a.source_wallet_balance,
|
||||
@@ -42,6 +43,9 @@
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = 0
|
||||
<if test="dto.bizType != null">
|
||||
and a.biz_type = #{dto.bizType}
|
||||
</if>
|
||||
<if test="dto.sourceWalletId != null">
|
||||
and a.source_wallet_id = #{dto.sourceWalletId}
|
||||
</if>
|
||||
@@ -68,7 +72,7 @@
|
||||
targetWalletType.name as targetWalletTypeName,
|
||||
targetWalletType.unique_code as targetWalletTypeCode
|
||||
from wallet_rule_transaction a
|
||||
left join wallet_transaction t on t.biz_id = a.id and biz_type = '6'
|
||||
left join wallet_transaction t on t.biz_id = a.id and t.biz_type = '6'
|
||||
left join wallet_manage sourceWallet on sourceWallet.id = a.source_wallet_id
|
||||
left join wallet_type sourceWalletType on sourceWalletType.id = sourceWallet.wallet_type_id
|
||||
left join wallet_manage targetWallet on targetWallet.id = a.target_wallet_id
|
||||
@@ -96,5 +100,6 @@
|
||||
</if>
|
||||
</where>
|
||||
group by a.id
|
||||
order by a.create_time desc,a.id desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user