store.php 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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. $store_id = $model_store->addStore($shop_array);
  634. if($store_id) {
  635. //写入卖家账号
  636. $seller_array = array();
  637. $seller_array['seller_name'] = $joinin_detail['seller_name'];
  638. $seller_array['member_id'] = $joinin_detail['member_id'];
  639. $seller_array['seller_group_id'] = 0;
  640. $seller_array['store_id'] = $store_id;
  641. $seller_array['is_admin'] = 1;
  642. $state = $model_seller->addSeller($seller_array);
  643. }
  644. if($state) {
  645. // 添加相册默认
  646. $album_model = Model('album');
  647. $album_arr = array();
  648. $album_arr['aclass_name'] = Language::get('store_save_defaultalbumclass_name');
  649. $album_arr['store_id'] = $store_id;
  650. $album_arr['aclass_des'] = '';
  651. $album_arr['aclass_sort'] = '255';
  652. $album_arr['aclass_cover'] = '';
  653. $album_arr['upload_time'] = time();
  654. $album_arr['is_default'] = '1';
  655. $album_model->addClass($album_arr);
  656. $model = Model();
  657. //插入店铺扩展表
  658. $model->table('store_extend')->insert(array('store_id'=>$store_id));
  659. $msg = Language::get('store_save_create_success');
  660. //插入店铺绑定分类表
  661. $store_bind_class_array = array();
  662. $store_bind_class = unserialize($joinin_detail['store_class_ids']);
  663. $store_bind_commis_rates = explode(',', $joinin_detail['store_class_commis_rates']);
  664. for($i=0, $length=count($store_bind_class); $i<$length; $i++) {
  665. list($class1, $class2, $class3) = explode(',', $store_bind_class[$i]);
  666. $store_bind_class_array[] = array(
  667. 'store_id' => $store_id,
  668. 'commis_rate' => $store_bind_commis_rates[$i],
  669. 'class_1' => $class1,
  670. 'class_2' => $class2,
  671. 'class_3' => $class3,
  672. 'state' => 1
  673. );
  674. }
  675. $model_store_bind_class = Model('store_bind_class');
  676. $model_store_bind_class->addStoreBindClassAll($store_bind_class_array);
  677. showMessage('店铺开店成功','index.php?act=store&op=store_joinin');
  678. } else {
  679. showMessage('店铺开店失败','index.php?act=store&op=store_joinin');
  680. }
  681. } else {
  682. showMessage('店铺开店拒绝','index.php?act=store&op=store_joinin');
  683. }
  684. }
  685. /**
  686. * 提醒续费
  687. */
  688. public function remind_renewalOp() {
  689. $store_id = intval($_GET['store_id']);
  690. $store_info = Model('store')->getStoreInfoByID($store_id);
  691. if (!empty($store_info) && $store_info['store_end_time'] < (time() + 864000) && cookie('remindRenewal'.$store_id) == null) {
  692. // 发送商家消息
  693. $param = array();
  694. $param['code'] = 'store_expire';
  695. $param['store_id'] = intval($_GET['store_id']);
  696. $param['param'] = array();
  697. QueueClient::push('sendStoreMsg', $param);
  698. setNcCookie('remindRenewal'.$store_id, 1, 86400 * 10); // 十天
  699. showMessage('消息发送成功');
  700. }
  701. showMessage('消息发送失败');
  702. }
  703. public function delOp()
  704. {
  705. $storeId = (int) $_GET['id'];
  706. $storeModel = model('store');
  707. $storeArray = $storeModel->field('is_own_shop,store_name')->find($storeId);
  708. if (empty($storeArray)) {
  709. showMessage('外驻店铺不存在', '', 'html', 'error');
  710. }
  711. if ($storeArray['is_own_shop']) {
  712. showMessage('不能在此删除自营店铺', '', 'html', 'error');
  713. }
  714. $condition = array(
  715. 'store_id' => $storeId,
  716. );
  717. if ((int) model('goods')->getGoodsCount($condition) > 0)
  718. showMessage('已经发布商品的外驻店铺不能被删除', '', 'html', 'error');
  719. // 完全删除店铺
  720. $storeModel->delStoreEntirely($condition);
  721. $this->log("删除外驻店铺: {$storeArray['store_name']}");
  722. showMessage('操作成功', getReferer());
  723. }
  724. public function newshop_addOp()
  725. {
  726. if (chksubmit())
  727. {
  728. $memberName = $_POST['member_name'];
  729. $memberPasswd = (string) $_POST['member_passwd'];
  730. if (strlen($memberName) < 3 || strlen($memberName) > 15
  731. || strlen($_POST['seller_name']) < 3 || strlen($_POST['seller_name']) > 15)
  732. showMessage('账号名称必须是3~15位', '', 'html', 'error');
  733. if (strlen($memberPasswd) < 6)
  734. showMessage('登录密码不能短于6位', '', 'html', 'error');
  735. if (!$this->checkMemberName($memberName))
  736. showMessage('店主账号已被占用', '', 'html', 'error');
  737. if (!$this->checkSellerName($_POST['seller_name']))
  738. showMessage('店主卖家账号名称已被其它店铺占用', '', 'html', 'error');
  739. try
  740. {
  741. $memberId = model('member')->addMember(array(
  742. 'member_name' => $memberName,
  743. 'member_passwd' => $memberPasswd,
  744. 'member_email' => '',
  745. ));
  746. }
  747. catch (Exception $ex)
  748. {
  749. showMessage('店主账号新增失败', '', 'html', 'error');
  750. }
  751. $storeModel = model('store');
  752. $saveArray = array();
  753. $saveArray['store_name'] = $_POST['store_name'];
  754. $saveArray['member_id'] = $memberId;
  755. $saveArray['member_name'] = $memberName;
  756. $saveArray['seller_name'] = $_POST['seller_name'];
  757. $saveArray['bind_all_gc'] = 1;
  758. $saveArray['store_state'] = 1;
  759. $saveArray['store_time'] = time();
  760. $saveArray['is_own_shop'] = 0;
  761. $storeId = $storeModel->addStore($saveArray);
  762. model('seller')->addSeller(array(
  763. 'seller_name' => $_POST['seller_name'],
  764. 'member_id' => $memberId,
  765. 'store_id' => $storeId,
  766. 'seller_group_id' => 0,
  767. 'is_admin' => 1,
  768. ));
  769. model('store_joinin')->save(array(
  770. 'seller_name' => $_POST['seller_name'],
  771. 'store_name' => $_POST['store_name'],
  772. 'member_name' => $memberName,
  773. 'member_id' => $memberId,
  774. 'joinin_state' => 40,
  775. 'company_province_id' => 0,
  776. 'sc_bail' => 0,
  777. 'joinin_year' => 1,
  778. ));
  779. // 添加相册默认
  780. $album_model = Model('album');
  781. $album_arr = array();
  782. $album_arr['aclass_name'] = '默认相册';
  783. $album_arr['store_id'] = $storeId;
  784. $album_arr['aclass_des'] = '';
  785. $album_arr['aclass_sort'] = '255';
  786. $album_arr['aclass_cover'] = '';
  787. $album_arr['upload_time'] = time();
  788. $album_arr['is_default'] = '1';
  789. $album_model->addClass($album_arr);
  790. //插入店铺扩展表
  791. $model = Model();
  792. $model->table('store_extend')->insert(array('store_id'=>$storeId));
  793. // 删除自营店id缓存
  794. Model('store')->dropCachedOwnShopIds();
  795. $this->log("新增外驻店铺: {$saveArray['store_name']}");
  796. showMessage('操作成功', urlAdmin('store', 'store'));
  797. return;
  798. }
  799. Tpl::showpage('store.newshop.add');
  800. }
  801. public function check_seller_nameOp()
  802. {
  803. echo json_encode($this->checkSellerName($_GET['seller_name'], $_GET['id']));
  804. exit;
  805. }
  806. private function checkSellerName($sellerName, $storeId = 0)
  807. {
  808. // 判断store_joinin是否存在记录
  809. $count = (int) Model('store_joinin')->getStoreJoininCount(array(
  810. 'seller_name' => $sellerName,
  811. ));
  812. if ($count > 0)
  813. return false;
  814. $seller = Model('seller')->getSellerInfo(array(
  815. 'seller_name' => $sellerName,
  816. ));
  817. if (empty($seller))
  818. return true;
  819. if (!$storeId)
  820. return false;
  821. if ($storeId == $seller['store_id'] && $seller['seller_group_id'] == 0 && $seller['is_admin'] == 1)
  822. return true;
  823. return false;
  824. }
  825. public function check_member_nameOp()
  826. {
  827. echo json_encode($this->checkMemberName($_GET['member_name']));
  828. exit;
  829. }
  830. private function checkMemberName($memberName)
  831. {
  832. // 判断store_joinin是否存在记录
  833. $count = (int) Model('store_joinin')->getStoreJoininCount(array(
  834. 'member_name' => $memberName,
  835. ));
  836. if ($count > 0)
  837. return false;
  838. return ! Model('member')->getMemberCount(array(
  839. 'member_name' => $memberName,
  840. ));
  841. }
  842. /**
  843. * 验证店铺名称是否存在
  844. */
  845. public function ckeck_store_nameOp() {
  846. /**
  847. * 实例化卖家模型
  848. */
  849. $where = array();
  850. $where['store_name'] = $_GET['store_name'];
  851. $where['store_id'] = array('neq', $_GET['store_id']);
  852. $store_info = Model('store')->getStoreInfo($where);
  853. if(!empty($store_info['store_name'])) {
  854. echo 'false';
  855. } else {
  856. echo 'true';
  857. }
  858. }
  859. /**
  860. * 验证店铺名称是否存在
  861. */
  862. private function ckeckStoreName($store_name) {
  863. /**
  864. * 实例化卖家模型
  865. */
  866. $where = array();
  867. $where['store_name'] = $store_name;
  868. $store_info = Model('store')->getStoreInfo($where);
  869. if(!empty($store_info['store_name'])) {
  870. return false;
  871. } else {
  872. return true;
  873. }
  874. }
  875. public function store_importOp(){
  876. Tpl::showpage('store_import');
  877. }
  878. public function store_import_csvOp(){
  879. if (isset($_POST['import'])) {
  880. $file = $_FILES['csv_stores'];
  881. $file_type = substr(strstr($file['name'], '.'), 1);
  882. //上传文件存在判断
  883. if(empty($file['name'])){
  884. showMessage('请选择要上传csv的文件!','','html','error');
  885. }
  886. // 检查文件格式
  887. if ($file_type != 'csv') {
  888. showMessage('文件格式不对,请重新上传!','','html','error');
  889. exit;
  890. }
  891. $handle = fopen($file['tmp_name'], "r");
  892. $result = $this->input_csv($handle); //解析csv
  893. $rows = count($result);
  894. if($rows == 0){
  895. showMessage('没有任何数据!','','html','error');
  896. exit;
  897. }
  898. $scounter = 0;
  899. $storeModel = model('store');
  900. for ($i = 1; $i < $rows; $i++) {
  901. //循环获取各字段值
  902. $store_name = iconv('gb2312', 'utf-8', $result[$i][0]);
  903. $member_name = iconv('gb2312', 'utf-8', $result[$i][1]);
  904. $seller_name = iconv('gb2312', 'utf-8', $result[$i][2]);
  905. $password = iconv('gb2312', 'utf-8', $result[$i][3]);
  906. $store_company_name = iconv('gb2312', 'utf-8', $result[$i][4]);
  907. $company_name = iconv('gb2312', 'utf-8', $result[$i][5]);
  908. $company_address = iconv('gb2312', 'utf-8', $result[$i][6]);
  909. $store_address = iconv('gb2312', 'utf-8', $result[$i][7]);
  910. $store_zip = iconv('gb2312', 'utf-8', $result[$i][8]);
  911. $store_qq = iconv('gb2312', 'utf-8', $result[$i][9]);
  912. $store_ww = iconv('gb2312', 'utf-8', $result[$i][10]);
  913. $store_phone = iconv('gb2312', 'utf-8', $result[$i][11]);
  914. $company_employee_count = iconv('gb2312', 'utf-8', $result[$i][12]);
  915. $company_registered_capital = iconv('gb2312', 'utf-8', $result[$i][13]);
  916. $contacts_name = iconv('gb2312', 'utf-8', $result[$i][14]);
  917. $contacts_phone = iconv('gb2312', 'utf-8', $result[$i][15]);
  918. $contacts_email = iconv('gb2312', 'utf-8', $result[$i][16]);
  919. $business_licence_number = iconv('gb2312', 'utf-8', $result[$i][17]);
  920. $business_licence_address = iconv('gb2312', 'utf-8', $result[$i][18]);
  921. $business_licence_start = iconv('gb2312', 'utf-8', $result[$i][19]);
  922. $business_licence_end = iconv('gb2312', 'utf-8', $result[$i][20]);
  923. $business_sphere = iconv('gb2312', 'utf-8', $result[$i][21]);
  924. $organization_code = iconv('gb2312', 'utf-8', $result[$i][22]);
  925. $bank_account_name = iconv('gb2312', 'utf-8', $result[$i][23]);
  926. $bank_account_number = iconv('gb2312', 'utf-8', $result[$i][24]);
  927. $bank_name = iconv('gb2312', 'utf-8', $result[$i][25]);
  928. $bank_code = iconv('gb2312', 'utf-8', $result[$i][26]);
  929. $bank_address = iconv('gb2312', 'utf-8', $result[$i][27]);
  930. $is_settlement_account = iconv('gb2312', 'utf-8', $result[$i][28]);
  931. $settlement_bank_account_name = iconv('gb2312', 'utf-8', $result[$i][29]);
  932. $settlement_bank_account_number = iconv('gb2312', 'utf-8', $result[$i][30]);
  933. $settlement_bank_name = iconv('gb2312', 'utf-8', $result[$i][31]);
  934. $settlement_bank_code = iconv('gb2312', 'utf-8', $result[$i][32]);
  935. $settlement_bank_address = iconv('gb2312', 'utf-8', $result[$i][33]);
  936. $tax_registration_certificate = iconv('gb2312', 'utf-8', $result[$i][34]);
  937. $taxpayer_id = iconv('gb2312', 'utf-8', $result[$i][35]);
  938. $joinin_year = iconv('gb2312', 'utf-8', $result[$i][36]);
  939. if(!$this->ckeckStoreName($store_name))
  940. {
  941. continue;
  942. }
  943. if(!$this->checkMemberName($member_name))
  944. {
  945. continue;
  946. }
  947. if(!$this->checkSellerName($seller_name))
  948. {
  949. continue;
  950. }
  951. try
  952. {
  953. $memberId = model('member')->addMember(array(
  954. 'member_name' => $member_name,
  955. 'member_passwd' => $password,
  956. 'member_email' => '',
  957. ));
  958. }
  959. catch (Exception $ex)
  960. {
  961. showMessage('店主账号新增失败', '', 'html', 'error');
  962. }
  963. $storeModel = model('store');
  964. $saveArray = array();
  965. $saveArray['store_name'] = $store_name;
  966. $saveArray['grade_id'] = 1;
  967. $saveArray['member_id'] = $memberId;
  968. $saveArray['member_name'] = $member_name;
  969. $saveArray['seller_name'] = $seller_name;
  970. $saveArray['bind_all_gc'] = 0;
  971. $saveArray['store_state'] = 1;
  972. $saveArray['store_time'] = time();
  973. $saveArray['store_company_name'] = $store_company_name;
  974. $saveArray['store_address'] = $store_address;
  975. $saveArray['store_zip'] = $store_zip;
  976. $saveArray['store_qq'] = $store_qq;
  977. $saveArray['store_ww'] = $store_ww;
  978. $saveArray['store_phone'] = $store_phone;
  979. $storeId = $storeModel->addStore($saveArray);
  980. model('seller')->addSeller(array(
  981. 'seller_name' => $seller_name,
  982. 'member_id' => $memberId,
  983. 'store_id' => $storeId,
  984. 'seller_group_id' => 0,
  985. 'is_admin' => 1,
  986. ));
  987. $store_joinModel = model('store_joinin');
  988. $save_joinArray = array();
  989. $save_joinArray['member_id'] = $memberId;
  990. $save_joinArray['member_name'] = $member_name;
  991. $save_joinArray['company_name'] = $company_name;
  992. $save_joinArray['company_address'] = $company_address;
  993. $save_joinArray['company_address_detail'] = $store_address;
  994. $save_joinArray['company_phone'] = $store_phone;
  995. $save_joinArray['company_employee_count'] = $company_employee_count;
  996. $save_joinArray['company_registered_capital'] = $company_registered_capita;
  997. $save_joinArray['contacts_name'] = $contacts_name;
  998. $save_joinArray['contacts_phone'] = $contacts_phone;
  999. $save_joinArray['contacts_email'] = $contacts_email;
  1000. $save_joinArray['business_licence_number'] = $business_licence_number;
  1001. $save_joinArray['business_licence_address'] = $business_licence_address;
  1002. $save_joinArray['business_licence_start'] = $business_licence_start;
  1003. $save_joinArray['business_licence_end'] = $business_licence_end;
  1004. $save_joinArray['business_sphere'] = $business_sphere;
  1005. $save_joinArray['organization_code'] = $organization_code;
  1006. $save_joinArray['general_taxpayer'] = $general_taxpayer;
  1007. $save_joinArray['bank_account_name'] = $bank_account_name;
  1008. $save_joinArray['bank_account_number'] = $bank_account_number;
  1009. $save_joinArray['bank_name'] = $bank_name;
  1010. $save_joinArray['bank_code'] = $bank_code;
  1011. $save_joinArray['bank_address'] = $bank_address;
  1012. $save_joinArray['is_settlement_account'] = $is_settlement_account;
  1013. if($is_settlement_account == '是')
  1014. {
  1015. //2独立
  1016. $save_joinArray['is_settlement_account'] = 2;
  1017. $save_joinArray['settlement_bank_account_name'] = $settlement_bank_account_name;
  1018. $save_joinArray['settlement_bank_account_number'] = $settlement_bank_account_number;
  1019. $save_joinArray['settlement_bank_name'] = $settlement_bank_name;
  1020. $save_joinArray['settlement_bank_code'] = $settlement_bank_code;
  1021. $save_joinArray['settlement_bank_address'] = $settlement_bank_address;
  1022. }
  1023. else
  1024. {
  1025. //1非独立
  1026. $save_joinArray['is_settlement_account'] = 1;
  1027. $save_joinArray['settlement_bank_account_name'] = $bank_account_name;
  1028. $save_joinArray['settlement_bank_account_number'] = $bank_account_number;
  1029. $save_joinArray['settlement_bank_name'] = $bank_name;
  1030. $save_joinArray['settlement_bank_code'] = $bank_code;
  1031. $save_joinArray['settlement_bank_address'] = $bank_address;
  1032. }
  1033. $save_joinArray['tax_registration_certificate'] = $tax_registration_certificate;
  1034. $save_joinArray['taxpayer_id'] = $taxpayer_id;
  1035. $save_joinArray['seller_name'] = $seller_name;
  1036. $save_joinArray['store_name'] = $store_name;
  1037. $save_joinArray['joinin_state'] = 40;
  1038. $save_joinArray['joinin_year'] = $joinin_year;
  1039. $save_joinArray['company_name'] = $company_name;
  1040. $save_joinArray['company_name'] = $company_name;
  1041. $store_joinModel->save($save_joinArray);
  1042. // 添加相册默认
  1043. $album_model = Model('album');
  1044. $album_arr = array();
  1045. $album_arr['aclass_name'] = '默认相册';
  1046. $album_arr['store_id'] = $storeId;
  1047. $album_arr['aclass_des'] = '';
  1048. $album_arr['aclass_sort'] = '255';
  1049. $album_arr['aclass_cover'] = '';
  1050. $album_arr['upload_time'] = time();
  1051. $album_arr['is_default'] = '1';
  1052. $album_model->addClass($album_arr);
  1053. //插入店铺扩展表
  1054. $model = Model();
  1055. $model->table('store_extend')->insert(array('store_id'=>$storeId));
  1056. $scounter++;
  1057. }
  1058. //$data_values = substr($data_values,0,-1); //去掉最后一个逗号
  1059. fclose($handle); //关闭指针
  1060. showMessage('操作成功,成功导入 '.strval($scounter).' 条数据' , urlAdmin('store', 'store'));
  1061. return;
  1062. /*
  1063. $row = 0;
  1064. while ($data = fgetcsv($handle, 10000)) {
  1065. $row++;
  1066. if ($row == 1) continue;
  1067. $num = count($data);
  1068. for ($i = 0; $i < $num; $i++) {
  1069. $t=iconv('gb2312', 'utf-8', $data[$i]);
  1070. echo $t.
  1071. "<br>";
  1072. }
  1073. }
  1074. fclose($handle);
  1075. */
  1076. }
  1077. }
  1078. /*
  1079. * 解析csv
  1080. */
  1081. private function input_csv($handle) {
  1082. $out = array ();
  1083. $n = 0;
  1084. while ($data = fgetcsv($handle, 10000)) {
  1085. $num = count($data);
  1086. for ($i = 0; $i < $num; $i++) {
  1087. $out[$n][$i] = $data[$i];
  1088. }
  1089. $n++;
  1090. }
  1091. return $out;
  1092. }
  1093. }