Promotionmansong.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Promotionmansong extends AdminControl
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/promotionmansong.lang.php');
  21. }
  22. /**
  23. * 活动列表
  24. **/
  25. public function index()
  26. {
  27. //自动开启满就送
  28. if (intval(input('param.promotion_allow')) === 1) {
  29. $config_model = model('config');
  30. $update_array = array();
  31. $update_array['promotion_allow'] = 1;
  32. $config_model->editConfig($update_array);
  33. }
  34. $mansong_model = model('pmansong');
  35. $param = array();
  36. if (!empty(input('param.mansong_name'))) {
  37. $param[] = array('mansong_name', 'like', '%' . input('param.mansong_name') . '%');
  38. }
  39. if (!empty(input('param.store_name'))) {
  40. $param[] = array('store_name', 'like', '%' . input('param.store_name') . '%');
  41. }
  42. if (!empty(input('param.state'))) {
  43. $param[] = array('mansong_state', '=', input('param.state'));
  44. }
  45. $mansong_list = $mansong_model->getMansongList($param, 10);
  46. View::assign('mansong_list', $mansong_list);
  47. View::assign('show_page', $mansong_model->page_info->render());
  48. View::assign('mansong_state_array', $mansong_model->getMansongStateArray());
  49. $this->setAdminCurItem('index');
  50. // 输出自营店铺IDS
  51. View::assign('flippedOwnShopIds', array_flip(model('store')->getOwnShopIds()));
  52. return View::fetch();
  53. }
  54. /**
  55. * 活动详细信息
  56. * temp
  57. **/
  58. public function mansong_detail()
  59. {
  60. $mansong_id = intval(input('param.mansong_id'));
  61. $mansong_model = model('pmansong');
  62. $mansongrule_model = model('pmansongrule');
  63. $mansong_info = $mansong_model->getMansongInfoByID($mansong_id);
  64. if (empty($mansong_info)) {
  65. $this->error(lang('param_error'));
  66. }
  67. View::assign('mansong_info', $mansong_info);
  68. $param = array();
  69. $param['mansong_id'] = $mansong_id;
  70. $mansongrule_list = $mansongrule_model->getMansongruleListByID($mansong_id);
  71. View::assign('mansongrule_list', $mansongrule_list);
  72. $this->setAdminCurItem('mansong_detail');
  73. return View::fetch();
  74. }
  75. /**
  76. * 满即送活动取消
  77. **/
  78. public function mansong_cancel()
  79. {
  80. $mansong_id = intval(input('param.mansong_id'));
  81. if ($mansong_id <= 0) {
  82. ds_json_encode(10001, lang('param_error'));
  83. }
  84. $mansong_model = model('pmansong');
  85. $result = $mansong_model->cancelMansong(array('mansong_id' => $mansong_id));
  86. if ($result) {
  87. $this->log('取消满即送活动,活动编号' . $mansong_id);
  88. ds_json_encode(10000, lang('ds_common_del_succ'));
  89. } else {
  90. ds_json_encode(10001, lang('ds_common_del_fail'));
  91. }
  92. }
  93. /**
  94. * 满即送活动删除
  95. **/
  96. public function mansong_del()
  97. {
  98. $mansong_model = model('pmansong');
  99. $mansong_id = input('param.mansong_id');
  100. $mansong_id_array = ds_delete_param($mansong_id);
  101. if ($mansong_id_array === FALSE) {
  102. ds_json_encode(10001, lang('param_error'));
  103. }
  104. $condition = array(array('mansong_id', 'in', $mansong_id_array));
  105. $result = $mansong_model->delMansong($condition);
  106. if ($result) {
  107. $this->log('删除满即送活动,活动编号' . implode(',', $mansong_id_array));
  108. ds_json_encode(10000, lang('ds_common_del_succ'));
  109. } else {
  110. ds_json_encode(10001, lang('ds_common_del_fail'));
  111. }
  112. }
  113. /**
  114. * 套餐管理
  115. **/
  116. public function mansong_quota()
  117. {
  118. $mansongquota_model = model('pmansongquota');
  119. $param = array();
  120. if (!empty(input('param.store_name'))) {
  121. $param[] = array('store_name', 'like', '%' . input('param.store_name') . '%');
  122. }
  123. $mansongquota_list = $mansongquota_model->getMansongquotaList($param, 10, 'mansongquota_id desc');
  124. View::assign('mansongquota_list', $mansongquota_list);
  125. View::assign('show_page', $mansongquota_model->page_info->render());
  126. $this->setAdminCurItem('mansong_quota');
  127. return View::fetch();
  128. }
  129. /**
  130. * 设置
  131. **/
  132. public function mansong_setting()
  133. {
  134. if (!(request()->isPost())) {
  135. $setting = rkcache('config', true);
  136. View::assign('setting', $setting);
  137. $this->setAdminCurItem('mansong_setting');
  138. return View::fetch();
  139. } else {
  140. $promotion_mansong_price = intval(input('post.promotion_mansong_price'));
  141. if ($promotion_mansong_price < 0) {
  142. $this->error(lang('param_error'));
  143. }
  144. $config_model = model('config');
  145. $update_array = array();
  146. $update_array['promotion_mansong_price'] = $promotion_mansong_price;
  147. $result = $config_model->editConfig($update_array);
  148. if ($result === true) {
  149. $this->log(lang('ds_config') . lang('ds_promotion_mansong') . lang('mansong_price'));
  150. dsLayerOpenSuccess(lang('setting_save_success'));
  151. } else {
  152. $this->error(lang('setting_save_fail'));
  153. }
  154. }
  155. }
  156. /**
  157. * 页面内导航菜单
  158. *
  159. * @param string $menu_key 当前导航的menu_key
  160. * @param array $array 附加菜单
  161. * @return
  162. */
  163. protected function getAdminItemList()
  164. {
  165. $menu_array = array(
  166. array(
  167. 'name' => 'index',
  168. 'text' => lang('mansong_list'),
  169. 'url' => (string)url('Promotionmansong/index')
  170. ), array(
  171. 'name' => 'mansong_quota',
  172. 'text' => lang('mansong_quota'),
  173. 'url' => (string)url('Promotionmansong/mansong_quota')
  174. ), array(
  175. 'name' => 'mansong_setting',
  176. 'text' => lang('mansong_setting'),
  177. 'url' => "javascript:dsLayerOpen('" . (string)url('Promotionmansong/mansong_setting') . "','" . lang('mansong_setting') . "')"
  178. ),
  179. );
  180. if (request()->action() == 'mansong_detail') {
  181. $menu_array[] = array(
  182. 'name' => 'mansong_detail', 'text' => lang('mansong_detail'),
  183. 'url' => (string)url('Promotionmansong/mansong_detail')
  184. );
  185. }
  186. return $menu_array;
  187. }
  188. }