Merge branch 'feature/fin' into develop
This commit is contained in:
@@ -34,7 +34,11 @@ class FinReceiptController extends BaseController
|
||||
{
|
||||
try {
|
||||
$id = $request->input('id');
|
||||
$raw = $this->service->credit($id);
|
||||
$exchange_rate = $request->input('exchange_rate');
|
||||
if(empty($exchange_rate) || !is_numeric($exchange_rate)){
|
||||
return $this->error('请输入汇率');
|
||||
}
|
||||
$raw = $this->service->credit($id,$exchange_rate);
|
||||
return $this->success($raw);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
|
||||
@@ -14,8 +14,8 @@ class FinReceiptLogic
|
||||
*/
|
||||
protected string $modelClass = FinReceipt::class;
|
||||
|
||||
public function credit($id)
|
||||
public function credit($id, $data)
|
||||
{
|
||||
return FinReceipt::where('id', $id)->update(['received_at' => time()]);
|
||||
return FinReceipt::where('id', $id)->update($data);
|
||||
}
|
||||
}
|
||||
@@ -282,13 +282,19 @@ class FinReceiptService
|
||||
return $query->paginate($limit, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
public function credit($id)
|
||||
public function credit($id, $exchange_rate)
|
||||
{
|
||||
$finReceipt = FinReceipt::find($id);
|
||||
if(!empty($finReceipt->received_at)){
|
||||
throw new BusinessException('该记录已将确认入账');
|
||||
}
|
||||
$res = $this->logic->credit($id);
|
||||
|
||||
$data = [
|
||||
'received_at' => time(),
|
||||
'exchange_rate' => $exchange_rate,
|
||||
'total_amount_cny' => round($finReceipt['amount']*$exchange_rate,2),
|
||||
];
|
||||
$res = $this->logic->credit($id,$data);
|
||||
$this->afterServiceUpdate(['id'=>$id]);
|
||||
return $res;
|
||||
}
|
||||
@@ -303,10 +309,6 @@ class FinReceiptService
|
||||
public function serviceUpdatePayment(Request $request, array $data = [], string $scene = 'payment')
|
||||
{
|
||||
$payment_apply_id = $request->input('payment_apply_id');
|
||||
$exchange_rate = $request->input('exchange_rate');
|
||||
if(empty($exchange_rate) || !is_numeric($exchange_rate)){
|
||||
throw new BusinessException('请输入汇率');
|
||||
}
|
||||
|
||||
$id = $request->input('id');
|
||||
$data = $this->preProcess(ucfirst($scene), $data, $request);
|
||||
@@ -319,8 +321,6 @@ class FinReceiptService
|
||||
$receipt = FinReceipt::find($id);
|
||||
$data['discount_amount'] = $payment->amount - $receipt->amount ?? 0;
|
||||
$data['submit_files'] = $payment->submit_files ?? '';
|
||||
$data['exchange_rate'] = $exchange_rate;
|
||||
$data['total_amount_cny'] = round($data['amount']*$exchange_rate,2);
|
||||
|
||||
$updated = $this->logicUpdateBy($config, $data);
|
||||
return $this->postProcess(ucfirst($scene), $data);
|
||||
|
||||
Reference in New Issue
Block a user