Sellerinfo.php 16 KB

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