Sellergoodsoffline.php 6.1 KB

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