TRX 1 anno fa
parent
commit
89adc66e3f

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoMoreModel.java

@@ -1,5 +1,7 @@
 package com.zhongshu.card.client.model.devices;
 
+import com.zhongshu.card.client.model.org.OrganizationPayInfoModel;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 /**
@@ -9,4 +11,6 @@ import lombok.Data;
 @Data
 public class DeviceInfoMoreModel extends DeviceInfoModel {
 
+    @Schema(description = "收款结构信息")
+    private OrganizationPayInfoModel payOrgInfo;
 }

+ 41 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/org/OrganizationPayInfoModel.java

@@ -0,0 +1,41 @@
+package com.zhongshu.card.client.model.org;
+
+import com.github.microservice.auth.security.type.AuthType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 机构数据 最简单的模型
+ *
+ * @author TRX
+ * @date 2024/5/31
+ */
+@Data
+public class OrganizationPayInfoModel {
+
+    @Schema(description = "数据ID")
+    private String id;
+
+    @Schema(description = "机构oid")
+    private String oid;
+
+    @Schema(description = "机构名称")
+    private String name;
+
+    @Schema(description = "编码、项目ID、机构编号")
+    private String code;
+
+    private String logo;
+
+    @Schema(description = "机构类型")
+    private AuthType authType = AuthType.Enterprise;
+
+    private String authTypeStr;
+
+    public String getAuthTypeStr() {
+        if (authType != null) {
+            return authType.getRemark();
+        }
+        return "";
+    }
+}

+ 2 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/payment/ExpenseFlowPayShowModel.java

@@ -3,6 +3,7 @@ package com.zhongshu.card.client.model.payment;
 import com.zhongshu.card.client.model.base.SuperModel;
 import com.zhongshu.card.client.model.devices.DeviceInfoModel;
 import com.zhongshu.card.client.model.org.OrganizationMiniModel;
+import com.zhongshu.card.client.model.org.OrganizationPayInfoModel;
 import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -39,7 +40,7 @@ public class ExpenseFlowPayShowModel extends SuperModel {
     private DeviceInfoModel deviceInfo;
 
     @Schema(description = "收款机构信息")
-    private OrganizationMiniModel shopInfo;
+    private OrganizationPayInfoModel shopInfo;
 
     @Schema(description = "是否可以支付")
     private Boolean isCanPay = Boolean.FALSE;

+ 8 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/service/school/DeviceInfoService.java

@@ -52,4 +52,12 @@ public interface DeviceInfoService {
      */
     ResultContent updateDevice(DeviceBindAreaParam param);
 
+    /**
+     * 得到当前用户对应设备的信息(判断是否有权限)
+     *
+     * @param deviceId
+     * @return
+     */
+    ResultContent<DeviceInfoMoreModel> getDeviceDetailAndPer(String deviceId);
+
 }

+ 7 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/DeviceInfoController.java

@@ -103,4 +103,11 @@ public class DeviceInfoController {
         return deviceInfoService.pageBindDevices(param, pageable);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "得到当前用户对应设备信息(是否有权限)", description = "得到当前用户对应设备信息(是否有权限)")
+    @RequestMapping(value = "getDeviceDetailAndPer", method = {RequestMethod.POST})
+    public ResultContent getDeviceDetailAndPer(@RequestBody DeviceInfoParam param) {
+        return this.deviceInfoService.getDeviceDetailAndPer(param.getDeviceId());
+    }
+
 }

+ 56 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceInfoServiceImpl.java

@@ -7,6 +7,7 @@ import com.github.microservice.net.ResultContent;
 import com.github.microservice.net.ResultMessage;
 import com.zhongshu.card.client.model.devices.*;
 import com.zhongshu.card.client.model.org.OrganizationMiniModel;
+import com.zhongshu.card.client.model.org.OrganizationPayInfoModel;
 import com.zhongshu.card.client.model.org.UserJoinBusOrgModel;
 import com.zhongshu.card.client.model.school.AreaSimpleModel;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
@@ -16,6 +17,7 @@ import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.school.AreaDao;
 import com.zhongshu.card.server.core.dataConfig.DeviceConfig;
 import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
+import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
 import com.zhongshu.card.server.core.domain.devices.DeviceProductBindDevice;
 import com.zhongshu.card.server.core.domain.devices.permiss.DevicePermiss;
 import com.zhongshu.card.server.core.domain.org.Organization;
@@ -24,6 +26,7 @@ import com.zhongshu.card.server.core.service.base.CommonService;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.devices.deviceProduct.DeviceProductBindDeviceService;
 import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissEventService;
+import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissVerifyService;
 import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
 import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
 import com.zhongshu.card.server.core.service.paySetting.OrgPaySettingJudgmentService;
