From d57858b6a7d6db7b995de20d9aaaad5563d1c90c Mon Sep 17 00:00:00 2001 From: lcc <805383944@qq.com> Date: Mon, 8 Sep 2025 14:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E6=9E=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/api/organization/User.php | 73 +++++++++---------- agent/admin/controllers/auto/Login.php | 5 +- .../controllers/pingan/receiver/Clues.php | 3 +- .../controllers/pingan/receiver/Customer.php | 4 +- agent/admin/hooks/ApiAuthHook.php | 8 +- .../libraries/entity/AutoUserCouponEntity.php | 3 + .../models/agent/Auto_user_coupon_model.php | 1 + common/models/agent/Auto_user_model.php | 18 ++++- .../models/receiver/Receiver_clues_model.php | 2 + .../receiver/Receiver_customers_model.php | 13 +++- 10 files changed, 79 insertions(+), 51 deletions(-) diff --git a/agent/admin/controllers/api/organization/User.php b/agent/admin/controllers/api/organization/User.php index c9710118..fb8ad531 100644 --- a/agent/admin/controllers/api/organization/User.php +++ b/agent/admin/controllers/api/organization/User.php @@ -89,7 +89,9 @@ class User extends BaseController 'typeCn' => Pingan_users_model::TYPE_CN[$v['groupType']], 'groupType' => $v['groupType'], 'cityName' => $city['city_name'], 'centerNumber' => Pingan_users_model::TYPE_CENTER[$v['centerNumber']], - 'areaUser' => $areaUser, 'depUser' => $depUser, 'teamUser' => $teamUser + 'areaUser' => $areaUser, 'depUser' => $depUser, 'teamUser' => $teamUser, + 'orgId' => intval($v['orgId']), 'citys' => [$v['provinceId'], $v['cityId']], + 'remark' => $v['remark'] ]; } } @@ -117,59 +119,56 @@ class User extends BaseController public function index_put() { $id = $this->input_param('id'); - $username = $this->input_param('username'); - $mobile = $this->input_param('mobile'); - $groupType = intval($this->input_param('groupType')); + $params = $this->input_param(); + if (!$params['username']) { + $this->return_json('请输入用户账号'); + } + if (!$params['userCode']) { + $this->return_json('请输入工号'); + } $row = $this->pinganUsers->get(['id' => $id]); if (!$row) { $this->return_json('参数错误'); } - if ($mobile != $row['mobile']) { - $mobileRow = $this->pinganUsers->get(['mobile' => $mobile, 'status>=' => 0]); + if ($params['userCode'] != $row['userCode']) { + $mobileRow = $this->pinganUsers->get(['userCode' => $params['userCode'], 'status>=' => 0]); if ($mobileRow) { - $this->return_json('手机号已存在'); + $this->return_json('帐号已存在'); } } - $upDate = ['username' => $username, 'mobile' => $mobile, 'groupType' => $groupType]; + $citys = $this->input_param('citys'); + $upDate = [ + 'username' => $params['username'], 'mobile' => $params['mobile'], 'userCode' => $params['userCode'], + 'remark' => $params['remark'], 'provinceId' => $citys[0] ?: 0, 'cityId' => $citys[1] ?: 0 + + ]; $this->pinganUsers->update($upDate, ['id' => $id]); $this->return_response(); } public function index_post() { - $username = $this->input_param('username'); - $nickname = $this->input_param('nickname'); - $phone = $this->input_param('phone'); - $sex = $this->input_param('sex'); - $birthday = $this->input_param('birthday'); - $introduction = $this->input_param('introduction'); - $email = $this->input_param('email'); - $roleIds = $this->input_param('roleIds'); - $password = $this->input_param('password'); - if (!$username) { - $this->return_json('请输入用户帐户'); + $params = $this->input_param(); + + if (!$params['username']) { + $this->return_json('请输入用户账号'); } - if (!$nickname) { - $this->return_json('请输入用户名'); + if (!$params['userCode']) { + $this->return_json('请输入工号'); } - if (!$sex) { - $this->return_json('请选择性别'); - } - if (!$password) { - $this->return_json('请输入登录密码'); - } - if (!$roleIds) { - $this->return_json('请选择角色'); - } - $re = $this->mdSysAdmin->get(['username' => $username]); + $re = $this->pinganUsers->get(['userCode' => $params['userCode'], 'status>=' => 0]); if ($re) { - $this->return_json('用户帐号已存在'); + $this->return_json('帐号已存在'); } - $roleId = intval($roleIds[0]); - $password = password_hash($password, PASSWORD_BCRYPT); - $addDate = ['username' => $username, 'nickname' => $nickname, 'phone' => $phone, 'sex' => $sex, 'birthday' => $birthday - , 'password' => $password, 'introduction' => $introduction, 'email' => $email, 'roleId' => $roleId, 'createTime' => date('Y-m-d H:i:s')]; - $id = $this->mdSysAdmin->add($addDate); + $citys = $this->input_param('citys'); + $addDate = [ + 'username' => $params['username'], 'mobile' => $params['mobile'], 'userCode' => $params['userCode'], + 'remark' => $params['remark'], 'createTime' => date('Y-m-d H:i:s'), + 'orgId' => intval($params['orgId']) + ]; + $citys[0] && $addDate['provinceId'] = $citys[0]; + $citys[1] && $addDate['cityId'] = $citys[1]; + $id = $this->pinganUsers->add($addDate); if (!$id) { $this->return_json('添加用户失败'); } diff --git a/agent/admin/controllers/auto/Login.php b/agent/admin/controllers/auto/Login.php index 1f604db1..e6c53441 100644 --- a/agent/admin/controllers/auto/Login.php +++ b/agent/admin/controllers/auto/Login.php @@ -18,6 +18,7 @@ class Login extends BaseController $config = $this->config->item('default'); $code = $this->input_param('code'); $accountId = $this->input_param('accountId'); + $from = $this->input_param('from'); if (!$code) { throw new Exception('参数错误'); } @@ -42,13 +43,13 @@ class Login extends BaseController } /** @var MyResponse $response */ - $response = $this->autoUserModel->initUser($ret['openid'], $accountId, $otherInfo); + $response = $this->autoUserModel->initUser($ret['openid'], $accountId, $from, $otherInfo); if (!$response->isSuccess()) { $this->return_json($response->getMessage()); } $responseData = $response->getData(); $data = [ - 'Authorization' => Authorization::generateToken($responseData['id'], 'jwt_key_auto'), + 'Authorization' => Authorization::generateToken([$responseData['id'], $responseData['orgId'] ?: 0], 'jwt_key_auto'), ]; $this->return_response($data, API_CODE_SUCCESS); } catch (Exception $e) { diff --git a/agent/admin/controllers/pingan/receiver/Clues.php b/agent/admin/controllers/pingan/receiver/Clues.php index 9aabc124..ef6ba8c6 100644 --- a/agent/admin/controllers/pingan/receiver/Clues.php +++ b/agent/admin/controllers/pingan/receiver/Clues.php @@ -230,7 +230,8 @@ class Clues extends BaseController $citys = $this->input_param('citys'); // $belong = $this->input_param('belong'); $where = [ - 'app_id' => self::APP_ID + 'app_id' => self::APP_ID, + 'org_id' => $_SESSION['orgId'] ]; if ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM || $_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM_CONTACT) { diff --git a/agent/admin/controllers/pingan/receiver/Customer.php b/agent/admin/controllers/pingan/receiver/Customer.php index 1627e4b2..bb8c14b1 100644 --- a/agent/admin/controllers/pingan/receiver/Customer.php +++ b/agent/admin/controllers/pingan/receiver/Customer.php @@ -307,6 +307,7 @@ class Customer extends BaseController $bizIds = $params['bizIds']; $brands = $params['brands']; $uid = $_SESSION['id']; + $orgId = $_SESSION['orgId']; $appId = self::APP_ID; $where = [ 'rid>' => 0, @@ -343,9 +344,10 @@ class Customer extends BaseController $subSql .= " and pingan_user_id=-99999"; } } - if($params['cluesSid']){ + if ($params['cluesSid']) { $subSql .= " and sid like '%{$params['cluesSid']}%'"; } + $subSql .= " and org_id={$orgId}"; $where["rid in ($subSql)"] = null; $params['title'] && $where['mobile LIKE "%' . trim($params['title']) . '%"'] = null; if ($params['dateRange'][0] && $params['dateRange'][1]) { diff --git a/agent/admin/hooks/ApiAuthHook.php b/agent/admin/hooks/ApiAuthHook.php index 91c61518..319627db 100644 --- a/agent/admin/hooks/ApiAuthHook.php +++ b/agent/admin/hooks/ApiAuthHook.php @@ -21,13 +21,13 @@ class ApiAuthHook $this->auth_pingan = ',pingan/auth'; $this->route_un = [ 'api/captcha', 'api/login', 'api/login/code', 'api/login/forget', 'api/upload', - 'api/common/*', 'pingan/login/*', 'pingan/captcha', 'pingan/register','pingan/upload', + 'api/common/*', 'pingan/login/*', 'pingan/captcha', 'pingan/register', 'pingan/upload', 'pingan/common/*' ]; //h5白名单 $this->route_un_auto = [ 'auto/config/*', 'auto/login/*', 'auto/area/*', - 'auto/car/brand','auto/car/product/list', + 'auto/car/brand', 'auto/car/product/list', 'auto/car/coupon/bizs', ]; } @@ -46,7 +46,9 @@ class ApiAuthHook !in_array($urlArray[0] . '/' . $urlArray[1] . '/' . $urlArray[2] . '/*', $this->route_un_auto)) { $headers = $this->CI->input->request_headers(); if ($this->tokenIsExist($headers)) { - $this->CI->userId = $this->validateToken($headers['Authorization'], 'jwt_key_auto'); + $req = $this->validateToken($headers['Authorization'], 'jwt_key_auto'); + $this->CI->userId = $req[0]; + $this->CI->orgId = $req[1]; if (!$this->CI->userId) { $this->return_json('登录已过期,请重新登录', 403); } diff --git a/common/libraries/entity/AutoUserCouponEntity.php b/common/libraries/entity/AutoUserCouponEntity.php index 0bb0fd9c..59e0003f 100644 --- a/common/libraries/entity/AutoUserCouponEntity.php +++ b/common/libraries/entity/AutoUserCouponEntity.php @@ -145,6 +145,9 @@ class AutoUserCouponEntity 'contractImg' => $contractImg, 'createTime' => date('Y-m-d H:i:s') ]; + if (!in_array($clueRow['org_id'], Receiver_clues_model::COMM_ORG_IDS)) { + $data['commStatus'] = Receiver_order_subsidy_model::COMM_STATUS_NOT; + } $result = $this->ci->receiver_order_subsidy_model->add($data); if (!$result) { throw new Exception('新增补贴记录失败', API_CODE_FAIL); diff --git a/common/models/agent/Auto_user_coupon_model.php b/common/models/agent/Auto_user_coupon_model.php index d6768c0c..2727dde7 100644 --- a/common/models/agent/Auto_user_coupon_model.php +++ b/common/models/agent/Auto_user_coupon_model.php @@ -106,6 +106,7 @@ class Auto_user_coupon_model extends HD_Model ]; $data['brand_id'] = $product['brandId'] ?: 0; $data['series_id'] = $product['seriesId'] ?: 0; + $data['org_id'] = $user['orgId'] ?: 0; $data['pingan_user_id'] = $user['pinganUserId'] ?: 0; $data['team_id'] = $user['teamId'] ?: 0; $data['dep_id'] = $user['depId'] ?: 0; diff --git a/common/models/agent/Auto_user_model.php b/common/models/agent/Auto_user_model.php index 1516e77b..117d8362 100644 --- a/common/models/agent/Auto_user_model.php +++ b/common/models/agent/Auto_user_model.php @@ -6,23 +6,35 @@ class Auto_user_model extends HD_Model const STATUS_DISABLE = 0; //禁用 const STATUS_NORMAL = 1; //正常 private $table_name = 'lc_auto_user'; + const MAP_USER_MODEL = [ + 'ain' => 'ain_users_model', + 'fish' => 'fish_users_model' + ]; public function __construct() { parent::__construct($this->table_name, 'default'); - $this->load->model('agent/pingan/pingan_users_model', 'pingAnUsers'); + + $this->load->model('agent/pingan/pingan_users_model'); $this->load->model('agent/organization/organization_model'); } /** * @param $openid - * @param $accountId 平安用户编码 + * @param string $accountId 平安用户编码 + * @param string $from ain fish * @param array $otherInfo * @return MyResponse */ - public function initUser($openid, $accountId, $otherInfo = []) + public function initUser($openid, $accountId, $from = '', $otherInfo = []) { try { + $userModel = self::MAP_USER_MODEL[$from]; + if ($userModel) { + $this->load->model('agent/pingan/' . $userModel, 'pingAnUsers'); + } else { + $this->load->model('agent/pingan/pingan_users_model', 'pingAnUsers'); + } $user = $this->get(['openid' => $openid]); if (!$user) { $user = [ diff --git a/common/models/receiver/Receiver_clues_model.php b/common/models/receiver/Receiver_clues_model.php index 790b1afb..dfff7d55 100644 --- a/common/models/receiver/Receiver_clues_model.php +++ b/common/models/receiver/Receiver_clues_model.php @@ -15,6 +15,8 @@ class Receiver_clues_model extends HD_Model const CF_ID2_PRODUCT = 40; // cf_id2 来源产品 //意向购车周期 const BUY_TIME_LIST = [1 => '3天内', 2 => '一周内', 3 => '15天内', 4 => '1个月内', 5 => '超过1个月']; + //分佣机构id + const COMM_ORG_IDS = [1]; public function __construct() { diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index 1dabc982..4221d7ca 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -355,6 +355,7 @@ class Receiver_customers_model extends HD_Model } $this->db->trans_commit(); $this->auto_user_coupon_model->db->trans_commit(); + debug_log("解锁成功", $log_path); return new MyResponse(EXIT_SUCCESS, '解锁成功'); } catch (Exception $e) { $this->db->trans_rollback(); @@ -387,14 +388,15 @@ class Receiver_customers_model extends HD_Model if (!$clues) { throw new Exception("线索不存在"); } + if ($clues['app_id'] != Receiver_clues_model::APP_ID_ACTIVITY) { + throw new Exception("当前线索不是活动线索"); + } if (!$clues['out_id']) { throw new Exception("报名来源不存在"); } $bizMoney = 0; //商家扣除金额 - if ($clues['cf2_id'] == Receiver_clues_model::CF_ID2_PRODUCT) { //产品来源 - $product = $this->auto_product_model->get(['id' => $clues['out_id']]); - $bizMoney = $product['cluesCommission']; - } + $product = $this->auto_product_model->get(['id' => $clues['out_id']]); + $bizMoney = $product['cluesCommission']; if ($bizMoney <= 0) { debug_log("扣除金额结束:扣除金额不能小于等于0,{$bizMoney}", $log_path, $log_dir); return new MyResponse(EXIT_SUCCESS, '保存成功'); @@ -430,6 +432,9 @@ class Receiver_customers_model extends HD_Model 'jsondata' => json_encode(['clues_id' => $cluesId]), 'target_id' => $cluesId ]; + if (!in_array($clues['org_id'], Receiver_clues_model::COMM_ORG_IDS)) { + $logData['comm_status'] = Biz_accountLog_model::COMM_STATUS_NOT; + } $ret = $this->accountlog_model->add($logData); if (!$ret) { throw new Exception('写入交易日志失败', 0);