收款管理
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
package com.bms.web.controller.ar;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bms.ar.domain.ArBalanceWriteoff;
|
||||
import com.bms.ar.domain.ArBill;
|
||||
import com.bms.ar.service.IArBalanceWriteoffService;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.customer.customermoney.domain.CustomerReceipt;
|
||||
import com.bms.customer.customermoney.service.ICustomerMoneyService;
|
||||
|
||||
/**
|
||||
* 收款管理 Controller(账单管理-收款管理)
|
||||
* <p>
|
||||
* 收款登记/审核/取消与「客户余额-登记收款」复用同一套 Service 逻辑;
|
||||
* 账单核销同样复用余额核销 Service:登记收款时可携带核销计划(审核通过后联动核销),
|
||||
* 本页「账单核销」页签可直接对账单发起核销/反核销。
|
||||
*
|
||||
* @author bms
|
||||
* @date 2026-10-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ar/receipt")
|
||||
public class ArReceiptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICustomerMoneyService customerMoneyService;
|
||||
|
||||
@Autowired
|
||||
private IArBalanceWriteoffService balanceWriteoffService;
|
||||
|
||||
/** 收款时间查询/默认范围格式:精确到秒 */
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/**
|
||||
* 查询收款记录(跨客户)。支持按客户、收款时间(精确到时分秒)等维度查询,未传时间范围时默认查当天。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CustomerReceipt query)
|
||||
{
|
||||
if (query != null)
|
||||
{
|
||||
Object begin = query.getParams() == null ? null : query.getParams().get("beginTime");
|
||||
Object end = query.getParams() == null ? null : query.getParams().get("endTime");
|
||||
if (begin == null && end == null)
|
||||
{
|
||||
// 默认当天 00:00:00 ~ 23:59:59
|
||||
LocalDate today = LocalDate.now();
|
||||
query.getParams().put("beginTime", today.atStartOfDay().format(DATE_TIME_FORMATTER));
|
||||
query.getParams().put("endTime", today.atTime(23, 59, 59).format(DATE_TIME_FORMATTER));
|
||||
}
|
||||
}
|
||||
startPage();
|
||||
List<CustomerReceipt> list = customerMoneyService.selectReceiptList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收款单详情(含核销计划与收款附件)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(customerMoneyService.selectReceiptById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 登记收款(必须选择客户;默认待确认,审核通过后入账并执行登记时选择的核销计划)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:add')")
|
||||
@Log(title = "收款管理-登记收款", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CustomerReceipt receipt)
|
||||
{
|
||||
receipt.setCreateBy(getUsername());
|
||||
return toAjax(customerMoneyService.insertReceipt(receipt));
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核通过收款单:确认后金额计入客户余额,登记时选择的账单一并核销
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:review')")
|
||||
@Log(title = "收款管理-收款审核", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/confirm/{id}")
|
||||
public AjaxResult confirm(@PathVariable("id") Long id)
|
||||
{
|
||||
return toAjax(customerMoneyService.confirmReceipt(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消收款单(仅待确认可取消)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:edit')")
|
||||
@Log(title = "收款管理-取消收款", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/cancel/{id}")
|
||||
public AjaxResult cancel(@PathVariable("id") Long id)
|
||||
{
|
||||
return toAjax(customerMoneyService.cancelReceipt(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户可核销账单(已确认/部分核销,未核销额大于0),登记收款选账单与核销页签共用
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:list')")
|
||||
@GetMapping("/bill/unsettled/{customerId}")
|
||||
public AjaxResult unsettledBills(@PathVariable("customerId") Long customerId)
|
||||
{
|
||||
return success(balanceWriteoffService.selectUnsettledBills(customerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询核销记录(跨客户,支持客户/账单号/状态/核销日期范围)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:list')")
|
||||
@GetMapping("/writeoff/list")
|
||||
public TableDataInfo writeoffList(ArBalanceWriteoff query)
|
||||
{
|
||||
startPage();
|
||||
List<ArBalanceWriteoff> list = balanceWriteoffService.selectWriteoffList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 账单核销(账单核销页签直接核销;与客户余额页核销同一套逻辑)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:writeoff')")
|
||||
@Log(title = "收款管理-账单核销", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/writeoff")
|
||||
public AjaxResult writeoff(@RequestBody ArBalanceWriteoff cmd)
|
||||
{
|
||||
cmd.setCreateBy(getUsername());
|
||||
return success(balanceWriteoffService.writeoff(cmd));
|
||||
}
|
||||
|
||||
/**
|
||||
* 反核销(取消一笔有效核销,账单恢复未核销金额)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ar:receipt:writeoff:cancel')")
|
||||
@Log(title = "收款管理-反核销", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/writeoff/{writeoffId}/cancel")
|
||||
public AjaxResult cancelWriteoff(@PathVariable("writeoffId") Long writeoffId,
|
||||
@RequestBody(required = false) ArBalanceWriteoff body)
|
||||
{
|
||||
balanceWriteoffService.cancelWriteoff(writeoffId, body == null ? null : body.getCancelRemark());
|
||||
return success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user