瀏覽代碼

机构资产信息相关功能类创建

hgw 3 年之前
父節點
當前提交
9935d38365

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantAssetsInfoDao.java

@@ -0,0 +1,20 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 机构资产信息(TenantAssetsInfo)表数据库访问层
+ *
+ * @author hgw
+ * @since 2021-12-22 14:27:02
+ */
+public interface TenantAssetsInfoDao extends BaseMapper<TenantAssetsInfo> {
+
+    int insertBatch(@Param("entities") List<TenantAssetsInfo> entities);
+
+}
+

+ 99 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantAssetsInfo.java

@@ -0,0 +1,99 @@
+package com.ym.mec.biz.dal.entity;
+
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+
+/**
+ * 机构资产信息(TenantAssetsInfo)表实体类
+ *
+ * @author hgw
+ * @since 2021-12-22 14:27:02
+ */
+@ApiModel(value = "tenant_assets_info-机构资产信息")
+public class TenantAssetsInfo implements Serializable {
+    @TableId(value = "id_", type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    @TableField("tenant_id_")
+    @ApiModelProperty(value = "机构id")
+    private Integer tenantId;
+
+    @TableField("balance_")
+    @ApiModelProperty(value = "余额")
+    private BigDecimal balance;
+
+    @TableField("frozen_amount_")
+    @ApiModelProperty(value = "冻结金额")
+    private BigDecimal frozenAmount;
+
+    @TableField("created_time_")
+    @ApiModelProperty(value = "创建时间")
+    private Date createdTime;
+
+    @TableField("updated_time_")
+    @ApiModelProperty(value = "更新时间")
+    private Date updatedTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public BigDecimal getBalance() {
+        return balance;
+    }
+
+    public void setBalance(BigDecimal balance) {
+        this.balance = balance;
+    }
+
+    public BigDecimal getFrozenAmount() {
+        return frozenAmount;
+    }
+
+    public void setFrozenAmount(BigDecimal frozenAmount) {
+        this.frozenAmount = frozenAmount;
+    }
+
+    public Date getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Date createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Date getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Date updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+
+}
+

+ 108 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/TenantConfigDetail.java

@@ -0,0 +1,108 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * TenantConfig表config字段,该字段是动态
+ * @author hgw
+ * Created by 2021-12-22
+ */
+public class TenantConfigDetail implements Serializable {
+
+    /**
+     * 会员设置-分润金额
+     */
+    private MemberConfig member_config;
+
+    /**
+     * 云教室规则
+     */
+    private CloudRoomRule cloud_room_rule;
+
+    public static class MemberConfig implements Serializable {
+        private BigDecimal month_divide;
+        private BigDecimal quarter_divide;
+        private BigDecimal half_year_divide;
+        private BigDecimal year_divide;
+
+        public BigDecimal getMonth_divide() {
+            return month_divide;
+        }
+
+        public void setMonth_divide(BigDecimal month_divide) {
+            this.month_divide = month_divide;
+        }
+
+        public BigDecimal getQuarter_divide() {
+            return quarter_divide;
+        }
+
+        public void setQuarter_divide(BigDecimal quarter_divide) {
+            this.quarter_divide = quarter_divide;
+        }
+
+        public BigDecimal getHalf_year_divide() {
+            return half_year_divide;
+        }
+
+        public void setHalf_year_divide(BigDecimal half_year_divide) {
+            this.half_year_divide = half_year_divide;
+        }
+
+        public BigDecimal getYear_divide() {
+            return year_divide;
+        }
+
+        public void setYear_divide(BigDecimal year_divide) {
+            this.year_divide = year_divide;
+        }
+    }
+
+    public static class CloudRoomRule implements Serializable {
+
+        /**
+         * 云教室人数上限(含老师)
+         */
+        private Integer cloud_room_up_limit;
+
+        /**
+         * String人数-BigDecimal每分钟扣费标准
+         */
+        private Map<String, BigDecimal> cloud_room_config;
+
+        public Integer getCloud_room_up_limit() {
+            return cloud_room_up_limit;
+        }
+
+        public void setCloud_room_up_limit(Integer cloud_room_up_limit) {
+            this.cloud_room_up_limit = cloud_room_up_limit;
+        }
+
+        public Map<String, BigDecimal> getCloud_room_config() {
+            return cloud_room_config;
+        }
+
+        public void setCloud_room_config(Map<String, BigDecimal> cloud_room_config) {
+            this.cloud_room_config = cloud_room_config;
+        }
+    }
+
+    public MemberConfig getMember_config() {
+        return member_config;
+    }
+
+    public void setMember_config(MemberConfig member_config) {
+        this.member_config = member_config;
+    }
+
+    public CloudRoomRule getCloud_room_rule() {
+        return cloud_room_rule;
+    }
+
+    public void setCloud_room_rule(CloudRoomRule cloud_room_rule) {
+        this.cloud_room_rule = cloud_room_rule;
+    }
+}

+ 19 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TenantAssetsInfoService.java

@@ -0,0 +1,19 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
+
+import java.util.List;
+
+/**
+ * 机构资产信息(TenantAssetsInfo)表服务接口
+ *
+ * @author hgw
+ * @since 2021-12-22 14:27:02
+ */
+public interface TenantAssetsInfoService extends IService<TenantAssetsInfo> {
+
+    void courseDeductionRules(List<CourseSchedule> dto);
+}
+

+ 59 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java

@@ -0,0 +1,59 @@
+package com.ym.mec.biz.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.dao.TenantAssetsInfoDao;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
+import com.ym.mec.biz.dal.entity.TenantConfig;
+import com.ym.mec.biz.dal.entity.TenantConfigDetail;
+import com.ym.mec.biz.dal.entity.TenantConfigDetail.CloudRoomRule;
+import com.ym.mec.biz.service.TenantAssetsInfoService;
+import com.ym.mec.biz.service.TenantConfigService;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.filters.TenantIdThreadLocal;
+import com.ym.mec.common.page.WrapperUtil;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * 机构资产信息(TenantAssetsInfo)表服务实现类
+ *
+ * @author hgw
+ * @since 2021-12-22 14:27:02
+ */
+@Service("tenantAssetsInfoService")
+public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao, TenantAssetsInfo> implements TenantAssetsInfoService {
+
+    private final static Logger log = LoggerFactory.getLogger(TenantAssetsInfoServiceImpl.class);
+
+    @Autowired
+    private TenantConfigService tenantConfigService;
+
+    /**
+     * 排课扣费计算
+     * 1.线上排课计算出的总价格不能超过账户余额(注意多人同时操作账户余额多扣问题)
+     * 2.若符合规则冻结部分账户
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void courseDeductionRules(List<CourseSchedule> dto) {
+
+    }
+
+
+}
+

+ 28 - 0
mec-biz/src/main/resources/config/mybatis/TenantAssetsInfoMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.TenantAssetsInfoDao">
+    <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.TenantAssetsInfo">
+        <id column="id_" jdbcType="INTEGER" property="id"/>
+        <result column="tenant_id_" jdbcType="INTEGER" property="tenantId"/>
+        <result column="balance_" jdbcType="VARCHAR" property="balance"/>
+        <result column="frozen_amount_" jdbcType="VARCHAR" property="frozenAmount"/>
+        <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
+        <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id_
+        , tenant_id_, balance_, frozen_amount_, created_time_, updated_time_
+    </sql>
+
+    <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
+            parameterType="com.ym.mec.biz.dal.entity.TenantAssetsInfo">
+        insert into tenant_assets_info(tenant_id_, balance_, frozen_amount_, created_time_, updated_time_)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.tenantId}, #{entity.balance}, #{entity.frozenAmount}, #{entity.createdTime},
+            #{entity.updatedTime})
+        </foreach>
+    </insert>
+
+</mapper>

+ 16 - 0
mec-biz/src/main/resources/rebel.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
+  Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
+-->
+<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
+
+	<id>mec-biz</id>
+
+	<classpath>
+		<dir name="E:/hgw/DYYM/项目/mec/mec-biz/target/classes">
+		</dir>
+	</classpath>
+
+</application>

+ 40 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TenantAssetsInfoController.java

@@ -0,0 +1,40 @@
+package com.ym.mec.web.controller;
+
+
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
+import com.ym.mec.biz.service.TenantAssetsInfoService;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.web.bind.annotation.*;
+import com.ym.mec.common.controller.BaseController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 机构资产信息(TenantAssetsInfo)表控制层
+ *
+ * @author hgw
+ * @since 2021-12-22 14:27:02
+ */
+@RestController
+@RequestMapping("/tenantAssetsInfo")
+public class TenantAssetsInfoController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private TenantAssetsInfoService tenantAssetsInfoService;
+
+    @ApiOperation("修改机构启用停用状态")
+    @GetMapping(value = "/ops/{id}")
+//    @PreAuthorize("@pcs.hasPermissions('tenantInfo/opsState')")
+    public Object opsState() {
+        tenantAssetsInfoService.courseDeductionRules(null);
+        return succeed();
+    }
+
+
+}
+