yanite %!s(int64=3) %!d(string=hai) anos
pai
achega
aaaa81d02d

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantInfoDao.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ym.mec.biz.dal.entity.TenantInfo;
+import com.ym.mec.biz.dal.entity.TenantProductSumm;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Map;
@@ -11,4 +12,6 @@ import java.util.Map;
 public interface TenantInfoDao extends BaseMapper<TenantInfo> {
 
     <T> IPage<T> queryPage(Page<T> page, @Param("param") Map<String, Object> param);
+
+    TenantProductSumm queryTenantInfoProductSumm(Integer tenantId);
 }

+ 56 - 28
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantProductSumm.java

@@ -19,60 +19,64 @@ import java.util.Date;
 @ApiModel(value = "tenant_info-机构表")
 public class TenantProductSumm extends TenantInfo implements Serializable  {
 
-    @TableField("name_")
     @ApiModelProperty(value = "当前版本")
-    private String name;
+    private String serverName;
 
-    @TableField("pay_date_")
     @ApiModelProperty(value = "服务有效期开始")
-    private Date payDateBegin;
+    private Date expiryDate;
 
-    @ApiModelProperty(value = "服务有效期开始")
-    private Date payDateEnd;
+    @ApiModelProperty(value = "有效期(数字-结合有效期单位)")
+    private int expiryCount;
 
-    @ApiModelProperty(value = "有效期剩余")
-    private String validRemaining;
+    @ApiModelProperty(value = "有效期单位")
+    private String expiryUnit;
 
-    @TableField("balance_")
     @ApiModelProperty(value = "可用余额")
     private BigDecimal balance;
 
-    @TableField("frozen_amount_")
     @ApiModelProperty(value = "冻结金额")
     private BigDecimal frozenAmount;
 
-    @Override
-    public String getName() {
-        return name;
+    // ----------- 计算字段
+    @ApiModelProperty(value = "服务有效期开始")
+    private Date payDateEnd;
+
+    @ApiModelProperty(value = "剩余天数")
+    private String validRemaining;
+
+    @ApiModelProperty(value = "总余额")
+    private BigDecimal sumBalance;
+
+    public String getServerName() {
+        return serverName;
     }
 
-    @Override
-    public void setName(String name) {
-        this.name = name;
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
     }
 
-    public Date getPayDateBegin() {
-        return payDateBegin;
+    public Date getExpiryDate() {
+        return expiryDate;
     }
 
-    public void setPayDateBegin(Date payDateBegin) {
-        this.payDateBegin = payDateBegin;
+    public void setExpiryDate(Date expiryDate) {
+        this.expiryDate = expiryDate;
     }
 
-    public Date getPayDateEnd() {
-        return payDateEnd;
+    public int getExpiryCount() {
+        return expiryCount;
     }
 
-    public void setPayDateEnd(Date payDateEnd) {
-        this.payDateEnd = payDateEnd;
+    public void setExpiryCount(int expiryCount) {
+        this.expiryCount = expiryCount;
     }
 
-    public String getValidRemaining() {
-        return validRemaining;
+    public String getExpiryUnit() {
+        return expiryUnit;
     }
 
-    public void setValidRemaining(String validRemaining) {
-        this.validRemaining = validRemaining;
+    public void setExpiryUnit(String expiryUnit) {
+        this.expiryUnit = expiryUnit;
     }
 
     public BigDecimal getBalance() {
@@ -90,5 +94,29 @@ public class TenantProductSumm extends TenantInfo implements Serializable  {
     public void setFrozenAmount(BigDecimal frozenAmount) {
         this.frozenAmount = frozenAmount;
     }
+
+    public Date getPayDateEnd() {
+        return payDateEnd;
+    }
+
+    public void setPayDateEnd(Date payDateEnd) {
+        this.payDateEnd = payDateEnd;
+    }
+
+    public String getValidRemaining() {
+        return validRemaining;
+    }
+
+    public void setValidRemaining(String validRemaining) {
+        this.validRemaining = validRemaining;
+    }
+
+    public BigDecimal getSumBalance() {
+        return sumBalance;
+    }
+
+    public void setSumBalance(BigDecimal sumBalance) {
+        this.sumBalance = sumBalance;
+    }
 }
 

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TenantInfoService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.biz.dal.dto.TenantInfoDto;
 import com.ym.mec.biz.dal.entity.TenantInfo;
+import com.ym.mec.biz.dal.entity.TenantProductSumm;
 import com.ym.mec.biz.dal.vo.TenantInfoInfoPageVo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.thirdparty.yqpay.Msg;
@@ -33,4 +34,6 @@ public interface TenantInfoService extends IService<TenantInfo> {
     Map<String, Object> recharge(Integer tenantId, BigDecimal amount) throws Exception;
 
     Boolean rechargeCheck(String orderNo) throws Exception;
+
+    TenantProductSumm queryTenantInfoProductSumm(Integer id);
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -27,6 +27,7 @@ import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.yqpay.DateUtils;
 import com.ym.mec.thirdparty.yqpay.Msg;
+import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.joda.time.LocalDate;
 import org.joda.time.LocalDateTime;
@@ -644,5 +645,22 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         return record.getOrderState() == 1;
     }
 
+    @Override
+    public TenantProductSumm queryTenantInfoProductSumm(Integer tenantId) {
+        TenantProductSumm tps = baseMapper.queryTenantInfoProductSumm(tenantId);
+        Date d1;
+        if (Objects.equals(tps.getExpiryUnit(), "MONTH")) {
+            d1 = DateUtil.addMonths(tps.getExpiryDate(), tps.getExpiryCount());
+        } else if (Objects.equals(tps.getExpiryUnit(), "YEAR")) {
+            d1 = DateUtil.addYears(tps.getExpiryDate(), tps.getExpiryCount());
+        } else if (Objects.equals(tps.getExpiryUnit(), "DAY")) {
+            d1 = DateUtil.addDays(tps.getExpiryDate(), tps.getExpiryCount());
+        } else {
+            d1 = null;
+        }
+        tps.setPayDateEnd(d1);
+        return tps;
+    }
+
 
 }

+ 16 - 0
mec-biz/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -89,5 +89,21 @@
             </if>
         </where>
     </select>
+    <select id="queryTenantInfoProductSumm" resultType="com.ym.mec.biz.dal.entity.TenantProductSumm">
+            SELECT t.*, ps.name_ as serverName,
+                   tp.pay_date_ as payDateBegin,
+                   tp.expiry_date_ as expiryDate,
+                   tp.expiry_count_  as expiryCount,
+                   tp.expiry_unit_ as expiryUnit,
+
+                   ta.balance_ as balance,
+                   ta.frozen_amount_ as frozenAmount
+            FROM `tenant_info` t
+                     left join tenant_assets_info ta on ta.tenant_id_ = t.id_
+                     left join tenant_product_info tp on tp.tenant_id_ = t.id_
+                     left join platform_serve ps on tp.serve_id_ = ps.id_
+                     left join platform_serve_detail psd on tp.serve_detail_id_ = psd.id_
+            where t.id_ = #{tenantId}
+    </select>
 
 </mapper>

+ 6 - 5
mec-web/src/main/java/com/ym/mec/web/controller/TenantInfoController.java

@@ -4,6 +4,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.TenantInfoDto;
 import com.ym.mec.biz.dal.entity.CloudTeacherStudent;
+import com.ym.mec.biz.dal.entity.TenantProductSumm;
 import com.ym.mec.biz.service.TenantInfoService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -74,11 +75,11 @@ public class TenantInfoController extends BaseController {
         return succeed(tenantInfoService.queryTenantInfoCheck(id));
     }
 
-    // @ApiOperation("查询机构产品")
-    // @GetMapping(value = "/queryTenantInfoProduct/{id}")
-    // public Object queryTenantInfoProduct(@ApiParam(value = "机构ID", required = true) @PathVariable("id") Integer id) {
-    //     return succeed(tenantInfoService.queryTenantInfoProduct(id));
-    // }
+    @ApiOperation("查询机构产品")
+    @GetMapping(value = "/queryTenantInfoSumm/{id}")
+    public HttpResponseResult<TenantProductSumm> queryTenantInfoProductSumm(@ApiParam(value = "机构ID", required = true) @PathVariable("id") Integer id) {
+        return succeed(tenantInfoService.queryTenantInfoProductSumm(id));
+    }
 
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "关键字"),