|
|
|
@ -10,6 +10,7 @@ use App\Models\AgentProduct; |
|
|
|
use App\Models\Guide; |
|
|
|
use App\Models\IndustryOrder; |
|
|
|
use App\Models\Order; |
|
|
|
use App\Models\Statement; |
|
|
|
use App\Models\Supplier; |
|
|
|
use App\Models\Product; |
|
|
|
use App\Models\OrderProductItem; |
|
|
|
@ -102,8 +103,19 @@ class VerificationController extends Controller |
|
|
|
//扣除供应商的交易金
|
|
|
|
$supplier = Supplier::find($order->supplier_id); |
|
|
|
$supplier->trade_balance = $supplier->trade_balance - $order->trade_deposit; |
|
|
|
$supplier->balance = DB::raw('`balance` + ' . $order->paid_money); |
|
|
|
$supplier->save(); //需要用save才能执行模型事件记录日志
|
|
|
|
|
|
|
|
//记录余额日志
|
|
|
|
Statement::query()->forceCreate([ |
|
|
|
'price' => $order->paid_money, |
|
|
|
'type' => StatementType::INDUSTRY_ORDER, |
|
|
|
'user_id' => $order->supplier_id, |
|
|
|
'user_type' => Supplier::class, |
|
|
|
'access_id' => $order->id, |
|
|
|
'access_type' => IndustryOrder::class, |
|
|
|
]); |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return $this->success('核销成功'); |
|
|
|
} catch (\Exception $e) { |
|
|
|
|