MpAdReportLogModel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * MpAdReportLogModel.php UTF-8
  4. *
  5. *
  6. * @date : 2021-04-06 11:39
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 9.0
  11. */
  12. namespace huomp\model\weixin;
  13. use huo\model\game\GameModel;
  14. use huo\model\member\MemberModel;
  15. use huo\model\user\UserModel;
  16. class MpAdReportLogModel extends CommonModel {
  17. protected $name = 'mpad_report_log';
  18. protected $pk = 'id';
  19. /* 开启自动写入时间戳字段 */
  20. protected $autoWriteTimestamp = 'create_time';
  21. protected $type
  22. = [
  23. 'id' => 'integer',
  24. 'agent_id' => 'integer',
  25. 'mem_id' => 'integer',
  26. 'app_id' => 'integer',
  27. 'mg_mem_id' => 'integer',
  28. 'server_id' => 'string',
  29. 'role_id' => 'string',
  30. 'advertiser_app_id' => 'string',
  31. 'source_id' => 'string',
  32. 'url' => 'string',
  33. 'action_type' => 'string',
  34. 'action_time' => 'integer',
  35. 'wechat_app_id' => 'string',
  36. 'wechat_openid' => 'string',
  37. 'action_param_value' => 'string',
  38. 'action_param_source' => 'string',
  39. 'action_param_claim_type' => 'integer',
  40. 'create_time' => 'integer',
  41. ];
  42. /**
  43. * 添加数据
  44. *
  45. * @param array $data 需要添加的数据
  46. *
  47. * @return false|int 添加失败返回 false 添加成功 返回添加的ID
  48. */
  49. public function addData($data) {
  50. $_data = $data;
  51. $_id = parent::addData($_data);
  52. if (false === $_id) {
  53. return false;
  54. }
  55. /* TAG缓存操作 */
  56. return $_id;
  57. }
  58. public function agent() {
  59. return $this->belongsTo(UserModel::class, 'agent_id')->field(['id', 'user_login', 'user_nicename']);
  60. }
  61. public function mem() {
  62. return $this->belongsTo(MemberModel::class, 'mem_id')->field(['id', 'username']);
  63. }
  64. public function game() {
  65. return $this->belongsTo(GameModel::class, 'app_id')->field(['id', 'name']);
  66. }
  67. }