|
|
@@ -0,0 +1,98 @@
|
|
|
+package org.dromara.server.base.service.yktOperation;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.backstage.api.RemoteUserAccountService;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemoteUserAccountBo;
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 结算账户同步
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class SyncRemotePtUserAccountService {
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteUserAccountService userAccountService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调用开户
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ public void openUserAccount(Object msg) throws ServiceException{
|
|
|
+ Long[] ids = JSONUtil.parseArray(msg).toArray(Long[]::new);
|
|
|
+ boolean flag = userAccountService.batchOpenAccount(ids);
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("开户失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调用结算账户修改
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ public void closeUserAccount(Object msg) throws ServiceException{
|
|
|
+ Long[] ids = JSONUtil.parseArray(msg).toArray(Long[]::new);
|
|
|
+ boolean flag = userAccountService.batchCloseAccount(ids);
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("开户失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调用账户冻结/解冻
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ public void updateFreezeStatus(Object msg) throws ServiceException{
|
|
|
+ JSONObject msgObj = JSONUtil.parseObj(msg);
|
|
|
+ Long[] ids = JSONUtil.parseArray(msgObj.getJSONArray("userIds")).toArray(Long[]::new);
|
|
|
+ String freezeStatus = msgObj.getStr("freezeStatus");
|
|
|
+ boolean flag = userAccountService.updateFreezeStatus(freezeStatus, ids);
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("账户冻结/解冻失败: "+ freezeStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调用重置有效期
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ public void resetTime(Object msg) throws ServiceException{
|
|
|
+ JSONObject msgObj = JSONUtil.parseObj(msg);
|
|
|
+ Long[] ids = JSONUtil.parseArray(msgObj.getJSONArray("userIds")).toArray(Long[]::new);
|
|
|
+ String lifespan = msgObj.getStr("lifespan");
|
|
|
+ boolean flag = userAccountService.resetLifespan(ids, lifespan);
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("重置有效期失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调用重置卡类
|
|
|
+ * @param msg
|
|
|
+ */
|
|
|
+ public void resetCardType(Object msg) throws ServiceException{
|
|
|
+ JSONObject msgObj = JSONUtil.parseObj(msg);
|
|
|
+ Long[] ids = JSONUtil.parseArray(msgObj.getJSONArray("userIds")).toArray(Long[]::new);
|
|
|
+ String cardType = msgObj.getStr("cardType");
|
|
|
+ boolean flag = userAccountService.resetCardType(ids, cardType);
|
|
|
+ if (!flag){
|
|
|
+ throw new ServiceException("重置卡类失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增账户
|
|
|
+ * @param msg
|
|
|
+ * @throws ServiceException
|
|
|
+ */
|
|
|
+ public void addUserAccount(Object msg) throws ServiceException{
|
|
|
+ userAccountService.insertByBo(JSONUtil.toBean(msg.toString(), RemoteUserAccountBo.class));
|
|
|
+ }
|
|
|
+}
|