收付款
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user