Level_log.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Agent\Lib;
  3. use Dever;
  4. # 记录日志
  5. class Level_log
  6. {
  7. # 记录日志
  8. public function up($mid, $order_id, $old_level, $new_level, $new_sell, $sell, $group_num = 0)
  9. {
  10. $data['mid'] = $mid;
  11. $data['order_id'] = $order_id;
  12. $data['old_level'] = $old_level;
  13. $data['new_level'] = $new_level;
  14. $data['new_sell'] = $new_sell;
  15. $data['sell'] = $sell;
  16. $data['group_num'] = $group_num;
  17. $data['order_num'] = $this->getOrderId();
  18. if ($order_id && $order_id > 0) {
  19. $data['type'] = 1;
  20. } else {
  21. $admin = Dever::load('manage/auth.info');
  22. if ($admin) {
  23. $data['audit_admin'] = $admin['id'];
  24. $data['type'] = 2;
  25. }
  26. }
  27. $id = Dever::db('agent/member_level_log')->insert($data);
  28. if ($id) {
  29. # 升级时查看是否有升级的合同,如果没有需要生成
  30. }
  31. return $id;
  32. }
  33. /**
  34. * 生成日志订单号
  35. *
  36. * @return mixed
  37. */
  38. public function getOrderId()
  39. {
  40. $where['order_num'] = Dever::order('L');
  41. $state = Dever::db('agent/member_level_log')->one($where);
  42. if (!$state) {
  43. return $where['order_num'];
  44. } else {
  45. return $this->getOrderId();
  46. }
  47. }
  48. }