IntegralActivityModel.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * IntegralActivityModel.php UTF-8
  4. *
  5. *
  6. * @date : 2018/5/5 14:17
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\integral;
  13. use huo\model\common\CommonModel;
  14. class IntegralActivityModel extends CommonModel {
  15. protected $name = 'itg_act';
  16. // 开启自动写入时间戳字段
  17. protected $autoWriteTimestamp = true;
  18. /**
  19. * 基础查询
  20. *
  21. * @param $query
  22. */
  23. protected function base($query) {
  24. $query->where('delete_time', 0)
  25. ->where('is_delete', 2);
  26. }
  27. /**
  28. * 添加积分活动
  29. *
  30. * @param $data
  31. *
  32. * @return bool|mixed
  33. */
  34. public function addIa($data) {
  35. if (empty($data)) {
  36. return false;
  37. }
  38. if ($_obj = self::create($data, true)) {
  39. return $_obj->id;
  40. } else {
  41. return false;
  42. }
  43. }
  44. /**
  45. * 获取积分活动
  46. *
  47. * @param array $where
  48. *
  49. * @return array|false|\PDOStatement|string|\think\Collection
  50. */
  51. public function getIas($where = []) {
  52. $_field
  53. = 'id,ia_code,ia_name,icon,ia_desc,integral,link_table,start_time,end_time,limit_agent,list_order,limit_cnt,type';
  54. $_data = $this->where($where)->order('list_order desc, id asc')->column($_field, 'id');
  55. return $_data;
  56. }
  57. /**
  58. * 更新积分活动
  59. *
  60. * @param array $ia_data
  61. * @param int $ia_id
  62. *
  63. * @return bool
  64. */
  65. public function updateIa($ia_data, $ia_id) {
  66. $_map['id'] = $ia_id;
  67. $_data = $ia_data;
  68. $_rs = self::update($_data, $_map, true);
  69. if (false == $_rs) {
  70. return false;
  71. } else {
  72. return true;
  73. }
  74. }
  75. }