存客宝应用接口初始化
This commit is contained in:
11
application/cunkebao/model/AiKnowledgeBase.php
Normal file
11
application/cunkebao/model/AiKnowledgeBase.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class AiKnowledgeBase extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'ai_knowledge_base';
|
||||
}
|
||||
11
application/cunkebao/model/AiKnowledgeBaseType.php
Normal file
11
application/cunkebao/model/AiKnowledgeBaseType.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class AiKnowledgeBaseType extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'ai_knowledge_base_type';
|
||||
}
|
||||
60
application/cunkebao/model/BaseModel.php
Normal file
60
application/cunkebao/model/BaseModel.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
// 数据插入 duplicate
|
||||
public function insertAllDuplicate($data, $duplicate = null, $limit = null)
|
||||
{
|
||||
if (!empty($duplicate)) {
|
||||
if (is_array($duplicate)) {
|
||||
$temp = [];
|
||||
foreach ($duplicate as $key => $item) {
|
||||
if (is_integer($key)) {
|
||||
$temp[] = "{$item} = VALUES({$item})";
|
||||
} else {
|
||||
$temp[] = "{$key} = {$item}";
|
||||
}
|
||||
}
|
||||
$duplicate = implode(',', $temp);
|
||||
}
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
// 分批写入 自动启动事务支持
|
||||
$this->startTrans();
|
||||
|
||||
try {
|
||||
// array_chunk 函数把数组分割为新的数组块。
|
||||
//其中每个数组的单元数目由 size 参数决定。最后一个数组的单元数目可能会少几个。
|
||||
//可选参数 preserve_key 是一个布尔值,它指定新数组的元素是否有和原数组相同的键(用于关联数组),还是从 0 开始的新数字键(用于索引数组)。默认是分配新的键。
|
||||
$array = array_chunk($data, $limit, true);
|
||||
$count = 0;
|
||||
|
||||
foreach ($array as $item) {
|
||||
$sql = $this->fetchSql(true)->insertAll($item);
|
||||
$sql = preg_replace("/INSERT\s*INTO\s*/", "INSERT IGNORE INTO ", $sql);
|
||||
if (is_string($duplicate)) {
|
||||
$sql = $sql . ' ON DUPLICATE KEY UPDATE ' . $duplicate;
|
||||
}
|
||||
$count += $this->execute($sql); // 获取影响函数
|
||||
}
|
||||
// 提交事务
|
||||
$this->commit();
|
||||
} catch (\Exception $e) {
|
||||
$this->rollback();
|
||||
throw $e;
|
||||
}
|
||||
return $count;
|
||||
} else {
|
||||
$sql = $this->fetchSql(true)->insertAll($data);
|
||||
$sql = preg_replace("/INSERT\s*INTO\s*/", "INSERT IGNORE INTO ", $sql);
|
||||
if (is_string($duplicate)) {
|
||||
$sql = $sql . ' ON DUPLICATE KEY UPDATE ' . $duplicate;
|
||||
}
|
||||
return $this->execute($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
application/cunkebao/model/ContentItem.php
Normal file
20
application/cunkebao/model/ContentItem.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ContentItem extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'content_item';
|
||||
|
||||
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
|
||||
}
|
||||
38
application/cunkebao/model/ContentLibrary.php
Normal file
38
application/cunkebao/model/ContentLibrary.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ContentLibrary extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'content_library';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的用户
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User', 'userId', 'id');
|
||||
}
|
||||
|
||||
// 定义关联的内容项目
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('ContentItem', 'libraryId', 'id');
|
||||
}
|
||||
|
||||
// 根据ID数组获取内容库列表
|
||||
public static function getByIds($ids)
|
||||
{
|
||||
if (empty($ids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return self::where('id', 'in', $ids)->select();
|
||||
}
|
||||
}
|
||||
87
application/cunkebao/model/DistributionChannel.php
Normal file
87
application/cunkebao/model/DistributionChannel.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use app\cunkebao\model\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 分销渠道模型
|
||||
*/
|
||||
class DistributionChannel extends BaseModel
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'distribution_channel';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
protected $deleteTime = 'deleteTime';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
// 类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'companyId' => 'integer',
|
||||
'totalCustomers' => 'integer',
|
||||
'todayCustomers' => 'integer',
|
||||
'totalFriends' => 'integer',
|
||||
'todayFriends' => 'integer',
|
||||
'withdrawableAmount' => 'integer',
|
||||
'createTime' => 'timestamp',
|
||||
'updateTime' => 'timestamp',
|
||||
'deleteTime' => 'timestamp',
|
||||
];
|
||||
|
||||
/**
|
||||
* 生成渠道编码
|
||||
* 格式:QD + 时间戳 + 9位随机字符串
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateChannelCode()
|
||||
{
|
||||
$prefix = 'QD';
|
||||
$timestamp = time();
|
||||
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$randomStr = '';
|
||||
|
||||
// 生成9位随机字符串
|
||||
for ($i = 0; $i < 9; $i++) {
|
||||
$randomStr .= $chars[mt_rand(0, strlen($chars) - 1)];
|
||||
}
|
||||
|
||||
$code = $prefix . $timestamp . $randomStr;
|
||||
|
||||
// 检查是否已存在
|
||||
$exists = self::where('code', $code)->find();
|
||||
if ($exists) {
|
||||
// 如果已存在,递归重新生成
|
||||
return self::generateChannelCode();
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类型:manual(手动创建)
|
||||
*/
|
||||
const CREATE_TYPE_MANUAL = 'manual';
|
||||
|
||||
/**
|
||||
* 创建类型:auto(扫码创建)
|
||||
*/
|
||||
const CREATE_TYPE_AUTO = 'auto';
|
||||
|
||||
/**
|
||||
* 状态:enabled(启用)
|
||||
*/
|
||||
const STATUS_ENABLED = 'enabled';
|
||||
|
||||
/**
|
||||
* 状态:disabled(禁用)
|
||||
*/
|
||||
const STATUS_DISABLED = 'disabled';
|
||||
}
|
||||
|
||||
71
application/cunkebao/model/DistributionWithdrawal.php
Normal file
71
application/cunkebao/model/DistributionWithdrawal.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use app\cunkebao\model\BaseModel;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 分销渠道提现申请模型
|
||||
*/
|
||||
class DistributionWithdrawal extends BaseModel
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'distribution_withdrawal';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'companyId' => 'integer',
|
||||
'channelId' => 'integer',
|
||||
'amount' => 'integer',
|
||||
'reviewTime' => 'timestamp',
|
||||
'applyTime' => 'timestamp',
|
||||
'createTime' => 'timestamp',
|
||||
'updateTime' => 'timestamp',
|
||||
];
|
||||
|
||||
/**
|
||||
* 状态:pending(待审核)
|
||||
*/
|
||||
const STATUS_PENDING = 'pending';
|
||||
|
||||
/**
|
||||
* 状态:approved(已通过)
|
||||
*/
|
||||
const STATUS_APPROVED = 'approved';
|
||||
|
||||
/**
|
||||
* 状态:rejected(已拒绝)
|
||||
*/
|
||||
const STATUS_REJECTED = 'rejected';
|
||||
|
||||
/**
|
||||
* 状态:paid(已打款)
|
||||
*/
|
||||
const STATUS_PAID = 'paid';
|
||||
|
||||
/**
|
||||
* 支付类型:wechat(微信)
|
||||
*/
|
||||
const PAY_TYPE_WECHAT = 'wechat';
|
||||
|
||||
/**
|
||||
* 支付类型:alipay(支付宝)
|
||||
*/
|
||||
const PAY_TYPE_ALIPAY = 'alipay';
|
||||
|
||||
/**
|
||||
* 支付类型:bankcard(银行卡)
|
||||
*/
|
||||
const PAY_TYPE_BANKCARD = 'bankcard';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
286
application/cunkebao/model/FriendTask.php
Normal file
286
application/cunkebao/model/FriendTask.php
Normal file
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 添加好友任务记录模型
|
||||
*/
|
||||
class FriendTask extends Model
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'tk_friend_task';
|
||||
|
||||
/**
|
||||
* 状态常量
|
||||
*/
|
||||
const STATUS_PENDING = 1; // 待处理
|
||||
const STATUS_PROCESSING = 2; // 处理中
|
||||
const STATUS_APPROVED = 3; // 已通过
|
||||
const STATUS_REJECTED = 4; // 已拒绝
|
||||
const STATUS_EXPIRED = 5; // 已过期
|
||||
const STATUS_CANCELLED = 6; // 已取消
|
||||
|
||||
/**
|
||||
* 获取状态文本
|
||||
* @param int $status 状态码
|
||||
* @return string 状态文本
|
||||
*/
|
||||
public static function getStatusText($status)
|
||||
{
|
||||
$statusMap = [
|
||||
self::STATUS_PENDING => '待处理',
|
||||
self::STATUS_PROCESSING => '处理中',
|
||||
self::STATUS_APPROVED => '已通过',
|
||||
self::STATUS_REJECTED => '已拒绝',
|
||||
self::STATUS_EXPIRED => '已过期',
|
||||
self::STATUS_CANCELLED => '已取消'
|
||||
];
|
||||
|
||||
return isset($statusMap[$status]) ? $statusMap[$status] : '未知状态';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取好友任务列表
|
||||
* @param array $where 查询条件
|
||||
* @param string $order 排序条件
|
||||
* @param int $page 页码
|
||||
* @param int $limit 每页数量
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public static function getTaskList($where = [], $order = 'createTime desc', $page = 1, $limit = 10)
|
||||
{
|
||||
return self::where($where)
|
||||
->order($order)
|
||||
->paginate($limit, false, ['page' => $page]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务详情
|
||||
* @param int $id 任务ID
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getTaskDetail($id)
|
||||
{
|
||||
return self::where('id', $id)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建好友任务
|
||||
* @param array $data 任务数据
|
||||
* @return int|bool 任务ID或false
|
||||
*/
|
||||
public static function createTask($data)
|
||||
{
|
||||
// 确保必填字段存在
|
||||
if (!isset($data['id'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
if (!isset($data['status'])) {
|
||||
$data['status'] = self::STATUS_PENDING;
|
||||
}
|
||||
|
||||
// 设置创建时间
|
||||
$data['createTime'] = time();
|
||||
$data['updateTime'] = time();
|
||||
|
||||
// 创建任务
|
||||
$task = new self;
|
||||
$task->allowField(true)->save($data);
|
||||
|
||||
return $task->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务信息
|
||||
* @param int $id 任务ID
|
||||
* @param array $data 更新数据
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateTask($id, $data)
|
||||
{
|
||||
// 更新时间
|
||||
$data['updateTime'] = time();
|
||||
|
||||
return self::where('id', $id)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
* @param int $id 任务ID
|
||||
* @param int $status 新状态
|
||||
* @param string $remark 备注
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateTaskStatus($id, $status, $remark = '')
|
||||
{
|
||||
$data = [
|
||||
'status' => $status,
|
||||
'updateTime' => time()
|
||||
];
|
||||
|
||||
if (!empty($remark)) {
|
||||
$data['remark'] = $remark;
|
||||
}
|
||||
|
||||
return self::where('id', $id)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
* @param int $id 任务ID
|
||||
* @param string $remark 取消原因
|
||||
* @return bool
|
||||
*/
|
||||
public static function cancelTask($id, $remark = '')
|
||||
{
|
||||
return self::updateTaskStatus($id, self::STATUS_CANCELLED, $remark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务审批通过
|
||||
* @param int $id 任务ID
|
||||
* @param string $remark 备注信息
|
||||
* @return bool
|
||||
*/
|
||||
public static function approveTask($id, $remark = '')
|
||||
{
|
||||
return self::updateTaskStatus($id, self::STATUS_APPROVED, $remark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务拒绝
|
||||
* @param int $id 任务ID
|
||||
* @param string $remark 拒绝原因
|
||||
* @return bool
|
||||
*/
|
||||
public static function rejectTask($id, $remark = '')
|
||||
{
|
||||
return self::updateTaskStatus($id, self::STATUS_REJECTED, $remark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据微信账号ID获取任务列表
|
||||
* @param int $wechatAccountId 微信账号ID
|
||||
* @param array $status 状态数组,默认查询所有状态
|
||||
* @param int $page 页码
|
||||
* @param int $limit 每页数量
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public static function getTasksByWechatAccount($wechatAccountId, $status = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$where = ['wechatAccountId' => $wechatAccountId];
|
||||
|
||||
if (!empty($status)) {
|
||||
$where['status'] = ['in', $status];
|
||||
}
|
||||
|
||||
return self::getTaskList($where, 'createTime desc', $page, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据操作账号ID获取任务列表
|
||||
* @param int $operatorAccountId 操作账号ID
|
||||
* @param array $status 状态数组,默认查询所有状态
|
||||
* @param int $page 页码
|
||||
* @param int $limit 每页数量
|
||||
* @return \think\Paginator
|
||||
*/
|
||||
public static function getTasksByOperator($operatorAccountId, $status = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$where = ['operatorAccountId' => $operatorAccountId];
|
||||
|
||||
if (!empty($status)) {
|
||||
$where['status'] = ['in', $status];
|
||||
}
|
||||
|
||||
return self::getTaskList($where, 'createTime desc', $page, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号/微信号查询任务
|
||||
* @param string $phone 手机号/微信号
|
||||
* @param int $tenantId 租户ID
|
||||
* @return array
|
||||
*/
|
||||
public static function getTasksByPhone($phone, $tenantId = null)
|
||||
{
|
||||
$where = ['phone' => $phone];
|
||||
|
||||
if ($tenantId !== null) {
|
||||
$where['tenantId'] = $tenantId;
|
||||
}
|
||||
|
||||
return self::where($where)->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计数据
|
||||
* @param int $tenantId 租户ID
|
||||
* @param int $timeRange 时间范围(秒)
|
||||
* @return array
|
||||
*/
|
||||
public static function getTaskStats($tenantId = null, $timeRange = 86400)
|
||||
{
|
||||
$where = [];
|
||||
|
||||
if ($tenantId !== null) {
|
||||
$where['tenantId'] = $tenantId;
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
$startTime = time() - $timeRange;
|
||||
$where['createTime'] = ['>=', $startTime];
|
||||
|
||||
// 获取各状态的任务数量
|
||||
$stats = [
|
||||
'total' => self::where($where)->count(),
|
||||
'pending' => self::where(array_merge($where, ['status' => self::STATUS_PENDING]))->count(),
|
||||
'processing' => self::where(array_merge($where, ['status' => self::STATUS_PROCESSING]))->count(),
|
||||
'approved' => self::where(array_merge($where, ['status' => self::STATUS_APPROVED]))->count(),
|
||||
'rejected' => self::where(array_merge($where, ['status' => self::STATUS_REJECTED]))->count(),
|
||||
'expired' => self::where(array_merge($where, ['status' => self::STATUS_EXPIRED]))->count(),
|
||||
'cancelled' => self::where(array_merge($where, ['status' => self::STATUS_CANCELLED]))->count()
|
||||
];
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务处理结果统计
|
||||
* @param int $tenantId 租户ID
|
||||
* @param int $timeRange 时间范围(秒)
|
||||
* @return array
|
||||
*/
|
||||
public static function getTaskResultStats($tenantId = null, $timeRange = 86400 * 30)
|
||||
{
|
||||
$where = [];
|
||||
|
||||
if ($tenantId !== null) {
|
||||
$where['tenantId'] = $tenantId;
|
||||
}
|
||||
|
||||
// 时间范围
|
||||
$startTime = time() - $timeRange;
|
||||
$where['createTime'] = ['>=', $startTime];
|
||||
|
||||
// 获取处理结果数据
|
||||
$stats = [
|
||||
'total' => self::where($where)->count(),
|
||||
'approved' => self::where(array_merge($where, ['status' => self::STATUS_APPROVED]))->count(),
|
||||
'rejected' => self::where(array_merge($where, ['status' => self::STATUS_REJECTED]))->count(),
|
||||
'pending' => self::where(array_merge($where, ['status' => ['in', [self::STATUS_PENDING, self::STATUS_PROCESSING]]]))->count(),
|
||||
'other' => self::where(array_merge($where, ['status' => ['in', [self::STATUS_EXPIRED, self::STATUS_CANCELLED]]]))->count()
|
||||
];
|
||||
|
||||
// 计算成功率
|
||||
$stats['approvalRate'] = $stats['total'] > 0 ? round($stats['approved'] / $stats['total'] * 100, 2) : 0;
|
||||
|
||||
return $stats;
|
||||
}
|
||||
}
|
||||
13
application/cunkebao/model/PlanTask.php
Normal file
13
application/cunkebao/model/PlanTask.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 获客计划任务模型
|
||||
*/
|
||||
class PlanTask extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'plan_task';
|
||||
}
|
||||
17
application/cunkebao/model/TokensPackage.php
Normal file
17
application/cunkebao/model/TokensPackage.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
class TokensPackage extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'tokens_package';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
|
||||
}
|
||||
25
application/cunkebao/model/User.php
Normal file
25
application/cunkebao/model/User.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 用户模型
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'users';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'id', 'userId');
|
||||
}
|
||||
}
|
||||
15
application/cunkebao/model/WechatChatroom.php
Normal file
15
application/cunkebao/model/WechatChatroom.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 微信好友模型类
|
||||
*/
|
||||
class WechatChatroom extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'wechat_group';
|
||||
|
||||
|
||||
}
|
||||
78
application/cunkebao/model/Workbench.php
Normal file
78
application/cunkebao/model/Workbench.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 工作台模型
|
||||
*/
|
||||
class Workbench extends Model
|
||||
{
|
||||
|
||||
protected $table = 'ck_workbench';
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
protected $dateFormat = 'Y-m-d H:i:s';
|
||||
|
||||
// 创建时间获取器
|
||||
public function getCreateTimeAttr($value)
|
||||
{
|
||||
return $value ? date('Y-m-d', is_numeric($value) ? $value : strtotime($value)) : '';
|
||||
}
|
||||
|
||||
// 更新时间获取器
|
||||
public function getUpdateTimeAttr($value)
|
||||
{
|
||||
return $value ? date('Y-m-d', is_numeric($value) ? $value : strtotime($value)) : '';
|
||||
}
|
||||
|
||||
// 自动点赞配置关联
|
||||
public function autoLike()
|
||||
{
|
||||
return $this->hasOne('WorkbenchAutoLike', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 朋友圈同步配置关联
|
||||
public function momentsSync()
|
||||
{
|
||||
return $this->hasOne('WorkbenchMomentsSync', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 群消息推送配置关联
|
||||
public function groupPush()
|
||||
{
|
||||
return $this->hasOne('WorkbenchGroupPush', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 自动建群配置关联
|
||||
public function groupCreate()
|
||||
{
|
||||
return $this->hasOne('WorkbenchGroupCreate', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 流量分发配置关联
|
||||
public function trafficConfig()
|
||||
{
|
||||
return $this->hasOne('WorkbenchTrafficConfig', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
public function importContact()
|
||||
{
|
||||
return $this->hasOne('WorkbenchImportContact', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户关联
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User', 'userId', 'id');
|
||||
}
|
||||
}
|
||||
25
application/cunkebao/model/WorkbenchAutoLike.php
Normal file
25
application/cunkebao/model/WorkbenchAutoLike.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 自动点赞工作台模型
|
||||
*/
|
||||
class WorkbenchAutoLike extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_auto_like';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
}
|
||||
23
application/cunkebao/model/WorkbenchGroupCreate.php
Normal file
23
application/cunkebao/model/WorkbenchGroupCreate.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class WorkbenchGroupCreate extends Model
|
||||
{
|
||||
protected $table = 'ck_workbench_group_create';
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_group_create';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
}
|
||||
23
application/cunkebao/model/WorkbenchGroupPush.php
Normal file
23
application/cunkebao/model/WorkbenchGroupPush.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class WorkbenchGroupPush extends Model
|
||||
{
|
||||
protected $table = 'ck_workbench_group_push';
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_group_push';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
}
|
||||
25
application/cunkebao/model/WorkbenchImportContact.php
Normal file
25
application/cunkebao/model/WorkbenchImportContact.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 自动点赞工作台模型
|
||||
*/
|
||||
class WorkbenchImportContact extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_import_contact';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
}
|
||||
59
application/cunkebao/model/WorkbenchMomentsSync.php
Normal file
59
application/cunkebao/model/WorkbenchMomentsSync.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class WorkbenchMomentsSync extends Model
|
||||
{
|
||||
protected $table = 'ck_workbench_moments_sync';
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_moments_sync';
|
||||
|
||||
// 同步类型
|
||||
const SYNC_TYPE_TEXT = 1; // 文本
|
||||
const SYNC_TYPE_IMAGE = 2; // 图片
|
||||
const SYNC_TYPE_VIDEO = 3; // 视频
|
||||
const SYNC_TYPE_LINK = 4; // 链接
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
// 定义关联的内容库
|
||||
public function contentLibraries()
|
||||
{
|
||||
return $this->belongsToMany('ContentLibrary', 'workbench_content_relation', 'contentLibraryId', 'workbenchId');
|
||||
}
|
||||
|
||||
// 开始时间获取器
|
||||
public function getStartTimeAttr($value)
|
||||
{
|
||||
return $value ? date('H:i', strtotime($value)) : '';
|
||||
}
|
||||
|
||||
// 结束时间获取器
|
||||
public function getEndTimeAttr($value)
|
||||
{
|
||||
return $value ? date('H:i', strtotime($value)) : '';
|
||||
}
|
||||
|
||||
// 同步类型获取器
|
||||
public function getSyncTypeTextAttr($value, $data)
|
||||
{
|
||||
$types = [
|
||||
self::SYNC_TYPE_TEXT => '文本',
|
||||
self::SYNC_TYPE_IMAGE => '图片',
|
||||
self::SYNC_TYPE_VIDEO => '视频',
|
||||
self::SYNC_TYPE_LINK => '链接'
|
||||
];
|
||||
return isset($types[$data['syncType']]) ? $types[$data['syncType']] : '未知';
|
||||
}
|
||||
}
|
||||
25
application/cunkebao/model/WorkbenchTrafficConfig.php
Normal file
25
application/cunkebao/model/WorkbenchTrafficConfig.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 自动点赞工作台模型
|
||||
*/
|
||||
class WorkbenchTrafficConfig extends Model
|
||||
{
|
||||
protected $pk = 'id';
|
||||
protected $name = 'workbench_traffic_config';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
// 定义关联的工作台
|
||||
public function workbench()
|
||||
{
|
||||
return $this->belongsTo('Workbench', 'workbenchId', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user