增加领取优惠券记录城市信息

This commit is contained in:
lcc
2025-07-30 10:57:00 +08:00
parent 9f4280292c
commit 0524ecaabb
8 changed files with 61 additions and 80 deletions
+2 -1
View File
@@ -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());
}
@@ -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;
}
}
@@ -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);
}
@@ -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']]);
@@ -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');
+12 -2
View File
@@ -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']]);
@@ -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;
@@ -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'));