| @@ -14,6 +14,9 @@ import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxBillRent") | @RequestMapping("wxBillRent") | ||||
| public class WxBillRentController extends BaseController { | public class WxBillRentController extends BaseController { | ||||
| @@ -36,17 +39,13 @@ public class WxBillRentController extends BaseController { | |||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxBillRent wxBillRent) { | public ResultData add(@RequestBody WxBillRent wxBillRent) { | ||||
| //Assert.notNull(wxBillRent.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxBillRent.setTenantId(getTenantId()); | wxBillRent.setTenantId(getTenantId()); | ||||
| wxBillRentService.saveOrUpdate(wxBillRent); | |||||
| return new ResultData(ResultData.SUCCESS, "操作成功"); | |||||
| return wxBillRentService.saveOrUpdate(wxBillRent); | |||||
| } | } | ||||
| @PostMapping("update") | @PostMapping("update") | ||||
| public ResultData update(@RequestBody WxBillRent wxBillRent) { | public ResultData update(@RequestBody WxBillRent wxBillRent) { | ||||
| wxBillRentService.saveOrUpdate(wxBillRent); | |||||
| return new ResultData(ResultData.SUCCESS, "操作成功"); | |||||
| return wxBillRentService.saveOrUpdate(wxBillRent); | |||||
| } | } | ||||
| @GetMapping("/del") | @GetMapping("/del") | ||||
| @@ -6,11 +6,14 @@ import com.iformall.domain.po.WxBillRent; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxBillRentMapper extends CommonMapper<WxBillRent, String> { | public interface WxBillRentMapper extends CommonMapper<WxBillRent, String> { | ||||
| List<WxBillRent> findList(WxBillRent wxBillRent); | List<WxBillRent> findList(WxBillRent wxBillRent); | ||||
| List<Map<String,Object>> findListMap(WxBillRent record); | |||||
| List<Map<String,Object>> queryBillRentList(WxBillRent record); | |||||
| Map<String,Object> queryPayInfo(Map<String,Object> params); | Map<String,Object> queryPayInfo(Map<String,Object> params); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.service; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBillRent; | import com.iformall.domain.po.WxBillRent; | ||||
| public interface WxBillRentService { | public interface WxBillRentService { | ||||
| @@ -27,9 +28,9 @@ public interface WxBillRentService { | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| * | * | ||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxBillRent record); | |||||
| * @param record | |||||
| */ | |||||
| ResultData saveOrUpdate(WxBillRent record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -2,8 +2,12 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxBillRent; | import com.iformall.domain.po.WxBillRent; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxBillRentMapper; | import com.iformall.mapper.WxBillRentMapper; | ||||
| import com.iformall.service.WxBillRentService; | import com.iformall.service.WxBillRentService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -15,19 +19,22 @@ import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | @Service | ||||
| public class WxBillRentServiceImpl implements WxBillRentService { | public class WxBillRentServiceImpl implements WxBillRentService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxBillRentMapper wxBillRentMapper; | WxBillRentMapper wxBillRentMapper; | ||||
| @Override | @Override | ||||
| public PageInfo<Map<String, Object>> listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { | public PageInfo<Map<String, Object>> listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { | ||||
| PageHelper.startPage(pageIndex, pageSize); | PageHelper.startPage(pageIndex, pageSize); | ||||
| List<Map<String,Object>> shops = wxBillRentMapper.findListMap(record); | |||||
| PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(shops); | |||||
| List<Map<String, Object>> shops = wxBillRentMapper.queryBillRentList(record); | |||||
| PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(shops); | |||||
| return pageInfo; | return pageInfo; | ||||
| //return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillRentMapper.findList(record)); | //return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillRentMapper.findList(record)); | ||||
| } | } | ||||
| @@ -36,21 +43,35 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| public Map<String, Object> getById(Long id) { | public Map<String, Object> getById(Long id) { | ||||
| WxBillRent record = new WxBillRent(); | WxBillRent record = new WxBillRent(); | ||||
| record.setId(id); | record.setId(id); | ||||
| return wxBillRentMapper.findListMap(record).get(0); | |||||
| return wxBillRentMapper.queryBillRentList(record).get(0); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxBillRent record) { | |||||
| public ResultData saveOrUpdate(WxBillRent record) { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| logger.info("新增租赁账单"); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| record.setUpdatetime(date); | record.setUpdatetime(date); | ||||
| wxBillRentMapper.insertSelective(record); | |||||
| try { | |||||
| wxBillRentMapper.insertSelective(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("保存租赁账单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "保存租赁账单成功"); | |||||
| } else { | } else { | ||||
| logger.info("更新租赁账单"); | |||||
| record.setUpdatetime(new Date()); | record.setUpdatetime(new Date()); | ||||
| wxBillRentMapper.updateByPrimaryKeySelective(record); | |||||
| try { | |||||
| wxBillRentMapper.updateByPrimaryKeySelective(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("更新租赁账单失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "更新租赁账单成功"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -58,12 +79,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxBillRentMapper.deleteByPrimaryKey(id); | wxBillRentMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| } | } | ||||
| @@ -63,8 +63,28 @@ | |||||
| </select> | </select> | ||||
| <select id="queryBillRentList" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap"> | |||||
| select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate, | |||||
| br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`, | |||||
| br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime` | |||||
| from wx_bill_rent br left join wx_merchant m on br.merchant_id=m.id | |||||
| left join wx_shop s on br.shop_id=s.id | |||||
| <where> | |||||
| <if test=" null != id "> and br.`id` = #{id} </if> | |||||
| <if test=" null != merchantId "> and br.`merchant_id` = #{merchantId} </if> | |||||
| <if test=" null != tenantId "> and br.`tenant_id` = #{tenantId} </if> | |||||
| <if test=" null != status "> and br.`status` = #{status} </if> | |||||
| <if test=" null != isDel "> and br.`is_del` = #{isDel} </if> | |||||
| </where> | |||||
| order by id | |||||
| </select> | |||||
| <select id="queryPayInfo" resultType="hashmap" parameterType="hashmap"> | |||||
| select sum(receive_pay) receivepay,sum(pay) pay,tenant_id from wx_bill_rent | |||||
| where tenant_id=#{tenantId} and date_format(receive_date,'%Y-%m')=#{receiveDate} | |||||
| group by tenant_id | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -77,8 +77,8 @@ | |||||
| </select> | </select> | ||||
| <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract"> | <select id="queryRentContractData" resultType="hashmap" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| select rc.id,rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`, | |||||
| rc.price,rc.contract_number,s.shop_number,f.floor_name,b.building_name | |||||
| select rc.id,rc.merchant_name merchantName,rc.rental_start_date rentalStartDate,rc.rental_end_date rentalEndDate,rc.`status`, | |||||
| rc.price,rc.contract_number contractNumber,s.shop_number shopNumber,f.floor_name floorName,b.building_name buildingName | |||||
| from wx_rent_contract rc | from wx_rent_contract rc | ||||
| left join wx_shop s on rc.shop_id=s.id | left join wx_shop s on rc.shop_id=s.id | ||||
| left join wx_mall_floor f on s.floor=f.id | left join wx_mall_floor f on s.floor=f.id | ||||