|
- <?php
-
- namespace backend\modules\zzcs\models;
-
- use Yii;
- use yii\db\Expression;
-
- /**
- * This is the model class for table "run_bus_delay".
- *
- * @property integer $id
- * @property integer $cancel_flag
- * @property integer $create_user_id
- * @property integer $update_user_id
- * @property string $create_time
- * @property string $update_time
- * @property integer $delay_res_seq_id
- * @property integer $delay_res_id
- * @property string $delay_res_name
- * @property integer $delay_minute
- * @property integer $run_id
- * @property integer $bus_order_id
- * @property integer $is_send_message
- */
- class RunBusDelay extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'run_bus_delay';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['cancel_flag', 'create_user_id', 'update_user_id', 'delay_res_seq_id', 'delay_res_id', 'delay_minute', 'run_id', 'bus_order_id', 'is_send_message'], 'integer'],
- [['create_time', 'update_time'], 'safe'],
- [['delay_res_name'], 'string', 'max' => 100],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'cancel_flag' => 'Cancel Flag',
- 'create_user_id' => 'Create User ID',
- 'update_user_id' => 'Update User ID',
- 'create_time' => 'Create Time',
- 'update_time' => 'Update Time',
- 'delay_res_seq_id' => 'Delay Res Seq ID',
- 'delay_res_id' => 'Delay Res ID',
- 'delay_res_name' => 'Delay Res Name',
- 'delay_minute' => 'Delay Minute',
- 'run_id' => 'Run ID',
- 'bus_order_id' => 'Bus Order ID',
- 'is_send_message' => 'Is Send Message',
- ];
- }
-
- /**
- * Des:添加新记录
- * Name: addRow
- * @param $params
- * @return int|mixed
- * @author 倪宗锋
- */
- public function addRow($params)
- {
- $data = [
- 'create_user_id' => $params['user_id'],
- 'create_time' => date('Y-m-d H:i:s'),
- 'delay_res_seq_id' => $params['seq_id'],
- 'delay_res_id' => $params['res_id'],
- 'delay_res_name' => $params['res_name'],
- 'delay_minute' => $params['val'],
- 'run_id' => $params['run_id'],
- 'bus_order_id' => $params['bus_order_id'],
- ];
- $this->attributes = $data;
- $res = $this->insert();
- if ($res == false) {
- return 0;
- }
- return $this->id;
- }
-
- /**
- * Des:获取晚点时间
- * Name: getInfo
- * @param $params
- * @return int
- * @author 倪宗锋
- */
- public function getDelayTime($params)
- {
- $where = [
- 'and',
- ['=', 'a.run_id', $params['run_id']],
- ['=', 'a.bus_order_id', $params['bus_order_id']]
- ];
- $select = ['delay_time' => new Expression("SUM(a.delay_minute)")];
- $getInfo = self::find()->select($select)
- ->from(static::tableName() . ' a')
- ->where($where)
- ->asArray()
- ->one();
- if (empty($getInfo['delay_time'])) {
- return 0;
- }
- return $getInfo['delay_time'];
- }
-
- /**
- * Des:修改发送短信通知的状态
- * Name: setSendDelayMsg
- * @param $params
- * @return bool
- * @author 倪宗锋
- */
- public function setSendDelayMsg($params)
- {
- $where = [
- 'and',
- ['=', 'run_id', $params['run_id']],
- ['=', 'bus_order_id', $params['bus_order_id']]
- ];
- $values = [
- 'update_user_id' => $params['user_id'],
- 'update_time' => date('Y-m-d H:i:s'),
- 'is_send_message' => 1,
- ];
- $flag = self::updateAll($values,$where);
- if ($flag == false) {
- return false;
- }
- return true;
- }
- }
|