优化财务流水写入

This commit is contained in:
luofei 2024-01-30 14:13:10 +08:00
parent 3626181717
commit 19cbb37def

View File

@ -213,23 +213,20 @@ class CommissionDao
*/
public function refundByCallback($data)
{
$finance = [];
$result = [];
$users = $this->getUsers($data['user']);
$order = StoreOrder::where('order_id', $data['order_id'])->find();
if (empty($order) || empty($users)) {
return [];
}
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
$financeSn = $financialRecordRepository->getSn();
$financeDao = new FinancialDao();
foreach ($users as $k => $user) {
foreach ($users as $user) {
$commission = bcdiv($user['user_profit'], 100, 2);
if ($commission > 0) {
$financeDao->user = $user;
$financeDao->order = $order;
$financialType = ($user['type'] == 3 ? 'order_commission' : 'first_order_commission') . '_refund';
$finance[] = $financeDao->platformIn($commission, $financialType, $financeSn, $k);
$financeDao->platformIn($commission, $financialType);
$result[] = $user;
}
$redPack = bcmul($order['pay_price'], 0.07, 2);
@ -241,9 +238,7 @@ class CommissionDao
}
}
}
if (count($finance) > 0) {
$financialRecordRepository->insertAll($finance);
}
$financeDao->save();
return $result;
}