123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\common\model;
- use think\Model;
- class SubscriptionRelation extends Model
- {
- // 表名
- protected $table = 'subscription_relation';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- ];
- /**获取订阅号信息BY Admin_id
- * @param int $adminId
- * @return array
- */
- public function getSubListByAdminId($adminIds = []){
- if(is_string($adminIds)){
- $adminIds = (array)$adminIds;
- }
- $list = $this->alias("a")
- ->join("subscription s","a.subscription_id = s.id","left")
- ->whereIn("a.admin_id",$adminIds)
- ->where("s.status='normal'")
- ->field("s.id,s.json $.authorizer_info.nick_name")->select();
- $res = [];
- foreach ($list as $v){
- $res[$v['id']] = ['sub_id'=>$v['id'],'sub_name'=>trim($v["json_extract(s.json , '$.authorizer_info.nick_name')"],'"')?:'-'];
- }
- return array_values($res);
- }
- }
|