12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445 |
- <?php
- /**
- * 店铺管理界面
- *
- **by 好商城V3 www.33hao.com 运营版*/
- ini_set('auto_detect_line_endings', 1);
- defined('InShopNC') or exit('Access Invalid!');
- class storeControl extends SystemControl{
- const EXPORT_SIZE = 1000;
- public function __construct(){
- parent::__construct();
- Language::read('store,store_grade');
- }
- /**
- * 店铺
- */
- public function storeOp(){
- $lang = Language::getLangContent();
- $model_store = Model('store');
- if(trim($_GET['owner_and_name']) != ''){
- $condition['member_name'] = array('like', '%'.$_GET['owner_and_name'].'%');
- Tpl::output('owner_and_name',$_GET['owner_and_name']);
- }
- if(trim($_GET['store_name']) != ''){
- $condition['store_name'] = array('like', '%'.trim($_GET['store_name']).'%');
- Tpl::output('store_name',$_GET['store_name']);
- }
- if(intval($_GET['grade_id']) > 0){
- $condition['grade_id'] = intval($_GET['grade_id']);
- Tpl::output('grade_id',intval($_GET['grade_id']));
- }
- switch ($_GET['store_type']) {
- case 'close':
- $condition['store_state'] = 0;
- break;
- case 'open':
- $condition['store_state'] = 1;
- break;
- case 'expired':
- $condition['store_end_time'] = array('between', array(1, time()));
- $condition['store_state'] = 1;
- break;
- case 'expire':
- $condition['store_end_time'] = array('between', array(time(), time() + 864000));
- $condition['store_state'] = 1;
- break;
- }
- // 默认店铺管理不包含自营店铺
- $condition['is_own_shop'] = 0;
- //店铺列表
- $store_list = $model_store->getStoreList($condition, 10,'store_id desc');
- //店铺等级
- $model_grade = Model('store_grade');
- $grade_list = $model_grade->getGradeList($condition);
- if (!empty($grade_list)){
- $search_grade_list = array();
- foreach ($grade_list as $k => $v){
- $search_grade_list[$v['sg_id']] = $v['sg_name'];
- }
- }
- Tpl::output('search_grade_list', $search_grade_list);
- Tpl::output('grade_list',$grade_list);
- Tpl::output('store_list',$store_list);
- Tpl::output('store_type', $this->_get_store_type_array());
- Tpl::output('page',$model_store->showpage('2'));
- Tpl::showpage('store.index');
- }
- private function _get_store_type_array() {
- return array(
- 'open' => '开启',
- 'close' => '关闭',
- 'expire' => '即将到期',
- 'expired' => '已到期'
- );
- }
- /**
- * 店铺编辑
- */
- public function store_editOp(){
- $lang = Language::getLangContent();
- $model_store = Model('store');
- //保存
- if (chksubmit()){
- //取店铺等级的审核
- $model_grade = Model('store_grade');
- $grade_array = $model_grade->getOneGrade(intval($_POST['grade_id']));
- if (empty($grade_array)){
- showMessage($lang['please_input_store_level']);
- }
- //结束时间
- $time = '';
- if(trim($_POST['end_time']) != ''){
- $time = strtotime($_POST['end_time']);
- }
- $update_array = array();
- $update_array['store_name'] = trim($_POST['store_name']);
- $update_array['sc_id'] = intval($_POST['sc_id']);
- $update_array['grade_id'] = intval($_POST['grade_id']);
- $update_array['store_end_time'] = $time;
- $update_array['store_state'] = intval($_POST['store_state']);
- $update_array['store_baozh'] = trim($_POST['store_baozh']);//保障服务开关
- $update_array['store_baozhopen'] = trim($_POST['store_baozhopen']);//保证金显示开关
- $update_array['store_baozhrmb'] = trim($_POST['store_baozhrmb']);//新加保证金-金额
- $update_array['store_qtian'] = trim($_POST['store_qtian']);//保障服务-七天退换
- $update_array['store_zhping'] = trim($_POST['store_zhping']);//保障服务-正品保证
- $update_array['store_erxiaoshi'] = trim($_POST['store_erxiaoshi']);//保障服务-两小时发货
- $update_array['store_tuihuo'] = trim($_POST['store_tuihuo']);//保障服务-退货承诺
- $update_array['store_shiyong'] = trim($_POST['store_shiyong']);//保障服务-试用
- $update_array['store_xiaoxie'] = trim($_POST['store_xiaoxie']);//保障服务-消协
- $update_array['store_huodaofk'] = trim($_POST['store_huodaofk']);//保障服务-货到付款
- $update_array['store_shiti'] = trim($_POST['store_shiti']);//保障服务-实体店铺
- $update_array['store_type'] = intval($_POST['store_type']);//商家类型
- if ($update_array['store_state'] == 0){
- //根据店铺状态修改该店铺所有商品状态
- $model_goods = Model('goods');
- $model_goods->editProducesOffline(array('store_id' => $_POST['store_id']));
- $update_array['store_close_info'] = trim($_POST['store_close_info']);
- $update_array['store_recommend'] = 0;
- }else {
- //店铺开启后商品不在自动上架,需要手动操作
- $update_array['store_close_info'] = '';
- $update_array['store_recommend'] = intval($_POST['store_recommend']);
- }
- $result = $model_store->editStore($update_array, array('store_id' => $_POST['store_id']));
- if ($result){
- $url = array(
- array(
- 'url'=>'index.php?act=store&op=store',
- 'msg'=>$lang['back_store_list'],
- ),
- array(
- 'url'=>'index.php?act=store&op=store_edit&store_id='.intval($_POST['store_id']),
- 'msg'=>$lang['countinue_add_store'],
- ),
- );
- $this->log(L('nc_edit,store').'['.$_POST['store_name'].']',1);
- showMessage($lang['nc_common_save_succ'],$url);
- }else {
- $this->log(L('nc_edit,store').'['.$_POST['store_name'].']',1);
- showMessage($lang['nc_common_save_fail']);
- }
- }
- //取店铺信息
- $store_array = $model_store->getStoreInfoByID($_GET['store_id']);
- if (empty($store_array)){
- showMessage($lang['store_no_exist']);
- }
- //整理店铺内容
- $store_array['store_end_time'] = $store_array['store_end_time']?date('Y-m-d',$store_array['store_end_time']):'';
- //店铺分类
- $model_store_class = Model('store_class');
- $parent_list = $model_store_class->getStoreClassList(array(),'',false);
- //店铺等级
- $model_grade = Model('store_grade');
- $grade_list = $model_grade->getGradeList();
- Tpl::output('grade_list',$grade_list);
- Tpl::output('class_list',$parent_list);
- Tpl::output('store_array',$store_array);
- $joinin_detail = Model('store_joinin')->getOne(array('member_id'=>$store_array['member_id']));
- Tpl::output('joinin_detail', $joinin_detail);
- Tpl::showpage('store.edit');
- }
- /**
- * 编辑保存注册信息
- */
- public function edit_save_joininOp() {
- if (chksubmit()) {
- $member_id = $_POST['member_id'];
- if ($member_id <= 0) {
- showMessage(L('param_error'));
- }
- $param = array();
- $param['company_name'] = $_POST['company_name'];
- $province_id = intval($_POST['province_id']);
- $city_id = intval($_POST['city_id']);
- if($province_id > 0) {
- $param['company_province_id'] = $province_id;
- }
- if($city_id > 0) {
- $param['company_city_id'] = $city_id;
- }
- $param['company_address'] = $_POST['company_address'];
- $param['company_address_detail'] = $_POST['company_address_detail'];
- $param['company_phone'] = $_POST['company_phone'];
- $param['company_employee_count'] = intval($_POST['company_employee_count']);
- $param['company_registered_capital'] = intval($_POST['company_registered_capital']);
- $param['contacts_name'] = $_POST['contacts_name'];
- $param['contacts_phone'] = $_POST['contacts_phone'];
- $param['contacts_email'] = $_POST['contacts_email'];
- $param['business_licence_number'] = $_POST['business_licence_number'];
- $param['business_licence_address'] = $_POST['business_licence_address'];
- $param['business_licence_start'] = $_POST['business_licence_start'];
- $param['business_licence_end'] = $_POST['business_licence_end'];
- $param['business_sphere'] = $_POST['business_sphere'];
- if ($_FILES['business_licence_number_electronic']['name'] != '') {
- $param['business_licence_number_electronic'] = $this->upload_image('business_licence_number_electronic');
- }
- $param['organization_code'] = $_POST['organization_code'];
- if ($_FILES['organization_code_electronic']['name'] != '') {
- $param['organization_code_electronic'] = $this->upload_image('organization_code_electronic');
- }
- if ($_FILES['general_taxpayer']['name'] != '') {
- $param['general_taxpayer'] = $this->upload_image('general_taxpayer');
- }
- $param['bank_account_name'] = $_POST['bank_account_name'];
- $param['bank_account_number'] = $_POST['bank_account_number'];
- $param['bank_name'] = $_POST['bank_name'];
- $param['bank_code'] = $_POST['bank_code'];
- $param['bank_address'] = $_POST['bank_address'];
- if ($_FILES['bank_licence_electronic']['name'] != '') {
- $param['bank_licence_electronic'] = $this->upload_image('bank_licence_electronic');
- }
- $param['settlement_bank_account_name'] = $_POST['settlement_bank_account_name'];
- $param['settlement_bank_account_number'] = $_POST['settlement_bank_account_number'];
- $param['settlement_bank_name'] = $_POST['settlement_bank_name'];
- $param['settlement_bank_code'] = $_POST['settlement_bank_code'];
- $param['settlement_bank_address'] = $_POST['settlement_bank_address'];
- $param['tax_registration_certificate'] = $_POST['tax_registration_certificate'];
- $param['taxpayer_id'] = $_POST['taxpayer_id'];
- if ($_FILES['tax_registration_certificate_electronic']['name'] != '') {
- $param['tax_registration_certificate_electronic'] = $this->upload_image('tax_registration_certificate_electronic');
- }
- $result = Model('store_joinin')->editStoreJoinin(array('member_id' => $member_id), $param);
- if ($result) {
- //好商城V3-B11 更新店铺信息
- $store_update = array();
- $store_update['store_company_name']=$param['company_name'];
- $store_update['area_info']=$param['company_address'];
- $store_update['store_address']=$param['company_address_detail'];
- if(isset($param['company_province_id'])) {
- $store_update['province_id'] = $param['company_province_id'];
- }
- if(isset($param['company_city_id'])) {
- $store_update['city_id'] = $param['company_city_id'];
- }
- $model_store = Model('store');
- $store_info = $model_store->getStoreInfo(array('member_id'=>$member_id));
- if(!empty($store_info)) {
- $r=$model_store->editStore($store_update, array('member_id'=>$member_id));
- $this->log('编辑店铺信息' . '[ID:' . $r. ']', 1);
- }
- showMessage(L('nc_common_op_succ'), 'index.php?act=store&op=store');
- } else {
- showMessage(L('nc_common_op_fail'));
- }
- }
- }
-
- private function upload_image($file) {
- $pic_name = '';
- $upload = new UploadFile();
- $uploaddir = ATTACH_PATH.DS.'store_joinin'.DS;
- $upload->set('default_dir',$uploaddir);
- $upload->set('allow_type',array('jpg','jpeg','gif','png'));
- if (!empty($_FILES[$file]['name'])){
- $result = $upload->upfile($file);
- if ($result){
- $pic_name = $upload->file_name;
- $upload->file_name = '';
- }
- }
- return $pic_name;
- }
-
- /**
- * 店铺经营类目管理
- */
- public function store_bind_classOp() {
- $store_id = intval($_GET['store_id']);
- $model_store = Model('store');
- $model_store_bind_class = Model('store_bind_class');
- $model_goods_class = Model('goods_class');
- $gc_list = $model_goods_class->getGoodsClassListByParentId(0);
- Tpl::output('gc_list',$gc_list);
- $store_info = $model_store->getStoreInfoByID($store_id);
- if(empty($store_info)) {
- showMessage(L('param_error'),'','','error');
- }
- Tpl::output('store_info', $store_info);
- $store_bind_class_list = $model_store_bind_class->getStoreBindClassList(array('store_id'=>$store_id,'state'=>array('in',array(1,2))), null);
- $goods_class = Model('goods_class')->getGoodsClassIndexedListAll();
- for($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
- $store_bind_class_list[$i]['class_1_name'] = $goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
- $store_bind_class_list[$i]['class_2_name'] = $goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
- $store_bind_class_list[$i]['class_3_name'] = $goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
- }
- Tpl::output('store_bind_class_list', $store_bind_class_list);
- Tpl::showpage('store_bind_class');
- }
- /**
- * 添加经营类目
- */
- public function store_bind_class_addOp() {
- $store_id = intval($_POST['store_id']);
- $commis_rate = intval($_POST['commis_rate']);
- if($commis_rate < 0 || $commis_rate > 100) {
- showMessage(L('param_error'), '');
- }
- list($class_1, $class_2, $class_3) = explode(',', $_POST['goods_class']);
- $model_store_bind_class = Model('store_bind_class');
- $param = array();
- $param['store_id'] = $store_id;
- $param['class_1'] = $class_1;
- $param['state'] = 1;
- if(!empty($class_2)) {
- $param['class_2'] = $class_2;
- }
- if(!empty($class_3)) {
- $param['class_3'] = $class_3;
- }
- // 检查类目是否已经存在
- $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo($param);
- if(!empty($store_bind_class_info)) {
- showMessage('该类目已经存在','','','error');
- }
- $param['commis_rate'] = $commis_rate;
- $result = $model_store_bind_class->addStoreBindClass($param);
- if($result) {
- $this->log('删除店铺经营类目,类目编号:'.$result.',店铺编号:'.$store_id);
- showMessage(L('nc_common_save_succ'), '');
- } else {
- showMessage(L('nc_common_save_fail'), '');
- }
- }
- /**
- * 删除经营类目
- */
- public function store_bind_class_delOp() {
- $bid = intval($_POST['bid']);
- $data = array();
- $data['result'] = true;
- $model_store_bind_class = Model('store_bind_class');
- $model_goods = Model('goods');
- $store_bind_class_info = $model_store_bind_class->getStoreBindClassInfo(array('bid' => $bid));
- if(empty($store_bind_class_info)) {
- $data['result'] = false;
- $data['message'] = '经营类目删除失败';
- echo json_encode($data);die;
- }
- // 商品下架
- $condition = array();
- $condition['store_id'] = $store_bind_class_info['store_id'];
- $gc_id = $store_bind_class_info['class_1'].','.$store_bind_class_info['class_2'].','.$store_bind_class_info['class_3'];
- $update = array();
- $update['goods_stateremark'] = '管理员删除经营类目';
- $condition['gc_id'] = array('in', rtrim($gc_id, ','));
- $model_goods->editProducesLockUp($update, $condition);
- $result = $model_store_bind_class->delStoreBindClass(array('bid'=>$bid));
- if(!$result) {
- $data['result'] = false;
- $data['message'] = '经营类目删除失败';
- }
- $this->log('删除店铺经营类目,类目编号:'.$bid.',店铺编号:'.$store_bind_class_info['store_id']);
- echo json_encode($data);die;
- }
- public function store_bind_class_updateOp() {
- $bid = intval($_GET['id']);
- if($bid <= 0) {
- echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
- die;
- }
- $new_commis_rate = intval($_GET['value']);
- if ($new_commis_rate < 0 || $new_commis_rate >= 100) {
- echo json_encode(array('result'=>FALSE,'message'=>Language::get('param_error')));
- die;
- } else {
- $update = array('commis_rate' => $new_commis_rate);
- $condition = array('bid' => $bid);
- $model_store_bind_class = Model('store_bind_class');
- $result = $model_store_bind_class->editStoreBindClass($update, $condition);
- if($result) {
- $this->log('更新店铺经营类目,类目编号:'.$bid);
- echo json_encode(array('result'=>TRUE));
- die;
- } else {
- echo json_encode(array('result'=>FALSE,'message'=>L('nc_common_op_fail')));
- die;
- }
- }
- }
- /**
- * 店铺 待审核列表
- */
- public function store_joininOp(){
- //店铺列表
- if(!empty($_GET['owner_and_name'])) {
- $condition['member_name'] = array('like','%'.$_GET['owner_and_name'].'%');
- }
- if(!empty($_GET['store_name'])) {
- $condition['store_name'] = array('like','%'.$_GET['store_name'].'%');
- }
- if(!empty($_GET['grade_id']) && intval($_GET['grade_id']) > 0) {
- $condition['sg_id'] = $_GET['grade_id'];
- }
- if(!empty($_GET['joinin_state']) && intval($_GET['joinin_state']) > 0) {
- $condition['joinin_state'] = $_GET['joinin_state'] ;
- } else {
- $condition['joinin_state'] = array('gt',0);
- }
- $model_store_joinin = Model('store_joinin');
- $store_list = $model_store_joinin->getList($condition, 10, 'joinin_state asc');
- Tpl::output('store_list', $store_list);
- Tpl::output('joinin_state_array', $this->get_store_joinin_state());
- //店铺等级
- $model_grade = Model('store_grade');
- $grade_list = $model_grade->getGradeList();
- Tpl::output('grade_list', $grade_list);
- Tpl::output('page',$model_store_joinin->showpage('2'));
- Tpl::showpage('store_joinin');
- }
- /**
- * 经营类目申请列表
- */
- public function store_bind_class_applay_listOp(){
- $condition = array();
- // 不显示自营店铺绑定的类目
- if ($_GET['state'] != '') {
- $condition['state'] = intval($_GET['state']);
- if (!in_array($condition['state'], array('0', '1', )))
- unset($condition['state']);
- } else {
- $condition['state'] = array('in', array('0', '1', ));
- }
- if(intval($_GET['store_id'])) {
- $condition['store_id'] = intval($_GET['store_id']);
- }
- $model_store_bind_class = Model('store_bind_class');
- $store_bind_class_list = $model_store_bind_class->getStoreBindClassList($condition, 15,'state asc,bid desc');
- $goods_class = Model('goods_class')->getGoodsClassIndexedListAll();
- $store_ids = array();
- for($i = 0, $j = count($store_bind_class_list); $i < $j; $i++) {
- $store_bind_class_list[$i]['class_1_name'] = $goods_class[$store_bind_class_list[$i]['class_1']]['gc_name'];
- $store_bind_class_list[$i]['class_2_name'] = $goods_class[$store_bind_class_list[$i]['class_2']]['gc_name'];
- $store_bind_class_list[$i]['class_3_name'] = $goods_class[$store_bind_class_list[$i]['class_3']]['gc_name'];
- $store_ids[] = $store_bind_class_list[$i]['store_id'];
- }
- //取店铺信息
- $model_store = Model('store');
- $store_list = $model_store->getStoreList(array('store_id'=>array('in',$store_ids)),null);
- $bind_store_list = array();
- if (!empty($store_list) && is_array($store_list)) {
- foreach ($store_list as $k => $v) {
- $bind_store_list[$v['store_id']]['store_name'] = $v['store_name'];
- $bind_store_list[$v['store_id']]['seller_name'] = $v['seller_name'];
- }
- }
- Tpl::output('bind_list', $store_bind_class_list);
- Tpl::output('bind_store_list',$bind_store_list);
- Tpl::output('page',$model_store_bind_class->showpage('2'));
- Tpl::showpage('store_bind_class_applay.list');
- }
- /**
- * 审核经营类目申请
- */
- public function store_bind_class_applay_checkOp() {
- $model_store_bind_class = Model('store_bind_class');
- $condition = array();
- $condition['bid'] = intval($_GET['bid']);
- $condition['state'] = 0;
- $update = $model_store_bind_class->editStoreBindClass(array('state'=>1),$condition);
- if ($update) {
- $this->log('审核新经营类目申请,店铺ID:'.$_GET['store_id'],1);
- showMessage('审核成功',getReferer());
- } else {
- showMessage('审核失败',getReferer(),'html','error');
- }
- }
- /**
- * 删除经营类目申请
- */
- public function store_bind_class_applay_delOp() {
- $model_store_bind_class = Model('store_bind_class');
- $condition = array();
- $condition['bid'] = intval($_GET['bid']);
- $del = $model_store_bind_class->delStoreBindClass($condition);
- if ($del) {
- $this->log('删除经营类目,店铺ID:'.$_GET['store_id'],1);
- showMessage('删除成功',getReferer());
- } else {
- showMessage('删除失败',getReferer(),'html','error');
- }
- }
- private function get_store_joinin_state() {
- $joinin_state_array = array(
- STORE_JOIN_STATE_NEW => '新申请',
- STORE_JOIN_STATE_PAY => '已付款',
- STORE_JOIN_STATE_VERIFY_SUCCESS => '待付款',
- STORE_JOIN_STATE_VERIFY_FAIL => '审核失败',
- STORE_JOIN_STATE_PAY_FAIL => '付款审核失败',
- STORE_JOIN_STATE_FINAL => '开店成功',
- );
- return $joinin_state_array;
- }
- /**
- * 店铺续签申请列表
- */
- public function reopen_listOp(){
- $condition = array();
- if(intval($_GET['store_id'])) {
- $condition['re_store_id'] = intval($_GET['store_id']);
- }
- if(!empty($_GET['store_name'])) {
- $condition['re_store_name'] = $_GET['store_name'];
- }
- if ($_GET['re_state'] != '') {
- $condition['re_state'] = intval($_GET['re_state']);
- }
- $model_store_reopen = Model('store_reopen');
- $reopen_list = $model_store_reopen->getStoreReopenList($condition, 15);
- Tpl::output('reopen_list', $reopen_list);
- Tpl::output('page',$model_store_reopen->showpage('2'));
- Tpl::showpage('store_reopen.list');
- }
- /**
- * 审核店铺续签申请
- */
- public function reopen_checkOp() {
- if (intval($_GET['re_id']) <= 0) exit();
- $model_store_reopen = Model('store_reopen');
- $condition = array();
- $condition['re_id'] = intval($_GET['re_id']);
- $condition['re_state'] = 1;
- //取当前申请信息
- $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
- //取目前店铺有效截止日期
- $store_info = Model('store')->getStoreInfoByID($reopen_info['re_store_id']);
- $data = array();
- $data['re_start_time'] = strtotime(date('Y-m-d 0:0:0',$store_info['store_end_time']))+24*3600;
- $data['re_end_time'] = strtotime(date('Y-m-d 23:59:59', $data['re_start_time'])." +".intval($reopen_info['re_year'])." year");
- $data['re_state'] = 2;
- $update = $model_store_reopen->editStoreReopen($data,$condition);
- if ($update) {
- //更新店铺有效期
- Model('store')->editStore(array('store_end_time'=>$data['re_end_time']),array('store_id'=>$reopen_info['re_store_id']));
- $msg = '审核通过店铺续签申请,店铺ID:'.$reopen_info['re_store_id'].',续签时间段:'.date('Y-m-d',$data['re_start_time']).' - '.date('Y-m-d',$data['re_end_time']);
- $this->log($msg,1);
- showMessage('续签成功,店铺有效成功延续到了'.date('Y-m-d',$data['re_end_time']).'日',getReferer());
- } else {
- showMessage('审核失败',getReferer(),'html','error');
- }
- }
- /**
- * 删除店铺续签申请
- */
- public function reopen_delOp() {
- $model_store_reopen = Model('store_reopen');
- $condition = array();
- $condition['re_id'] = intval($_GET['re_id']);
- $condition['re_state'] = array('in',array(0,1));
- //取当前申请信息
- $reopen_info = $model_store_reopen->getStoreReopenInfo($condition);
- $cert_file = BASE_UPLOAD_PATH.DS.ATTACH_STORE_JOININ.DS.$reopen_info['re_pay_cert'];
- $del = $model_store_reopen->delStoreReopen($condition);
- if ($del) {
- if (is_file($cert_file)) {
- unlink($cert_file);
- }
- $this->log('删除店铺续签目申请,店铺ID:'.$_GET['re_store_id'],1);
- showMessage('删除成功',getReferer());
- } else {
- showMessage('删除失败',getReferer(),'html','error');
- }
- }
- /**
- * 审核详细页
- */
- public function store_joinin_detailOp(){
- $model_store_joinin = Model('store_joinin');
- $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_GET['member_id']));
- $joinin_detail_title = '查看';
- if(in_array(intval($joinin_detail['joinin_state']), array(STORE_JOIN_STATE_NEW, STORE_JOIN_STATE_PAY))) {
- $joinin_detail_title = '审核';
- }
- if (!empty($joinin_detail['sg_info'])) {
- $store_grade_info = Model('store_grade')->getOneGrade($joinin_detail['sg_id']);
- $joinin_detail['sg_price'] = $store_grade_info['sg_price'];
- } else {
- $joinin_detail['sg_info'] = @unserialize($joinin_detail['sg_info']);
- if (is_array($joinin_detail['sg_info'])) {
- $joinin_detail['sg_price'] = $joinin_detail['sg_info']['sg_price'];
- }
- }
- Tpl::output('joinin_detail_title', $joinin_detail_title);
- Tpl::output('joinin_detail', $joinin_detail);
- Tpl::showpage('store_joinin.detail');
- }
- /**
- * 审核
- */
- public function store_joinin_verifyOp() {
- $model_store_joinin = Model('store_joinin');
- $joinin_detail = $model_store_joinin->getOne(array('member_id'=>$_POST['member_id']));
- switch (intval($joinin_detail['joinin_state'])) {
- case STORE_JOIN_STATE_NEW:
- $this->store_joinin_verify_pass($joinin_detail);
- break;
- case STORE_JOIN_STATE_PAY:
- $this->store_joinin_verify_open($joinin_detail);
- break;
- default:
- showMessage('参数错误','');
- break;
- }
- }
- private function store_joinin_verify_pass($joinin_detail) {
- $param = array();
- $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_VERIFY_SUCCESS : STORE_JOIN_STATE_VERIFY_FAIL;
- $param['joinin_message'] = $_POST['joinin_message'];
- $param['paying_amount'] = abs(floatval($_POST['paying_amount']));
- $param['store_class_commis_rates'] = implode(',', $_POST['commis_rate']);
- $model_store_joinin = Model('store_joinin');
- $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
- if ($param['paying_amount'] > 0) {
- showMessage('店铺入驻申请审核完成','index.php?act=store&op=store_joinin');
- } else {
- //如果开店支付费用为零,则审核通过后直接开通,无需再上传付款凭证
- $this->store_joinin_verify_open($joinin_detail);
- }
- }
- private function store_joinin_verify_open($joinin_detail) {
- $model_store_joinin = Model('store_joinin');
- $model_store = Model('store');
- $model_seller = Model('seller');
- //验证卖家用户名是否已经存在
- if($model_seller->isSellerExist(array('seller_name' => $joinin_detail['seller_name']))) {
- showMessage('卖家用户名已存在','');
- }
- $param = array();
- $param['joinin_state'] = $_POST['verify_type'] === 'pass' ? STORE_JOIN_STATE_FINAL : STORE_JOIN_STATE_PAY_FAIL;
- $param['joinin_message'] = $_POST['joinin_message'];
- $model_store_joinin->modify($param, array('member_id'=>$_POST['member_id']));
- if($_POST['verify_type'] === 'pass') {
- //开店
- $shop_array = array();
- $shop_array['member_id'] = $joinin_detail['member_id'];
- $shop_array['member_name'] = $joinin_detail['member_name'];
- $shop_array['seller_name'] = $joinin_detail['seller_name'];
- $shop_array['grade_id'] = $joinin_detail['sg_id'];
- $shop_array['store_name'] = $joinin_detail['store_name'];
- $shop_array['sc_id'] = $joinin_detail['sc_id'];
- $shop_array['store_company_name'] = $joinin_detail['company_name'];
- $shop_array['province_id'] = $joinin_detail['company_province_id'];
- $shop_array['city_id'] = $joinin_detail['company_city_id'];
- $shop_array['area_info'] = $joinin_detail['company_address'];
- $shop_array['store_address']= $joinin_detail['company_address_detail'];
- $shop_array['store_zip'] = '';
- $shop_array['store_zy'] = '';
- $shop_array['store_state'] = 1;
- $shop_array['store_time'] = time();
- $shop_array['store_end_time'] = strtotime(date('Y-m-d 23:59:59', strtotime('+1 day'))." +".intval($joinin_detail['joinin_year'])." year");
- $shop_array['bind_all_gc'] = 1;
- $store_id = $model_store->addStore($shop_array);
- QueueClient::push('UpdateSotreLocation',['store_id' => $store_id]);
- if($store_id) {
- //写入卖家账号
- $seller_array = array();
- $seller_array['seller_name'] = $joinin_detail['seller_name'];
- $seller_array['member_id'] = $joinin_detail['member_id'];
- $seller_array['seller_group_id'] = 0;
- $seller_array['store_id'] = $store_id;
- $seller_array['is_admin'] = 1;
- $state = $model_seller->addSeller($seller_array);
- }
- if($state) {
- // 添加相册默认
- $album_model = Model('album');
- $album_arr = array();
- $album_arr['aclass_name'] = Language::get('store_save_defaultalbumclass_name');
- $album_arr['store_id'] = $store_id;
- $album_arr['aclass_des'] = '';
- $album_arr['aclass_sort'] = '255';
- $album_arr['aclass_cover'] = '';
- $album_arr['upload_time'] = time();
- $album_arr['is_default'] = '1';
- $album_model->addClass($album_arr);
- $model = Model();
- //插入店铺扩展表
- $model->table('store_extend')->insert(array('store_id'=>$store_id));
- $msg = Language::get('store_save_create_success');
- //插入店铺绑定分类表
- $store_bind_class_array = array();
- $store_bind_class = unserialize($joinin_detail['store_class_ids']);
- $store_bind_commis_rates = explode(',', $joinin_detail['store_class_commis_rates']);
- for($i=0, $length=count($store_bind_class); $i<$length; $i++) {
- list($class1, $class2, $class3) = explode(',', $store_bind_class[$i]);
- $store_bind_class_array[] = array(
- 'store_id' => $store_id,
- 'commis_rate' => $store_bind_commis_rates[$i],
- 'class_1' => $class1,
- 'class_2' => $class2,
- 'class_3' => $class3,
- 'state' => 1
- );
- }
- $model_store_bind_class = Model('store_bind_class');
- $model_store_bind_class->addStoreBindClassAll($store_bind_class_array);
- showMessage('店铺开店成功','index.php?act=store&op=store_joinin');
- } else {
- showMessage('店铺开店失败','index.php?act=store&op=store_joinin');
- }
- } else {
- showMessage('店铺开店拒绝','index.php?act=store&op=store_joinin');
- }
- }
- /**
- * 提醒续费
- */
- public function remind_renewalOp() {
- $store_id = intval($_GET['store_id']);
- $store_info = Model('store')->getStoreInfoByID($store_id);
- if (!empty($store_info) && $store_info['store_end_time'] < (time() + 864000) && cookie('remindRenewal'.$store_id) == null) {
- // 发送商家消息
- $param = array();
- $param['code'] = 'store_expire';
- $param['store_id'] = intval($_GET['store_id']);
- $param['param'] = array();
- QueueClient::push('sendStoreMsg', $param);
- setNcCookie('remindRenewal'.$store_id, 1, 86400 * 10); // 十天
- showMessage('消息发送成功');
- }
- showMessage('消息发送失败');
- }
- public function delOp()
- {
- $storeId = (int) $_GET['id'];
- $storeModel = model('store');
- $storeArray = $storeModel->field('is_own_shop,store_name')->find($storeId);
- if (empty($storeArray)) {
- showMessage('外驻店铺不存在', '', 'html', 'error');
- }
- if ($storeArray['is_own_shop']) {
- showMessage('不能在此删除自营店铺', '', 'html', 'error');
- }
- $condition = array(
- 'store_id' => $storeId,
- );
- if ((int) model('goods')->getGoodsCount($condition) > 0)
- showMessage('已经发布商品的外驻店铺不能被删除', '', 'html', 'error');
- // 完全删除店铺
- $storeModel->delStoreEntirely($condition);
- $this->log("删除外驻店铺: {$storeArray['store_name']}");
- showMessage('操作成功', getReferer());
- }
- public function newshop_addOp()
- {
- if (chksubmit())
- {
- $memberName = $_POST['member_name'];
- $memberPasswd = (string) $_POST['member_passwd'];
- if (strlen($memberName) < 3 || strlen($memberName) > 15
- || strlen($_POST['seller_name']) < 3 || strlen($_POST['seller_name']) > 15)
- showMessage('账号名称必须是3~15位', '', 'html', 'error');
- if (strlen($memberPasswd) < 6)
- showMessage('登录密码不能短于6位', '', 'html', 'error');
- if (!$this->checkMemberName($memberName))
- showMessage('店主账号已被占用', '', 'html', 'error');
- if (!$this->checkSellerName($_POST['seller_name']))
- showMessage('店主卖家账号名称已被其它店铺占用', '', 'html', 'error');
- try
- {
- $memberId = model('member')->addMember(array(
- 'member_name' => $memberName,
- 'member_passwd' => $memberPasswd,
- 'member_email' => '',
- ));
- }
- catch (Exception $ex)
- {
- showMessage('店主账号新增失败', '', 'html', 'error');
- }
- $storeModel = model('store');
- $saveArray = array();
- $saveArray['store_name'] = $_POST['store_name'];
- $saveArray['member_id'] = $memberId;
- $saveArray['member_name'] = $memberName;
- $saveArray['seller_name'] = $_POST['seller_name'];
- $saveArray['bind_all_gc'] = 1;
- $saveArray['store_state'] = 1;
- $saveArray['store_time'] = time();
- $saveArray['is_own_shop'] = 0;
- $storeId = $storeModel->addStore($saveArray);
- QueueClient::push('UpdateSotreLocation',['store_id' => $storeId]);
- model('seller')->addSeller(array(
- 'seller_name' => $_POST['seller_name'],
- 'member_id' => $memberId,
- 'store_id' => $storeId,
- 'seller_group_id' => 0,
- 'is_admin' => 1,
- ));
- model('store_joinin')->save(array(
- 'seller_name' => $_POST['seller_name'],
- 'store_name' => $_POST['store_name'],
- 'member_name' => $memberName,
- 'member_id' => $memberId,
- 'joinin_state' => 40,
- 'company_province_id' => 0,
- 'sc_bail' => 0,
- 'joinin_year' => 1,
- ));
- // 添加相册默认
- $album_model = Model('album');
- $album_arr = array();
- $album_arr['aclass_name'] = '默认相册';
- $album_arr['store_id'] = $storeId;
- $album_arr['aclass_des'] = '';
- $album_arr['aclass_sort'] = '255';
- $album_arr['aclass_cover'] = '';
- $album_arr['upload_time'] = time();
- $album_arr['is_default'] = '1';
- $album_model->addClass($album_arr);
- //插入店铺扩展表
- $model = Model();
- $model->table('store_extend')->insert(array('store_id'=>$storeId));
- // 删除自营店id缓存
- Model('store')->dropCachedOwnShopIds();
- $this->log("新增外驻店铺: {$saveArray['store_name']}");
- showMessage('操作成功', urlAdmin('store', 'store'));
- return;
- }
- Tpl::showpage('store.newshop.add');
- }
- public function check_seller_nameOp()
- {
- echo json_encode($this->checkSellerName($_GET['seller_name'], $_GET['id']));
- exit;
- }
- private function checkSellerName($sellerName, $storeId = 0)
- {
- // 判断store_joinin是否存在记录
- $count = (int) Model('store_joinin')->getStoreJoininCount(array(
- 'seller_name' => $sellerName,
- ));
- if ($count > 0)
- return false;
- $seller = Model('seller')->getSellerInfo(array(
- 'seller_name' => $sellerName,
- ));
- if (empty($seller))
- return true;
- if (!$storeId)
- return false;
- if ($storeId == $seller['store_id'] && $seller['seller_group_id'] == 0 && $seller['is_admin'] == 1)
- return true;
- return false;
- }
- public function check_member_nameOp()
- {
- echo json_encode($this->checkMemberName($_GET['member_name']));
- exit;
- }
- private function checkMemberName($memberName)
- {
- // 判断store_joinin是否存在记录
- $count = (int) Model('store_joinin')->getStoreJoininCount(array(
- 'member_name' => $memberName,
- ));
- if ($count > 0)
- return false;
- return ! Model('member')->getMemberCount(array(
- 'member_name' => $memberName,
- ));
- }
- /**
- * 验证店铺名称是否存在
- */
- public function ckeck_store_nameOp() {
- /**
- * 实例化卖家模型
- */
- $where = array();
- $where['store_name'] = $_GET['store_name'];
- $where['store_id'] = array('neq', $_GET['store_id']);
- $store_info = Model('store')->getStoreInfo($where);
- if(!empty($store_info['store_name'])) {
- echo 'false';
- } else {
- echo 'true';
- }
- }
- /**
- * 验证店铺名称是否存在
- */
- private function ckeckStoreName($store_name) {
- /**
- * 实例化卖家模型
- */
- $where = array();
- $where['store_name'] = $store_name;
- $store_info = Model('store')->getStoreInfo($where);
- if(!empty($store_info['store_name'])) {
- return false;
- } else {
- return true;
- }
- }
- public function store_importOp(){
- Tpl::showpage('store_import');
- }
- public function store_import_csv_xOp()
- {
- if (isset($_POST['import']))
- {
- $file = $_FILES['csv_stores'];
- $file_type = substr(strstr($file['name'], '.'), 1);
- //上传文件存在判断
- if(empty($file['name'])){
- showMessage('请选择要上传csv的文件!','','html','error');
- }
- // 检查文件格式
- if ($file_type != 'csv') {
- showMessage('文件格式不对,请重新上传!','','html','error');
- exit;
- }
- $delimiter = ";";
- if(isset($_POST['delimiter'])) $delimiter=trim(strval($_POST['delimiter']));
- $handle = @fopen($file['tmp_name'], "r");
- $encoding = $this->get_str_encoding(file_get_contents($file['tmp_name']));
- $result = $this->read_csv($handle, $encoding, $delimiter);
- $rows = count($result);
- if($rows == 0){
- showMessage('没有任何数据!','','html','error');
- exit;
- }
- $scounter = 0;
- for ($i = 0; $i < $rows; $i++) {
- //循环获取各字段值
- $store_name = $result[$i][0];
- $member_name = $result[$i][1];
- $seller_name = $result[$i][2];
- $password = $result[$i][3];
- $store_company_name = $result[$i][4];
- $store_area = $result[$i][5];
- $store_address = $result[$i][6];
- $store_phone = $result[$i][7];
- $store_type = intval($result[$i][8]);
- if(!$this->ckeckStoreName($store_name))
- {
- showMessage("店铺名称 {$member_name} 已存在", '', 'html', 'error');
- return;
- }
- if(!$this->checkMemberName($member_name))
- {
- showMessage("店主账号 {$member_name} 已存在", '', 'html', 'error');
- return;
- }
- if(!$this->checkSellerName($seller_name))
- {
- showMessage("卖家账号 {$member_name} 已存在", '', 'html', 'error');
- return;
- }
- //批量导入数据的所在省份/城市校验
- $pattern = '/(\S+)[\s]*(\S+)*/u';
- $result = preg_match_all($pattern, $store_area, $matches);
- if(!$result) {
- showMessage("{$store_company_name}所在省份/城市无法识别!",'','html','error');
- exit;
- }
- if(count($matches) !== 3) {
- showMessage("{$store_company_name}所在省份/城市识别错误!",'','html','error');
- exit;
- }
- if(empty($match[2][0])) {
- $city_name = $matches[1][0];
- }
- else {
- $city_name = $matches[2][0];
- }
- if($city_name == '北京' || $city_name == '上海' || $city_name == '天津' || $city_name == '重庆') {
- $city_name = $city_name. "市";
- }
- $mod_area = Model('area');
- $info = $mod_area->getAreaInfo(['area_name' => $city_name]);
- if(empty($info)) {
- showMessage("{$store_company_name}所在省份/城市无法识别!",'','html','error');
- exit;
- }
- $city_id = intval($info['area_id']);
- $province_id = intval($info['area_parent_id']);
- try
- {
- $memberId = model('member')->addMember(array(
- 'member_name' => $member_name,
- 'member_passwd' => $password,
- 'member_email' => '',
- ));
- }
- catch (Exception $ex)
- {
- showMessage("店主账号{$member_name}新增失败", '', 'html', 'error');
- return;
- }
- $storeModel = model('store');
- $saveArray = array();
- $saveArray['store_name'] = $store_name;
- $saveArray['grade_id'] = 1;
- $saveArray['member_id'] = $memberId;
- $saveArray['member_name'] = $member_name;
- $saveArray['seller_name'] = $seller_name;
- $saveArray['bind_all_gc'] = 1;
- $saveArray['store_state'] = 1;
- $saveArray['store_time'] = time();
- $saveArray['store_company_name'] = $store_company_name;
- $saveArray['province_id'] = $province_id;
- $saveArray['city_id'] = $city_id;
- $saveArray['area_info'] = $store_area;
- $saveArray['store_address'] = $store_address;
- $saveArray['store_type'] = $store_type;
- $storeId = $storeModel->addStore($saveArray);
- QueueClient::push('UpdateSotreLocation',['store_id' => $storeId]);
- model('seller')->addSeller(array(
- 'seller_name' => $seller_name,
- 'member_id' => $memberId,
- 'store_id' => $storeId,
- 'seller_group_id' => 0,
- 'is_admin' => 1,
- ));
- $store_joinModel = model('store_joinin');
- $save_joinArray = array();
- $save_joinArray['member_id'] = $memberId;
- $save_joinArray['member_name'] = $member_name;
- $save_joinArray['seller_name'] = $seller_name;
- $save_joinArray['store_name'] = $store_name;
- $save_joinArray['company_name'] = $store_company_name;
- $save_joinArray['company_address'] = $store_address;
- $save_joinArray['company_address_detail'] = $store_address;
- $save_joinArray['company_phone']= $store_phone;
- $save_joinArray['store_type'] = $store_type;
- $save_joinArray['joinin_state'] = 40;
- $save_joinArray['company_name'] = $store_company_name;
- $save_joinArray['company_province_id'] = $province_id;
- $save_joinArray['company_city_id'] = $city_id;
- $store_joinModel->save($save_joinArray);
- // 添加相册默认
- $album_model = Model('album');
- $album_arr = array();
- $album_arr['aclass_name'] = '默认相册';
- $album_arr['store_id'] = $storeId;
- $album_arr['aclass_des'] = '';
- $album_arr['aclass_sort'] = '255';
- $album_arr['aclass_cover'] = '';
- $album_arr['upload_time'] = time();
- $album_arr['is_default'] = '1';
- $album_model->addClass($album_arr);
- //插入店铺扩展表
- $model = Model();
- $model->table('store_extend')->insert(array('store_id'=>$storeId));
- $scounter++;
- }
- @fclose($handle); //关闭指针
- showMessage('操作成功,成功导入 '.strval($scounter).' 条数据' , urlAdmin('store', 'store'));
- return;
- }
- }
-
- public function store_import_csvOp()
- {
- if (isset($_POST['import'])) {
- $file = $_FILES['csv_stores'];
- $file_type = substr(strstr($file['name'], '.'), 1);
-
- //上传文件存在判断
- if(empty($file['name'])){
- showMessage('请选择要上传csv的文件!','','html','error');
- }
-
- // 检查文件格式
- if ($file_type != 'csv') {
- showMessage('文件格式不对,请重新上传!','','html','error');
- exit;
- }
- $handle = fopen($file['tmp_name'], "r");
- $result = $this->input_csv($handle); //解析csv
- $rows = count($result);
- if($rows == 0){
- showMessage('没有任何数据!','','html','error');
- exit;
- }
- $scounter = 0;
-
- $storeModel = model('store');
-
- for ($i = 1; $i < $rows; $i++) {
- //循环获取各字段值
- $store_name = iconv('gb2312', 'utf-8', $result[$i][0]);
- $member_name = iconv('gb2312', 'utf-8', $result[$i][1]);
- $seller_name = iconv('gb2312', 'utf-8', $result[$i][2]);
- $password = iconv('gb2312', 'utf-8', $result[$i][3]);
- $store_company_name = iconv('gb2312', 'utf-8', $result[$i][4]);
- $company_name = iconv('gb2312', 'utf-8', $result[$i][5]);
- $company_address = iconv('gb2312', 'utf-8', $result[$i][6]);
- $store_address = iconv('gb2312', 'utf-8', $result[$i][7]);
- $store_zip = iconv('gb2312', 'utf-8', $result[$i][8]);
- $store_qq = iconv('gb2312', 'utf-8', $result[$i][9]);
-
- $store_ww = iconv('gb2312', 'utf-8', $result[$i][10]);
- $store_phone = iconv('gb2312', 'utf-8', $result[$i][11]);
- $company_employee_count = iconv('gb2312', 'utf-8', $result[$i][12]);
- $company_registered_capital = iconv('gb2312', 'utf-8', $result[$i][13]);
- $contacts_name = iconv('gb2312', 'utf-8', $result[$i][14]);
- $contacts_phone = iconv('gb2312', 'utf-8', $result[$i][15]);
- $contacts_email = iconv('gb2312', 'utf-8', $result[$i][16]);
- $business_licence_number = iconv('gb2312', 'utf-8', $result[$i][17]);
- $business_licence_address = iconv('gb2312', 'utf-8', $result[$i][18]);
- $business_licence_start = iconv('gb2312', 'utf-8', $result[$i][19]);
-
- $business_licence_end = iconv('gb2312', 'utf-8', $result[$i][20]);
- $business_sphere = iconv('gb2312', 'utf-8', $result[$i][21]);
- $organization_code = iconv('gb2312', 'utf-8', $result[$i][22]);
- $bank_account_name = iconv('gb2312', 'utf-8', $result[$i][23]);
- $bank_account_number = iconv('gb2312', 'utf-8', $result[$i][24]);
- $bank_name = iconv('gb2312', 'utf-8', $result[$i][25]);
- $bank_code = iconv('gb2312', 'utf-8', $result[$i][26]);
- $bank_address = iconv('gb2312', 'utf-8', $result[$i][27]);
- $is_settlement_account = iconv('gb2312', 'utf-8', $result[$i][28]);
- $settlement_bank_account_name = iconv('gb2312', 'utf-8', $result[$i][29]);
-
- $settlement_bank_account_number = iconv('gb2312', 'utf-8', $result[$i][30]);
- $settlement_bank_name = iconv('gb2312', 'utf-8', $result[$i][31]);
- $settlement_bank_code = iconv('gb2312', 'utf-8', $result[$i][32]);
- $settlement_bank_address = iconv('gb2312', 'utf-8', $result[$i][33]);
- $tax_registration_certificate = iconv('gb2312', 'utf-8', $result[$i][34]);
- $taxpayer_id = iconv('gb2312', 'utf-8', $result[$i][35]);
- $joinin_year = iconv('gb2312', 'utf-8', $result[$i][36]);
- if(!$this->ckeckStoreName($store_name))
- {
- continue;
- }
- if(!$this->checkMemberName($member_name))
- {
- continue;
- }
- if(!$this->checkSellerName($seller_name))
- {
- continue;
- }
- try
- {
- $memberId = model('member')->addMember(array(
- 'member_name' => $member_name,
- 'member_passwd' => $password,
- 'member_email' => '',
- ));
- }
- catch (Exception $ex)
- {
- showMessage('店主账号新增失败', '', 'html', 'error');
- }
-
- $storeModel = model('store');
-
- $saveArray = array();
- $saveArray['store_name'] = $store_name;
- $saveArray['grade_id'] = 1;
- $saveArray['member_id'] = $memberId;
- $saveArray['member_name'] = $member_name;
- $saveArray['seller_name'] = $seller_name;
- $saveArray['bind_all_gc'] = 0;
- $saveArray['store_state'] = 1;
- $saveArray['store_time'] = time();
- $saveArray['store_company_name'] = $store_company_name;
- $saveArray['store_address'] = $store_address;
- $saveArray['store_zip'] = $store_zip;
- $saveArray['store_qq'] = $store_qq;
- $saveArray['store_ww'] = $store_ww;
- $saveArray['store_phone'] = $store_phone;
-
- $storeId = $storeModel->addStore($saveArray);
- QueueClient::push('UpdateSotreLocation',['store_id' => $storeId]);
- model('seller')->addSeller(array(
- 'seller_name' => $seller_name,
- 'member_id' => $memberId,
- 'store_id' => $storeId,
- 'seller_group_id' => 0,
- 'is_admin' => 1,
- ));
- $store_joinModel = model('store_joinin');
- $save_joinArray = array();
- $save_joinArray['member_id'] = $memberId;
- $save_joinArray['member_name'] = $member_name;
- $save_joinArray['company_name'] = $company_name;
- $save_joinArray['company_address'] = $company_address;
- $save_joinArray['company_address_detail'] = $store_address;
- $save_joinArray['company_phone'] = $store_phone;
- $save_joinArray['company_employee_count'] = $company_employee_count;
- $save_joinArray['company_registered_capital'] = $company_registered_capita;
- $save_joinArray['contacts_name'] = $contacts_name;
- $save_joinArray['contacts_phone'] = $contacts_phone;
- $save_joinArray['contacts_email'] = $contacts_email;
- $save_joinArray['business_licence_number'] = $business_licence_number;
- $save_joinArray['business_licence_address'] = $business_licence_address;
- $save_joinArray['business_licence_start'] = $business_licence_start;
- $save_joinArray['business_licence_end'] = $business_licence_end;
- $save_joinArray['business_sphere'] = $business_sphere;
- $save_joinArray['organization_code'] = $organization_code;
- $save_joinArray['general_taxpayer'] = $general_taxpayer;
- $save_joinArray['bank_account_name'] = $bank_account_name;
- $save_joinArray['bank_account_number'] = $bank_account_number;
- $save_joinArray['bank_name'] = $bank_name;
- $save_joinArray['bank_code'] = $bank_code;
- $save_joinArray['bank_address'] = $bank_address;
- $save_joinArray['is_settlement_account'] = $is_settlement_account;
- if($is_settlement_account == '是')
- {
- //2独立
- $save_joinArray['is_settlement_account'] = 2;
- $save_joinArray['settlement_bank_account_name'] = $settlement_bank_account_name;
- $save_joinArray['settlement_bank_account_number'] = $settlement_bank_account_number;
- $save_joinArray['settlement_bank_name'] = $settlement_bank_name;
- $save_joinArray['settlement_bank_code'] = $settlement_bank_code;
- $save_joinArray['settlement_bank_address'] = $settlement_bank_address;
- }
- else
- {
- //1非独立
- $save_joinArray['is_settlement_account'] = 1;
- $save_joinArray['settlement_bank_account_name'] = $bank_account_name;
- $save_joinArray['settlement_bank_account_number'] = $bank_account_number;
- $save_joinArray['settlement_bank_name'] = $bank_name;
- $save_joinArray['settlement_bank_code'] = $bank_code;
- $save_joinArray['settlement_bank_address'] = $bank_address;
- }
- $save_joinArray['tax_registration_certificate'] = $tax_registration_certificate;
- $save_joinArray['taxpayer_id'] = $taxpayer_id;
- $save_joinArray['seller_name'] = $seller_name;
- $save_joinArray['store_name'] = $store_name;
- $save_joinArray['joinin_state'] = 40;
- $save_joinArray['joinin_year'] = $joinin_year;
- $save_joinArray['company_name'] = $company_name;
- $save_joinArray['company_name'] = $company_name;
-
-
- $store_joinModel->save($save_joinArray);
-
- // 添加相册默认
- $album_model = Model('album');
- $album_arr = array();
- $album_arr['aclass_name'] = '默认相册';
- $album_arr['store_id'] = $storeId;
- $album_arr['aclass_des'] = '';
- $album_arr['aclass_sort'] = '255';
- $album_arr['aclass_cover'] = '';
- $album_arr['upload_time'] = time();
- $album_arr['is_default'] = '1';
- $album_model->addClass($album_arr);
- //插入店铺扩展表
- $model = Model();
- $model->table('store_extend')->insert(array('store_id'=>$storeId));
-
- $scounter++;
-
- }
- //$data_values = substr($data_values,0,-1); //去掉最后一个逗号
- fclose($handle); //关闭指针
- showMessage('操作成功,成功导入 '.strval($scounter).' 条数据' , urlAdmin('store', 'store'));
- return;
-
- /*
- $row = 0;
- while ($data = fgetcsv($handle, 10000)) {
- $row++;
- if ($row == 1) continue;
- $num = count($data);
- for ($i = 0; $i < $num; $i++) {
- $t=iconv('gb2312', 'utf-8', $data[$i]);
- echo $t.
- "<br>";
- }
- }
- fclose($handle);
- */
- }
- }
-
- /*
- * 解析csv
- */
- private function input_csv($handle) {
- $out = array ();
- $n = 0;
- while ($data = fgetcsv($handle, 10000)) {
- $num = count($data);
- for ($i = 0; $i < $num; $i++) {
- $out[$n][$i] = $data[$i];
- }
- $n++;
- }
- return $out;
- }
- /**
- * 汽车类商家批量导入解析csv
- */
- private function read_csv($handle, $encoding, $delimeter=";")
- {
- $out = [];
- $n = 0;
- while ($line = @fgets($handle))
- {
- if($n == 0) {
- $n++;
- continue;
- }else{
- $out[] = explode($delimeter, iconv($encoding,'utf-8',trim($line)));
- $n++;
- }
- }
- return $out;
- }
- private function get_str_encoding($str)
- {
- $encoding = mb_detect_encoding($str, ['GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII']);
- return $encoding;
- }
- }
|