Promotionwholesale.php 8.6 KB

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