StoreApplicationModel.class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace Admin\Model;
  3. use Common\Model\StoreApplicationModel as StoreApplication;
  4. /**
  5. * 加盟申请
  6. * @author: linch
  7. * Class StoreApplicationModel
  8. * @package Admin\Model
  9. */
  10. class StoreApplicationModel extends StoreApplication
  11. {
  12. /**
  13. * 状态列表
  14. * @author: linch
  15. * @return array
  16. */
  17. public function get_status_list() {
  18. return array(
  19. self::status_wait => '待处理',
  20. self::status_processed => '已联系',
  21. );
  22. }
  23. /**
  24. * 获取来源
  25. * @author: linch
  26. * @return array
  27. */
  28. public function get_source_list() {
  29. return array(
  30. self::source_mini_app => '小程序',
  31. self::source_official_web => '官网',
  32. self::source_official_wap => 'wap端',
  33. );
  34. }
  35. /**
  36. * 申请列表
  37. * @author: linch
  38. * @param array $search 筛选条件
  39. * @param int $page_num 页码
  40. * @param int $page_size 页行数
  41. * @return array
  42. */
  43. public function get_list($search, $page_num, $page_size) {
  44. $where = array(
  45. 'flag' => self::flag_on,
  46. );
  47. $s_time = strtotime($search['s_time']);
  48. $e_time = strtotime($search['e_time']);
  49. if (!empty($s_time)) {
  50. $where['c_time'][] = array('egt', date('Y-m-d H:i:s', $s_time));
  51. }
  52. if (!empty($e_time)) {
  53. $where['c_time'][] = array('elt', date('Y-m-d H:i:s', $e_time));
  54. }
  55. $order = 'id desc';
  56. $limit = ($page_num - 1) * $page_size . ' ,' . $page_size;
  57. $field = '*';
  58. $list = $this->where($where)->order($order)->field($field)->limit($limit)->select();
  59. $count = $this->where($where)->count();
  60. $page = $this->x_show($count, $page_size, array());
  61. $ad_message_id_arr = array();
  62. foreach ($list as $k => $v) {
  63. $ad_message_id_arr[] = $v['ad_message_id'];
  64. }
  65. //广告数据
  66. $ad_message_id_arr = array_unique($ad_message_id_arr);
  67. $ad_message_data = array();
  68. if (!empty($ad_message_id_arr)) {
  69. $ad_message_model = new \Common\Model\AdMessageModel();
  70. $ad_message_temp = $ad_message_model->field('id,name')->where(array('id' => array('in', $ad_message_id_arr)))->select();
  71. foreach ($ad_message_temp as $k => $v) {
  72. $ad_message_data[$v['id']] = $v;
  73. }
  74. }
  75. //整合数据
  76. foreach ($list as $k => $v) {
  77. if (empty($ad_message_data[$v['ad_message_id']])) {
  78. $list[$k]['ad_source'] = '';
  79. } else {
  80. $list[$k]['ad_source'] = $ad_message_data[$v['ad_message_id']]['name'];
  81. }
  82. }
  83. $data = array(
  84. 'list' => $list,
  85. 'pager' => $page,
  86. );
  87. return $data;
  88. }
  89. /**
  90. * 设置已联系状态
  91. * @author: linch
  92. * @param $id
  93. * @return bool
  94. */
  95. public function data_set_finish($id) {
  96. $result = $this->where(array('id' => $id))->setField(array('status' => self::status_processed));
  97. return $result;
  98. }
  99. /**
  100. * 设置删除
  101. * @author: linch
  102. * @param $id
  103. * @return bool
  104. */
  105. public function data_del($id) {
  106. $result = $this->where(array('id' => $id))->setField(array('flag' => self::flag_off));
  107. return $result;
  108. }
  109. }