Sellergoodsoffline.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Sellergoodsoffline extends BaseSeller {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellergoodsadd.lang.php');
  20. $this->template_dir = 'default/seller/sellergoodsadd/';
  21. }
  22. public function index() {
  23. $this->goods_storage();
  24. }
  25. /**
  26. * 仓库中的商品列表
  27. */
  28. public function goods_storage() {
  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. $commonid = input('param.commonid');
  109. if (!preg_match('/^[\d,]+$/i', $commonid)) {
  110. ds_json_encode(10001, lang('param_error'));
  111. }
  112. $commonid_array = explode(',', $commonid);
  113. if ($this->store_info['store_state'] != 1) {
  114. ds_json_encode(10001, lang(lang('store_goods_index_goods_show_fail') . ',店铺正在审核中或已经关闭'));
  115. }
  116. $return = model('goods')->editProducesOnline(array(array('goods_commonid', 'in', $commonid_array), array('store_id', '=', session('store_id'))));
  117. if ($return) {
  118. // 添加操作日志
  119. $this->recordSellerlog('商品上架,平台货号:' . $commonid);
  120. ds_json_encode(10000, lang('store_goods_index_goods_show_success'));
  121. } else {
  122. ds_json_encode(10001, lang('store_goods_index_goods_show_fail'));
  123. }
  124. }
  125. /**
  126. * 栏目菜单
  127. */
  128. function getSellerItemList() {
  129. $item_list = array(
  130. array(
  131. 'name' => 'goods_storage',
  132. 'text' => lang('ds_member_path_goods_storage'),
  133. 'url' => (string) url('Sellergoodsoffline/index'),
  134. ),
  135. array(
  136. 'name' => 'goods_lockup',
  137. 'text' => lang('ds_member_path_goods_state'),
  138. 'url' => (string) url('Sellergoodsoffline/index', ['type' => 'lock_up']),
  139. ),
  140. array(
  141. 'name' => 'goods_verify',
  142. 'text' => lang('ds_member_path_goods_verify'),
  143. 'url' => (string) url('Sellergoodsoffline/index', ['type' => 'wait_verify']),
  144. ),
  145. );
  146. return $item_list;
  147. }
  148. }
  149. ?>