AccountsRecordLogic.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\logic\admin;
  3. use Illuminate\Support\Facades\DB;
  4. class AccountsRecordLogic
  5. {
  6. /**
  7. * 添加操作记录 - 提现 / 充值
  8. * @param int $id 订单ID
  9. * @param int $before_state 提现前状态
  10. * @param int $after_state 提现后状态
  11. * @param string $remarks 备注
  12. * @param int $admin_id 操作人ID
  13. * @param int $type 类型 1提现 2充值
  14. * @return bool
  15. */
  16. public function create_record($id, $before_state, $after_state, $remarks, $admin_id, $type)
  17. {
  18. $first = DB::table('QPAccountsDB.dbo.AccountsRecord')->where('RecordID',$id)->first();
  19. $data = [
  20. 'RecordID' => $id,
  21. 'before_state' => $before_state,
  22. 'after_state' => $after_state,
  23. 'admin_id' => $admin_id,
  24. 'create_at' => date('Y-m-d H:i:s'),
  25. 'update_at' => date('Y-m-d H:i:s'),
  26. 'type' => $type,
  27. ];
  28. !empty($remarks) && $data['remarks'] = $remarks;
  29. $bool = DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $id, 'type' => $type], $data);
  30. }
  31. }