PromotionplanModel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * PromotionplanModel.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 PromotionplanModel extends CommonModel {
  15. protected $name = 'promotion_plan';
  16. // 开启自动写入时间戳字段
  17. protected $autoWriteTimestamp = true;
  18. // /**
  19. // * 基础查询
  20. // *
  21. // * @param $query
  22. // */
  23. // protected function base($query) {
  24. // $query->where('is_delete', 2);
  25. // }
  26. public function updateData($gmh_data, $_map = null) {
  27. $_data = $gmh_data;
  28. $_data['update_time'] = time();
  29. $_rs = self::update($_data, $_map, true);
  30. if (false == $_rs) {
  31. return false;
  32. } else {
  33. return true;
  34. }
  35. }
  36. /**
  37. * 获取单条记录
  38. *
  39. * @param int $id
  40. *
  41. * @param bool $base
  42. *
  43. * @return array|false
  44. * @throws \think\Exception
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\ModelNotFoundException
  47. * @throws \think\exception\DbException
  48. */
  49. public function getInfoById($id, $base = true) {
  50. $_map['id'] = $id;
  51. $_info = $this->useGlobalScope($base)->where($_map)->find();
  52. if (false === $_info) {
  53. return false;
  54. }
  55. if (is_object($_info)) {
  56. return $_info->toArray();
  57. } else {
  58. return $_info;
  59. }
  60. }
  61. /**
  62. * 添加一条记录
  63. *
  64. * @param $data
  65. *
  66. * @return bool|mixed
  67. */
  68. public function addData($data) {
  69. if (empty($data)) {
  70. return false;
  71. }
  72. $_obj = self::create($data, true);
  73. if (false == $_obj) {
  74. return false;
  75. }
  76. return $_obj->id;
  77. }
  78. /**
  79. * 字段对应表
  80. *
  81. * @param array $where
  82. * @param string $_field
  83. *
  84. * @return array
  85. * @internal param bool $inc_nice
  86. *
  87. */
  88. public function getIdValues($where, $_field = 'domain') {
  89. $_platforms = $this->where($where)
  90. ->column($_field, 'id');
  91. return $_platforms;
  92. }
  93. }