123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- class Sellerjoinin extends MobileMember
- {
- private $joinin_detail = NULL;
- public function initialize()
- {
- parent::initialize();
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerjoinin.lang.php');
- $storejoinin_model = model('storejoinin');
- $this->joinin_detail = $storejoinin_model->getOneStorejoinin(array('member_id' => $this->member_info['member_id']));
- $store_joinin_open = config('ds_config.store_joinin_open');
- if (!$this->joinin_detail || !$this->joinin_detail['joinin_state']) {
- if ($store_joinin_open == 0) {
- ds_json_encode(10001, lang('store_joinin_close'));
- }
- }
- }
-
- public function get_info()
- {
- $storejoinin_model = model('storejoinin');
- $joinin_detail = $this->joinin_detail;
- if ($joinin_detail) {
- $store_class_names = unserialize($joinin_detail['store_class_names']);
- $store_class_ids = unserialize($joinin_detail['store_class_ids']);
- $joinin_detail['store_class_names'] = $store_class_names ? $store_class_names : array();
- $joinin_detail['store_class_ids'] = $store_class_ids ? $store_class_ids : array();
- $joinin_detail['store_class_commis_rates'] = explode(',', $joinin_detail['store_class_commis_rates']);
- if ($joinin_detail['business_licence_number_electronic']) {
- $joinin_detail['business_licence_number_electronic_url'] = get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic']);
- }
- if ($joinin_detail['business_author_letter']) {
- $joinin_detail['business_author_letter'] = get_store_joinin_imageurl($joinin_detail['business_author_letter']);
- }
- if (!empty($joinin_detail['sg_info'])) {
- $store_grade_info = model('storegrade')->getOneStoregrade($joinin_detail['storegrade_id']);
- $joinin_detail['storegrade_price'] = $store_grade_info['storegrade_price'];
- } else {
- $joinin_detail['sg_info'] = @unserialize($joinin_detail['sg_info']);
- if (is_array($joinin_detail['sg_info'])) {
- $joinin_detail['storegrade_price'] = $joinin_detail['sg_info']['storegrade_price'];
- }
- }
- if ($joinin_detail['joinin_state'] == STORE_JOIN_STATE_VERIFY_SUCCESS) {
- $joinin_detail['member_available_pd'] = $this->member_info['available_predeposit'];
- $joinin_detail['member_available_rcb'] = $this->member_info['available_rc_balance'];
- $joinin_detail['member_paypwd'] = true;
- if (empty($this->member_info['member_paypwd'])) {
- $joinin_detail['member_paypwd'] = false;
- }
- $joinin_detail['pay_amount'] = round($joinin_detail['paying_amount'] - $joinin_detail['pd_amount'] - $joinin_detail['rcb_amount'], 2);
- }
- }
- ds_json_encode(10000, '', array('store_joinin' => $joinin_detail));
- }
-
- public function step2()
- {
- $param = array();
- $param['member_name'] = $this->member_info['member_name'];
- $param['store_type'] = input('post.store_type');
- $param['company_name'] = input('post.company_name');
- $param['store_longitude'] = input('post.store_longitude');
- $param['store_latitude'] = input('post.store_latitude');
- $param['company_province_id'] = intval(input('post.company_province_id'));
- $param['company_address'] = input('post.company_address');
- $param['company_address_detail'] = input('post.company_address_detail');
- $param['company_registered_capital'] = intval(input('post.company_registered_capital'));
- $param['contacts_name'] = input('post.contacts_name');
- $param['contacts_phone'] = input('post.contacts_phone');
- $param['contacts_email'] = input('post.contacts_email');
- $param['business_licence_number'] = input('post.business_licence_number');
- $param['business_licence_address'] = input('post.business_licence_address');
- $param['business_licence_start'] = input('post.business_licence_start');
- $param['business_licence_end'] = input('post.business_licence_end');
- $param['business_sphere'] = input('post.business_sphere');
- $param['business_licence_number_electronic'] = input('post.business_licence_number_electronic');
- $param['business_author_letter'] = input('post.business_author_letter');
- $this->step2_save_valid($param);
-
- if ($param['store_type'] == 0) {
- if (empty($param['business_licence_number_electronic'])) {
- ds_json_encode(10001,'请上传营业执照电子版');
- }
- if (empty($param['business_author_letter'])) {
- ds_json_encode(10001,'请上企业授权书照片');
- }
- $res = $this->getCompanyInfo($param['business_licence_number_electronic']);
- if ($res['code'] == 200) {
- $info = $res['data'];
- $info['capital'] = cn2num($info['capital'])/10000;
- if ($info['capital'] != $param['company_registered_capital']) {
- ds_json_encode(10001,'填写注册资金与营业执照不匹配,请仔细核对后提交');
- }
- if ($info['company'] != $param['company_name']) {
- ds_json_encode(10001,'填写企业名称与营业执照不匹配,请仔细核对后提交');
- }
- if ($info['reg_num'] != strtoupper($param['business_licence_number'])) {
- ds_json_encode(10001,'填写营业执照号与营业执照不匹配,请仔细核对后提交');
- }
- } else {
- ds_json_encode(10001,$res['msg']);
- }
- }
- if ($param['store_type'] == 1) {
- if (empty($param['business_licence_number_electronic'])) {
- ds_json_encode(10001,'请上传身份证正面照片');
- }
- if (empty($param['business_author_letter'])) {
- ds_json_encode(10001,'请上传身份证背面照片');
- }
- $res = $this->getIdCardInfo2($param);
- if ($res['code'] == 200) {
- $info = $res['data'];
- if ($param['business_licence_number'] != $info['idcard'] || $param['contacts_name'] !== $info['name']) {
- ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
- }
- } else {
- ds_json_encode(10001,$res['msg']);
- }
- }
- $storejoinin_model = model('storejoinin');
- if (empty($this->joinin_detail)) {
- $param['member_id'] = $this->member_info['member_id'];
- $storejoinin_model->addStorejoinin($param);
- } else {
- $storejoinin_model->editStorejoinin($param, array('member_id' => $this->member_info['member_id']));
- }
- ds_json_encode(10000);
- }
- private function step2_save_valid($param)
- {
- $sellerjoinin_validate = ds_validate('sellerjoinin');
- if (!$sellerjoinin_validate->scene(input('post.store_type') ? 'step2_save_valid2' : 'step2_save_valid')->check($param)) {
- ds_json_encode(10001, $sellerjoinin_validate->getError());
- }
- }
-
- public function step3()
- {
- $param = array();
- if (input('post.store_type')) {
- $param['settlement_bank_account_name'] = input('post.settlement_bank_account_name');
- $param['settlement_bank_account_number'] = input('post.settlement_bank_account_number');
- } else {
- $param['bank_account_name'] = input('post.bank_account_name');
- $param['bank_account_number'] = input('post.bank_account_number');
- $param['bank_name'] = input('post.bank_name');
- $param['bank_address'] = input('post.bank_address');
- $is_settlement_account = input('post.is_settlement_account');
- if (!empty($is_settlement_account)) {
- $param['is_settlement_account'] = 1;
- $param['settlement_bank_account_name'] = input('post.bank_account_name');
- $param['settlement_bank_account_number'] = input('post.bank_account_number');
- $param['settlement_bank_name'] = input('post.bank_name');
- $param['settlement_bank_address'] = input('post.bank_address');
- } else {
- $param['is_settlement_account'] = 2;
- $param['settlement_bank_account_name'] = input('post.settlement_bank_account_name');
- $param['settlement_bank_account_number'] = input('post.settlement_bank_account_number');
- $param['settlement_bank_name'] = input('post.settlement_bank_name');
- $param['settlement_bank_address'] = input('post.settlement_bank_address');
- }
- }
- $this->step3_save_valid($param);
- $storejoinin_model = model('storejoinin');
- $storejoinin_model->editStorejoinin($param, array('member_id' => $this->member_info['member_id']));
- ds_json_encode(10000);
- }
- private function step3_save_valid($param)
- {
- $sellerjoinin_validate = ds_validate('sellerjoinin');
- if (!$sellerjoinin_validate->scene(input('post.store_type') ? 'step3_save_valid3' : 'step3_save_valid')->check($param)) {
- ds_json_encode(10001, $sellerjoinin_validate->getError());
- }
- }
-
- public function step4()
- {
- $store_class_ids = array();
- $store_class_names = array();
- $store_class_ids_array = input('post.store_class_ids/a');
- if (!empty($store_class_ids_array)) {
- foreach ($store_class_ids_array as $value) {
- $store_class_ids[] = $value;
- }
- }
- $store_class_names_array = input('post.store_class_names/a');
- if (!empty($store_class_names_array)) {
- foreach ($store_class_names_array as $value) {
- if (empty($value)) {
- continue;
- } else {
- $store_class_names[] = $value;
- }
- }
- }
-
- $sc_ids = array();
- foreach ($store_class_ids as $v) {
- $v = explode(',', trim($v, ','));
- if (!empty($v) && is_array($v)) {
- $sc_ids[] = end($v);
- }
- }
- $store_class_commis_rates = array();
- if (!empty($sc_ids)) {
- $goods_class_list = model('goodsclass')->getGoodsclassListByIds($sc_ids);
- if (!empty($goods_class_list) && is_array($goods_class_list)) {
- $sc_ids = array();
- foreach ($goods_class_list as $v) {
- $store_class_commis_rates[] = $v['commis_rate'];
- }
- }
- }
- $param = array();
- $param['store_type'] = input('post.store_type');
- $param['seller_name'] = $this->member_info['member_name'];
- $param['store_name'] = trim(input('post.store_name'));
- $param['store_class_ids'] = serialize($store_class_ids);
- $param['store_class_names'] = serialize($store_class_names);
- $param['joinin_year'] = intval(input('post.joinin_year'));
- $param['joinin_state'] = STORE_JOIN_STATE_NEW;
- $param['store_class_commis_rates'] = implode(',', $store_class_commis_rates);
-
- $grade_list = rkcache('storegrade', true);
- $storegrade_id = intval(input('post.storegrade_id'));
- if ($storegrade_id <= 0) {
- ds_json_encode(10001, lang('select_store_level'));
- }
- if (!empty($grade_list[$storegrade_id])) {
- $param['storegrade_id'] = $storegrade_id;
- $param['storegrade_name'] = $grade_list[$storegrade_id]['storegrade_name'];
- $param['sg_info'] = serialize(array('storegrade_price' => $grade_list[$storegrade_id]['storegrade_price']));
- }
-
- $storeclass_id = intval(input('post.storeclass_id'));
- if ($storeclass_id <= 0) {
- ds_json_encode(10001, lang('select_store_category'));
- }
- $store_class_info = model('storeclass')->getStoreclassInfo(array('storeclass_id' => $storeclass_id));
- if ($store_class_info) {
- $param['storeclass_id'] = $store_class_info['storeclass_id'];
- $param['storeclass_name'] = $store_class_info['storeclass_name'];
- $param['storeclass_bail'] = $store_class_info['storeclass_bail'];
- }
-
- $param['paying_amount'] = floatval($grade_list[$storegrade_id]['storegrade_price']) * $param['joinin_year'] + floatval($param['storeclass_bail']);
- $this->step4_save_valid($param);
- $storejoinin_model = model('storejoinin');
- $storejoinin_model->editStorejoinin($param, array('member_id' => $this->member_info['member_id']));
- ds_json_encode(10000);
- }
- private function step4_save_valid($param)
- {
- $sellerjoinin_validate = ds_validate('sellerjoinin');
- if (!$sellerjoinin_validate->scene(input('post.store_type') ? 'step4_save_valid4' : 'step4_save_valid')->check($param)) {
- ds_json_encode(10001, $sellerjoinin_validate->getError());
- }
- }
-
- public function pay_save()
- {
- $param = array();
- $param['paying_money_certificate'] = input('post.paying_money_certificate');
- $param['paying_money_certificate_explain'] = input('post.paying_money_certificate_explain');
- $param['joinin_state'] = STORE_JOIN_STATE_PAY;
- if (empty($param['paying_money_certificate'])) {
- ds_json_encode(10001, lang('paying_money_certificate_empty'));
- }
- $storejoinin_model = model('storejoinin');
- $storejoinin_model->editStorejoinin($param, array('member_id' => $this->member_info['member_id']));
- ds_json_encode(10000);
- }
-
- public function upload_image()
- {
- $file = 'file';
-
- $pic_name = '';
- if (!empty($_FILES[$file]['name'])) {
-
- $file_name = $this->member_info['member_id'] . '_' . date('YmdHis') . rand(10000, 99999) . '.png';
- $res = ds_upload_pic('home' . DIRECTORY_SEPARATOR . 'store_joinin', $file, $file_name);
- if ($res['code']) {
- $pic_name = $res['data']['file_name'];
- } else {
- ds_json_encode(10001, $res['msg']);
- }
- }
- ds_json_encode(10000, '', array('path' => $pic_name, 'url' => get_store_joinin_imageurl($pic_name)));
- }
- }
|