确认入账
This commit is contained in:
@@ -24,6 +24,23 @@ class FinReceiptController extends BaseController
|
||||
{
|
||||
$this->service = new FinReceiptService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认入账
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function credit(Request $request)
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id');
|
||||
$raw = $this->service->credit($id);
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -14,4 +14,8 @@ class FinReceiptLogic
|
||||
*/
|
||||
protected string $modelClass = FinReceipt::class;
|
||||
|
||||
public function credit($id)
|
||||
{
|
||||
return FinReceipt::where('id', $id)->update(['received_at' => time()]);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\logic\FinReceiptLogic;
|
||||
use app\common\model\FinReceiptHis;
|
||||
use app\common\validate\FinReceiptValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\FinReceipt;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class FinReceiptService
|
||||
@@ -23,6 +25,14 @@ class FinReceiptService
|
||||
*/
|
||||
protected $validator = FinReceiptValidate::class;
|
||||
|
||||
|
||||
protected $logic;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logic = (new FinReceiptLogic());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
@@ -251,4 +261,13 @@ class FinReceiptService
|
||||
|
||||
return $query->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
public function credit($id)
|
||||
{
|
||||
$finReceipt = FinReceipt::find($id);
|
||||
if(!empty($finReceipt->received_at)){
|
||||
throw new BusinessException('该记录已将确认入账');
|
||||
}
|
||||
return $this->logic->credit($id);
|
||||
}
|
||||
}
|
||||
@@ -360,6 +360,7 @@ Route::group('/admin', function () {
|
||||
Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']);
|
||||
Route::any('/payment', [app\common\controller\FinReceiptController::class, 'update']);
|
||||
Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']);
|
||||
Route::any('/credit', [app\common\controller\FinReceiptController::class, 'credit']);
|
||||
});
|
||||
// 收款记录历史
|
||||
Route::group('/receipt/his', function () {
|
||||
|
||||
Reference in New Issue
Block a user