Promotionpintuan.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /**
  3. * 拼团管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. * ============================================================================
  10. * DSMall多用户商城
  11. * ============================================================================
  12. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  13. * 网站地址: http://www.csdeshang.com
  14. * ----------------------------------------------------------------------------
  15. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  16. * 不允许对程序代码以任何形式任何目的的再发布。
  17. * ============================================================================
  18. * 控制器
  19. */
  20. class Promotionpintuan extends AdminControl
  21. {
  22. public function initialize()
  23. {
  24. parent::initialize();
  25. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/promotionpintuan.lang.php');
  26. }
  27. /**
  28. * 拼团列表
  29. */
  30. public function index()
  31. {
  32. $pintuan_model = model('ppintuan');
  33. $condition = array();
  34. if (!empty(input('param.pintuan_name'))) {
  35. $condition[]=array('pintuan_name','like', '%' . input('param.pintuan_name') . '%');
  36. }
  37. if (!empty(input('param.store_name'))) {
  38. $condition[]=array('store_name','like', '%' . input('param.store_name') . '%');
  39. }
  40. if (input('param.state') != '') {
  41. $condition[]=array('pintuan_state','=',intval(input('param.state')));
  42. }
  43. $pintuan_list = $pintuan_model->getPintuanList($condition, 10, 'pintuan_state desc, pintuan_end_time desc');
  44. View::assign('pintuan_list', $pintuan_list);
  45. View::assign('show_page', $pintuan_model->page_info->render());
  46. View::assign('pintuan_state_array', $pintuan_model->getPintuanStateArray());
  47. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  48. $this->setAdminCurItem('pintuan_list');
  49. return View::fetch();
  50. }
  51. /**
  52. * 拼团详情
  53. */
  54. public function pintuan_manage()
  55. {
  56. $ppintuangroup_model = model('ppintuangroup');
  57. $ppintuanorder_model = model('ppintuanorder');
  58. $pintuan_id = intval(input('param.pintuan_id'));
  59. $condition = array();
  60. $condition[] = array('pintuan_id','=',$pintuan_id);
  61. if (input('param.pintuangroup_state')){
  62. $condition[] = array('pintuangroup_state','=',intval(input('param.pintuangroup_state')));
  63. }
  64. $ppintuangroup_list = $ppintuangroup_model->getPpintuangroupList($condition, 10); #获取开团信息
  65. foreach ($ppintuangroup_list as $key => $ppintuangroup) {
  66. //获取开团订单下的参团订单
  67. $condition = array();
  68. $condition[] = array('pintuangroup_id','=',$ppintuangroup['pintuangroup_id']);
  69. if($ppintuangroup['pintuangroup_is_virtual']){
  70. $ppintuangroup_list[$key]['order_list'] = $ppintuanorder_model->getPpintuanvrorderList($condition);
  71. }else{
  72. $ppintuangroup_list[$key]['order_list'] = $ppintuanorder_model->getPpintuanorderList($condition);
  73. }
  74. }
  75. $ppintuan_info = model('ppintuan')->getPintuanInfo(['pintuan_id'=>$pintuan_id]);
  76. View::assign('pintuan_info', $ppintuan_info);
  77. View::assign('show_page', $ppintuangroup_model->page_info->render());
  78. View::assign('pintuangroup_list', $ppintuangroup_list);
  79. View::assign('pintuangroup_state_array', $ppintuangroup_model->getPintuangroupStateArray());
  80. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  81. $this->setAdminCurItem('pintuan_manage');
  82. return View::fetch();
  83. }
  84. /**
  85. * 拼团活动 提前结束
  86. */
  87. public function pintuan_end() {
  88. $pintuan_id = intval(input('param.pintuan_id'));
  89. $ppintuan_model = model('ppintuan');
  90. $pintuan_info = $ppintuan_model->getPintuanInfoByID($pintuan_id);
  91. if (!$pintuan_info) {
  92. ds_json_encode(10001, lang('param_error'));
  93. }
  94. /**
  95. * 指定拼团活动结束
  96. */
  97. $result = $ppintuan_model->endPintuan(array('pintuan_id' => $pintuan_id));
  98. if ($result) {
  99. $this->log('拼团活动提前结束,活动名称:' . $pintuan_info['pintuan_name'] . '活动编号:' . $pintuan_id, 1);
  100. ds_json_encode(10000, lang('ds_common_op_succ'));
  101. } else {
  102. ds_json_encode(10001, lang('ds_common_op_fail'));
  103. }
  104. }
  105. /**
  106. * 拼团套餐管理
  107. */
  108. public function pintuan_quota()
  109. {
  110. $pintuanquota_model = model('ppintuanquota');
  111. $condition = array();
  112. $condition[]=array('store_name','like', '%' . input('param.store_name') . '%');
  113. $pintuanquota_list = $pintuanquota_model->getPintuanquotaList($condition, 10, 'pintuanquota_endtime desc');
  114. View::assign('pintuanquota_list', $pintuanquota_list);
  115. View::assign('show_page', $pintuanquota_model->page_info->render());
  116. $this->setAdminCurItem('pintuan_quota');
  117. return View::fetch();
  118. }
  119. /**
  120. * 拼团设置
  121. */
  122. public function pintuan_setting() {
  123. if (!(request()->isPost())) {
  124. $setting = rkcache('config', true);
  125. View::assign('setting', $setting);
  126. return View::fetch();
  127. } else {
  128. $promotion_pintuan_price = intval(input('post.promotion_pintuan_price'));
  129. if ($promotion_pintuan_price < 0) {
  130. $this->error(lang('param_error'));
  131. }
  132. $config_model = model('config');
  133. $update_array = array();
  134. $update_array['promotion_pintuan_price'] = $promotion_pintuan_price;
  135. $result = $config_model->editConfig($update_array);
  136. if ($result) {
  137. $this->log('修改拼团套餐价格为' . $promotion_pintuan_price . '元');
  138. dsLayerOpenSuccess(lang('setting_save_success'));
  139. } else {
  140. $this->error(lang('setting_save_fail'));
  141. }
  142. }
  143. }
  144. protected function getAdminItemList()
  145. {
  146. $menu_array = array(
  147. array(
  148. 'name' => 'pintuan_list', 'text' => lang('pintuan_list'), 'url' => (string)url('Promotionpintuan/index')
  149. ), array(
  150. 'name' => 'pintuan_quota', 'text' => lang('pintuan_quota'),
  151. 'url' => (string)url('Promotionpintuan/pintuan_quota')
  152. ), array(
  153. 'name' => 'pintuan_setting',
  154. 'text' => lang('pintuan_setting'),
  155. 'url' => "javascript:dsLayerOpen('".(string)url('Promotionpintuan/pintuan_setting')."','".lang('pintuan_setting')."')"
  156. ),
  157. );
  158. if (request()->action() == 'pintuan_detail'){
  159. $menu_array[] = array(
  160. 'name' => 'pintuan_detail', 'text' => lang('pintuan_detail'),
  161. 'url' => (string)url('Promotionpintuan/pintuan_detail')
  162. );
  163. }
  164. return $menu_array;
  165. }
  166. }