store.php 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222
  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. $store_id = intval($_POST['store_id']);
  278. $commis_rate = intval($_POST['commis_rate']);
  279. if($commis_rate < 0 || $commis_rate > 100) {
  280. showMessage(L('param_error'), '');
  281. }
  282. list($class_1, $class_2, $class_3) = explode(',', $_POST['goods_class']);
  283. $model_store_bind_class = Model('store_bind_class');
  284. $param = array();
  285. $param['store_id'] = $store_id;
  286. $param['class_1'] = $class_1;
  287. $param['state'] = 1;
  288. if(!empty($class_2)) {
  289. $param['class_2'] = $class_2;
  290. }
  291. if(!empty($class_3)) {
  292. $param['class_3'] = $class_3;
  293. }
  294. // 检查类目是否已经存在
  295. $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo($param);
  296. if(!empty($store_bind_class_info)) {
  297. showMessage('该类目已经存在','','','error');
  298. }
  299. $param['commis_rate'] = $commis_rate;
  300. $result = $model_store_bind_class->addStoreBindClass($param);
  301. if($result) {
  302. $this->log('删除店铺经营类目,类目编号:'.$result.',店铺编号:'.$store_id);
  303. showMessage(L('nc_common_save_succ'), '');
  304. } else {
  305. showMessage(L('nc_common_save_fail'), '');
  306. }
  307. }
  308. /**
  309. * 删除经营类目
  310. */
  311. public function store_bind_class_delOp() {
  312. $bid = intval($_POST['bid']);
  313. $data = array();
  314. $data['result'] = true;
  315. $model_store_bind_class = Model('store_bind_class');
  316. $model_goods = Model('goods');
  317. $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo(array('bid' => $bid));
  318. if(empty($store_bind_class_info)) {
  319. $data['result'] = false;
  320. $data['message'] = '经营类目删除失败';
  321. echo json_encode($data);die;
  322. }
  323. // 商品下架
  324. $condition = array();
  325. $condition['store_id'] = $store_bind_class_info['store_id'];
  326. $gc_id = $store_bind_class_info['class_1'].','.$store_bind_class_info['class_2'].','.$store_bind_class_info['class_3'];
  327. $update = array();
  328. $update['goods_stateremark'] = '管理员删除经营类目';
  329. $condition['gc_id'] = array('in', rtrim($gc_id, ','));
  330. $model_goods->editProducesLockUp($update, $condition);
  331. $result = $model_store_bind_class->delStoreBindClass(array('bid'=>$bid));
  332. if(!$result) {
  333. $data['result'] = false;
  334. $data['message'] = '经营类目删除失败';
  335. }
  336. $this->log('删除店铺经营类目,类目编号:'.$bid.',店铺编号:'.$store_bind_class_info['store_id']);
  337. echo json_encode($data);die;
  338. }
  339. public function store_bind_class_updateOp() {
  340. $bid = intval($_GET['id']);
  341. if($bid <= 0) {
  342. echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
  343. die;
  344. }
  345. $new_commis_rate = intval($_GET['value']);
  346. if ($new_commis_rate < 0 || $new_commis_rate >= 100) {
  347. echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
  348. die;
  349. } else {
  350. $update = array('commis_rate' => $new_commis_rate);
  351. $condition = array('bid' => $bid);
  352. $model_store_bind_class = Model('store_bind_class');
  353. $result = $model_store_bind_class->editStoreBindClass($update, $condition);
  354. if($result) {
  355. $this->log('更新店铺经营类目,类目编号:'.$bid);
  356. echo json_encode(array('result'=>TRUE));
  357. die;
  358. } else {
  359. echo json_encode(array('result'=>FALSE,'message'=>L('nc_common_op_fail')));
  360. die;
  361. }
  362. }
  363. }
  364. /**
  365. * 店铺 待审核列表
  366. */
  367. public function store_joininOp(){
  368. //店铺列表
  369. if(!empty($_GET['owner_and_name'])) {
  370. $condition['member_name'] = array('like','%'.$_GET['owner_and_name'].'%');
  371. }
  372. if(!empty($_GET['store_name'])) {
  373. $condition['store_name'] = array('like','%'.$_GET['store_name'].'%');
  374. }
  375. if(!empty($_GET['grade_id']) && intval($_GET['grade_id']) > 0) {
  376. $condition['sg_id'] = $_GET['grade_id'];
  377. }
  378. if(!empty($_GET['joinin_state']) && intval($_GET['joinin_state']) > 0) {
  379. $condition['joinin_state'] = $_GET['joinin_state'] ;
  380. } else {
  381. $condition['joinin_state'] = array('gt',0);
  382. }
  383. $model_store_joinin = Model('store_joinin');
  384. $store_list = $model_store_joinin->getList($condition, 10, 'joinin_state asc');
  385. Tpl::output('store_list', $store_list);
  386. Tpl::output('joinin_state_array', $this->get_store_joinin_state());
  387. //店铺等级
  388. $model_grade = Model('store_grade');
  389. $grade_list = $model_grade->getGradeList();
  390. Tpl::output('grade_list', $grade_list);
  391. Tpl::output('page',$model_store_joinin->showpage('2'));
  392. Tpl::showpage('store_joinin');
  393. }
  394. /**
  395. * 经营类目申请列表
  396. */
  397. public function store_bind_class_applay_listOp(){
  398. $condition = array();
  399. // 不显示自营店铺绑定的类目
  400. if ($_GET['state'] != '') {
  401. $condition['state'] = intval($_GET['state']);
  402. if (!in_array($condition['state'], array('0', '1', )))
  403. unset($condition['state']);
  404. } else {
  405. $condition['state'] = array('in', array('0', '1', ));
  406. }
  407. if(intval($_GET['store_id'])) {
  408. $condition['store_id'] = intval($_GET['store_id']);
  409. }
  410. $model_store_bind_class = Model('store_bind_class');
  411. $store_bind_class_list = $model_store_bind_class->getStoreBindClassList($condition, 15,'state asc,bid desc');
  412. $goods_class = Model('goods_class')->getGoodsClassIndexedListAll();
  413. $store_ids = array();
  414. for($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
  415. $store_bind_class_list[$i]['class_1_name'] = $goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
  416. $store_bind_class_list[$i]['class_2_name'] = $goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
  417. $store_bind_class_list[$i]['class_3_name'] = $goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
  418. $store_ids[] = $store_bind_class_list[$i]['store_id'];
  419. }
  420. //取店铺信息
  421. $model_store = Model('store');
  422. $store_list = $model_store->getStoreList(array('store_id'=>array('in',$store_ids)),null);
  423. $bind_store_list = array();
  424. if (!empty($store_list) && is_array($store_list)) {
  425. foreach ($store_list as $k => $v) {
  426. $bind_store_list[$v['store_id']]['store_name'] = $v['store_name'];
  427. $bind_store_list[$v['store_id']]['seller_name'] = $v['seller_name'];
  428. }
  429. }
  430. Tpl::output('bind_list', $store_bind_class_list);
  431. Tpl::output('bind_store_list',$bind_store_list);
  432. Tpl::output('page',$model_store_bind_class->showpage('2'));
  433. Tpl::showpage('store_bind_class_applay.list');
  434. }
  435. /**
  436. * 审核经营类目申请
  437. */
  438. public function store_bind_class_applay_checkOp() {
  439. $model_store_bind_class = Model('store_bind_class');
  440. $condition = array();
  441. $condition['bid'] = intval($_GET['bid']);
  442. $condition['state'] = 0;
  443. $update = $model_store_bind_class->editStoreBindClass(array('state'=>1),$condition);
  444. if ($update) {
  445. $this->log('审核新经营类目申请,店铺ID:'.$_GET['store_id'],1);
  446. showMessage('审核成功',getReferer());
  447. } else {
  448. showMessage('审核失败',getReferer(),'html','error');
  449. }
  450. }
  451. /**
  452. * 删除经营类目申请
  453. */
  454. public function store_bind_class_applay_delOp() {
  455. $model_store_bind_class = Model('store_bind_class');
  456. $condition = array();
  457. $condition['bid'] = intval($_GET['bid']);
  458. $del = $model_store_bind_class->delStoreBindClass($condition);
  459. if ($del) {
  460. $this->log('删除经营类目,店铺ID:'.$_GET['store_id'],1);
  461. showMessage('删除成功',getReferer());
  462. } else {
  463. showMessage('删除失败',getReferer(),'html','error');
  464. }
  465. }
  466. private function get_store_joinin_state() {
  467. $joinin_state_array = array(
  468. STORE_JOIN_STATE_NEW => '新申请',
  469. STORE_JOIN_STATE_PAY => '已付款',
  470. STORE_JOIN_STATE_VERIFY_SUCCESS => '待付款',
  471. STORE_JOIN_STATE_VERIFY_FAIL => '审核失败',
  472. STORE_JOIN_STATE_PAY_FAIL => '付款审核失败',
  473. STORE_JOIN_STATE_FINAL => '开店成功',
  474. );
  475. return $joinin_state_array;
  476. }
  477. /**
  478. * 店铺续签申请列表
  479. */
  480. public function reopen_listOp(){
  481. $condition = array();
  482. if(intval($_GET['store_id'])) {
  483. $condition['re_store_id'] = intval($_GET['store_id']);
  484. }
  485. if(!empty($_GET['store_name'])) {
  486. $condition['re_store_name'] = $_GET['store_name'];
  487. }
  488. if ($_GET['re_state'] != '') {
  489. $condition['re_state'] = intval($_GET['re_state']);
  490. }
  491. $model_store_reopen = Model('store_reopen');
  492. $reopen_list = $model_store_reopen->getStoreReopenList($condition, 15);
  493. Tpl::output('reopen_list', $reopen_list);
  494. Tpl::output('page',$model_store_reopen->showpage('2'));
  495. Tpl::showpage('store_reopen.list');
  496. }
  497. /**
  498. * 审核店铺续签申请
  499. */
  500. public function reopen_checkOp() {
  501. if (intval($_GET['re_id']) <= 0) exit();
  502. $model_store_reopen = Model('store_reopen');
  503. $condition = array();
  504. $condition['re_id'] = intval($_GET['re_id']);
  505. $condition['re_state'] = 1;
  506. //取当前申请信息
  507. $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
  508. //取目前店铺有效截止日期
  509. $store_info = Model('store')->getStoreInfoByID($reopen_info['re_store_id']);
  510. $data = array();
  511. $data['re_start_time'] = strtotime(date('Y-m-d 0:0:0',$store_info['store_end_time']))+24*3600;
  512. $data['re_end_time'] = strtotime(date('Y-m-d 23:59:59', $data['re_start_time'])." +".intval($reopen_info['re_year'])." year");
  513. $data['re_state'] = 2;
  514. $update = $model_store_reopen->editStoreReopen($data,$condition);
  515. if ($update) {
  516. //更新店铺有效期
  517. Model('store')->editStore(array('store_end_time'=>$data['re_end_time']),array('store_id'=>$reopen_info['re_store_id']));
  518. $msg = '审核通过店铺续签申请,店铺ID:'.$reopen_info['re_store_id'].',续签时间段:'.date('Y-m-d',$data['re_start_time']).' - '.date('Y-m-d',$data['re_end_time']);
  519. $this->log($msg,1);
  520. showMessage('续签成功,店铺有效成功延续到了'.date('Y-m-d',$data['re_end_time']).'日',getReferer());
  521. } else {
  522. showMessage('审核失败',getReferer(),'html','error');
  523. }
  524. }
  525. /**
  526. * 删除店铺续签申请
  527. */
  528. public function reopen_delOp() {
  529. $model_store_reopen = Model('store_reopen');
  530. $condition = array();
  531. $condition['re_id'] = intval($_GET['re_id']);
  532. $condition['re_state'] = array('in',array(0,1));
  533. //取当前申请信息
  534. $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
  535. $cert_file = BASE_UPLOAD_PATH.DS.ATTACH_STORE_JOININ.DS.$reopen_info['re_pay_cert'];
  536. $del = $model_store_reopen->delStoreReopen($condition);
  537. if ($del) {
  538. if (is_file($cert_file)) {
  539. unlink($cert_file);
  540. }
  541. $this->log('删除店铺续签目申请,店铺ID:'.$_GET['re_store_id'],1);
  542. showMessage('删除成功',getReferer());
  543. } else {
  544. showMessage('删除失败',getReferer(),'html','error');
  545. }
  546. }
  547. /**
  548. * 审核详细页
  549. */
  550. public function store_joinin_detailOp(){
  551. $model_store_joinin = Model('store_joinin');
  552. $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_GET['member_id']));
  553. $joinin_detail_title = '查看';
  554. if(in_array(intval($joinin_detail['joinin_state']), array(STORE_JOIN_STATE_NEW, STORE_JOIN_STATE_PAY))) {
  555. $joinin_detail_title = '审核';
  556. }
  557. if (!empty($joinin_detail['sg_info'])) {
  558. $store_grade_info = Model('store_grade')->getOneGrade($joinin_detail['sg_id']);
  559. $joinin_detail['sg_price'] = $store_grade_info['sg_price'];
  560. } else {
  561. $joinin_detail['sg_info'] = @unserialize($joinin_detail['sg_info']);
  562. if (is_array($joinin_detail['sg_info'])) {
  563. $joinin_detail['sg_price'] = $joinin_detail['sg_info']['sg_price'];
  564. }
  565. }
  566. Tpl::output('joinin_detail_title', $joinin_detail_title);
  567. Tpl::output('joinin_detail', $joinin_detail);
  568. Tpl::showpage('store_joinin.detail');
  569. }
  570. /**
  571. * 审核
  572. */
  573. public function store_joinin_verifyOp() {
  574. $model_store_joinin = Model('store_joinin');
  575. $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_POST['member_id']));
  576. switch (intval($joinin_detail['joinin_state'])) {
  577. case STORE_JOIN_STATE_NEW:
  578. $this->store_joinin_verify_pass($joinin_detail);
  579. break;
  580. case STORE_JOIN_STATE_PAY:
  581. $this->store_joinin_verify_open($joinin_detail);
  582. break;
  583. default:
  584. showMessage('参数错误','');
  585. break;
  586. }
  587. }
  588. private function store_joinin_verify_pass($joinin_detail) {
  589. $param = array();
  590. $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_VERIFY_SUCCESS : STORE_JOIN_STATE_VERIFY_FAIL;
  591. $param['joinin_message'] = $_POST['joinin_message'];
  592. $param['paying_amount'] = abs(floatval($_POST['paying_amount']));
  593. $param['store_class_commis_rates'] = implode(',', $_POST['commis_rate']);
  594. $model_store_joinin = Model('store_joinin');
  595. $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
  596. if ($param['paying_amount'] > 0) {
  597. showMessage('店铺入驻申请审核完成','index.php?act=store&op=store_joinin');
  598. } else {
  599. //如果开店支付费用为零,则审核通过后直接开通,无需再上传付款凭证
  600. $this->store_joinin_verify_open($joinin_detail);
  601. }
  602. }
  603. private function store_joinin_verify_open($joinin_detail) {
  604. $model_store_joinin = Model('store_joinin');
  605. $model_store = Model('store');
  606. $model_seller = Model('seller');
  607. //验证卖家用户名是否已经存在
  608. if($model_seller->isSellerExist(array('seller_name' => $joinin_detail['seller_name']))) {
  609. showMessage('卖家用户名已存在','');
  610. }
  611. $param = array();
  612. $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_FINAL : STORE_JOIN_STATE_PAY_FAIL;
  613. $param['joinin_message'] = $_POST['joinin_message'];
  614. $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
  615. if($_POST['verify_type'] === 'pass') {
  616. //开店
  617. $shop_array = array();
  618. $shop_array['member_id'] = $joinin_detail['member_id'];
  619. $shop_array['member_name'] = $joinin_detail['member_name'];
  620. $shop_array['seller_name'] = $joinin_detail['seller_name'];
  621. $shop_array['grade_id'] = $joinin_detail['sg_id'];
  622. $shop_array['store_name'] = $joinin_detail['store_name'];
  623. $shop_array['sc_id'] = $joinin_detail['sc_id'];
  624. $shop_array['store_company_name'] = $joinin_detail['company_name'];
  625. $shop_array['province_id'] = $joinin_detail['company_province_id'];
  626. $shop_array['area_info'] = $joinin_detail['company_address'];
  627. $shop_array['store_address']= $joinin_detail['company_address_detail'];
  628. $shop_array['store_zip'] = '';
  629. $shop_array['store_zy'] = '';
  630. $shop_array['store_state'] = 1;
  631. $shop_array['store_time'] = time();
  632. $shop_array['store_end_time'] = strtotime(date('Y-m-d 23:59:59', strtotime('+1 day'))." +".intval($joinin_detail['joinin_year'])." year");
  633. $shop_array['bind_all_gc'] = 1;
  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. }