|
|
@@ -14,11 +14,19 @@ use app\user\model\UserModel;
|
|
|
use app\weixin\model\AccountLog;
|
|
|
use app\weixin\model\UserRechargeLog;
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
+use think\Db;
|
|
|
|
|
|
class SalesController extends AdminBaseController
|
|
|
{
|
|
|
+ /**
|
|
|
+ * 我的资源库
|
|
|
+ * @return mixed
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
public function index(){
|
|
|
- $content = hook_one('admin_pools_presale_view');
|
|
|
+ $content = hook_one('admin_sales_index_view');
|
|
|
|
|
|
if (!empty($content)) {
|
|
|
return $content;
|
|
|
@@ -32,6 +40,7 @@ class SalesController extends AdminBaseController
|
|
|
->leftJoin('user u','p.user_id=u.id')
|
|
|
->leftJoin('user s','s.id=p.sale_uid')
|
|
|
->leftJoin('user_profile up','up.userid=u.id')
|
|
|
+ ->where('p.expire_at','>=', date('Y-m-d H:i:s', time() - 3* 86400))
|
|
|
->where(['u.user_status'=> 1,'u.user_type'=> 2,'p.sale_uid'=> session('ADMIN_ID'),'p.status'=>1])
|
|
|
->where(function($query) use($params){
|
|
|
$uid = isset($params['uid'])? $params['uid'] : 0;
|
|
|
@@ -54,7 +63,7 @@ class SalesController extends AdminBaseController
|
|
|
$query->where('u.mobile','like',"{$mobile}%");
|
|
|
}
|
|
|
})
|
|
|
- ->field('p.id,p.user_id,u.openid,u.user_nickname,u.real_name,u.avatar,u.vip_auth,u.vip_expire,u.user_status,u.mobile,up.graduate,up.age,u.birthday,u.sex,up.married,up.education,up.city,p.id as pool_id,p.intention,p.followup_num,p.agency,p.create_time,p.last_follow_time,p.expire_at')
|
|
|
+ ->field('p.id,p.user_id,u.openid,u.user_nickname,u.real_name,u.avatar,u.vip_auth,u.vip_expire,u.user_status,u.mobile,up.graduate,up.age,u.birthday,u.sex,up.married,up.education,up.city,p.id as pool_id,p.intention,p.followup_num,p.agency,p.remark,p.create_time,p.last_follow_time,p.expire_at')
|
|
|
->order($sort);
|
|
|
|
|
|
$total = $list->count('p.id');
|
|
|
@@ -64,6 +73,312 @@ class SalesController extends AdminBaseController
|
|
|
$page = $list->render();
|
|
|
$datas = $list ? $list->toArray() : [];
|
|
|
$tags = ['无','意向强','有意向','完全不考虑','已到店','已成交','其他'];
|
|
|
+ $agencys = ['无','今天需跟进','明天需跟进','到期未跟进','今天坠海','明天坠海','一礼拜后坠海','其他'];
|
|
|
+ if ($datas) {
|
|
|
+ $educations = config('weixin.educations');
|
|
|
+ $marrieds = config('weixin.marrieds');
|
|
|
+ foreach ($datas['data'] as $k => &$item) {
|
|
|
+ $item['avatar'] = $item['avatar']? cmf_get_image_preview_url($item['avatar']):'';
|
|
|
+
|
|
|
+ $isVip = isset($item['vip_auth'])? $item['vip_auth'] : 0;
|
|
|
+ $vipExpire = isset($item['vip_expire'])? $item['vip_expire'] : 0;
|
|
|
+ $item['is_vip'] = $isVip && time() < $vipExpire? 1 : 0;
|
|
|
+
|
|
|
+ // 是否充值和消费过
|
|
|
+ $item['is_recharge'] = UserRechargeLog::check($item['id'], 2);
|
|
|
+ $item['is_cost'] = AccountLog::check($item['id']);
|
|
|
+
|
|
|
+ $profile = [];
|
|
|
+ $birthday = isset($item['birthday'])? $item['birthday'] : 0;
|
|
|
+ $year = $birthday? date('Y', $birthday) : '';
|
|
|
+ if($year){
|
|
|
+ $profile[] = '<em class="red">'.(date('Y') - $year).'</em>岁(<em class="primary">'.$year.'</em>)';
|
|
|
+ }
|
|
|
+
|
|
|
+ $married = isset($item['married'])? $item['married'] : 0;
|
|
|
+ $marriedText = isset($marrieds[$married])? $marrieds[$married] : '';
|
|
|
+ if($marriedText){
|
|
|
+ $profile[] = $marriedText;
|
|
|
+ }
|
|
|
+
|
|
|
+ $education = isset($item['education'])? $item['education'] : 0;
|
|
|
+ $educationText = $education && isset($educations[$education])? $educations[$education] : '';
|
|
|
+ if($educationText){
|
|
|
+ $profile[] = $educationText;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($item['graduate']) && $item['graduate']){
|
|
|
+ $profile[] = $item['graduate'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $city = isset($item['city'])? $item['city'] : '';
|
|
|
+ if($city){
|
|
|
+ $profile[] = $city;
|
|
|
+ }
|
|
|
+
|
|
|
+ $item['profile_text'] = $profile? join(' ', $profile) : '';
|
|
|
+
|
|
|
+ $dayTime = strtotime(date('Y-m-d'));
|
|
|
+ $expireAt = isset($item['expire_at'])? $item['expire_at'] : '';
|
|
|
+ $time = strtotime($expireAt);
|
|
|
+ $expireTime = $expireAt? strtotime($expireAt) - time() : 0;
|
|
|
+ $day = $expireTime>0? intval($expireTime/(24*3600)) : 0;
|
|
|
+ $hour = $expireTime>0? intval(($expireTime-($day*24*3600))/3600) : 0;
|
|
|
+ $item['expire_text'] = $day? $day.'天'.$hour.'小时' : '已坠海';
|
|
|
+ $item['is_expired'] = 0;
|
|
|
+ if($time >= time() && $time < $dayTime + 86400){
|
|
|
+ $item['expire_text'] = '今天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+86400 && $time < $dayTime + 2 * 86400){
|
|
|
+ $item['expire_text'] = '明天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+7*86400 && $time < $dayTime + 15 * 86400){
|
|
|
+ $item['expire_text'] = '一礼拜后坠海';
|
|
|
+ }else if($expireTime <= 0 ){
|
|
|
+ $item['mobile'] = formatStr($item['mobile']);
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ $item['expire_text'] = '已坠海';
|
|
|
+ }
|
|
|
+
|
|
|
+ $intention = isset($item['intention'])? $item['intention'] : 0;
|
|
|
+ $item['intention_text'] = $intention && isset($tags[$intention])? $tags[$intention] : '';
|
|
|
+
|
|
|
+ }
|
|
|
+ unset($item);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assign('params', $params);
|
|
|
+ $this->assign('tags', $tags);
|
|
|
+ $this->assign('agencys', $agencys);
|
|
|
+ $this->assign('total', $total);
|
|
|
+ $this->assign('list', $datas['data']);
|
|
|
+ $this->assign('sales', UserModel::getSales());
|
|
|
+ $this->assign('page', $page);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 我的标签分类资源库
|
|
|
+ * @return mixed
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function tips(){
|
|
|
+ $content = hook_one('admin_sales_agency_view');
|
|
|
+
|
|
|
+ if (!empty($content)) {
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
+
|
|
|
+ $params = input();
|
|
|
+ $params['sort'] = isset($params['sort'])? $params['sort'] : 0;
|
|
|
+ $params['intention'] = isset($params['intention'])? $params['intention'] : 0;
|
|
|
+ $params['sort_type'] = isset($params['sort_type'])? $params['sort_type'] : 'desc';
|
|
|
+ $sort = $params['sort']==1? "p.create_time {$params['sort_type']}" : ($params['sort']==2? "p.expire_at {$params['sort_type']}" : "p.last_follow_time {$params['sort_type']}");
|
|
|
+ $list = PoolModel::alias('p')
|
|
|
+ ->leftJoin('user u','p.user_id=u.id')
|
|
|
+ ->leftJoin('user s','s.id=p.sale_uid')
|
|
|
+ ->leftJoin('user_profile up','up.userid=u.id')
|
|
|
+ ->where('p.expire_at','>=', date('Y-m-d H:i:s', time() - 3* 86400))
|
|
|
+ ->where(['u.user_status'=> 1,'u.user_type'=> 2,'p.sale_uid'=> session('ADMIN_ID'),'p.status'=>1])
|
|
|
+ ->where(function($query) use($params){
|
|
|
+ $uid = isset($params['uid'])? $params['uid'] : 0;
|
|
|
+ if($uid){
|
|
|
+ $query->where(['u.id'=> $uid]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $intention = isset($params['intention'])? intval($params['intention']) : 0;
|
|
|
+ if($intention){
|
|
|
+ $query->where('p.intention',$intention);
|
|
|
+ }
|
|
|
+
|
|
|
+ $nickname = isset($params['user_nickname'])? trim($params['user_nickname']) : '';
|
|
|
+ if($nickname){
|
|
|
+ $query->where('u.user_nickname','like',"{$nickname}%");
|
|
|
+ }
|
|
|
+
|
|
|
+ $realname = isset($params['real_name'])? trim($params['real_name']) : '';
|
|
|
+ if($realname){
|
|
|
+ $query->where('u.real_name','like',"{$realname}%");
|
|
|
+ }
|
|
|
+
|
|
|
+ $mobile = isset($params['mobile'])? trim($params['mobile']) : '';
|
|
|
+ if($mobile){
|
|
|
+ $query->where('u.mobile','like',"{$mobile}%");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->field('p.id,p.user_id,u.openid,u.user_nickname,u.real_name,u.avatar,u.vip_auth,u.vip_expire,u.user_status,u.mobile,up.graduate,up.age,u.birthday,u.sex,up.married,up.education,up.city,p.id as pool_id,p.intention,p.followup_num,p.agency,p.remark,p.create_time,p.last_follow_time,p.expire_at')
|
|
|
+ ->order($sort)
|
|
|
+ ->paginate(30, false, ['query' => request()->param()]);
|
|
|
+
|
|
|
+ // 获取分页显示
|
|
|
+ $page = $list->render();
|
|
|
+ $datas = $list ? $list->toArray() : [];
|
|
|
+ $tags = ['无','意向强','有意向','完全不考虑','已到店','已成交','其他'];
|
|
|
+ $agencys = ['无','今天需跟进','明天需跟进','到期未跟进','今天坠海','明天坠海','一礼拜后坠海','其他'];
|
|
|
+ if ($datas) {
|
|
|
+ $educations = config('weixin.educations');
|
|
|
+ $marrieds = config('weixin.marrieds');
|
|
|
+ foreach ($datas['data'] as $k => &$item) {
|
|
|
+ $item['avatar'] = $item['avatar']? cmf_get_image_preview_url($item['avatar']):'';
|
|
|
+
|
|
|
+ $isVip = isset($item['vip_auth'])? $item['vip_auth'] : 0;
|
|
|
+ $vipExpire = isset($item['vip_expire'])? $item['vip_expire'] : 0;
|
|
|
+ $item['is_vip'] = $isVip && time() < $vipExpire? 1 : 0;
|
|
|
+
|
|
|
+ // 是否充值和消费过
|
|
|
+ $item['is_recharge'] = UserRechargeLog::check($item['id'], 2);
|
|
|
+ $item['is_cost'] = AccountLog::check($item['id']);
|
|
|
+
|
|
|
+ $profile = [];
|
|
|
+ $birthday = isset($item['birthday'])? $item['birthday'] : 0;
|
|
|
+ $year = $birthday? date('Y', $birthday) : '';
|
|
|
+ if($year){
|
|
|
+ $profile[] = '<em class="red">'.(date('Y') - $year).'</em>岁(<em class="primary">'.$year.'</em>)';
|
|
|
+ }
|
|
|
+
|
|
|
+ $married = isset($item['married'])? $item['married'] : 0;
|
|
|
+ $marriedText = isset($marrieds[$married])? $marrieds[$married] : '';
|
|
|
+ if($marriedText){
|
|
|
+ $profile[] = $marriedText;
|
|
|
+ }
|
|
|
+
|
|
|
+ $education = isset($item['education'])? $item['education'] : 0;
|
|
|
+ $educationText = $education && isset($educations[$education])? $educations[$education] : '';
|
|
|
+ if($educationText){
|
|
|
+ $profile[] = $educationText;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($item['graduate']) && $item['graduate']){
|
|
|
+ $profile[] = $item['graduate'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $city = isset($item['city'])? $item['city'] : '';
|
|
|
+ if($city){
|
|
|
+ $profile[] = $city;
|
|
|
+ }
|
|
|
+
|
|
|
+ $item['profile_text'] = $profile? join(' ', $profile) : '';
|
|
|
+
|
|
|
+ $dayTime = strtotime(date('Y-m-d'));
|
|
|
+ $expireAt = isset($item['expire_at'])? $item['expire_at'] : '';
|
|
|
+ $time = strtotime($expireAt);
|
|
|
+ $expireTime = $expireAt? strtotime($expireAt) - time() : 0;
|
|
|
+ $day = $expireTime>0? intval($expireTime/(24*3600)) : 0;
|
|
|
+ $hour = $expireTime>0? intval(($expireTime-($day*24*3600))/3600) : 0;
|
|
|
+ $item['expire_text'] = $day? $day.'天'.$hour.'小时' : '已坠海';
|
|
|
+ $item['is_expired'] = 0;
|
|
|
+ if($time >= time() && $time < $dayTime + 86400){
|
|
|
+ $item['expire_text'] = '今天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+86400 && $time < $dayTime + 2 * 86400){
|
|
|
+ $item['expire_text'] = '明天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+7*86400 && $time < $dayTime + 15 * 86400){
|
|
|
+ $item['expire_text'] = '一礼拜后坠海';
|
|
|
+ }else if($expireTime <= 0 ){
|
|
|
+ $item['mobile'] = formatStr($item['mobile']);
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ $item['expire_text'] = '已坠海';
|
|
|
+ }
|
|
|
+
|
|
|
+ $intention = isset($item['intention'])? $item['intention'] : 0;
|
|
|
+ $item['intention_text'] = $intention && isset($tags[$intention])? $tags[$intention] : '';
|
|
|
+
|
|
|
+ }
|
|
|
+ unset($item);
|
|
|
+ }
|
|
|
+
|
|
|
+ $total = 0;
|
|
|
+ $tagCounts = [];
|
|
|
+ $counts = PoolModel::getCounts($params,'intention');
|
|
|
+ foreach($tags as $k => $v){
|
|
|
+ $tagCounts[$k] = [
|
|
|
+ 'name'=> $v,
|
|
|
+ 'num'=> 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($counts as $v){
|
|
|
+ $total += $v['count'];
|
|
|
+ $intention = isset($v['intention'])? $v['intention'] : 0;
|
|
|
+ if(isset($tagCounts[$intention])){
|
|
|
+ $tagCounts[$intention]['num'] = $v['count'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assign('params', $params);
|
|
|
+ $this->assign('tags', $tags);
|
|
|
+ $this->assign('tagCounts', $tagCounts);
|
|
|
+ $this->assign('agencys', $agencys);
|
|
|
+ $this->assign('total', $total);
|
|
|
+ $this->assign('list', $datas['data']);
|
|
|
+ $this->assign('sales', UserModel::getSales());
|
|
|
+ $this->assign('page', $page);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 我的资源库
|
|
|
+ * @return mixed
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ */
|
|
|
+ public function agency(){
|
|
|
+ $content = hook_one('admin_sales_agency_view');
|
|
|
+
|
|
|
+ if (!empty($content)) {
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
+
|
|
|
+ $params = input();
|
|
|
+ $params['agency'] = isset($params['agency'])? $params['agency'] : 0;
|
|
|
+ $params['sort'] = isset($params['sort'])? $params['sort'] : 0;
|
|
|
+ $params['sort_type'] = isset($params['sort_type'])? $params['sort_type'] : 'desc';
|
|
|
+ $sort = $params['sort']==1? "p.create_time {$params['sort_type']}" : ($params['sort']==2? "p.expire_at {$params['sort_type']}" : "p.last_follow_time {$params['sort_type']}");
|
|
|
+ $list = PoolModel::alias('p')
|
|
|
+ ->leftJoin('user u','p.user_id=u.id')
|
|
|
+ ->leftJoin('user s','s.id=p.sale_uid')
|
|
|
+ ->leftJoin('user_profile up','up.userid=u.id')
|
|
|
+ ->where('p.expire_at','>=', date('Y-m-d H:i:s', time() - 3* 86400))
|
|
|
+ ->where(['u.user_status'=> 1,'u.user_type'=> 2,'p.sale_uid'=> session('ADMIN_ID'),'p.status'=>1])
|
|
|
+ ->where(function($query) use($params){
|
|
|
+ $uid = isset($params['uid'])? $params['uid'] : 0;
|
|
|
+ if($uid){
|
|
|
+ $query->where(['u.id'=> $uid]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $agency = isset($params['agency'])? intval($params['agency']) : 0;
|
|
|
+ if($agency){
|
|
|
+ $query->where('p.agency',$agency);
|
|
|
+ }
|
|
|
+
|
|
|
+ $nickname = isset($params['user_nickname'])? trim($params['user_nickname']) : '';
|
|
|
+ if($nickname){
|
|
|
+ $query->where('u.user_nickname','like',"{$nickname}%");
|
|
|
+ }
|
|
|
+
|
|
|
+ $realname = isset($params['real_name'])? trim($params['real_name']) : '';
|
|
|
+ if($realname){
|
|
|
+ $query->where('u.real_name','like',"{$realname}%");
|
|
|
+ }
|
|
|
+
|
|
|
+ $mobile = isset($params['mobile'])? trim($params['mobile']) : '';
|
|
|
+ if($mobile){
|
|
|
+ $query->where('u.mobile','like',"{$mobile}%");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->field('p.id,p.user_id,u.openid,u.user_nickname,u.real_name,u.avatar,u.vip_auth,u.vip_expire,u.user_status,u.mobile,up.graduate,up.age,u.birthday,u.sex,up.married,up.education,up.city,p.id as pool_id,p.intention,p.followup_num,p.agency,p.remark,p.create_time,p.last_follow_time,p.expire_at')
|
|
|
+ ->order($sort)
|
|
|
+ ->paginate(30, false, ['query' => request()->param()]);
|
|
|
+
|
|
|
+ // 获取分页显示
|
|
|
+ $page = $list->render();
|
|
|
+ $datas = $list ? $list->toArray() : [];
|
|
|
+ $tags = ['无','意向强','有意向','完全不考虑','已到店','已成交','其他'];
|
|
|
+ $agencys = ['无','今天需跟进','明天需跟进','到期未跟进','今天坠海','明天坠海','一礼拜后坠海','其他'];
|
|
|
if ($datas) {
|
|
|
$educations = config('weixin.educations');
|
|
|
$marrieds = config('weixin.marrieds');
|
|
|
@@ -108,11 +423,27 @@ class SalesController extends AdminBaseController
|
|
|
|
|
|
$item['profile_text'] = $profile? join(' ', $profile) : '';
|
|
|
|
|
|
+ $dayTime = strtotime(date('Y-m-d'));
|
|
|
$expireAt = isset($item['expire_at'])? $item['expire_at'] : '';
|
|
|
+ $time = strtotime($expireAt);
|
|
|
$expireTime = $expireAt? strtotime($expireAt) - time() : 0;
|
|
|
$day = $expireTime>0? intval($expireTime/(24*3600)) : 0;
|
|
|
- $hour = $expireTime>0? intval($expireTime%(24*3600)/3600) : 0;
|
|
|
- $item['expire_text'] = $day? $day.'天'.$hour.'小时' : '已到期';
|
|
|
+ $hour = $expireTime>0? intval(($expireTime-($day*24*3600))/3600) : 0;
|
|
|
+ $item['expire_text'] = $day? $day.'天'.$hour.'小时' : '已坠海';
|
|
|
+ $item['is_expired'] = 0;
|
|
|
+ if($time >= time() && $time < $dayTime + 86400){
|
|
|
+ $item['expire_text'] = '今天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+86400 && $time < $dayTime + 2 * 86400){
|
|
|
+ $item['expire_text'] = '明天坠海';
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ }else if($time>=$dayTime+7*86400 && $time < $dayTime + 15 * 86400){
|
|
|
+ $item['expire_text'] = '一礼拜后坠海';
|
|
|
+ }else if($expireTime <= 0 ){
|
|
|
+ $item['mobile'] = formatStr($item['mobile']);
|
|
|
+ $item['is_expired'] = 1;
|
|
|
+ $item['expire_text'] = '已坠海';
|
|
|
+ }
|
|
|
|
|
|
$intention = isset($item['intention'])? $item['intention'] : 0;
|
|
|
$item['intention_text'] = $intention && isset($tags[$intention])? $tags[$intention] : '';
|
|
|
@@ -121,8 +452,28 @@ class SalesController extends AdminBaseController
|
|
|
unset($item);
|
|
|
}
|
|
|
|
|
|
+ $total = 0;
|
|
|
+ $agencyCounts = [];
|
|
|
+ $counts = PoolModel::getCounts($params,'agency');
|
|
|
+ foreach($agencys as $k => $v){
|
|
|
+ $agencyCounts[$k] = [
|
|
|
+ 'name'=> $v,
|
|
|
+ 'num'=> 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($counts as $v){
|
|
|
+ $total += $v['count'];
|
|
|
+ $agency = isset($v['agency'])? $v['agency'] : -1;
|
|
|
+ if($agency>0 && isset($agencyCounts[$agency])){
|
|
|
+ $agencyCounts[$agency]['num'] = $v['count'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$this->assign('params', $params);
|
|
|
$this->assign('tags', $tags);
|
|
|
+ $this->assign('agencys', $agencys);
|
|
|
+ $this->assign('agencyCounts', $agencyCounts);
|
|
|
$this->assign('total', $total);
|
|
|
$this->assign('list', $datas['data']);
|
|
|
$this->assign('sales', UserModel::getSales());
|
|
|
@@ -157,4 +508,37 @@ class SalesController extends AdminBaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置跟进情况(待办)
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
+ */
|
|
|
+ public function setAgency(){
|
|
|
+ $poolId = input('pool_id', 0);
|
|
|
+ if(empty($poolId)){
|
|
|
+ $this->error("请选择操作项!", '');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(session('ADMIN_ID')<=0){
|
|
|
+ $this->error("非法操作!", '');
|
|
|
+ }
|
|
|
+
|
|
|
+ $agencyId = input('agencyId', 0);
|
|
|
+ $remark = input('remark','');
|
|
|
+ if($agencyId <= 0){
|
|
|
+ $this->error("请设置跟进情况!", '');
|
|
|
+ }
|
|
|
+
|
|
|
+ $time = date('Y-m-d H:i:s');
|
|
|
+ $where = ['sale_uid'=> session('ADMIN_ID'),'id'=> $poolId,'type'=>0];
|
|
|
+ $info = PoolModel::where($where)->find();
|
|
|
+ $expireAt = isset($info['expired_at'])? $info['expired_at'] : '';
|
|
|
+ $followNum = isset($info['followup_num'])? $info['followup_num'] : 0;
|
|
|
+ if(PoolModel::where($where)->update(['agency'=> $agencyId,'remark'=> $remark,'last_follow_time'=> $time])){
|
|
|
+ PoolModel::where($where)->setInc('followup_num', 1);
|
|
|
+ $this->success('设置跟进情况成功!', '',['num'=> $followNum+1, 'time'=> $time]);
|
|
|
+ }else{
|
|
|
+ $this->error('设置跟进情况失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|