|
|
@@ -1,11 +1,25 @@
|
|
|
package org.dromara.backstage.payment.dubbo;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.dromara.backstage.api.RemoteBagService;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemoteConsumptionBo;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemotePurseInOutBo;
|
|
|
+import org.dromara.backstage.business.errfill.ErrFillBusiness;
|
|
|
+import org.dromara.backstage.business.payments.PayOrderBusiness;
|
|
|
+import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
+import org.dromara.backstage.consumption.domain.bo.ConsumptionBo;
|
|
|
+import org.dromara.backstage.payment.domain.bo.PtBagBo;
|
|
|
+import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
|
import org.dromara.backstage.payment.service.IPtBagService;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.enums.SystemUseTypeEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
/**
|
|
|
* name: RemoteBagServiceImpl
|
|
|
* package: org.dromara.backstage.dubbo
|
|
|
@@ -19,10 +33,95 @@ import org.springframework.stereotype.Service;
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
@DubboService
|
|
|
+@Slf4j
|
|
|
public class RemoteBagServiceImpl implements RemoteBagService {
|
|
|
private final IPtBagService bagService;
|
|
|
+ private final PayOrderBusiness payOrderBusiness;
|
|
|
+ private final ErrFillBusiness errFillBusiness;
|
|
|
+ private final IPtCardService ptCardService;
|
|
|
@Override
|
|
|
public String selectAccountBalanceByIds(String userIds) {
|
|
|
return bagService.selectAccountBalanceByIds(userIds);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean recharge(RemotePurseInOutBo bo) {
|
|
|
+ return R.isSuccess(payOrderBusiness.recharge(BeanUtil.copyProperties(bo, PurseInOutBo.class)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean refund(RemotePurseInOutBo bo) {
|
|
|
+ return R.isSuccess(payOrderBusiness.refund(BeanUtil.copyProperties(bo, PurseInOutBo.class)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean createErrFillRecord(RemoteConsumptionBo bo) {
|
|
|
+ bo.setUseType(SystemUseTypeEnum.CONSUME);
|
|
|
+ return null != errFillBusiness.createErrFillRecord(BeanUtil.copyProperties(bo, ConsumptionBo.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean batchRecharge(RemotePurseInOutBo bo, Long[] userIds) {
|
|
|
+ StringBuffer errIds = new StringBuffer();
|
|
|
+ boolean flag = true;
|
|
|
+ bo.setUseType(SystemUseTypeEnum.CONSUME);
|
|
|
+ for(Long userId : userIds) {
|
|
|
+ bo.setUserId(userId);
|
|
|
+ if(R.isError(payOrderBusiness.recharge(BeanUtil.copyProperties(bo, PurseInOutBo.class)))){
|
|
|
+ flag = false;
|
|
|
+ errIds.append(userId).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!flag){
|
|
|
+ log.error("账户批量充值失败,失败用户ID:{}", Arrays.toString(userIds));
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean batchRefund(RemotePurseInOutBo bo, Long[] userIds) {
|
|
|
+ StringBuffer errIds = new StringBuffer();
|
|
|
+ boolean flag = true;
|
|
|
+ bo.setUseType(SystemUseTypeEnum.CONSUME);
|
|
|
+ for(Long userId : userIds) {
|
|
|
+ bo.setUserId(userId);
|
|
|
+ if(R.isError(payOrderBusiness.refund(BeanUtil.copyProperties(bo, PurseInOutBo.class)))){
|
|
|
+ flag = false;
|
|
|
+ errIds.append(userId).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!flag){
|
|
|
+ log.error("账户批量退款失败,失败用户ID:{}", Arrays.toString(userIds));
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean batchSetBalance(RemotePurseInOutBo bo, Long[] userIds) {
|
|
|
+ StringBuffer errIds = new StringBuffer();
|
|
|
+ boolean flag = true;
|
|
|
+ bo.setUseType(SystemUseTypeEnum.CONSUME);
|
|
|
+ for(Long userId : userIds) {
|
|
|
+ bo.setUserId(userId);
|
|
|
+ if(null == bagService.updateBalanceByBo(BeanUtil.copyProperties(bo, PtBagBo.class))){
|
|
|
+ flag = false;
|
|
|
+ errIds.append(userId).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!flag){
|
|
|
+ log.error("账户批量设置余额失败,失败用户ID:{}", Arrays.toString(userIds));
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean lockCard(Long cardId) {
|
|
|
+ return ptCardService.lockCard(cardId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean unlockCard(Long cardId) {
|
|
|
+ return ptCardService.unlockCard(cardId);
|
|
|
+ }
|
|
|
+
|
|
|
}
|