| @@ -40,13 +40,13 @@ public class WxBillRentController extends BaseController | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxBillRent.setTenantId(getTenantId()); | |||
| wxBillRentService.saveOrUpdate(wxBillRent); | |||
| return new ResultData(); | |||
| return new ResultData(ResultData.SUCCESS,"操作成功"); | |||
| } | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxBillRent wxBillRent) { | |||
| wxBillRentService.saveOrUpdate(wxBillRent); | |||
| return new ResultData(); | |||
| return new ResultData(ResultData.SUCCESS,"操作成功"); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -0,0 +1,62 @@ | |||
| package com.simple.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxRentContract; | |||
| import com.simple.service.WxRentContractService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxRentContract") | |||
| public class WxRentContractController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxRentContractService wxRentContractService; | |||
| private Logger logger = Logger.getLogger(WxRentContractController.class); | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxRentContract wxRentContract,Integer pageNum, Integer pageSize) { | |||
| if (null == wxRentContract) wxRentContract = new WxRentContract(); | |||
| final PageInfo<WxRentContract> page = wxRentContractService.listAsPage(wxRentContract, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxRentContract wxRentContract) { | |||
| //Assert.notNull(wxRentContract.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxRentContractService.saveOrUpdate(wxRentContract); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxRentContract wxRentContract) { | |||
| wxRentContractService.saveOrUpdate(wxRentContract); | |||
| return new ResultData(); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData delete(String id) { | |||
| wxRentContractService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData findById(String id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxRentContractService.getById(id)); | |||
| } | |||
| } | |||
| @@ -14,17 +14,17 @@ public class WxBillRent implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected String id; | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public String getId() { | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(String id) { | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| @@ -55,13 +55,13 @@ public class WxBillRent implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="单价",name="price") | |||
| private BigDecimal price; | |||
| /*应缴金额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="应缴金额",name="needPay") | |||
| @io.swagger.annotations.ApiModelProperty(value="应收金额",name="needPay") | |||
| private BigDecimal needPay; | |||
| /*应收金额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="应收金额",name="receivePay") | |||
| @io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="receivePay") | |||
| private BigDecimal receivePay; | |||
| /*实收金额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="实收金额",name="pay") | |||
| @io.swagger.annotations.ApiModelProperty(value="实缴金额",name="pay") | |||
| private BigDecimal pay; | |||
| /*缴费周期**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="缴费周期",name="receivePeriod") | |||
| @@ -90,7 +90,7 @@ public class WxBillRent implements Serializable { | |||
| private String tenantId; | |||
| /*欠缴**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="欠缴",name="owe") | |||
| @io.swagger.annotations.ApiModelProperty(value="欠缴金额",name="owe") | |||
| private BigDecimal owe; | |||
| @@ -4,6 +4,7 @@ import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @@ -56,6 +57,10 @@ public class WxMerchant implements Serializable { | |||
| @Transient | |||
| private Date rentalEndDate; | |||
| /*单价**/ | |||
| @Transient | |||
| private BigDecimal price; | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| @@ -202,6 +207,14 @@ public class WxMerchant implements Serializable { | |||
| this.linkPerson = linkPerson; | |||
| } | |||
| public BigDecimal getPrice() { | |||
| return price; | |||
| } | |||
| public void setPrice(BigDecimal price) { | |||
| this.price = price; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -0,0 +1,170 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_rent_contract") | |||
| public class WxRentContract implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*商户**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户",name="merchantId") | |||
| private Long merchantId; | |||
| /*单价**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="单价",name="price") | |||
| private BigDecimal price; | |||
| /*计租开始时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="计租开始时间",name="rentalStartDate") | |||
| private Date rentalStartDate; | |||
| /*计租结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="计租结束时间",name="rentalEndDate") | |||
| private Date rentalEndDate; | |||
| /*签定合同时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="签定合同时间",name="signDate") | |||
| private Date signDate; | |||
| /*计租面积**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="计租面积",name="payArea") | |||
| private BigDecimal payArea; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="receivePeriod") | |||
| private Integer receivePeriod; | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(Long _merchantId) { | |||
| merchantId = _merchantId; | |||
| } | |||
| public BigDecimal getPrice() { | |||
| return price; | |||
| } | |||
| public void setPrice(BigDecimal _price) { | |||
| price = _price; | |||
| } | |||
| public Date getRentalStartDate() { | |||
| return rentalStartDate; | |||
| } | |||
| public void setRentalStartDate(Date _rentalStartDate) { | |||
| rentalStartDate = _rentalStartDate; | |||
| } | |||
| public Date getRentalEndDate() { | |||
| return rentalEndDate; | |||
| } | |||
| public void setRentalEndDate(Date _rentalEndDate) { | |||
| rentalEndDate = _rentalEndDate; | |||
| } | |||
| public Date getSignDate() { | |||
| return signDate; | |||
| } | |||
| public void setSignDate(Date _signDate) { | |||
| signDate = _signDate; | |||
| } | |||
| public BigDecimal getPayArea() { | |||
| return payArea; | |||
| } | |||
| public void setPayArea(BigDecimal _payArea) { | |||
| payArea = _payArea; | |||
| } | |||
| public Integer getReceivePeriod() { | |||
| return receivePeriod; | |||
| } | |||
| public void setReceivePeriod(Integer _receivePeriod) { | |||
| receivePeriod = _receivePeriod; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") | |||
| ,Price_ASC("`price` ASC"),Price_DESC("`price` DESC") | |||
| ,RentalStartDate_ASC("`rentalStartDate` ASC"),RentalStartDate_DESC("`rentalStartDate` DESC") | |||
| ,RentalEndDate_ASC("`rentalEndDate` ASC"),RentalEndDate_DESC("`rentalEndDate` DESC") | |||
| ,SignDate_ASC("`signDate` ASC"),SignDate_DESC("`signDate` DESC") | |||
| ,PayArea_ASC("`payArea` ASC"),PayArea_DESC("`payArea` DESC") | |||
| ,ReceivePay_ASC("`receive_period` ASC"),ReceivePay_DESC("`receive_period` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.simple.mapper; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.WxRentContract; | |||
| import java.util.List; | |||
| public interface WxRentContractMapper extends CommonMapper<WxRentContract, String> { | |||
| List<WxRentContract> findList(WxRentContract wxRentContract); | |||
| WxRentContract findObjectByMerchantId(Long id); | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxRentContract; | |||
| public interface WxRentContractService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxRentContract> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxRentContract getById(String id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxRentContract record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(String id); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.domain.po.WxBillRent; | |||
| import com.simple.mapper.WxBillRentMapper; | |||
| import com.simple.service.WxBillRentService; | |||
| @@ -33,7 +34,8 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||
| @Override | |||
| public void saveOrUpdate(WxBillRent record) { | |||
| if (record.getId() == null) { | |||
| record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxBillRentMapper.insertSelective(record); | |||
| } else { | |||
| wxBillRentMapper.updateByPrimaryKeySelective(record); | |||
| @@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @@ -36,6 +37,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Autowired | |||
| WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| WxRentContractMapper wxRentContractMapper; | |||
| @Override | |||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | |||
| @@ -123,6 +127,16 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| wxMerchant.setCreateDate(date); | |||
| wxMerchantMapper.insertSelective(wxMerchant); | |||
| WxRentContract wxRentContract = new WxRentContract(); | |||
| wxRentContract.setMerchantId(merchantid); | |||
| wxRentContract.setRentalStartDate(wxMerchant.getRentalStartDate()); | |||
| wxRentContract.setRentalEndDate(wxMerchant.getRentalEndDate()); | |||
| wxRentContract.setPrice(wxMerchant.getPrice()); | |||
| wxRentContract.setSignDate(date); | |||
| wxRentContract.setPayArea(new BigDecimal(0)); | |||
| wxRentContract.setReceivePeriod(0); | |||
| wxRentContractMapper.insertSelective(wxRentContract); | |||
| //保存商户商铺的关联 | |||
| List<Long> shopidlist = wxMerchant.getShopids(); | |||
| for(Long shopid:shopidlist){ | |||
| @@ -171,6 +185,15 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| wxMerchant.setUpdateDate(date); | |||
| wxMerchantMapper.updateByPrimaryKeySelective(wxMerchant); | |||
| WxRentContract wxRentContract = wxRentContractMapper.findObjectByMerchantId(wxMerchant.getId()); | |||
| wxRentContract.setRentalStartDate(wxMerchant.getRentalStartDate()); | |||
| wxRentContract.setRentalEndDate(wxMerchant.getRentalEndDate()); | |||
| wxRentContract.setPrice(wxMerchant.getPrice()); | |||
| wxRentContract.setSignDate(date); | |||
| wxRentContract.setPayArea(new BigDecimal(0)); | |||
| wxRentContract.setReceivePeriod(0); | |||
| wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); | |||
| //删除当前商户关联的所有商铺然后再插入 | |||
| WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | |||
| wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); | |||
| @@ -0,0 +1,53 @@ | |||
| package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.IdWorker; | |||
| import com.simple.domain.po.WxRentContract; | |||
| import com.simple.mapper.WxRentContractMapper; | |||
| import com.simple.service.WxRentContractService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxRentContractMapper wxRentContractMapper; | |||
| @Override | |||
| public PageInfo<WxRentContract> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxRentContract getById(String id) { | |||
| return wxRentContractMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxRentContract record) { | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxRentContractMapper.insertSelective(record); | |||
| } else { | |||
| wxRentContractMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(String id) { | |||
| wxRentContractMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| <?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.simple.mapper.WxRentContractMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxRentContract"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="price" jdbcType="DECIMAL" property="price" /> | |||
| <result column="rental_start_date" jdbcType="TIMESTAMP" property="rentalStartDate" /> | |||
| <result column="rental_end_date" jdbcType="TIMESTAMP" property="rentalEndDate" /> | |||
| <result column="sign_date" jdbcType="TIMESTAMP" property="signDate" /> | |||
| <result column="pay_area" jdbcType="DECIMAL" property="payArea" /> | |||
| <result column="receive_period" jdbcType="INTEGER" property="receivePeriod" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`merchant_id`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`pay_area`,`receive_pay` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if> | |||
| <if test=" null != price "> and `price` = #{price} </if> | |||
| <if test=" null != rentalStartDate "> and `rental_start_date` = #{rentalStartDate} </if> | |||
| <if test=" null != rentalEndDate "> and `rental_end_date` = #{rentalEndDate} </if> | |||
| <if test=" null != signDate "> and `sign_date` = #{signDate} </if> | |||
| <if test=" null != payArea "> and `pay_area` = #{payArea} </if> | |||
| <if test=" null != receivePeriod "> and `receive_period` = #{receivePeriod} </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.simple.domain.po.WxRentContract" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_rent_contract | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findObjectByMerchantId" resultMap="BaseResultMap"> | |||
| select * from wx_rent_contract where merchant_id=#{value} | |||
| </select> | |||
| </mapper> | |||
| @@ -232,9 +232,11 @@ | |||
| </select> | |||
| <select id="getMerchantShopByShopId" resultType="hashmap" parameterType="hashmap"> | |||
| select m.`name` merchantName,s.build_area buildArea,s.operation_area operationArea | |||
| select m.`name` merchantName,s.build_area buildArea,s.operation_area operationArea, | |||
| c.price,c.receive_period receivePeriod | |||
| from wx_merchant_shop ms inner join wx_merchant m on ms.merchant_id=m.id | |||
| inner join wx_shop s on ms.shop_id=s.id | |||
| inner join wx_rent_contract c on ms.merchant_id=c.merchant_id | |||
| where ms.tenant_id=${tenantId} and ms.shop_id=${shopId} and ms.is_del=0 | |||
| </select> | |||