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