diff --git a/application/admin/controller/general/Profile.php b/application/admin/controller/general/Profile.php
index 02a786e..47c4ff2 100644
--- a/application/admin/controller/general/Profile.php
+++ b/application/admin/controller/general/Profile.php
@@ -5,6 +5,7 @@ namespace app\admin\controller\general;
use app\admin\model\Admin;
use app\common\controller\Backend;
use fast\Random;
+use think\Db;
use think\Session;
use think\Validate;
@@ -70,10 +71,17 @@ class Profile extends Backend
// $this->error(__("Email already exists"));
// }
if ($params) {
- $admin = Admin::get($this->auth->id);
+ $admin = Session::get('admin')?Session::get('admin'):Session::get('member');
+ if(!$admin){
+ $this->redirect('index/register', [], 302);
+ }
+
+ $admin = Admin::get($admin['id']);
$admin->save($params);
//因为个人资料面板读取的Session显示,修改自己资料后同时更新Session
- Session::set("admin", $admin->toArray());
+// Session::set("admin", $admin->toArray());
+ $adminInfo = Db::name("admin")->where('id','=',$this->auth->id)->find();
+ Session::set("admin", $adminInfo);
$this->success();
}
$this->error();
diff --git a/application/admin/controller/qingdong/customer/Customer.php b/application/admin/controller/qingdong/customer/Customer.php
index bd07123..ae38a45 100644
--- a/application/admin/controller/qingdong/customer/Customer.php
+++ b/application/admin/controller/qingdong/customer/Customer.php
@@ -32,6 +32,7 @@ use addons\qingdong\model\Business;
use PhpOffice\PhpWord\TemplateProcessor;
use PhpOffice\PhpWord\Settings;
use think\Db;
+use think\Env;
use think\Exception;
/**
@@ -1515,4 +1516,114 @@ class Customer extends Base
return $this->view->fetch();
}
+ public function getImgInfo(){
+ $result = [
+ "business_name" => '',
+ "business_range" => '',
+ "business_legal" => '',
+ "business_social" => '',
+ "business_establish" => '',
+ "business_address" => '',
+ "business_type" => '',
+ ];
+
+ $file = input('url', '');
+ if($file == ""){
+ return json($result);
+ }
+
+ $token = cache("baidu_api_token");
+ if(!$token){
+ $resStr = $this->get_token();
+ $res = json_decode($resStr,true);
+ $token = $res['access_token'];
+ $expires_in = $res['expires_in'];
+ cache("baidu_api_token",$token,$expires_in-10 );
+ }
+
+ $url = 'https://aip.baidubce.com/rest/2.0/ocr/v1/business_license?access_token=' . $token;
+ if(substr($file,0,4)!="http"){
+ $file = Env::get('ext.domain', $_SERVER['HTTP_HOST']).$file;
+ }
+ try {
+ $img = file_get_contents($file);
+ } catch (Exception $e){
+ return json($result);
+ }
+ if(!$img){
+ return json($result);
+ }
+ $img = base64_encode($img);
+
+ $bodys = array(
+ 'image' => $img
+ );
+ $resStr = $this->request_post($url, $bodys);
+ $res = json_decode($resStr,true);
+ $res2 = $res['words_result'];
+ $result = [
+ "business_name" => $res2['单位名称']['words'] ?? "",
+ "business_range" => $res2['经营范围']['words'] ?? "",
+ "business_legal" => $res2['法人']['words'] ?? "",
+ "business_social" => $res2['社会信用代码']['words'] ?? "",
+ "business_establish" =>$res2['成立日期']['words'] ?? "",
+ "business_address" => $res2['地址']['words'] ?? "",
+ "business_type" => $res2['类型']['words'] ?? "",
+ ];
+ return json($result);
+ }
+
+
+ /**
+ * 发起http post请求(REST API), 并获取REST请求的结果
+ * @param string $url
+ * @param string $param
+ * @return - http response body if succeeds, else false.
+ */
+ function request_post($url = '', $param = '')
+ {
+ if (empty($url) || empty($param)) {
+ return false;
+ }
+
+ $postUrl = $url;
+ $curlPost = $param;
+ // 初始化curl
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $postUrl);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ // 要求结果为字符串且输出到屏幕上
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ // post提交方式
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
+ // 运行curl
+ $data = curl_exec($curl);
+ curl_close($curl);
+
+ return $data;
+ }
+
+
+ public function get_token(){
+ $curl = curl_init();
+ curl_setopt_array($curl, array(
+ CURLOPT_URL => "https://aip.baidubce.com/oauth/2.0/token?client_id=VBgaZy6xOiHsWVRMTuOqRynw&client_secret=fe6OOmXCZzt2B7BDGo6ctyR3TPEZkmws&grant_type=client_credentials",
+ CURLOPT_TIMEOUT => 30,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+
+
+ CURLOPT_HTTPHEADER => array(
+ 'Content-Type: application/json',
+ 'Accept: application/json'
+ ),
+
+ ));
+ $response = curl_exec($curl);
+ curl_close($curl);
+ return $response;
+ }
+
}
diff --git a/application/admin/controller/qingdong/customer/Need.php b/application/admin/controller/qingdong/customer/Need.php
index b960ce1..198f212 100644
--- a/application/admin/controller/qingdong/customer/Need.php
+++ b/application/admin/controller/qingdong/customer/Need.php
@@ -38,6 +38,7 @@ class Need extends Base
$where['next_time'] = array(array('egt',date('Y-m-d 00:00:00')),array('lt',date('Y-m-d 23:59:59')));
$where['follow_type'] = ['neq', '其它'];
$where['status'] = 0;
+ $where['cid'] = CID;
// 待跟进客户
$where1['relation_type'] = 1;
$customerlist = Record::where($where)->where($where1)->column('relation_id');
@@ -143,6 +144,8 @@ class Need extends Base
$where['next_time'] = array(array('egt',date('Y-m-d 00:00:00')),array('lt',date('Y-m-d 23:59:59')));
$where['follow_type'] = ['neq', '其它'];
$where['status'] = 0;
+ $where['cid'] = CID;
+
// 待跟进客户
$where1['relation_type'] = 1;
$customerlist = Record::where($where)->where($where1)->column('relation_id');
diff --git a/application/admin/view/general/profile/index.html b/application/admin/view/general/profile/index.html
index 94d5901..a1c8e4c 100644
--- a/application/admin/view/general/profile/index.html
+++ b/application/admin/view/general/profile/index.html
@@ -54,8 +54,9 @@
++工商信息
+