First commit
This commit is contained in:
161
app/card/common.php
Executable file
161
app/card/common.php
Executable file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
use app\card\model\UserInfo;
|
||||
use think\facade\Db;
|
||||
|
||||
//获取最小account
|
||||
function longbingGetUserInfoMinAutoCount($uniacid)
|
||||
{
|
||||
$user_info_model = new UserInfo();
|
||||
$count = $user_info_model->getStaffMaxAutoCount(['uniacid' => $uniacid]);
|
||||
if(empty($count)) $count = 0;
|
||||
return (int)$count;
|
||||
}
|
||||
function longbingGetWxAppTabbarResponse($data)
|
||||
{
|
||||
if(empty($data)) return [];
|
||||
//数据处理
|
||||
$data['list'] = [];
|
||||
//处理过的参数
|
||||
$menus = [];
|
||||
//默认设置
|
||||
$data['color'] = '#5d6268';
|
||||
// $data['selectedColor'] = '#21bf34';
|
||||
$data['selectedColor'] = '#19c865';
|
||||
$data['backgroundColor'] = '#fff';
|
||||
$data['borderStyle'] = 'white';
|
||||
//名片
|
||||
if(isset($data['menu1_is_hide']) && !empty($data['menu1_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['is_show'] = $data['menu1_is_hide'];
|
||||
$val['key'] = 1;
|
||||
$val['iconPath'] = 'icon-mingpian';
|
||||
$val['selectedIconPath'] = 'icon-mingpian1';
|
||||
$val['pageComponents'] = 'cardHome';
|
||||
if(isset($data['menu1_name'])) $val['name'] = $data['menu1_name'];
|
||||
if(isset($data['menu1_url'])) $val['url'] = $data['menu1_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu1_url_out'])) $val['url_out'] = $data['menu1_url_out'];
|
||||
if(isset($data['menu1_url_jump_way'])) $val['jump_way'] = $data['menu1_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//商城
|
||||
if(isset($data['menu2_is_hide']) && !empty($data['menu2_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 2;
|
||||
$val['is_show'] = $data['menu2_is_hide'];
|
||||
$val['iconPath'] = 'icon-shangcheng1';
|
||||
$val['selectedIconPath'] = 'icon-shangcheng';
|
||||
$val['pageComponents'] = 'shopHome';
|
||||
if(isset($data['menu2_name'])) $val['name'] = $data['menu2_name'];
|
||||
if(isset($data['menu2_url'])) $val['url'] = $data['menu2_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu2_url_out'])) $val['url_out'] = $data['menu2_url_out'];
|
||||
if(isset($data['menu2_url_jump_way'])) $val['url_jump_way'] = $data['menu2_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//动态
|
||||
if(isset($data['menu3_is_hide']) && !empty($data['menu3_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 3;
|
||||
$val['is_show'] = $data['menu3_is_hide'];
|
||||
$val['iconPath'] = 'icon-dongtai1';
|
||||
$val['selectedIconPath'] = 'icon-dongtai';
|
||||
$val['pageComponents'] = 'infoHome';
|
||||
if(isset($data['menu3_name'])) $val['name'] = $data['menu3_name'];
|
||||
if(isset($data['menu3_url'])) $val['url'] = $data['menu3_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu3_url_out'])) $val['url_out'] = $data['menu3_url_out'];
|
||||
if(isset($data['menu3_url_jump_way'])) $val['url_jump_way'] = $data['menu3_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//官网
|
||||
if(isset($data['menu4_is_hide']) && !empty($data['menu4_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 4;
|
||||
$val['is_show'] = $data['menu4_is_hide'];
|
||||
$val['iconPath'] = 'icon-guanwang';
|
||||
$val['selectedIconPath'] = 'icon-guanwang1';
|
||||
$val['pageComponents'] = 'websiteHome';
|
||||
if(isset($data['menu4_name'])) $val['name'] = $data['menu4_name'];
|
||||
if(isset($data['menu4_url'])) $val['url'] = $data['menu4_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu4_url_out'])) $val['url_out'] = $data['menu4_url_out'];
|
||||
if(isset($data['menu4_url_jump_way'])) $val['url_jump_way'] = $data['menu4_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//预约
|
||||
if(isset($data['menu_appoint_is_hide']) && !empty($data['menu_appoint_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 7;
|
||||
$val['is_show'] = $data['menu_appoint_is_hide'];
|
||||
$val['iconPath'] = 'icon-yuyue';
|
||||
$val['selectedIconPath'] = 'icon-yuyue1';
|
||||
$val['pageComponents'] = 'reserveHome';
|
||||
if(isset($data['menu_appoint_name'])) $val['name'] = $data['menu_appoint_name'];
|
||||
if(isset($data['menu_appoint_url'])) $val['url'] = $data['menu_appoint_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu_appoint_url_out'])) $val['url_out'] = $data['menu_appoint_url_out'];
|
||||
if(isset($data['menu_appoint_url_jump_way'])) $val['url_jump_way'] = $data['menu_appoint_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//活动报名
|
||||
if(isset($data['menu_activity_is_show']) && !empty($data['menu_activity_is_show']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 6;
|
||||
$val['is_show'] = $data['menu_activity_is_show'];
|
||||
$val['iconPath'] = 'icon-huodong1';
|
||||
$val['selectedIconPath'] = 'icon-huodong';
|
||||
$val['pageComponents'] = 'avtivityHome';
|
||||
if(isset($data['menu_activity_name'])) $val['name'] = $data['menu_activity_name'];
|
||||
if(isset($data['menu_activity_url'])) $val['url'] = $data['menu_activity_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu_activity_url_out'])) $val['url_out'] = $data['menu_activity_url_out'];
|
||||
if(isset($data['menu_activity_url_jump_way'])) $val['url_jump_way'] = $data['menu_activity_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
//房产
|
||||
if(isset($data['menu_house_is_show']) && !empty($data['menu_house_is_show']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 5;
|
||||
$val['is_show'] = $data['menu_house_is_show'];
|
||||
$val['iconPath'] = 'icon-fangchan1';
|
||||
$val['selectedIconPath'] = 'icon-fangchan';
|
||||
$val['pageComponents'] = 'houseHome';
|
||||
if(isset($data['menu_house_name']))$val['name'] = $data['menu_house_name'];
|
||||
if(isset($data['menu_house_url']))$val['url'] = $data['menu_house_url'];
|
||||
$val['url'] = "/pages/user/home";
|
||||
if(isset($data['menu_house_url_out']))$val['url_out'] = $data['menu_house_url_out'];
|
||||
if(isset($data['menu_house_url_jump_way']))$val['url_jump_way'] = $data['menu_house_url_jump_way'];
|
||||
$data['list'][] = $val;
|
||||
}
|
||||
$menus = ["menu1_name","menu1_is_hide","menu1_url","menu1_url_out","menu1_url_jump_way","menu2_name","menu2_is_hide","menu2_url","menu2_url_out","menu2_url_jump_way","menu3_name","menu3_is_hide","menu3_url","menu3_url_out","menu3_url_jump_way","menu4_name","menu4_is_hide","menu4_url","menu4_url_out","menu4_url_jump_way","menu_appoint_name","menu_appoint_is_hide","menu_appoint_url","menu_appoint_url_out","menu_appoint_url_jump_way","menu_activity_is_show","menu_activity_name","menu_activity_is_hide","menu_activity_url","menu_activity_url_out","menu_activity_url_jump_way","menu_house_is_show","menu_house_name","menu_house_is_hide","menu_house_url","menu_house_url_out","menu_house_url_jump_way"];
|
||||
foreach($menus as $menu)
|
||||
{
|
||||
unset($data[$menu]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
if ( !function_exists( 'wxContentRlue' ) ) {
|
||||
//检测评论发表是否合法
|
||||
function wxContentRlue($content, $access_token)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token={$access_token}";
|
||||
$tmp = [
|
||||
'url' => $url,
|
||||
'data' => [
|
||||
'content' => urlencode($content)
|
||||
],
|
||||
];
|
||||
$rest = lbCurlPost($tmp['url'], urldecode(json_encode($tmp['data'])));
|
||||
$rest = json_decode($rest, true);
|
||||
return $rest;
|
||||
}
|
||||
}
|
||||
|
||||
35
app/card/config.php
Executable file
35
app/card/config.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Notes:
|
||||
* User: chenniang
|
||||
* Date: 2019-11-14
|
||||
* Time: 18:32
|
||||
* ${PARAM_DOC}
|
||||
* @return ${TYPE_HINT}
|
||||
* ${THROWS_DOC}
|
||||
*/
|
||||
|
||||
|
||||
$tabbar_BusinessCard = [
|
||||
"key" => 1,
|
||||
"is_show" => 1,
|
||||
"iconPath" =>"icon-mingpian",
|
||||
"selectedIconPath"=> "icon-mingpian1",
|
||||
"pageComponents" => "cardHome",
|
||||
"name" => "名片",
|
||||
"url" => "/pages/user/home",
|
||||
"url_out" => "",
|
||||
"url_jump_way" => 0
|
||||
];
|
||||
|
||||
$page_BusinessCard = [
|
||||
|
||||
];
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'BusinessCard_tabbar' => $tabbar_BusinessCard,
|
||||
'BusinessCard_page' => $page_BusinessCard
|
||||
|
||||
];
|
||||
2463
app/card/controller/Admin.php
Executable file
2463
app/card/controller/Admin.php
Executable file
File diff suppressed because it is too large
Load Diff
41
app/card/controller/CardCacheKey.php
Executable file
41
app/card/controller/CardCacheKey.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\card\controller;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/26 14:16
|
||||
* Class CardCacheKey
|
||||
* @package app\card\controller
|
||||
*/
|
||||
class CardCacheKey
|
||||
{
|
||||
|
||||
/**
|
||||
* 名片配置缓存key
|
||||
*
|
||||
* @param $uniacid
|
||||
* @return string
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/26 14:21
|
||||
*/
|
||||
public static function cardAppConfig($uniacid){
|
||||
|
||||
return longbing_get_cache_key('card_app_config' , $uniacid) ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
45
app/card/controller/GetImage.php
Executable file
45
app/card/controller/GetImage.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\card\controller;
|
||||
|
||||
use app\BaseController;
|
||||
|
||||
class GetImage extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 将线上图片转为本地图片用于前端cavans画图
|
||||
*/
|
||||
public function getImage ()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
$path = $param['path'] ?? null ;
|
||||
if (!$path ) {
|
||||
return $this->error('请传入参数');
|
||||
}
|
||||
//
|
||||
// $path = $_SERVER[ 'QUERY_STRING' ];
|
||||
// $position = strpos($path, 'getImage&path=');
|
||||
// $sub_str = substr($path, $position + 14);
|
||||
// $path = urldecode($sub_str);
|
||||
//把https 替换为 http
|
||||
$path = str_replace("https://" , "http://" , $path) ;
|
||||
//判断类型
|
||||
$type_img = getimagesize($path);
|
||||
|
||||
ob_start();
|
||||
|
||||
if ( strpos($type_img[ 'mime' ], 'jpeg') ) {
|
||||
$resourch = imagecreatefromjpeg($path);
|
||||
imagejpeg($resourch);
|
||||
} elseif ( strpos($type_img[ 'mime' ], 'png') ) {
|
||||
$resourch = imagecreatefrompng($path);
|
||||
imagepng($resourch);
|
||||
}
|
||||
|
||||
$content = ob_get_clean();
|
||||
imagedestroy($resourch);
|
||||
return response($content, 200, [ 'Content-Length' => strlen($content) ])->contentType('image/png');
|
||||
}
|
||||
}
|
||||
2561
app/card/controller/Index.php
Executable file
2561
app/card/controller/Index.php
Executable file
File diff suppressed because it is too large
Load Diff
179
app/card/controller/IndexV2.php
Executable file
179
app/card/controller/IndexV2.php
Executable file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\controller;
|
||||
|
||||
use app\ApiRest;
|
||||
use app\card\model\CardCount;
|
||||
use app\card\model\CardCoupon;
|
||||
use app\card\model\CardCouponRecord;
|
||||
use app\card\model\CardExtension;
|
||||
use app\card\model\CardFormId;
|
||||
use app\card\model\CardJob;
|
||||
use app\card\model\CardTags;
|
||||
use app\card\model\CardType;
|
||||
use app\card\model\CardUserLabel;
|
||||
use app\card\model\CardUserTags;
|
||||
use app\card\model\Collection;
|
||||
use app\card\model\Company;
|
||||
use app\card\model\Config;
|
||||
use app\card\model\DefaultSetting;
|
||||
use app\card\model\Job;
|
||||
use app\card\model\User;
|
||||
use app\card\model\UserInfo;
|
||||
use app\card\model\UserPhone;
|
||||
use app\card\model\UserSk;
|
||||
use app\Common\model\LongbingCardFromId;
|
||||
use app\company\model\CardCompany;
|
||||
use app\radar\model\RadarCount;
|
||||
use app\shop\model\IndexUserInfo;
|
||||
use app\shop\model\IndexShopCollage;
|
||||
use longbingcore\permissions\Tabbar;
|
||||
use longbingcore\tools\LongbingArr;
|
||||
use think\App;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use function Qiniu\explodeUpToken;
|
||||
|
||||
class IndexV2 extends ApiRest
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['configV2'];
|
||||
|
||||
protected $modelUser;
|
||||
protected $modelUserInfo;
|
||||
protected $modelCollection;
|
||||
protected $modelCompany;
|
||||
protected $modelConfig;
|
||||
protected $app;
|
||||
|
||||
// 继承 验证用户登陆
|
||||
public function __construct ( App $app )
|
||||
{
|
||||
parent::__construct( $app );
|
||||
$this->app = $app;
|
||||
$this->modelUser = new User();
|
||||
$this->modelUserInfo = new UserInfo();
|
||||
$this->modelCollection = new Collection();
|
||||
$this->modelCompany = new Company();
|
||||
$this->modelConfig = new Config();
|
||||
//$this->_user_id = '2';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Purpose: 小程序配置接口
|
||||
*
|
||||
* @Method GET
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function config ()
|
||||
{
|
||||
|
||||
$data = longbingGetAppConfig($this->_uniacid);
|
||||
|
||||
unset( $data[ 'auth_code' ] );
|
||||
|
||||
$exist = Db::query( 'show tables like "%longbing_card_config%"' );
|
||||
|
||||
$auth_info = false;
|
||||
|
||||
$cardauth2_config_exist = Db::query('show tables like "%longbing_cardauth2_config%"');
|
||||
|
||||
if (!empty($exist) && !empty($cardauth2_config_exist)) {
|
||||
$auth_info = Db::name('longbing_cardauth2_config')
|
||||
->where([['modular_id', '=', $this->_uniacid]])
|
||||
->find();
|
||||
}
|
||||
$data[ 'is_pay_shop' ] = 1;
|
||||
// 判断能不能使用商城的支付功能
|
||||
if ( $auth_info && isset( $auth_info[ 'pay_shop' ] ) && $auth_info[ 'pay_shop' ] == 0 )
|
||||
{
|
||||
$data[ 'is_pay_shop' ] = 0;
|
||||
}
|
||||
if ( isset( $data[ 'btn_talk' ] ) && !$data[ 'btn_talk' ] )
|
||||
{
|
||||
$data[ 'btn_talk' ] = '面议';
|
||||
}
|
||||
$data['tabBar1'] = [];
|
||||
//tabbar用新的方式返回
|
||||
$data['tabBar1'] = Tabbar::all($this->_uniacid, $this->_user_id);
|
||||
|
||||
$pluginAuth = longbingGetPluginAuth($this->_uniacid, $this->_user_id, $auth_info);
|
||||
|
||||
$data = array_merge($data, $pluginAuth);
|
||||
|
||||
$data = LongbingArr::delBykey($data , ['web_manage_meta_config','wx_appid','wx_tplid'
|
||||
,'update_time','create_time','app_secret','appid',
|
||||
'aliyun_sms_access_key_id','aliyun_sms_access_key_secret'
|
||||
,'coupon_pass','corpsecret',
|
||||
'coupon_pass','order_pwd','mini_template_id']) ;
|
||||
|
||||
$config_model = new DefaultSetting();
|
||||
//默认配置
|
||||
$DefaultSetting = $config_model->settingInfo(['uniacid'=>$this->_uniacid],'primaryColor,subColor,share_more');
|
||||
//主色
|
||||
$data['primaryColor'] = !empty($DefaultSetting['primaryColor'])?$DefaultSetting['primaryColor']:'#19c865';
|
||||
//辅色
|
||||
$data['subColor'] = !empty($DefaultSetting['subColor'])?$DefaultSetting['subColor']:'#f86c53';
|
||||
|
||||
$data['share_more'] = $DefaultSetting['share_more'];
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-25 09:44
|
||||
* @功能说明:
|
||||
*/
|
||||
public function configV2(){
|
||||
|
||||
$data = longbingGetAppConfig($this->_uniacid);
|
||||
|
||||
unset( $data[ 'auth_code' ] );
|
||||
|
||||
$exist = Db::query( 'show tables like "%longbing_card_config%"' );
|
||||
|
||||
$auth_info = false;
|
||||
|
||||
$cardauth2_config_exist = Db::query('show tables like "%longbing_cardauth2_config%"');
|
||||
|
||||
if (!empty($exist) && !empty($cardauth2_config_exist)) {
|
||||
$auth_info = Db::name('longbing_cardauth2_config')
|
||||
->where([['modular_id', '=', $this->_uniacid]])
|
||||
->find();
|
||||
}
|
||||
$data[ 'is_pay_shop' ] = 1;
|
||||
// 判断能不能使用商城的支付功能
|
||||
if ( $auth_info && isset( $auth_info[ 'pay_shop' ] ) && $auth_info[ 'pay_shop' ] == 0 )
|
||||
{
|
||||
$data[ 'is_pay_shop' ] = 0;
|
||||
}
|
||||
if ( isset( $data[ 'btn_talk' ] ) && !$data[ 'btn_talk' ] )
|
||||
{
|
||||
$data[ 'btn_talk' ] = '面议';
|
||||
}
|
||||
$data['tabBar1'] = [];
|
||||
//tabbar用新的方式返回
|
||||
//$data['tabBar1'] = Tabbar::all($this->_uniacid, $this->_user_id);
|
||||
$config_model = new DefaultSetting();
|
||||
//默认配置
|
||||
$DefaultSetting = $config_model->settingInfo(['uniacid'=>$this->_uniacid],'primaryColor,subColor,share_more');
|
||||
//主色
|
||||
$data['primaryColor'] = !empty($DefaultSetting['primaryColor'])?$DefaultSetting['primaryColor']:'#19c865';
|
||||
//辅色
|
||||
$data['subColor'] = !empty($DefaultSetting['subColor'])?$DefaultSetting['subColor']:'#f86c53';
|
||||
|
||||
$data['share_more'] = $DefaultSetting['share_more'];
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
163
app/card/info/AdminMenu.php
Executable file
163
app/card/info/AdminMenu.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
$menu = <<<BUSINESSCARD
|
||||
|
||||
{
|
||||
"path": "/businessCard",
|
||||
"component": "Layout",
|
||||
"redirect": "/businessCard/staffCard",
|
||||
"meta": {
|
||||
"menuName": "BusinessCard",
|
||||
"icon": "icon-mingpian",
|
||||
"subNavName": [{
|
||||
"name": "CardInfo",
|
||||
"url": [{
|
||||
"name": "StaffCard",
|
||||
"url": "/businessCard/staffCard"
|
||||
}, {
|
||||
"name": "ImpressionLabel",
|
||||
"url": "/businessCard/tag"
|
||||
}]
|
||||
}, {
|
||||
"name": "CardSetting",
|
||||
"url": [{
|
||||
"name": "ExemptionPassword",
|
||||
"url": "/businessCard/exemptionPwd"
|
||||
}, {
|
||||
"name": "MobileSetting",
|
||||
"url": "/businessCard/mobileSetting"
|
||||
}, {
|
||||
"name": "MediaSetting",
|
||||
"url": "/businessCard/mediaSetting"
|
||||
}, {
|
||||
"name": "CardSetting",
|
||||
"url": "/businessCard/cardSetting"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"children": [{
|
||||
"path": "staffCard",
|
||||
"name": "StaffCard",
|
||||
"component": "/businessCard/manage/staffCard",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "StaffCard",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editCard",
|
||||
"name": "EditCard",
|
||||
"component": "/businessCard/manage/editCard",
|
||||
"meta": {
|
||||
"refresh": false,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "EditCard",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "tag",
|
||||
"name": "ImpressionLabel",
|
||||
"component": "/businessCard/manage/tag",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "ImpressionLabel",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "exemptionPwd",
|
||||
"name": "ExemptionPassword",
|
||||
"component": "/businessCard/set/exemptionPwd",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "ExemptionPassword",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "mobileSetting",
|
||||
"name": "MobileSetting",
|
||||
"component": "/businessCard/set/mobileSetting",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "MobileSetting",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "mediaSetting",
|
||||
"name": "MediaSetting",
|
||||
"component": "/businessCard/set/mediaSetting",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "MediaSetting",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "cardSetting",
|
||||
"name": "CardSetting",
|
||||
"component": "/businessCard/set/cardSetting",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "CardManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "CardSetting",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
BUSINESSCARD;
|
||||
|
||||
//return json_decode($menu, true) ;
|
||||
|
||||
return ['card' => $menu];
|
||||
|
||||
|
||||
87
app/card/info/DiyCompoents.php
Executable file
87
app/card/info/DiyCompoents.php
Executable file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
$gzh = <<<GZH
|
||||
|
||||
{"title":"公众号组件","type":"official","icon":"iconOfficial","isDelete":true,"addNumber":1,"data":{"title":"公众号组件"}}
|
||||
|
||||
GZH;
|
||||
|
||||
|
||||
$acrd = <<<CARD
|
||||
|
||||
{"title":"名片模块","type":"cardModule","icon":"iconCardModule","isDelete":true,"addNumber":1,"attr":[{"title":"显示发名片按钮","type":"Switch","name":"isShowSendBtn"},{"title":"显示保存到通讯录","type":"Switch","name":"isShowSaveBtn"},{"title":"显示电话","type":"Switch","name":"isShowPhone"},{"title":"显示座机","type":"Switch","name":"isShowZuoji"},{"title":"显示400热线","type":"Switch","name":"isShowHotPhone"},{"title":"显示微信","type":"Switch","name":"isShowWechat"},{"title":"显示邮箱","type":"Switch","name":"isShowEmail"},{"title":"显示公司名称","type":"Switch","name":"isShowCompanyName"},{"title":"显示公司地址","type":"Switch","name":"isShowCompanyAddr"}],"data":{"title":"名片模块","isShowSendBtn":true,"isShowSaveBtn":true,"isShowPhone":true,"isShowZuoji":true,"isShowHotPhone":true,"isShowWechat":true,"isShowEmail":true,"isShowCompanyName":true,"isShowCompanyAddr":true},"dataList":[]}
|
||||
CARD;
|
||||
|
||||
$userinfo = <<<USERINFO
|
||||
|
||||
{"title":"个人简介","type":"staffIntroduce","icon":"iconStaffIntroduce","isDelete":true,"addNumber":1,"data":{"title":"个人简介"},"dataList":[]}
|
||||
USERINFO;
|
||||
|
||||
$vr = <<<VR
|
||||
|
||||
{"title":"VR全景","type":"myVR","icon":"iconMyVR","isDelete":true,"addNumber":1,"data":{"title":"VR全景"},"dataList":[]}
|
||||
VR;
|
||||
|
||||
|
||||
$video = <<<VIDEO
|
||||
|
||||
{"title":"我的视频","type":"myVideo","icon":"iconMyVideo","isDelete":true,"addNumber":1,"data":{"title":"我的视频"},"dataList":[]}
|
||||
VIDEO;
|
||||
|
||||
|
||||
$photo = <<<PHOTO
|
||||
{"title":"我的照片","type":"myPhoto","icon":"iconMyPhoto","isDelete":true,"addNumber":1,"data":{"title":"我的照片"},"dataList":[]}
|
||||
PHOTO;
|
||||
|
||||
|
||||
$goods = <<<GOODS
|
||||
|
||||
{"model_name_key":"shop","title":"主推商品","type":"myGoods","icon":"iconMyGoods","isDelete":true,"addNumber":1,"data":{"title":"主推商品"},"dataList":[]}
|
||||
GOODS;
|
||||
|
||||
|
||||
$dynamic = <<<DYNAMIC
|
||||
|
||||
{"model_name_key":"dynamic","title":"我的动态","type":"myDynamic","icon":"iconDynamicList","isDelete":true,"addNumber":1,"attr":[{"title":"点击图片/视频","type":"Radio","name":"clickType","data":[{"label":1,"title":"查看图片/视频"},{"label":2,"title":"进入详情"}]},{"title":"显示数量","type":"InputNumber","name":"row"}],"data":{"title":"我的动态","clickType":1,"row":{"number":3,"min":1,"max":3,"label":"请输入"},"dataList":[]}}
|
||||
DYNAMIC;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
|
||||
return [
|
||||
|
||||
[
|
||||
"title" => "业务组件",
|
||||
'type' => 'cardCompoent',
|
||||
"data" => [
|
||||
json_decode($gzh, true),
|
||||
|
||||
json_decode($acrd, true),
|
||||
|
||||
json_decode($userinfo, true),
|
||||
|
||||
json_decode($vr, true),
|
||||
|
||||
json_decode($video, true),
|
||||
|
||||
json_decode($photo, true),
|
||||
|
||||
json_decode($goods, true),
|
||||
|
||||
json_decode($dynamic, true),
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
19
app/card/info/DiyDefaultCompoents.php
Executable file
19
app/card/info/DiyDefaultCompoents.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
$defaultPage=<<<DEFAULT
|
||||
|
||||
{"key":1,"list":[{"title":"名片模块","type":"cardModule","icon":"iconCardModule","isDelete":true,"addNumber":1,"attr":[{"title":"显示发名片按钮","type":"Switch","name":"isShowSendBtn"},{"title":"显示保存到通讯录","type":"Switch","name":"isShowSaveBtn"},{"title":"显示电话","type":"Switch","name":"isShowPhone"},{"title":"显示座机","type":"Switch","name":"isShowZuoji"},{"title":"显示400热线","type":"Switch","name":"isShowHotPhone"},{"title":"显示微信","type":"Switch","name":"isShowWechat"},{"title":"显示邮箱","type":"Switch","name":"isShowEmail"},{"title":"显示公司名称","type":"Switch","name":"isShowCompanyName"},{"title":"显示公司地址","type":"Switch","name":"isShowCompanyAddr"}],"data":{"title":"名片模块","isShowSendBtn":true,"isShowSaveBtn":true,"isShowPhone":true,"isShowZuoji":true,"isShowHotPhone":true,"isShowWechat":true,"isShowEmail":true,"isShowCompanyName":true,"isShowCompanyAddr":true,"dataList":[]},"id":1591842905840,"compontents":"cardCompoent"},{"title":"优惠券","type":"couponList","icon":"iconCouponList","isDelete":true,"addNumber":1,"attr":[{"title":"模板名称","type":"Input","name":"title","maxLength":10},{"title":"卡券样式","type":"Radio","name":"type","data":[{"label":1,"title":"弹窗样式"},{"label":2,"title":"列表样式"}]}],"data":{"title":"领取优惠券","type":1,"dataList":[]},"id":1591842929534,"compontents":"operate"},{"title":"公众号组件","type":"official","icon":"iconOfficial","isDelete":true,"addNumber":1,"data":{"title":"公众号组件"},"id":1591842933706,"compontents":"cardCompoent"},{"title":"个人简介","type":"staffIntroduce","icon":"iconStaffIntroduce","isDelete":true,"addNumber":1,"data":{"title":"个人简介","dataList":[]},"id":1591842938310,"compontents":"cardCompoent"},{"title":"主推商品","type":"myGoods","icon":"iconMyGoods","isDelete":true,"addNumber":1,"data":{"title":"主推商品","dataList":[]},"id":1591842976731,"compontents":"cardCompoent"},{"title":"VR全景","type":"myVR","icon":"iconMyVR","isDelete":true,"addNumber":1,"data":{"title":"VR全景","dataList":[]},"id":1591842986079,"compontents":"cardCompoent"},{"title":"我的视频","type":"myVideo","icon":"iconMyVideo","isDelete":true,"addNumber":1,"data":{"title":"我的视频","dataList":[]},"id":1591842987329,"compontents":"cardCompoent"},{"title":"我的动态","type":"myDynamic","icon":"iconMyDynamic","isDelete":true,"addNumber":1,"attr":[{"title":"点击图片\/视频","type":"Radio","name":"clickType","data":[{"label":1,"title":"查看图片\/视频"},{"label":2,"title":"进入详情"}]},{"title":"显示数量","type":"InputNumber","name":"row"}],"data":{"title":"我的动态","clickType":1,"row":{"number":3,"min":1,"max":3,"label":"请输入"},"dataList":[]},"id":1591843000578,"compontents":"cardCompoent"},{"title":"我的照片","type":"myPhoto","icon":"iconMyPhoto","isDelete":true,"addNumber":1,"data":{"title":"我的照片","dataList":[]},"id":1591843001799,"compontents":"cardCompoent"}]}
|
||||
DEFAULT;
|
||||
|
||||
|
||||
$page = json_decode( $defaultPage , true);
|
||||
|
||||
|
||||
return $page;
|
||||
12
app/card/info/DiyLink.php
Executable file
12
app/card/info/DiyLink.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
return [];
|
||||
39
app/card/info/DiyTabbar.php
Executable file
39
app/card/info/DiyTabbar.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
//底部菜单自定义
|
||||
return [
|
||||
|
||||
[
|
||||
//底部菜单编号
|
||||
'key' => 1 ,
|
||||
//是否显示
|
||||
'is_show' => 1 ,
|
||||
//图标
|
||||
'iconPath' => 'icon-mingpian',
|
||||
//选中图标样式
|
||||
'selectedIconPath' => 'icon-mingpian1',
|
||||
//那个页面 英文名称
|
||||
'pageComponents' => 'cardHome',
|
||||
//名称
|
||||
'name' => '名片',
|
||||
'url' => '',
|
||||
'url_jump_way' => '0',
|
||||
'url_out' => '',
|
||||
'is_delete' => false ,
|
||||
'bind_compoents'=>[
|
||||
|
||||
'cardCompoent',
|
||||
|
||||
'operate'
|
||||
],
|
||||
'bind_links' => [],
|
||||
'page'=> []
|
||||
],
|
||||
|
||||
];
|
||||
28
app/card/info/FunctionPage.php
Executable file
28
app/card/info/FunctionPage.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
return [
|
||||
//链接类型
|
||||
|
||||
[
|
||||
'id'=>'',
|
||||
|
||||
'key'=> 1,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "名片页面",
|
||||
//小程序路径
|
||||
"path" => "/pages/user/home?key=1&staff_id="
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
34
app/card/info/Info.php
Executable file
34
app/card/info/Info.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:30
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
//模块名称[必填]
|
||||
'name' => 'card',
|
||||
//模块标题[必填]
|
||||
'title' =>'名片',
|
||||
//内容简介
|
||||
'desc' =>'',
|
||||
//封面图标
|
||||
'icon' =>'',
|
||||
//模块类型[必填] model:模块 可以出现在左侧一级 app:应用中心 , 是一个应用中心的应用
|
||||
'type' => 'model',
|
||||
// 模块唯一标识[必填],格式:模块名.开发者标识.module
|
||||
'identifier' => 'card.longbing.module',
|
||||
// 版本[必填],格式采用三段式:主版本号.次版本号.修订版本号
|
||||
'version' => '1.0.8',
|
||||
// 模块依赖[可选],格式[[模块名, 模块唯一标识, 依赖版本, 对比方式]]
|
||||
'need_module' => [
|
||||
['admin', 'admin.longbing.module', '1.0.0']
|
||||
],
|
||||
// 应用依赖[可选],格式[[插件名, 应用唯一标识, 依赖版本, 对比方式]]
|
||||
'need_app' => [],
|
||||
|
||||
|
||||
|
||||
];
|
||||
131
app/card/info/PermissionCard.php
Executable file
131
app/card/info/PermissionCard.php
Executable file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace app\card\info;
|
||||
|
||||
use app\agent\model\Cardauth2DefaultModel;
|
||||
use longbingcore\permissions\PermissionAbstract;
|
||||
|
||||
/**
|
||||
* 模块功能权限
|
||||
* Class PermissionAppstore
|
||||
*/
|
||||
class PermissionCard extends PermissionAbstract {
|
||||
|
||||
const tabbarKey = null;
|
||||
//后台管理菜单对应key[必填] , 当前模块文件夹名称
|
||||
const adminMenuKey = 'card';
|
||||
public $saasKey ;
|
||||
const apiPaths = [];
|
||||
|
||||
|
||||
public function __construct(int $uniacid,$infoConfigOptions = [])
|
||||
{
|
||||
$this->saasKey = longbing_get_auth_prefix('AUTH_CARD') ;
|
||||
parent::__construct($uniacid, self::tabbarKey, self::adminMenuKey, $this->saasKey, self::apiPaths , $infoConfigOptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回saas端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function sAuth(): bool
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回p端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function pAuth(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回c端授权结果
|
||||
*
|
||||
* @param int $user_id
|
||||
* @return bool
|
||||
* @author ArtizanZhang
|
||||
* @DataTime: 2019/12/9 17:13
|
||||
*/
|
||||
public function cAuth(int $user_id): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加名片数量
|
||||
*
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/19 19:02
|
||||
*/
|
||||
public function getAuthNumber()
|
||||
{
|
||||
$returnAuthNumber = -1;
|
||||
//代理管理端控制的数量
|
||||
$pAuthConfig = $this->getPAuthConfig();
|
||||
|
||||
$authCardNumber = $this->getAuthVaule($this->saasKey, 5);
|
||||
|
||||
$pAuthNumber = isset($pAuthConfig['number']) ? $pAuthConfig['number'] : -1;
|
||||
//全局设置配置
|
||||
$cardauth2DefaultModel = new Cardauth2DefaultModel();
|
||||
|
||||
$defaultAuthNumber = $cardauth2DefaultModel->getCardNumber() ;
|
||||
|
||||
if ($authCardNumber > 0) {
|
||||
|
||||
if ($pAuthNumber > 0){
|
||||
|
||||
$returnAuthNumber = $pAuthNumber >= $authCardNumber ? $authCardNumber : $pAuthNumber;
|
||||
|
||||
} else {
|
||||
|
||||
$returnAuthNumber = $authCardNumber;
|
||||
|
||||
}
|
||||
|
||||
}else if( $authCardNumber == 0 ){
|
||||
//无限开模式
|
||||
if ($pAuthNumber >=0) {
|
||||
|
||||
$returnAuthNumber = $pAuthNumber;
|
||||
|
||||
}else if($defaultAuthNumber >= 0 ){
|
||||
|
||||
$returnAuthNumber = $defaultAuthNumber;
|
||||
|
||||
}else{
|
||||
|
||||
$returnAuthNumber = $pAuthNumber;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$returnAuthNumber = $pAuthNumber;
|
||||
}
|
||||
|
||||
return $returnAuthNumber;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
216
app/card/info/RadarMessage.php
Executable file
216
app/card/info/RadarMessage.php
Executable file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
$radar_msg = [
|
||||
[
|
||||
"sign"=> "praise",
|
||||
"type"=> 2,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请尽快把握商机",
|
||||
"operation"=> "查看",
|
||||
"item"=> "名片",
|
||||
"show_count"=> 1,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 1,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "对你已建立信任,保持联系持续跟进",
|
||||
"operation"=> "将",
|
||||
"item"=> "手机号码存入了手机通讯录",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 2,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "咨询意向强烈,及时联系确保沟通顺畅",
|
||||
"operation"=> "拨打",
|
||||
"item"=> "手机号",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_user_info",
|
||||
"field"=> "phone",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 3,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请随时保持电话畅通",
|
||||
"operation"=> "拨打",
|
||||
"item"=> "公司电话",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 4,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "客户请随时可能加你微信",
|
||||
"operation"=> "复制了",
|
||||
"item"=> "微信",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 5,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "可能随时邮寄文件给你,请注意查收",
|
||||
"operation"=> "复制了",
|
||||
"item"=> "邮箱",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 6,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请及时留意雷达动态",
|
||||
"operation"=> "复制",
|
||||
"item"=> "公司名称",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 7,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "对你的公司非常感兴趣",
|
||||
"operation"=> "查看了",
|
||||
"item"=> "公司地址",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 9,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请及时留意雷达动态",
|
||||
"operation"=> "播放",
|
||||
"item"=> "语音",
|
||||
"show_count"=> 1,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 10,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "正在帮你裂变人脉,请及时留意雷达动态(快去表达一下你的感谢)",
|
||||
"operation"=> "保存了",
|
||||
"item"=> "名片海报",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 11,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请随时保持电话畅通",
|
||||
"operation"=> "拨打",
|
||||
"item"=> "400热线",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "praise",
|
||||
"type"=> 1,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请尽快把握商机",
|
||||
"operation"=> "语音点赞",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "praise",
|
||||
"type"=> 3,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "",
|
||||
"operation"=> "Ta给你点赞了",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "praise",
|
||||
"type"=> 4,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "正在帮你裂变人脉,请及时留意雷达动态(快去表达一下你的感谢)",
|
||||
"operation"=> "分享了",
|
||||
"item"=> "名片",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
return $radar_msg;
|
||||
163
app/card/info/Subscribe.php
Executable file
163
app/card/info/Subscribe.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\card\info;
|
||||
|
||||
use app\card\model\Job;
|
||||
use app\card\model\User;
|
||||
use app\card\service\UserService;
|
||||
use app\Common\model\LongbingUserInfo;
|
||||
use longbingcore\diy\BaseSubscribe;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/11 16:23
|
||||
* Class Subscribe
|
||||
* @package app\ucenter\info
|
||||
*/
|
||||
class Subscribe extends BaseSubscribe
|
||||
{
|
||||
|
||||
/**
|
||||
* 监听个人中心用户监听事件
|
||||
*
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/12 9:36
|
||||
*/
|
||||
public function onDiyUserInfo($data)
|
||||
{
|
||||
return $data ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听用户创建模块
|
||||
*
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/18 14:05
|
||||
*/
|
||||
public function onDiyCreateCard($data)
|
||||
{
|
||||
|
||||
//这里需要优化
|
||||
/* $data['dataList'] = [
|
||||
"createText" => "",
|
||||
"createBtn" => ""
|
||||
];*/
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听用户中心切换按钮
|
||||
*
|
||||
* @param $data
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/18 14:07
|
||||
*/
|
||||
public function onDiyChangeStaff($data)
|
||||
{
|
||||
|
||||
$userModel = new User();
|
||||
|
||||
$last_staff_id = $userModel->where('id',$this->getUserId())->value('last_staff_id ');
|
||||
|
||||
if ( $last_staff_id) {
|
||||
|
||||
$staff_model = new LongbingUserInfo();
|
||||
|
||||
$staff_info = $staff_model->getStaff($last_staff_id, $this->_uniacid);
|
||||
|
||||
if(!empty($staff_info)){
|
||||
|
||||
$job_model = new Job();
|
||||
$job_name = $job_model->where( 'id' , $staff_info['job_id'])->value('name') ;
|
||||
$staff_info['job_name'] = $job_name;
|
||||
|
||||
$staff_info = longbing_array_columns([$staff_info],['id','fans_id','name','avatar','job_name']) ;
|
||||
$staff_info = $staff_info[0] ;
|
||||
|
||||
//获取职位信息
|
||||
|
||||
}
|
||||
|
||||
$data['dataList'] = $staff_info;
|
||||
}
|
||||
|
||||
return $data ;
|
||||
}
|
||||
/**
|
||||
* 监听用户中心模块
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/18 14:04
|
||||
*/
|
||||
public function onAddUcenterCompoent(){
|
||||
|
||||
$userInfo = <<<COMPOENT
|
||||
{"title":"用户信息","type":"userInfo","icon":"iconyonghuxinxi","isDelete":false,"addNumber":1,"attr":[{"title":"字体颜色","type":"ColorPicker","name":"fontColor"},{"title":"背景图片","type":"UploadImage","desc":"750*440","name":"bgImage"}],"data":{"nickName":"用户昵称","avatarUrl":"https://retail.xiaochengxucms.com/defaultAvatar.png","nickText":"更新我的个人资料","fontColor":"#F9DEAF","bgImage":[{"url":"http://longbingcdn.xiaochengxucms.com/admin/diy/user_bg.jpg"}]}}
|
||||
COMPOENT;
|
||||
|
||||
$createCard = <<<COMPOENT
|
||||
{"title":"创建名片","type":"createCard","icon":"iconchuangjianmingpian","isDelete":false,"addNumber":1,"data":{"createText":"创建我的名片","createBtn":"创建名片"}}
|
||||
COMPOENT;
|
||||
|
||||
$changeStaff = <<<COMPOENT
|
||||
{"title":"切换销售","type":"changeStaff","icon":"iconqiehuanmingpian-copy","isDelete":false,"addNumber":1,"attr":[{"title":"模板名称","type":"Input","name":"title"},{"title":"是否显示更多","type":"Switch","name":"isShowMore"}],"data":{"title":"切换销售","isShowMore":true},"dataList":[]}
|
||||
COMPOENT;
|
||||
|
||||
$distribution = <<<DISTRIBUTION
|
||||
|
||||
{"title":"分销申请","type":"distributionApply","icon":"iconDistributionApply","isDelete":true,"addNumber":1,"data":{"title":"分销申请","img":"http://longbingcdn.xiaochengxucms.com/admin/shop/distridution.jpg"}}
|
||||
DISTRIBUTION;
|
||||
|
||||
|
||||
|
||||
$compoentList = [
|
||||
json_decode($userInfo, true),
|
||||
|
||||
json_decode($createCard, true),
|
||||
|
||||
json_decode($changeStaff, true),
|
||||
|
||||
] ;
|
||||
|
||||
$app_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
if(!in_array($app_name,['longbing_web'])){
|
||||
|
||||
$compoentList[] = json_decode($distribution, true);
|
||||
}
|
||||
|
||||
return $compoentList ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听用户登录
|
||||
*
|
||||
* @param $user
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/30 17:28
|
||||
*/
|
||||
public function onUserLoginApp($user){
|
||||
$userService = new UserService();
|
||||
$userService->initFirstUserToStaff($user['id'], $user['uniacid']) ;
|
||||
}
|
||||
|
||||
}
|
||||
34
app/card/lang/zh-cn.php
Executable file
34
app/card/lang/zh-cn.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
return [
|
||||
'hello thinkphp' => '欢迎使用ThinkPHP',
|
||||
'data type error' => '数据类型错误',
|
||||
'test' => '你好啊',
|
||||
'picture' => '图片',
|
||||
'audio' => '音频',
|
||||
'vedio' => '视频',
|
||||
'Hello, I am ' => '您好,我是',
|
||||
', May I help you? Please contact me!' => ',有什么可以帮到您的吗?记得联系我!',
|
||||
'panoramic' => 'VR全景',
|
||||
'tag is exist ,please do not create twice.' => '标签已存在,请勿重复添加。',
|
||||
'not user' => '用户不存在',
|
||||
'code error' => '免审口令错误',
|
||||
'not set job' => '未设置职位',
|
||||
'card info not found' => '名片不存在',
|
||||
'create qr error.'=> '生成二维码失败',
|
||||
'tag is exist' => '标签已存在,请勿重复添加。',
|
||||
'not the job' => '没有此职位',
|
||||
'not the company' => '没有此公司',
|
||||
'staff info not found' => '员工不存在',
|
||||
'not set company' => '未设置公司',
|
||||
'traded' => '已成交',
|
||||
'not staff' => '员工不存在',
|
||||
'not company id' => '公司不能为空',
|
||||
'not card num' => '名片数量已超过限制数量,请联系管理员。',
|
||||
'not boss num' => 'boss数量超标,请联系管理员',
|
||||
'not from company'=> '所属公司不能为空',
|
||||
'chage card error'=> '修改用户名片信息失败',
|
||||
'card share text' => '您好,我是您的专属客户经理,这是我的名片,请惠存。',
|
||||
'At least one staff is required' => '系统必须保留一名推荐员工。',
|
||||
'create qr error' => '生成失败,请重试!',
|
||||
|
||||
];
|
||||
21
app/card/model/CardAuth2Activity.php
Executable file
21
app/card/model/CardAuth2Activity.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardAuth2Activity extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_cardauth2_activity';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
app/card/model/CardAuth2Article.php
Executable file
21
app/card/model/CardAuth2Article.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardAuth2Article extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_cardauth2_article';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
app/card/model/CardBoss.php
Executable file
23
app/card/model/CardBoss.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardBoss extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_boss';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
public function bosslist($where){
|
||||
return $this->where($where)->value('boss');
|
||||
}
|
||||
}
|
||||
460
app/card/model/CardCount.php
Executable file
460
app/card/model/CardCount.php
Executable file
@@ -0,0 +1,460 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardStatistics;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardCount extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_count';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
public function getYesterdaylist($where){
|
||||
$data = $this->where($where)
|
||||
->whereDay('create_time','yesterday')
|
||||
->field('to_uid as user_id,type,sign,count(to_uid) as number,uniacid')
|
||||
->group('to_uid')
|
||||
->order('create_time','desc')
|
||||
->select()
|
||||
->toArray();
|
||||
if($data){
|
||||
$stat = new CardStatistics();
|
||||
foreach ($data as $key=>$val){
|
||||
$data[$key]['create_time'] = strtotime("-1 day");
|
||||
$data[$key]['table'] = 'CardCount';
|
||||
// $whe['user_id'] = $val['to_uid'];
|
||||
// $whe['type'] = $val['type'];
|
||||
// $whe['sign'] = $val['sign'];
|
||||
// $info = $stat->getUserid($whe);
|
||||
// if($info){
|
||||
// $stat->where($whe)->inc('number',$val['number'])->update();
|
||||
// }else{
|
||||
// $whe['number'] =$val['number'];
|
||||
// $stat->addinfo($whe);
|
||||
}
|
||||
// }print_r(123);exit;
|
||||
$stat->createRows($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
//昨日数据
|
||||
public function getYesterday($where){
|
||||
return $this->where($where)->whereDay('create_time','yesterday')->count();
|
||||
}
|
||||
//今日数据
|
||||
public function gettoday($where){
|
||||
return $this->where($where)->whereDay('create_time')->count();
|
||||
}
|
||||
//新增咨询
|
||||
public function zxInfo($user_id,$where=[],$type=0){
|
||||
if($type==1){
|
||||
$de = '=';
|
||||
}else{
|
||||
$de = 'in';
|
||||
}
|
||||
$where1 = [
|
||||
['to_uid',$de,$user_id],
|
||||
['sign','=','copy'],
|
||||
['type','=','8'],
|
||||
$where
|
||||
];
|
||||
$where2 = [
|
||||
['to_uid',$de,$user_id],
|
||||
['sign','=','praise'],
|
||||
['type','=','5'],
|
||||
$where
|
||||
];
|
||||
$count = $this->where([array_filter($where1)])->whereor([array_filter($where2)])->count();
|
||||
return $count;
|
||||
}
|
||||
public function getCount($where5){
|
||||
$data = $this->where($where5)->count();
|
||||
return $data;
|
||||
}
|
||||
public function radarList ( $where = [], $page = 1, $list_rows = 20 )
|
||||
{
|
||||
$data = self::where( $where )
|
||||
->alias( 'a' )
|
||||
->field( [ 'a.*','b.nickName as name']
|
||||
)
|
||||
->join( 'longbing_card_user b', 'a.user_id = b.id' )
|
||||
->join( 'longbing_card_collection c', 'a.user_id = c.uid && a.to_uid = c.to_uid' )
|
||||
->order( [ 'a.id' => 'desc' ] )
|
||||
->paginate( [ 'list_rows' => $list_rows, 'page' => $page ]
|
||||
)
|
||||
->toArray();
|
||||
|
||||
// 查询手机号
|
||||
// $tmpArr = [];
|
||||
// foreach ( $data[ 'data' ] as $index => $item )
|
||||
// {
|
||||
// $data[ 'data' ][ $index ][ 'phone' ] = '';
|
||||
// array_push( $tmpArr, $item[ 'user_id' ] );
|
||||
// }
|
||||
// if ( !empty( $tmpArr ) )
|
||||
// {
|
||||
// $tmpArr = array_unique( $tmpArr );
|
||||
//
|
||||
// $list = UserPhone::where( [ [ 'user_id', 'in', $tmpArr ] ] )
|
||||
// ->field( [ 'user_id', 'phone' ] )
|
||||
// ->select()
|
||||
// ->toArray();
|
||||
//
|
||||
// $tmpArr = [];
|
||||
// foreach ( $list as $index => $item )
|
||||
// {
|
||||
// $tmpArr[ $item[ 'user_id' ] ] = $item[ 'phone' ];
|
||||
// }
|
||||
// foreach ( $data[ 'data' ] as $index => $item )
|
||||
// {
|
||||
// if ( isset( $tmpArr[ $item[ 'user_id' ] ] ) )
|
||||
// {
|
||||
// $data[ 'data' ][ $index ][ 'phone' ] = $tmpArr[ $item[ 'user_id' ] ];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!empty($data[ 'data' ]))
|
||||
{
|
||||
// 处理雷达展示日期
|
||||
//$data[ 'data' ] = lbHandelRadarDate( $data[ 'data' ] );
|
||||
|
||||
// 处理用户来源
|
||||
//$data[ 'data' ] = lbHandelRadarSource( $data[ 'data' ] );
|
||||
|
||||
// 处理雷达激励提醒文案
|
||||
$data[ 'data' ] = lbHandelRadarMsg( $data[ 'data' ] );
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
//兴趣占比
|
||||
public function doPageBossInterest ($where,$uniacid)
|
||||
{
|
||||
|
||||
$filter = [
|
||||
['sign','=','copy'] , ['uniacid','=',$uniacid],$where,[ 'type', 'in', [ 6, 7 ,11] ]
|
||||
];
|
||||
$filter1 = [
|
||||
['sign','=','view'] , [ 'type', '=', 6 ],['uniacid','=',$uniacid],$where
|
||||
];
|
||||
//// // 对公司感兴趣
|
||||
$compony = $this->where([$filter])->whereor([$filter1])->count();
|
||||
$filter2 = [
|
||||
['sign','=','copy'] , ['uniacid','=',$uniacid],$where,[ 'type', '=', 8 ]
|
||||
];
|
||||
$where3 = [
|
||||
['sign','=','view'] ,['uniacid','=',$uniacid],$where,[ 'type', 'in', [ 1, 2, 11, 15, 16, 17, 19, 20, 25, 26, 27, 28, 29, 30 ] ]
|
||||
];
|
||||
$where21 = [
|
||||
['sign','=','praise'] , ['uniacid','=',$uniacid],$where, [ 'type', 'in', [ 5, 6, 7, 8 ] ]
|
||||
];
|
||||
$where31 = [
|
||||
['sign','=','order'] ,['uniacid','=',$uniacid],$where
|
||||
];
|
||||
|
||||
// 对产品感兴趣
|
||||
$goods = $this->where([$filter2])->whereor([$where3])->whereor([$where21])->whereor([$where31])->count();
|
||||
|
||||
// 对员工感兴趣
|
||||
$where4 = [
|
||||
['sign','=','copy'],['uniacid','=',$uniacid],$where, [ 'type', 'in', [ 1, 2, 3, 4, 5, 9, 10 ] ]
|
||||
];
|
||||
$where5 = [
|
||||
['sign','=','praise'],['uniacid','=',$uniacid],$where,[ 'type', 'in', [ 1, 2, 3, 4 ] ]
|
||||
];
|
||||
$staff = $this->where([$where4])->whereor([array_filter($where5)])->count();
|
||||
|
||||
$total = $compony + $goods + $staff;
|
||||
$data = [
|
||||
[
|
||||
'data' => $compony,
|
||||
'rate' => 0,
|
||||
'name'=>'对公司感兴趣'
|
||||
],
|
||||
[
|
||||
'data' => $goods,
|
||||
'rate' => 0,
|
||||
'name'=>'对产品感兴趣'
|
||||
],
|
||||
[
|
||||
'data' => $staff,
|
||||
'rate' => 0,
|
||||
'name'=>'对我感兴趣'
|
||||
],
|
||||
];
|
||||
if ( $total ) {
|
||||
foreach ( $data as $k => $v ) {
|
||||
$data[ $k ][ 'rate' ] = sprintf( "%.2f", $v[ 'data' ] / $total ) * 100;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
//活跃度0,1,2 $type 单个用户还是多个
|
||||
// public function doPageActivity ($uid,$type=0)
|
||||
// {
|
||||
// if($type ==1){
|
||||
// $str = 'in';
|
||||
// $last = 7;
|
||||
// }else{
|
||||
// $str = '=';
|
||||
// $last = 30;
|
||||
// }
|
||||
// //$forward = new CardForward();
|
||||
// //$stat = new CardStatistics();
|
||||
// $card_count = new CardCount();
|
||||
// $data = [];
|
||||
// $ss = [];
|
||||
// for ( $i = 0; $i < $last; $i++ ) {
|
||||
// $beginTime = mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $i, date( 'Y' ) );
|
||||
// $endTime = mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $i + 1, date( 'Y' ) ) - 1;
|
||||
// $date = date( 'm/d', $beginTime );
|
||||
// $data[ $i ][ 'date' ] = $date;
|
||||
// $data[ $i ][ 'beginTime' ] = $beginTime;
|
||||
// $data[ $i ][ 'endTime' ] = $endTime;
|
||||
//
|
||||
//
|
||||
//// $where1[] = [
|
||||
//// ['user_id',$str,$uid],['table','=','forward'],['create_time','BETWEEN',[$beginTime,$endTime]]
|
||||
//// ];
|
||||
// // $count2 = $forward->forwardCount($where1);
|
||||
//// $wherez = [['sign','=','praise'], ['type','=',4],['to_uid','=',$uid],['uniacid','=',$this->_uniacid],['create_time','BETWEEN',[$beginTime,$endTime]]];
|
||||
//// $count2 =$card_count->getCount($wherez);
|
||||
// //$count2 = $stat->getCustomerCount($where1);
|
||||
// $card_message = new CardMessage();
|
||||
//// $where2[] = [
|
||||
//// ['user_id',$str,$uid],['table','=','message'],['create_time','BETWEEN',[$beginTime,$endTime]]
|
||||
//// ];
|
||||
// $where3 = [['status','=',1], ['deleted','=',0],['target_id',$str,$uid],['uniacid','=',$this->_uniacid],['create_time','BETWEEN',[$beginTime,$endTime]]];
|
||||
// $count3 = $card_message->getCount($where3);
|
||||
// //$count3 = $stat->getCustomerCount($where2);
|
||||
//
|
||||
// //$card_count = new CardCount();
|
||||
// $where4 = [['sign','=','copy'],['to_uid',$str,$uid],['uniacid','=',$this->_uniacid],['create_time','BETWEEN',[$beginTime,$endTime]]];
|
||||
//// $where3[] = [
|
||||
//// ['user_id',$str,$uid],['create_time','BETWEEN',[$beginTime,$endTime],['sign','=','copy']]
|
||||
//// ];
|
||||
// $count4 = $card_count->getCount($where4);
|
||||
//// $where3[] = [
|
||||
//// ['user_id',$str,$uid],['create_time','BETWEEN',[$beginTime,$endTime],['sign','=','view']]
|
||||
//// ];
|
||||
// $where5 = [['sign','=','view'],['to_uid',$str,$uid],['uniacid','=',$this->_uniacid],['create_time','BETWEEN',[$beginTime,$endTime]]];
|
||||
// $count5 = $card_count->getCount($where5);
|
||||
// $where3[] = [
|
||||
// ['user_id',$str,$uid],['create_time','BETWEEN',[$beginTime,$endTime],['sign','=','praise']]
|
||||
// ];
|
||||
// $where6 = [['sign','=','praise'],['to_uid',$str,$uid],['uniacid','=',$this->_uniacid],['create_time','BETWEEN',[$beginTime,$endTime]]];
|
||||
// $count6 = $card_count->getCount($where6);
|
||||
//
|
||||
//// $count6 = $stat->getCustomerCount($where3);$count2 +
|
||||
// $count = $count3 + $count4 + $count5 + $count6;
|
||||
// $data[ $i ][ 'number' ] = $count;
|
||||
// $ss[] = $count;
|
||||
// }
|
||||
// $arr = max($ss);
|
||||
// if($arr ==0){
|
||||
// $arr =5;
|
||||
// }
|
||||
// return ['max'=>$arr,'data'=>$data];
|
||||
// }
|
||||
public function active ( $staff_id, $uniacid,$type=0 )
|
||||
{
|
||||
if($type ==1){
|
||||
$str = 'in';
|
||||
// $last = 7;['uniacid'=>$uniacid],
|
||||
}else{
|
||||
$str = '=';
|
||||
// $last = 30;
|
||||
}
|
||||
$data = [];
|
||||
|
||||
|
||||
$lastday = date( 'Y/m/d' );
|
||||
|
||||
$number = self::where( [ [ 'to_uid',$str, $staff_id ], [ 'create_time', 'between',
|
||||
[ strtotime( $lastday . ' 00:00:00' ), strtotime( $lastday . ' 23:59:59' ) ] ] ]
|
||||
)
|
||||
->count();
|
||||
$data[] = [ 'date' => date( 'm/d' ), 'number' => $number ];
|
||||
|
||||
$max = $number;
|
||||
|
||||
for ( $i = 1; $i < 15; $i++ )
|
||||
{
|
||||
|
||||
$start_time = strtotime( "$lastday -$i days" );
|
||||
|
||||
$md = date( 'm/d', $start_time );
|
||||
$ymd = date( 'Y/m/d', $start_time );
|
||||
|
||||
$end_time = strtotime( $ymd . ' 23:59:59' );
|
||||
|
||||
$number = self::where( [ [ 'to_uid',$str, $staff_id ],
|
||||
[ 'create_time', 'between', [ $start_time, $end_time ] ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
if ( $number > $max )
|
||||
{
|
||||
$max = $number;
|
||||
}
|
||||
|
||||
|
||||
$data[] = [ 'date' => $md, 'number' => $number ];
|
||||
}
|
||||
|
||||
return [ 'data'=>$data, 'max'=>$max ];
|
||||
}
|
||||
public function getsss($staff_id,$uniacid,$type=0){
|
||||
if($type==1){
|
||||
$str = '=';
|
||||
}else{
|
||||
$str = 'in';
|
||||
}
|
||||
$data = [ 'max_number' => 0, 'total' => 0, 'data' => [] ];
|
||||
|
||||
//咨询产品
|
||||
$count = self::where( [ [ 'sign', '=', 'copy' ], [ 'to_uid',$str, $staff_id ],
|
||||
[ 'type', '=', 8 ],[ 'uniacid', '=', $uniacid ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
$data[ 'max_number' ] = $count;
|
||||
$data[ 'total' ] += $count;
|
||||
$data[ 'data' ][] = [ 'name' => '咨询产品', 'number' => $count ];
|
||||
|
||||
// 保存电话
|
||||
$count = self::where( [ [ 'sign', '=', 'copy' ], [ 'to_uid', $str, $staff_id ],
|
||||
[ 'type', '=', 1 ] ,[ 'uniacid', '=', $uniacid ]]
|
||||
)
|
||||
->count();
|
||||
|
||||
if ( $count > $data[ 'max_number' ] )
|
||||
{
|
||||
$data[ 'max_number' ] = $count;
|
||||
}
|
||||
$data[ 'total' ] += $count;
|
||||
$data[ 'data' ][] = [ 'name' => '保存电话', 'number' => $count ];
|
||||
|
||||
// 拨打电话
|
||||
$count = self::where( [ [ 'sign', '=', 'copy' ], [ 'to_uid', $str, $staff_id ],[ 'uniacid', '=', $uniacid ],
|
||||
[ 'type', 'in', [ 2, 3, 11 ] ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
$count += self::where( [ [ 'sign', '=', 'praise' ], [ 'to_uid', $str, $staff_id ],[ 'uniacid', '=', $uniacid ],
|
||||
[ 'type', '=', 7 ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
if ( $count > $data[ 'max_number' ] )
|
||||
{
|
||||
$data[ 'max_number' ] = $count;
|
||||
}
|
||||
$data[ 'total' ] += $count;
|
||||
$data[ 'data' ][] = [ 'name' => '拨打电话', 'number' => $count ];
|
||||
|
||||
|
||||
|
||||
$view_base_filter = [
|
||||
['to_uid', $str, $staff_id],
|
||||
['sign', '=', 'view'],[ 'uniacid', '=', $uniacid ]
|
||||
];
|
||||
|
||||
//浏览商城
|
||||
$view_shop_filter = $view_base_filter;
|
||||
$view_shop_filter[] = ['type' , '=' , 1];
|
||||
$view_shop_number = self::where($view_shop_filter)->count();
|
||||
$data['total'] += $view_shop_number;
|
||||
$data['data'][] = ['name' => '浏览商城', 'number' => $view_shop_number];
|
||||
|
||||
|
||||
//浏览商品
|
||||
$view_goods_filter = $view_base_filter;
|
||||
$view_goods_filter[] = ['type' , '=' , 2];
|
||||
$view_goods_number = self::where($view_goods_filter)->count();
|
||||
$data['total'] += $view_goods_number;
|
||||
$data['data'][] = ['name' => '浏览商品', 'number' => $view_goods_number];
|
||||
|
||||
//查看官网
|
||||
$view_official_web_filter = $view_base_filter;
|
||||
$view_official_web_filter[] = ['type' , '=' , 6];
|
||||
$view_official_web_number = self::where($view_official_web_filter)->count();
|
||||
$data['total'] += $view_official_web_number;
|
||||
$name = tabbarName(4,$uniacid);
|
||||
|
||||
$data['data'][] = ['name' =>!empty($name)?'查看'.$name: '查看官网', 'number' => $view_official_web_number];
|
||||
|
||||
|
||||
//浏览动态
|
||||
$view_timeline_filter = $view_base_filter;
|
||||
$view_timeline_filter[] = ['type' , '=' , 3];
|
||||
$view_timeline_number = self::where($view_timeline_filter)->count();
|
||||
$data['total'] += $view_timeline_number;
|
||||
$data['data'][] = ['name' => '浏览动态', 'number' => $view_timeline_number];
|
||||
|
||||
|
||||
//点赞
|
||||
$praise_filter = [
|
||||
['to_uid', $str, $staff_id],[ 'uniacid', '=', $uniacid ],
|
||||
['sign', '=', 'praise'],
|
||||
['type', 'IN', [1, 3]]
|
||||
];
|
||||
$praise_number = self::where($praise_filter)->count();
|
||||
$data['total'] += $praise_number;
|
||||
$data['data'][] = ['name' => '点赞', 'number' => $praise_number];
|
||||
|
||||
|
||||
|
||||
//分享名片
|
||||
$share_filter = [
|
||||
['to_uid', $str, $staff_id],[ 'uniacid', '=', $uniacid ],
|
||||
['sign', '=', 'praise'],
|
||||
['type', '=', 4]
|
||||
];
|
||||
$share_number = self::where($share_filter)->count();
|
||||
$data['total'] += $share_number;
|
||||
$data['data'][] = ['name' => '分享', 'number' => $share_number];
|
||||
|
||||
|
||||
|
||||
|
||||
//按number倒序
|
||||
$sort_arr = [];
|
||||
foreach ($data['data'] as $k => $v) {
|
||||
$sort_arr[] = $v['number'];
|
||||
}
|
||||
|
||||
array_multisort($sort_arr, SORT_DESC, $data['data']);
|
||||
$data['max_number'] = $data['data'][0]['number'] ?? 0;
|
||||
|
||||
//计算rate
|
||||
foreach ($data['data'] as $index => $item) {
|
||||
if ($data['max_number'] == 0) {
|
||||
$rate = 0;
|
||||
} else {
|
||||
$rate = $item['number'] / $data['max_number'] * 100;
|
||||
}
|
||||
$rate = sprintf("%.0f", $rate);
|
||||
$data['data'][$index]['rate'] = $rate;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function getCountUser($where,$time){
|
||||
$data = $this->alias('a')
|
||||
->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id' )
|
||||
->where($where)
|
||||
->whereDay('a.create_time',$time)
|
||||
->group('user_id')
|
||||
->count();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
21
app/card/model/CardCoupon.php
Executable file
21
app/card/model/CardCoupon.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardCoupon extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_coupon';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
app/card/model/CardCouponRecord.php
Executable file
21
app/card/model/CardCouponRecord.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardCouponRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_coupon_record';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
122
app/card/model/CardExtension.php
Executable file
122
app/card/model/CardExtension.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\member\model\Member;
|
||||
use app\shop\model\AdminShopSpePrice;
|
||||
use app\shop\model\IndexUserInfo;
|
||||
use app\shop\model\IndexUserShop;
|
||||
use think\facade\Db;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardExtension extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_extension';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 名片的标签列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function cardExtensionList ( $staff_id, $uniacid )
|
||||
{
|
||||
|
||||
|
||||
$user_model = new IndexUserInfo();
|
||||
|
||||
$company_id = $user_model->getCompanyId(['fans_id'=>$staff_id],$uniacid);
|
||||
|
||||
$member_model= new Member();
|
||||
|
||||
$arr = [];
|
||||
|
||||
if($member_model->getAuth($uniacid)==true){
|
||||
|
||||
$arr[] = ['b.is_member','=',0];
|
||||
|
||||
}
|
||||
|
||||
$dis[] = ['d.company_id','=',$company_id];
|
||||
|
||||
$dis[] = ['b.public_goods','=',1];
|
||||
|
||||
$config = longbingGetAppConfig($uniacid);
|
||||
//自选
|
||||
if($config['myshop_switch']==1){
|
||||
$user_shop = new IndexUserShop();
|
||||
|
||||
$my_goods = $user_shop->MyGoodList(['user_id'=>$staff_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$arrs[] = ['a.id','in',$my_goods];
|
||||
|
||||
}else{
|
||||
|
||||
$arrs[] = ['a.index_show', '=', 1];
|
||||
}
|
||||
|
||||
$data = self::where( [ [ 'a.user_id', '=', $staff_id ], [ 'a.status', '=', 1 ], [ 'b.status', '=', 1 ], [ 'a.uniacid', '=', $uniacid ] ] )
|
||||
->where($arr)
|
||||
->alias( 'a' )
|
||||
->field( [ 'a.id as e_id','b.id', 'b.name', 'b.cover', 'b.price', 'b.status', 'b.unit', 'b.recommend', 'b.is_collage' ]
|
||||
)
|
||||
->where(function ($query) use ($dis){
|
||||
$query->whereOr($dis);
|
||||
})
|
||||
->join('longbing_card_goods b', 'a.goods_id = b.id')
|
||||
->join('longbing_card_user_info c','a.user_id = c.fans_id')
|
||||
->join('longbing_card_company_goods d' ,'c.company_id = d.company_id and a.goods_id = d.goods_id','left')
|
||||
// ->order( [ 'a.id' => 'desc' ] )
|
||||
->order('a.status desc,b.recommend desc,b.top desc,b.id desc,b.update_time desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
|
||||
if($data){
|
||||
$spe_price = new AdminShopSpePrice();
|
||||
foreach ($data as $key=>$val){
|
||||
$o_dis = [];
|
||||
$o_dis[] = ['status','=',1];
|
||||
$o_dis[] = ['goods_id','=',$val['id']];
|
||||
$data[$key]['price_text'] = $spe_price->where($o_dis)->min('price');
|
||||
$o_dis[] = ['original_price','<>',0];
|
||||
$data[$key]['original_price'] = $spe_price->where($o_dis)->min('original_price');
|
||||
}
|
||||
}
|
||||
$data = transImagesOne($data, ['cover']);
|
||||
$data = formatNumberPrice($data);
|
||||
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function getlist($dis){
|
||||
$data = $this
|
||||
->alias('a')
|
||||
->join('longbing_card_user_info b','a.user_id = b.fans_id')
|
||||
->join('longbing_card_company_goods c' ,'b.company_id = c.company_id and a.goods_id = c.goods_id')
|
||||
->join('longbing_card_goods d' ,'a.goods_id = d.id and d.status = 1')
|
||||
->where($dis)
|
||||
->field(['a.*'])
|
||||
->order('a.create_time','desc')
|
||||
->select()
|
||||
->toArray();
|
||||
return $data;
|
||||
}
|
||||
public function getCount($where){
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
app/card/model/CardFormId.php
Executable file
21
app/card/model/CardFormId.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardFormId extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_form_id';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
app/card/model/CardForward.php
Executable file
43
app/card/model/CardForward.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardStatistics;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardForward extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_forward';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
public function getCount($where){
|
||||
$data = $this
|
||||
->field('staff_id as user_id,count(staff_id) as number,uniacid')
|
||||
->whereDay('create_time','yesterday')
|
||||
->group('staff_id')
|
||||
->where($where)->select()->toArray();
|
||||
if($data){
|
||||
foreach ($data as $key=>$val){
|
||||
$data[$key]['table'] = 'forward';
|
||||
$data[$key]['create_time'] = strtotime("-1 day");
|
||||
}
|
||||
$stat = new CardStatistics();
|
||||
$stat->createRows($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getYesterday($where){
|
||||
return $this->where($where)->whereDay('create_time','yesterday')->count();
|
||||
}
|
||||
public function forwardCount($where4){
|
||||
return $this->where($where4)->count();
|
||||
}
|
||||
}
|
||||
147
app/card/model/CardJob.php
Executable file
147
app/card/model/CardJob.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardJob extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_job';
|
||||
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 根据员工获取工具列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getListByUser ( $card_id = 0, $uniacid )
|
||||
{
|
||||
$list = self::where( [ [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1 ] ] )
|
||||
->field( [ 'id', 'name' ] )
|
||||
->order( 'top', 'desc' )
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
if ( !$list )
|
||||
{
|
||||
$list = $this->initCardJob( $uniacid );
|
||||
}
|
||||
|
||||
foreach ( $list as $index => $item )
|
||||
{
|
||||
$list[ $index ][ 'selected' ] = 0;
|
||||
if ( isset( $item[ 'id' ] ) && $item[ 'id' ] == $card_id )
|
||||
{
|
||||
$list[ $index ][ 'selected' ] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 初始化名片样式
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function initCardJob ( $uniacid )
|
||||
{
|
||||
$data = [ [ 'name' => '首席服务官', 'uniacid' => $uniacid ] ];
|
||||
$result = self::createRows( $data );
|
||||
return $result->toArray();
|
||||
}
|
||||
|
||||
// public function getJob($filter)
|
||||
// {
|
||||
// $result = $this->where($filter)->find();
|
||||
// if(!empty($result)) $result = $result->toArray();
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @Purpose: 创建职位
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function createJob($data){
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
/**
|
||||
* @Purpose: 更新职位
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function updateJob($filter ,$data){
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
/**
|
||||
* @Purpose: 获取职位列表
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function listJob($filter ,$page_config = ['page' => 1 ,'page_count' => 20 ]){
|
||||
$result = $this->where($filter)
|
||||
->order('top desc , id desc')
|
||||
->page($page_config['page'] ,$page_config['page_count'])
|
||||
->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* @Purpose: 获取职位详情
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getJob($filter){
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* @Purpose: 删除职位信息
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function delJob($filter){
|
||||
$result = $this->updateJob($filter ,['status' => -1 ,'update_time' => time()]);
|
||||
return !empty($result);
|
||||
}
|
||||
/**
|
||||
* @Purpose: 获取职位总数
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getJobCount($filter){
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
20
app/card/model/CardLabel.php
Executable file
20
app/card/model/CardLabel.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardLabel extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_label';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
}
|
||||
38
app/card/model/CardMessage.php
Executable file
38
app/card/model/CardMessage.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardStatistics;
|
||||
|
||||
|
||||
class CardMessage extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_message';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
public function getCount($where){
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
// public function getCountlist($where){
|
||||
// $data = $this
|
||||
// ->field('target_id as user_id,count(target_id) as number,uniacid')
|
||||
// ->whereDay('create_time','yesterday')
|
||||
// ->group('target_id')
|
||||
// ->where($where)->select()->toArray();
|
||||
// if($data){
|
||||
// foreach ($data as $key=>$val){
|
||||
// $data[$key]['table'] = 'message';
|
||||
// $data[$key]['create_time'] = strtotime("-1 day");
|
||||
// }
|
||||
// $stat = new CardStatistics();
|
||||
// $stat->createRows($data);
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
63
app/card/model/CardTags.php
Executable file
63
app/card/model/CardTags.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardTags extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_tags';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 名片的标签列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function cardTagList ( $staff_id, $client_id, $uniacid )
|
||||
{
|
||||
$data = self::where( [ [ 'user_id', '=', $staff_id ], [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1 ] ] )
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ( $data as $index => $item )
|
||||
{
|
||||
$data[ $index ][ 'thumbed' ] = 0;
|
||||
$check = CardUserTags::where( [ [ 'tag_id', '=', $item[ 'id' ] ],
|
||||
[ 'user_id', '=', $client_id ], [ 'uniacid', '=', $uniacid ],
|
||||
[ 'status', '=', 1 ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
if ($check)
|
||||
{
|
||||
$data[ $index ][ 'thumbed' ] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getTag($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTagCount($filter)
|
||||
{
|
||||
$count = $this->where($filter)->count();
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
61
app/card/model/CardType.php
Executable file
61
app/card/model/CardType.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardType extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_card_type';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Purpose: 初始化名片样式
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function initCardType ( $uniacid )
|
||||
{
|
||||
$data = [ [ 'card_type' => 'cardType1', 'img' => 'https://retail.xiaochengxucms.com/1.png', 'uniacid' => $uniacid ],
|
||||
[ 'card_type' => 'cardType4', 'img' => 'https://retail.xiaochengxucms.com/2.png', 'uniacid' => $uniacid ],
|
||||
[ 'card_type' => 'cardType2', 'img' => 'https://retail.xiaochengxucms.com/4.png', 'uniacid' => $uniacid ],];
|
||||
$result = self::createRows( $data );
|
||||
return $result->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 初始化名片样式
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getCardTypeList ( $uniacid, $type = '' )
|
||||
{
|
||||
$list = self::where( [ [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1 ] ] )
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ( $list as $index => $item )
|
||||
{
|
||||
$list[$index]['selected'] = 0;
|
||||
|
||||
if ($item['card_type'] == $type)
|
||||
{
|
||||
$list[$index]['selected'] = 1;
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
22
app/card/model/CardUserLabel.php
Executable file
22
app/card/model/CardUserLabel.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardUserLabel extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_label';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
public function getlist($where){
|
||||
return $this->where($where)->group('user_id')->field('user_id,uniacid')->select()->toArray();
|
||||
}
|
||||
}
|
||||
20
app/card/model/CardUserTags.php
Executable file
20
app/card/model/CardUserTags.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardUserTags extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_tags';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
}
|
||||
195
app/card/model/CardValue.php
Executable file
195
app/card/model/CardValue.php
Executable file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardShareGroup;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class CardValue extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_value';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
public function getlist($where){
|
||||
return $this->where($where)->order('update_time','desc')->find();
|
||||
}
|
||||
public function bossGetAiValue ( $id,$uniacid )
|
||||
{
|
||||
$value = [
|
||||
'client' => 0, // 获客能力值
|
||||
'charm' => 0, // 个人魅力值
|
||||
'interaction' => 0, // 客户互动值
|
||||
'product' => 0, // 产品推广值
|
||||
'website' => 0, // 官网推广度
|
||||
'active' => 0, // 销售主动性值
|
||||
];
|
||||
$check = $this->getlist([ 'staff_id' => $id ]);
|
||||
if ( !$check || ( $check && time() - $check[ 'update_time' ] > 24 * 60 * 60 ) ) {
|
||||
$colle = new Collection();
|
||||
// 获客能力值
|
||||
$client = $colle->getlistCount(['status' => 1, 'to_uid' => $id,]);
|
||||
if ( $client > 0 ) {
|
||||
$client -= 1;
|
||||
}
|
||||
$value[ 'client' ] = $client;
|
||||
$card_count = new CardCount();
|
||||
// 个人魅力值
|
||||
$list1 = $card_count->getCount([ 'sign' => 'praise', 'type' => 1, 'to_uid' => $id ]);
|
||||
$list2 = $card_count->getCount( [ 'sign' => 'praise', 'type' => 3, 'to_uid' => $id ]);
|
||||
$list3 = $card_count->getCount([ 'sign' => 'copy', 'to_uid' => $id ]);
|
||||
$count = $list1 + $list2+ $list3;
|
||||
$value[ 'charm' ] = $count;
|
||||
$card_message = new CardMessage();
|
||||
|
||||
// 客户互动值
|
||||
$list1 = $card_message->getCount([ 'user_id' => $id ]);
|
||||
$list2 = $card_message->getCount([ 'target_id' => $id ]);
|
||||
$list3 = $card_count->getCount([ 'sign' => 'view', 'to_uid' => $id ]);
|
||||
$count = $list1 + $list2 + $list3;
|
||||
$value[ 'interaction' ] = $count;
|
||||
$extension = new CardExtension();
|
||||
$mark = new UserMark();
|
||||
$forward = new CardForward();
|
||||
$group = new CardShareGroup();
|
||||
|
||||
// 产品推广值
|
||||
$list1 = $extension->getCount([ 'user_id' => $id, 'uniacid' => $uniacid ]);
|
||||
$list2 = $mark->getCount([ 'staff_id' => $id, 'uniacid' => $uniacid, 'mark' => 2 ]);
|
||||
$list3 = $forward->forwardCount([ 'staff_id' => $id, 'uniacid' => $uniacid, 'type' => 2 ]);
|
||||
|
||||
$where=[['user_id','=',$id],['uniacid','=',$uniacid], ['view_goods','<>',''] ];
|
||||
$list4 = $group->getCount($where);
|
||||
$count = $list1 + $list2 + $list3 + $list4;
|
||||
$value[ 'product' ] = $count;
|
||||
|
||||
// 官网推广度
|
||||
$list1 = $card_count->getCount([ 'sign' => 'view', 'type' => 6, 'to_uid' => $id ]);
|
||||
$list2 = $forward->forwardCount([ 'staff_id' => $id, 'uniacid' => $uniacid, 'type' => 4 ]);
|
||||
$count = $list1 + $list2;
|
||||
$value[ 'website' ] = $count;
|
||||
$follow = new UserFollow();
|
||||
|
||||
// 销售主动性值
|
||||
$list1 = $card_message->getCount([ 'user_id' => $id ]);
|
||||
$list2 = $card_message->getCount([ 'target_id' => $id ]);
|
||||
$list3 = $follow->getCount([ 'staff_id' => $id ]);
|
||||
$list4 = $mark->getCount([ 'staff_id' => $id ]);
|
||||
$count = $list1 + $list2 + $list3+ $list4;
|
||||
$value[ 'active' ] = $count;
|
||||
|
||||
$insertData = $value;
|
||||
$insertData[ 'staff_id' ] = $id;
|
||||
$time = time();
|
||||
$insertData[ 'update_time' ] = $time;
|
||||
$insertData[ 'uniacid' ] = $uniacid;
|
||||
if ( !$check ) {
|
||||
$insertData[ 'create_time' ] = $time;
|
||||
$this->createRow($insertData);
|
||||
} else {
|
||||
$insertData[ 'update_time' ] = $time;
|
||||
$this->upsave([ 'id' => $check[ 'id' ]],$insertData);
|
||||
}
|
||||
} else {
|
||||
$value = [
|
||||
'client' => $check[ 'client' ], // 获客能力值
|
||||
'charm' => $check[ 'charm' ], // 个人魅力值
|
||||
'interaction' => $check[ 'interaction' ], // 客户互动值
|
||||
'product' => $check[ 'product' ], // 产品推广值
|
||||
'website' => $check[ 'website' ], // 官网推广度
|
||||
'active' => $check[ 'active' ], // 销售主动性值
|
||||
];
|
||||
}
|
||||
|
||||
$max=array_sum(array($value[ 'active' ],$value[ 'charm' ],$value[ 'client' ],$value[ 'interaction' ],$value[ 'product' ],$value[ 'website' ]));
|
||||
|
||||
$web_name = tabbarName(4,$uniacid);
|
||||
|
||||
$data = [
|
||||
[
|
||||
'name'=>'销售主动性值',
|
||||
'number'=>$value[ 'active' ],
|
||||
|
||||
],
|
||||
[
|
||||
'name'=>!empty($web_name)?$web_name.'推广度':'官网推广度',
|
||||
'number'=>$value[ 'website' ],
|
||||
$bb[] = $value[ 'website' ]
|
||||
],
|
||||
[
|
||||
'name'=>'产品推广值',
|
||||
'number'=>$value[ 'product' ],
|
||||
|
||||
],
|
||||
[
|
||||
'name'=>'客户互动值',
|
||||
'number'=>$value[ 'interaction' ],
|
||||
|
||||
],
|
||||
[
|
||||
'name'=>'获客能力值',
|
||||
'number'=>$value[ 'client' ],
|
||||
|
||||
],
|
||||
[
|
||||
'name'=>'个人魅力值',
|
||||
'number'=>$value[ 'charm' ],
|
||||
|
||||
],
|
||||
];
|
||||
|
||||
return ['max'=>$max,'data'=>$data];
|
||||
}
|
||||
function bossAi ($user_list, $uniacid )
|
||||
{
|
||||
$max = [
|
||||
0 => 0, // 销售主动性值
|
||||
1 => 0, // 官网推广度
|
||||
2 => 0, // 产品推广值
|
||||
3 => 0, // 客户互动值
|
||||
4 => 0, // 获客能力值
|
||||
5 => 0, // 个人魅力值
|
||||
];
|
||||
$staff_list = User::where( [ [ 'uniacid', '=', $uniacid ], [ 'is_staff', '=', 1 ] ] )
|
||||
->field( [ 'id', 'nickName' ] )
|
||||
->where('id','in',$user_list)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ( $staff_list as $k => $v )
|
||||
{
|
||||
$total = 0;
|
||||
$value = $this->bossGetAiValue( $v[ 'id' ], $uniacid );
|
||||
|
||||
foreach ( $value['data'] as $k2 => $v2 )
|
||||
{
|
||||
if ( $v2[ 'number' ] > $max[ $k2 ] )
|
||||
{
|
||||
$max[ $k2 ] = $v2[ 'number' ];
|
||||
}
|
||||
$total += $v2[ 'number' ];
|
||||
}
|
||||
|
||||
$staff_list[ $k ][ 'number' ] = $value['data'];
|
||||
//$staff_list[ $k ][ 'total' ] = $total;
|
||||
// $staff_list[ $k ][ 'info' ] = $info;
|
||||
}
|
||||
|
||||
// // 二维数组排序
|
||||
// array_multisort( array_column( $staff_list, 'total' ), SORT_DESC, $staff_list );
|
||||
//
|
||||
// $staff_list = array_splice( $staff_list, 0, 3 );
|
||||
|
||||
|
||||
$data = ['max_data' => $max,'max_number'=>max($max) ];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
20
app/card/model/ClientInfo.php
Executable file
20
app/card/model/ClientInfo.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
||||
class ClientInfo extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_client_info';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
}
|
||||
931
app/card/model/Collection.php
Executable file
931
app/card/model/Collection.php
Executable file
@@ -0,0 +1,931 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardShopOrder;
|
||||
use app\dynamic\model\CardStatistics;
|
||||
use app\dynamic\model\UserInfo;
|
||||
use app\radar\model\RadarCount;
|
||||
use think\facade\Db;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Collection extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_collection';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 绑定的员工列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function bindCardList ( $userId, $userInfo, $page = 1, $uniacid = 0 )
|
||||
{
|
||||
$page = intval( $page );
|
||||
|
||||
$page = $page ? $page : 1;
|
||||
|
||||
$data = self::alias( 'a' )
|
||||
->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id' )
|
||||
->join( 'longbing_card_job c', 'b.job_id = c.id', 'LEFT' )
|
||||
->where( [ [ 'a.uniacid', '=', $uniacid ], [ 'a.uid', '=', $userId ], [ 'a.status', '=', 1 ],
|
||||
[ 'b.is_staff', '=', 1 ], [ 'a.to_uid', '<>', $userId ] ]
|
||||
)
|
||||
->field( [ 'a.to_uid', 'b.name', 'b.avatar', 'b.job_id', 'b.phone', 'b.email', 'c.name as job_name' ,'b.name']
|
||||
)
|
||||
->order( [ 'a.id' => 'desc' ] )
|
||||
->paginate( [ 'list_rows' => 10, 'page' => $page ]
|
||||
)
|
||||
->toArray();
|
||||
|
||||
|
||||
// 自己如果是员工则把自己返回在第一页第一个
|
||||
// if ( $userInfo[ 'is_staff' ] == 1 && $page == 1 )
|
||||
// {
|
||||
// $card = self::alias( 'a' )
|
||||
// ->where( [ [ 'a.uniacid', '=', $uniacid ], [ 'a.uid', '=', $userId ], [ 'a.status', '=', 1 ],
|
||||
// [ 'b.is_staff', '=', 1 ], [ 'a.to_uid', '=', $userId ] ]
|
||||
// )
|
||||
// ->field( [ 'a.to_uid', 'b.name', 'b.avatar', 'b.job_id', 'b.phone', 'b.email', 'c.name as job_name' ]
|
||||
// )
|
||||
// ->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id' )
|
||||
// ->join( 'longbing_card_job c', 'b.job_id = c.id', 'LEFT' )
|
||||
// ->find();
|
||||
// if ($card)
|
||||
// {
|
||||
// $card = $card->toArray();
|
||||
//
|
||||
// $data[ 'data' ] = array_merge([$card], $data[ 'data' ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach ($data[ 'data' ] as $index => $item)
|
||||
{
|
||||
if ($item['job_name'] === null)
|
||||
{
|
||||
$data[ 'data' ][$index]['job_name'] = '未设置职位';
|
||||
}
|
||||
}
|
||||
|
||||
$data[ 'data' ] = transImages( $data[ 'data' ], [ 'avatar' ] );
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 默认推荐员工列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function defaultCardList ($page = 1, $uniacid = 0 ,$staff_id = null)
|
||||
{
|
||||
$page = intval( $page );
|
||||
|
||||
$page = $page ? $page : 1;
|
||||
|
||||
$modelUserInfo = new UserInfo();
|
||||
//Update by jingshuixian 'a.fans_id', 'a.fans_id as to_uid', 修复无法访问的bug
|
||||
$where = [ [ 'a.uniacid', '=', $uniacid ], [ 'a.is_default', '=', 1 ], [ 'a.is_staff', '=', 1 ]];
|
||||
if(!empty($staff_id)) $where[] = ['fans_id' ,'<>' , $staff_id];
|
||||
$data = $modelUserInfo->alias('a')
|
||||
->where($where)
|
||||
->field( [ 'a.fans_id', 'a.fans_id as to_uid', 'a.name', 'a.avatar', 'a.job_id', 'a.phone', 'a.email', 'b.name as job_name' ]
|
||||
)
|
||||
->join( 'longbing_card_job b', 'a.job_id = b.id', 'LEFT' )
|
||||
->order( [ 'a.top' => 'desc' ] )
|
||||
->paginate( [ 'list_rows' => 10, 'page' => $page ]
|
||||
)
|
||||
->toArray();
|
||||
|
||||
foreach ($data[ 'data' ] as $index => $item)
|
||||
{
|
||||
if ($item['job_name'] === null)
|
||||
{
|
||||
$data[ 'data' ][$index]['job_name'] = '未设置职位';
|
||||
}
|
||||
}
|
||||
|
||||
$data[ 'data' ] = transImages( $data[ 'data' ], [ 'avatar' ] );
|
||||
|
||||
return $data;
|
||||
}
|
||||
//收藏名片
|
||||
public function createCollection($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
// var_dump($data);die;
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//修改
|
||||
public function updateCollection($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//获取收藏名片总数
|
||||
public function getCollectionCount($filter)
|
||||
{
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
//获取收藏名片信息
|
||||
public function checkCollection($filter)
|
||||
{
|
||||
$result = $this->where($filter)->field('id ,status')->find();
|
||||
if($result) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
//获去信息
|
||||
public function getCollection($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if($result) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
//获取需要更新的rate数据总数
|
||||
// public function getCollectionJoinRateCount()
|
||||
// {
|
||||
// $time = time() - 24*60*60;
|
||||
// $result = $this->alias('a')
|
||||
// ->leftJoin('longbing_card_rate b' ,'a.uid = b.user_id && a.to_uid = b.staff_id && a.uniacid = b.uniacid')
|
||||
//// ->whereOr([['b.update_time' ,'<' ,$time] ,['b.id' , '=',null]])
|
||||
//// ->fetchSql()
|
||||
// ->count();
|
||||
//// var_dump($result);die;
|
||||
// return $result;
|
||||
// }
|
||||
//获取需要更新的rate数据
|
||||
// public function listCollectionJoinRate($page_config = ['page' => 1 ,'page_count' =>200])
|
||||
// {
|
||||
// $time = time() - 24*60*60;
|
||||
// $result = $this->alias('a')
|
||||
// ->leftJoin('longbing_card_rate b' ,'a.uid = b.user_id && a.to_uid = b.staff_id && a.uniacid = b.uniacid')
|
||||
// ->whereOr([['b.update_time' ,'<' ,$time] ,['b.id' ,'=' ,null]])
|
||||
// ->field('a.id ,b.id as rate_id')
|
||||
// ->page($page_config['page'] ,$page_config['page_count'])
|
||||
// ->select();
|
||||
// if(!empty($result)) $result = $result->toArray();
|
||||
// return $result;
|
||||
// }
|
||||
//
|
||||
public function getCollectionJoinRateCount()
|
||||
{
|
||||
$time = time() - 24*60*60;
|
||||
$result = $this->where([['update_rate_time' ,'<' ,$time]])->count();
|
||||
// var_dump($result);die;
|
||||
return $result;
|
||||
}
|
||||
//获取需要更新的rate数据
|
||||
public function listCollectionJoinRate($page_config = ['page' => 1 ,'page_count' =>200])
|
||||
{
|
||||
$time = time() - 24*60*60;
|
||||
$result = $this->where([['update_rate_time' ,'<' ,$time]])
|
||||
->field('id')
|
||||
->page($page_config['page'] ,$page_config['page_count'])
|
||||
->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
public function getYesterdaylist($where){
|
||||
$data = $this->alias('a')
|
||||
->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id')
|
||||
->join( 'longbing_card_user d', 'b.fans_id = d.id && d.is_staff = 1','left')
|
||||
->join( 'longbing_card_job c', 'c.id = b.job_id ','left')
|
||||
->field('a.to_uid,count(a.to_uid) as number,a.uniacid,b.name,avatar,c.name as job_name,nickName,avatarUrl')
|
||||
->where($where)
|
||||
->limit(3)
|
||||
->group('a.to_uid')
|
||||
->order('number desc ,a.to_uid asc')
|
||||
->whereDay('a.create_time','yesterday')
|
||||
->select()->toArray();
|
||||
foreach ($data as $k=>$v){
|
||||
if(!$v['name']){
|
||||
$data[$k]['name'] = $v['nickName'];
|
||||
}
|
||||
if(!$v['avatar']){
|
||||
$data[$k]['avatar'] = $v['avatarUrl'];
|
||||
}
|
||||
if(!$v['job_name']){
|
||||
$data[$k]['job_name'] = '未设置职位';
|
||||
}
|
||||
}
|
||||
$data = transImagesOne($data,['avatar']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getlistAll($where,$page,$list_rows,$type =0,$desc = 0){
|
||||
if($desc == 0){
|
||||
$de = 'asc';
|
||||
}else{
|
||||
$de = 'desc';
|
||||
}
|
||||
if($desc == 0){
|
||||
$de1 = 'desc';
|
||||
}else{
|
||||
$de1 = 'asc';
|
||||
}
|
||||
$data = $this->alias('a')
|
||||
->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id')
|
||||
->join( 'longbing_card_user d', 'b.fans_id = d.id && d.is_staff = 1','left')
|
||||
->join( 'longbing_card_job c', 'c.id = b.job_id ','left')
|
||||
->field('a.to_uid,count(a.to_uid) as number,a.uniacid,b.name,avatar,c.name as job_name,nickName,avatarUrl')
|
||||
->where($where)
|
||||
->group('a.to_uid')
|
||||
->order("number $de,a.to_uid $de1")
|
||||
->paginate([ 'list_rows' => $list_rows, 'page' => $page ])->each(function ($item,$key)use ($type){
|
||||
if(!$item['name']){
|
||||
$item['name'] = $item['nickName'];
|
||||
}
|
||||
if(!$item['avatar']){
|
||||
$item['avatar'] = $item['avatarUrl'];
|
||||
}
|
||||
if(!$item['job_name']){
|
||||
$item['job_name'] = '未设置职位';
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
$data = transImagesOne($data,['avatar']);
|
||||
return $data;
|
||||
}
|
||||
//查询昨天新增客户的数据
|
||||
public function getTodaylist($where){
|
||||
$data = $this->alias('a')
|
||||
//->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id' )
|
||||
->where($where)
|
||||
->field('a.to_uid as user_id,count(a.to_uid) as number,a.uniacid')
|
||||
->whereDay('a.create_time','yesterday')
|
||||
->group( 'a.to_uid' )
|
||||
->select()->toArray();
|
||||
if($data){
|
||||
foreach ($data as $key=>$val){
|
||||
$data[$key]['table'] = 'customer';
|
||||
$data[$key]['create_time'] = strtotime("-1 day");
|
||||
}
|
||||
$stat = new CardStatistics();
|
||||
$stat->createRows($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function getCount($where){
|
||||
return $this->alias('a')
|
||||
->where($where)
|
||||
->count();
|
||||
}
|
||||
//查询今天线索
|
||||
public function today($where){
|
||||
return $this->alias('a')
|
||||
->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id' )
|
||||
->where($where)
|
||||
->whereDay('a.create_time')
|
||||
->group( 'a.uid, a.to_uid' )
|
||||
->count();
|
||||
}
|
||||
//查询七天类的客户数量
|
||||
public function weekToday($where){
|
||||
$weekday = date("Y-m-d",strtotime("-6 day"));
|
||||
$data = $this->alias('a')
|
||||
->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id' )
|
||||
->where($where)
|
||||
->whereWeek('a.update_time',$weekday)
|
||||
->group( 'a.uid, a.to_uid' )
|
||||
->count();
|
||||
return $data;
|
||||
}
|
||||
//查询昨天线索的数据
|
||||
public function Yesterday($where){
|
||||
return $this->alias('a')
|
||||
->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id' )
|
||||
->where($where)
|
||||
->whereDay('a.create_time','yesterday')
|
||||
->group( 'a.uid, a.to_uid' )
|
||||
->count();
|
||||
}
|
||||
// public function getLookCount($where){
|
||||
// return $this->alias('a')
|
||||
// ->join( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
// ->where($where)
|
||||
// ->count();
|
||||
// }
|
||||
//查询客户当天的数据
|
||||
public function todayLook($where){
|
||||
return $this->alias('a')
|
||||
->join( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->whereDay('a.update_time')
|
||||
->where($where)
|
||||
->count();
|
||||
}
|
||||
//更新变更线索人数
|
||||
// public function changeNember($where){
|
||||
// $data = $this->where($where)
|
||||
// ->alias('a')
|
||||
// //->join( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
// ->field('a.to_uid as user_id,count(a.to_uid) as number,a.uniacid')
|
||||
// //->whereDay('a.create_time')
|
||||
// ->group('a.to_uid')
|
||||
// ->select()
|
||||
// ->toArray();
|
||||
// if($data){
|
||||
// $stat = new CardStatistics();
|
||||
// foreach ($data as $key=>$val){
|
||||
// $id = $stat->getUserid(['user_id'=>$val['user_id'],'sign'=>'customer_no']);
|
||||
// if($id){
|
||||
// $stat->updateinfo(['user_id'=>$val['user_id'],'sign'=>'customer_no'],['number'=>$val['number'],'create_time'=>strtotime("-1 day")]);
|
||||
// }else{
|
||||
// $val['sign'] = 'customer_no';
|
||||
// $val['create_time'] = strtotime("-1 day");
|
||||
// $stat->addinfo($val);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
//查询线索数据
|
||||
public function todayUid($where){
|
||||
$data = $this->alias('a')
|
||||
->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id','left' )
|
||||
->where($where)
|
||||
->group( 'a.uid, a.to_uid' )
|
||||
->count();
|
||||
return $data;
|
||||
}
|
||||
//线索池
|
||||
public function xian($where){
|
||||
$sc1 = $this->alias('a')
|
||||
//->join( 'longbing_card_collection b', 'a.uid = b.user_id' )
|
||||
->field('uid,to_uid,intention')
|
||||
->where($where)
|
||||
->column('to_uid','uid');
|
||||
// if($sc1){
|
||||
// foreach ($sc1 as $key=>$value){
|
||||
// $uid = $this->where(['uid'=>$key,'intention'=>1])->value('uid');
|
||||
// if($uid){
|
||||
// unset($sc1[$key]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return count($sc1);
|
||||
}
|
||||
//今天线索池
|
||||
public function Todayxian($where){
|
||||
$sc1 = $this->alias('a')
|
||||
//->join( 'longbing_card_collection b', 'a.uid = b.user_id' )
|
||||
->field('uid,to_uid,intention')
|
||||
->whereDay('create_time')
|
||||
->where($where)
|
||||
->column('to_uid','uid');
|
||||
// if($sc1){
|
||||
// foreach ($sc1 as $key=>$value){
|
||||
// $uid = $this->where(['uid'=>$key,'intention'=>1])->value('uid');
|
||||
// if($uid){
|
||||
// unset($sc1[$key]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return count($sc1);
|
||||
}
|
||||
//总线索数量
|
||||
public function allXian($where){
|
||||
$data = $this->alias('a')->leftJoin( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->join( 'longbing_card_user c', 'a.uid = c.id' )
|
||||
->where($where)
|
||||
->group( 'a.uid, a.to_uid' )->count();
|
||||
return $data;
|
||||
}
|
||||
public function getlistCount($where){
|
||||
return $this->where($where)->count();
|
||||
}
|
||||
//累计访问量
|
||||
public function visit($where){
|
||||
$visit_number = 0;
|
||||
$visit = $this->alias('a')
|
||||
->join( 'longbing_card_count b', 'a.uid = b.user_id && a.to_uid = b.to_uid' )
|
||||
->field('count(a.to_uid) as number')
|
||||
->where($where)
|
||||
->group('a.to_uid')
|
||||
// ->where($where)
|
||||
->select()->toArray();
|
||||
if($visit){
|
||||
foreach ($visit as $value){
|
||||
$visit_number += $value['number'];
|
||||
}
|
||||
}
|
||||
return $visit_number;
|
||||
}
|
||||
public function staffInfo($where_s,$page,$list_rows){
|
||||
$data = $this->alias('a')
|
||||
->join( 'longbing_card_user_info b', 'a.to_uid = b.fans_id' )
|
||||
->join( 'longbing_card_company c', 'b.company_id = c.id')
|
||||
->join( 'longbing_card_job d', 'b.job_id = d.id','left' )
|
||||
->join( 'longbing_card_user e', 'e.id = b.fans_id' )
|
||||
->where($where_s)
|
||||
->field('avatar,b.name,company_id,job_id,b.phone,a.create_time,c.name as company_name,d.name as job_name,b.fans_id,a.uniacid,b.create_time as start_time,a.to_uid,e.create_time as start_time')
|
||||
->find();//
|
||||
$arr =[] ;
|
||||
$follow_info = [];
|
||||
$radar_count = [];
|
||||
$behavior = [];
|
||||
$ability = [];
|
||||
$Interest = [];
|
||||
$active = [];
|
||||
$start_time = 0;
|
||||
if($data){
|
||||
$data = $data ->toArray();
|
||||
if ($data['job_name'] === null)
|
||||
{
|
||||
$data[ 'job_name' ] = '未设置职位';
|
||||
}
|
||||
$timediff = time() - $data['start_time'];
|
||||
$data['day'] = intval($timediff / 86400);
|
||||
$data['time'] = '今天'.date('H:i',time());
|
||||
// $card_value = new CardValue();
|
||||
// $rest = $card_value->bossGetAiValue($data['to_uid'],$data['uniacid']);
|
||||
// $data['total_info'] = $rest['data'];
|
||||
$data['create_time'] = date('Y-m-d',$data['create_time']);
|
||||
//新增线索
|
||||
$collect = new Collection();
|
||||
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
|
||||
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
|
||||
|
||||
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
|
||||
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
|
||||
|
||||
$beginbeforeYesterday=mktime(0,0,0,date('m'),date('d')-2,date('Y'));
|
||||
$endbeforeYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'))-1;
|
||||
$user_id = $data['fans_id'];
|
||||
$stat = new CardStatistics();
|
||||
//累计线索
|
||||
// $wherex[] =[
|
||||
// ['user_id','=',$user_id],
|
||||
// ['uniacid','=',$this->_uniacid],
|
||||
// ['table','=','customer']
|
||||
// ];
|
||||
|
||||
//查询关联公司的员工
|
||||
// $user_info = new UserInfo();
|
||||
//一个公司的员工
|
||||
// $other_staff = $user_info->getIsStaff($user_id,$data['uniacid']);
|
||||
|
||||
//日增长线索
|
||||
$whes[] = [
|
||||
['intention','=',0],
|
||||
['a.uid','<>',$user_id],['a.to_uid','=',$user_id],['a.uniacid','=',$data['uniacid']]
|
||||
|
||||
];
|
||||
$cumulative_clues = $collect->todayUid($whes);
|
||||
$todayKh = $collect->today($whes);
|
||||
//昨天线索
|
||||
$yesterdaytodayKh = $collect->Yesterday($whes);
|
||||
//前天的线索
|
||||
$whes[1] =[
|
||||
[ 'a.create_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday ]]
|
||||
];
|
||||
$beforXs = $collect->todayUid($whes);
|
||||
//昨天对比前天新增数
|
||||
$contrastKh =$yesterdaytodayKh-$beforXs;
|
||||
|
||||
//线索池
|
||||
$whes1[] =[
|
||||
|
||||
['a.uid','<>',$user_id],['a.to_uid','=',$user_id],['a.uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$xs = $collect->todayUid($whes1);
|
||||
//今天的线索池
|
||||
$whes1[1] =[[ 'a.create_time', 'BETWEEN', [ $beginToday, $endToday ]]];
|
||||
$todayxs = $collect->todayUid($whes1);
|
||||
//昨天线索池
|
||||
$whes1[1] =[[ 'a.create_time', 'BETWEEN', [ $beginYesterday, $endYesterday ]]];
|
||||
$yesterdayxs = $collect->todayUid($whes1);
|
||||
//前天线索池
|
||||
$whes1[1] =[[ 'a.create_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday ]]];
|
||||
$beforexs = $collect->todayUid($whes1);
|
||||
//昨天对比前天新增数
|
||||
$contrastxs =$yesterdayxs-$beforexs;
|
||||
$whez[] =[
|
||||
['a.uid','<>',$user_id],
|
||||
['intention','=',1],
|
||||
['a.to_uid','=',$user_id],
|
||||
['a.uniacid','=',$data['uniacid']]
|
||||
];
|
||||
|
||||
// //累计客户数量
|
||||
$customer = $collect->todayUid($whez);
|
||||
|
||||
//日增长客户
|
||||
$today = $collect->today($whez);
|
||||
//日线索增长
|
||||
$addTodayxs = $todayxs-$today;
|
||||
//昨天客户数
|
||||
$yesterdaykh = $collect->Yesterday($whez);
|
||||
//前天的客户
|
||||
$whez[] = [
|
||||
[ 'a.update_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday ]]
|
||||
];
|
||||
$beforkh = $collect->todayUid($whez);
|
||||
//昨天对比前天新增数
|
||||
$contrastkh =$yesterdaykh-$beforkh;
|
||||
|
||||
//累计访问量
|
||||
$card_count = new CardCount();
|
||||
// $visit_number = $stat->getCustomerCount([['user_id','=',$user_id],
|
||||
// ['sign','=','praise'],
|
||||
// ['type','=',2],['uniacid','=',$this->_uniacid]]);
|
||||
|
||||
//今天的访问量
|
||||
$wheres[] = [
|
||||
['to_uid','=',$user_id],
|
||||
['sign','=','praise'],
|
||||
['type','=',2],
|
||||
['uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$visit_number = $card_count->getCount($wheres);
|
||||
$wheres[1] =[[ 'create_time', 'BETWEEN', [ $beginToday, $endToday ]]];
|
||||
$todayVisitNumber = $card_count->getCount($wheres);
|
||||
//昨天的访问量
|
||||
$wheres[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginYesterday, $endYesterday ] ],
|
||||
];
|
||||
$yesterdayVisit = $card_count->getCount($wheres);
|
||||
//前天的访问量
|
||||
$wheres[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday] ],
|
||||
];
|
||||
$beforVisit = $card_count->getCount($wheres);
|
||||
//昨天对比前天新增数
|
||||
$contrastVisit =$yesterdayVisit-$beforVisit;
|
||||
|
||||
//咨询
|
||||
//消息
|
||||
$whereMsg[] = [
|
||||
['message_type','=','text'],
|
||||
['deleted','=',0],
|
||||
['uniacid','=',$this->_uniacid],
|
||||
['target_id','=',$user_id]
|
||||
];
|
||||
$card_message = new CardMessage();
|
||||
//累计消息
|
||||
$message = $card_message->getCount($whereMsg);
|
||||
//今天消息
|
||||
$whereMsg[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginToday, $endToday ] ],
|
||||
];
|
||||
$today_message = $card_message->getCount($whereMsg);
|
||||
//昨天的消息
|
||||
$whereMsg[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginYesterday, $endYesterday ] ],
|
||||
];
|
||||
$Yesterday_message = $card_message->getCount($whereMsg);
|
||||
//前天的消息
|
||||
$whereMsg[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday ] ],
|
||||
];
|
||||
$before_message = $card_message->getCount($whereMsg);
|
||||
$zx = $card_count->zxInfo($user_id,[],1);
|
||||
$zx = $zx+$message;
|
||||
$where1 = ['create_time','BETWEEN',[ $beginToday, $endToday ]];
|
||||
$zxtoday = $card_count->zxInfo($user_id,$where1,1);
|
||||
$zxtoday = $zxtoday+$today_message;
|
||||
//昨天的咨询
|
||||
$where1 = ['create_time','BETWEEN',[ $beginYesterday, $endYesterday ]];
|
||||
$zxYesterday = $card_count->zxInfo($user_id,$where1,1);
|
||||
$zxYesterday = $zxYesterday+$Yesterday_message;
|
||||
//前天的咨询
|
||||
$where1 = ['create_time','BETWEEN',[ $beginbeforeYesterday, $endbeforeYesterday ]];
|
||||
$zxbefore = $card_count->zxInfo($user_id,$where1,1);
|
||||
$zxbefore = $zxbefore+$before_message;
|
||||
//昨天对比前天新增数
|
||||
$contrastzx =$zxYesterday-$zxbefore;
|
||||
|
||||
//跟进客户次数
|
||||
$user_mark = new UserFollow();
|
||||
$where3[] = [
|
||||
['staff_id','=',$user_id],
|
||||
['status','=',1],
|
||||
//['uniacid','=',$this->_uniacid]
|
||||
];
|
||||
$mark = $user_mark->getCount($where3);
|
||||
$where3[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginToday, $endToday ] ],
|
||||
];
|
||||
$today_mark = $user_mark->getCount($where3);
|
||||
//昨天的跟进客户
|
||||
$where3[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginYesterday, $endYesterday ] ],
|
||||
];
|
||||
$Yesterday_mark = $user_mark->getCount($where3);
|
||||
//前天的跟进客户
|
||||
$where3[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginbeforeYesterday, $endbeforeYesterday ] ],
|
||||
];
|
||||
$before_mark = $user_mark->getCount($where3);
|
||||
$contrastzmark =$Yesterday_mark-$before_mark;
|
||||
//被转发次数
|
||||
// $forward = new CardForward();
|
||||
$where4[] = [
|
||||
['to_uid','=',$user_id],
|
||||
['type','=',4],
|
||||
['sign','=','praise'],
|
||||
['uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$forward_count = $card_count->getCount($where4);
|
||||
$today_forward_count =$card_count->gettoday($where4);
|
||||
//昨天转发
|
||||
$Yesterday_forward_count =$card_count->getYesterday($where4);
|
||||
//前天转发
|
||||
$where4[] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginbeforeYesterday, $endbeforeYesterday] ],
|
||||
];
|
||||
$before_forward_count =$card_count->getCount($where4);
|
||||
$contrastzforward =$Yesterday_forward_count-$before_forward_count;
|
||||
//累计被点赞次数
|
||||
$where5[] = [
|
||||
['to_uid','=',$user_id],
|
||||
['type','=',3],
|
||||
['sign','=','praise'],
|
||||
['uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$dz = $card_count->getCount($where5);
|
||||
$where5[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginToday, $endToday ] ],
|
||||
];
|
||||
$today_dz = $card_count->getCount($where5);
|
||||
//昨天点赞
|
||||
$where5[1] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginYesterday, $endYesterday] ],
|
||||
];
|
||||
$Yesterday_dz = $card_count->getCount($where5);
|
||||
//前天点赞
|
||||
$where5[1] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginbeforeYesterday, $endbeforeYesterday] ],
|
||||
];
|
||||
$before_dz = $card_count->getCount($where5);
|
||||
$contrastzdz =$Yesterday_dz-$before_dz;
|
||||
//累计被保存次数
|
||||
$where6[] = [
|
||||
['to_uid','=',$user_id],
|
||||
['type','=',1],
|
||||
['sign','=','copy'],
|
||||
['uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$bc = $card_count->getCount($where6);
|
||||
$where6[1] = [
|
||||
[ 'create_time', 'BETWEEN', [ $beginToday, $endToday ] ],
|
||||
];
|
||||
$today_bc = $card_count->getCount($where6);
|
||||
//昨天保存
|
||||
$where6[1] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginYesterday, $endYesterday] ],
|
||||
];
|
||||
$Yesterday_bc = $card_count->getCount($where6);
|
||||
//前天保存
|
||||
$where6[1] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginbeforeYesterday, $endbeforeYesterday] ],
|
||||
];
|
||||
$before_bc = $card_count->getCount($where6);
|
||||
$contrastzbc =$Yesterday_bc-$before_bc;
|
||||
//商城订单笔数和销售金额
|
||||
$admin_goods = new CardShopOrder();
|
||||
$where7[]= [
|
||||
['company_id','=',$data['company_id']],
|
||||
['to_uid','=',$user_id],
|
||||
['uniacid','=',$data['uniacid']]
|
||||
];
|
||||
$sales_count = $admin_goods->getGoosSale($where7);
|
||||
//昨天的商品销售
|
||||
$where7[] = [
|
||||
[ 'create_time', 'BETWEEN', [$beginYesterday, $endYesterday] ],
|
||||
];
|
||||
$Yesterday_sales_count = $admin_goods->getGoosSale($where7);
|
||||
//数据
|
||||
$arr = [
|
||||
'count'=>[
|
||||
[
|
||||
[
|
||||
'name'=>'累计线索(人)',
|
||||
'number'=>$xs,
|
||||
'rate'=>$todayKh,
|
||||
],
|
||||
[
|
||||
'name'=>'线索池(人)',
|
||||
'number'=>$cumulative_clues,
|
||||
// 'text'=>$title,
|
||||
'rate'=>$addTodayxs,
|
||||
// 'up'=>$up
|
||||
],
|
||||
[
|
||||
'name'=>'累计客户(人)',
|
||||
'number'=>$customer,
|
||||
'rate'=>$today,
|
||||
],
|
||||
[
|
||||
'name'=>'累计访问量(次)',
|
||||
'number'=>$visit_number,
|
||||
'rate'=>$todayVisitNumber,
|
||||
],
|
||||
[
|
||||
'name'=>'累计咨询(次)',
|
||||
'number'=>$zx,
|
||||
'rate'=>$zxtoday,
|
||||
],
|
||||
[
|
||||
'name'=>'累计跟进客户(次)',
|
||||
'number'=>$mark,
|
||||
'rate'=>$today_mark,
|
||||
],
|
||||
[
|
||||
'name'=>'累计被转发(次)',
|
||||
'number'=>$forward_count,
|
||||
'rate'=>$today_forward_count,
|
||||
],
|
||||
[
|
||||
'name'=>'累计被点赞(次)',
|
||||
'number'=>$dz,
|
||||
'rate'=>$today_dz,
|
||||
],
|
||||
[
|
||||
'name'=>'累计被保存(次)',
|
||||
'number'=>$bc,
|
||||
'rate'=>$today_bc,
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'name'=>'新增线索(人)',
|
||||
'number'=>$yesterdaytodayKh,
|
||||
'rate'=>$contrastKh,
|
||||
],
|
||||
[
|
||||
'name'=>'变动线索池(人)',
|
||||
'number'=>$yesterdayxs,
|
||||
'rate'=>$contrastxs,
|
||||
],
|
||||
[
|
||||
'name'=>'新增客户(人)',
|
||||
'number'=>$yesterdaykh,
|
||||
'rate'=>$contrastkh,
|
||||
],
|
||||
[
|
||||
'name'=>'新增访问量(次)',
|
||||
'number'=>$yesterdayVisit,
|
||||
'rate'=>$contrastVisit,
|
||||
],
|
||||
[
|
||||
'name'=>'新增咨询(次)',
|
||||
'number'=>$zxYesterday,
|
||||
'rate'=>$contrastzx,
|
||||
],
|
||||
[
|
||||
'name'=>'新增跟进客户(次)',
|
||||
'number'=>$Yesterday_mark,
|
||||
'rate'=>$contrastzmark,
|
||||
],
|
||||
[
|
||||
'name'=>'新增被转发(次)',
|
||||
'number'=>$Yesterday_forward_count,
|
||||
'rate'=>$contrastzforward,
|
||||
],
|
||||
[
|
||||
'name'=>'新增被点赞(次)',
|
||||
'number'=>$Yesterday_dz,
|
||||
'rate'=>$contrastzdz,
|
||||
],
|
||||
[
|
||||
'name'=>'新增被保存(次)',
|
||||
'number'=>$Yesterday_bc,
|
||||
'rate'=>$contrastzbc,
|
||||
]
|
||||
],
|
||||
],
|
||||
'goods_sale'=>[
|
||||
$sales_count,$Yesterday_sales_count
|
||||
]
|
||||
];
|
||||
$title1 = '日增涨';
|
||||
$title2 = '日减少';
|
||||
$title3 = '持平 -';
|
||||
foreach ($arr['count'][0] as $key=>$value){
|
||||
if($value['rate']>0){
|
||||
$arr['count'][0][$key]['text'] = $title1;
|
||||
$arr['count'][0][$key]['up'] =1;
|
||||
}elseif ($value['rate']==0){
|
||||
$arr['count'][0][$key]['up'] =-1;
|
||||
$arr['count'][0][$key]['text'] = $title3;
|
||||
}else{
|
||||
$arr['count'][0][$key]['up'] =0;
|
||||
$arr['count'][0][$key]['text'] = $title2;
|
||||
}
|
||||
$arr['count'][0][$key]['rate'] = abs($value['rate']);
|
||||
}
|
||||
foreach ($arr['count'][1] as $k=>$val){
|
||||
|
||||
if($val['rate']>0){
|
||||
$arr['count'][1][$k]['text'] = $title1;
|
||||
$arr['count'][1][$k]['up'] =1;
|
||||
}elseif ($val['rate']==0){
|
||||
$arr['count'][1][$k]['up'] =-1;
|
||||
$arr['count'][1][$k]['text'] = $title3;
|
||||
}else{
|
||||
$arr['count'][1][$k]['up'] =0;
|
||||
$arr['count'][1][$k]['text'] = $title2;
|
||||
}
|
||||
$arr['count'][1][$k]['rate'] = abs($val['rate']);
|
||||
}
|
||||
//跟进客户记录
|
||||
$follow_info = UserFollow::alias( 'a' )
|
||||
->join( 'longbing_card_user b', 'a.user_id = b.id')
|
||||
->field( [ 'content', 'a.create_time','user_id','b.nickName as name' ] )
|
||||
->where( [
|
||||
[ 'a.staff_id', '=',$user_id ] ]
|
||||
)->order( 'a.id', 'desc' )
|
||||
->paginate( [ 'list_rows' => 4, 'page' => 1 ])->toArray();
|
||||
$follow_info['data'] = lbHandelRadarDate( $follow_info['data'], 'create_time' );
|
||||
foreach ($follow_info['data'] as $index => $item )
|
||||
{
|
||||
$follow_info['data'][ $index ][ 'create_time' ] = date( 'Y-m-d H:i', $item[ 'create_time' ] );
|
||||
}
|
||||
|
||||
$ardar = new CardCount();
|
||||
$radar_count = $ardar->radarList([ [ 'a.to_uid', '=', $user_id ],[ 'a.user_id', '<>', $user_id ] ], 1,4);
|
||||
$radar_count['data'] = lbHandelRadarDate( $radar_count['data'], 'create_time' );
|
||||
if($radar_count['data']){
|
||||
foreach ($radar_count['data'] as $k => $v )
|
||||
{
|
||||
$radar_count['data'][ $k ][ 'create_time' ] = date( 'Y-m-d H:i', $v[ 'create_time' ] );
|
||||
}
|
||||
}
|
||||
//客户行为
|
||||
$card_count = new CardCount();
|
||||
$behavior = $card_count->getsss($user_id,$data['uniacid'],1);
|
||||
//能力雷达
|
||||
$card_value = new CardValue();
|
||||
|
||||
$ability = $card_value->bossGetAiValue($user_id,$data['uniacid']);
|
||||
//兴趣占比
|
||||
$Interest = $ardar->doPageBossInterest(['to_uid','=',$user_id],$data['uniacid']);
|
||||
//客户活跃度
|
||||
$active = $ardar->active($user_id,$data['uniacid']);
|
||||
$timediff = time() - $data['start_time'];
|
||||
$start_time = intval($timediff / 86400);
|
||||
}
|
||||
$data['look'] =$arr;
|
||||
$data['interaction'] =$radar_count;
|
||||
$data['follow_info'] =$follow_info;
|
||||
$data['behavior'] =$behavior;
|
||||
$data['ability'] =$ability;
|
||||
$data['interest'] =$Interest;
|
||||
$data['active'] =$active;
|
||||
$data['day'] = $start_time;
|
||||
$data = transImagesOne($data, ['avatar']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-03-30 15:06
|
||||
* @功能说明:获取浏览过的名片
|
||||
*/
|
||||
public function getCard($uid,$uniacid){
|
||||
//查看浏览过的名片
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b', 'a.to_uid = b.id AND b.is_staff = 1')
|
||||
->where(['uid'=>$uid])
|
||||
->value('to_uid');
|
||||
|
||||
//如果没有就给一个推荐的
|
||||
if(empty($data)){
|
||||
|
||||
$data = Db::name('longbing_card_user_info')->where(['uniacid'=>$uniacid,'is_default'=>1])->value('fans_id');
|
||||
}
|
||||
//修改
|
||||
if(!empty($data)){
|
||||
//修改最近浏览的名片
|
||||
Db::name('longbing_card_user')->where(['id'=>$uid])->update(['last_staff_id'=>$data]);
|
||||
//增肌默认分配次数
|
||||
Db::name('longbing_card_user')->where(['id'=>$data])->inc('auto_count');
|
||||
//缓存的键
|
||||
$key = 'longbing_card_user_' . $uid;
|
||||
//删除缓存
|
||||
delCache($key,$uniacid);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
358
app/card/model/Company.php
Executable file
358
app/card/model/Company.php
Executable file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Company extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_company';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 创建公司
|
||||
* @Author: yangqi
|
||||
* @create time : 2019年11月25日20:28:45
|
||||
*/
|
||||
|
||||
public function createRow($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 获取公司信息
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getInfo ( $uniacid = 0, $userId = 0, $company_id = 0 )
|
||||
{
|
||||
$company = [];
|
||||
|
||||
if ( $userId )
|
||||
{
|
||||
$userInfo = UserInfo::where( [ [ 'fans_id', '=', $userId ] ] )
|
||||
->find();
|
||||
if ( $userInfo && $userInfo[ 'company_id' ] )
|
||||
{
|
||||
$company = self::where( [ [ 'id', '=', $userInfo[ 'company_id' ] ], [ 'status', '=', 1 ] ] )
|
||||
// ->withoutField( [ 'auth_code' ] )
|
||||
->find();
|
||||
}
|
||||
}
|
||||
|
||||
if ( $company_id )
|
||||
{
|
||||
$company = self::where( [ [ 'id', '=', $company_id ], [ 'status', '=', 1 ] ] )
|
||||
// ->withoutField( [ 'auth_code' ] )
|
||||
->find();
|
||||
}
|
||||
|
||||
if ( is_array( $company ) && $company = [] )
|
||||
{
|
||||
$company = self::where( [ [ 'status', '=', 1 ], [ 'uniacid', '=', $uniacid ] ] )
|
||||
// ->withoutField( [ 'auth_code' ] )
|
||||
->find();
|
||||
}
|
||||
|
||||
if ( $company )
|
||||
{
|
||||
$company = $company->toArray();
|
||||
$company = transImages( $company, [ 'culture' ] );
|
||||
$company = transImagesOne( $company, [ 'logo', 'desc' ] );
|
||||
$company[ 'shop_bg' ] = $company[ 'desc' ];
|
||||
$company[ 'carousel' ] = $company[ 'culture' ];
|
||||
}
|
||||
return $company;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-21 14:02
|
||||
* @功能说明:替换顶级公司的名字
|
||||
*/
|
||||
|
||||
public function changeTopName($company){
|
||||
|
||||
if(!empty($company['top_id'])){
|
||||
|
||||
$dis = [
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'id' => $company['top_id'],
|
||||
|
||||
'uniacid'=> $company['uniacid']
|
||||
|
||||
];
|
||||
|
||||
$top_name = $this->where($dis)->value('name');
|
||||
|
||||
$short_name = $this->where($dis)->value('short_name');
|
||||
|
||||
if(!empty($top_name)){
|
||||
|
||||
$company['name'] = $top_name;
|
||||
|
||||
$company['short_name'] = $short_name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 根据用户id返回公司列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getListByUser ( $user_id, $uniacid, $is_all = 0, $company_id = 0 )
|
||||
{
|
||||
if ( $is_all )
|
||||
{
|
||||
$companyList = self::where( [ [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1, ], [ 'pid', '=', 0 ] ] )
|
||||
->field( [ 'id', 'pid', 'name', 'logo', 'addr' ] )
|
||||
->order('top desc,pid asc,id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$sonList = self::where( [ [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1, ], [ 'pid', '<>', 0 ] ] )
|
||||
->field( [ 'id', 'pid', 'name', 'logo', 'addr' ] )
|
||||
->order('top desc,pid asc,id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$companyList = self::handleCompanyLevel( $companyList, $sonList );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$modelCardBoss = new CardBoss();
|
||||
$check = $modelCardBoss->where( [ [ 'user_id', '=', $user_id ], [ 'uniacid', '=', $uniacid ],
|
||||
[ 'boss', '<>', '' ] ]
|
||||
)
|
||||
->field( [ 'boss' ] )
|
||||
->find();
|
||||
if ( !$check )
|
||||
{
|
||||
return $this->getListByUser( $user_id, $uniacid, $is_all = 1 );
|
||||
}
|
||||
|
||||
$tmpArr = explode( ',', $check[ 'boss' ] );
|
||||
$companyList = self::where( [ [ 'uniacid', '=', $uniacid ], [ 'status', '=', 1, ], [ 'id', 'in', $tmpArr ] ] )
|
||||
->field( [ 'id', 'pid', 'name', 'logo', 'addr' ] )
|
||||
->order('top desc,pid asc,id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ( $companyList as $index => $item )
|
||||
{
|
||||
$companyList[ $index ][ 'sec' ] = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$companyList = transImagesOne( $companyList, [ 'logo' ] );
|
||||
|
||||
foreach ( $companyList as $index => $item )
|
||||
{
|
||||
$companyList[ $index ][ 'selected' ] = 0;
|
||||
if ( isset( $item[ 'id' ] ) && $item[ 'id' ] == $company_id )
|
||||
{
|
||||
$companyList[ $index ][ 'selected' ] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $companyList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 处理公司层级--无限级
|
||||
*
|
||||
* @Param: array $list 顶级公司列表
|
||||
* @Param: array $son 部门列表
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function handleCompanyLevel ( $list, $son, $item_name = 'sec' )
|
||||
{
|
||||
foreach ( $list as $index => $item )
|
||||
{
|
||||
if ( !isset( $list[ $index ][ $item_name ] ) )
|
||||
{
|
||||
$list[ $index ][ $item_name ] = array();
|
||||
}
|
||||
foreach ( $son as $key => $value )
|
||||
{
|
||||
if ( $item[ 'id' ] == $value[ 'pid' ] )
|
||||
{
|
||||
array_push( $list[ $index ][ $item_name ], $value );
|
||||
unset( $son[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $list[ $index ][ $item_name ] && count( $list[ $index ][ $item_name ] ) && count( $son ) )
|
||||
{
|
||||
|
||||
$list[ $index ][ $item_name ] = self::handleCompanyLevel( $list[ $index ][ $item_name ], $son, $item_name );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 改变公司状态
|
||||
*
|
||||
* @Param:$company_id number 公司id
|
||||
* @Param:$method number 操作类型 0 = 下架 1 = 上架 2 = 删除
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function updateStatus ( $company_id, $method = 0 )
|
||||
{
|
||||
$result = false;
|
||||
switch ( $method )
|
||||
{
|
||||
case 0:
|
||||
$result = self::update( [ 'status' => 0 ], [ 'id' => $company_id ] );
|
||||
$this->updateSonCompanyInfo( $company_id, [ 'status' => 0 ] );
|
||||
break;
|
||||
case 1:
|
||||
$result = self::update( [ 'status' => 1 ], [ 'id' => $company_id ] );
|
||||
break;
|
||||
case 2:
|
||||
$result = self::update( [ 'status' => -1 ], [ 'id' => $company_id ] );
|
||||
$this->updateSonCompanyInfo( $company_id, [ 'status' => -1 ] );
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $result === false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 改变下级公司信息
|
||||
*
|
||||
* @Param:$company_id number 公司id
|
||||
* @Param:$data array 修改内容
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function updateSonCompanyInfo ( $company_id, $data )
|
||||
{
|
||||
$list = self::where( [ [ 'pid', '=', $company_id ] ] )
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ( $list as $index => $item )
|
||||
{
|
||||
$check = self::where( [ [ 'pid', '=', $item[ 'id' ] ] ] )
|
||||
->count();
|
||||
if ( $check )
|
||||
{
|
||||
$this->updateSonCompanyInfo( $item[ 'id' ], $data );
|
||||
}
|
||||
self::update( $data, [ 'id' => $item[ 'id' ] ] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 获取公司和部门名
|
||||
*
|
||||
* @Param:$company_id number 公司id
|
||||
*
|
||||
* @Author: zzf
|
||||
*
|
||||
* @Return: mixed 查询返回值(结果集对象)
|
||||
*/
|
||||
public function getCompanyAndDepartmentName ( $company_id )
|
||||
{
|
||||
$info = self::where( [ [ 'id', '=', $company_id ] ] )
|
||||
->find();
|
||||
|
||||
if ( !$info )
|
||||
{
|
||||
return [ '未设置公司', '未设置部门' ];
|
||||
}
|
||||
|
||||
if ( $info[ 'pid' ] == 0 )
|
||||
{
|
||||
return [ $info[ 'name' ], '未设置部门' ];
|
||||
}
|
||||
|
||||
$topCompany = $this->getTopCompany( $info[ 'pid' ] );
|
||||
|
||||
$companyName = '未设置公司';
|
||||
|
||||
if ( $topCompany && $topCompany[ 'status' ] )
|
||||
{
|
||||
$companyName = $topCompany[ 'name' ];
|
||||
}
|
||||
|
||||
return [ $companyName, $info[ 'name' ] ];
|
||||
|
||||
}
|
||||
|
||||
protected function getTopCompany ( $pid )
|
||||
{
|
||||
$info = self::where( [ [ 'id', '=', $pid ] ] )
|
||||
->find();
|
||||
if ( !$info )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $info[ 'pid' ] )
|
||||
{
|
||||
return $this->getTopCompany( $info[ 'pid' ] );
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function getCompany($filter ,$field = [])
|
||||
{
|
||||
if(isset($filter['company_id']))
|
||||
{
|
||||
$filter['id'] = $filter['company_id'];
|
||||
unset($filter['company_id']);
|
||||
}
|
||||
$result = $this->where($filter);
|
||||
if(!empty($field)) $result = $result->field($field);
|
||||
$result = $result->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
71
app/card/model/Config.php
Executable file
71
app/card/model/Config.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
||||
class Config extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_config';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
|
||||
public function initConfig ($uniacid)
|
||||
{
|
||||
return self::create( [ 'uniacid' => $uniacid,'agreement'=>'' ] );
|
||||
}
|
||||
|
||||
public function getConfig ($uniacid)
|
||||
{
|
||||
$key = 'longbing_card_config_';
|
||||
|
||||
$cacheData = getCache($key, $uniacid);
|
||||
|
||||
// 暂时关闭缓存
|
||||
$cacheData = false;
|
||||
|
||||
if ($cacheData)
|
||||
{
|
||||
$cacheData['fromCache'] = 1;
|
||||
return $cacheData;
|
||||
}
|
||||
|
||||
$data = self::where( [ [ 'uniacid', '=', $uniacid ] ] )
|
||||
->find();
|
||||
|
||||
if ( !$data )
|
||||
{
|
||||
$data = $this->initConfig($uniacid);
|
||||
}
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
|
||||
$data = transImagesOne( $data, [ 'vr_cover', 'default_video', 'default_voice', 'appoint_pic', 'click_copy_show_img',
|
||||
'shop_carousel_more', 'copyright', 'default_video_cover' ], $uniacid
|
||||
);
|
||||
setCache( $key, $data, 36000, $uniacid );
|
||||
|
||||
return $data;
|
||||
}
|
||||
//获取
|
||||
public function getConfigByUniacid($uniacid)
|
||||
{
|
||||
$result = $this->where(['uniacid' => $uniacid])->find();
|
||||
if(!empty($result)){
|
||||
$result = $result->toArray();
|
||||
$result = transImagesOne($data, [ 'vr_cover', 'default_video', 'default_voice', 'appoint_pic', 'click_copy_show_img',
|
||||
'shop_carousel_more', 'copyright', 'default_video_cover' ], $uniacid);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
54
app/card/model/DefaultSetting.php
Executable file
54
app/card/model/DefaultSetting.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
||||
class DefaultSetting extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_default_setting';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-03-18 12:23
|
||||
* @功能说明:查找配置
|
||||
*/
|
||||
public function settingInfo($dis,$field='*'){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$dis['my_photo_cover'] = !empty($dis['my_photo_cover'])?$dis['my_photo_cover']:'';
|
||||
|
||||
$dis['share_text'] = !empty($dis['share_text'])?$dis['share_text']:'';
|
||||
|
||||
$this->insert($dis);
|
||||
}
|
||||
|
||||
return $this->where($dis)->field($field)->find()->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-03-18 12:24
|
||||
* @功能说明:配置编辑
|
||||
*/
|
||||
public function settingUpdate($dis,$data){
|
||||
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
33
app/card/model/Job.php
Executable file
33
app/card/model/Job.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
|
||||
class Job extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_job';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
/**
|
||||
* @Purpose: 创建职位
|
||||
*
|
||||
* @Author: yangqi
|
||||
*
|
||||
* @Return: boolean
|
||||
*/
|
||||
|
||||
public function createRow($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
}
|
||||
453
app/card/model/User.php
Executable file
453
app/card/model/User.php
Executable file
@@ -0,0 +1,453 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use longbingcore\wxcore\Excel;
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
||||
class User extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user';
|
||||
|
||||
|
||||
protected static function init ()
|
||||
{
|
||||
//TODO:初始化内容
|
||||
}
|
||||
|
||||
public function searchNickNameAttr($query, $value, $data)
|
||||
{
|
||||
$query->where('nickName','like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
public function createUser($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function updateUser($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function getUser($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
public function listUser($filter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $where
|
||||
* @功能说明:名片导出
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 14:41
|
||||
*/
|
||||
public function cardExcel($where,$mapor,$type=0,$start_time='',$end_time=''){
|
||||
|
||||
$data = User::alias( 'a' )
|
||||
->join( 'longbing_card_user_info b', 'b.fans_id = a.id' ,'LEFT')
|
||||
->join( 'longbing_card_company c', 'b.company_id = c.id', 'LEFT' )
|
||||
->join( 'longbing_card_company d', 'c.top_id = d.id', 'LEFT' )
|
||||
->where( $where )
|
||||
->where(function ($query) use ($mapor){
|
||||
$query->whereOr($mapor);
|
||||
})
|
||||
->field( [ 'b.id as card_id', 'b.name', 'b.avatar', 'b.job_id', 'b.company_id', 'b.phone',
|
||||
'b.create_time', 'a.nickName', 'a.avatarUrl', 'a.is_staff', 'a.is_boss',
|
||||
'c.name as company_name', 'd.name as top_company_name', 'b.is_default', 'a.id' ,'a.import','a.uniacid']
|
||||
)
|
||||
->group('a.id')
|
||||
->order( [ 'a.is_boss' => 'desc', 'a.is_staff' => 'desc', 'a.update_time' => 'desc', 'a.id' => 'desc' ] )
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
if(empty($v['top_company_name'])){
|
||||
|
||||
$data[$k]['top_company_name'] = $v['company_name'];
|
||||
|
||||
$data[$k]['company_name'] = '未设置部门';
|
||||
}
|
||||
$data[$k]['name'] = !empty($v['name'])?$v['name']:$v['nickName'];
|
||||
//累计客户数量
|
||||
$data[$k]['all_customer'] = $this->customerCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增客户
|
||||
$data[$k]['new_customer'] = $this->customerCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
//累计线索
|
||||
$data[$k]['all_collection'] = $this->collectionCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增线索
|
||||
$data[$k]['new_collection'] = $this->collectionCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
//总浏览量
|
||||
$data[$k]['all_visit'] = $this->visitCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增浏览量
|
||||
$data[$k]['new_visit'] = $this->visitCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
//累计转发
|
||||
$data[$k]['all_zf'] = $this->zfCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增转发
|
||||
$data[$k]['new_zf'] = $this->zfCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
//累计被保存
|
||||
$data[$k]['all_save'] = $this->saveCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增保存
|
||||
$data[$k]['new_save'] = $this->saveCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
//累计点赞
|
||||
$data[$k]['all_dz'] = $this->dzCount($v['id'],$v['uniacid'],0,$end_time);
|
||||
//新增点赞
|
||||
$data[$k]['new_dz'] = $this->dzCount($v['id'],$v['uniacid'],$start_time,$end_time);
|
||||
}
|
||||
}
|
||||
|
||||
$header=[
|
||||
'序号',
|
||||
'分公司',
|
||||
'部门',
|
||||
'员工姓名',
|
||||
'客户数',
|
||||
'',
|
||||
'累计线索',
|
||||
'',
|
||||
'累计浏览量',
|
||||
'',
|
||||
'累计被转发',
|
||||
'',
|
||||
'累计被保存',
|
||||
'',
|
||||
'累计被点赞',
|
||||
'',
|
||||
];
|
||||
|
||||
if($type==1){
|
||||
$header_one=[
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'新增',
|
||||
'总数',
|
||||
'新增',
|
||||
'总数',
|
||||
'新增',
|
||||
'总数',
|
||||
'新增',
|
||||
'总数',
|
||||
'新增',
|
||||
'总数',
|
||||
'新增',
|
||||
'总数',
|
||||
];
|
||||
}else{
|
||||
|
||||
$header_one=[
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'累计新增',
|
||||
'总数',
|
||||
'累计新增',
|
||||
'总数',
|
||||
'累计新增',
|
||||
'总数',
|
||||
'累计新增',
|
||||
'总数',
|
||||
'累计新增',
|
||||
'总数',
|
||||
'累计新增',
|
||||
'总数',
|
||||
];
|
||||
}
|
||||
$new_data = [];
|
||||
|
||||
$new_data[] = $header_one;
|
||||
|
||||
$data = array_values($data);
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$info = array();
|
||||
|
||||
$info[] = $k+1;
|
||||
|
||||
$info[] = $v['top_company_name'];
|
||||
|
||||
$info[] = $v['company_name'];
|
||||
|
||||
$info[] = $v['name'];
|
||||
|
||||
$info[] = $v['new_customer'];
|
||||
|
||||
$info[] = $v['all_customer'];
|
||||
|
||||
$info[] = $v['new_collection'];
|
||||
|
||||
$info[] = $v['all_collection'];
|
||||
|
||||
$info[] = $v['new_visit'];
|
||||
|
||||
$info[] = $v['all_visit'];
|
||||
|
||||
$info[] = $v['new_zf'];
|
||||
|
||||
$info[] = $v['all_zf'];
|
||||
|
||||
$info[] = $v['new_save'];
|
||||
|
||||
$info[] = $v['all_save'];
|
||||
|
||||
$info[] = $v['new_dz'];
|
||||
|
||||
$info[] = $v['all_dz'];
|
||||
|
||||
$new_data[] = $info;
|
||||
}
|
||||
|
||||
$excel = new Excel();
|
||||
|
||||
$name = '员工列表';
|
||||
|
||||
if($type==1){
|
||||
|
||||
$name = date('Y-m-d',$start_time).'——'.'员工列表';
|
||||
}
|
||||
|
||||
if($type==0&&!empty($start_time)&&!empty($end_time)){
|
||||
|
||||
$name = date('Y-m-d',$start_time).'——'.date('Y-m-d',$end_time).'-'.'员工列表';
|
||||
}
|
||||
|
||||
|
||||
// dump($name);exit;
|
||||
$fileName=$excel->excelExport($name,$header,$new_data,1);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:客户数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function customerCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
//线索模型
|
||||
$collect = new Collection();
|
||||
|
||||
$whez[] =[
|
||||
|
||||
['a.uid','<>',$user_id],
|
||||
|
||||
['intention','=',1],
|
||||
|
||||
['a.to_uid','=',$user_id],
|
||||
|
||||
['a.uniacid','=',$uniacid]
|
||||
];
|
||||
|
||||
//如果选了时间
|
||||
if(!empty($start_time)||!empty($end_time)){
|
||||
|
||||
$whez[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
$new_customer = $collect->todayUid($whez);
|
||||
|
||||
return $new_customer;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:线索数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function collectionCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
//线索模型
|
||||
$collect = new Collection();
|
||||
|
||||
|
||||
$whes[] = [
|
||||
|
||||
['a.uid','<>',$user_id],
|
||||
|
||||
['a.to_uid','=',$user_id],
|
||||
|
||||
['a.uniacid','=',$uniacid],
|
||||
|
||||
// ['intention','=',0],
|
||||
];
|
||||
|
||||
//如果选了时间
|
||||
if(!empty($start_time)||!empty($end_time)){
|
||||
|
||||
$whes[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
$data = $collect->todayUid($whes);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:线索数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function visitCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
|
||||
//雷达模型
|
||||
$card_count = new CardCount();
|
||||
|
||||
$wheres[] = [
|
||||
['to_uid','=',$user_id],
|
||||
|
||||
['sign','=','praise'],
|
||||
|
||||
['type','=',2],
|
||||
|
||||
['uniacid','=',$uniacid]
|
||||
];
|
||||
|
||||
//如果选了时间
|
||||
if(!empty($start_time)||!empty($end_time)){
|
||||
|
||||
$wheres[] = ['create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//新增浏览量
|
||||
$data = $card_count->getCount($wheres);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:转发数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function zfCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
|
||||
//雷达模型
|
||||
$card_count = new CardCount();
|
||||
|
||||
$where4[] = [
|
||||
|
||||
['to_uid','=',$user_id],
|
||||
|
||||
['type','=',4],
|
||||
|
||||
['sign','=','praise'],
|
||||
|
||||
['uniacid','=',$uniacid]
|
||||
];
|
||||
|
||||
//如果选了时间
|
||||
if(!empty($start_time)||!empty($end_time)){
|
||||
|
||||
$where4[] = ['create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//新增浏览量
|
||||
$data = $card_count->getCount($where4);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:保存数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function saveCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
//雷达模型
|
||||
$card_count = new CardCount();
|
||||
|
||||
$where6[] = [
|
||||
|
||||
['to_uid','=',$user_id],
|
||||
|
||||
['type','=',1],
|
||||
|
||||
['sign','=','copy'],
|
||||
|
||||
['uniacid','=',$uniacid]
|
||||
];
|
||||
//如果选了时间
|
||||
if(!empty($start_time)||!empty($end_time)){
|
||||
|
||||
$where6[] = ['create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//保存
|
||||
$data = $card_count->getCount($where6);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param $start_time
|
||||
* @param $end_time
|
||||
* @功能说明:点赞数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-14 16:14
|
||||
*/
|
||||
public function dzCount($user_id,$uniacid,$start_time='',$end_time=''){
|
||||
//雷达模型
|
||||
$card_count = new CardCount();
|
||||
|
||||
$where5[] = [
|
||||
|
||||
['to_uid','=',$user_id],
|
||||
|
||||
['type','=',3],
|
||||
|
||||
['sign','=','praise'],
|
||||
|
||||
['uniacid','=',$uniacid]
|
||||
];
|
||||
//如果选了时间
|
||||
if(!empty($start_time)&&!empty($end_time)){
|
||||
|
||||
$where5[] = ['create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//点赞
|
||||
$data = $card_count->getCount($where5);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
17
app/card/model/UserFollow.php
Executable file
17
app/card/model/UserFollow.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
|
||||
|
||||
class UserFollow extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_follow';
|
||||
public function getCount($where){
|
||||
$data = $this->where($where)->count();
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
49
app/card/model/UserInfo.php
Executable file
49
app/card/model/UserInfo.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class UserInfo extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_info';
|
||||
|
||||
public function createUser($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function updateUser($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function cardList ()
|
||||
{
|
||||
$data = $this->where(['fans_id' => 1])->find();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getUserPhone($user_id ,$uniacid = null)
|
||||
{
|
||||
$filter = ['fans_id' => $user_id];
|
||||
if(!empty($uniacid)) $filter['uniacid'] = $uniacid;
|
||||
$result = $this->where($filter)->field('phone,wechat')->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getStaffMaxAutoCount($filter)
|
||||
{
|
||||
$filter['is_staff'] = 1;
|
||||
$filter['is_default'] = 1;
|
||||
$count = $this->where($filter)->min('auto_count');
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
43
app/card/model/UserMark.php
Executable file
43
app/card/model/UserMark.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardStatistics;
|
||||
|
||||
|
||||
class UserMark extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_mark';
|
||||
public function getCount($where3){
|
||||
return $this->where($where3)->count();
|
||||
}
|
||||
public function getCountlist($where){
|
||||
$data = $this
|
||||
->field('staff_id as user_id,count(staff_id) as number,uniacid')
|
||||
->whereDay('create_time','yesterday')
|
||||
->group('staff_id')
|
||||
->where($where)->select()->toArray();
|
||||
if($data){
|
||||
foreach ($data as $key=>$val){
|
||||
$data[$key]['table'] = 'mark';
|
||||
$data[$key]['create_time'] = strtotime("-1 day");
|
||||
}
|
||||
$stat = new CardStatistics();
|
||||
$stat->createRows($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
//跟进状态
|
||||
public function getMarkStatus($where){
|
||||
$mark = $this->where($where)->value('mark');
|
||||
if($mark ==2){
|
||||
$mark ='已成交';
|
||||
}elseif ($mark ==1){
|
||||
$mark ='跟进中';
|
||||
}else{
|
||||
$mark ='还未跟进';
|
||||
}
|
||||
return $mark;
|
||||
}
|
||||
}
|
||||
21
app/card/model/UserPhone.php
Executable file
21
app/card/model/UserPhone.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
|
||||
|
||||
class UserPhone extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_phone';
|
||||
|
||||
public function getUserPhone($user_id ,$uniacid = null)
|
||||
{
|
||||
$filter = ['user_id' => $user_id];
|
||||
if(!empty($uniacid)) $filter['uniacid'] = $uniacid;
|
||||
$result = $this->where($filter)->field('phone')->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
19
app/card/model/UserSk.php
Executable file
19
app/card/model/UserSk.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace app\card\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
|
||||
|
||||
class UserSk extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_user_sk';
|
||||
|
||||
public function getSk($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
215
app/card/route/route.php
Executable file
215
app/card/route/route.php
Executable file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
use think\facade\Route;
|
||||
/**
|
||||
* @model card
|
||||
* @author yangqi
|
||||
* @create time 2019年11月25日23:09:59
|
||||
*
|
||||
*/
|
||||
Route::group('admin' ,function(){
|
||||
//获取微擎版权接口
|
||||
Route::get('getW7Tmp' ,'admin/getW7Tmp');
|
||||
//后台概览
|
||||
Route::get('overview', 'admin/overview');
|
||||
//工具中心
|
||||
Route::get('tool', 'admin/toolCenter');
|
||||
//公司列表
|
||||
Route::get('company', 'admin/companyList');
|
||||
//下架 / 上架 / 删除公司
|
||||
Route::post('updateCompany', 'admin/updateCompanyStatus');
|
||||
//编辑 / 新增公司
|
||||
Route::post('editCompany', 'admin/editCompany');
|
||||
//后台公司信息
|
||||
Route::get('companyInfo', 'admin/companyInfo');
|
||||
//新增 / 编辑 部门信息
|
||||
Route::post('editDepartment', 'admin/editDepartment');
|
||||
//职位列表
|
||||
Route::get('positionList', 'admin/position');
|
||||
//下架 / 上架 / 删除职位
|
||||
Route::post('updatePosition', 'admin/updatePositionStatus');
|
||||
//编辑职位
|
||||
Route::post('editPosition', 'admin/editPosition');
|
||||
//员工列表
|
||||
Route::get('staffs', 'admin/staffs');
|
||||
//用户列表
|
||||
Route::get('cardExcel', 'admin/cardExcel');
|
||||
|
||||
Route::get('users', 'admin/users');
|
||||
//取消员工 名片 / boss / 推荐
|
||||
Route::post('cancelStaff', 'admin/cancelStaff');
|
||||
//设置员工 名片 / boss / 推荐
|
||||
Route::post('setStaff', 'admin/setStaff');
|
||||
//编辑员工名片回显数据
|
||||
Route::get('staffInfo', 'admin/staffInfo');
|
||||
//编辑员工名片
|
||||
Route::post('editStaff', 'admin/editStaff');
|
||||
//分配BOSS权限回显数据
|
||||
Route::get('authBossInfo', 'admin/authBossInfo');
|
||||
//分配BOSS权限
|
||||
Route::post('editAuthBoss', 'admin/editAuthBoss');
|
||||
//重新生成员工小程序码
|
||||
Route::post('reCreateStaffQr', 'admin/createStaffQr');
|
||||
//印象标签列表
|
||||
Route::get('tags', 'admin/tags');
|
||||
//下架 / 上架 / 印象标签
|
||||
Route::post('updateTag', 'admin/updateTagStatus');
|
||||
//新增 / 编辑标签
|
||||
Route::post('editTag', 'admin/editTag');
|
||||
//免审口令
|
||||
Route::post('getAuthCode', 'admin/authCode');
|
||||
//手机创建设置
|
||||
Route::post('getPhoneCreate', 'admin/phoneCreate');
|
||||
//音频视频设置
|
||||
Route::post('getDefaultMedia', 'admin/defaultMedia');
|
||||
//默认配置
|
||||
Route::post('defaultSetting', 'admin/defaultSetting');
|
||||
//返回json
|
||||
Route::post('returnJson', 'admin/returnJson');
|
||||
//名片设置
|
||||
Route::post('getCardSetting', 'admin/cardSetting');
|
||||
|
||||
Route::post('websitebind', 'admin/websitebind');
|
||||
Route::get('getPluginAuth', 'admin/getPluginAuth');
|
||||
//获取展示模块
|
||||
Route::get('getPermission', 'admin/getPermissionV2');
|
||||
Route::get('getPermissionV2', 'admin/getPermissionV2');
|
||||
|
||||
Route::get('returnAdmin', 'admin/admin');
|
||||
});
|
||||
Route::get('getPermission', 'admin/getPermissionV2');
|
||||
//小程序接口
|
||||
Route::group('app' ,function(){
|
||||
//用户在小程序授权之后跟新信息
|
||||
Route::any('clearCache', 'index/clearCacheData');
|
||||
//用户在小程序授权之后跟新信息
|
||||
Route::post('updateWechat', 'index/updateWechatInfo');
|
||||
//用户信息
|
||||
Route::get('info', 'index/userInfo');
|
||||
//名片列表
|
||||
Route::get('center', 'index/userCenter');
|
||||
//收藏名片
|
||||
Route::post('collection', 'index/collectionCard');
|
||||
//取消收藏
|
||||
Route::post('uncollection', 'index/unCollectionCard');
|
||||
//小程序配置
|
||||
Route::get('config', 'IndexV2/config');
|
||||
|
||||
Route::get('configV2', 'IndexV2/configV2');
|
||||
//小程序允许使用的名片样式
|
||||
Route::get('cardTypes', 'index/cardType');
|
||||
//修改名片样式
|
||||
Route::post('editType', 'index/editCardType');
|
||||
//修改名片录音
|
||||
Route::post('editVoice', 'index/editCardVoice');
|
||||
//创建 / 编辑名片时回显数据
|
||||
Route::get('review', 'index/reviewData');
|
||||
//名片信息
|
||||
Route::get('cardInfo', 'index/cardInfo');
|
||||
//名片信息
|
||||
Route::get('cardInfoV2', 'index/cardInfoV2');
|
||||
|
||||
Route::get('cardInfoDiy', 'index/cardInfoV3');
|
||||
//名片信息(统计)
|
||||
Route::get('cardCount', 'index/getCardCount');
|
||||
//默认配置
|
||||
Route::get('defaultSetting', 'index/defaultSetting');
|
||||
//编辑自我描述
|
||||
Route::post('editDesc', 'index/editDesc');
|
||||
//编辑名片图片展示
|
||||
Route::post('editImages', 'index/editImages');
|
||||
//创建 / 修改名片
|
||||
Route::post('create', 'index/createCard');
|
||||
//点赞 / 取消点赞 名片 / 语音
|
||||
Route::post('thumb', 'index/thumbStaff');
|
||||
//点赞 / 取消点赞 印象标签
|
||||
Route::post('thumbTag', 'index/thumbTag');
|
||||
//收集formId
|
||||
Route::post('reportFormId', 'index/getFormIdFromMini');
|
||||
//上报手机号
|
||||
Route::post('reportPhone', 'index/reportPhone');
|
||||
//百度上报手机号
|
||||
Route::post('baiduReportPhone', 'index/baiduReportPhone');
|
||||
//编辑标签回显数据
|
||||
Route::get('reviewTags', 'index/reviewTags');
|
||||
//编辑标签
|
||||
Route::post('editTags', 'index/editTags');
|
||||
//获取微信小程序码
|
||||
Route::post('getWxCode', 'index/getWxCode');
|
||||
//获取微信小程序码信息
|
||||
Route::get('getWxCodeData', 'index/getWxCodeData');
|
||||
//剩余通知条数
|
||||
Route::get('formIds', 'Index/formIds');
|
||||
//删除名片录音功能接口
|
||||
Route::get('clearCardInfoVoice', 'Index/clearCardInfoVoice');
|
||||
//生成
|
||||
Route::post('getQr', 'Index/getQr');
|
||||
//获取套餐是否过期
|
||||
Route::get('authStatus' , 'Index/authStatus');
|
||||
//名片首页diy
|
||||
Route::get('cardInfoDiy' , 'Index/cardInfoV3');
|
||||
});
|
||||
|
||||
|
||||
//=====================================兼容老的小程序接口=====================================
|
||||
|
||||
|
||||
//将线上图片转为本地图片用于前端cavans画图
|
||||
Route::get('getImage', 'GetImage/getImage');
|
||||
|
||||
Route::group('' ,function(){
|
||||
//用户在小程序授权之后跟新信息
|
||||
Route::any('clearCache', 'index/clearCacheData');
|
||||
//用户在小程序授权之后跟新信息
|
||||
Route::post('updateWechat', 'index/updateWechatInfo');
|
||||
//用户信息
|
||||
Route::get('info', 'index/userInfo');
|
||||
//名片列表
|
||||
Route::get('center', 'index/userCenter');
|
||||
//收藏名片
|
||||
Route::post('collection', 'index/collectionCard');
|
||||
//取消收藏
|
||||
Route::post('uncollection', 'index/unCollectionCard');
|
||||
//小程序配置
|
||||
Route::get('config', 'index/config');
|
||||
//小程序允许使用的名片样式
|
||||
Route::get('cardTypes', 'index/cardType');
|
||||
//修改名片样式
|
||||
Route::post('editType', 'index/editCardType');
|
||||
//修改名片录音
|
||||
Route::post('editVoice', 'index/editCardVoice');
|
||||
//创建 / 编辑名片时回显数据
|
||||
Route::get('review', 'index/reviewData');
|
||||
//名片信息
|
||||
Route::get('cardInfo', 'index/cardInfo');
|
||||
//名片信息
|
||||
Route::get('cardInfoV2', 'index/cardInfoV2');
|
||||
//名片信息(统计)
|
||||
Route::get('cardCount', 'index/getCardCount');
|
||||
//编辑自我描述
|
||||
Route::post('editDesc', 'index/editDesc');
|
||||
//编辑名片图片展示
|
||||
Route::post('editImages', 'index/editImages');
|
||||
//创建 / 修改名片
|
||||
Route::post('create', 'index/createCard');
|
||||
//点赞 / 取消点赞 名片 / 语音
|
||||
Route::post('thumb', 'index/thumbStaff');
|
||||
//点赞 / 取消点赞 印象标签
|
||||
Route::post('thumbTag', 'index/thumbTag');
|
||||
//收集formId
|
||||
Route::post('reportFormId', 'index/getFormIdFromMini');
|
||||
//上报手机号
|
||||
Route::post('reportPhone', 'index/reportPhone');
|
||||
//编辑标签回显数据
|
||||
Route::get('reviewTags', 'index/reviewTags');
|
||||
//编辑标签
|
||||
Route::post('editTags', 'index/editTags');
|
||||
//获取微信小程序码
|
||||
Route::post('getWxCode', 'index/getWxCode');
|
||||
//获取微信小程序码信息
|
||||
Route::get('getWxCodeData', 'index/getWxCodeData');
|
||||
//剩余通知条数
|
||||
Route::get('formIds', 'Index/formIds');
|
||||
//删除名片录音功能接口
|
||||
Route::get('clearCardInfoVoice', 'Index/clearCardInfoVoice');
|
||||
});
|
||||
|
||||
235
app/card/service/UserService.php
Executable file
235
app/card/service/UserService.php
Executable file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\card\service;
|
||||
|
||||
|
||||
use app\card\model\CardBoss;
|
||||
use app\card\model\Company;
|
||||
use app\card\model\User;
|
||||
use app\card\model\UserInfo;
|
||||
|
||||
class UserService
|
||||
{
|
||||
|
||||
private $_uniacid ;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化系统没有员工的情况
|
||||
*
|
||||
* @param $staff_id
|
||||
* @param $uniacid
|
||||
* @return bool
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/30 16:47
|
||||
*/
|
||||
public function initFirstUserToStaff($staff_id ,$uniacid){
|
||||
longbingGetCompanyConfig($uniacid);
|
||||
$count = User::where(['uniacid' => $uniacid ,'is_staff' => 1] )->count() ;
|
||||
$result = false ;
|
||||
if (!$count){
|
||||
$result = $this->addUserToStaff($staff_id , [] , $uniacid) ;
|
||||
}
|
||||
|
||||
return $result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户为模拟人员工说
|
||||
*
|
||||
* @param $staff_id
|
||||
* @param $companyIds
|
||||
* @param $uniacid
|
||||
* @return CardBoss|bool|\think\Model
|
||||
* @throws \Exception
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/30 16:50
|
||||
*/
|
||||
public function addUserToStaff($staff_id , $companyIds ,$uniacid){
|
||||
|
||||
$params = [ 'staff_id' => $staff_id , 'company_ids' => $companyIds];
|
||||
|
||||
$this->_uniacid = $uniacid ;
|
||||
|
||||
//检查数据是否存在
|
||||
if(!isset($params['staff_id']) || empty($params['staff_id'])) return lang('not staff');
|
||||
|
||||
$user = longbingGetUser($params[ 'staff_id' ] ,$this->_uniacid);
|
||||
//判断用户是否存在
|
||||
if(empty($user)) return lang('not user');
|
||||
//获取boss端权限
|
||||
$permissions = longbingGetPluginAuth($this->_uniacid);
|
||||
if(empty($user['is_staff']))
|
||||
{
|
||||
//获取名片总数
|
||||
if(!empty($permissions) && isset($permissions['card_number']) && !empty($permissions['card_number']))
|
||||
{
|
||||
if(!(longbingGetCardNum($this->_uniacid) < $permissions['card_number']))
|
||||
{
|
||||
return lang('not card num');
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = true;
|
||||
if(empty($permissions) || !isset($permissions['plugin']) || !isset($permissions['plugin']['boss']) || empty($permissions['plugin']['boss']))
|
||||
{
|
||||
$params['company_ids'] = [];
|
||||
//获取一个默认的公司id
|
||||
$company_model = new Company();
|
||||
$company = $company_model->getCompany(['uniacid' => $this->_uniacid ,'status' => 1] ,['id']);
|
||||
if(!empty($company)) $params['company_ids'][] = $company['id'];
|
||||
}else{
|
||||
if(!isset($params['company_ids']) || empty($params['company_ids'])) return lang('not company id');
|
||||
CardBoss::where( [ [ 'user_id', '=', $params[ 'staff_id' ] ] ] )
|
||||
->delete();
|
||||
|
||||
$boss = implode( ',', $params[ 'company_ids' ] );
|
||||
|
||||
$result = CardBoss::create( [ 'user_id' => $params[ 'staff_id' ], 'boss' => $boss, 'uniacid' => $this->_uniacid ] );
|
||||
}
|
||||
|
||||
if ( $result === false )
|
||||
{
|
||||
return 'edit failed' ;
|
||||
}else{
|
||||
$check = true;
|
||||
//判断用户是否是员工
|
||||
if(empty($user['is_staff'])){
|
||||
$user['is_staff'] = 1;
|
||||
longbingSetUser($params[ 'staff_id' ] ,$this->_uniacid ,$user);
|
||||
//更新数据
|
||||
$user_model = new User();
|
||||
$check = $user_model->updateUser(['id' => $params[ 'staff_id' ] ,'uniacid' => $this->_uniacid] ,['is_staff' => 1]);
|
||||
}
|
||||
if($check){
|
||||
//判断员工名片是否存在
|
||||
$staff = longbingGetUserInfo($params[ 'staff_id' ] ,$this->_uniacid);
|
||||
$staff_model = new UserInfo();
|
||||
$company_id = '';
|
||||
if(isset($params[ 'company_ids' ][0]) && !empty($params[ 'company_ids' ][0])) $company_id = $params[ 'company_ids' ][0];
|
||||
if(empty($staff))
|
||||
{
|
||||
$result = $staff_model->createUser(['fans_id' => $params[ 'staff_id' ] ,'uniacid' => $this->_uniacid ,'is_staff' => 1 ,'company_id' => $company_id ,'is_default' => 1]);
|
||||
longbingGetUserInfo($params[ 'staff_id' ] ,$this->_uniacid ,true);
|
||||
}
|
||||
if(!empty($staff))
|
||||
{
|
||||
$company_id = $staff['company_id'];
|
||||
if(isset($params[ 'company_ids' ]) && !empty($params[ 'company_ids' ]) && !in_array($staff['company_id'], $params[ 'company_ids' ])) $company_id = $params[ 'company_ids' ][0];
|
||||
$result = $staff_model->updateUser(['fans_id' => $params[ 'staff_id' ] ,'uniacid' => $this->_uniacid] ,['is_staff' => 1 , 'is_default' => 1 ,'company_id' => $company_id ]);
|
||||
$staff['is_staff'] = 1;
|
||||
$staff['is_default'] = 1;
|
||||
$staff['company_id'] = $company_id;
|
||||
longbingSetUserInfo($params[ 'staff_id' ] ,$this->_uniacid ,$staff);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推荐员工数量
|
||||
*
|
||||
* @param $uniacid
|
||||
* @return int
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 17:04
|
||||
*/
|
||||
public static function getDefaultStraffNumber($uniacid){
|
||||
|
||||
$count = User::alias( 'a' )
|
||||
->join( 'longbing_card_user_info b', 'b.fans_id = a.id' )
|
||||
->where('a.is_staff' , 1)
|
||||
->where('b.is_staff' , 1)
|
||||
->where('b.is_default' , 1)
|
||||
->where('a.uniacid',$uniacid)
|
||||
->where('b.uniacid',$uniacid)
|
||||
->count();
|
||||
|
||||
return $count ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成员工头像二维码
|
||||
*
|
||||
* @param $_uniacid
|
||||
* @param $params
|
||||
* @return array|bool|mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 21:15
|
||||
*/
|
||||
public static function createHeaderQr($_uniacid , $params){
|
||||
|
||||
$staff = longbingGetUserInfo($params['staff_id'] ,$_uniacid);
|
||||
|
||||
if(empty($staff) || empty($staff['is_staff'])) return lang('staff info not found');
|
||||
//生成数据
|
||||
$data = ["data" => ["staff_id" => $params['staff_id'] ,"pid" => $params['staff_id'] ,"type" => 4 ,"key" => 1]];
|
||||
//生成二维码
|
||||
$result = longbingCreateWxCode($_uniacid,$data);
|
||||
|
||||
if(isset($result['qr_path'])) $result = transImagesOne($result ,['qr_path'] ,$_uniacid);
|
||||
//获取名片设置
|
||||
$config = longbingGetAppConfig($_uniacid);
|
||||
//是否用头像替换二维码中心
|
||||
if(!empty($staff['avatar']) && !empty($result) && !empty($result['qr_path']) && !empty($result['path']) && isset($config['qr_avatar_switch']) && !empty($config['qr_avatar_switch']))
|
||||
{
|
||||
$staff = transImagesOne($staff ,['avatar'] ,$_uniacid);
|
||||
|
||||
$dat = longbingUpdateQrByAvatar($staff['avatar'] ,$result['qr_path'] , $_uniacid ,$result['path']);
|
||||
}
|
||||
//判断是否成功
|
||||
if(empty($result) || !isset($result['qr_path'])) return lang('create qr error');
|
||||
//改写数据
|
||||
User::update( [ 'qr_path' => $result['qr_path'] ], [ 'id' => $params[ 'staff_id' ] ] );
|
||||
//更新缓存
|
||||
longbingGetUser($params['staff_id'] , $_uniacid ,true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $_uniacid
|
||||
* @param $userId
|
||||
* @功能说明:获取用户最后访问名片的ID
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020/1/7 17:22
|
||||
*/
|
||||
public static function getLastStaffId($_uniacid,$userId){
|
||||
|
||||
$where[] = ['uniacid','=' , $_uniacid ];
|
||||
$where[] = ['id','=' , $userId ];
|
||||
$last_staff_id = User::where($where)->value('last_staff_id');
|
||||
|
||||
return $last_staff_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $_uniacid
|
||||
* @param $userId
|
||||
* @功能说明:删除用户缓存信息
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020/1/10 14:43
|
||||
*/
|
||||
public static function delUserInfoCache($_uniacid , $userId){
|
||||
$key = 'longbing_card_info_' . $userId;
|
||||
return delCache($key ,$_uniacid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user