PromotionvisitlogModel.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * PromotionvisitlogModel.php UTF-8
  4. * 投放平台管理
  5. *
  6. * @date : 2018/7/26 21:41
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : guxiannong <gxn@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\distribution;
  13. use huo\model\common\CommonModel;
  14. class PromotionvisitlogModel extends CommonModel {
  15. protected $name = 'promotion_visit_log';
  16. // 开启自动写入时间戳字段
  17. protected $autoWriteTimestamp = true;
  18. public function updateData($gmh_data, $_map = null) {
  19. $_data = $gmh_data;
  20. $_data['update_time'] = time();
  21. $_rs = self::update($_data, $_map, true);
  22. if (false == $_rs) {
  23. return false;
  24. } else {
  25. return true;
  26. }
  27. }
  28. /**
  29. * 获取单条记录
  30. *
  31. * @param int $id
  32. *
  33. * @param bool $base
  34. *
  35. * @return array|false
  36. * @throws \think\Exception
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. * @throws \think\exception\DbException
  40. */
  41. public function getInfoById($id, $base = true) {
  42. $_map['id'] = $id;
  43. $_info = $this->useGlobalScope($base)->where($_map)->find();
  44. if (false === $_info) {
  45. return false;
  46. }
  47. if (is_object($_info)) {
  48. return $_info->toArray();
  49. } else {
  50. return $_info;
  51. }
  52. }
  53. /**
  54. * 添加一条记录
  55. *
  56. * @param $data
  57. *
  58. * @return bool|mixed
  59. */
  60. public function addData($data) {
  61. if (empty($data)) {
  62. return false;
  63. }
  64. $_obj = self::create($data, true);
  65. if (false == $_obj) {
  66. return false;
  67. }
  68. return $_obj->id;
  69. }
  70. /**
  71. * 字段对应表
  72. *
  73. * @param array $where
  74. * @param string $_field
  75. *
  76. * @return array
  77. * @internal param bool $inc_nice
  78. *
  79. */
  80. public function getIdValues($where, $_field = 'domain') {
  81. $_platforms = $this->where($where)
  82. ->column($_field, 'id');
  83. return $_platforms;
  84. }
  85. }