优化财务流水写入
This commit is contained in:
parent
3626181717
commit
19cbb37def
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user