|
- <?php
-
- namespace backend\modules\api\models;
-
- use yii\db\ActiveRecord;
-
- /**
- * This is the model class for table "order_check_tickets".
- *
- * @property integer $id
- * @property integer $order_id
- * @property integer $run_id
- * @property integer $bus_no
- * @property integer $check_status
- * @property string $check_time
- * @property integer $check_station
- * @property integer $check_seq_id
- * @property integer $check_user_id
- */
- class OrderCheckTickets extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'order_check_tickets';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['order_id', 'run_id', 'bus_no', 'check_status', 'check_station', 'check_seq_id', 'check_user_id'], 'integer'],
- [['bus_no', 'check_user_id'], 'required'],
- [['check_time'], 'string', 'max' => 20],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'order_id' => 'Order ID',
- 'run_id' => 'Run ID',
- 'bus_no' => 'Bus No',
- 'check_status' => 'Check Status',
- 'check_time' => 'Check Time',
- 'check_station' => 'Check Station',
- 'check_seq_id' => 'Check Seq ID',
- 'check_user_id' => 'Check User ID',
- ];
- }
-
-
- /**
- * Function Description:更改乘客上车状态
- * Function Name: updateCheckStatus
- * @param int $driver_id 司机id
- * @param int $run_id 班次id
- * @param int $order_id 订单id
- * @param int $bus_no 车号
- * @param int $check_status 检票状态
- *
- * @return bool
- *
- * @author 张帅
- */
- public function updateCheckStatus($driver_id, $run_id, $order_id, $bus_no, $check_status)
- {
- $result = self::find()->select('id')
- ->where([
- 'and',
- ['=', 'order_id', $order_id],
- ['=', 'run_id', $run_id],
- ['=', 'bus_no', $bus_no],
- ])
- ->asArray()->one();
-
- if (count($result) > 0) {
- return true;
- }
-
- $value = [
- 'order_id' => $order_id,
- 'run_id' => $run_id,
- 'bus_no' => $bus_no,
- 'check_status' => $check_status,
- 'check_time' => date('Y-m-d H:i:s', time()),
- 'check_station' => 0,
- 'check_user_id' => $driver_id,
- ];
- $this->attributes = $value;
- $res = $this->insert();
-
- if ($res) {
- return true;
- } else {
- return false;
- }
- }
-
- public function getCustomerMobile($run_id,$bus_order_id){
-
- //根据run_id查询到已经检票的乘客电话号码
- $customer_phone_list = OrderCheckTickets::find()
- ->select("om.customer_mobile,om.order_id")
- ->from("order_check_tickets as oct")
- ->innerJoin("order_main as om",'oct.run_id=om.run_id and oct.order_id=om.parent_order_id')
- ->where(["and",["=","om.cancel_flag","0"],["=","om.run_id",$run_id],["=","oct.bus_no",$bus_order_id]])
- ->groupBy("om.parent_order_id")
- ->asArray()->all();
- return $customer_phone_list;
- }
- }
|