Promotionpintuan.php 7.9 KB

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