导入补贴
This commit is contained in:
parent
433fd0f909
commit
3481119859
|
|
@ -11,16 +11,14 @@ import com.bonus.common.core.web.page.TableDataInfo;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 账户资料Controller
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-05
|
||||
*/
|
||||
|
|
@ -56,6 +54,8 @@ public class AccSubsidyController extends BaseController {
|
|||
this.accSubService.batchAccSubsidyAdd(param);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("批量补贴校验")
|
||||
@PostMapping("/batch/add/check")
|
||||
public AjaxResult batchAccSubsidyAddCheck(@RequestBody @Valid AccSubsidyBatchAddParam param) {
|
||||
|
|
@ -64,6 +64,19 @@ public class AccSubsidyController extends BaseController {
|
|||
}
|
||||
return AjaxResult.success(accSubService.batchOperationWalletAddCheck(param));
|
||||
}
|
||||
|
||||
@ApiOperation("批量补贴校验")
|
||||
@PostMapping("/import/add/check")
|
||||
public AjaxResult importAccSubsidyAddCheck(@RequestParam("file") MultipartFile excel) {
|
||||
return AjaxResult.success(accSubService.importOperationWalletAddCheck(excel));
|
||||
}
|
||||
|
||||
@ApiOperation("批量导入补贴")
|
||||
@PostMapping("/batch/import/add")
|
||||
public AjaxResult batchImportAccSubsidyAdd(@RequestBody @Valid AccImportBatchAddParam param) {
|
||||
this.accSubService.batchImportAccSubsidyAdd(param);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
@ApiOperation("批量补贴清空")
|
||||
@PostMapping({"/batch/clear"})
|
||||
public AjaxResult batchAccSubsidyClear(@RequestBody @Valid AccSubsidyBatchClearParam param) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.canteen.core.account.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author xliu
|
||||
* @date 2025/12/2 15:49
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AccImportDTO {
|
||||
|
||||
private String organization;
|
||||
private String orgName;
|
||||
@NonNull
|
||||
private String userCode;
|
||||
private String nickName;
|
||||
private String phone;
|
||||
@NonNull
|
||||
private BigDecimal amount;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Long userId;
|
||||
|
||||
public AccImportDTO() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.bonus.canteen.core.account.domain.param;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.DecimalMax;
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class AccImportBatchAddParam extends BaseEntity {
|
||||
@ApiModelProperty(value = "用户编号")
|
||||
private @NotNull(message = "用户编号不能为空") List<Long> userIds;
|
||||
private List<Map<Long,BigDecimal>> userIdAmountMap;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.bonus.canteen.core.account.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class AccImportOperationWallerErrorVO {
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
@ApiModelProperty("用户姓名")
|
||||
private String nickName;
|
||||
@ApiModelProperty("用户编码")
|
||||
private String userCode;
|
||||
@ApiModelProperty("组织全名")
|
||||
private String deptFullName;
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer userType;
|
||||
@ApiModelProperty("用户手机号")
|
||||
private String phoneNumber;
|
||||
@ApiModelProperty("充值金额")
|
||||
private BigDecimal amount;
|
||||
@ApiModelProperty("失败原因")
|
||||
private String errorMessage;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.canteen.core.account.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class AccImportOperationWalletPreCheckVO {
|
||||
@ApiModelProperty("总人数")
|
||||
private Integer totalUserSum;
|
||||
@ApiModelProperty("有效人数")
|
||||
private Integer validCount;
|
||||
@ApiModelProperty("有效充值总额")
|
||||
private BigDecimal validTotalAmount;
|
||||
@ApiModelProperty("成功用户id集合")
|
||||
private List<Long> validUserIdList;
|
||||
@ApiModelProperty("无效人数")
|
||||
private Integer invalidCount;
|
||||
@ApiModelProperty("失败用户信息集合")
|
||||
private List<AccBatchOperationWallerErrorVO> errVOList;
|
||||
@ApiModelProperty("校验无效用户信息集合")
|
||||
private List<AccImportOperationWallerErrorVO> invalidVOList;
|
||||
|
||||
private List<Map<Long,BigDecimal>> sucVoListMap;
|
||||
@ApiModelProperty("操作金额")
|
||||
private BigDecimal amount;
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -13,14 +13,14 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 账户资料Mapper接口
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-05
|
||||
*/
|
||||
public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
||||
/**
|
||||
* 查询账户资料
|
||||
*
|
||||
*
|
||||
* @param accId 账户资料主键
|
||||
* @return 账户资料
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
|
||||
/**
|
||||
* 查询账户资料列表
|
||||
*
|
||||
*
|
||||
* @param accountInfo 账户资料
|
||||
* @return 账户资料集合
|
||||
*/
|
||||
|
|
@ -38,7 +38,7 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
|
||||
/**
|
||||
* 新增账户资料
|
||||
*
|
||||
*
|
||||
* @param accountInfo 账户资料
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -46,7 +46,7 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
|
||||
/**
|
||||
* 修改账户资料
|
||||
*
|
||||
*
|
||||
* @param accountInfo 账户资料
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -54,7 +54,7 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
|
||||
/**
|
||||
* 删除账户资料
|
||||
*
|
||||
*
|
||||
* @param id 账户资料主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -62,7 +62,7 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
|
||||
/**
|
||||
* 批量删除账户资料
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -80,6 +80,8 @@ public interface AccInfoMapper extends BaseMapper<AccountInfo> {
|
|||
@Param("userIds") List<Long> userIds,
|
||||
@Param("updateBy") String updateBy);
|
||||
List<AccInfoDetailsVO> queryAccInfoByUserIds(@Param("userIds") List<Long> userIds);
|
||||
|
||||
List<AccInfoDetailsVO> queryAccInfoByUserCodes(@Param("userCodes") List<Long> userCodes);
|
||||
AccInfoDetailsVO queryAccInfoByUserId(@Param("userId") Long userId);
|
||||
AccInfoDetailsVO queryAccInfoByUserCode(@Param("userCode") String userCode);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ package com.bonus.canteen.core.account.service;
|
|||
|
||||
import com.bonus.canteen.core.account.domain.param.*;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccBatchOperationWalletPreCheckVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccImportOperationWalletPreCheckVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccOperationListVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -21,4 +23,7 @@ public interface AccSubService {
|
|||
|
||||
List<AccOperationListVO> queryAccSubOperationList(AccWalletOperationQueryParam param);
|
||||
|
||||
AccImportOperationWalletPreCheckVO importOperationWalletAddCheck(MultipartFile excel);
|
||||
|
||||
void batchImportAccSubsidyAdd(AccImportBatchAddParam param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 账户资料Service接口
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-05
|
||||
*/
|
||||
public interface IAccInfoService {
|
||||
/**
|
||||
* 查询账户资料
|
||||
*
|
||||
*
|
||||
* @param id 账户资料主键
|
||||
* @return 账户资料
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ public interface IAccInfoService {
|
|||
|
||||
/**
|
||||
* 查询账户资料列表
|
||||
*
|
||||
*
|
||||
* @return 账户资料集合
|
||||
*/
|
||||
public List<AccInfoDetailsVO> selectAccInfoList(AccountInfoQueryParam accountInfoQueryParam);
|
||||
|
|
@ -37,7 +37,7 @@ public interface IAccInfoService {
|
|||
|
||||
/**
|
||||
* 新增账户资料
|
||||
*
|
||||
*
|
||||
* @param accountInfo 账户资料
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -45,14 +45,14 @@ public interface IAccInfoService {
|
|||
|
||||
/**
|
||||
* 修改账户资料
|
||||
*
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public void updateAccInfo(AccountBalanceEditParam accountBalanceEditParam);
|
||||
|
||||
/**
|
||||
* 批量删除账户资料
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的账户资料主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -69,6 +69,7 @@ public interface IAccInfoService {
|
|||
|
||||
public WalletBalanceVO queryWalletBalance(AccountInfo accountInfo);
|
||||
List<AccInfoDetailsVO> queryAccInfoByUserIds(List<Long> userIds);
|
||||
List<AccInfoDetailsVO> queryAccInfoByUserCodes(List<Long> userCodes);
|
||||
AccInfoDetailsVO queryAccInfoByUserId(Long userId);
|
||||
AccInfoDetailsVO queryAccInfoByUserCode(String userId);
|
||||
void checkAccStatus(AccInfoDetailsVO accInfoVO);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
/**
|
||||
* 账户资料Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-05
|
||||
*/
|
||||
|
|
@ -80,7 +80,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
|||
|
||||
/**
|
||||
* 查询账户资料
|
||||
*
|
||||
*
|
||||
* @param id 账户资料主键
|
||||
* @return 账户资料
|
||||
*/
|
||||
|
|
@ -111,7 +111,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
|||
|
||||
/**
|
||||
* 新增账户资料
|
||||
*
|
||||
*
|
||||
* @param accountInfo 账户资料
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -158,7 +158,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
|||
|
||||
/**
|
||||
* 批量删除账户资料
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的账户资料主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -169,7 +169,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
|||
|
||||
/**
|
||||
* 删除账户资料信息
|
||||
*
|
||||
*
|
||||
* @param users 账户资料主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
|
@ -354,6 +354,12 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
|||
public List<AccInfoDetailsVO> queryAccInfoByUserIds(List<Long> userIds) {
|
||||
return accInfoMapper.queryAccInfoByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccInfoDetailsVO> queryAccInfoByUserCodes(List<Long> userCodes) {
|
||||
return accInfoMapper.queryAccInfoByUserCodes(userCodes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccInfoDetailsVO queryAccInfoByUserId(Long userId) {
|
||||
return accInfoMapper.queryAccInfoByUserId(userId);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
package com.bonus.canteen.core.account.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.bonus.canteen.core.account.constants.AccTradeTypeEnum;
|
||||
import com.bonus.canteen.core.account.constants.AccWalletTypeEnum;
|
||||
import com.bonus.canteen.core.account.domain.AccImportDTO;
|
||||
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
||||
import com.bonus.canteen.core.account.domain.WalletUpdateDTO;
|
||||
import com.bonus.canteen.core.account.domain.param.*;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccBatchOperationWallerErrorVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccBatchOperationWalletPreCheckVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.AccOperationListVO;
|
||||
import com.bonus.canteen.core.account.domain.vo.*;
|
||||
import com.bonus.canteen.core.account.service.AccSubService;
|
||||
import com.bonus.canteen.core.account.service.IAccInfoService;
|
||||
import com.bonus.canteen.core.account.service.IAccTradeService;
|
||||
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||
import com.bonus.canteen.core.account.utils.AccRedisUtils;
|
||||
import com.bonus.canteen.core.common.utils.EasyExcelUtil;
|
||||
import com.bonus.canteen.core.common.utils.MqUtil;
|
||||
import com.bonus.canteen.core.cook.dto.DishesImportCheckResult;
|
||||
import com.bonus.canteen.core.cook.dto.MenuDishesImportDTO;
|
||||
import com.bonus.canteen.core.pay.constants.PayChannelEnum;
|
||||
import com.bonus.canteen.core.pay.constants.PayTypeEnum;
|
||||
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
||||
|
|
@ -30,12 +32,12 @@ import org.springframework.context.annotation.Lazy;
|
|||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class AccSubServiceImpl implements AccSubService {
|
||||
|
|
@ -51,17 +53,19 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
IAccTradeService accTradeService;
|
||||
|
||||
@Resource(
|
||||
name = "smartCanteenTaskExecutor"
|
||||
name = "smartCanteenTaskExecutor"
|
||||
)
|
||||
@Lazy
|
||||
private AsyncTaskExecutor asyncTaskExecutor;
|
||||
|
||||
private static final BigDecimal ONE_HUNDRED = new BigDecimal("100");
|
||||
|
||||
@Transactional(
|
||||
rollbackFor = {Exception.class}
|
||||
rollbackFor = {Exception.class}
|
||||
)
|
||||
public void individualAccSubsidyAdd(AccSubsidyAddParam param) {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(param.getUserId());
|
||||
if(Objects.isNull(accInfoVO)) {
|
||||
if (Objects.isNull(accInfoVO)) {
|
||||
throw new ServiceException("账户不存在");
|
||||
}
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
|
|
@ -74,7 +78,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
walletUpdateDTO.setPayTypeEnum(PayTypeEnum.SUB_GRANT);
|
||||
accWalletInfoService.addAccWalletBalance(walletUpdateDTO);
|
||||
try {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(param.getUserId()),"update");
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(param.getUserId()), "update");
|
||||
String jsonString = JacksonUtil.writeValueAsString(bean);
|
||||
log.info("账户变动发送mq内容:{}", jsonString);
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
|
|
@ -82,18 +86,19 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
log.error("发送MQ消息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(
|
||||
rollbackFor = {Exception.class}
|
||||
rollbackFor = {Exception.class}
|
||||
)
|
||||
public void individualAccSubsidyClear(AccSubsidyClearParam param) {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(param.getUserId());
|
||||
if(Objects.isNull(accInfoVO)) {
|
||||
if (Objects.isNull(accInfoVO)) {
|
||||
throw new ServiceException("账户不存在");
|
||||
}
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
clearAllAccSubsidyHandler(accInfoVO, param);
|
||||
try {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(param.getUserId()),"update");
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(param.getUserId()), "update");
|
||||
String jsonString = JacksonUtil.writeValueAsString(bean);
|
||||
log.info("账户变动发送mq内容:{}", jsonString);
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
|
|
@ -122,7 +127,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
|
||||
private void clearAllAccSubsidyHandler(AccInfoDetailsVO accInfoVO, AccSubsidyClearParam param) {
|
||||
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletType(accInfoVO.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
|
||||
if(Objects.isNull(walletInfo)) {
|
||||
if (Objects.isNull(walletInfo)) {
|
||||
throw new ServiceException("补贴钱包不存在");
|
||||
}
|
||||
WalletUpdateDTO walletUpdateDTO = new WalletUpdateDTO();
|
||||
|
|
@ -147,7 +152,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
|
||||
public void batchAccSubsidyClear(AccSubsidyBatchClearParam param) {
|
||||
log.info("批量清空补贴用户数量:{}", param.getUserIds().size());
|
||||
if(CollUtil.isEmpty(param.getUserIds())) {
|
||||
if (CollUtil.isEmpty(param.getUserIds())) {
|
||||
throw new ServiceException("批量清空补贴用户为空");
|
||||
}
|
||||
List<AccInfoDetailsVO> accInfoVOList = this.accInfoService.queryAccInfoByUserIds(param.getUserIds());
|
||||
|
|
@ -163,7 +168,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
|
||||
public void batchAccSubsidyAdd(AccSubsidyBatchAddParam param) {
|
||||
log.info("批量补贴用户数量:{}", param.getUserIds().size());
|
||||
if(CollUtil.isEmpty(param.getUserIds())) {
|
||||
if (CollUtil.isEmpty(param.getUserIds())) {
|
||||
throw new ServiceException("批量补贴用户为空");
|
||||
}
|
||||
List<AccInfoDetailsVO> accInfoVOList = this.accInfoService.queryAccInfoByUserIds(param.getUserIds());
|
||||
|
|
@ -177,6 +182,70 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void batchImportAccSubsidyAdd(AccImportBatchAddParam param) {
|
||||
log.info("批量补贴用户数量:{}", param.getUserIds().size());
|
||||
if (CollUtil.isEmpty(param.getUserIds())) {
|
||||
throw new ServiceException("批量补贴用户为空");
|
||||
}
|
||||
List<AccInfoDetailsVO> accInfoVOList = this.accInfoService.queryAccInfoByUserIds(param.getUserIds());
|
||||
log.info("批量补贴根据用户编号查询到{}人", accInfoVOList.size());
|
||||
if (CollUtil.isEmpty(accInfoVOList)) {
|
||||
throw new ServiceException("批量补贴查询到的用户为空");
|
||||
} else {
|
||||
this.asyncTaskExecutor.execute(() -> {
|
||||
this.batchImportAccSubsidyAddHandler(accInfoVOList, param.getUserIdAmountMap());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void batchImportAccSubsidyAddHandler(List<AccInfoDetailsVO> accInfoDetails, List<Map<Long,BigDecimal>> mapList) {
|
||||
log.info("批量daoru补贴开始:{}", accInfoDetails.size());
|
||||
AccRedisUtils.lockBatchUpdateAccWallet();
|
||||
try {
|
||||
accInfoDetails.forEach((accInfo) -> {
|
||||
try {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(accInfo.getUserId());
|
||||
if (Objects.isNull(accInfoVO)) {
|
||||
throw new ServiceException(accInfo.getNickName() + "的账户不存在");
|
||||
}
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
WalletUpdateDTO walletUpdateDTO = new WalletUpdateDTO();
|
||||
BigDecimal amount = mapList.stream()
|
||||
.filter(m -> m.containsKey(accInfo.getUserId()))
|
||||
.map(m -> m.get(accInfo.getUserId()))
|
||||
.findFirst()
|
||||
.orElse(BigDecimal.ZERO);
|
||||
walletUpdateDTO.setAmount(amount);
|
||||
walletUpdateDTO.setUserId(accInfo.getUserId());
|
||||
walletUpdateDTO.setAccWalletTypeEnum(AccWalletTypeEnum.SUBSIDY);
|
||||
walletUpdateDTO.setAccTradeTypeEnum(AccTradeTypeEnum.SUBSIDY);
|
||||
walletUpdateDTO.setPayChannelEnum(PayChannelEnum.GC_SYSTEM);
|
||||
walletUpdateDTO.setPayTypeEnum(PayTypeEnum.SUB_GRANT);
|
||||
accWalletInfoService.addAccWalletBalance(walletUpdateDTO);
|
||||
try {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(accInfo.getUserId()), "update");
|
||||
String jsonString = JacksonUtil.writeValueAsString(bean);
|
||||
log.info("账户变动发送mq内容:{}", jsonString);
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
} catch (Exception e) {
|
||||
log.error("发送MQ消息失败", e);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("批量补贴充值异常, 用户id: {}, 用户名称:{}", accInfo.getUserId(), accInfo.getNickName(), ex);
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
log.error("批量补贴系统异常", ex);
|
||||
} finally {
|
||||
AccRedisUtils.unlockBatchUpdateAccWallet();
|
||||
}
|
||||
|
||||
log.info("批量补贴结束");
|
||||
}
|
||||
|
||||
private void batchAccSubsidyAddHandler(List<AccInfoDetailsVO> accInfoDetails, BigDecimal amount) {
|
||||
log.info("批量补贴开始:{}", accInfoDetails.size());
|
||||
AccRedisUtils.lockBatchUpdateAccWallet();
|
||||
|
|
@ -184,7 +253,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
accInfoDetails.forEach((accInfo) -> {
|
||||
try {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(accInfo.getUserId());
|
||||
if(Objects.isNull(accInfoVO)) {
|
||||
if (Objects.isNull(accInfoVO)) {
|
||||
throw new ServiceException(accInfo.getNickName() + "的账户不存在");
|
||||
}
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
|
|
@ -197,7 +266,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
walletUpdateDTO.setPayTypeEnum(PayTypeEnum.SUB_GRANT);
|
||||
accWalletInfoService.addAccWalletBalance(walletUpdateDTO);
|
||||
try {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(accInfo.getUserId()),"update");
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(accInfo.getUserId()), "update");
|
||||
String jsonString = JacksonUtil.writeValueAsString(bean);
|
||||
log.info("账户变动发送mq内容:{}", jsonString);
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
|
|
@ -225,7 +294,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
accInfoDetails.forEach((accInfo) -> {
|
||||
try {
|
||||
AccInfoDetailsVO accInfoVO = this.accInfoService.queryAccInfoByUserId(accInfo.getUserId());
|
||||
if(Objects.isNull(accInfoVO)) {
|
||||
if (Objects.isNull(accInfoVO)) {
|
||||
throw new ServiceException(accInfo.getNickName() + "的账户不存在");
|
||||
}
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
|
|
@ -234,7 +303,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
param.setClearType(clearType);
|
||||
clearAllAccSubsidyHandler(accInfoVO, param);
|
||||
try {
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(accInfo.getUserId()),"update");
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(Math.toIntExact(accInfo.getUserId()), "update");
|
||||
String jsonString = JacksonUtil.writeValueAsString(bean);
|
||||
log.info("账户变动发送mq内容:{}", jsonString);
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
|
|
@ -288,7 +357,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
try {
|
||||
checkAccount(accInfo);
|
||||
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletType(accInfo.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
|
||||
if(Objects.isNull(walletInfo)) {
|
||||
if (Objects.isNull(walletInfo)) {
|
||||
throw new ServiceException("补贴钱包不存在");
|
||||
}
|
||||
walletBal = walletInfo.getWalletBal();
|
||||
|
|
@ -355,6 +424,11 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
accInfoService.checkAccStatus(accInfoVO);
|
||||
}
|
||||
|
||||
private void checkAccountByUserCode(AccInfoDetailsVO accInfo) {
|
||||
AccInfoDetailsVO accInfoVO = accInfoService.queryAccInfoByUserCode(accInfo.getUserCode());
|
||||
accInfoService.checkAccStatus(accInfoVO);
|
||||
}
|
||||
|
||||
private AccBatchOperationWallerErrorVO createErrorVO(AccInfoDetailsVO accInfo, BigDecimal amount, String errMsg) {
|
||||
AccBatchOperationWallerErrorVO errVO = new AccBatchOperationWallerErrorVO();
|
||||
errVO.setUserId(accInfo.getUserId());
|
||||
|
|
@ -367,6 +441,7 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
errVO.setErrorMessage(errMsg);
|
||||
return errVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccOperationListVO> queryAccSubOperationList(AccWalletOperationQueryParam param) {
|
||||
List<AccOperationListVO> operationListVOList = accTradeService.queryAccOperationList(param);
|
||||
|
|
@ -375,6 +450,121 @@ public class AccSubServiceImpl implements AccSubService {
|
|||
// vo.setPhoneNumber(SM4EncryptUtils.sm4Decrypt(vo.getPhoneNumber()));
|
||||
// }
|
||||
// }
|
||||
return operationListVOList ;
|
||||
return operationListVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccImportOperationWalletPreCheckVO importOperationWalletAddCheck(MultipartFile excel) {
|
||||
AccImportOperationWalletPreCheckVO result = new AccImportOperationWalletPreCheckVO();
|
||||
List<AccImportDTO> accImportDTOList = null;
|
||||
List<AccImportOperationWallerErrorVO> errorVOS = new ArrayList<>();
|
||||
try {
|
||||
accImportDTOList = EasyExcelUtil.readSingleExcel(excel, new AccImportDTO(), 2);
|
||||
//校验导入数据
|
||||
errorVOS = checkExcelData(accImportDTOList);
|
||||
if(errorVOS.size() >0){
|
||||
result.setInvalidVOList(errorVOS);
|
||||
result.setRemark("存在部分数据不符合要求,请修改后重新导入");
|
||||
return result;
|
||||
}
|
||||
log.info("批量校验操作人数:{}", accImportDTOList.size());
|
||||
List<Long> userCodes = accImportDTOList.stream()
|
||||
.map(dto -> Long.valueOf(dto.getUserCode()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
java.util.Map<String,BigDecimal> userCodeAmountMap = accImportDTOList.stream()
|
||||
.collect(Collectors.toMap(AccImportDTO::getUserCode, AccImportDTO::getAmount, (v1, v2) -> v1));
|
||||
List<AccInfoDetailsVO> accInfoVOList = accInfoService.queryAccInfoByUserCodes(userCodes);
|
||||
if (CollUtil.isEmpty(accInfoVOList)) {
|
||||
throw new ServiceException("批量补贴查询到的用户为空");
|
||||
}
|
||||
List<AccBatchOperationWallerErrorVO> errVOList = new ArrayList<>();
|
||||
List<Long> sucVoList = new ArrayList<>();
|
||||
List<Map<Long,BigDecimal>> sucVoListMap = new ArrayList<Map<Long,BigDecimal>>();
|
||||
|
||||
for (AccInfoDetailsVO accInfo : accInfoVOList) {
|
||||
try {
|
||||
checkAccountByUserCode(accInfo);
|
||||
sucVoList.add(accInfo.getUserId());
|
||||
Map<Long,BigDecimal> maps = new HashMap<>();
|
||||
maps.put(accInfo.getUserId(),userCodeAmountMap.get(accInfo.getUserCode()).movePointRight(2));
|
||||
sucVoListMap.add(maps);
|
||||
} catch (Exception ex) {
|
||||
errVOList.add(createErrorVO(accInfo, userCodeAmountMap.get(accInfo.getUserCode()).movePointRight(2), ex.getMessage()));
|
||||
}
|
||||
}
|
||||
// 从主集合中提取所有的 userCode
|
||||
java.util.Set<String> mainUserCodes = accInfoVOList.stream()
|
||||
.map(AccInfoDetailsVO::getUserCode)
|
||||
.collect(Collectors.toSet());
|
||||
// 找出次集合中不在主集合中的元素
|
||||
List<AccImportDTO> newCollection = accImportDTOList.stream()
|
||||
.filter(vo -> !mainUserCodes.contains(vo.getUserCode()))
|
||||
.collect(Collectors.toList());
|
||||
for (AccImportDTO bean:newCollection){
|
||||
AccInfoDetailsVO newAccInfo = new AccInfoDetailsVO();
|
||||
newAccInfo.setNickName(bean.getNickName());
|
||||
newAccInfo.setDeptFullName(bean.getUserCode());
|
||||
errVOList.add(createErrorVO(newAccInfo, userCodeAmountMap.get(bean.getUserCode()), "用户或人员编码不存在,请核对!"));
|
||||
}
|
||||
result.setTotalUserSum(accImportDTOList.size());
|
||||
result.setValidCount(accInfoVOList.size());
|
||||
BigDecimal validTotalAmount = sucVoListMap.stream()
|
||||
.map(map -> map.values().iterator().next())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
result.setValidTotalAmount(validTotalAmount);
|
||||
result.setInvalidCount(errVOList.size());
|
||||
result.setErrVOList(errVOList);
|
||||
result.setInvalidVOList(errorVOS);
|
||||
result.setValidUserIdList(sucVoList);
|
||||
result.setSucVoListMap(sucVoListMap);
|
||||
BigDecimal amount = accImportDTOList.stream()
|
||||
.map(AccImportDTO::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
result.setAmount(amount);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<AccImportOperationWallerErrorVO> checkExcelData(List<AccImportDTO> accImportDTOList) {
|
||||
List<AccImportDTO> errorDTOList = new ArrayList<>();
|
||||
errorDTOList = accImportDTOList.stream()
|
||||
.peek(dto -> {
|
||||
List<String> errors = new ArrayList<>();
|
||||
// 检查人员编码
|
||||
if (StringUtils.isBlank(dto.getUserCode())) {
|
||||
errors.add("人员编码为空");
|
||||
}
|
||||
// 检查金额
|
||||
if (dto.getAmount() == null) {
|
||||
errors.add("补助金额为空");
|
||||
} else if (dto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
errors.add("补助金额必须大于0");
|
||||
}
|
||||
// 如果有错误,设置remark
|
||||
if (!errors.isEmpty()) {
|
||||
dto.setRemark(String.join(",", errors));
|
||||
}
|
||||
})
|
||||
.filter(dto -> StringUtils.isNotBlank(dto.getRemark())) // 过滤出有错误的数据
|
||||
.collect(Collectors.toList());
|
||||
System.err.println("不符合要求的errorDTOList长度="+errorDTOList.size());
|
||||
System.err.println("不符合要求的errorDTOList="+errorDTOList);
|
||||
List<AccImportOperationWallerErrorVO> errorVOS = errorDTOList.stream().map(dto -> {
|
||||
AccImportOperationWallerErrorVO errorVO = new AccImportOperationWallerErrorVO();
|
||||
errorVO.setUserCode(dto.getUserCode());
|
||||
errorVO.setNickName(dto.getNickName());
|
||||
errorVO.setPhoneNumber(dto.getPhone());
|
||||
errorVO.setAmount(dto.getAmount());
|
||||
errorVO.setErrorMessage(dto.getRemark());
|
||||
return errorVO;
|
||||
}).collect(Collectors.toList());
|
||||
return errorVOS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class KitchenStaffInfoController extends BaseController {
|
|||
try {
|
||||
return toAjax(kitchenStaffInfoService.deleteKitchenStaffInfoByStaffIds(staffIds));
|
||||
} catch (Exception e) {
|
||||
log.error("修改厨房员工人脸状态失败", e);
|
||||
log.error("删除厨房员工人脸状态失败", e);
|
||||
return error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -448,9 +448,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM account_info ai
|
||||
LEFT JOIN sys_user su ON su.user_id = ai.user_id
|
||||
LEFT JOIN sys_dept co ON co.dept_id = su.dept_id
|
||||
WHERE ai.user_id = #{userId} and ai.del_flag = '0'
|
||||
WHERE ai.user_id = #{userId} and ai.del_flag = '0' and ai.del_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAccInfoByUserCode" resultType="com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO">
|
||||
SELECT ai.account_id,
|
||||
ai.user_id,
|
||||
|
|
@ -463,6 +464,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM sys_user su
|
||||
LEFT JOIN account_info ai ON su.user_id = ai.user_id
|
||||
LEFT JOIN sys_dept co ON co.dept_id = su.dept_id
|
||||
WHERE su.user_code = #{userCode}
|
||||
WHERE su.user_code = #{userCode} and su.del_flag = '0' and ai.del_flag = '0'
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
<select id="queryAccInfoByUserCodes" resultType="com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO">
|
||||
SELECT ai.account_id,
|
||||
ai.user_id,
|
||||
su.user_code,
|
||||
ai.end_date,
|
||||
ai.account_status,
|
||||
su.nick_name,
|
||||
su.phonenumber,
|
||||
su.dept_id,
|
||||
co.dept_full_name,
|
||||
su.user_type
|
||||
FROM account_info ai
|
||||
LEFT JOIN sys_user su ON su.user_id = ai.user_id
|
||||
LEFT JOIN sys_dept co ON co.dept_id = su.dept_id
|
||||
WHERE su.del_flag = '0' and ai.del_flag ='0' and su.user_code in
|
||||
<foreach collection="userCodes" item="userCode" separator="," open="(" close=")">
|
||||
#{userCode}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue