TRX 1 rok pred
rodič
commit
35416a2258

+ 10 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/user/IndexController.java

@@ -50,6 +50,16 @@ public class IndexController {
     @Autowired
     UserAccountService userAccountService;
 
+    @Operation(summary = "物联网管理登录", description = "物联网管理登录")
+    @RequestMapping(value = "iotLogin", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    public ResultContent iotLogin(@RequestBody LoginParam param, HttpServletRequest request, HttpServletResponse response) {
+        param.setLoginFromType(LoginFromType.Platform);
+        ResultContent result = indexService.iotLogin(param);
+        if (result.isSuccess()) {
+        }
+        return result;
+    }
+
     @Operation(summary = "web通用登录", description = "web通用登录")
     @RequestMapping(value = "commonLogin", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
     public ResultContent commonLogin(@RequestBody LoginParam param, HttpServletRequest request, HttpServletResponse response) {

+ 2 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/projectAbout/OrgPayAccountDao.java

@@ -16,4 +16,6 @@ public interface OrgPayAccountDao extends MongoDao<OrgPayAccount> {
 
     OrgPayAccount findTopByOidAndPaymentType(String oid, PaymentType paymentType);
 
+    OrgPayAccount findTopByPayAccountId(String payAccountId);
+
 }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DevicePermissService.java

@@ -121,7 +121,7 @@ public class DevicePermissService extends SuperService {
                     for (OrganizationUser organizationUser : orgUsers) {
                         String userId = organizationUser.getUserId();
                         // 判断是否是编辑
-                        DevicePermiss permiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(deviceInfo.getDeviceId(), userId, projectOid);
+                        DevicePermiss permiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(userId, deviceInfo.getDeviceId(), projectOid);
                         if (ObjectUtils.isEmpty(permiss)) {
                             permiss = new DevicePermiss();
                             initEntity(permiss);

+ 54 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/org/IndexService.java

@@ -99,6 +99,60 @@ public class IndexService {
     @Autowired
     PlatFormConfigInfoService platFormConfigInfoService;
 
+    /**
+     * 物联网登录
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent<LoginCommonModel> iotLogin(LoginParam param) {
+        StopWatch stopWatch = new StopWatch();
+        stopWatch.start("1");
+
+        String phone = param.getLoginValue();
+        UserAccount userAccount = userCountDao.findTopByLoginName(phone);
+        UserCountModel userCountModel = userAccountService.toModel(userAccount);
+
+        UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
+        BeanUtils.copyProperties(param, userAuthLoginModel);
+        // 登录
+        ResultContent<LoginTokenModel> resultContent = commonLogin(userAuthLoginModel);
+        if (resultContent.isFailed()) {
+            return ResultContent.buildFail(resultContent.getMsg());
+        }
+        Organization organization = organizationDao.findTopByAuthType(AuthType.Platform);
+        if (ObjectUtils.isEmpty(organization)) {
+            return ResultContent.buildFail(String.format("平台未初始化,请联系管理员"));
+        }
+
+        OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUser(organization, userAccount);
+        if (ObjectUtils.isEmpty(organizationUser)) {
+            return ResultContent.buildFail("当前用户不是超管用户,登录失败");
+        }
+
+        LoginCommonModel commonModel = new LoginCommonModel();
+        LoginTokenModel loginTokenModel = resultContent.getContent();
+        com.zhongshu.card.server.core.util.BeanUtils.copyProperties(loginTokenModel, commonModel);
+        stopWatch.stop();
+
+        stopWatch.start("2");
+
+        commonModel.setUserInfo(userCountModel);
+        // 平台信息
+        commonModel.setPlatformOid(organization.getOid());
+        commonModel.setPlatformInfo(organizationService.toSimpleModel(organization));
+        stopWatch.stop();
+
+        stopWatch.start("3");
+        // 用户所有的权限
+        Set<String> auth = roleServiceImpl.getUserAllAuths(userAccount.getUserId());
+        commonModel.setAuths(auth);
+        stopWatch.stop();
+        log.info(stopWatch.prettyPrint());
+
+        return ResultContent.buildSuccess(commonModel);
+    }
+
     /**
      * 通用用户登录(返回所有权限数据)
      *

+ 51 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/OrgPayAccountService.java

@@ -1,11 +1,16 @@
 package com.zhongshu.card.server.core.service.paySetting;
 
+import com.github.microservice.net.ResultContent;
 import com.github.microservice.pay.client.service.PayProductAccountService;
+import com.github.microservice.pay.client.type.PayProductChannelType;
 import com.github.microservice.types.payment.PaymentType;
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.projectAbout.OrgPayAccountDao;
+import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.domain.paySetting.OrgPayAccount;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -25,6 +30,10 @@ public class OrgPayAccountService extends SuperService {
     @Autowired
     private PayProductAccountService payProductAccountService;
 
+    @Autowired
+    private OrganizationDao organizationDao;
+
+
     /**
      * 查询机构 支付账号
      *
@@ -36,4 +45,46 @@ public class OrgPayAccountService extends SuperService {
         OrgPayAccount orgPayAccount = orgPayAccountDao.findTopByOidAndPaymentType(oid, paymentType);
         return orgPayAccount;
     }
+
+    /**
+     * 保存项目 微信支付账号
+     *
+     * @param projectOid
+     * @param paymentType
+     * @return
+     */
+    public ResultContent saveProjectAccount(String projectOid, PaymentType paymentType, PayProductChannelType productChannelType) {
+        String payAccountId = buildPayAccountName(projectOid, paymentType);
+        OrgPayAccount orgPayAccount = orgPayAccountDao.findTopByPayAccountId(payAccountId);
+        if (ObjectUtils.isEmpty(orgPayAccount)) {
+            orgPayAccount = new OrgPayAccount();
+        }
+        Organization organization = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isNotEmpty(organization)) {
+            orgPayAccount.setOrgName(organization.getName());
+            orgPayAccount.setOid(organization.getOid());
+        }
+        orgPayAccount.setProjectOid(projectOid);
+        orgPayAccount.setPayAccountId(payAccountId);
+        orgPayAccount.setPaymentType(paymentType);
+        orgPayAccount.setProductChannelType(productChannelType);
+        orgPayAccount.setDisable(Boolean.FALSE);
+        orgPayAccountDao.save(orgPayAccount);
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 得到项目的 微信小程序支付的账号
+     *
+     * @param projectOid
+     * @return
+     */
+    public String getProjectWxAccount(String projectOid) {
+        return buildPayAccountName(projectOid, PaymentType.WeChat);
+    }
+
+    public String buildPayAccountName(String projectOid, PaymentType paymentType) {
+        return String.format("%s%s", projectOid, paymentType.name());
+    }
+
 }

+ 6 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/paySetting/ProjectPaySettingServiceImpl.java

@@ -67,6 +67,9 @@ public class ProjectPaySettingServiceImpl extends SuperService {
     @Autowired
     private PayProductAccountService payProductAccountService;
 
+    @Autowired
+    private OrgPayAccountService orgPayAccountService;
+
     /**
      * 关联支付渠道
      *
@@ -490,9 +493,10 @@ public class ProjectPaySettingServiceImpl extends SuperService {
         ProjectPaySettingInfo entity = projectPaySettingInfoDao.findTopByProjectOidAndChannelTypeAndIsDefault(
                 projectOid, paymentType, Boolean.TRUE);
 
+        String payAccountName = orgPayAccountService.buildPayAccountName(projectOid, paymentType);
         AccountModel accountModel = new AccountModel();
         Boolean disable = Boolean.FALSE;
-        accountModel.setName(projectOid);
+        accountModel.setName(payAccountName);
         if (ObjectUtils.isNotEmpty(entity)) {
             if (paymentType == PaymentType.WeChat) {
                 accountModel.setProductChannelType(PayProductChannelType.WeChatMiniAppPay);
@@ -528,6 +532,7 @@ public class ProjectPaySettingServiceImpl extends SuperService {
         com.github.microservice.pay.client.ret.ResultContent<Void> resultContent = payProductAccountService.upsert(accountModel);
         if (resultContent.getState() == ResultState.Success) {
             log.info("更新支付产品账户成功...");
+            orgPayAccountService.saveProjectAccount(projectOid, paymentType, accountModel.getProductChannelType());
         } else {
             log.error("更新支付产品账户出错: {}", resultContent.getMsg());
         }