| @@ -1,6 +1,5 @@ | |||
| package com.iformall.controller.market; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| @@ -10,7 +9,6 @@ import com.iformall.domain.po.WxEnergyFees; | |||
| import com.iformall.domain.po.WxFinanceAdvanceType; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumFinanceType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxEnergyService; | |||
| import com.iformall.service.WxFinanceService; | |||
| @@ -42,16 +40,6 @@ public class WxFinanceController extends BaseController { | |||
| @Autowired | |||
| WxEnergyService wxEnergyService; | |||
| @ApiOperation("财务类型") | |||
| @GetMapping("financeTypeList") | |||
| public ResultData financeTypeList() { | |||
| Map<Integer,String> retMap = new HashMap<Integer,String>(); | |||
| for (EnumFinanceType mem : EnumFinanceType.values()) { | |||
| retMap.put(mem.getCode(), mem.getMessage()); | |||
| } | |||
| return new ResultData(retMap); | |||
| } | |||
| /** | |||
| * 账单类型(非能源) | |||
| * @return | |||
| @@ -152,10 +140,6 @@ public class WxFinanceController extends BaseController { | |||
| if (new BigDecimal(record.getRate()).compareTo(new BigDecimal(100)) > 0 ) { | |||
| return new ResultData(Result.ERROR,"冲抵比例不能超过100"); | |||
| } | |||
| if (StringUtils.isBlank(record.getFinanceTypes())) { | |||
| return new ResultData(Result.ERROR,"清选择冲抵类型"); | |||
| } | |||
| record.setFinanceTypes(","+record.getFinanceTypes()+","); | |||
| wxFinanceService.saveOrUpdateAdvanceType(record); | |||
| return new ResultData(); | |||
| } | |||
| @@ -1590,21 +1590,6 @@ create table wx_energy_fees_99 like wx_energy_fees; | |||
| drop table wx_energy_fees; | |||
| CREATE TABLE `wx_finance_advance_type` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `create_time` timestamp NULL DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT NULL, | |||
| `is_del` int(1) NOT NULL DEFAULT '0', | |||
| `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表名称', | |||
| `rate` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '最高抵扣比例', | |||
| `finance_types` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '可抵扣类型', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| alter table wx_bill_rent_0 add column energy_fees_id bigint(20) NOT NULL COMMENT '科目编号';; | |||
| alter table wx_bill_rent_1 add column energy_fees_id bigint(20) NOT NULL COMMENT '科目编号';; | |||
| alter table wx_bill_rent_2 add column energy_fees_id bigint(20) NOT NULL COMMENT '科目编号';; | |||
| @@ -2515,5 +2500,32 @@ alter table wx_bill_other_deposit_98 add column energy_fees_id bigint(20) N | |||
| alter table wx_bill_other_deposit_99 add column energy_fees_id bigint(20) NOT NULL COMMENT '科目编号';; | |||
| CREATE TABLE `wx_finance_advance_type` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `create_time` timestamp NULL DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT NULL, | |||
| `is_del` int(1) NOT NULL DEFAULT '0', | |||
| `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表名称', | |||
| `rate` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '最高抵扣比例', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| CREATE TABLE `wx_finance_advance_type_fees` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `create_time` timestamp NULL DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT NULL, | |||
| `advance_type_id` bigint(20) NOT NULL COMMENT 'advance_type编码', | |||
| `fees_id` bigint(20) NOT NULL COMMENT '科目编码', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`), | |||
| KEY `T_A_F` (`tenant_id`,`advance_type_id`,`fees_id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| @@ -1,18 +1,14 @@ | |||
| package com.iformall.domain.po; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumFinanceType; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| */ | |||
| @@ -42,36 +38,24 @@ public class WxFinanceAdvanceType extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="冲抵比例",name="rate") | |||
| private String rate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "冲抵类型,多个串EnumFinanceType", name = "financeTypes") | |||
| private String financeTypes; | |||
| @TableField(exist = false) | |||
| private Integer financeTypeQuery; | |||
| @TableField(exist = false) | |||
| private List<EnumFinanceType> financeTypesList; | |||
| private List<Long> feesIds; | |||
| @TableField(exist = false) | |||
| private String financeTypesName; | |||
| public List<EnumFinanceType> getFinanceTypesList() { | |||
| if (StringUtils.isNotBlank(financeTypes)) { | |||
| String[] fs = financeTypes.split(","); | |||
| if (null != fs && fs.length > 0 ) { | |||
| List<EnumFinanceType> retList = new ArrayList<EnumFinanceType>(); | |||
| for (int i = 0 ; i < fs.length ; i ++) { | |||
| String _fs = fs[i]; | |||
| if (StringUtils.isNotBlank(_fs)) { | |||
| EnumFinanceType eft = EnumFinanceType.getEnum(Integer.parseInt(_fs)); | |||
| if (null != eft) { | |||
| retList.add(eft); | |||
| financeTypesName = financeTypesName+","+eft.getMessage(); | |||
| } | |||
| } | |||
| private String feesName; | |||
| public String getFeesIdsName(Map<Long, WxEnergyFees> feesMap) { | |||
| if (null != feesIds) { | |||
| StringBuffer sb= new StringBuffer(); | |||
| for (int i = 0 ; i < feesIds.size(); i++) { | |||
| Long feid = feesIds.get(i); | |||
| WxEnergyFees f = feesMap.get(feid); | |||
| if (null != f) { | |||
| sb.append(f.getName()).append(","); | |||
| } | |||
| if (retList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| return retList; | |||
| } | |||
| return sb.toString(); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| /** | |||
| */ | |||
| @TableName(value = "wx_finance_advance_type_fees") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxFinanceAdvanceTypeFees extends TenantEntity { | |||
| private static final long serialVersionUID = 7009117540201976664L; | |||
| @io.swagger.annotations.ApiModelProperty(value="id",name="id") | |||
| private Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="createTime",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime") | |||
| private Date updateTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "advanceType编码", name = "advanceTypeId") | |||
| private Long advanceTypeId; | |||
| @io.swagger.annotations.ApiModelProperty(value="科目编码",name="feesId") | |||
| private Long feesId; | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| package com.iformall.enums; | |||
| public enum EnumFinanceType { | |||
| RENT(1,"租金",EnumBillAllType.RENT.getCode()), | |||
| RENT_BUSSINESS_MANAGE(11,"商业管理费",EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode()), | |||
| RENT_OPERATION_MANAGE(12,"运营管理费",EnumBillAllType.RENT_OPERATION_MANAGE.getCode()), | |||
| RENT_DEPOSIT(13,"租赁押金",EnumBillAllType.RENT_DEPOSIT.getCode()), | |||
| PROPERTY(2,"物业费",EnumBillAllType.PROPERTY.getCode()), | |||
| PROPERTY_DEPOSIT(21,"物业押金",EnumBillAllType.PROPERTY_DEPOSIT.getCode()), | |||
| WATER(3, "水费",EnumBillAllType.DAILY.getCode()), | |||
| POWER(4, "电费",EnumBillAllType.DAILY.getCode()), | |||
| GAS(5, "燃气费",EnumBillAllType.DAILY.getCode()), | |||
| OTHER(6, "其他费用",EnumBillAllType.OTHER.getCode()), | |||
| OTHER_DEPOSIT(7, "其他押金",EnumBillAllType.OTHER_DEPOSIT.getCode()) | |||
| ; | |||
| public static EnumFinanceType getEnum(Integer code) { | |||
| for (EnumFinanceType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| private Integer billType; | |||
| EnumFinanceType(Integer code, String message,Integer billType) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.billType = billType; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| public Integer getBillType() { | |||
| return billType; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxFinanceAdvanceTypeFees; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| /** | |||
| */ | |||
| public interface WxFinanceAdvanceTypeFeesMapper extends CommonMapper<WxFinanceAdvanceTypeFees, Long> { | |||
| List<WxFinanceAdvanceTypeFees> findList(WxFinanceAdvanceTypeFees wxBillRent); | |||
| List<Long> findFeesIdList(WxFinanceAdvanceTypeFees wxBillRent); | |||
| WxFinanceAdvanceTypeFees selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void deleteByAdvanceId(WxFinanceAdvanceTypeFees wxBillRent); | |||
| } | |||
| @@ -15,6 +15,7 @@ import com.iformall.utils.Constant; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.*; | |||
| @@ -28,6 +29,12 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| WxBillPayWayMapper wxBillPayWayMapper; | |||
| @Autowired | |||
| WxFinanceAdvanceTypeMapper wxFinanceAdvanceTypeMapper; | |||
| @Autowired | |||
| WxFinanceAdvanceTypeFeesMapper wxFinanceAdvanceTypeFeesMapper; | |||
| @Lazy | |||
| @Autowired | |||
| WxEnergyService wxEnergyService; | |||
| @Override | |||
| public PageInfo<WxBillPayWay> payWayListAsPage(WxBillPayWay record, Integer pageIndex, Integer pageSize) { | |||
| @@ -107,7 +114,21 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| public PageInfo<WxFinanceAdvanceType> advanceTypeListAsPage(WxFinanceAdvanceType record, Integer pageIndex, | |||
| Integer pageSize) { | |||
| PageInfo<WxFinanceAdvanceType> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxFinanceAdvanceTypeMapper.findList(record)); | |||
| return page; | |||
| if (null != page && null != page.getList()) { | |||
| WxEnergyFees fq = new WxEnergyFees(); | |||
| fq.updateTenantInfo(record); | |||
| Map<Long, WxEnergyFees> feesMap = wxEnergyService.getFeesMap(fq); | |||
| for (int i = 0 ; i < page.getList().size() ; i++) { | |||
| WxFinanceAdvanceType at = page.getList().get(i); | |||
| WxFinanceAdvanceTypeFees tf = new WxFinanceAdvanceTypeFees(); | |||
| tf.updateTenantInfo(at); | |||
| tf.setAdvanceTypeId(at.getId()); | |||
| at.setFeesIds(wxFinanceAdvanceTypeFeesMapper.findFeesIdList(tf)); | |||
| at.setFeesName(at.getFeesIdsName(feesMap)); | |||
| } | |||
| } | |||
| return page; | |||
| } | |||
| @Override | |||
| @@ -118,8 +139,8 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| @Override | |||
| public void saveOrUpdateAdvanceType(WxFinanceAdvanceType record) { | |||
| Date date = new Date(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateTime(date); | |||
| record.setUpdateTime(date); | |||
| @@ -130,9 +151,29 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } else { | |||
| //先删掉之前的关联 | |||
| WxFinanceAdvanceTypeFees fd = new WxFinanceAdvanceTypeFees(); | |||
| fd.updateTenantInfo(record); | |||
| fd.setAdvanceTypeId(record.getId()); | |||
| wxFinanceAdvanceTypeFeesMapper.deleteByAdvanceId(fd); | |||
| record.setUpdateTime(date); | |||
| wxFinanceAdvanceTypeMapper.updateById(record); | |||
| } | |||
| if (null != record.getFeesIds()) { | |||
| for (int i = 0 ; i < record.getFeesIds().size(); i++) { | |||
| Long feeid = record.getFeesIds().get(i); | |||
| WxFinanceAdvanceTypeFees tf = new WxFinanceAdvanceTypeFees(); | |||
| tf.setId(idWorker.nextId()); | |||
| tf.setAdvanceTypeId(record.getId()); | |||
| tf.setFeesId(feeid); | |||
| tf.setCreateTime(new Date()); | |||
| tf.setUpdateTime(new Date()); | |||
| wxFinanceAdvanceTypeFeesMapper.insert(tf); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| @@ -0,0 +1,62 @@ | |||
| <?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.iformall.mapper.WxFinanceAdvanceTypeFeesMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxFinanceAdvanceTypeFees"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||
| <result column="advance_type_id" jdbcType="BIGINT" property="advanceTypeId"/> | |||
| <result column="fees_id" jdbcType="BIGINT" property="feesId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`advance_type_id`,`fees_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1=1 | |||
| <if test=" null != id ">and `id` = #{id}</if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != advanceTypeId ">and `advance_type_id` = #{advanceTypeId}</if> | |||
| <if test=" null != feesId ">and `fees_id` = #{feesId}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxFinanceAdvanceTypeFees" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_finance_advance_type_fees | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findFeesIdList" parameterType="com.iformall.domain.po.WxFinanceAdvanceTypeFees" resultType="Long"> | |||
| select distinct fees_id | |||
| from wx_finance_advance_type_fees | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_finance_advance_type_fees where id = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| <delete id="deleteByAdvanceId" parameterType="com.iformall.domain.po.WxFinanceAdvanceTypeFees" > | |||
| delete from wx_finance_advance_type_fees where `tenant_id` = #{tenantId} and advance_type_id = #{advanceTypeId} | |||
| </delete> | |||
| </mapper> | |||
| @@ -10,11 +10,10 @@ | |||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="rate" jdbcType="VARCHAR" property="rate"/> | |||
| <result column="finance_types" jdbcType="INTEGER" property="financeTypes"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`rate`,`finance_types` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`rate` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -27,7 +26,6 @@ | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != isDel ">and `is_del` = #{isDel}</if> | |||
| <if test=" null != financeTypeQuery ">and `finance_types` like concat('%,', #{financeTypeQuery},',%')</if> | |||
| <if test=" null != name and '' != name ">and name like concat('%', #{name},'%')</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||