|
|
@@ -1,7 +1,9 @@
|
|
|
package org.dromara.backstage.payment.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
+import org.dromara.backstage.payment.service.IPtBagService;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -17,6 +19,8 @@ import org.dromara.backstage.payment.domain.PtUserAccount;
|
|
|
import org.dromara.backstage.payment.mapper.PtUserAccountMapper;
|
|
|
import org.dromara.backstage.payment.service.IPtUserAccountService;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
|
@@ -29,10 +33,12 @@ import java.util.Collection;
|
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
|
|
|
private final PtUserAccountMapper baseMapper;
|
|
|
private final IPtCardService ptCardService;
|
|
|
+ private final IPtBagService bagService;
|
|
|
|
|
|
/**
|
|
|
* 查询一卡通账户
|
|
|
@@ -249,4 +255,54 @@ public class PtUserAccountServiceImpl implements IPtUserAccountService {
|
|
|
}
|
|
|
return userIds.length;
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 开户
|
|
|
+ *
|
|
|
+ * date 2024-08-08 16:37:49 16:37
|
|
|
+ * @author: luoyibo
|
|
|
+ * @param userIds 账户Id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int openAccount(Long[] userIds) {
|
|
|
+ for (Long userId : userIds){
|
|
|
+ //先初始化钱包
|
|
|
+ bagService.initAccountBag(userId);
|
|
|
+ //更新开户状态
|
|
|
+ baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getAccountStatus,"1")
|
|
|
+ .eq(PtUserAccount::getUserId,userId));
|
|
|
+ }
|
|
|
+ return userIds.length;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 销户
|
|
|
+ *
|
|
|
+ * date 2024-08-08 16:29:11 16:29
|
|
|
+ * @author: luoyibo
|
|
|
+ * @param userIds 账户Id
|
|
|
+ * @return 销户的结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean closeAccount(Long[] userIds) {
|
|
|
+ List<String> notCloseList = new ArrayList<>();
|
|
|
+ for (Long userId : userIds){
|
|
|
+ String tempValue = bagService.selectAccountBalanceByIds(String.valueOf(userId));
|
|
|
+ BigDecimal totalValue = new BigDecimal(tempValue);
|
|
|
+ if (totalValue.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ //卡余为0,可以销户
|
|
|
+ baseMapper.update(null,new LambdaUpdateWrapper<PtUserAccount>()
|
|
|
+ .set(PtUserAccount::getAccountStatus,"-1")
|
|
|
+ .eq(PtUserAccount::getUserId,userId));
|
|
|
+ } else {
|
|
|
+ notCloseList.add(userId.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!notCloseList.isEmpty()){
|
|
|
+ log.warn("[销户失败,有账户存在余额]-[{}]", String.join(StringUtils.SEPARATOR, notCloseList));
|
|
|
+ }
|
|
|
+ return notCloseList.isEmpty();
|
|
|
+ }
|
|
|
}
|