Promotionwholesale.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 Promotionwholesale extends AdminControl
  21. {
  22. public function initialize()
  23. {
  24. parent::initialize();
  25. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/promotionwholesale.lang.php');
  26. }
  27. /**
  28. * 活动列表
  29. **/
  30. public function index()
  31. {
  32. //自动开启批发
  33. if (intval(input('param.promotion_allow')) === 1) {
  34. $config_model = model('config');
  35. $update_array = array();
  36. $update_array['promotion_allow'] = 1;
  37. $config_model->editConfig($update_array);
  38. }
  39. $wholesale_model = model('wholesale');
  40. $condition = array();
  41. if (!empty(input('param.goods_name'))) {
  42. $condition[]=array('goods_name','like', '%' . input('param.goods_name') . '%');
  43. }
  44. if (!empty(input('param.store_name'))) {
  45. $condition[]=array('store_name','like', '%' . input('param.store_name') . '%');
  46. }
  47. if (!empty(input('param.state'))) {
  48. $condition[]=array('wholesale_state','=',intval(input('param.state')));
  49. }
  50. $wholesale_list = $wholesale_model->getWholesaleList($condition, 10, 'wholesale_state desc, wholesale_end_time desc');
  51. View::assign('wholesale_list', $wholesale_list);
  52. View::assign('show_page', $wholesale_model->page_info->render());
  53. View::assign('wholesale_state_array', $wholesale_model->getWholesaleStateArray());
  54. $this->setAdminCurItem('wholesale_list');
  55. // 输出自营店铺IDS
  56. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  57. View::assign('flippedOwnShopIds', array_flip(model('store')->getOwnShopIds()));
  58. return View::fetch();
  59. }
  60. /**
  61. * 批发活动取消
  62. **/
  63. public function wholesale_cancel()
  64. {
  65. $wholesale_id = intval(input('param.wholesale_id'));
  66. $wholesale_model = model('wholesale');
  67. $result = $wholesale_model->cancelWholesale(array('wholesale_id' => $wholesale_id));
  68. if ($result) {
  69. $this->log(lang('ds_cancel').lang('ds_promotion_wholesale').'ID:' . $wholesale_id);
  70. ds_json_encode(10000, lang('ds_common_op_succ'));
  71. }
  72. else {
  73. ds_json_encode(10001, lang('ds_common_op_fail'));
  74. }
  75. }
  76. /**
  77. * 批发活动删除
  78. **/
  79. public function wholesale_del()
  80. {
  81. $wholesale_model = model('wholesale');
  82. $wholesale_id = input('param.wholesale_id');
  83. $wholesale_id_array = ds_delete_param($wholesale_id);
  84. if($wholesale_id_array === FALSE){
  85. ds_json_encode(10001, lang('param_error'));
  86. }
  87. $condition = array(array('wholesale_id' ,'in', $wholesale_id_array));
  88. $result = $wholesale_model->delWholesale($condition);
  89. if ($result) {
  90. $this->log(lang('ds_del').lang('ds_promotion_wholesale').'ID:' . $wholesale_id);
  91. ds_json_encode(10000, lang('ds_common_op_succ'));
  92. }
  93. else {
  94. ds_json_encode(10001, lang('ds_common_op_fail'));
  95. }
  96. }
  97. /**
  98. * 活动详细信息
  99. **/
  100. public function wholesale_detail()
  101. {
  102. $wholesale_id = intval(input('param.wholesale_id'));
  103. $wholesale_model = model('wholesale');
  104. $wholesalegoods_model = model('wholesalegoods');
  105. $wholesale_info = $wholesale_model->getWholesaleInfoByID($wholesale_id);
  106. if (empty($wholesale_info)) {
  107. $this->error(lang('param_error'));
  108. }
  109. View::assign('wholesale_info', $wholesale_info);
  110. //获取批发商品列表
  111. $condition = array();
  112. $condition[] = array('wholesale_id','=',$wholesale_id);
  113. $wholesalegoods_list = $wholesalegoods_model->getWholesalegoodsExtendList($condition,5);
  114. View::assign('wholesalegoods_list', $wholesalegoods_list);
  115. View::assign('show_page',$wholesalegoods_model->page_info->render());
  116. return View::fetch();
  117. }
  118. /**
  119. * 套餐管理
  120. **/
  121. public function wholesale_quota()
  122. {
  123. $wholesalequota_model = model('wholesalequota');
  124. $condition = array();
  125. $condition[]=array('store_name','like', '%' . input('param.store_name') . '%');
  126. $wholesalequota_list = $wholesalequota_model->getWholesalequotaList($condition, 10, 'wholesalequota_endtime desc');
  127. View::assign('wholesalequota_list', $wholesalequota_list);
  128. View::assign('show_page', $wholesalequota_model->page_info->render());
  129. $this->setAdminCurItem('wholesale_quota');
  130. return View::fetch();
  131. }
  132. /**
  133. * 设置
  134. **/
  135. public function wholesale_setting() {
  136. if (!(request()->isPost())) {
  137. $setting = rkcache('config', true);
  138. View::assign('setting', $setting);
  139. return View::fetch();
  140. } else {
  141. $promotion_wholesale_price = intval(input('post.promotion_wholesale_price'));
  142. if ($promotion_wholesale_price < 0) {
  143. $this->error(lang('param_error'));
  144. }
  145. $config_model = model('config');
  146. $update_array = array();
  147. $update_array['promotion_wholesale_price'] = $promotion_wholesale_price;
  148. $result = $config_model->editConfig($update_array);
  149. if ($result) {
  150. $this->log('修改批发价格为' . $promotion_wholesale_price . '元');
  151. dsLayerOpenSuccess(lang('setting_save_success'));
  152. } else {
  153. $this->error(lang('setting_save_fail'));
  154. }
  155. }
  156. }
  157. /**
  158. * ajax修改抢购信息
  159. */
  160. public function ajax()
  161. {
  162. $result = true;
  163. $update_array = array();
  164. $condition = array();
  165. switch (input('param.branch')) {
  166. case 'recommend':
  167. $wholesalegoods_model = model('wholesalegoods');
  168. $update_array['wholesalegoods_recommend'] = input('param.value');
  169. $condition[] = array('wholesalegoods_id','=',input('param.id'));
  170. $result = $wholesalegoods_model->editWholesalegoods($update_array, $condition);
  171. break;
  172. }
  173. if ($result) {
  174. echo 'true';
  175. exit;
  176. }
  177. else {
  178. echo 'false';
  179. exit;
  180. }
  181. }
  182. /*
  183. * 发送消息
  184. */
  185. private function send_message($member_id, $member_name, $message)
  186. {
  187. $param = array();
  188. $param['from_member_id'] = 0;
  189. $param['member_id'] = $member_id;
  190. $param['to_member_name'] = $member_name;
  191. $param['message_type'] = '1';//表示为系统消息
  192. $param['msg_content'] = $message;
  193. $message_model = model('message');
  194. return $message_model->addMessage($param);
  195. }
  196. /**
  197. * 页面内导航菜单
  198. *
  199. * @param string $menu_key 当前导航的menu_key
  200. * @param array $array 附加菜单
  201. * @return
  202. */
  203. protected function getAdminItemList()
  204. {
  205. $menu_array = array(
  206. array(
  207. 'name' => 'wholesale_list', 'text' => lang('wholesale_list'), 'url' => (string)url('Promotionwholesale/index')
  208. ), array(
  209. 'name' => 'wholesale_quota', 'text' => lang('wholesale_quota'),
  210. 'url' => (string)url('Promotionwholesale/wholesale_quota')
  211. ), array(
  212. 'name' => 'wholesale_setting',
  213. 'text' => lang('wholesale_setting'),
  214. 'url' => "javascript:dsLayerOpen('".(string)url('Promotionwholesale/wholesale_setting')."','".lang('wholesale_setting')."')"
  215. ),
  216. );
  217. if (request()->action() == 'wholesale_detail')
  218. $menu_array[] = array(
  219. 'name' => 'wholesale_detail', 'text' => lang('wholesale_detail'),
  220. 'url' => (string)url('Promotionwholesale/wholesale_detail')
  221. );
  222. return $menu_array;
  223. }
  224. }