Sellerinfo.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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 Sellerinfo extends BaseSeller {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerinfo.lang.php');
  20. }
  21. /**
  22. * 店铺信息
  23. */
  24. public function index() {
  25. $store_model = model('store');
  26. $storebindclass_model = model('storebindclass');
  27. $storeclass_model = model('storeclass');
  28. $storegrade_model = model('storegrade');
  29. // 店铺信息
  30. $store_info = $store_model->getStoreInfoByID(session('store_id'));
  31. View::assign('store_info', $store_info);
  32. // 店铺分类信息
  33. $store_class_info = $storeclass_model->getStoreclassInfo(array('storeclass_id' => $store_info['storeclass_id']));
  34. View::assign('store_class_name', $store_class_info['storeclass_name']);
  35. // 店铺等级信息
  36. $store_grade_info = $storegrade_model->getOneStoregrade($store_info['grade_id']);
  37. View::assign('store_grade_name', $store_grade_info['storegrade_name']);
  38. $storejoinin_model = model('storejoinin');
  39. $joinin_detail = $storejoinin_model->getOneStorejoinin(array('member_id' => $store_info['member_id']));
  40. View::assign('joinin_detail', $joinin_detail);
  41. $store_bind_class_list = $storebindclass_model->getStorebindclassList(array(
  42. array('store_id', '=', session('store_id')),
  43. array('storebindclass_state', 'in', array(1, 2))
  44. ), null);
  45. $goods_class = model('goodsclass')->getGoodsclassIndexedListAll();
  46. for ($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
  47. $store_bind_class_list[$i]['class_1_name'] = @$goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
  48. $store_bind_class_list[$i]['class_2_name'] = @$goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
  49. $store_bind_class_list[$i]['class_3_name'] = @$goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
  50. }
  51. View::assign('store_bind_class_list', $store_bind_class_list);
  52. $this->setSellerCurMenu('sellerinfo');
  53. $this->setSellerCurItem('index');
  54. return View::fetch($this->template_dir . 'index');
  55. }
  56. /**
  57. * 经营类目列表
  58. */
  59. public function bind_class() {
  60. $storebindclass_model = model('storebindclass');
  61. $store_bind_class_list = $storebindclass_model->getStorebindclassList(array('store_id' => session('store_id')), null);
  62. $goods_class = model('goodsclass')->getGoodsclassIndexedListAll();
  63. for ($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
  64. $store_bind_class_list[$i]['class_1_name'] = @$goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
  65. $store_bind_class_list[$i]['class_2_name'] = @$goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
  66. $store_bind_class_list[$i]['class_3_name'] = @$goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
  67. }
  68. View::assign('bind_list', $store_bind_class_list);
  69. $this->setSellerCurMenu('sellerinfo');
  70. $this->setSellerCurItem('bind_class');
  71. return View::fetch($this->template_dir . 'bind_class_index');
  72. }
  73. /**
  74. * 申请新的经营类目
  75. */
  76. public function bind_class_add() {
  77. $goodsclass_model = model('goodsclass');
  78. $gc_list = $goodsclass_model->getGoodsclassListByParentId(0);
  79. View::assign('gc_list', $gc_list);
  80. $this->setSellerCurMenu('sellerinfo');
  81. $this->setSellerCurItem('bind_class');
  82. return View::fetch($this->template_dir . 'bind_class_add');
  83. }
  84. /**
  85. * 申请新经营类目保存
  86. */
  87. public function bind_class_save() {
  88. if (!request()->isPost())
  89. exit();
  90. $goods_class_array = input('post.goods_class'); #获取数组
  91. if (preg_match('/^[\d,]+$/', $goods_class_array)) {
  92. @list($class_1, $class_2, $class_3) = explode(',', trim($goods_class_array));
  93. } else {
  94. ds_json_encode(10001, lang('ds_common_save_fail'));
  95. }
  96. $storebindclass_model = model('storebindclass');
  97. $param = array();
  98. $param['store_id'] = session('store_id');
  99. $param['storebindclass_state'] = 0;
  100. $param['class_1'] = $class_1;
  101. $last_gc_id = $class_1;
  102. if (!empty($class_2)) {
  103. $param['class_2'] = $class_2;
  104. $last_gc_id = $class_2;
  105. }
  106. if (!empty($class_3)) {
  107. $param['class_3'] = $class_3;
  108. $last_gc_id = $class_3;
  109. }
  110. // 检查类目是否已经存在
  111. $store_bind_class_info = $storebindclass_model->getStorebindclassInfo($param);
  112. if (!empty($store_bind_class_info)) {
  113. ds_json_encode(10001, lang('store_bind_class_exist'));
  114. }
  115. //取分佣比例
  116. $goods_class_info = model('goodsclass')->getGoodsclassInfoById($last_gc_id);
  117. $param['commis_rate'] = $goods_class_info['commis_rate'];
  118. $result = $storebindclass_model->addStorebindclass($param);
  119. if ($result) {
  120. ds_json_encode(10000, lang('apply_success'));
  121. } else {
  122. ds_json_encode(10001, lang('ds_common_save_fail'));
  123. }
  124. }
  125. /**
  126. * 删除申请的经营类目
  127. */
  128. public function bind_class_del() {
  129. $condition = array();
  130. $condition[] = array('storebindclass_id', '=', intval(input('param.bid')));
  131. $condition[] = array('store_id', '=', session('store_id'));
  132. $condition[] = array('storebindclass_state', '=', 0);
  133. $del = model('storebindclass')->delStorebindclass($condition);
  134. if ($del) {
  135. ds_json_encode(10000, lang('ds_common_del_succ'));
  136. } else {
  137. ds_json_encode(10001, lang('ds_common_del_fail'));
  138. }
  139. }
  140. /**
  141. * 店铺续签
  142. */
  143. public function reopen() {
  144. $storereopen_model = model('storereopen');
  145. $reopen_list = $storereopen_model->getStorereopenList(array('storereopen_store_id' => session('store_id')));
  146. View::assign('reopen_list', $reopen_list);
  147. $store_info = $this->store_info;
  148. if (intval($store_info['store_endtime']) > 0) {
  149. $store_info['store_endtime_text'] = date('Y-m-d', $store_info['store_endtime']);
  150. $reopen_time = $store_info['store_endtime'] - 3600 * 24 + 1 - TIMESTAMP;
  151. if (!check_platform_store() && $store_info['store_endtime'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
  152. //(<30天)
  153. $store_info['reopen'] = true;
  154. }
  155. $store_info['allow_applay_date'] = $store_info['store_endtime'] - 2592000;
  156. }
  157. if (!empty($reopen_list)) {
  158. $last = reset($reopen_list);
  159. $store_endtime = $store_info['store_endtime'];
  160. if (!check_platform_store() && $store_endtime - TIMESTAMP < 2592000 && $store_endtime - TIMESTAMP >= 0) {
  161. //(<30天)
  162. $store_info['reopen'] = true;
  163. } else {
  164. $store_info['reopen'] = false;
  165. }
  166. }
  167. View::assign('store_info', $store_info);
  168. //店铺等级
  169. $grade_list = rkcache('storegrade', true);
  170. View::assign('grade_list', $grade_list);
  171. //默认选中当前级别
  172. View::assign('current_grade_id', session('grade_id'));
  173. //如果存在有未上传凭证或审核中的信息,则不能再申请续签
  174. $condition = array();
  175. $condition[] = array('storereopen_state', 'in', array(0, 1));
  176. $condition[] = array('storereopen_store_id', '=', session('store_id'));
  177. $reopen_info = $storereopen_model->getStorereopenInfo($condition);
  178. if ($reopen_info) {
  179. if ($reopen_info['storereopen_state'] == '0') {
  180. View::assign('upload_cert', true);
  181. View::assign('reopen_info', $reopen_info);
  182. }
  183. } else {
  184. View::assign('applay_reopen', isset($store_info['reopen']) ? true : false);
  185. }
  186. $this->setSellerCurMenu('sellerinfo');
  187. $this->setSellerCurItem('reopen');
  188. return View::fetch($this->template_dir . 'reopen_index');
  189. }
  190. /**
  191. * 申请续签
  192. */
  193. public function reopen_add() {
  194. if (request()->isPost()) {
  195. $storereopen_grade_id = intval(input('post.storereopen_grade_id'));
  196. $storereopen_year = intval(input('post.storereopen_year'));
  197. if ($storereopen_grade_id <= 0 || $storereopen_year <= 0)
  198. exit();
  199. // 店铺信息
  200. $store_info = $this->store_info;
  201. if (empty($store_info['store_endtime'])) {
  202. ds_json_encode(10001, lang('store_endtime_no_limit'));
  203. }
  204. $storereopen_model = model('storereopen');
  205. //如果存在有未上传凭证或审核中的信息,则不能再申请续签
  206. $condition = array();
  207. $condition[] = array('storereopen_state', 'in', array(0, 1));
  208. $condition[] = array('storereopen_store_id', '=', session('store_id'));
  209. if ($storereopen_model->getStorereopenCount($condition)) {
  210. ds_json_encode(10001, lang('store_bind_class_repeat'));
  211. }
  212. $data = array();
  213. //取店铺等级信息
  214. $grade_list = rkcache('storegrade', true);
  215. if (empty($grade_list[$storereopen_grade_id])) {
  216. exit();
  217. }
  218. //取得店铺信息
  219. $data['storereopen_grade_id'] = $storereopen_grade_id;
  220. $data['storereopen_grade_name'] = $grade_list[$storereopen_grade_id]['storegrade_name'];
  221. $data['storereopen_grade_price'] = $grade_list[$storereopen_grade_id]['storegrade_price'];
  222. $data['storereopen_store_id'] = session('store_id');
  223. $data['storereopen_store_name'] = session('store_name');
  224. $data['storereopen_year'] = $storereopen_year;
  225. $data['storereopen_pay_amount'] = $data['storereopen_grade_price'] * $data['storereopen_year'];
  226. if ($data['storereopen_pay_amount'] == 0) {
  227. $data['storereopen_state'] = 1;
  228. }
  229. $insert = $storereopen_model->addStorereopen($data);
  230. if ($insert) {
  231. if ($data['storereopen_pay_amount'] == 0) {
  232. ds_json_encode(10000, lang('apply_success'));
  233. } else {
  234. ds_json_encode(10000, lang('ds_common_save_succ') . sprintf(lang('storereopen_pay_amount_notice'), ds_price_format($data['storereopen_pay_amount'])));
  235. }
  236. } else {
  237. ds_json_encode(10001, lang('ds_common_save_fail'));
  238. }
  239. }
  240. }
  241. //上传付款凭证
  242. public function reopen_upload() {
  243. if (!empty($_FILES['storereopen_pay_cert']['tmp_name'])) {
  244. $res = ds_upload_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'store_joinin', 'storereopen_pay_cert');
  245. if ($res['code']) {
  246. $pic_name = $res['data']['file_name'];
  247. } else {
  248. $this->error($res['msg']);
  249. }
  250. }
  251. $data = array();
  252. $data['storereopen_pay_cert'] = $pic_name;
  253. $data['storereopen_pay_cert_explain'] = input('post.storereopen_pay_cert_explain');
  254. $data['storereopen_state'] = 1;
  255. $storereopen_model = model('storereopen');
  256. $update = $storereopen_model->editStorereopen($data, array('storereopen_id' => input('post.storereopen_id'), 'storereopen_state' => 0));
  257. if ($update) {
  258. $this->success(lang('upload_success'));
  259. } else {
  260. $this->error(lang('ds_common_save_fail'));
  261. }
  262. }
  263. /**
  264. * 删除未上传付款凭证的续签信息
  265. */
  266. public function reopen_del() {
  267. $storereopen_model = model('storereopen');
  268. $condition = array();
  269. $condition[] = array('storereopen_id', '=', intval(input('param.storereopen_id')));
  270. $condition[] = array('storereopen_state', '=', 0);
  271. $condition[] = array('storereopen_store_id', '=', session('store_id'));
  272. $del = $storereopen_model->delStorereopen($condition);
  273. if ($del) {
  274. ds_json_encode(10000, lang('ds_common_del_succ'));
  275. } else {
  276. ds_json_encode(10001, lang('ds_common_del_fail'));
  277. }
  278. }
  279. /**
  280. * 用户中心右边,小导航
  281. *
  282. * @param string $menu_type 导航类型
  283. * @param string $name 当前导航的name
  284. * @param array $array 附加菜单
  285. * @return
  286. */
  287. protected function getSellerItemList() {
  288. $menu_array = array();
  289. switch (request()->action()) {
  290. case 'index':
  291. $menu_array [] = array(
  292. 'name' => 'bind_class', 'text' => lang('ds_member_path_bind_class'),
  293. 'url' => (string) url('Sellerinfo/bind_class')
  294. );
  295. $menu_array[] = array(
  296. 'name' => 'index', 'text' => lang('ds_member_path_store_info'),
  297. 'url' => (string) url('Sellerinfo/index')
  298. );
  299. $menu_array[] = array(
  300. 'name' => 'reopen', 'text' => lang('ds_member_path_store_reopen'),
  301. 'url' => (string) url('Sellerinfo/reopen')
  302. );
  303. break;
  304. case 'bind_class':
  305. $menu_array [] = array(
  306. 'name' => 'bind_class', 'text' => lang('ds_member_path_bind_class'),
  307. 'url' => (string) url('Sellerinfo/bind_class')
  308. );
  309. if (!check_platform_store()) {
  310. $menu_array[] = array(
  311. 'name' => 'index', 'text' => lang('ds_member_path_store_info'),
  312. 'url' => (string) url('Sellerinfo/index')
  313. );
  314. $menu_array[] = array(
  315. 'name' => 'reopen', 'text' => lang('ds_member_path_store_reopen'),
  316. 'url' => (string) url('Sellerinfo/reopen')
  317. );
  318. }
  319. break;
  320. case 'reopen':
  321. $menu_array = array(
  322. array(
  323. 'name' => 'index', 'text' => lang('ds_member_path_bind_class'),
  324. 'url' => (string) url('Sellerinfo/bind_class')
  325. ), array(
  326. 'name' => 'index', 'text' => lang('ds_member_path_store_info'),
  327. 'url' => (string) url('Sellerinfo/index')
  328. ), array(
  329. 'name' => 'reopen', 'text' => lang('ds_member_path_store_reopen'),
  330. 'url' => (string) url('Sellerinfo/reopen')
  331. )
  332. );
  333. break;
  334. }
  335. if (!empty($array)) {
  336. $menu_array[] = $array;
  337. }
  338. return $menu_array;
  339. }
  340. }