186 lines
7.0 KiB
PHP
186 lines
7.0 KiB
PHP
<?php
|
|
namespace app\controllers\channel;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Yii;
|
|
use yii\web\Controller;
|
|
use app\models\common\Store;
|
|
class NoticeController extends CommonController{
|
|
public $enableCsrfValidation = false;
|
|
private $shop_id;
|
|
public function init(){
|
|
parent::init();
|
|
$this->shop_id=$this->storeId?:Store::getMainStore($this->wqData['uniacid'])['id'];
|
|
$this->shop_id=$this->shop_id?:0;
|
|
}
|
|
public function actionGetNoticeList(){
|
|
$page=Yii::$app->request->get('page')?Yii::$app->request->get('page'):1;
|
|
$num=($page-1)*10;
|
|
$limit=10;
|
|
$noticeType=Yii::$app->request->get('noticeType');
|
|
$result=axios_request();
|
|
$storeId=$result['storeId']?:Store::getMainStore($this->wqData['uniacid'])['id'];
|
|
$query=(new \yii\db\Query())
|
|
->from('{{%ybwm_notice}}')
|
|
->where(['uniacid'=>$this->wqData['uniacid'],'storeId'=>$storeId,'deleteAt'=>0]);
|
|
if($noticeType){
|
|
$query->andWhere(['noticeType'=>$noticeType]);
|
|
}
|
|
|
|
$data=$query->offset($num)
|
|
->limit($limit)
|
|
->orderBy('sort asc,id desc')
|
|
->all();
|
|
|
|
foreach ($data as $k=>$v){
|
|
// $data[$k]['body']=$v['body'];
|
|
$data[$k]['createdAt']=date('Y-m-d H:i:s',$v['createdAt']);
|
|
}
|
|
$count=(new \yii\db\Query()) ->from('{{%ybwm_notice}}')->where(['deleteAt'=>0,'uniacid'=>$this->wqData['uniacid'],'noticeType'=>$noticeType])->count();
|
|
//dd($data);die;
|
|
return $this->result(1,'成功',$data,$count);
|
|
}
|
|
|
|
public function actionNoticeSave(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$result=axios_request();
|
|
$data=array(
|
|
'sort'=>$result['sort'],
|
|
'title'=>$result['title'],
|
|
'body'=>$result['body'],
|
|
'noticeType'=>$result['noticeType'],
|
|
'uniacid'=>$this->wqData['uniacid'],
|
|
'introduction'=>$result['introduction'],
|
|
'storeId'=>$result['storeId']?:$this->shop_id
|
|
);
|
|
$data=filter_array($data);
|
|
if($result['id']){
|
|
$data['changeAt']=time();
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_notice}}', $data, ['id'=>$result['id']])->execute();
|
|
}else{
|
|
$data['createdAt']=time();
|
|
//dd($data);die;
|
|
$re = YII::$app->db->createCommand()->insert('{{%ybwm_notice}}', $data)->execute();
|
|
}
|
|
return $this->result(1,'成功');
|
|
}
|
|
}
|
|
public function actionChangeNotice(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$result=axios_request();
|
|
$id=$result['id'];
|
|
if(is_array($id)){
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_notice}}', ['display'=>$result['display']], ['in','id',$id])->execute();
|
|
}else{
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_notice}}', ['display'=>$result['display']], ['id'=>$id])->execute();
|
|
}
|
|
return $this->result(1,'成功');
|
|
|
|
}
|
|
}
|
|
|
|
public function actionNoticeDel(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$id=axios_request()['id'];
|
|
if(is_array($id)){
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_notice}}', ['deleteAt'=>time()], ['in','id',$id])->execute();
|
|
}else{
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_notice}}', ['deleteAt'=>time()], ['id'=>$id])->execute();
|
|
}
|
|
return $this->result(1,'成功');
|
|
}
|
|
|
|
}
|
|
|
|
//-------------------------------------帮助中心
|
|
public function actionGetHelpList(){
|
|
$page=Yii::$app->request->get('page')?Yii::$app->request->get('page'):1;
|
|
$num=($page-1)*10;
|
|
$limit=10;
|
|
$data= (new \yii\db\Query())
|
|
->from('{{%ybwm_helps}}')
|
|
->where(['deleteAt'=>0,'uniacid'=>$this->wqData['uniacid']])
|
|
->orderBy('sort asc,id desc')
|
|
->offset($num)
|
|
->limit($limit)
|
|
->all();
|
|
foreach ($data as $k=>$v){
|
|
$data[$k]['body']=$v['body'];
|
|
$data[$k]['createdAt']=date('Y-m-d H:i:s',$v['createdAt']);
|
|
}
|
|
$count=(new \yii\db\Query()) ->from('{{%ybwm_helps}}')->where(['deleteAt'=>0,'uniacid'=>$this->wqData['uniacid']])->count();
|
|
return $this->result(1,'成功',$data,$count);
|
|
}
|
|
|
|
public function actionHelpSave(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$result=axios_request();
|
|
$data=array(
|
|
'sort'=>$result['sort'],
|
|
'title'=>$result['title'],
|
|
'body'=>$result['body'],
|
|
'uniacid'=>$this->wqData['uniacid'],
|
|
'otherType'=>$result['otherType']
|
|
);
|
|
$data=filter_array($data);
|
|
|
|
if($result['id']){
|
|
$data['changeAt']=time();
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_helps}}', $data, ['id'=>$result['id']])->execute();
|
|
}else{
|
|
$data['createdAt']=time();
|
|
try{
|
|
$re = YII::$app->db->createCommand()->insert('{{%ybwm_helps}}', $data)->execute();
|
|
}catch (\Exception $e) {
|
|
dd($e);die;
|
|
}
|
|
}
|
|
return $this->result(1,'成功');
|
|
}
|
|
}
|
|
public function actionChangeHelps(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$result=axios_request();
|
|
$id=$result['id'];
|
|
if(is_array($id)){
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_helps}}', ['display'=>$result['display']], ['in','id',$id])->execute();
|
|
}else{
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_helps}}', ['display'=>$result['display']], ['id'=>$id])->execute();
|
|
}
|
|
return $this->result(1,'成功');
|
|
|
|
}
|
|
}
|
|
|
|
public function actionHelpsDel(){
|
|
$request = Yii::$app->request;
|
|
if($request->isPost){
|
|
$id=axios_request()['id'];
|
|
if(is_array($id)){
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_helps}}', ['deleteAt'=>time()], ['in','id',$id])->execute();
|
|
}else{
|
|
$re = YII::$app->db->createCommand()->update('{{%ybwm_helps}}', ['deleteAt'=>time()], ['id'=>$id])->execute();
|
|
}
|
|
return $this->result(1,'成功');
|
|
}
|
|
|
|
}
|
|
|
|
public function actionGetUpContent(){
|
|
$result = axios_request();
|
|
$type=$result['type']?:2;
|
|
$page=$result['page']?:1;
|
|
$data = array('page'=>$page,'type'=>$type,'auth_type'=>1);
|
|
//获取项目的应用列表
|
|
$url = Yii::$app->params['domain_url'] . '/cloud/notice/getnoticelist';
|
|
//$result= object_array(json_decode(httpRequest($url, $data)));
|
|
|
|
return httpRequest($url, $data);
|
|
}
|
|
|
|
}
|