package com.java110.fee.api;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.java110.utils.util.Assert;
|
import com.java110.utils.util.BeanConvertUtil;
|
import org.mybatis.spring.SqlSessionTemplate;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 对方收款单位接口
|
* 适配 payee_receive_info 表
|
* @author dev
|
* @date 2025-12-24
|
*/
|
@RestController
|
@RequestMapping(value = "/payeeReceiveInfo")
|
public class PayeeReceiveInfoApi {
|
|
@Autowired
|
protected SqlSessionTemplate sqlSessionTemplate;
|
|
/**
|
* 保存对方收款单位信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/savePayeeReceiveInfo
|
* @path /app/payeeReceiveInfo/savePayeeReceiveInfo
|
*/
|
@RequestMapping(value = "/savePayeeReceiveInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> savePayeeReceiveInfo(@RequestBody JSONObject reqJson) {
|
// 核心参数校验(可根据业务补充必传校验)
|
Assert.hasKeyAndValue(reqJson, "owner_id", "请求报文中未包含业主编号owner_id");
|
|
// 转换为POJO
|
PayeeReceiveInfoPo po = BeanConvertUtil.covertBean(reqJson, PayeeReceiveInfoPo.class);
|
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("payeeReceiveInfoServiceDaoImpl.savePayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
JSONObject resJson = new JSONObject();
|
if (insert > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "保存对方收款单位信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "保存对方收款单位信息失败");
|
}
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
public ResponseEntity<String> savePayeeReceiveInfo(PayeeReceiveInfoPo po) {
|
// 调用Mapper保存方法
|
int insert = sqlSessionTemplate.insert("payeeReceiveInfoServiceDaoImpl.savePayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
// 构造响应结果
|
JSONObject resJson = new JSONObject();
|
if (insert > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "保存对方收款单位信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "保存对方收款单位信息失败");
|
}
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 批量保存对方收款单位信息
|
*
|
* @param reqJson 请求参数(包含payeeReceiveInfoList数组)
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/savePayeeReceiveInfos
|
* @path /app/payeeReceiveInfo/savePayeeReceiveInfos
|
*/
|
@RequestMapping(value = "/savePayeeReceiveInfos", method = RequestMethod.POST)
|
public ResponseEntity<String> savePayeeReceiveInfos(@RequestBody JSONObject reqJson) {
|
Assert.hasKeyAndValue(reqJson, "payeeReceiveInfoList", "请求报文中未包含批量数据列表");
|
|
// 转换批量数据
|
List<PayeeReceiveInfoPo> poList = BeanConvertUtil.covertBeanList(
|
reqJson.getJSONArray("payeeReceiveInfoList"), PayeeReceiveInfoPo.class);
|
|
Map<String, Object> param = BeanConvertUtil.beanCovertMap(reqJson);
|
param.put("payeeReceiveInfoList", poList);
|
|
// 批量插入
|
int insert = sqlSessionTemplate.insert("payeeReceiveInfoServiceDaoImpl.batchSavePayeeReceiveInfo", param);
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "批量保存对方收款单位信息成功");
|
resJson.put("count", insert);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 修改对方收款单位信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/updatePayeeReceiveInfo
|
* @path /app/payeeReceiveInfo/updatePayeeReceiveInfo
|
*/
|
@RequestMapping(value = "/updatePayeeReceiveInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> updatePayeeReceiveInfo(@RequestBody JSONObject reqJson) {
|
// 主键校验
|
Assert.hasKeyAndValue(reqJson, "id", "请求报文中未包含主键ID");
|
|
PayeeReceiveInfoPo po = BeanConvertUtil.covertBean(reqJson, PayeeReceiveInfoPo.class);
|
|
// 调用Mapper修改方法
|
int update = sqlSessionTemplate.update("payeeReceiveInfoServiceDaoImpl.updatePayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
JSONObject resJson = new JSONObject();
|
if (update > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "修改对方收款单位信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "修改对方收款单位信息失败,未找到对应记录");
|
}
|
resJson.put("count", update);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 删除对方收款单位信息
|
*
|
* @param reqJson 请求参数
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/deletePayeeReceiveInfo
|
* @path /app/payeeReceiveInfo/deletePayeeReceiveInfo
|
*/
|
@RequestMapping(value = "/deletePayeeReceiveInfo", method = RequestMethod.POST)
|
public ResponseEntity<String> deletePayeeReceiveInfo(@RequestBody JSONObject reqJson) {
|
// 必要参数校验
|
Assert.hasKeyAndValue(reqJson, "id", "主键ID不能为空");
|
|
PayeeReceiveInfoPo po = BeanConvertUtil.covertBean(reqJson, PayeeReceiveInfoPo.class);
|
|
// 调用Mapper删除方法
|
int delete = sqlSessionTemplate.delete("payeeReceiveInfoServiceDaoImpl.deletePayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(po));
|
|
JSONObject resJson = new JSONObject();
|
if (delete > 0) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "删除对方收款单位信息成功");
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "删除对方收款单位信息失败,未找到对应记录");
|
}
|
resJson.put("count", delete);
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 分页查询对方收款单位信息列表
|
*
|
* @param owner_id 业主编号(必传)
|
* @param page 页码(默认1)
|
* @param row 每页条数(默认10)
|
* @param id 主键ID(可选)
|
* @param room_id 房屋Id(可选)
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/queryPayeeReceiveInfo
|
* @path /app/payeeReceiveInfo/queryPayeeReceiveInfo
|
*/
|
@RequestMapping(value = "/queryPayeeReceiveInfo", method = RequestMethod.GET)
|
public ResponseEntity<String> queryPayeeReceiveInfo(
|
@RequestParam(value = "owner_id") String owner_id,
|
@RequestParam(value = "page", defaultValue = "1") int page,
|
@RequestParam(value = "row", defaultValue = "10") int row,
|
@RequestParam(value = "id", required = false) String id,
|
@RequestParam(value = "room_id", required = false) String room_id) {
|
|
// 封装查询参数
|
PayeeReceiveInfoPo queryPo = new PayeeReceiveInfoPo();
|
queryPo.setOwner_id(owner_id);
|
queryPo.setPage((page - 1) * row); // 转换为MySQL分页偏移量
|
queryPo.setRow(row);
|
|
if (id != null && !id.isEmpty()) {
|
queryPo.setId(Integer.parseInt(id));
|
}
|
if (room_id != null && !room_id.isEmpty()) {
|
queryPo.setRoom_id(room_id);
|
}
|
|
// 查询列表数据
|
List<Map<String, Object>> list = sqlSessionTemplate.selectList(
|
"payeeReceiveInfoServiceDaoImpl.getPayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
// 查询总数
|
Object total = ((HashMap) sqlSessionTemplate.selectOne(
|
"payeeReceiveInfoServiceDaoImpl.queryPayeeReceiveInfoCount",
|
BeanConvertUtil.beanCovertMap(queryPo))).get("count");
|
|
// 构造分页响应
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询对方收款单位信息成功");
|
resJson.put("page", page);
|
resJson.put("row", row);
|
resJson.put("total", total);
|
resJson.put("data", list);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据ID查询单条对方收款单位信息
|
*
|
* @param id 主键ID
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/getPayeeReceiveInfoById
|
* @path /app/payeeReceiveInfo/getPayeeReceiveInfoById
|
*/
|
@RequestMapping(value = "/getPayeeReceiveInfoById", method = RequestMethod.GET)
|
public ResponseEntity<String> getPayeeReceiveInfoById(@RequestParam(value = "id") Integer id) {
|
// 主键校验
|
Assert.notNull(id, "主键ID不能为空");
|
|
PayeeReceiveInfoPo queryPo = new PayeeReceiveInfoPo();
|
queryPo.setId(id);
|
|
// 查询单条数据
|
Map<String, Object> result = sqlSessionTemplate.selectOne(
|
"payeeReceiveInfoServiceDaoImpl.getPayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
if (result != null) {
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询对方收款单位信息成功");
|
resJson.put("data", result);
|
} else {
|
resJson.put("code", "0001");
|
resJson.put("msg", "未找到对应对方收款单位记录");
|
}
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 根据owner_id查询对方收款单位信息
|
*
|
* @param owner_id 业主编号
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/getPayeeReceiveInfoByOwnerId
|
* @path /app/payeeReceiveInfo/getPayeeReceiveInfoByOwnerId
|
*/
|
@RequestMapping(value = "/getPayeeReceiveInfoByOwnerId", method = RequestMethod.GET)
|
public ResponseEntity<String> getPayeeReceiveInfoByOwnerId(@RequestParam(value = "owner_id") String owner_id) {
|
Assert.notNull(owner_id, "业主编号owner_id不能为空");
|
|
PayeeReceiveInfoPo queryPo = new PayeeReceiveInfoPo();
|
queryPo.setOwner_id(owner_id);
|
|
List<Map<String, Object>> result = sqlSessionTemplate.selectList(
|
"payeeReceiveInfoServiceDaoImpl.getPayeeReceiveInfo",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "查询对方收款单位信息成功");
|
resJson.put("data", result);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 统计对方收款单位信息
|
*
|
* @param owner_id 业主编号(可选)
|
* @param room_id 房屋Id(可选)
|
* @param startCreateTime 开始创建时间(可选,格式:yyyy-MM-dd HH:mm:ss)
|
* @param endCreateTime 结束创建时间(可选)
|
* @return 响应结果
|
* @serviceCode /payeeReceiveInfo/queryPayeeReceiveInfoStatistics
|
* @path /app/payeeReceiveInfo/queryPayeeReceiveInfoStatistics
|
*/
|
@RequestMapping(value = "/queryPayeeReceiveInfoStatistics", method = RequestMethod.GET)
|
public ResponseEntity<String> queryPayeeReceiveInfoStatistics(
|
@RequestParam(value = "owner_id", required = false) String owner_id,
|
@RequestParam(value = "room_id", required = false) String room_id,
|
@RequestParam(value = "startCreateTime", required = false) String startCreateTime,
|
@RequestParam(value = "endCreateTime", required = false) String endCreateTime) {
|
|
PayeeReceiveInfoPo queryPo = new PayeeReceiveInfoPo();
|
queryPo.setOwner_id(owner_id);
|
queryPo.setRoom_id(room_id);
|
queryPo.setStartCreateTime(startCreateTime);
|
queryPo.setEndCreateTime(endCreateTime);
|
|
// 统计查询
|
Map<String, Object> statistics = sqlSessionTemplate.selectOne(
|
"payeeReceiveInfoServiceDaoImpl.queryPayeeReceiveInfoStatistics",
|
BeanConvertUtil.beanCovertMap(queryPo));
|
|
JSONObject resJson = new JSONObject();
|
resJson.put("code", "0000");
|
resJson.put("msg", "统计对方收款单位信息成功");
|
resJson.put("data", statistics);
|
|
return ResponseEntity.ok(resJson.toJSONString());
|
}
|
|
/**
|
* 配套POJO类(内部类形式,也可抽离为独立类)
|
*/
|
public static class PayeeReceiveInfoPo {
|
private Integer id;
|
private String caller_name;
|
private String contact_info;
|
private String payee_info;
|
private String invoice_no;
|
private String invoice_date;
|
private String receipt_no;
|
private String receipt_date;
|
private String receipt_note;
|
private String receipt_note_date;
|
private String image_file;
|
private String our_company_receive_date;
|
private String attachment_file;
|
private String create_time;
|
private String update_time;
|
private String owner_id;
|
private String room_id;
|
// 分页参数
|
private int page;
|
private int row;
|
// 统计时间范围参数
|
private String startCreateTime;
|
private String endCreateTime;
|
|
// Getter & Setter
|
public Integer getId() {
|
return id;
|
}
|
|
public void setId(Integer id) {
|
this.id = id;
|
}
|
|
public String getCaller_name() {
|
return caller_name;
|
}
|
|
public void setCaller_name(String caller_name) {
|
this.caller_name = caller_name;
|
}
|
|
public String getContact_info() {
|
return contact_info;
|
}
|
|
public void setContact_info(String contact_info) {
|
this.contact_info = contact_info;
|
}
|
|
public String getPayee_info() {
|
return payee_info;
|
}
|
|
public void setPayee_info(String payee_info) {
|
this.payee_info = payee_info;
|
}
|
|
public String getInvoice_no() {
|
return invoice_no;
|
}
|
|
public void setInvoice_no(String invoice_no) {
|
this.invoice_no = invoice_no;
|
}
|
|
public String getInvoice_date() {
|
return invoice_date;
|
}
|
|
public void setInvoice_date(String invoice_date) {
|
this.invoice_date = invoice_date;
|
}
|
|
public String getReceipt_no() {
|
return receipt_no;
|
}
|
|
public void setReceipt_no(String receipt_no) {
|
this.receipt_no = receipt_no;
|
}
|
|
public String getReceipt_date() {
|
return receipt_date;
|
}
|
|
public void setReceipt_date(String receipt_date) {
|
this.receipt_date = receipt_date;
|
}
|
|
public String getReceipt_note() {
|
return receipt_note;
|
}
|
|
public void setReceipt_note(String receipt_note) {
|
this.receipt_note = receipt_note;
|
}
|
|
public String getReceipt_note_date() {
|
return receipt_note_date;
|
}
|
|
public void setReceipt_note_date(String receipt_note_date) {
|
this.receipt_note_date = receipt_note_date;
|
}
|
|
public String getImage_file() {
|
return image_file;
|
}
|
|
public void setImage_file(String image_file) {
|
this.image_file = image_file;
|
}
|
|
public String getOur_company_receive_date() {
|
return our_company_receive_date;
|
}
|
|
public void setOur_company_receive_date(String our_company_receive_date) {
|
this.our_company_receive_date = our_company_receive_date;
|
}
|
|
public String getAttachment_file() {
|
return attachment_file;
|
}
|
|
public void setAttachment_file(String attachment_file) {
|
this.attachment_file = attachment_file;
|
}
|
|
public String getCreate_time() {
|
return create_time;
|
}
|
|
public void setCreate_time(String create_time) {
|
this.create_time = create_time;
|
}
|
|
public String getUpdate_time() {
|
return update_time;
|
}
|
|
public void setUpdate_time(String update_time) {
|
this.update_time = update_time;
|
}
|
|
public String getOwner_id() {
|
return owner_id;
|
}
|
|
public void setOwner_id(String owner_id) {
|
this.owner_id = owner_id;
|
}
|
|
public String getRoom_id() {
|
return room_id;
|
}
|
|
public void setRoom_id(String room_id) {
|
this.room_id = room_id;
|
}
|
|
public int getPage() {
|
return page;
|
}
|
|
public void setPage(int page) {
|
this.page = page;
|
}
|
|
public int getRow() {
|
return row;
|
}
|
|
public void setRow(int row) {
|
this.row = row;
|
}
|
|
public String getStartCreateTime() {
|
return startCreateTime;
|
}
|
|
public void setStartCreateTime(String startCreateTime) {
|
this.startCreateTime = startCreateTime;
|
}
|
|
public String getEndCreateTime() {
|
return endCreateTime;
|
}
|
|
public void setEndCreateTime(String endCreateTime) {
|
this.endCreateTime = endCreateTime;
|
}
|
}
|
}
|