Promotionpintuan.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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_del() {
  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. if (!(request()->isPost())) {
  145. $setting = rkcache('config', true);
  146. View::assign('setting', $setting);
  147. return View::fetch();
  148. } else {
  149. $promotion_pintuan_price = intval(input('post.promotion_pintuan_price'));
  150. if ($promotion_pintuan_price < 0) {
  151. $this->error(lang('param_error'));
  152. }
  153. $config_model = model('config');
  154. $update_array = array();
  155. $update_array['promotion_pintuan_price'] = $promotion_pintuan_price;
  156. $result = $config_model->editConfig($update_array);
  157. if ($result) {
  158. $this->log('修改拼团套餐价格为' . $promotion_pintuan_price . '元');
  159. dsLayerOpenSuccess(lang('setting_save_success'));
  160. } else {
  161. $this->error(lang('setting_save_fail'));
  162. }
  163. }
  164. }
  165. protected function getAdminItemList()
  166. {
  167. $menu_array = array(
  168. array(
  169. 'name' => 'pintuan_list', 'text' => lang('pintuan_list'), 'url' => (string)url('Promotionpintuan/index')
  170. ), array(
  171. 'name' => 'pintuan_quota', 'text' => lang('pintuan_quota'),
  172. 'url' => (string)url('Promotionpintuan/pintuan_quota')
  173. ), array(
  174. 'name' => 'pintuan_setting',
  175. 'text' => lang('pintuan_setting'),
  176. 'url' => "javascript:dsLayerOpen('".(string)url('Promotionpintuan/pintuan_setting')."','".lang('pintuan_setting')."')"
  177. ),
  178. );
  179. if (request()->action() == 'pintuan_detail'){
  180. $menu_array[] = array(
  181. 'name' => 'pintuan_detail', 'text' => lang('pintuan_detail'),
  182. 'url' => (string)url('Promotionpintuan/pintuan_detail')
  183. );
  184. }
  185. return $menu_array;
  186. }
  187. }