| @@ -1,15 +1,22 @@ | |||
| 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; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBillPayWay; | |||
| import com.iformall.domain.po.WxFinanceAdvanceType; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumFinanceType; | |||
| import com.iformall.service.WxFinanceService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.math.BigDecimal; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -29,6 +36,17 @@ public class WxFinanceController extends BaseController { | |||
| @Autowired | |||
| private WxFinanceService wxFinanceService; | |||
| @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); | |||
| } | |||
| @ApiOperation("支付方式列表") | |||
| @GetMapping("payWayList") | |||
| @ApiImplicitParams({ | |||
| @@ -57,4 +75,39 @@ public class WxFinanceController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("预收类型列表") | |||
| @GetMapping("advanceTypeList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData advanceTypeList(@ModelAttribute WxFinanceAdvanceType record, Integer pageNum, Integer pageSize) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| PageInfo<WxFinanceAdvanceType> page = wxFinanceService.advanceTypeListAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("能源表新增修改") | |||
| @PostMapping("saveAdvanceType") | |||
| public ResultData saveAdvanceType(@RequestBody WxFinanceAdvanceType record) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| 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(); | |||
| } | |||
| @PostMapping("advanceTypeUpdateIsDel") | |||
| public ResultData advanceTypeUpdateIsDel(@RequestBody WxFinanceAdvanceType record) { | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| wxFinanceService.updateAdvanceTypeIsDel(record); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1482,4 +1482,18 @@ INSERT INTO wx_bill_pay_way_89 (id,tenant_id,parent_tenant_id,create_time,update | |||
| VALUES (1,'789',NULL,NOW(),NOW(),0,'商户小程序',1), (2,'789',NULL,NOW(),NOW(),0,'系统自动结清',1); | |||
| 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='能耗表'; | |||
| @@ -0,0 +1,77 @@ | |||
| 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; | |||
| /** | |||
| */ | |||
| @TableName(value = "wx_finance_advance_type") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxFinanceAdvanceType extends TenantEntity { | |||
| private static final long serialVersionUID = 7009117540201976664L; | |||
| @io.swagger.annotations.ApiModelProperty(value="id",name="id") | |||
| private Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="name",name="name") | |||
| private String name; | |||
| @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 = "isDel", name = "isDel") | |||
| private Integer isDel; | |||
| @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; | |||
| @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(); | |||
| } | |||
| } | |||
| } | |||
| if (retList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| return retList; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| 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,20 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxEnergyMeter; | |||
| import com.iformall.domain.po.WxFinanceAdvanceType; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| /** | |||
| */ | |||
| public interface WxFinanceAdvanceTypeMapper extends CommonMapper<WxFinanceAdvanceType, Long> { | |||
| List<WxFinanceAdvanceType> findList(WxFinanceAdvanceType wxBillRent); | |||
| WxFinanceAdvanceType selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void setIsDel(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("isDel")Integer isDel); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||
| import java.util.Map; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxBillPayWay; | |||
| import com.iformall.domain.po.WxFinanceAdvanceType; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| /** | |||
| */ | |||
| @@ -15,4 +16,10 @@ public interface WxFinanceService { | |||
| void updatePayWayIsDel(WxBillPayWay record); | |||
| Map<Long,WxBillPayWay> getPayWayMap(WxBillPayWay record); | |||
| void payWayInit(TenantEntity tenantInfo); | |||
| //预收款类型 | |||
| PageInfo<WxFinanceAdvanceType> advanceTypeListAsPage(WxFinanceAdvanceType record, Integer pageIndex, Integer pageSize); | |||
| WxFinanceAdvanceType getAdvanceTypeById(TenantEntity tenantEntity,Long id); | |||
| void saveOrUpdateAdvanceType(WxFinanceAdvanceType record); | |||
| void updateAdvanceTypeIsDel(WxFinanceAdvanceType record); | |||
| } | |||
| @@ -26,6 +26,8 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| @Autowired | |||
| WxBillPayWayMapper wxBillPayWayMapper; | |||
| @Autowired | |||
| WxFinanceAdvanceTypeMapper wxFinanceAdvanceTypeMapper; | |||
| @Override | |||
| public PageInfo<WxBillPayWay> payWayListAsPage(WxBillPayWay record, Integer pageIndex, Integer pageSize) { | |||
| @@ -101,4 +103,41 @@ public class WxFinanceServiceImpl implements WxFinanceService { | |||
| wxBillPayWayMapper.insert(payway2); | |||
| } | |||
| @Override | |||
| public PageInfo<WxFinanceAdvanceType> advanceTypeListAsPage(WxFinanceAdvanceType record, Integer pageIndex, | |||
| Integer pageSize) { | |||
| PageInfo<WxFinanceAdvanceType> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxFinanceAdvanceTypeMapper.findList(record)); | |||
| return page; | |||
| } | |||
| @Override | |||
| public WxFinanceAdvanceType getAdvanceTypeById(TenantEntity tenantEntity, Long id) { | |||
| return wxFinanceAdvanceTypeMapper.selectById(id, tenantEntity.getTenantId()); | |||
| } | |||
| @Override | |||
| public void saveOrUpdateAdvanceType(WxFinanceAdvanceType record) { | |||
| Date date = new Date(); | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateTime(date); | |||
| record.setUpdateTime(date); | |||
| try { | |||
| wxFinanceAdvanceTypeMapper.insert(record); | |||
| } catch (Exception e) { | |||
| logger.error("保存失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } else { | |||
| record.setUpdateTime(date); | |||
| wxFinanceAdvanceTypeMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void updateAdvanceTypeIsDel(WxFinanceAdvanceType record) { | |||
| wxFinanceAdvanceTypeMapper.setIsDel(record.getId(), record.getTenantId(), record.getIsDel()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| <?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.WxFinanceAdvanceTypeMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxFinanceAdvanceType"> | |||
| <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="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` | |||
| </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 != 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 | |||
| <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.WxFinanceAdvanceType" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_finance_advance_type | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_finance_advance_type where id = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| <update id = "setIsDel" parameterType="HashMap"> | |||
| update wx_finance_advance_type set is_del = #{isDel} where id = #{id} and `tenant_id` = #{tenantId} | |||
| </update> | |||
| </mapper> | |||