Sellergoodsoffline.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Sellergoodsoffline extends BaseSeller
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize();
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellergoodsadd.lang.php');
  18. $this->template_dir = 'default/seller/sellergoodsadd/';
  19. }
  20. public function index()
  21. {
  22. $this->goods_storage();
  23. }
  24. /**
  25. * 仓库中的商品列表
  26. */
  27. public function goods_storage()
  28. {
  29. $goods_model = model('goods');
  30. $where = array();
  31. $where[] = array('store_id', '=', session('store_id'));
  32. $storegc_id = intval(input('get.storegc_id'));
  33. if ($storegc_id > 0) {
  34. $where[] = array('goods_stcids', 'like', '%,' . $storegc_id . ',%');
  35. }
  36. $keyword = input('get.keyword');
  37. $search_type = input('get.search_type');
  38. if (trim($keyword) != '') {
  39. switch ($search_type) {
  40. case 0:
  41. $where[] = array('goods_name', 'like', '%' . trim($keyword) . '%');
  42. break;
  43. case 1:
  44. $where[] = array('goods_serial', 'like', '%' . trim($keyword) . '%');
  45. break;
  46. case 2:
  47. $where[] = array('goods_commonid', '=', intval($keyword));
  48. break;
  49. }
  50. }
  51. $type = input('param.type');
  52. $verify = input('get.verify');
  53. switch ($type) {
  54. // 违规的商品
  55. case 'lock_up':
  56. /* 设置卖家当前菜单 */
  57. $this->setSellerCurMenu('sellergoodsoffline');
  58. $this->setSellerCurItem('goods_lockup');
  59. $goods_list = $goods_model->getGoodsCommonLockUpList($where);
  60. break;
  61. // 等待审核或审核失败的商品
  62. case 'wait_verify':
  63. /* 设置卖家当前菜单 */
  64. $this->setSellerCurMenu('sellergoodsoffline');
  65. $this->setSellerCurItem('goods_verify');
  66. if (isset($verify) && in_array($verify, array('0', '10'))) {
  67. $where[] = array('goods_verify', '=', $verify);
  68. }
  69. $goods_list = $goods_model->getGoodsCommonWaitVerifyList($where);
  70. break;
  71. // 仓库中的商品
  72. default:
  73. /* 设置卖家当前菜单 */
  74. $this->setSellerCurMenu('sellergoodsoffline');
  75. $this->setSellerCurItem('goods_storage');
  76. $goods_list = $goods_model->getGoodsCommonOfflineList($where);
  77. break;
  78. }
  79. View::assign('show_page', $goods_model->page_info->render());
  80. View::assign('goods_list', $goods_list);
  81. // 计算库存
  82. $storage_array = $goods_model->calculateStorage($goods_list);
  83. View::assign('storage_array', $storage_array);
  84. // 商品分类
  85. $store_goods_class = model('storegoodsclass')->getClassTree(array('store_id' => session('store_id'), 'storegc_state' => '1'));
  86. View::assign('store_goods_class', $store_goods_class);
  87. switch ($type) {
  88. // 违规的商品
  89. case 'lock_up':
  90. echo View::fetch($this->template_dir . 'store_goods_list_offline_lockup');
  91. break;
  92. // 等待审核或审核失败的商品
  93. case 'wait_verify':
  94. View::assign('verify', array('0' => lang('wait_verify_0'), '10' => lang('wait_verify_10')));
  95. echo View::fetch($this->template_dir . 'store_goods_list_offline_waitverify');
  96. break;
  97. // 仓库中的商品
  98. default:
  99. echo View::fetch($this->template_dir . 'store_goods_list_offline');
  100. break;
  101. }
  102. exit;
  103. }
  104. /**
  105. * 商品上架
  106. */
  107. public function goods_show()
  108. {
  109. $commonid = input('param.commonid');
  110. if (!preg_match('/^[\d,]+$/i', $commonid)) {
  111. ds_json_encode(10001, lang('param_error'));
  112. }
  113. $commonid_array = explode(',', $commonid);
  114. if ($this->store_info['store_state'] != 1) {
  115. ds_json_encode(10001, lang(lang('store_goods_index_goods_show_fail') . ',店铺正在审核中或已经关闭'));
  116. }
  117. $return = model('goods')->editProducesOnline(array(array('goods_commonid', 'in', $commonid_array), array('store_id', '=', session('store_id'))));
  118. if ($return) {
  119. // 添加操作日志
  120. $this->recordSellerlog('商品上架,平台货号:' . $commonid);
  121. ds_json_encode(10000, lang('store_goods_index_goods_show_success'));
  122. } else {
  123. ds_json_encode(10001, lang('store_goods_index_goods_show_fail'));
  124. }
  125. }
  126. /**
  127. * 栏目菜单
  128. */
  129. function getSellerItemList()
  130. {
  131. $item_list = array(
  132. array(
  133. 'name' => 'goods_storage',
  134. 'text' => lang('ds_member_path_goods_storage'),
  135. 'url' => (string) url('Sellergoodsoffline/index'),
  136. ),
  137. array(
  138. 'name' => 'goods_lockup',
  139. 'text' => lang('ds_member_path_goods_state'),
  140. 'url' => (string) url('Sellergoodsoffline/index', ['type' => 'lock_up']),
  141. ),
  142. array(
  143. 'name' => 'goods_verify',
  144. 'text' => lang('ds_member_path_goods_verify'),
  145. 'url' => (string) url('Sellergoodsoffline/index', ['type' => 'wait_verify']),
  146. ),
  147. );
  148. return $item_list;
  149. }
  150. }