初始化代码
This commit is contained in:
56
app/agent/model/AdminModel.php
Normal file
56
app/agent/model/AdminModel.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AdminModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_admin';
|
||||
|
||||
|
||||
public function appAdmin()
|
||||
{
|
||||
return $this->hasOne(AppAdminModel::class, 'admin_id', 'admin_id');
|
||||
}
|
||||
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->hasOne(AdminRoleModel::class, 'role_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function createAdmin($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
//修改
|
||||
public function updateAdmin($filter ,$data)
|
||||
{
|
||||
$filter['status'] = 1;
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
// var_dump($result);die;
|
||||
return !empty($result);
|
||||
}
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
public function getAdmin($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$filter['status'] = 1;
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
13
app/agent/model/AdminRoleModel.php
Normal file
13
app/agent/model/AdminRoleModel.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AdminRoleModel extends BaseModel {
|
||||
|
||||
protected $name = 'longbing_role';
|
||||
|
||||
}
|
||||
93
app/agent/model/AgentLevel.php
Normal file
93
app/agent/model/AgentLevel.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentLevel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_card_agent_level';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:54
|
||||
* @功能说明:代理等级列表
|
||||
*/
|
||||
public function levelList($dis,$page=10){
|
||||
|
||||
$list = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:55
|
||||
* @功能说明:添加代理商等级
|
||||
*/
|
||||
public function levelAdd($data){
|
||||
//创建时间
|
||||
$data['create_time'] = time();
|
||||
//更新时间
|
||||
$data['update_time'] = time();
|
||||
//状态
|
||||
$data['status'] = 1;
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:57
|
||||
* @功能说明:代理商等级编辑
|
||||
*/
|
||||
public function levelUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:34
|
||||
* @功能说明:代理商等级详情
|
||||
*/
|
||||
public function levelInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-26 13:28
|
||||
* @功能说明:代理商选择框
|
||||
*/
|
||||
public function levelSelect($dis){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->select();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
152
app/agent/model/AgentList.php
Normal file
152
app/agent/model/AgentList.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentList extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_card_agent_list';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'status_text',
|
||||
|
||||
'have_count',
|
||||
|
||||
'level_title'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:代理商等级名字
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-26 14:07
|
||||
*/
|
||||
public function getLevelTitleAttr($value,$data){
|
||||
|
||||
if(!empty($data['level'])){
|
||||
|
||||
$level_model = new AgentLevel();
|
||||
|
||||
$dis[] = ['id','=',$data['level']];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
return $level_model->where($dis)->value('title');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:54
|
||||
* @功能说明:获取状态
|
||||
*/
|
||||
public function getStatusTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['over_time'])){
|
||||
|
||||
switch ($data['over_time']){
|
||||
|
||||
case $data['over_time']>time():
|
||||
|
||||
return '使用中';
|
||||
|
||||
break;
|
||||
case $data['over_time']<time():
|
||||
|
||||
return '已过期';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 14:04
|
||||
* @功能说明:获取已经安装的数量
|
||||
*/
|
||||
public function getHaveCountAttr($value,$data){
|
||||
|
||||
$num = Db::name('longbing_cardauth2_config')->where(['agent_id'=>$data['id']])->count();
|
||||
|
||||
return $num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:54
|
||||
* @功能说明:代理商列表
|
||||
*/
|
||||
public function agentList($dis,$page=10){
|
||||
|
||||
$list = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:55
|
||||
* @功能说明:添加代理商
|
||||
*/
|
||||
public function agentAdd($data){
|
||||
//创建时间
|
||||
$data['create_time'] = time();
|
||||
//更新时间
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:57
|
||||
* @功能说明:代理商编辑
|
||||
*/
|
||||
public function agentUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:34
|
||||
* @功能说明:代理商详情
|
||||
*/
|
||||
public function agentInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
app/agent/model/AppAdminModel.php
Normal file
13
app/agent/model/AppAdminModel.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AppAdminModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_app_admin';
|
||||
|
||||
}
|
||||
14
app/agent/model/Cardauth2ActivityModel.php
Normal file
14
app/agent/model/Cardauth2ActivityModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2ActivityModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_activity';
|
||||
|
||||
|
||||
}
|
||||
19
app/agent/model/Cardauth2ArticleModel.php
Normal file
19
app/agent/model/Cardauth2ArticleModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardConfig;
|
||||
|
||||
class Cardauth2ArticleModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_article';
|
||||
|
||||
public function cardConfig()
|
||||
{
|
||||
return $this->hasOne(CardConfig::class, 'uniacid', 'modular_id');
|
||||
}
|
||||
|
||||
}
|
||||
53
app/agent/model/Cardauth2AuthAppModel.php
Normal file
53
app/agent/model/Cardauth2AuthAppModel.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\agent\model\Cardauth2AuthAppModel as Cardauth2Model;
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2AuthAppModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_auth_app';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-04 17:53
|
||||
* @功能说明:获取插件使用数量
|
||||
*/
|
||||
public static function getUseNum($app_name,$is_weiqin){
|
||||
|
||||
|
||||
if($is_weiqin){
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$count = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
|
||||
->where([['a.status', '=', 1],['app_name','like',"%".$app_name ."%"] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"] ])
|
||||
->group('a.id')
|
||||
->sum('count');
|
||||
|
||||
}else{
|
||||
|
||||
$count = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1],['app_name','=',$app_name]])
|
||||
->group('a.id')
|
||||
->sum('count');
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
14
app/agent/model/Cardauth2BossModel.php
Normal file
14
app/agent/model/Cardauth2BossModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2BossModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_boss';
|
||||
|
||||
|
||||
}
|
||||
18
app/agent/model/Cardauth2ConfigModel.php
Normal file
18
app/agent/model/Cardauth2ConfigModel.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardConfig;
|
||||
|
||||
class Cardauth2ConfigModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_config';
|
||||
|
||||
public function cardConfig()
|
||||
{
|
||||
return $this->hasOne(CardConfig::class, 'uniacid', 'modular_id');
|
||||
}
|
||||
}
|
||||
13
app/agent/model/Cardauth2CopyrightModel.php
Normal file
13
app/agent/model/Cardauth2CopyrightModel.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2CopyrightModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_copyright';
|
||||
|
||||
}
|
||||
68
app/agent/model/Cardauth2DefaultModel.php
Normal file
68
app/agent/model/Cardauth2DefaultModel.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
use think\facade\Env;
|
||||
|
||||
class Cardauth2DefaultModel extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = 'longbing_cardauth2_default';
|
||||
public function getinfo(){
|
||||
$data = $this->order('id','desc')->select()->toArray();
|
||||
if($data){
|
||||
$data = $data[0];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function is_table(){
|
||||
$prefix = config('database.connections.mysql.prefix');
|
||||
$table = $prefix.$this->name;
|
||||
$res = Db::query('SHOW TABLES LIKE '."'".$table."'");
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得配置值
|
||||
*
|
||||
* @param string|\think\model\concern\string $key
|
||||
* @return int|mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:51
|
||||
*/
|
||||
public function getDefaultValue($key ,$defualt = -1 ){
|
||||
|
||||
$defaultConfig = $this->getinfo();
|
||||
$number = isset($defaultConfig[$key]) ? $defaultConfig[$key] : $defualt ;
|
||||
return $number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得名片数量默认配置
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:51
|
||||
*/
|
||||
public function getCardNumber(){
|
||||
|
||||
return $this->getDefaultValue('card_number');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信群发默认配置
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:53
|
||||
*/
|
||||
public function getSendMsg(){
|
||||
return $this->getDefaultValue('send_switch' , 0 );
|
||||
}
|
||||
}
|
||||
14
app/agent/model/Cardauth2HouseModel.php
Normal file
14
app/agent/model/Cardauth2HouseModel.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2HouseModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_house';
|
||||
|
||||
|
||||
}
|
||||
30
app/agent/model/LongbingPlugeKey.php
Normal file
30
app/agent/model/LongbingPlugeKey.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?PHP
|
||||
|
||||
namespace app\agent\model;
|
||||
use app\BaseModel;
|
||||
|
||||
Class LongbingPlugeKey extends BaseModel
|
||||
{
|
||||
protected $name = 'lb_pluge_key';
|
||||
|
||||
public function getPlugeKey($filter = [])
|
||||
{
|
||||
$result = $this;
|
||||
if(!empty($filter)) $result = $result->where($filter);
|
||||
$result = $result->limit(1)->select();
|
||||
if(!empty($result))
|
||||
{
|
||||
$result = $result->toArray();
|
||||
if(isset($result[0])) $result = $result[0];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updatePlugeKey($filter ,$data = [])
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
}
|
||||
109
app/agent/model/OssConfig.php
Normal file
109
app/agent/model/OssConfig.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class OssConfig extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_oos_config';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 09:53
|
||||
* @功能说明:添加配置
|
||||
*/
|
||||
public function configAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['is_sync'] = 1;
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:02
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function configUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:04
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function configList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:15
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function configInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @功能说明:删除
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:18
|
||||
*/
|
||||
public function configDel($dis){
|
||||
|
||||
$config_dis = [
|
||||
|
||||
'upload_setting' => $dis['id']
|
||||
|
||||
];
|
||||
|
||||
$info = Db::name('longbing_cardauth2_config')->where($config_dis)->find();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->delete();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user