diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php
index fe57dad..38a0fec 100644
--- a/app/admin/controller/supplychain/Index.php
+++ b/app/admin/controller/supplychain/Index.php
@@ -102,6 +102,7 @@ class Index extends BaseController
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['name'] = $params['title']; // 团队名称
$data['tel'] = $params['phone']; // 联系电话
+ $data['shareRate'] = $params['shareRate']; // 分润比例
$data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户
$data['street_id'] = $params['street_id']; // 街道ID
@@ -169,6 +170,7 @@ class Index extends BaseController
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['name'] = $params['title']; // 团队名称
$data['tel'] = $params['phone']; // 联系电话
+ $data['shareRate'] = $params['shareRate']; // 分润比例
$data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户
$data['street_id'] = $params['street_id']; // 街道ID
$street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据
diff --git a/app/admin/view/supplychain/index/add.html b/app/admin/view/supplychain/index/add.html
index b4b9888..0e5787b 100644
--- a/app/admin/view/supplychain/index/add.html
+++ b/app/admin/view/supplychain/index/add.html
@@ -73,6 +73,16 @@
+
请选择所在地址* |
diff --git a/app/admin/view/supplychain/index/index.html b/app/admin/view/supplychain/index/index.html
index 1932a93..ac0d49c 100644
--- a/app/admin/view/supplychain/index/index.html
+++ b/app/admin/view/supplychain/index/index.html
@@ -96,6 +96,11 @@
title: '联系电话',
align: 'center',
width:150,
+ },{
+ field: 'shareRate',
+ title: '分佣比例',
+ align: 'center',
+ width:150,
},{
field: 'earnings_amount',
title: '净收益',
diff --git a/app/api/BaseController.php b/app/api/BaseController.php
index bea59e9..823bf71 100644
--- a/app/api/BaseController.php
+++ b/app/api/BaseController.php
@@ -83,52 +83,62 @@ abstract class BaseController
//每页显示数据量
$this->pageSize = Request::param('page_size', \think\facade\Config::get('app.page_size'));
- $token = Request::header('x-Token');
- if ($token) {
- if (strpos($token, 'Bearer') === 0){
- $token = trim(substr($token, 6));
- }
- if (count(explode('.', $token)) != 3) {
- return json(['code'=>404,'msg'=>'非法请求']);
- }
- $config = get_system_config('token');
- //var_dump($config);exit;
- try {
- JWT::$leeway = 60;//当前时间减去60,把时间留点余地
- $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应
+// 暂时去除 -----------------------------------------------------
+// $token = Request::header('x-Token');
+// if ($token) {
+// if (strpos($token, 'Bearer') === 0){
+// $token = trim(substr($token, 6));
+// }
+// if (count(explode('.', $token)) != 3) {
+// return json(['code'=>404,'msg'=>'非法请求']);
+// }
+// $config = get_system_config('token');
- //return (array)$decoded;
-// $decoded_array = json_decode(json_encode($decoded),TRUE);
-// $jwt_data = $decoded_array['data'];
+// return json($token);
+// JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+// $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应
- $user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find();
- if (!$user){
- return json(['code'=>403,'msg'=>'签名错误']);
- return false;
- }
- $user = Db::table('fa_user')->where('id',$user['n_user_id'])->find();
- //$request->uid = $jwt_data['userid'];
- define('JWT_UID', $user['id']);
-// $response = $next($request);
-// return $response;
- //return $next($request);
- } catch(\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
- return json(['code'=>403,'msg'=>'签名错误']);
- }catch(\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
- return json(['code'=>401,'msg'=>'token失效']);
- }catch(\Firebase\JWT\ExpiredException $e) { // token过期
- return json(['code'=>401,'msg'=>'token已过期']);
- }catch(Exception $e) { //其他错误
- return json(['code'=>404,'msg'=>'非法请求']);
- }catch(\UnexpectedValueException $e) { //其他错误
- return json(['code'=>404,'msg'=>'非法请求']);
- } catch(\DomainException $e) { //其他错误
- return json(['code'=>404,'msg'=>'非法请求']);
- }
- }else{
- define('JWT_UID', '');
- }
+// return $decoded->jti[0];
+// exit;
+// //var_dump($config);exit;
+// try {
+// JWT::$leeway = 60;//当前时间减去60,把时间留点余地
+// $decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应
+
+// //return (array)$decoded;
+// // $decoded_array = json_decode(json_encode($decoded),TRUE);
+// // $jwt_data = $decoded_array['data'];
+
+// $user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find();
+// if (!$user){
+// return json(['code'=>403,'msg'=>'签名错误']);
+// return false;
+// }
+// $user = Db::table('fa_user')->where('id',$user['n_user_id'])->find();
+// //$request->uid = $jwt_data['userid'];
+// define('JWT_UID', $user['id']);
+// // $response = $next($request);
+// // return $response;
+// //return $next($request);
+// } catch(\Firebase\JWT\SignatureInvalidException $e) { //签名不正确
+// return json(['code'=>403,'msg'=>'签名错误']);
+// }catch(\Firebase\JWT\BeforeValidException $e) { // 签名在某个时间点之后才能用
+// return json(['code'=>401,'msg'=>'token失效']);
+// }catch(\Firebase\JWT\ExpiredException $e) { // token过期
+// return json(['code'=>401,'msg'=>'token已过期']);
+// }catch(Exception $e) { //其他错误
+// return json(['code'=>404,'msg'=>'非法请求']);
+// }catch(\UnexpectedValueException $e) { //其他错误
+// return json(['code'=>404,'msg'=>'非法请求']);
+// } catch(\DomainException $e) { //其他错误
+// return json(['code'=>404,'msg'=>'非法请求']);
+// }
+// }else{
+// define('JWT_UID', '');
+// }
+
+// 暂时去除 -----------------------------------------------------
}
/**
diff --git a/app/api/controller/Article.php b/app/api/controller/Article.php
index 5659497..f3fe1f4 100644
--- a/app/api/controller/Article.php
+++ b/app/api/controller/Article.php
@@ -41,8 +41,8 @@ class Article extends BaseController
unset($where[1]);
}
//根据个人村id进行查询
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village', '=', $find['village_id']];
@@ -54,7 +54,7 @@ class Article extends BaseController
}
// 登录返回村名和村地址
$cun_arr['cun_name'] = Db::table('fa_geo_village')->where('village_id', $find['village_id'])->value('village_name');
- $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', JWT_UID)->value('address_name');
+ $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->value('address_name');
}else{
$cun_arr = [];
}
@@ -183,8 +183,8 @@ class Article extends BaseController
unset($where[1]);
}
// 如果登录
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village', '=', $find['village_id']];
@@ -312,8 +312,8 @@ class Article extends BaseController
['status', '=', 1],
];
//根据个人村id进行查询
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village', '=', $find['village_id']];
@@ -497,7 +497,7 @@ class Article extends BaseController
// if (!$res) {
// return $this->apiError($valdate->getError());
// }
- $useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find();
+ $useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->where('status', 1)->find();
$data = [];
if ($useraddress) {
@@ -507,7 +507,7 @@ class Article extends BaseController
}
$data['end_time'] = date('Y-m-d H:i:s', strtotime('+1 day'));
$data['view_time'] = date('Y-m-d H:i:s');
- $data['user_id'] = JWT_UID;//添加用户的id
+ $data['user_id'] = $this->request->uid;//添加用户的id
$data['category_id'] = $input['category_id'];//大分类id
$data['category_type'] = $input['category_type'];//小分类id
$data['title'] = $input['title'];//标题
@@ -518,7 +518,7 @@ class Article extends BaseController
$data['image'] = $input['image'];//封面
$data['is_vote'] =empty($input['is_vote'])?0:$input['is_vote'];//是否投票
if ($input['category_id']==150){
- $name=Db::table('fa_szxc_information_usermsg')->where('user_id',JWT_UID)->value('name');
+ $name=Db::table('fa_szxc_information_usermsg')->where('user_id',$this->request->uid)->value('name');
$data['title'] = '来自于'.$name.'的一键求救';
}
$res = Db::table('fa_article')->insertGetId($data);
@@ -575,7 +575,7 @@ class Article extends BaseController
$data['describe'] = empty($input['describe'])?'':$input['describe'];//简介
$data['image'] = $input['image'];//封面
$data['is_vote'] = $input['is_vote'];//是否投票
- $input['update_user_id'] = JWT_UID;//更新用户的id
+ $input['update_user_id'] = $this->request->uid;//更新用户的id
$res = Db::table('fa_article')->where('id', $id)->update($data);
if ($input['is_vote'] == 1) {
@@ -596,8 +596,8 @@ class Article extends BaseController
{
// $model = Db::table('fa_article');
//根据个人村id进行查询
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village', '=', $find['village_id']];
@@ -650,12 +650,12 @@ class Article extends BaseController
{
// $model = Db::table('fa_article');
//根据个人id进行查询
- $where[] = ['a.user_id','=',JWT_UID];
+ $where[] = ['a.user_id','=',$this->request->uid];
$where[] = ['b.is_read','=','0'];
$which = [];
//根据个人村id进行查询
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$www[] = ['a.village', '=', $find['village_id']];
@@ -665,7 +665,7 @@ class Article extends BaseController
$www[] = ['a.county', '=', $find['area_id']];
}
}
- $which['user_id'] = JWT_UID;
+ $which['user_id'] = $this->request->uid;
}
$yishi = Db::table('fa_article')->alias('a')->join(['fa_article_vote_side_tables' => 'b'],'a.id=b.article_id')->where($www)->where('a.category_id',162)->whereTime('b.end_time', '>', date('Y-m-d H:i:s'))->count();
$maodun = Db::table('fa_article')->alias('a')->join(['fa_article_comment' => 'b'],'a.id=b.vote_id')->where('a.is_solve', 1)->where($where)->where('a.category_id',147)->count();
@@ -708,8 +708,8 @@ class Article extends BaseController
}
//根据个人村id进行查询
- if (JWT_UID) {
- $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
+ if ($this->request->uid) {
+ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->request->uid)->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village', '=', $find['village_id']];
@@ -721,7 +721,7 @@ class Article extends BaseController
}
// 登录返回村名和村地址
$cun_arr['cun_name'] = Db::table('fa_geo_village')->where('village_id', $find['village_id'])->value('village_name');
- $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', JWT_UID)->value('address_name');
+ $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->value('address_name');
}else{
$cun_arr = [];
}
diff --git a/app/api/controller/User.php b/app/api/controller/User.php
index 513804a..aa4346b 100644
--- a/app/api/controller/User.php
+++ b/app/api/controller/User.php
@@ -29,9 +29,9 @@ class User extends BaseController
* 会员中心.
*/
public function index()
- {
- $user = Db::table('fa_user')->where('id',JWT_UID)->find();
- $user_msg = Db::table('fa_szxc_information_usermsg')->where('user_id',JWT_UID)->field('id,name,address_name,phone')->find();
+ {
+ $user = Db::table('fa_user')->where('id', $this->request->uid)->find();
+ $user_msg = Db::table('fa_szxc_information_usermsg')->where('user_id', $this->request->uid)->field('id,name,address_name,phone')->find();
$this->apiSuccess('', [
'nickname' => $user['nickname'],
'phone'=>$user_msg['phone'],
@@ -472,7 +472,7 @@ class User extends BaseController
// 获取实名认证信息
public function get_shiming(){
- $uid = JWT_UID;
+ $uid = $this->request->uid;
$is_have = Db::table('cms_szxc_user_authentication')->where('user_id',$uid)->find();
if($is_have){
$this->apiSuccess('获取成功',$is_have);
@@ -483,7 +483,7 @@ class User extends BaseController
// 获取后台账号信息
public function get_backstage(){
- $uid = JWT_UID;
+ $uid = $this->request->uid;
$admin = Db::table('cms_admin')->where('user_id',$uid)->find();
if($admin){
$data['url'] = 'https://nk.lihaink.cn';
diff --git a/app/api/controller/Userinfo.php b/app/api/controller/Userinfo.php
index a3da625..7617a8b 100644
--- a/app/api/controller/Userinfo.php
+++ b/app/api/controller/Userinfo.php
@@ -94,16 +94,17 @@ class Userinfo extends BaseController
public function Binding()
{
$post = get_params();
-
if(!$post['idcard'] || !$post['area_id'] || !$post['street_id'] || !$post['village_id'] || !$post['name']){
$this->apiError('缺少参数');
}
if($post['phone'] == 'undefined'){
$this->apiError('手机号错误');
}
+
$where['id'] = $this->request->uid;
$post['user_id'] = $this->request->uid;
$user = Db::table('fa_user')->where($where)->field('id,nickname,group_id,mobile,avatar,username,createtime,score')->find();
+
// 已绑定
if ($user) {
Db::startTrans();
diff --git a/app/api/controller/Village.php b/app/api/controller/Village.php
index 27cd03d..f0981ec 100644
--- a/app/api/controller/Village.php
+++ b/app/api/controller/Village.php
@@ -664,7 +664,7 @@ class Village extends BaseController
})
->withAttr('is_dz', function ($value, $data) {
// 判断redis
- $user_id = JWT_UID;
+ $user_id = $this->request->uid;
if($user_id){
$name = $user_id . $data['id'];
$is_zan = Cache::store('redis')->get($name);
diff --git a/app/api/middleware.php b/app/api/middleware.php
index 91dea02..e695fbe 100644
--- a/app/api/middleware.php
+++ b/app/api/middleware.php
@@ -6,4 +6,6 @@ return [
//验证勾股cms是否完成安装
\app\home\middleware\Install::class,
\app\api\middleware\AllowOriginMiddleware::class,
+ \app\api\middleware\Auth::class,
+
];
\ No newline at end of file
diff --git a/app/api/middleware/Auth.php b/app/api/middleware/Auth.php
index 6b55e8c..bfe148d 100644
--- a/app/api/middleware/Auth.php
+++ b/app/api/middleware/Auth.php
@@ -27,11 +27,12 @@ class Auth
if (count(explode('.', $token)) != 3) {
return json(['code'=>404,'msg'=>'非法请求']);
}
+
try {
JWT::$leeway = 60;//当前时间减去60,把时间留点余地
$decoded = JWT::decode($token, new Key('ae47e94a7dcd1fdfacb499b60e361a8d', 'HS256')); //HS256方式,这里要和签发的时候对应
$user=Db::connect('shop')->name('nk_user')->where('user_id',$decoded->jti[0])->find();
- if ($user &&$user['n_user_id']!=0){
+ if ($user && $user['n_user_id']!=0){
$request->uid=$user['n_user_id'];
}else{
$request->uid=$this->addUser($decoded->jti[0],$user);
@@ -61,41 +62,41 @@ class Auth
$msg=Db::table('fa_szxc_information_usermsg')->where('phone',$user['account'])->find();
Db::startTrans();
try {
- if ($msg){
- $users=Db::table('fa_user')->where('id',$msg['user_id'])->find();
- if (!$nk_user){
+ if ($msg){
+ $users=Db::table('fa_user')->where('id',$msg['user_id'])->find();
+ if (!$nk_user){
+ $datas=[
+ 'user_id'=>$user['uid'],
+ 'n_user_id'=>$msg['user_id'],
+ 'group_id'=>$users['group_id']
+ ];
+ Db::connect('shop')->name('nk_user')->insert($datas);
+ }else{
+ Db::connect('shop')->name('nk_user')->where('id',$nk_user['id'])->update(['user_id'=>$user['uid'],'group_id'=>$users['group_id']]);
+ }
+ }else{
+ $time=time();
+ $user_data=[
+ 'openid'=>'wx'.$time,
+ 'group_id'=>1,
+ 'username'=>'wx'.$time,
+ 'nickname'=>'微信用户'.$time,
+ 'avatar'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230104/32a639be4ee32349705e947fbbd1e114.png',
+ 'level'=>1,
+ 'prevtime'=>$time,
+ 'jointime'=>$time,
+ 'createtime'=>$time,
+ 'updatetime'=>$time,
+ 'status'=>'normal'
+ ];
+ $n_user_id= Db::table('fa_user')->insertGetId($user_data);
$datas=[
'user_id'=>$user['uid'],
- 'n_user_id'=>$msg['user_id'],
- 'group_id'=>$users['group_id']
+ 'n_user_id'=>$n_user_id,
+ 'group_id'=>1
];
Db::connect('shop')->name('nk_user')->insert($datas);
- }else{
- Db::connect('shop')->name('nk_user')->where('id',$nk_user['id'])->update(['user_id'=>$user['uid'],'group_id'=>$users['group_id']]);
- }
- }else{
- $time=time();
- $user_data=[
- 'openid'=>'wx'.$time,
- 'group_id'=>1,
- 'username'=>'wx'.$time,
- 'nickname'=>'微信用户'.$time,
- 'avatar'=>'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230104/32a639be4ee32349705e947fbbd1e114.png',
- 'level'=>1,
- 'prevtime'=>$time,
- 'jointime'=>$time,
- 'createtime'=>$time,
- 'updatetime'=>$time,
- 'status'=>'normal'
- ];
- $n_user_id= Db::table('fa_user')->insertGetId($user_data);
- $datas=[
- 'user_id'=>$user['uid'],
- 'n_user_id'=>$n_user_id,
- 'group_id'=>1
- ];
- Db::connect('shop')->name('nk_user')->insert($datas);
- return $n_user_id;
+ return $n_user_id;
}
Db::commit();
} catch (\Exception $e) {
|