|
- <?php
-
- namespace backend\modules\api\models;
-
- use backend\modules\zzcs\models\OrderTitleCancelRequest;
- use Yii;
- use yii\db\Expression;
- use yii\db\ActiveRecord;
-
- /**
- * This is the model class for table "order_title".
- *
- * @property integer $order_title_id
- * @property integer $order_title_type
- * @property integer $main_corp_id
- * @property string $create_date
- * @property integer $create_user_id
- * @property string $create_time
- * @property string $confirm_time
- * @property integer $update_user_id
- * @property string $update_time
- * @property string $end_time
- * @property integer $outside_sale_org_id
- * @property string $outside_order_no
- * @property string $order_title_prod_name
- * @property string $order_title_prod_description
- * @property string $start_date
- * @property string $start_time
- * @property string $cus_name
- * @property string $cus_phone
- * @property string $cus_id_no
- * @property string $cus_remark
- * @property integer $cus_id_type
- * @property integer $cus_num
- * @property string $order_title_all_price
- * @property string $order_title_per_price
- * @property string $order_title_all_cost
- * @property string $order_title_per_cost
- * @property string $order_title_all_affi
- * @property string $order_title_per_affi
- * @property string $order_prod_type
- * @property integer $order_pay_type
- * @property integer $order_title_status
- * @property string $order_passenger_list
- * @property string $order_title_memo
- * @property integer $cancel_flag
- * @property string $bus_order
- * @property string $ticket_order
- * @property string $hotel_order
- * @property integer $tourist_id
- * @property integer $adult_num
- * @property integer $child_num
- * @property integer $is_send_msg
- */
- class OrderTitle extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'order_title';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['main_corp_id', 'create_user_id', 'update_user_id', 'outside_sale_org_id', 'cus_id_type', 'cus_num', 'order_pay_type', 'order_title_status', 'cancel_flag', 'order_title_type', 'tourist_id', 'adult_num', 'child_num', 'is_send_msg', 'is_buy_insurance', 'is_connected_order'], 'integer'],
- [['order_title_prod_description', 'cus_remark', 'order_passenger_list', 'order_title_memo', 'outside_order_no'], 'string'],
- [['order_title_all_price', 'order_title_per_price', 'order_title_all_cost', 'order_title_per_cost', 'order_title_all_affi', 'order_title_per_affi'], 'number'],
- [['create_date', 'start_date'], 'string', 'max' => 10],
- [['create_time', 'confirm_time', 'update_time', 'end_time', 'end_date', 'cus_phone'], 'string', 'max' => 20],
- [['outside_order_no', 'cus_name', 'bus_order', 'ticket_order', 'hotel_order'], 'string', 'max' => 50],
- [['order_title_prod_name'], 'string', 'max' => 200],
- [['start_time'], 'string', 'max' => 5],
- [['cus_id_no'], 'string', 'max' => 30],
- [['order_prod_type'], 'string', 'max' => 3],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'order_title_id' => 'Order Title ID',
- 'order_title_type' => '组合订单种类:1自由选择(CS) 2跟团游(微信商城)。。。',
- 'main_corp_id' => '运营主体',
- 'create_date' => '下单日期',
- 'create_user_id' => '下单人',
- 'create_time' => '下单时刻',
- 'confirm_time' => '订单确认时间',
- 'update_user_id' => '最后更新人',
- 'update_time' => '最后更新时刻',
- 'end_date' => '游玩归来日期',
- 'end_time' => '订单完成或取消时间',
- 'outside_sale_org_id' => '渠道',
- 'outside_order_no' => '渠道订单号',
- 'order_title_prod_name' => '产品名(自动生成)',
- 'order_title_prod_description' => '产品明细',
- 'start_date' => '出发日期',
- 'start_time' => '出发时刻',
- 'cus_name' => '联系人',
- 'cus_phone' => '联系手机',
- 'cus_id_no' => '联系人身份证',
- 'cus_remark' => '备注',
- 'cus_id_type' => '联系人证件类型150身份证 153护照',
- 'cus_num' => '总人数',
- 'order_title_all_price' => '总收入',
- 'order_title_per_price' => '单人收入',
- 'order_title_all_cost' => '总成本',
- 'order_title_per_cost' => '单人成本',
- 'order_title_all_affi' => '总渠道佣金',
- 'order_title_per_affi' => '单人渠道佣金',
- 'order_prod_type' => '组合订单种类:[100]单车票[010]单酒店[001]单门票[110]车+酒[101]车+门[011]酒+门[111]车+酒+门',
- 'order_pay_type' => '组合订单支付方式',
- 'order_title_status' => '组合订单整体状态, 1:待确认 2: 已确认 3:已完成 4: 已取消。',
- 'order_passenger_list' => '出行人信息',
- 'order_title_memo' => '备注',
- 'cancel_flag' => 'Cancel Flag',
- 'bus_order' => '对应子巴士产品订单号,多个用逗号隔开',
- 'ticket_order' => '对应门票子产品订单号,多个用逗号隔开',
- 'hotel_order' => '对应酒店子产品订单号,多个用逗号隔开',
- 'tourist_id' => '自由行产品id,为0是组合订单',
- 'adult_num' => '自由行产品成人人数',
- 'child_num' => '自由行产品儿童人数',
- 'is_send_msg' => '自由行是否已发送短信',
- 'is_buy_insurance' => '是否购买保险',
- ];
- }
-
- /**
- * Function Description:获取组合订单信息判断是否可以取消
- * Function Name: getCheckCancelInfo
- * @param $order_title
- *
- * @return array|null|\yii\db\ActiveRecord
- *
- * @author 娄梦宁
- */
- public function getCheckCancelInfo($order_title)
- {
- $result = self::find()->select('order_title_type,tourist_id,order_title_status,is_buy_insurance,start_date')
- ->from(self::tableName())
- ->where(['order_title_id' => $order_title])
- ->limit(1)
- ->asArray()
- ->one();
- return $result;
- }
-
- /**
- * Function Description:获取自由行产品已确认未发预定短信订单
- * Function Name: getConfirmedOrders
- *
- * @return array
- *
- * @author 温依莅
- */
- public function getConfirmedOrders()
- {
- $res = self::find()->select([
- 'order_title_id',
- 'order_title_prod_name',
- 'cus_num',
- 'adult_num',
- 'child_num',
- 'start_date',
- 'order_title_type',
- 'tourist_id',
- 'order_title_status',
- 'is_send_msg',
- 'main_corp_id'
- ])->from(self::tableName())
- ->where([
- 'and',
- ['=', 'order_title_type', 2],
- ['>', 'tourist_id', 0],
- ['=', 'order_title_status', 2],
- ['=', 'is_send_msg', 0],
- ['=', 'cancel_flag', 0],
- ])->asArray()->all();
- return $res;
- }
-
- /**
- * Function Description:获取自由行产品的详细信息
- * Function Name: getTitleInfo
- * @param int $order_title_id
- * @return array
- *
- * @author 温依莅
- */
- public function getTitleInfo($order_title_id)
- {
- $select = [
- 'a.order_title_id',
- 'a.outside_order_no',
- 'a.order_title_prod_name',
- 'a.cus_phone',
- 'a.adult_num',
- 'a.child_num',
- 'a.cus_num',
- 'a.start_date',
- 'a.order_title_type',
- 'a.tourist_id',
- 'a.order_title_status',
- 'a.is_send_msg',
- 'a.is_connected_order',
- 'a.order_title_all_price',
- 'b.id',
- 'sequence_id' => new Expression("ifnull(b.sequence_id,'')"),
- 'request_status' => new Expression("ifnull(b.request_status,0)"),
- 'remark' => new Expression("ifnull(b.remark,'')")
- ];
- $res = self::find()->select($select)
- ->from(self::tableName() . ' a')
- ->leftJoin(OrderTitleCancelRequest::tableName() . ' b', 'b.order_title_id = a.order_title_id')
- ->where(['=', 'a.order_title_id', $order_title_id])
- ->orderBy('b.id desc')
- ->limit(1)
- ->asArray()
- ->one();
- return $res;
- }
-
- /**
- * Function Description:获取自由行产品的详细信息
- * Function Name: getCtripTitleInfo
- * @param int $outside_order_no
- * @return array
- *
- * @author 温依莅
- */
- public function getCtripTitleInfo($outside_order_no)
- {
- $select = [
- 'a.outside_sale_org_id',
- 'a.order_title_id',
- 'a.outside_order_no',
- 'a.order_title_prod_name',
- 'a.cus_phone',
- 'a.adult_num',
- 'a.child_num',
- 'a.cus_num',
- 'a.start_date',
- 'a.order_title_type',
- 'a.tourist_id',
- 'a.order_title_status',
- 'a.is_send_msg',
- 'a.is_connected_order',
- 'a.order_title_all_price',
- 'b.id',
- 'sequence_id' => new Expression("ifnull(b.sequence_id,'')"),
- 'request_status' => new Expression("ifnull(b.request_status,0)"),
- 'remark' => new Expression("ifnull(b.remark,'')")
- ];
- $res = self::find()->select($select)
- ->from(self::tableName() . ' a')
- ->leftJoin(OrderTitleCancelRequest::tableName() . ' b', 'b.order_title_id = a.order_title_id')
- ->where(['=', 'a.outside_order_no', $outside_order_no])
- ->orderBy('b.id desc')
- ->limit(1)
- ->asArray()
- ->one();
- return $res;
- }
- /**
- * Function Description:更新自由行产品短信发送状态
- * Function Name: updateMsgStatus
- * @param $order_title_id
- *
- * @return bool
- * @author 温依莅
- */
- public function updateMsgStatus($order_title_id)
- {
- $obj = self::findOne(['order_title_id' => $order_title_id]);
- if (!$obj) {
- return false;
- }
- $obj->is_send_msg = 1;
- if (false === $obj->update()) {
- return false;
- } else {
- return true;
- }
- }
-
-
- /**
- * Function Description:获取自由行产品信息(为了自由行下保险订单兼容巴士下保险订单发送短信)
- * Function Name: getTitleInfoById
- * @param $order_title_id
- *
- * @return array|null|ActiveRecord
- *
- * @author 田玲菲
- */
- public function getTitleInfoById($order_title_id)
- {
- $res = self::find()->select([
- 'order_title_id',
- 'order_title_prod_name',
- 'outside_sale_org_id',
- 'cus_phone',
- 'adult_num',
- 'child_num',
- 'start_date as run_date',
- 'start_date as prod_start_station_date',
- 'start_time as prod_start_station_time',
- 'create_time' => new Expression('concat(create_date,\' \',create_time)'),
- 'order_title_type',
- 'tourist_id',
- 'order_title_status',
- 'is_send_msg',
- ])->from(self::tableName())
- ->where([
- 'order_title_id' => $order_title_id
- ])->limit(1)->asArray()->one();
- return $res;
- }
-
-
- /**
- * Function Description:获取自由行订单信息
- * Function Name: getCtripOrderInfoById
- * @param $outside_order_no
- *
- * @return array|null|ActiveRecord
- *
- * @author 倪宗锋
- */
- public function getCtripOrderInfoById($outside_order_no)
- {
- $res = self::find()->select([
- 'order_title_id',
- 'order_title_prod_name',
- 'cus_phone',
- 'adult_num',
- 'child_num',
- 'start_date as run_date',
- 'start_date as prod_start_station_date',
- 'start_time as prod_start_station_time',
- 'create_time' => new Expression('concat(create_date,\' \',create_time)'),
- 'order_title_type',
- 'tourist_id',
- 'order_title_status',
- 'is_send_msg',
- ])->from(self::tableName())
- ->where([
- 'outside_order_no' => $outside_order_no
- ])->limit(1)->asArray()->one();
- return $res;
- }
-
- }
|