Promotionpintuan.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /**
  3. * 拼团管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 控制器
  14. */
  15. class Promotionpintuan extends AdminControl
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize();
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/promotionpintuan.lang.php');
  21. }
  22. /**
  23. * 拼团列表
  24. */
  25. public function index()
  26. {
  27. $pintuan_model = model('ppintuan');
  28. $condition = array();
  29. if (!empty(input('param.pintuan_name'))) {
  30. $condition[] = array('pintuan_name', 'like', '%' . input('param.pintuan_name') . '%');
  31. }
  32. if (!empty(input('param.store_name'))) {
  33. $condition[] = array('store_name', 'like', '%' . input('param.store_name') . '%');
  34. }
  35. if (input('param.state') != '') {
  36. $condition[] = array('pintuan_state', '=', intval(input('param.state')));
  37. }
  38. $pintuan_list = $pintuan_model->getPintuanList($condition, 10, 'pintuan_state desc, pintuan_end_time desc');
  39. View::assign('pintuan_list', $pintuan_list);
  40. View::assign('show_page', $pintuan_model->page_info->render());
  41. View::assign('pintuan_state_array', $pintuan_model->getPintuanStateArray());
  42. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  43. $this->setAdminCurItem('pintuan_list');
  44. return View::fetch();
  45. }
  46. /**
  47. * 拼团详情
  48. */
  49. public function pintuan_manage()
  50. {
  51. $ppintuangroup_model = model('ppintuangroup');
  52. $ppintuanorder_model = model('ppintuanorder');
  53. $pintuan_id = intval(input('param.pintuan_id'));
  54. $condition = array();
  55. $condition[] = array('pintuan_id', '=', $pintuan_id);
  56. if (input('param.pintuangroup_state')) {
  57. $condition[] = array('pintuangroup_state', '=', intval(input('param.pintuangroup_state')));
  58. }
  59. $ppintuangroup_list = $ppintuangroup_model->getPpintuangroupList($condition, 10); #获取开团信息
  60. foreach ($ppintuangroup_list as $key => $ppintuangroup) {
  61. //获取开团订单下的参团订单
  62. $condition = array();
  63. $condition[] = array('pintuangroup_id', '=', $ppintuangroup['pintuangroup_id']);
  64. if ($ppintuangroup['pintuangroup_is_virtual']) {
  65. $ppintuangroup_list[$key]['order_list'] = $ppintuanorder_model->getPpintuanvrorderList($condition);
  66. } else {
  67. $ppintuangroup_list[$key]['order_list'] = $ppintuanorder_model->getPpintuanorderList($condition);
  68. }
  69. }
  70. $ppintuan_info = model('ppintuan')->getPintuanInfo(['pintuan_id' => $pintuan_id]);
  71. View::assign('pintuan_info', $ppintuan_info);
  72. View::assign('show_page', $ppintuangroup_model->page_info->render());
  73. View::assign('pintuangroup_list', $ppintuangroup_list);
  74. View::assign('pintuangroup_state_array', $ppintuangroup_model->getPintuangroupStateArray());
  75. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  76. $this->setAdminCurItem('pintuan_manage');
  77. return View::fetch();
  78. }
  79. /**
  80. * 拼团活动 提前结束
  81. */
  82. public function pintuan_end()
  83. {
  84. $pintuan_id = intval(input('param.pintuan_id'));
  85. $ppintuan_model = model('ppintuan');
  86. $pintuan_info = $ppintuan_model->getPintuanInfoByID($pintuan_id);
  87. if (!$pintuan_info) {
  88. ds_json_encode(10001, lang('param_error'));
  89. }
  90. /**
  91. * 指定拼团活动结束
  92. */
  93. $result = $ppintuan_model->endPintuan(array('pintuan_id' => $pintuan_id));
  94. if ($result) {
  95. $this->log('拼团活动提前结束,活动名称:' . $pintuan_info['pintuan_name'] . '活动编号:' . $pintuan_id, 1);
  96. ds_json_encode(10000, lang('ds_common_op_succ'));
  97. } else {
  98. ds_json_encode(10001, lang('ds_common_op_fail'));
  99. }
  100. }
  101. /**
  102. * 拼团活动 删除
  103. */
  104. public function pintuan_del()
  105. {
  106. $pintuan_id = intval(input('param.pintuan_id'));
  107. $ppintuan_model = model('ppintuan');
  108. $pintuan_info = $ppintuan_model->getPintuanInfoByID($pintuan_id);
  109. if (!$pintuan_info) {
  110. ds_json_encode(10001, lang('param_error'));
  111. }
  112. /**
  113. * 指定拼团活动删除
  114. */
  115. $result = $ppintuan_model->delPintuan(array('pintuan_id' => $pintuan_id));
  116. if ($result) {
  117. $this->log('拼团活动删除,活动名称:' . $pintuan_info['pintuan_name'] . '活动编号:' . $pintuan_id, 1);
  118. ds_json_encode(10000, lang('ds_common_op_succ'));
  119. } else {
  120. ds_json_encode(10001, lang('ds_common_op_fail'));
  121. }
  122. }
  123. /**
  124. * 拼团套餐管理
  125. */
  126. public function pintuan_quota()
  127. {
  128. $pintuanquota_model = model('ppintuanquota');
  129. $condition = array();
  130. $condition[] = array('store_name', 'like', '%' . input('param.store_name') . '%');
  131. $pintuanquota_list = $pintuanquota_model->getPintuanquotaList($condition, 10, 'pintuanquota_endtime desc');
  132. View::assign('pintuanquota_list', $pintuanquota_list);
  133. View::assign('show_page', $pintuanquota_model->page_info->render());
  134. $this->setAdminCurItem('pintuan_quota');
  135. return View::fetch();
  136. }
  137. /**
  138. * 拼团设置
  139. */
  140. public function pintuan_setting()
  141. {
  142. if (!(request()->isPost())) {
  143. $setting = rkcache('config', true);
  144. View::assign('setting', $setting);
  145. return View::fetch();
  146. } else {
  147. $promotion_pintuan_price = intval(input('post.promotion_pintuan_price'));
  148. if ($promotion_pintuan_price < 0) {
  149. $this->error(lang('param_error'));
  150. }
  151. $config_model = model('config');
  152. $update_array = array();
  153. $update_array['promotion_pintuan_price'] = $promotion_pintuan_price;
  154. $result = $config_model->editConfig($update_array);
  155. if ($result) {
  156. $this->log('修改拼团套餐价格为' . $promotion_pintuan_price . '元');
  157. dsLayerOpenSuccess(lang('setting_save_success'));
  158. } else {
  159. $this->error(lang('setting_save_fail'));
  160. }
  161. }
  162. }
  163. protected function getAdminItemList()
  164. {
  165. $menu_array = array(
  166. array(
  167. 'name' => 'pintuan_list', 'text' => lang('pintuan_list'), 'url' => (string)url('Promotionpintuan/index')
  168. ), array(
  169. 'name' => 'pintuan_quota', 'text' => lang('pintuan_quota'),
  170. 'url' => (string)url('Promotionpintuan/pintuan_quota')
  171. ), array(
  172. 'name' => 'pintuan_setting',
  173. 'text' => lang('pintuan_setting'),
  174. 'url' => "javascript:dsLayerOpen('" . (string)url('Promotionpintuan/pintuan_setting') . "','" . lang('pintuan_setting') . "')"
  175. ),
  176. );
  177. if (request()->action() == 'pintuan_detail') {
  178. $menu_array[] = array(
  179. 'name' => 'pintuan_detail', 'text' => lang('pintuan_detail'),
  180. 'url' => (string)url('Promotionpintuan/pintuan_detail')
  181. );
  182. }
  183. return $menu_array;
  184. }
  185. }