Log.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php namespace Place_order\Lib;
  2. use Dever;
  3. class Log
  4. {
  5. protected $table;
  6. public function up($utype, $uid, $order_id, $desc, $id = false)
  7. {
  8. $update['utype'] = $utype;
  9. $update['uid'] = $uid;
  10. $update['order_id'] = $order_id;
  11. $update['desc'] = $desc;
  12. if ($id) {
  13. Dever::db($this->table, 'place_order')->update($id, $update);
  14. } else {
  15. Dever::db($this->table, 'place_order')->insert($update);
  16. }
  17. }
  18. # 获取日志信息
  19. public function getList($order_id)
  20. {
  21. $log = Dever::db($this->table, 'place_order')->select(['order_id' => $order_id]);
  22. if ($log) {
  23. foreach ($log as &$v) {
  24. $v = $this->getInfo($v);
  25. }
  26. }
  27. return $log;
  28. }
  29. # 获取日志信息
  30. public function getInfo($info)
  31. {
  32. if ($info['utype'] == 1) {
  33. $user = Dever::db('info', 'place_user')->find($info['uid']);
  34. } elseif ($info['utype'] == 2) {
  35. $user = Dever::db('user', 'sector')->find($info['uid']);
  36. } elseif ($info['utype'] > 30) {
  37. $type = $info['utype'] - 30;
  38. $user = Dever::load('info', 'place_channel_market')->get($type, $info['uid']);
  39. } elseif ($info['utype'] > 20) {
  40. $type = $info['utype'] - 20;
  41. $user = Dever::load('info', 'place_channel_supply')->get($type, $info['uid']);
  42. } elseif ($info['utype'] > 10) {
  43. $type = $info['utype'] - 10;
  44. $user = Dever::load('info', 'place_channel_sales')->get($type, $info['uid']);
  45. } else {
  46. $user['name'] = $user['mobile'] = '-';
  47. }
  48. $info['utype'] = Dever::db($this->table, 'place_order')->value('utype', $info);
  49. $info['name'] = $user['name'];
  50. $info['mobile'] = $user['mobile'];
  51. $info['cdate_str'] = date('Y-m-d H:i:s', $info['cdate']);
  52. return $info;
  53. }
  54. }