Promotionmansong.php 7.5 KB

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