OrderLog.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\common\model;
  20. use app\common\enum\OrderEnum;
  21. use app\common\enum\OrderLogEnum;
  22. use think\model\concern\SoftDelete;
  23. /**
  24. * 订单日志
  25. * Class OrderLog
  26. * @package app\common\model
  27. */
  28. class OrderLog extends BaseModel
  29. {
  30. public function record($params)
  31. {
  32. $this->insert([
  33. 'type' => $params['type'],
  34. 'channel' => $params['channel'],
  35. 'order_id' => $params['order_id'],
  36. 'operator_id' => $params['operator_id'] ?? 0,
  37. 'content' => $params['content'] ?? OrderLogEnum::getRecordDesc($params['channel']),
  38. 'create_time' => time(),
  39. 'update_time' => time(),
  40. ]);
  41. }
  42. /**
  43. * @notes 变动方式获取器
  44. * @param $value
  45. * @param $data
  46. * @return string|string[]
  47. * @author ljj
  48. * @date 2021/8/6 3:24 下午
  49. */
  50. public function getChannelDescAttr($value,$data)
  51. {
  52. return OrderLogEnum::getRecordDesc($data['channel']);
  53. }
  54. /**
  55. * @notes 操作人获取器
  56. * @param $value
  57. * @param $data
  58. * @return mixed|string
  59. * @author ljj
  60. * @date 2021/8/9 5:23 下午
  61. */
  62. public function getOperatorAttr($value,$data)
  63. {
  64. switch ($data['type']) {
  65. case 1:
  66. return '系统';
  67. case 2:
  68. return Admin::where('id',$data['operator_id'])->value('name');
  69. case 3:
  70. return User::where('id',$data['operator_id'])->value('nickname');
  71. default:
  72. return '未知';
  73. }
  74. }
  75. }