diff --git a/agent/admin/controllers/auto/car/Coupon.php b/agent/admin/controllers/auto/car/Coupon.php index fefe9482..2e5998e6 100644 --- a/agent/admin/controllers/auto/car/Coupon.php +++ b/agent/admin/controllers/auto/car/Coupon.php @@ -25,6 +25,7 @@ class Coupon extends BaseController $couponId = $this->post('couponId'); $mobile = $this->post('mobile'); $code = $this->post('code'); + $cityId = $this->post('cityId'); if (!$couponId || !$mobile || !$code) { throw new Exception("参数错误"); } @@ -35,7 +36,7 @@ class Coupon extends BaseController if (!$cacheCode || $cacheCode != $code) { throw new Exception("验证码错误"); } - $result = $this->auto_user_coupon_model->getCoupon(self::APP_ID, $this->userId, $couponId, $mobile); + $result = $this->auto_user_coupon_model->getCoupon(self::APP_ID, $this->userId, $couponId, $mobile, $cityId); if (!$result->isSuccess()) { throw new Exception($result->getMessage()); } diff --git a/agent/admin/controllers/pingan/car/Product.php b/agent/admin/controllers/pingan/car/Product.php index e338018d..f7dd46fa 100644 --- a/agent/admin/controllers/pingan/car/Product.php +++ b/agent/admin/controllers/pingan/car/Product.php @@ -103,13 +103,6 @@ class Product extends BaseController 'bizList' => $coupon['bizList'] ]; $temp['coupon'] = $tempCoupon; -// $where = [ -// 'app_id' => self::APP_ID, -// 'out_id' => $v->id, -// 'pingan_user_id' => $uid, -// 'cf2_id' => self::CF2_PRODUCT -// ]; -// $temp['cluesNum'] = $this->clues_model->count($where); //线索量 $list[] = $temp; } } diff --git a/agent/admin/controllers/pingan/organization/User.php b/agent/admin/controllers/pingan/organization/User.php index 8ab8c1b1..8f885b4d 100644 --- a/agent/admin/controllers/pingan/organization/User.php +++ b/agent/admin/controllers/pingan/organization/User.php @@ -91,6 +91,7 @@ class User extends BaseController public function groupType_get() { $res = Pingan_users_model::TYPE_CN; + unset($res[Pingan_users_model::GROUP_TYPE_TEAM_CONTACT],$res[Pingan_users_model::GROUP_TYPE_SUPER_ADMIN]); $this->return_response($res); } diff --git a/agent/admin/controllers/pingan/receiver/Clues.php b/agent/admin/controllers/pingan/receiver/Clues.php index 80e6c9c1..407eac7b 100644 --- a/agent/admin/controllers/pingan/receiver/Clues.php +++ b/agent/admin/controllers/pingan/receiver/Clues.php @@ -225,73 +225,34 @@ class Clues extends BaseController $brands = $this->input_param('brands'); $status = $this->input_param('status'); $citys = $this->input_param('citys'); - $belong = $this->input_param('belong'); +// $belong = $this->input_param('belong'); $where = [ 'app_id' => self::APP_ID ]; - if ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM) { + if ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM + || $_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM_CONTACT) { $where['team_id'] = $_SESSION['id']; -// if ($belong) { -// $pinganUserIdArray = []; -// foreach ($belong as $item) { -// $itemArray = json_decode($item, true); -// $itemArray[0] && $pinganUserIdArray[] = $itemArray[0]; -// } -// $pinganUserIdString = implode(',', $pinganUserIdArray); -// $pinganUserIdString && $where["pingan_user_id in ({$pinganUserIdString})"] = null; -// } } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_DEP) { $where['dep_id'] = $_SESSION['id']; -// if ($belong) { -// $teamIdArray = []; -// foreach ($belong as $item) { -// $itemArray = json_decode($item, true); -// $itemArray[0] && $teamIdArray[] = $itemArray[0]; -// } -// $teamString = implode(',', $teamIdArray); -// $teamString && $where["team_id in ({$teamString})"] = null; -// } } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_AREA) { $where['area_id'] = $_SESSION['id']; -// if ($belong) { -// $depIdArray = []; -// $teamIdArray = []; -// foreach ($belong as $item) { -// $itemArray = json_decode($item, true); -// $itemArray[0] && $depIdArray[] = $itemArray[0]; -// $itemArray[1] && $teamIdArray[] = $itemArray[1]; -// } -// $depIdString = implode(',', $depIdArray); -// $teamString = implode(',', $teamIdArray); -// $depIdString && $where["dep_id in ({$depIdString})"] = null; -// $teamString && $where["team_id in ({$teamString})"] = null; -// } } elseif (in_array($_SESSION['groupType'], - [Pingan_users_model::GROUP_TYPE_ORG_CONTACT, Pingan_users_model::GROUP_TYPE_TEAM_CONTACT])) { + [Pingan_users_model::GROUP_TYPE_ORG_CONTACT])) { //机构对接人 $orgName = $_SESSION['orgName']; $areaUserIds = $this->pingan_users_model->select(['orgName' => $orgName, 'groupType' => Pingan_users_model::GROUP_TYPE_AREA], '', 0, 0, 'id'); $areaUserIdsString = implode(',', $areaUserIds); !$areaUserIdsString && $areaUserIdsString = 0; $where["area_id in ({$areaUserIdsString})"] = null; -// if ($belong) { -// $areaIdArray = []; -// $depIdArray = []; -// $teamIdArray = []; -// foreach ($belong as $item) { -// $itemArray = json_decode($item, true); -// $itemArray[0] && $areaIdArray[] = $itemArray[0]; -// $itemArray[1] && $depIdArray[] = $itemArray[1]; -// $itemArray[2] && $teamIdArray[] = $itemArray[2]; -// } -// $areaString = implode(',', $areaIdArray); -// $depIdString = implode(',', $depIdArray); -// $teamString = implode(',', $teamIdArray); -// $areaString && $where["area_id in ({$areaString})"] = null; -// $depIdString && $where["dep_id in ({$depIdString})"] = null; -// $teamString && $where["team_id in ({$teamString})"] = null; -// } - } else { //机构 + }elseif($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_CENTER_CONTACT){ //中心对接人 + $centerNumber = $_SESSION['centerNumber']; + $areaUserIds = $this->pingan_users_model->select(['centerNumber' => $centerNumber, 'groupType' => Pingan_users_model::GROUP_TYPE_AREA], '', 0, 0, 'id'); + $areaUserIdsString = implode(',', $areaUserIds); + !$areaUserIdsString && $areaUserIdsString = 0; + $where["area_id in ({$areaUserIdsString})"] = null; + } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_ATTEND) { $where['pingan_user_id'] = $_SESSION['id']; + } else { //其它角色看到所有数据 + } $title && $where['mobile LIKE "%' . trim($title) . '%"'] = null; $sid && $where['sid LIKE "%' . trim($sid) . '%"'] = null; @@ -354,7 +315,7 @@ class Clues extends BaseController foreach ($rows as $key => $value) { $setValue = $value; $setValue['mobile'] = mobile_asterisk($value['mobile']); - $setValue['c_time'] = date('Y-m-d H:i:s',$value['c_time']); + $setValue['c_time'] = date('Y-m-d H:i:s', $value['c_time']); $brandName = $brands[$value['brand_id']] ? $brands[$value['brand_id']][0]['name'] : ''; $seriesName = $series[$value['series_id']] ? $series[$value['series_id']][0]['name'] : ''; $cfRow = $this->clues_cfrom_model->get(['id' => $value['cf2_id']]); diff --git a/agent/admin/controllers/pingan/receiver/Customer.php b/agent/admin/controllers/pingan/receiver/Customer.php index 19041d7b..bbbc689a 100644 --- a/agent/admin/controllers/pingan/receiver/Customer.php +++ b/agent/admin/controllers/pingan/receiver/Customer.php @@ -75,10 +75,10 @@ class Customer extends BaseController if ($brands[$val['brand_id']]) { $brand_detail .= '-' . $series[$val['series_id']][0]['name']; } - $order = $this->receiver_orders_model->get(['customer_id'=>$val['id'],'status>'=>0]); - $orderSubsidy = $this->receiver_order_subsidy_model->get(['orderId'=>$order['id']]); + $order = $this->receiver_orders_model->get(['customer_id' => $val['id'], 'status>' => 0]); + $orderSubsidy = $this->receiver_order_subsidy_model->get(['orderId' => $order['id']]); $checkStatus = ''; - if($orderSubsidy){ + if ($orderSubsidy) { $checkStatus = Receiver_order_subsidy_model::IF_CHECK_STATUS[$orderSubsidy['ifcheck']] ?: ''; } $temp = [ @@ -310,17 +310,29 @@ class Customer extends BaseController $where = [ 'rid>' => 0, ]; - if ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM) { + if ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM + || $_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_TEAM_CONTACT) { $subSql = "select id from lc_receiver_clues where app_id={$appId} and team_id={$uid}"; } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_DEP) { $subSql = "select id from lc_receiver_clues where app_id={$appId} and dep_id={$uid}"; } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_AREA) { $subSql = "select id from lc_receiver_clues where app_id={$appId} and area_id={$uid}"; - } elseif (in_array($_SESSION['groupType'], - [Pingan_users_model::GROUP_TYPE_ORG_CONTACT, Pingan_users_model::GROUP_TYPE_TEAM_CONTACT])) { - $subSql = "select id from lc_receiver_clues where app_id={$appId}"; - } else { + } elseif (in_array($_SESSION['groupType'], [Pingan_users_model::GROUP_TYPE_ORG_CONTACT])) { //机构对接人 + $orgName = $_SESSION['orgName']; + $areaUserIds = $this->pingan_users_model->select(['orgName' => $orgName, 'groupType' => Pingan_users_model::GROUP_TYPE_AREA], '', 0, 0, 'id'); + $areaUserIdsString = implode(',', $areaUserIds); + !$areaUserIdsString && $areaUserIdsString = 0; + $subSql = "select id from lc_receiver_clues where app_id={$appId} and area_id in ({$areaUserIdsString})"; + } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_CENTER_CONTACT) { //中心对接人 + $centerNumber = $_SESSION['centerNumber']; + $areaUserIds = $this->pingan_users_model->select(['centerNumber' => $centerNumber, 'groupType' => Pingan_users_model::GROUP_TYPE_AREA], '', 0, 0, 'id'); + $areaUserIdsString = implode(',', $areaUserIds); + !$areaUserIdsString && $areaUserIdsString = 0; + $subSql = "select id from lc_receiver_clues where app_id={$appId} and area_id in ({$areaUserIdsString})"; + } elseif ($_SESSION['groupType'] == Pingan_users_model::GROUP_TYPE_ATTEND) { $subSql = "select id from lc_receiver_clues where app_id={$appId} and pingan_user_id={$uid}"; + } else { + $subSql = "select id from lc_receiver_clues where app_id={$appId}"; } if ($params['userCode']) { $user = $this->pingan_users_model->get(["userCode like '%{$params['userCode']}%'" => null], 'id'); diff --git a/common/models/agent/Auto_user_coupon_model.php b/common/models/agent/Auto_user_coupon_model.php index 34c23bfe..bb3cbabd 100644 --- a/common/models/agent/Auto_user_coupon_model.php +++ b/common/models/agent/Auto_user_coupon_model.php @@ -23,14 +23,17 @@ class Auto_user_coupon_model extends HD_Model } /** - * 获取用户优惠券 + * 用户获取优惠券 + * @param $appId * @param $userId * @param $couponId * @param $mobile + * @param $cityId * @return MyResponse */ - public function getCoupon($appId, $userId, $couponId, $mobile) + public function getCoupon($appId, $userId, $couponId, $mobile, $cityId) { + $this->load->model('area_model'); $this->load->model('agent/auto_user_model', 'autoUserModel'); $this->load->model('agent/organization/organization_model', 'organizationModel'); $this->load->model('agent/auto_product_model'); @@ -44,6 +47,10 @@ class Auto_user_coupon_model extends HD_Model if (!$coupon) { throw new Exception('优惠券不存在'); } + $areaRow = []; + if ($cityId) { + $areaRow = $this->area_model->get(['city_id' => $cityId]); + } $where = [ 'userId' => $userId, 'couponId' => $couponId, @@ -103,6 +110,9 @@ class Auto_user_coupon_model extends HD_Model $data['team_id'] = $user['teamId'] ?: 0; $data['dep_id'] = $user['depId'] ?: 0; $data['area_id'] = $user['areaId'] ?: 0; + $data['province_id'] = $areaRow['province_id'] ?: 0; + $data['city_id'] = $areaRow['city_id'] ?: 0; + $data['county_id'] = $areaRow['county_id'] ?: 0; $this->receiver_clues_model->add($data); } else { $this->receiver_clues_model->update(['en_time' => date('Y-m-d H:i:s')], ['id' => $cluesRow['id']]); diff --git a/common/models/agent/pingan/Pingan_users_model.php b/common/models/agent/pingan/Pingan_users_model.php index 43baf73d..f71bdeec 100644 --- a/common/models/agent/pingan/Pingan_users_model.php +++ b/common/models/agent/pingan/Pingan_users_model.php @@ -9,10 +9,11 @@ class Pingan_users_model extends HD_Model const GROUP_TYPE_DEP = 3; //部经理 2级 const GROUP_TYPE_AREA = 4; //区经理 1级 - const GROUP_TYPE_CENTER_CONTACT=5; //中心对接人 - const GROUP_TYPE_PROJECT_CONTACT=6; //项目对接人 + const GROUP_TYPE_CENTER_CONTACT = 5; //中心对接人 + const GROUP_TYPE_PROJECT_CONTACT = 6; //项目对接人 const GROUP_TYPE_ORG_CONTACT = 8; //机构对接人 const GROUP_TYPE_TEAM_CONTACT = 9; //团队对接人 + const GROUP_TYPE_SUPER_ADMIN = 99; //超级管理员 const TYPE_CN = [ self::GROUP_TYPE_ATTEND => '坐席', self::GROUP_TYPE_TEAM => '团队长', @@ -21,7 +22,8 @@ class Pingan_users_model extends HD_Model self::GROUP_TYPE_CENTER_CONTACT => '中心对接人', self::GROUP_TYPE_PROJECT_CONTACT => '项目对接人', self::GROUP_TYPE_ORG_CONTACT => '机构对接人', - self::GROUP_TYPE_TEAM_CONTACT => '团队对接人' + self::GROUP_TYPE_TEAM_CONTACT => '团队对接人', + self::GROUP_TYPE_SUPER_ADMIN => '管理员' ]; const TYPE_CENTER = [ @@ -114,16 +116,17 @@ class Pingan_users_model extends HD_Model * 根据id获取数据 * @param array() $ids */ - public function get_map_by_ids($ids,$fileds=''){ + public function get_map_by_ids($ids, $fileds = '') + { $rows = []; $ids = array_filter($ids); - if($ids){ - if($ids){ - $cf_ids = implode(',',$ids); + if ($ids) { + if ($ids) { + $cf_ids = implode(',', $ids); $where = [ "id in ($cf_ids)" => null ]; - $rows = $this->map('id','',$where,'','','',$fileds); + $rows = $this->map('id', '', $where, '', '', '', $fileds); } } return $rows; diff --git a/common/models/receiver/Receiver_enroll_model.php b/common/models/receiver/Receiver_enroll_model.php index a1e1f8a5..ed8687b8 100644 --- a/common/models/receiver/Receiver_enroll_model.php +++ b/common/models/receiver/Receiver_enroll_model.php @@ -23,7 +23,7 @@ class Receiver_enroll_model extends HD_Model $where = [ 'mobile' => $mobile ]; - $rows = $this->select($where, '', '', '', 'DISTINCT brand_id,series_id'); + $rows = $this->select($where, 'id desc', '', '', 'DISTINCT brand_id,series_id'); $brandList = []; if($rows){ $brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));