diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java index d008f8a30..67a28f101 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java @@ -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 retMap = new HashMap(); - 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(); } diff --git a/mallinkAdmin/src/main/resources/db/migration/V202407018.sql b/mallinkAdmin/src/main/resources/db/migration/V202407018.sql index ee77d1875..23a314e31 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202407018.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202407018.sql @@ -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='能耗表'; + diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceType.java b/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceType.java index b8287587f..4b1f1ce14 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceType.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceType.java @@ -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 financeTypesList; + private List feesIds; @TableField(exist = false) - private String financeTypesName; - public List getFinanceTypesList() { - if (StringUtils.isNotBlank(financeTypes)) { - String[] fs = financeTypes.split(","); - if (null != fs && fs.length > 0 ) { - List retList = new ArrayList(); - 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 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; } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceTypeFees.java b/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceTypeFees.java new file mode 100644 index 000000000..d20a313cf --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxFinanceAdvanceTypeFees.java @@ -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; + + +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumFinanceType.java b/mallinkService/src/main/java/com/iformall/enums/EnumFinanceType.java deleted file mode 100644 index 90d79a27c..000000000 --- a/mallinkService/src/main/java/com/iformall/enums/EnumFinanceType.java +++ /dev/null @@ -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; - } -} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxFinanceAdvanceTypeFeesMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxFinanceAdvanceTypeFeesMapper.java new file mode 100644 index 000000000..0fa2083f0 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxFinanceAdvanceTypeFeesMapper.java @@ -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 { + + List findList(WxFinanceAdvanceTypeFees wxBillRent); + + List findFeesIdList(WxFinanceAdvanceTypeFees wxBillRent); + + WxFinanceAdvanceTypeFees selectById(@Param("id")Long id,@Param("tenantId")String tenantId); + + void deleteByAdvanceId(WxFinanceAdvanceTypeFees wxBillRent); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java index 70373bb7a..446403da2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java @@ -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 payWayListAsPage(WxBillPayWay record, Integer pageIndex, Integer pageSize) { @@ -107,7 +114,21 @@ public class WxFinanceServiceImpl implements WxFinanceService { public PageInfo advanceTypeListAsPage(WxFinanceAdvanceType record, Integer pageIndex, Integer pageSize) { PageInfo 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 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 diff --git a/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeFeesMapper.xml b/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeFeesMapper.xml new file mode 100644 index 000000000..811cae43d --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeFeesMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`advance_type_id`,`fees_id` + + + + where 1=1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `advance_type_id` = #{advanceTypeId} + and `fees_id` = #{feesId} + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + delete from wx_finance_advance_type_fees where `tenant_id` = #{tenantId} and advance_type_id = #{advanceTypeId} + + + + diff --git a/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeMapper.xml b/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeMapper.xml index d48eb63fa..1f548d93d 100644 --- a/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFinanceAdvanceTypeMapper.xml @@ -10,11 +10,10 @@ - - `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` @@ -27,7 +26,6 @@ and `parent_tenant_id` = #{parentTenantId} and `is_del` = #{isDel} - and `finance_types` like concat('%,', #{financeTypeQuery},',%') and name like concat('%', #{name},'%') and id in