Promotionmansong.php 7.3 KB

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