140 lines
5.2 KiB
PHP
140 lines
5.2 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年9月28日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
namespace app\modules\api\controllers;
|
||
|
||
use app\models\User;
|
||
use app\modules\api\behaviors\LoginBehavior;
|
||
use app\components\SiteHelper;
|
||
use app\components\SysConst;
|
||
use app\models\common\msg\CommonSysMsgActionForm;
|
||
use app\models\common\msg\CommonSysMsgListForm;
|
||
use app\models\msg\SysMsg;
|
||
use app\models\msg\UserSysMsg;
|
||
use app\components\SysErrCode;
|
||
use yii\web\NotFoundHttpException;
|
||
|
||
class SysMsgController extends Controller
|
||
{
|
||
public function behaviors() {
|
||
return array_merge(parent::behaviors(),[
|
||
'login' => [
|
||
'class' => LoginBehavior::className(),
|
||
'ignore' => [
|
||
'api/sys-msg/msg-centre',
|
||
'api/sys-msg/ball-warning',
|
||
'api/sys-msg/sms-send',
|
||
]
|
||
]
|
||
]);
|
||
}
|
||
|
||
|
||
public function actionIndex()
|
||
{
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$form = new CommonSysMsgListForm();
|
||
$form->scenario = 'user';
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$form->status = SysMsg::STATUS_PUBLISHED;
|
||
$form->to_user_id = [0, $user_id];
|
||
$form->user_id = $user_id;
|
||
$data = $form->search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
public function actionDetail()
|
||
{
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$form = new CommonSysMsgActionForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$form->to_user_id = [0, $user_id];
|
||
$data = $form->detail();
|
||
if($data['code'] == 0){
|
||
//标记已读
|
||
UserSysMsg::handleRead($form->sys_msg_id, $user_id, $this->cx_mch_id);
|
||
}
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 消息通知
|
||
* @title 消息通知列表
|
||
* @description 本接口提供消息通知列表
|
||
* @method get
|
||
* @url /api/sys-msg/msg-centre
|
||
* @param page 必选 int 页码
|
||
* @param limit 非必选 int 每页记录数
|
||
* @param type 非必选 int 消息类型1=租赁消息2=归还消息3=售后消息
|
||
* @return {"code":0,"msg":"ok","data":[{"id":"2","type":"1","title":"球车租赁消息通知","content":{"ball_mark":"123","ball_cart":"456","start_date":"01月01日 08:13","end_date":"~","price":"1213","order_id":"sn213123","number":"~"},"user_id":"86","is_admin_send":"0","created_at":"1667803007","object_id":"0","created_at_cn":"11月07日 14:36"}],"count":"1","page_size":20,"page_count":1,"page_no":1,"end_flag":true}
|
||
* @return_param title string 标题
|
||
* @return_param content array|string type=1或type=2为数组,type=3为字符串
|
||
* @return_param ball_mark string 球车型号
|
||
* @return_param ball_cart string 球车名称
|
||
* @return_param start_date string 租车时长
|
||
* @return_param end_date string 租车结束时间
|
||
* @return_param price string 消费金额
|
||
* @return_param number string 几小时
|
||
* @return_param object_id string 当前为订单id
|
||
* @return_param order_status int 是否显示还车按钮0=不现实1=显示
|
||
* @return_param created_at_cn string 日期
|
||
* @return_param count int 记录条数
|
||
* @return_param page_size int 每页记录数
|
||
* @return_param page_count int 总页数
|
||
* @return_param page_no int 当前页码
|
||
* @return_param end_flag bool 是否加载结束
|
||
* @remark
|
||
*/
|
||
public function actionMsgCentre()
|
||
{
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$form = new CommonSysMsgListForm();
|
||
$form->attributes = \Yii::$app->request->get();
|
||
$form->cx_mch_id = $this->cx_mch_id;
|
||
$form->to_user_id = [0, $user_id];
|
||
$form->user_id = $user_id;
|
||
$data = $form->msg_centre_search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 消息通知
|
||
* @title 报警消息列表
|
||
* @description 报警消息列表
|
||
* @method get
|
||
* @url /api/sys-msg/ball_warning
|
||
* @return {"code":0,"msg":"ok","data":[{"id":"2","type":"1","title":"球车租赁消息通知","content":{"ball_mark":"123","ball_cart":"456","start_date":"01月01日 08:13","end_date":"~","price":"1213","order_id":"sn213123","number":"~"},"user_id":"86","is_admin_send":"0","created_at":"1667803007","object_id":"0","created_at_cn":"11月07日 14:36"}],"count":"1","page_size":20,"page_count":1,"page_no":1,"end_flag":true}
|
||
* @return_param title string 标题
|
||
* @return_param content string 消息备注
|
||
* @return_param ball_mark string 球车型号
|
||
* @return_param ball_cart string 球车名称
|
||
* @return_param elec_percent string 剩余电量百分比
|
||
* @return_param created_at_cn string 日期
|
||
* @return_param count int 记录条数
|
||
* @remark
|
||
*/
|
||
public function actionBallWarning()
|
||
{
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$form = new CommonSysMsgListForm();
|
||
$data = $form->ball_warning($user_id);
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
}
|
||
|