@@ -82,6 +85,9 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
     @Autowired
     private DeviceProductBindDeviceService deviceProductBindDeviceService;
 
+    @Autowired
+    private DevicePermissVerifyService devicePermissVerifyService;
+
     /**
      * 同步设备 (设备基础信息) 从物联网来
      *
@@ -280,6 +286,31 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
         return ResultContent.buildSuccess(models);
     }
 
+    /**
+     * 判断当前用户关于设备的信息 和 是否有权限
+     *
+     * @param deviceId
+     * @return
+     */
+    @Override
+    public ResultContent<DeviceInfoMoreModel> getDeviceDetailAndPer(String deviceId) {
+        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
+
+        // 判断当前用户是否有设备的权限
+        String userId = getCurrentUserId();
+        ResultContent content = devicePermissVerifyService.verifyDevice(userId, deviceId, null);
+        if (content.isFailed()) {
+            return ResultContent.buildFail(content.getMsg());
+        }
+
+        DeviceInfoMoreModel model = null;
+        if (ObjectUtils.isNotEmpty(deviceInfo)) {
+            model = toMoreModel(deviceInfo);
+            model.setPayOrgInfo(getDeviceReceiveOrgInfo(deviceId));
+        }
+        return ResultContent.buildSuccess(model);
+    }
+
     public DeviceInfoMoreModel toMoreModel(DeviceInfo entity) {
         DeviceInfoMoreModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {
@@ -409,6 +440,31 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
         return Lists.newArrayList();
     }
 
+    /**
+     * 得到 设备的收款机构
+     *
+     * @param deviceId
+     * @return
+     */
+    public OrganizationPayInfoModel getDeviceReceiveOrgInfo(String deviceId) {
+        DeviceInfo deviceInfo = deviceInfoDao.findTopById(deviceId);
+        if (ObjectUtils.isEmpty(deviceInfo)) {
+            return null;
+        }
+        String beLongOid = deviceInfo.getBeLongOid();
+        if (StringUtils.isEmpty(beLongOid)) {
+            // 查询设备绑定的产品 关联的 收款机构
+            DeviceProduct deviceProduct = deviceProductBindDeviceService.getDeviceBindProductInfo(deviceInfo);
+            if (deviceProduct != null) {
+                beLongOid = deviceProduct.getBeLongOid();
+            }
+        }
+        if (StringUtils.isNotEmpty(beLongOid)) {
+            return organizationManagerService.toPayInfoModel(organizationServiceImpl.getOrgByOid(beLongOid));
+        }
+        return null;
+    }
+
     public DeviceInfoModel getDeviceInfoModel(String deviceId) {
         if (StringUtils.isEmpty(deviceId)) {
             return null;

+ 10 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductBindDeviceService.java

@@ -184,6 +184,16 @@ public class DeviceProductBindDeviceService extends SuperService {
         return null;
     }
 
+    public DeviceProduct getDeviceBindProductInfo(DeviceInfo deviceInfo) {
+        if (deviceInfo != null) {
+            DeviceProductBindDevice entity = deviceProductBindDeviceDao.findTopByDeviceIdOrderByCreateTimeDesc(deviceInfo.getDeviceId());
+            if (entity != null) {
+                return entity.getDeviceProduct();
+            }
+        }
+        return null;
+    }
+
     private DeviceProductBindDeviceModel toModel(DeviceProductBindDevice entity) {
         DeviceProductBindDeviceModel model = new DeviceProductBindDeviceModel();
         if (ObjectUtils.isNotEmpty(entity)) {

+ 15 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/orgManager/OrganizationManagerServiceImpl.java

@@ -320,6 +320,21 @@ public class OrganizationManagerServiceImpl extends SuperService {
         return model;
     }
 
+    /**
+     * 支付展示的  机构信息
+     *
+     * @param entity
+     * @return
+     */
+    public OrganizationPayInfoModel toPayInfoModel(Organization entity) {
+        OrganizationPayInfoModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new OrganizationPayInfoModel();
+            BeanUtils.copyProperties(entity, model);
+        }
+        return model;
+    }
+
     public OrganizationRelationModel toRelationModel(Organization entity) {
         OrganizationRelationModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {

+ 1 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/ExpenseFlowServiceImpl.java

@@ -900,8 +900,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             }
 
             // 收款机构信息
-            OrganizationMiniModel organizationMiniModel = organizationManagerService.toMiniModel(organizationService.getOrgByOid(entity.getShopOid()));
-            model.setShopInfo(organizationMiniModel);
+            model.setShopInfo(deviceInfoService.getDeviceReceiveOrgInfo(entity.getDeviceId()));
 
             // 判断是否可以支付
             OrderPayModel payModel = isCanPay(entity);