收付款

This commit is contained in:
2025-10-29 14:14:40 +08:00
parent 8a1b2f2369
commit 07c0b2a2f3
5 changed files with 51 additions and 3 deletions
@@ -66,6 +66,8 @@ class FinPaymentApplyController extends BaseController
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
if (isset($data['claimed_at']))
$data['claimed_at'] = date('Y-m-d H:i:s', $data['claimed_at']);
return $data;
}
+21 -1
View File
@@ -53,6 +53,24 @@ class FinReceiptController extends BaseController
return $this->error($e->getMessage());
}
}
/**
* 更新
*
* @param Request $request 请求对象
* @return mixed 返回更新成功的数据或信息
*/
public function payment(Request $request)
{
try {
$data = $this->validate($this->service->getValidator(), $request->post(), 'update');
$res = $this->service->serviceUpdatePayment($request, $data);
return $this->success([], '更新成功');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 列表页数据格式化
*
@@ -61,8 +79,10 @@ class FinReceiptController extends BaseController
*/
protected function indexFormat($data)
{
if (isset($data['created_at']))
if (isset($data['created_at'])){
$data['claim_timeout'] = (($data['created_at'] < (time()-86400)) && empty($data['payment_apply_id'])) ?1:0;
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
}
if (isset($data['updated_at']))
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
if (isset($data['arrived_at']))
+1 -1
View File
@@ -40,7 +40,7 @@ class FinPaymentApply extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files', 'created_at', 'updated_at'];
protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
+26
View File
@@ -3,6 +3,7 @@
namespace app\common\service;
use app\common\logic\FinReceiptLogic;
use app\common\model\FinPaymentApply;
use app\common\model\FinReceiptHis;
use app\common\validate\FinReceiptValidate;
use app\common\traits\crud\CrudServiceTrait;
@@ -89,6 +90,7 @@ class FinReceiptService
$config['where']['id'] = $p['id'];
break;
case 'update':
case 'payment':
case 'destroy':
$config['where']['id'] = $p['id'];
break;
@@ -272,4 +274,28 @@ class FinReceiptService
$this->afterServiceUpdate(['id'=>$id]);
return $res;
}
/**
* 更新计算折让金额
* @param Request $request
* @param array $data
* @param string $scene
* @return mixed
*/
public function serviceUpdatePayment(Request $request, array $data = [], string $scene = 'payment')
{
$payment_apply_id = $request->input('payment_apply_id');
$id = $request->input('id');
$data = $this->preProcess(ucfirst($scene), $data, $request);
$config = $this->buildQueryConfig($request, $scene);
FinPaymentApply::where('id', $payment_apply_id)->update(['receipt_id' => $id, 'claimed_at' => time()]);
//折让金额
$payment = FinPaymentApply::where('id', $payment_apply_id)->first();
$receipt = FinReceipt::find($id);
$data['discount_amount'] = $payment->amount - $payment->amount ?? 0;
$updated = $this->logicUpdateBy($config, $data);
return $this->postProcess(ucfirst($scene), $data);
}
}
+1 -1
View File
@@ -358,7 +358,7 @@ Route::group('/admin', function () {
Route::any('/show', [app\common\controller\FinReceiptController::class, 'show']);
Route::any('/store', [app\common\controller\FinReceiptController::class, 'store']);
Route::any('/update', [app\common\controller\FinReceiptController::class, 'update']);
Route::any('/payment', [app\common\controller\FinReceiptController::class, 'update']);
Route::any('/payment', [app\common\controller\FinReceiptController::class, 'payment']);
Route::any('/destroy', [app\common\controller\FinReceiptController::class, 'destroy']);
Route::any('/credit', [app\common\controller\FinReceiptController::class, 'credit']);
});