Operational.php 2.36 KB
<?php
namespace app\admin\controller;
use think\Db;
use think\facade\Request;
class Operational extends Common
{
    /********************************可发送消息列表*******************************/
    public function messagelist(){
        if(Request::isAjax()){
            $data = Request::except('file');
            $key= input('post.key') ? input('post.key') : "";
            $channel = @$key['channel'] ? @$key['channel'] : 1;
            $user_groups = @$key['user_groups'] ? @$key['user_groups'] : 2;
            $role = @$key['role'] ? @$key['role'] : '';
            $patt = @$key['patt'] ? @$key['patt'] : 1;
            $limit = '&offset='.$data["page"].'&size='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel.'&role='.$role.'&user_groups='.$user_groups.'&patt='.$patt;            

            $list= file_get_contents(ON_LINE.'App.Message.GetFormidList'.$limit); 
            $array = json_decode($list,TRUE);
            $total = $array['data']['total'];
            unset($array['data']['total']);
            foreach ($array['data'] as $key => $value) {
                $array['data'][$key]['sellerinfo'] = $value['id'].'-'.$value['sellername'];
                $array['data'][$key]['expire_in'] = $value['expire_in'] ? date('Y-m-d H:i:s',$value['expire_in']) : '';
                $array['data'][$key]['wx/app'] = $value['wx'].' / '.$value['app'];
                if($patt==2){
                    $array['data'][$key]['role_name'] = '顾客';
                }
            }
            
            return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'count'=>intval($total),'rel'=>1];
        }
        $this->assign ( 'title','运营消息推广');
        return $this->fetch();
    }

    /********************************消息推送*******************************/
    public function sendmessagelist(){
        if(Request::isAjax()){
            $data = Request::except('file');
            $list= file_get_contents(ON_LINE.'App.Message.SendMessage&openid='.json_encode($data['openid']));
            $array = json_decode($list,TRUE);
            if($array['ret']==200){
                $result['code'] = 1;
                $result['msg'] = 'SUCCESS!';
            }else{
                $result['code'] = 0;
                $result['msg'] = '请求错误!';
            }
            return $result;
        }
        return view();
    }
}