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