|
|
@@ -1,23 +1,24 @@
|
|
|
package org.dromara.backstage.payment.service.impl;
|
|
|
|
|
|
-import org.dromara.common.core.utils.MapstructUtils;
|
|
|
-import org.dromara.common.core.utils.StringUtils;
|
|
|
-import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
-import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
+import org.dromara.backstage.payment.domain.PtBag;
|
|
|
import org.dromara.backstage.payment.domain.bo.PtBagBo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtBagVo;
|
|
|
-import org.dromara.backstage.payment.domain.PtBag;
|
|
|
import org.dromara.backstage.payment.mapper.PtBagMapper;
|
|
|
import org.dromara.backstage.payment.service.IPtBagService;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.SpringUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 账户钱包Service业务层处理
|
|
|
@@ -38,7 +39,7 @@ public class PtBagServiceImpl implements IPtBagService {
|
|
|
* @return 账户钱包
|
|
|
*/
|
|
|
@Override
|
|
|
- public PtBagVo queryById(Long bagId){
|
|
|
+ public PtBagVo queryById(Long bagId) {
|
|
|
return baseMapper.selectVoById(bagId);
|
|
|
}
|
|
|
|
|
|
@@ -115,7 +116,7 @@ public class PtBagServiceImpl implements IPtBagService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(PtBag entity){
|
|
|
+ private void validEntityBeforeSave(PtBag entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
@@ -128,9 +129,41 @@ public class PtBagServiceImpl implements IPtBagService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据Id获取账户钱包余额
|
|
|
+ *
|
|
|
+ * @param userIds 人员Id串,英文逗号分隔
|
|
|
+ * @return 余额串,英文逗号分隔
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String selectAccountBalanceByIds(String userIds) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (Long id : StringUtils.splitTo(userIds, Convert::toLong)) {
|
|
|
+ PtBagBo bo = new PtBagBo();
|
|
|
+ bo.setUserId(id);
|
|
|
+ List<PtBagVo> listVo = SpringUtils.getAopProxy(this).queryList(bo);
|
|
|
+ BigDecimal balance1 = BigDecimal.ZERO;
|
|
|
+ BigDecimal balance2 = BigDecimal.ZERO;
|
|
|
+ Optional<PtBagVo> vo = listVo.stream().filter(p -> "1".equals(p.getBagCode()))
|
|
|
+ .findFirst();
|
|
|
+ if (vo.isPresent()) {
|
|
|
+ balance1 = vo.get().getBalance();
|
|
|
+ }
|
|
|
+ vo = listVo.stream().filter(p -> "3".equals(p.getBagCode()))
|
|
|
+ .findFirst();
|
|
|
+ if (vo.isPresent()) {
|
|
|
+ balance2 = vo.get().getBalance();
|
|
|
+ }
|
|
|
+ BigDecimal total = balance1.add(balance2);
|
|
|
+
|
|
|
+ list.add(total.toString());
|
|
|
+ }
|
|
|
+ return String.join(StringUtils.SEPARATOR, list);
|
|
|
+ }
|
|
|
}
|