store.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. <?php
  2. /**
  3. * 店铺管理界面
  4. *
  5. **by 好商城V3 www.33hao.com 运营版*/
  6. defined('InShopNC') or exit('Access Invalid!');
  7. class storeControl extends SystemControl{
  8. const EXPORT_SIZE = 1000;
  9. public function __construct(){
  10. parent::__construct();
  11. Language::read('store,store_grade');
  12. }
  13. /**
  14. * 店铺
  15. */
  16. public function storeOp(){
  17. $lang = Language::getLangContent();
  18. $model_store = Model('store');
  19. if(trim($_GET['owner_and_name']) != ''){
  20. $condition['member_name'] = array('like', '%'.$_GET['owner_and_name'].'%');
  21. Tpl::output('owner_and_name',$_GET['owner_and_name']);
  22. }
  23. if(trim($_GET['store_name']) != ''){
  24. $condition['store_name'] = array('like', '%'.trim($_GET['store_name']).'%');
  25. Tpl::output('store_name',$_GET['store_name']);
  26. }
  27. if(intval($_GET['grade_id']) > 0){
  28. $condition['grade_id'] = intval($_GET['grade_id']);
  29. Tpl::output('grade_id',intval($_GET['grade_id']));
  30. }
  31. switch ($_GET['store_type']) {
  32. case 'close':
  33. $condition['store_state'] = 0;
  34. break;
  35. case 'open':
  36. $condition['store_state'] = 1;
  37. break;
  38. case 'expired':
  39. $condition['store_end_time'] = array('between', array(1, time()));
  40. $condition['store_state'] = 1;
  41. break;
  42. case 'expire':
  43. $condition['store_end_time'] = array('between', array(time(), time() + 864000));
  44. $condition['store_state'] = 1;
  45. break;
  46. }
  47. // 默认店铺管理不包含自营店铺
  48. $condition['is_own_shop'] = 0;
  49. //店铺列表
  50. $store_list = $model_store->getStoreList($condition, 10,'store_id desc');
  51. //店铺等级
  52. $model_grade = Model('store_grade');
  53. $grade_list = $model_grade->getGradeList($condition);
  54. if (!empty($grade_list)){
  55. $search_grade_list = array();
  56. foreach ($grade_list as $k => $v){
  57. $search_grade_list[$v['sg_id']] = $v['sg_name'];
  58. }
  59. }
  60. Tpl::output('search_grade_list', $search_grade_list);
  61. Tpl::output('grade_list',$grade_list);
  62. Tpl::output('store_list',$store_list);
  63. Tpl::output('store_type', $this->_get_store_type_array());
  64. Tpl::output('page',$model_store->showpage('2'));
  65. Tpl::showpage('store.index');
  66. }
  67. private function _get_store_type_array() {
  68. return array(
  69. 'open' => '开启',
  70. 'close' => '关闭',
  71. 'expire' => '即将到期',
  72. 'expired' => '已到期'
  73. );
  74. }
  75. /**
  76. * 店铺编辑
  77. */
  78. public function store_editOp(){
  79. $lang = Language::getLangContent();
  80. $model_store = Model('store');
  81. //保存
  82. if (chksubmit()){
  83. //取店铺等级的审核
  84. $model_grade = Model('store_grade');
  85. $grade_array = $model_grade->getOneGrade(intval($_POST['grade_id']));
  86. if (empty($grade_array)){
  87. showMessage($lang['please_input_store_level']);
  88. }
  89. //结束时间
  90. $time = '';
  91. if(trim($_POST['end_time']) != ''){
  92. $time = strtotime($_POST['end_time']);
  93. }
  94. $update_array = array();
  95. $update_array['store_name'] = trim($_POST['store_name']);
  96. $update_array['sc_id'] = intval($_POST['sc_id']);
  97. $update_array['grade_id'] = intval($_POST['grade_id']);
  98. $update_array['store_end_time'] = $time;
  99. $update_array['store_state'] = intval($_POST['store_state']);
  100. $update_array['store_baozh'] = trim($_POST['store_baozh']);//保障服务开关
  101. $update_array['store_baozhopen'] = trim($_POST['store_baozhopen']);//保证金显示开关
  102. $update_array['store_baozhrmb'] = trim($_POST['store_baozhrmb']);//新加保证金-金额
  103. $update_array['store_qtian'] = trim($_POST['store_qtian']);//保障服务-七天退换
  104. $update_array['store_zhping'] = trim($_POST['store_zhping']);//保障服务-正品保证
  105. $update_array['store_erxiaoshi'] = trim($_POST['store_erxiaoshi']);//保障服务-两小时发货
  106. $update_array['store_tuihuo'] = trim($_POST['store_tuihuo']);//保障服务-退货承诺
  107. $update_array['store_shiyong'] = trim($_POST['store_shiyong']);//保障服务-试用
  108. $update_array['store_xiaoxie'] = trim($_POST['store_xiaoxie']);//保障服务-消协
  109. $update_array['store_huodaofk'] = trim($_POST['store_huodaofk']);//保障服务-货到付款
  110. $update_array['store_shiti'] = trim($_POST['store_shiti']);//保障服务-实体店铺
  111. if ($update_array['store_state'] == 0){
  112. //根据店铺状态修改该店铺所有商品状态
  113. $model_goods = Model('goods');
  114. $model_goods->editProducesOffline(array('store_id' => $_POST['store_id']));
  115. $update_array['store_close_info'] = trim($_POST['store_close_info']);
  116. $update_array['store_recommend'] = 0;
  117. }else {
  118. //店铺开启后商品不在自动上架,需要手动操作
  119. $update_array['store_close_info'] = '';
  120. $update_array['store_recommend'] = intval($_POST['store_recommend']);
  121. }
  122. $result = $model_store->editStore($update_array, array('store_id' => $_POST['store_id']));
  123. if ($result){
  124. $url = array(
  125. array(
  126. 'url'=>'index.php?act=store&op=store',
  127. 'msg'=>$lang['back_store_list'],
  128. ),
  129. array(
  130. 'url'=>'index.php?act=store&op=store_edit&store_id='.intval($_POST['store_id']),
  131. 'msg'=>$lang['countinue_add_store'],
  132. ),
  133. );
  134. $this->log(L('nc_edit,store').'['.$_POST['store_name'].']',1);
  135. showMessage($lang['nc_common_save_succ'],$url);
  136. }else {
  137. $this->log(L('nc_edit,store').'['.$_POST['store_name'].']',1);
  138. showMessage($lang['nc_common_save_fail']);
  139. }
  140. }
  141. //取店铺信息
  142. $store_array = $model_store->getStoreInfoByID($_GET['store_id']);
  143. if (empty($store_array)){
  144. showMessage($lang['store_no_exist']);
  145. }
  146. //整理店铺内容
  147. $store_array['store_end_time'] = $store_array['store_end_time']?date('Y-m-d',$store_array['store_end_time']):'';
  148. //店铺分类
  149. $model_store_class = Model('store_class');
  150. $parent_list = $model_store_class->getStoreClassList(array(),'',false);
  151. //店铺等级
  152. $model_grade = Model('store_grade');
  153. $grade_list = $model_grade->getGradeList();
  154. Tpl::output('grade_list',$grade_list);
  155. Tpl::output('class_list',$parent_list);
  156. Tpl::output('store_array',$store_array);
  157. $joinin_detail = Model('store_joinin')->getOne(array('member_id'=>$store_array['member_id']));
  158. Tpl::output('joinin_detail', $joinin_detail);
  159. Tpl::showpage('store.edit');
  160. }
  161. /**
  162. * 编辑保存注册信息
  163. */
  164. public function edit_save_joininOp() {
  165. if (chksubmit()) {
  166. $member_id = $_POST['member_id'];
  167. if ($member_id <= 0) {
  168. showMessage(L('param_error'));
  169. }
  170. $param = array();
  171. $param['company_name'] = $_POST['company_name'];
  172. $param['company_province_id'] = intval($_POST['province_id']);
  173. $param['company_address'] = $_POST['company_address'];
  174. $param['company_address_detail'] = $_POST['company_address_detail'];
  175. $param['company_phone'] = $_POST['company_phone'];
  176. $param['company_employee_count'] = intval($_POST['company_employee_count']);
  177. $param['company_registered_capital'] = intval($_POST['company_registered_capital']);
  178. $param['contacts_name'] = $_POST['contacts_name'];
  179. $param['contacts_phone'] = $_POST['contacts_phone'];
  180. $param['contacts_email'] = $_POST['contacts_email'];
  181. $param['business_licence_number'] = $_POST['business_licence_number'];
  182. $param['business_licence_address'] = $_POST['business_licence_address'];
  183. $param['business_licence_start'] = $_POST['business_licence_start'];
  184. $param['business_licence_end'] = $_POST['business_licence_end'];
  185. $param['business_sphere'] = $_POST['business_sphere'];
  186. if ($_FILES['business_licence_number_electronic']['name'] != '') {
  187. $param['business_licence_number_electronic'] = $this->upload_image('business_licence_number_electronic');
  188. }
  189. $param['organization_code'] = $_POST['organization_code'];
  190. if ($_FILES['organization_code_electronic']['name'] != '') {
  191. $param['organization_code_electronic'] = $this->upload_image('organization_code_electronic');
  192. }
  193. if ($_FILES['general_taxpayer']['name'] != '') {
  194. $param['general_taxpayer'] = $this->upload_image('general_taxpayer');
  195. }
  196. $param['bank_account_name'] = $_POST['bank_account_name'];
  197. $param['bank_account_number'] = $_POST['bank_account_number'];
  198. $param['bank_name'] = $_POST['bank_name'];
  199. $param['bank_code'] = $_POST['bank_code'];
  200. $param['bank_address'] = $_POST['bank_address'];
  201. if ($_FILES['bank_licence_electronic']['name'] != '') {
  202. $param['bank_licence_electronic'] = $this->upload_image('bank_licence_electronic');
  203. }
  204. $param['settlement_bank_account_name'] = $_POST['settlement_bank_account_name'];
  205. $param['settlement_bank_account_number'] = $_POST['settlement_bank_account_number'];
  206. $param['settlement_bank_name'] = $_POST['settlement_bank_name'];
  207. $param['settlement_bank_code'] = $_POST['settlement_bank_code'];
  208. $param['settlement_bank_address'] = $_POST['settlement_bank_address'];
  209. $param['tax_registration_certificate'] = $_POST['tax_registration_certificate'];
  210. $param['taxpayer_id'] = $_POST['taxpayer_id'];
  211. if ($_FILES['tax_registration_certificate_electronic']['name'] != '') {
  212. $param['tax_registration_certificate_electronic'] = $this->upload_image('tax_registration_certificate_electronic');
  213. }
  214. $result = Model('store_joinin')->editStoreJoinin(array('member_id' => $member_id), $param);
  215. if ($result) {
  216. //好商城V3-B11 更新店铺信息
  217. $store_update = array();
  218. $store_update['store_company_name']=$param['company_name'];
  219. $store_update['area_info']=$param['company_address'];
  220. $store_update['store_address']=$param['company_address_detail'];
  221. $model_store = Model('store');
  222. $store_info = $model_store->getStoreInfo(array('member_id'=>$member_id));
  223. if(!empty($store_info)) {
  224. $r=$model_store->editStore($store_update, array('member_id'=>$member_id));
  225. $this->log('编辑店铺信息' . '[ID:' . $r. ']', 1);
  226. }
  227. showMessage(L('nc_common_op_succ'), 'index.php?act=store&op=store');
  228. } else {
  229. showMessage(L('nc_common_op_fail'));
  230. }
  231. }
  232. }
  233. private function upload_image($file) {
  234. $pic_name = '';
  235. $upload = new UploadFile();
  236. $uploaddir = ATTACH_PATH.DS.'store_joinin'.DS;
  237. $upload->set('default_dir',$uploaddir);
  238. $upload->set('allow_type',array('jpg','jpeg','gif','png'));
  239. if (!empty($_FILES[$file]['name'])){
  240. $result = $upload->upfile($file);
  241. if ($result){
  242. $pic_name = $upload->file_name;
  243. $upload->file_name = '';
  244. }
  245. }
  246. return $pic_name;
  247. }
  248. /**
  249. * 店铺经营类目管理
  250. */
  251. public function store_bind_classOp() {
  252. $store_id = intval($_GET['store_id']);
  253. $model_store = Model('store');
  254. $model_store_bind_class = Model('store_bind_class');
  255. $model_goods_class = Model('goods_class');
  256. $gc_list = $model_goods_class->getGoodsClassListByParentId(0);
  257. Tpl::output('gc_list',$gc_list);
  258. $store_info = $model_store->getStoreInfoByID($store_id);
  259. if(empty($store_info)) {
  260. showMessage(L('param_error'),'','','error');
  261. }
  262. Tpl::output('store_info', $store_info);
  263. $store_bind_class_list = $model_store_bind_class->getStoreBindClassList(array('store_id'=>$store_id,'state'=>array('in',array(1,2))), null);
  264. $goods_class = Model('goods_class')->getGoodsClassIndexedListAll();
  265. for($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
  266. $store_bind_class_list[$i]['class_1_name'] = $goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
  267. $store_bind_class_list[$i]['class_2_name'] = $goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
  268. $store_bind_class_list[$i]['class_3_name'] = $goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
  269. }
  270. Tpl::output('store_bind_class_list', $store_bind_class_list);
  271. Tpl::showpage('store_bind_class');
  272. }
  273. /**
  274. * 添加经营类目
  275. */
  276. public function store_bind_class_addOp()
  277. {
  278. $store_id = intval($_POST['store_id']);
  279. $commis_rate = intval($_POST['commis_rate']);
  280. if($commis_rate < 0 || $commis_rate > 100) {
  281. showMessage(L('param_error'), '');
  282. }
  283. list($class_1, $class_2, $class_3) = explode(',', $_POST['goods_class']);
  284. $model_store_bind_class = Model('store_bind_class');
  285. $param = array();
  286. $param['store_id'] = $store_id;
  287. $param['class_1'] = $class_1;
  288. $param['state'] = 1;
  289. if(!empty($class_2)) {
  290. $param['class_2'] = $class_2;
  291. }
  292. if(!empty($class_3)) {
  293. $param['class_3'] = $class_3;
  294. }
  295. // 检查类目是否已经存在
  296. $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo($param);
  297. if(!empty($store_bind_class_info)) {
  298. showMessage('该类目已经存在','','','error');
  299. }
  300. $param['commis_rate'] = $commis_rate;
  301. $result = $model_store_bind_class->addStoreBindClass($param);
  302. if($result) {
  303. $this->log('删除店铺经营类目,类目编号:'.$result.',店铺编号:'.$store_id);
  304. showMessage(L('nc_common_save_succ'), '');
  305. } else {
  306. showMessage(L('nc_common_save_fail'), '');
  307. }
  308. }
  309. /**
  310. * 删除经营类目
  311. */
  312. public function store_bind_class_delOp() {
  313. $bid = intval($_POST['bid']);
  314. $data = array();
  315. $data['result'] = true;
  316. $model_store_bind_class = Model('store_bind_class');
  317. $model_goods = Model('goods');
  318. $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo(array('bid' => $bid));
  319. if(empty($store_bind_class_info)) {
  320. $data['result'] = false;
  321. $data['message'] = '经营类目删除失败';
  322. echo json_encode($data);die;
  323. }
  324. // 商品下架
  325. $condition = array();
  326. $condition['store_id'] = $store_bind_class_info['store_id'];
  327. $gc_id = $store_bind_class_info['class_1'].','.$store_bind_class_info['class_2'].','.$store_bind_class_info['class_3'];
  328. $update = array();
  329. $update['goods_stateremark'] = '管理员删除经营类目';
  330. $condition['gc_id'] = array('in', rtrim($gc_id, ','));
  331. $model_goods->editProducesLockUp($update, $condition);
  332. $result = $model_store_bind_class->delStoreBindClass(array('bid'=>$bid));
  333. if(!$result) {
  334. $data['result'] = false;
  335. $data['message'] = '经营类目删除失败';
  336. }
  337. $this->log('删除店铺经营类目,类目编号:'.$bid.',店铺编号:'.$store_bind_class_info['store_id']);
  338. echo json_encode($data);die;
  339. }
  340. public function store_bind_class_updateOp() {
  341. $bid = intval($_GET['id']);
  342. if($bid <= 0) {
  343. echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
  344. die;
  345. }
  346. $new_commis_rate = intval($_GET['value']);
  347. if ($new_commis_rate < 0 || $new_commis_rate >= 100) {
  348. echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
  349. die;
  350. } else {
  351. $update = array('commis_rate' => $new_commis_rate);
  352. $condition = array('bid' => $bid);
  353. $model_store_bind_class = Model('store_bind_class');
  354. $result = $model_store_bind_class->editStoreBindClass($update, $condition);
  355. if($result) {
  356. $this->log('更新店铺经营类目,类目编号:'.$bid);
  357. echo json_encode(array('result'=>TRUE));
  358. die;
  359. } else {
  360. echo json_encode(array('result'=>FALSE,'message'=>L('nc_common_op_fail')));
  361. die;
  362. }
  363. }
  364. }
  365. /**
  366. * 店铺 待审核列表
  367. */
  368. public function store_joininOp(){
  369. //店铺列表
  370. if(!empty($_GET['owner_and_name'])) {
  371. $condition['member_name'] = array('like','%'.$_GET['owner_and_name'].'%');
  372. }
  373. if(!empty($_GET['store_name'])) {
  374. $condition['store_name'] = array('like','%'.$_GET['store_name'].'%');
  375. }
  376. if(!empty($_GET['grade_id']) && intval($_GET['grade_id']) > 0) {
  377. $condition['sg_id'] = $_GET['grade_id'];
  378. }
  379. if(!empty($_GET['joinin_state']) && intval($_GET['joinin_state']) > 0) {
  380. $condition['joinin_state'] = $_GET['joinin_state'] ;
  381. } else {
  382. $condition['joinin_state'] = array('gt',0);
  383. }
  384. $model_store_joinin = Model('store_joinin');
  385. $store_list = $model_store_joinin->getList($condition, 10, 'joinin_state asc');
  386. Tpl::output('store_list', $store_list);
  387. Tpl::output('joinin_state_array', $this->get_store_joinin_state());
  388. //店铺等级
  389. $model_grade = Model('store_grade');
  390. $grade_list = $model_grade->getGradeList();
  391. Tpl::output('grade_list', $grade_list);
  392. Tpl::output('page',$model_store_joinin->showpage('2'));
  393. Tpl::showpage('store_joinin');
  394. }
  395. /**
  396. * 经营类目申请列表
  397. */
  398. public function store_bind_class_applay_listOp(){
  399. $condition = array();
  400. // 不显示自营店铺绑定的类目
  401. if ($_GET['state'] != '') {
  402. $condition['state'] = intval($_GET['state']);
  403. if (!in_array($condition['state'], array('0', '1', )))
  404. unset($condition['state']);
  405. } else {
  406. $condition['state'] = array('in', array('0', '1', ));
  407. }
  408. if(intval($_GET['store_id'])) {
  409. $condition['store_id'] = intval($_GET['store_id']);
  410. }
  411. $model_store_bind_class = Model('store_bind_class');
  412. $store_bind_class_list = $model_store_bind_class->getStoreBindClassList($condition, 15,'state asc,bid desc');
  413. $goods_class = Model('goods_class')->getGoodsClassIndexedListAll();
  414. $store_ids = array();
  415. for($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
  416. $store_bind_class_list[$i]['class_1_name'] = $goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
  417. $store_bind_class_list[$i]['class_2_name'] = $goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
  418. $store_bind_class_list[$i]['class_3_name'] = $goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
  419. $store_ids[] = $store_bind_class_list[$i]['store_id'];
  420. }
  421. //取店铺信息
  422. $model_store = Model('store');
  423. $store_list = $model_store->getStoreList(array('store_id'=>array('in',$store_ids)),null);
  424. $bind_store_list = array();
  425. if (!empty($store_list) && is_array($store_list)) {
  426. foreach ($store_list as $k => $v) {
  427. $bind_store_list[$v['store_id']]['store_name'] = $v['store_name'];
  428. $bind_store_list[$v['store_id']]['seller_name'] = $v['seller_name'];
  429. }
  430. }
  431. Tpl::output('bind_list', $store_bind_class_list);
  432. Tpl::output('bind_store_list',$bind_store_list);
  433. Tpl::output('page',$model_store_bind_class->showpage('2'));
  434. Tpl::showpage('store_bind_class_applay.list');
  435. }
  436. /**
  437. * 审核经营类目申请
  438. */
  439. public function store_bind_class_applay_checkOp() {
  440. $model_store_bind_class = Model('store_bind_class');
  441. $condition = array();
  442. $condition['bid'] = intval($_GET['bid']);
  443. $condition['state'] = 0;
  444. $update = $model_store_bind_class->editStoreBindClass(array('state'=>1),$condition);
  445. if ($update) {
  446. $this->log('审核新经营类目申请,店铺ID:'.$_GET['store_id'],1);
  447. showMessage('审核成功',getReferer());
  448. } else {
  449. showMessage('审核失败',getReferer(),'html','error');
  450. }
  451. }
  452. /**
  453. * 删除经营类目申请
  454. */
  455. public function store_bind_class_applay_delOp() {
  456. $model_store_bind_class = Model('store_bind_class');
  457. $condition = array();
  458. $condition['bid'] = intval($_GET['bid']);
  459. $del = $model_store_bind_class->delStoreBindClass($condition);
  460. if ($del) {
  461. $this->log('删除经营类目,店铺ID:'.$_GET['store_id'],1);
  462. showMessage('删除成功',getReferer());
  463. } else {
  464. showMessage('删除失败',getReferer(),'html','error');
  465. }
  466. }
  467. private function get_store_joinin_state() {
  468. $joinin_state_array = array(
  469. STORE_JOIN_STATE_NEW => '新申请',
  470. STORE_JOIN_STATE_PAY => '已付款',
  471. STORE_JOIN_STATE_VERIFY_SUCCESS => '待付款',
  472. STORE_JOIN_STATE_VERIFY_FAIL => '审核失败',
  473. STORE_JOIN_STATE_PAY_FAIL => '付款审核失败',
  474. STORE_JOIN_STATE_FINAL => '开店成功',
  475. );
  476. return $joinin_state_array;
  477. }
  478. /**
  479. * 店铺续签申请列表
  480. */
  481. public function reopen_listOp(){
  482. $condition = array();
  483. if(intval($_GET['store_id'])) {
  484. $condition['re_store_id'] = intval($_GET['store_id']);
  485. }
  486. if(!empty($_GET['store_name'])) {
  487. $condition['re_store_name'] = $_GET['store_name'];
  488. }
  489. if ($_GET['re_state'] != '') {
  490. $condition['re_state'] = intval($_GET['re_state']);
  491. }
  492. $model_store_reopen = Model('store_reopen');
  493. $reopen_list = $model_store_reopen->getStoreReopenList($condition, 15);
  494. Tpl::output('reopen_list', $reopen_list);
  495. Tpl::output('page',$model_store_reopen->showpage('2'));
  496. Tpl::showpage('store_reopen.list');
  497. }
  498. /**
  499. * 审核店铺续签申请
  500. */
  501. public function reopen_checkOp() {
  502. if (intval($_GET['re_id']) <= 0) exit();
  503. $model_store_reopen = Model('store_reopen');
  504. $condition = array();
  505. $condition['re_id'] = intval($_GET['re_id']);
  506. $condition['re_state'] = 1;
  507. //取当前申请信息
  508. $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
  509. //取目前店铺有效截止日期
  510. $store_info = Model('store')->getStoreInfoByID($reopen_info['re_store_id']);
  511. $data = array();
  512. $data['re_start_time'] = strtotime(date('Y-m-d 0:0:0',$store_info['store_end_time']))+24*3600;
  513. $data['re_end_time'] = strtotime(date('Y-m-d 23:59:59', $data['re_start_time'])." +".intval($reopen_info['re_year'])." year");
  514. $data['re_state'] = 2;
  515. $update = $model_store_reopen->editStoreReopen($data,$condition);
  516. if ($update) {
  517. //更新店铺有效期
  518. Model('store')->editStore(array('store_end_time'=>$data['re_end_time']),array('store_id'=>$reopen_info['re_store_id']));
  519. $msg = '审核通过店铺续签申请,店铺ID:'.$reopen_info['re_store_id'].',续签时间段:'.date('Y-m-d',$data['re_start_time']).' - '.date('Y-m-d',$data['re_end_time']);
  520. $this->log($msg,1);
  521. showMessage('续签成功,店铺有效成功延续到了'.date('Y-m-d',$data['re_end_time']).'日',getReferer());
  522. } else {
  523. showMessage('审核失败',getReferer(),'html','error');
  524. }
  525. }
  526. /**
  527. * 删除店铺续签申请
  528. */
  529. public function reopen_delOp() {
  530. $model_store_reopen = Model('store_reopen');
  531. $condition = array();
  532. $condition['re_id'] = intval($_GET['re_id']);
  533. $condition['re_state'] = array('in',array(0,1));
  534. //取当前申请信息
  535. $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
  536. $cert_file = BASE_UPLOAD_PATH.DS.ATTACH_STORE_JOININ.DS.$reopen_info['re_pay_cert'];
  537. $del = $model_store_reopen->delStoreReopen($condition);
  538. if ($del) {
  539. if (is_file($cert_file)) {
  540. unlink($cert_file);
  541. }
  542. $this->log('删除店铺续签目申请,店铺ID:'.$_GET['re_store_id'],1);
  543. showMessage('删除成功',getReferer());
  544. } else {
  545. showMessage('删除失败',getReferer(),'html','error');
  546. }
  547. }
  548. /**
  549. * 审核详细页
  550. */
  551. public function store_joinin_detailOp(){
  552. $model_store_joinin = Model('store_joinin');
  553. $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_GET['member_id']));
  554. $joinin_detail_title = '查看';
  555. if(in_array(intval($joinin_detail['joinin_state']), array(STORE_JOIN_STATE_NEW, STORE_JOIN_STATE_PAY))) {
  556. $joinin_detail_title = '审核';
  557. }
  558. if (!empty($joinin_detail['sg_info'])) {
  559. $store_grade_info = Model('store_grade')->getOneGrade($joinin_detail['sg_id']);
  560. $joinin_detail['sg_price'] = $store_grade_info['sg_price'];
  561. } else {
  562. $joinin_detail['sg_info'] = @unserialize($joinin_detail['sg_info']);
  563. if (is_array($joinin_detail['sg_info'])) {
  564. $joinin_detail['sg_price'] = $joinin_detail['sg_info']['sg_price'];
  565. }
  566. }
  567. Tpl::output('joinin_detail_title', $joinin_detail_title);
  568. Tpl::output('joinin_detail', $joinin_detail);
  569. Tpl::showpage('store_joinin.detail');
  570. }
  571. /**
  572. * 审核
  573. */
  574. public function store_joinin_verifyOp() {
  575. $model_store_joinin = Model('store_joinin');
  576. $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_POST['member_id']));
  577. switch (intval($joinin_detail['joinin_state'])) {
  578. case STORE_JOIN_STATE_NEW:
  579. $this->store_joinin_verify_pass($joinin_detail);
  580. break;
  581. case STORE_JOIN_STATE_PAY:
  582. $this->store_joinin_verify_open($joinin_detail);
  583. break;
  584. default:
  585. showMessage('参数错误','');
  586. break;
  587. }
  588. }
  589. private function store_joinin_verify_pass($joinin_detail) {
  590. $param = array();
  591. $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_VERIFY_SUCCESS : STORE_JOIN_STATE_VERIFY_FAIL;
  592. $param['joinin_message'] = $_POST['joinin_message'];
  593. $param['paying_amount'] = abs(floatval($_POST['paying_amount']));
  594. $param['store_class_commis_rates'] = implode(',', $_POST['commis_rate']);
  595. $model_store_joinin = Model('store_joinin');
  596. $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
  597. if ($param['paying_amount'] > 0) {
  598. showMessage('店铺入驻申请审核完成','index.php?act=store&op=store_joinin');
  599. } else {
  600. //如果开店支付费用为零,则审核通过后直接开通,无需再上传付款凭证
  601. $this->store_joinin_verify_open($joinin_detail);
  602. }
  603. }
  604. private function store_joinin_verify_open($joinin_detail) {
  605. $model_store_joinin = Model('store_joinin');
  606. $model_store = Model('store');
  607. $model_seller = Model('seller');
  608. //验证卖家用户名是否已经存在
  609. if($model_seller->isSellerExist(array('seller_name' => $joinin_detail['seller_name']))) {
  610. showMessage('卖家用户名已存在','');
  611. }
  612. $param = array();
  613. $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_FINAL : STORE_JOIN_STATE_PAY_FAIL;
  614. $param['joinin_message'] = $_POST['joinin_message'];
  615. $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
  616. if($_POST['verify_type'] === 'pass') {
  617. //开店
  618. $shop_array = array();
  619. $shop_array['member_id'] = $joinin_detail['member_id'];
  620. $shop_array['member_name'] = $joinin_detail['member_name'];
  621. $shop_array['seller_name'] = $joinin_detail['seller_name'];
  622. $shop_array['grade_id'] = $joinin_detail['sg_id'];
  623. $shop_array['store_name'] = $joinin_detail['store_name'];
  624. $shop_array['sc_id'] = $joinin_detail['sc_id'];
  625. $shop_array['store_company_name'] = $joinin_detail['company_name'];
  626. $shop_array['province_id'] = $joinin_detail['company_province_id'];
  627. $shop_array['area_info'] = $joinin_detail['company_address'];
  628. $shop_array['store_address']= $joinin_detail['company_address_detail'];
  629. $shop_array['store_zip'] = '';
  630. $shop_array['store_zy'] = '';
  631. $shop_array['store_state'] = 1;
  632. $shop_array['store_time'] = time();
  633. $shop_array['store_end_time'] = strtotime(date('Y-m-d 23:59:59', strtotime('+1 day'))." +".intval($joinin_detail['joinin_year'])." year");
  634. $store_id = $model_store->addStore($shop_array);
  635. if($store_id) {
  636. //写入卖家账号
  637. $seller_array = array();
  638. $seller_array['seller_name'] = $joinin_detail['seller_name'];
  639. $seller_array['member_id'] = $joinin_detail['member_id'];
  640. $seller_array['seller_group_id'] = 0;
  641. $seller_array['store_id'] = $store_id;
  642. $seller_array['is_admin'] = 1;
  643. $state = $model_seller->addSeller($seller_array);
  644. }
  645. if($state) {
  646. // 添加相册默认
  647. $album_model = Model('album');
  648. $album_arr = array();
  649. $album_arr['aclass_name'] = Language::get('store_save_defaultalbumclass_name');
  650. $album_arr['store_id'] = $store_id;
  651. $album_arr['aclass_des'] = '';
  652. $album_arr['aclass_sort'] = '255';
  653. $album_arr['aclass_cover'] = '';
  654. $album_arr['upload_time'] = time();
  655. $album_arr['is_default'] = '1';
  656. $album_model->addClass($album_arr);
  657. $model = Model();
  658. //插入店铺扩展表
  659. $model->table('store_extend')->insert(array('store_id'=>$store_id));
  660. $msg = Language::get('store_save_create_success');
  661. //插入店铺绑定分类表
  662. $store_bind_class_array = array();
  663. $store_bind_class = unserialize($joinin_detail['store_class_ids']);
  664. $store_bind_commis_rates = explode(',', $joinin_detail['store_class_commis_rates']);
  665. for($i=0, $length=count($store_bind_class); $i<$length; $i++) {
  666. list($class1, $class2, $class3) = explode(',', $store_bind_class[$i]);
  667. $store_bind_class_array[] = array(
  668. 'store_id' => $store_id,
  669. 'commis_rate' => $store_bind_commis_rates[$i],
  670. 'class_1' => $class1,
  671. 'class_2' => $class2,
  672. 'class_3' => $class3,
  673. 'state' => 1
  674. );
  675. }
  676. $model_store_bind_class = Model('store_bind_class');
  677. $model_store_bind_class->addStoreBindClassAll($store_bind_class_array);
  678. showMessage('店铺开店成功','index.php?act=store&op=store_joinin');
  679. } else {
  680. showMessage('店铺开店失败','index.php?act=store&op=store_joinin');
  681. }
  682. } else {
  683. showMessage('店铺开店拒绝','index.php?act=store&op=store_joinin');
  684. }
  685. }
  686. /**
  687. * 提醒续费
  688. */
  689. public function remind_renewalOp() {
  690. $store_id = intval($_GET['store_id']);
  691. $store_info = Model('store')->getStoreInfoByID($store_id);
  692. if (!empty($store_info) && $store_info['store_end_time'] < (time() + 864000) && cookie('remindRenewal'.$store_id) == null) {
  693. // 发送商家消息
  694. $param = array();
  695. $param['code'] = 'store_expire';
  696. $param['store_id'] = intval($_GET['store_id']);
  697. $param['param'] = array();
  698. QueueClient::push('sendStoreMsg', $param);
  699. setNcCookie('remindRenewal'.$store_id, 1, 86400 * 10); // 十天
  700. showMessage('消息发送成功');
  701. }
  702. showMessage('消息发送失败');
  703. }
  704. public function delOp()
  705. {
  706. $storeId = (int) $_GET['id'];
  707. $storeModel = model('store');
  708. $storeArray = $storeModel->field('is_own_shop,store_name')->find($storeId);
  709. if (empty($storeArray)) {
  710. showMessage('外驻店铺不存在', '', 'html', 'error');
  711. }
  712. if ($storeArray['is_own_shop']) {
  713. showMessage('不能在此删除自营店铺', '', 'html', 'error');
  714. }
  715. $condition = array(
  716. 'store_id' => $storeId,
  717. );
  718. if ((int) model('goods')->getGoodsCount($condition) > 0)
  719. showMessage('已经发布商品的外驻店铺不能被删除', '', 'html', 'error');
  720. // 完全删除店铺
  721. $storeModel->delStoreEntirely($condition);
  722. $this->log("删除外驻店铺: {$storeArray['store_name']}");
  723. showMessage('操作成功', getReferer());
  724. }
  725. public function newshop_addOp()
  726. {
  727. if (chksubmit())
  728. {
  729. $memberName = $_POST['member_name'];
  730. $memberPasswd = (string) $_POST['member_passwd'];
  731. if (strlen($memberName) < 3 || strlen($memberName) > 15
  732. || strlen($_POST['seller_name']) < 3 || strlen($_POST['seller_name']) > 15)
  733. showMessage('账号名称必须是3~15位', '', 'html', 'error');
  734. if (strlen($memberPasswd) < 6)
  735. showMessage('登录密码不能短于6位', '', 'html', 'error');
  736. if (!$this->checkMemberName($memberName))
  737. showMessage('店主账号已被占用', '', 'html', 'error');
  738. if (!$this->checkSellerName($_POST['seller_name']))
  739. showMessage('店主卖家账号名称已被其它店铺占用', '', 'html', 'error');
  740. try
  741. {
  742. $memberId = model('member')->addMember(array(
  743. 'member_name' => $memberName,
  744. 'member_passwd' => $memberPasswd,
  745. 'member_email' => '',
  746. ));
  747. }
  748. catch (Exception $ex)
  749. {
  750. showMessage('店主账号新增失败', '', 'html', 'error');
  751. }
  752. $storeModel = model('store');
  753. $saveArray = array();
  754. $saveArray['store_name'] = $_POST['store_name'];
  755. $saveArray['member_id'] = $memberId;
  756. $saveArray['member_name'] = $memberName;
  757. $saveArray['seller_name'] = $_POST['seller_name'];
  758. $saveArray['bind_all_gc'] = 1;
  759. $saveArray['store_state'] = 1;
  760. $saveArray['store_time'] = time();
  761. $saveArray['is_own_shop'] = 0;
  762. $storeId = $storeModel->addStore($saveArray);
  763. model('seller')->addSeller(array(
  764. 'seller_name' => $_POST['seller_name'],
  765. 'member_id' => $memberId,
  766. 'store_id' => $storeId,
  767. 'seller_group_id' => 0,
  768. 'is_admin' => 1,
  769. ));
  770. model('store_joinin')->save(array(
  771. 'seller_name' => $_POST['seller_name'],
  772. 'store_name' => $_POST['store_name'],
  773. 'member_name' => $memberName,
  774. 'member_id' => $memberId,
  775. 'joinin_state' => 40,
  776. 'company_province_id' => 0,
  777. 'sc_bail' => 0,
  778. 'joinin_year' => 1,
  779. ));
  780. // 添加相册默认
  781. $album_model = Model('album');
  782. $album_arr = array();
  783. $album_arr['aclass_name'] = '默认相册';
  784. $album_arr['store_id'] = $storeId;
  785. $album_arr['aclass_des'] = '';
  786. $album_arr['aclass_sort'] = '255';
  787. $album_arr['aclass_cover'] = '';
  788. $album_arr['upload_time'] = time();
  789. $album_arr['is_default'] = '1';
  790. $album_model->addClass($album_arr);
  791. //插入店铺扩展表
  792. $model = Model();
  793. $model->table('store_extend')->insert(array('store_id'=>$storeId));
  794. // 删除自营店id缓存
  795. Model('store')->dropCachedOwnShopIds();
  796. $this->log("新增外驻店铺: {$saveArray['store_name']}");
  797. showMessage('操作成功', urlAdmin('store', 'store'));
  798. return;
  799. }
  800. Tpl::showpage('store.newshop.add');
  801. }
  802. public function check_seller_nameOp()
  803. {
  804. echo json_encode($this->checkSellerName($_GET['seller_name'], $_GET['id']));
  805. exit;
  806. }
  807. private function checkSellerName($sellerName, $storeId = 0)
  808. {
  809. // 判断store_joinin是否存在记录
  810. $count = (int) Model('store_joinin')->getStoreJoininCount(array(
  811. 'seller_name' => $sellerName,
  812. ));
  813. if ($count > 0)
  814. return false;
  815. $seller = Model('seller')->getSellerInfo(array(
  816. 'seller_name' => $sellerName,
  817. ));
  818. if (empty($seller))
  819. return true;
  820. if (!$storeId)
  821. return false;
  822. if ($storeId == $seller['store_id'] && $seller['seller_group_id'] == 0 && $seller['is_admin'] == 1)
  823. return true;
  824. return false;
  825. }
  826. public function check_member_nameOp()
  827. {
  828. echo json_encode($this->checkMemberName($_GET['member_name']));
  829. exit;
  830. }
  831. private function checkMemberName($memberName)
  832. {
  833. // 判断store_joinin是否存在记录
  834. $count = (int) Model('store_joinin')->getStoreJoininCount(array(
  835. 'member_name' => $memberName,
  836. ));
  837. if ($count > 0)
  838. return false;
  839. return ! Model('member')->getMemberCount(array(
  840. 'member_name' => $memberName,
  841. ));
  842. }
  843. /**
  844. * 验证店铺名称是否存在
  845. */
  846. public function ckeck_store_nameOp() {
  847. /**
  848. * 实例化卖家模型
  849. */
  850. $where = array();
  851. $where['store_name'] = $_GET['store_name'];
  852. $where['store_id'] = array('neq', $_GET['store_id']);
  853. $store_info = Model('store')->getStoreInfo($where);
  854. if(!empty($store_info['store_name'])) {
  855. echo 'false';
  856. } else {
  857. echo 'true';
  858. }
  859. }
  860. /**
  861. * 验证店铺名称是否存在
  862. */
  863. private function ckeckStoreName($store_name) {
  864. /**
  865. * 实例化卖家模型
  866. */
  867. $where = array();
  868. $where['store_name'] = $store_name;
  869. $store_info = Model('store')->getStoreInfo($where);
  870. if(!empty($store_info['store_name'])) {
  871. return false;
  872. } else {
  873. return true;
  874. }
  875. }
  876. public function store_importOp(){
  877. Tpl::showpage('store_import');
  878. }
  879. public function store_import_csvOp(){
  880. if (isset($_POST['import'])) {
  881. $file = $_FILES['csv_stores'];
  882. $file_type = substr(strstr($file['name'], '.'), 1);
  883. //上传文件存在判断
  884. if(empty($file['name'])){
  885. showMessage('请选择要上传csv的文件!','','html','error');
  886. }
  887. // 检查文件格式
  888. if ($file_type != 'csv') {
  889. showMessage('文件格式不对,请重新上传!','','html','error');
  890. exit;
  891. }
  892. $handle = fopen($file['tmp_name'], "r");
  893. $result = $this->input_csv($handle); //解析csv
  894. $rows = count($result);
  895. if($rows == 0){
  896. showMessage('没有任何数据!','','html','error');
  897. exit;
  898. }
  899. $scounter = 0;
  900. $storeModel = model('store');
  901. for ($i = 1; $i < $rows; $i++) {
  902. //循环获取各字段值
  903. $store_name = iconv('gb2312', 'utf-8', $result[$i][0]);
  904. $member_name = iconv('gb2312', 'utf-8', $result[$i][1]);
  905. $seller_name = iconv('gb2312', 'utf-8', $result[$i][2]);
  906. $password = iconv('gb2312', 'utf-8', $result[$i][3]);
  907. $store_company_name = iconv('gb2312', 'utf-8', $result[$i][4]);
  908. $company_name = iconv('gb2312', 'utf-8', $result[$i][5]);
  909. $company_address = iconv('gb2312', 'utf-8', $result[$i][6]);
  910. $store_address = iconv('gb2312', 'utf-8', $result[$i][7]);
  911. $store_zip = iconv('gb2312', 'utf-8', $result[$i][8]);
  912. $store_qq = iconv('gb2312', 'utf-8', $result[$i][9]);
  913. $store_ww = iconv('gb2312', 'utf-8', $result[$i][10]);
  914. $store_phone = iconv('gb2312', 'utf-8', $result[$i][11]);
  915. $company_employee_count = iconv('gb2312', 'utf-8', $result[$i][12]);
  916. $company_registered_capital = iconv('gb2312', 'utf-8', $result[$i][13]);
  917. $contacts_name = iconv('gb2312', 'utf-8', $result[$i][14]);
  918. $contacts_phone = iconv('gb2312', 'utf-8', $result[$i][15]);
  919. $contacts_email = iconv('gb2312', 'utf-8', $result[$i][16]);
  920. $business_licence_number = iconv('gb2312', 'utf-8', $result[$i][17]);
  921. $business_licence_address = iconv('gb2312', 'utf-8', $result[$i][18]);
  922. $business_licence_start = iconv('gb2312', 'utf-8', $result[$i][19]);
  923. $business_licence_end = iconv('gb2312', 'utf-8', $result[$i][20]);
  924. $business_sphere = iconv('gb2312', 'utf-8', $result[$i][21]);
  925. $organization_code = iconv('gb2312', 'utf-8', $result[$i][22]);
  926. $bank_account_name = iconv('gb2312', 'utf-8', $result[$i][23]);
  927. $bank_account_number = iconv('gb2312', 'utf-8', $result[$i][24]);
  928. $bank_name = iconv('gb2312', 'utf-8', $result[$i][25]);
  929. $bank_code = iconv('gb2312', 'utf-8', $result[$i][26]);
  930. $bank_address = iconv('gb2312', 'utf-8', $result[$i][27]);
  931. $is_settlement_account = iconv('gb2312', 'utf-8', $result[$i][28]);
  932. $settlement_bank_account_name = iconv('gb2312', 'utf-8', $result[$i][29]);
  933. $settlement_bank_account_number = iconv('gb2312', 'utf-8', $result[$i][30]);
  934. $settlement_bank_name = iconv('gb2312', 'utf-8', $result[$i][31]);
  935. $settlement_bank_code = iconv('gb2312', 'utf-8', $result[$i][32]);
  936. $settlement_bank_address = iconv('gb2312', 'utf-8', $result[$i][33]);
  937. $tax_registration_certificate = iconv('gb2312', 'utf-8', $result[$i][34]);
  938. $taxpayer_id = iconv('gb2312', 'utf-8', $result[$i][35]);
  939. $joinin_year = iconv('gb2312', 'utf-8', $result[$i][36]);
  940. if(!$this->ckeckStoreName($store_name))
  941. {
  942. continue;
  943. }
  944. if(!$this->checkMemberName($member_name))
  945. {
  946. continue;
  947. }
  948. if(!$this->checkSellerName($seller_name))
  949. {
  950. continue;
  951. }
  952. try
  953. {
  954. $memberId = model('member')->addMember(array(
  955. 'member_name' => $member_name,
  956. 'member_passwd' => $password,
  957. 'member_email' => '',
  958. ));
  959. }
  960. catch (Exception $ex)
  961. {
  962. showMessage('店主账号新增失败', '', 'html', 'error');
  963. }
  964. $storeModel = model('store');
  965. $saveArray = array();
  966. $saveArray['store_name'] = $store_name;
  967. $saveArray['grade_id'] = 1;
  968. $saveArray['member_id'] = $memberId;
  969. $saveArray['member_name'] = $member_name;
  970. $saveArray['seller_name'] = $seller_name;
  971. $saveArray['bind_all_gc'] = 0;
  972. $saveArray['store_state'] = 1;
  973. $saveArray['store_time'] = time();
  974. $saveArray['store_company_name'] = $store_company_name;
  975. $saveArray['store_address'] = $store_address;
  976. $saveArray['store_zip'] = $store_zip;
  977. $saveArray['store_qq'] = $store_qq;
  978. $saveArray['store_ww'] = $store_ww;
  979. $saveArray['store_phone'] = $store_phone;
  980. $storeId = $storeModel->addStore($saveArray);
  981. model('seller')->addSeller(array(
  982. 'seller_name' => $seller_name,
  983. 'member_id' => $memberId,
  984. 'store_id' => $storeId,
  985. 'seller_group_id' => 0,
  986. 'is_admin' => 1,
  987. ));
  988. $store_joinModel = model('store_joinin');
  989. $save_joinArray = array();
  990. $save_joinArray['member_id'] = $memberId;
  991. $save_joinArray['member_name'] = $member_name;
  992. $save_joinArray['company_name'] = $company_name;
  993. $save_joinArray['company_address'] = $company_address;
  994. $save_joinArray['company_address_detail'] = $store_address;
  995. $save_joinArray['company_phone'] = $store_phone;
  996. $save_joinArray['company_employee_count'] = $company_employee_count;
  997. $save_joinArray['company_registered_capital'] = $company_registered_capita;
  998. $save_joinArray['contacts_name'] = $contacts_name;
  999. $save_joinArray['contacts_phone'] = $contacts_phone;
  1000. $save_joinArray['contacts_email'] = $contacts_email;
  1001. $save_joinArray['business_licence_number'] = $business_licence_number;
  1002. $save_joinArray['business_licence_address'] = $business_licence_address;
  1003. $save_joinArray['business_licence_start'] = $business_licence_start;
  1004. $save_joinArray['business_licence_end'] = $business_licence_end;
  1005. $save_joinArray['business_sphere'] = $business_sphere;
  1006. $save_joinArray['organization_code'] = $organization_code;
  1007. $save_joinArray['general_taxpayer'] = $general_taxpayer;
  1008. $save_joinArray['bank_account_name'] = $bank_account_name;
  1009. $save_joinArray['bank_account_number'] = $bank_account_number;
  1010. $save_joinArray['bank_name'] = $bank_name;
  1011. $save_joinArray['bank_code'] = $bank_code;
  1012. $save_joinArray['bank_address'] = $bank_address;
  1013. $save_joinArray['is_settlement_account'] = $is_settlement_account;
  1014. if($is_settlement_account == '是')
  1015. {
  1016. //2独立
  1017. $save_joinArray['is_settlement_account'] = 2;
  1018. $save_joinArray['settlement_bank_account_name'] = $settlement_bank_account_name;
  1019. $save_joinArray['settlement_bank_account_number'] = $settlement_bank_account_number;
  1020. $save_joinArray['settlement_bank_name'] = $settlement_bank_name;
  1021. $save_joinArray['settlement_bank_code'] = $settlement_bank_code;
  1022. $save_joinArray['settlement_bank_address'] = $settlement_bank_address;
  1023. }
  1024. else
  1025. {
  1026. //1非独立
  1027. $save_joinArray['is_settlement_account'] = 1;
  1028. $save_joinArray['settlement_bank_account_name'] = $bank_account_name;
  1029. $save_joinArray['settlement_bank_account_number'] = $bank_account_number;
  1030. $save_joinArray['settlement_bank_name'] = $bank_name;
  1031. $save_joinArray['settlement_bank_code'] = $bank_code;
  1032. $save_joinArray['settlement_bank_address'] = $bank_address;
  1033. }
  1034. $save_joinArray['tax_registration_certificate'] = $tax_registration_certificate;
  1035. $save_joinArray['taxpayer_id'] = $taxpayer_id;
  1036. $save_joinArray['seller_name'] = $seller_name;
  1037. $save_joinArray['store_name'] = $store_name;
  1038. $save_joinArray['joinin_state'] = 40;
  1039. $save_joinArray['joinin_year'] = $joinin_year;
  1040. $save_joinArray['company_name'] = $company_name;
  1041. $save_joinArray['company_name'] = $company_name;
  1042. $store_joinModel->save($save_joinArray);
  1043. // 添加相册默认
  1044. $album_model = Model('album');
  1045. $album_arr = array();
  1046. $album_arr['aclass_name'] = '默认相册';
  1047. $album_arr['store_id'] = $storeId;
  1048. $album_arr['aclass_des'] = '';
  1049. $album_arr['aclass_sort'] = '255';
  1050. $album_arr['aclass_cover'] = '';
  1051. $album_arr['upload_time'] = time();
  1052. $album_arr['is_default'] = '1';
  1053. $album_model->addClass($album_arr);
  1054. //插入店铺扩展表
  1055. $model = Model();
  1056. $model->table('store_extend')->insert(array('store_id'=>$storeId));
  1057. $scounter++;
  1058. }
  1059. //$data_values = substr($data_values,0,-1); //去掉最后一个逗号
  1060. fclose($handle); //关闭指针
  1061. showMessage('操作成功,成功导入 '.strval($scounter).' 条数据' , urlAdmin('store', 'store'));
  1062. return;
  1063. /*
  1064. $row = 0;
  1065. while ($data = fgetcsv($handle, 10000)) {
  1066. $row++;
  1067. if ($row == 1) continue;
  1068. $num = count($data);
  1069. for ($i = 0; $i < $num; $i++) {
  1070. $t=iconv('gb2312', 'utf-8', $data[$i]);
  1071. echo $t.
  1072. "<br>";
  1073. }
  1074. }
  1075. fclose($handle);
  1076. */
  1077. }
  1078. }
  1079. /*
  1080. * 解析csv
  1081. */
  1082. private function input_csv($handle) {
  1083. $out = array ();
  1084. $n = 0;
  1085. while ($data = fgetcsv($handle, 10000)) {
  1086. $num = count($data);
  1087. for ($i = 0; $i < $num; $i++) {
  1088. $out[$n][$i] = $data[$i];
  1089. }
  1090. $n++;
  1091. }
  1092. return $out;
  1093. }
  1094. }