|
- <?php
- /**
- * 数据库表类 order_main
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 倪宗锋
- * PhpStorm LoginController.php
- * Create By 2017/06/15 10:33 $
- */
-
- namespace common\models;
-
- use yii\db\ActiveRecord;
- use yii\db\Expression;
-
- /**
- * 数据库表类 order_main.
- * @property integer $order_id
- * @property string $order_name
- * @property string $spider_order_id
- * @property string $total_money
- * @property integer $category_id
- * @property integer $prod_cate_id
- * @property integer $prod_source
- * @property integer $prod_cnt
- * @property integer $sh_uid
- * @property integer $fx_uid
- * @property string $start_time
- * @property string $end_time
- * @property string $start_date
- * @property string $end_date
- * @property integer $order_status
- * @property string $update_time
- * @property string $create_time
- * @property integer $delete_flag
- * @property integer $system
- * @property string $start_area
- * @property string $end_area
- * @property integer $main_user_id
- */
- class OrderMain extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'order_main';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['original_price', 'total_money'], 'number'],
- [['category_id', 'prod_cate_id', 'prod_source', 'prod_cnt', 'sh_uid', 'fx_uid', 'order_status', 'delete_flag', 'system', 'main_user_id'], 'integer'],
- [['start_time', 'end_time', 'start_date', 'end_date', 'update_time', 'create_time'], 'safe'],
- [['order_name', 'spider_order_id', 'start_area', 'end_area','remark'], 'string', 'max' => 255],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'order_id' => 'Order ID',
- 'order_name' => 'Order Name',
- 'spider_order_id' => 'Spider Order ID',
- 'total_money' => 'Total Money',
- 'original_price' => 'original_price',
- 'category_id' => 'Category ID',
- 'prod_cate_id' => 'Prod Cate ID',
- 'prod_source' => 'Prod Source',
- 'prod_cnt' => 'Prod Cnt',
- 'sh_uid' => 'Sh Uid',
- 'fx_uid' => 'Fx Uid',
- 'start_time' => 'Start Time',
- 'end_time' => 'End Time',
- 'start_date' => 'Start Date',
- 'end_date' => 'End Date',
- 'order_status' => 'Order Status',
- 'update_time' => 'Update Time',
- 'create_time' => 'Create Time',
- 'delete_flag' => 'Delete Flag',
- 'system' => 'System',
- 'start_area' => 'Start Area',
- 'end_area' => 'End Area',
- 'main_user_id' => 'Main User ID'
- ];
- }
-
- /**
- * Des:根据订单ID 获取订单详情
- * Name: getOrderInfoById
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function getOrderInfoById($order_id)
- {
- $where = ['=', 'a.order_id', $order_id];
- $select = [
- 'order_id' => 'a.order_id',//订单ID
- 'a.order_name',//订单名称
- 'spider_order_id' => 'a.spider_order_id',//cs订单号
- 'total_money' => 'a.total_money',//总金额
- 'category_id' => 'a.category_id',//订单类型ID
- 'prod_cate_id' => 'a.prod_cate_id',//产品品类ID
- 'prod_cnt' => 'a.prod_cnt',//产品数量
- 'fx_uid' => 'a.fx_uid',//分销商ID
- 'sh_uid' => 'a.sh_uid',//用户ID
- 'start_time' => 'a.start_time',//出发时间
- 'start_date' => 'a.start_date',//出发日期
- 'end_date' => 'a.end_date',//接收日期
- 'order_status' => 'a.order_status',//订单状态
- 'update_time' => 'a.update_time',//更新时间
- 'create_time' => 'a.create_time',//下单时间
- 'delete_flag' => 'a.delete_flag',//是否删除 无用
- 'contacts_name' => 'b.contacts_name',//联系人
- 'contacts_phone' => 'b.contacts_phone',//手机号
- 'contacts_ID' => 'b.contacts_ID',//证件
- 'pro_cate_name' => 'a.order_name',//产品名称
- 'prod_source' => 'a.prod_source',//产品来源
- 'start_area' => new Expression("ifnull(a.start_area,'')"),
- 'end_area' => new Expression("ifnull(a.end_area,'')"),
- 'system' => 'a.system',
- 'pay_order_id' => new Expression("ifnull((SELECT pay_order_id from pay_main WHERE order_id = a.order_id),'')"),
- 'category_name' => new Expression("(SELECT category_name from base_category WHERE category_id = a.category_id)"),//产品类型
- //产品详细 ' ¥',format(x.total_price,2)
- 'prod_info' => new Expression("(
- SELECT GROUP_CONCAT(x.prod_name,' ',x.count separator '</br>')
- from order_info x
- WHERE x.order_id = a.order_id and x.count > 0
- GROUP BY x.order_id
- )
- "),
- 'order_status_des' => new Expression("CASE a.order_status
- WHEN 1 THEN '待支付'
- WHEN 2 THEN '已支付'
- WHEN 3 THEN '已完成'
- WHEN 4 THEN '已退款'
- WHEN 5 THEN '已取消'
- ELSE '异常'
- END
- "),
- 'sign' => new Expression("(SELECT x.sign from prod_category x where pro_cate_id = a.prod_cate_id)"),
- 'original_price',
- 'hotel_id' => new Expression("ifnull(c.hotel_id,'')"),
- 'room_id' => new Expression("ifnull(c.room_id,'')"),
- 'hotel_name' => new Expression("ifnull(c.hotel_name,'')"),
- 'room_name' => new Expression("ifnull(c.room_name,'')"),
- 'is_gift' => new Expression("ifnull(c.is_gift,0)"),
- 'gift_describe' => new Expression("ifnull(c.gift_describe,'')"),
- 'breakfast' => new Expression("ifnull(c.breakfast,'')"),
- 'is_confirm' => new Expression("ifnull(c.is_confirm,'')"),
- 'total_details' => new Expression("ifnull(c.total_details,'[]')"),
- 'remarks' => new Expression("ifnull(c.remarks,'')")
- ];
- $getInfo = self::find()->select($select)
- ->from(self::tableName() . ' as a')
- ->innerJoin(OrderContacts::tableName() . ' as b', 'a.order_id = b.order_id and b.contacts_type=1')
- ->leftJoin(OrderHotelExtra::tableName() . ' c', 'c.main_order_id = a.order_id')
- ->where($where)
- ->asArray()
- ->one();
- if (empty($getInfo['order_id'])) {
- return [];
- } else {
- $getInfo['total_money'] = $this->dealFloat($getInfo['total_money']);
- }
- return $getInfo;
- }
-
-
- /**
- * Function Description:处理价格
- * Function Name: dealFloat
- * @param $float
- *
- * @return float
- *
- * @author LUOCJ
- */
- public function dealFloat($float)
- {
- $int = floor($float);
- if ($float - $int == 0) {
- $float = $int;
- }
- return $float;
- }
-
-
- /**
- * Des:修改订单信息
- * Name: upOrder
- * @param $value
- * @param $orderIds
- * @return int
- * @author 倪宗锋
- */
- public function upOrder($value, $orderIds)
- {
- $count = self::updateAll($value, ['in', 'order_id', $orderIds]);
- return $count;
- }
-
-
- /**
- * Function Description:去cs下巴士订单获取基础数据
- * Function Name: GetCsProdInfo
- * @param $orderId
- *
- * @return array|null|\yii\db\ActiveRecord
- *
- * @author 娄梦宁
- */
- public function GetCsBusProdInfo($orderId)
- {
- $result = self::find()->select(["(select bus_ticket_id from prod_category where pro_cate_id =a.prod_cate_id limit 1) as ticket_id", "bus_run_id as run_id",
- "(select unit_price from order_info where order_id=a.order_id limit 1) as price", 'a.total_money', 'a.prod_cnt', 'b.contacts_name', 'b.contacts_phone', 'b.contacts_ID', 'a.system'])
- ->from(self::tableName() . ' as a')
- ->leftJoin('order_contacts as b', 'a.order_id=b.order_id and b.contacts_type = 1')
- ->where(['a.order_id' => $orderId])
- ->asArray()
- ->one();
- return $result;
- }
-
- /**
- * Des:获取非巴士产品的下单产品信息
- * Name: getCsUnBusProdInfo
- * @param $orderId
- * @return array
- * @author 倪宗锋
- */
- public function getCsUnBusProdInfo($orderId)
- {
- $where = [
- 'and',
- ['!=', 'a.count', 0],
- ['=', 'a.order_id', $orderId]
- ];
- $select = [
- 'prod_str' => new Expression("GROUP_CONCAT(CONCAT('{',b.bus_id,',',a.unit_price,',',a.count,'}') separator '')"),
- 'c.contacts_name',
- 'c.contacts_phone',
- 'c.contacts_ID',
- 'main_prod_id' => 'd.sign',
- 'run_date' => new Expression("(SELECT start_date FROM order_main WHERE order_id = a.order_id)"),
- 'e.system'
- ];
- $getProdStr = self::find()->select($select)
- ->from(OrderInfo::tableName() . ' a')
- ->innerJoin(OrderMain::tableName() . ' e', 'a.order_id = e.order_id')
- ->innerJoin(ProdCategory::tableName() . ' d', 'e.prod_cate_id=d.pro_cate_id')
- ->innerJoin(ProdMain::tableName() . ' b', 'a.prod_id = b.prod_id')
- ->innerJoin(OrderContacts::tableName() . ' c', 'a.order_id = c.order_id and c.contacts_type=1')
- ->where($where)
- ->asArray()
- ->one();
- if (empty($getProdStr)) {
- $getProdStr = [];
- }
- return $getProdStr;
- }
-
- /**
- * Des:添加cs订单ID记录
- * Name: addSpiderOrder
- * @param $spider_id
- * @param $order_id
- * @return int
- * @author 倪宗锋
- */
- public function addSpiderOrder($spider_id, $order_id)
- {
- $count = self::updateAll(['spider_order_id' => $spider_id], ['=', 'order_id', $order_id]);
- return $count;
- }
-
- /**
- * Function Description:插入主订单
- * Function Name: insertOrder
- * @param $param_arr
- *
- * @return bool
- *
- * @author 娄梦宁
- */
- public function insertOrder($param_arr)
- {
- $values = [
- 'remark'=>$param_arr['remark'],
- 'total_money' => $param_arr['total_money'],
- 'original_price' => $param_arr['total_money'],//原价
- 'prod_cate_id' => (int)$param_arr['pro_cate_id'],
- 'prod_cnt' => $param_arr['prod_cnt'],
- 'fx_uid' => $param_arr['fx_uid'],
- 'start_date' => $param_arr['start_date'],
- 'start_time' => $param_arr['start_time'],
- 'end_time' => empty($param_arr['end_time']) ? '00:00:00' : $param_arr['end_time'],
- 'sh_uid' => $param_arr['sh_uid'],
- 'order_status' => 1,
- 'create_time' => date('Y-m-d H:i:s'),
- 'end_date' => $param_arr['end_date'],
- 'category_id' => $param_arr['category_id'],
- 'system' => $param_arr['system'],
- 'order_name' => $param_arr['order_name'],
- 'prod_source' => $param_arr['prod_source'],
- 'start_area' => $param_arr['start_area'],
- 'end_area' => $param_arr['end_area'],
- 'main_user_id' => empty($param_arr['main_user_id']) ? 0 : $param_arr['main_user_id']
- ];
- $this->attributes = $values;
- $res = $this->insert();
- if (!$res) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Des:判断某个产品是否存在订单
- * Name: existOrder
- * @param $param array
- * @return bool
- * @author 付泓程
- */
- public function existOrder($param)
- {
- $prod_cate_id = $param['prod_cate_id'];
- $start_date = $param['start_date'];
- $run_time = $param['start_time'];
- $small24 = $param['small24']; //是否小于0 -即提前X天。
- $select = ['count(order_id) as count'];
- $where = [
- 'and',
- ['=', 'a.prod_cate_id', $prod_cate_id],
- ['=', 'a.start_date', $start_date],
- ['=', 'a.order_status', 2],
- ['=', 'a.delete_flag', 0]
- ];
- if (!$small24) {
- $where[] = ['>=', 'a.start_time', $run_time];
- }
- $result = self::find()
- ->select($select)
- ->from(OrderMain::tableName() . ' a')
- ->where($where)
- ->asArray()
- ->one();
- $count = $result['count'];
- if ($count > 0) {
- return true;
- }
- return false;
- }
-
- /**
- * Des:获取订单列表
- * Name: getListForZzcx
- * @param $param
- * @return array|ActiveRecord[]
- * @author 倪宗锋
- */
- public function getListForZzcx($param)
- {
- //where条件
- $where = [
- 'and',
- ['=', 'a.sh_uid', $param['sh_uid']],
- ['=', 'a.delete_flag', 0],
- [
- 'or',
- ['=', 'a.system', 2],//蜘蛛出行的订单全部展示
- ['not in', 'a.order_status', [1, 5]]//其他渠道的订单 如分销,未支付的订单是废单,不进行展示
- ]
- ];
- if (empty($param['order_status']) == false) {
- $where[] = ['in', 'a.order_status', explode(',', $param['order_status'])];
- }
-
- //查询字段
- $select = [
- 'a.order_id',//订单ID
- "a.create_time as create_order_time",//下单时间
- "c.category_name as order_type_des",//订单类型
- "a.order_name as book_product",//产品品类名称
- "(
- SELECT GROUP_CONCAT(CONCAT(x.prod_name,'',x.count,' ') SEPARATOR ' ')
- from order_info x
- WHERE x.order_id = a.order_id
- GROUP BY x.order_id
- ) as prod_des
- ",//具体产品及数量
- 'a.start_date',
- 'a.start_time',
- new Expression("CASE a.order_status
- WHEN 1 THEN '待支付'
- WHEN 2 THEN '已支付'
- WHEN 3 THEN '已完成'
- WHEN 4 THEN '已退款'
- WHEN 5 THEN '已取消'
- ELSE ''
- END
- as order_status_des
- ")
- ,//订单状态名称
- "a.order_status as order_status_id",//订单状态标识ID
- "if(d.pay_type=1,'微信',if(d.pay_type=2,'支付宝','预付款')) as pay_type_des",//支付类型名称
- "if(a.order_status in (1,2),
- if(a.start_date >= '" . date('Y-m-d') . "',0,1), 1)
- as if_can_cancel",//是否可以取消订单
- 'a.total_money',
- 'a.start_area',
- 'a.end_area',
- 'a.prod_cnt',
- 'a.category_id',
- ];
- //拼接sql语句
- $offset = ($param['current_page'] - 1) * $param['page_size'];
- $result = self::find()->select($select)
- ->from(self::tableName() . ' a')
- ->innerJoin(BaseCategory::tableName() . ' c', ' a.category_id = c.category_id')
- ->leftJoin(PayMain::tableName() . ' d', ' a.order_id = d.order_id')
- ->leftJoin(OrderContacts::tableName() . ' e', 'a.order_id = e.order_id and e.contacts_type=1')
- ->where($where)
- ->orderBy('a.start_date DESC,a.start_time desc')
- ->offset($offset)
- ->limit($param['page_size'])
- ->asArray()
- ->all();
- if (empty($result[0])) {
- $result = [];
- } else {
- foreach ($result as &$v) {
- $v['total_money'] = $this->dealfloat($v['total_money']);
- }
- }
- return $result;
- }
-
- /**
- * Des:获取订单产品ID
- * Name: getProdIdByCsOrderId
- * @param $cs_order_id
- * @return int|mixed
- * @author 倪宗锋
- */
- public function getProdIdByCsOrderId($cs_order_id)
- {
- $select = [
- 'prod_id' => new Expression("CONCAT(IFNULL(b.pro_cate_id,0),',',IFNULL(d.pro_cate_id,0))")
- ];
- $where = ['=', 'a.spider_order_id', $cs_order_id];
- $getProd = self::find()->select($select)
- ->from(OrderMain::tableName() . ' a')
- ->leftJoin(ProdCategory::tableName() . ' b', 'a.prod_cate_id = b.pro_cate_id')
- ->leftJoin(BusTicket::tableName() . ' c', 'b.bus_ticket_id = c.ticket_id')
- ->leftJoin(ProdCategory::tableName() . ' d', 'c.line_id = d.sign')
- ->where($where)
- ->asArray()
- ->one();
- if (empty($getProd['prod_id'])) {
- return 0;
- }
- return $getProd['prod_id'];
-
- }
-
- /**
- * Des:根据供应商订单ID获取订单ID
- * Name: getOrderIdBySpiderOrderId
- * @param $order_id
- * @param $type
- * @return mixed|string
- * @author 倪宗锋
- */
- public function getOrderIdBySpiderOrderId($order_id, $type)
- {
- $where = [
- 'and',
- ['=', 'spider_order_id', $order_id],
- ];
- if (empty($type)) {
- $where[] = ['=', 'category_id', $type];
- }
- $select = ['order_id'];
- $getInfo = self::find()->select($select)
- ->where($where)
- ->asArray()
- ->one();
- if (empty($getInfo['order_id'])) {
- return '';
- }
- return $getInfo['order_id'];
- }
-
- /**
- * Des:获取巴士自由行下单所用产品参数
- * Name: getCsFreeWalkProdForMakeOrder
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function getCsFreeWalkProdForMakeOrder($order_id)
- {
- $select = [
- 'prod_id' => 'b.bus_id',
- 'b.prod_name',
- 'prod_num' => 'a.count'
- ];
- $where = [
- 'and',
- ['=', 'a.order_id', $order_id],
- ['>', 'a.count', 0]
- ];
- $getProdArr = self::find()->select($select)
- ->from(OrderInfo::tableName() . ' a')
- ->innerJoin(ProdMain::tableName() . ' b', 'a.prod_id = b.prod_id')
- ->where($where)
- ->asArray()
- ->all();
- if (empty($getProdArr[0])) {
- return [];
- }
- return $getProdArr;
- }
-
-
- /**
- * Des:获取巴士产品下单推荐的产品的ID
- * Name: prodCategoryByBusOrder
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function prodCategoryByBusOrder($order_id)
- {
- $where = [
- 'and',
- ['=', 'a.order_id', $order_id],
- ['!=', 'f.category_id', '1'],
- ['=', 'f.delete_flag', '0']
- ];
- $getList = self::find()->select(['e.prod_cate_id'])
- ->from(static::tableName() . ' a')
- ->innerJoin(ProdCategory::tableName() . ' b', 'a.prod_cate_id = b.pro_cate_id')
- ->innerJoin(BusTicket::tableName() . ' c', 'b.bus_ticket_id = c.ticket_id')
- ->innerJoin(CmsCategoryExtra::tableName() . ' d', 'd.area_id = c.end_area_id')
- ->innerJoin(CmsCategoryProd::tableName() . ' e', 'd.category_id = e.cms_cate_id')
- ->innerJoin(ProdCategory::tableName() . ' f', 'e.prod_cate_id = f.pro_cate_id')
- ->where($where)
- ->indexBy('prod_cate_id')
- ->asArray()
- ->all();
- if (empty($getList)) {
- return [];
- }
- return $getList;
-
- }
-
- /**
- * Des:获取非巴士产品下单推荐的产品的ID
- * Name: prodCategoryByUnBusOrder
- * @param $order_id
- * @return array|ActiveRecord[]
- * @author 倪宗锋
- */
- public function prodCategoryByUnBusOrder($order_id)
- {
- $getList = self::find()->select(['y.pro_cate_id'])
- ->distinct()
- ->from(BusTicket::tableName() . ' x')
- ->innerJoin(ProdCategory::tableName() . ' y', 'x.line_id=y.sign and category_id=1 and delete_flag =0')
- ->innerJoin(OrderMain::tableName() . ' z', '(INSTR(x.start_area_name,SUBSTR(z.order_name FROM 1 FOR 1)) or INSTR(x.end_area_name,SUBSTR(z.order_name FROM 1 FOR 1))) and z.order_id = ' . $order_id)
- ->asArray()
- ->indexBy('pro_cate_id')
- ->limit(8)
- ->all();
- if (count($getList) == 0) {
- return [];
- }
- return $getList;
- }
-
- /**
- * Des:获取下单微信通模板数据
- * Name: getSendCreateWxMsg
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function getSendCreateWxMsg($order_id)
- {
- $where = ['=', 'a.order_id', $order_id];
- $select = [
- 'a.category_id',
- 'a.start_date',
- 'a.start_time',
- 'a.order_id',
- 'a.order_name',
- 'a.prod_cnt',
- 'a.total_money',
- 'a.start_area',
- 'a.end_area',
- 'users' => new Expression("(select GROUP_CONCAT(b.contacts_name) from order_contacts b WHERE a.order_id = b.order_id and b.contacts_type = 3)"),
- 'open_id' => new Expression("IFNULL((SELECT open_id from pay_main c where a.order_id = c.order_id and c.pay_type = 1),'')")
- ];
- $getWxMsg = self::find()->select($select)
- ->from(static::tableName() . ' a')
- ->where($where)
- ->asArray()
- ->one();
- return $getWxMsg;
- }
-
- /**
- * Des:获取班次发车一小时前的数据
- * Name: getSendWxMsgOrderForRunBus
- * @return array
- * @author 倪宗锋
- */
- public function getSendWxMsgOrderForRunBus()
- {
- $where = [
- 'and',
- ['=', 'category_id', 1],
- ['in', 'order_status', [2, 3]],
- // ['=','order_id','11410'],
- ['=', new Expression("DATE_FORMAT(CONCAT(start_date,' ',start_time),'%Y-%m-%d %H:%i')"), new Expression("DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 HOUR),'%Y-%m-%d %H:%i')")]
- ];
- $select = [
- 'start_area',
- 'spider_order_id',
- 'run_date' => new Expression("CONCAT(start_date,' ',start_time)"),
- 'order_id',
- 'open_id' => new Expression("IFNULL((SELECT open_id from pay_main c where " . static::tableName() . ".order_id = c.order_id and c.pay_type = 1),'')")
- ];
- $getInfo = self::find()->select($select)
- ->where($where)
- ->asArray()
- ->all();
- return $getInfo;
- }
-
- /**
- * Des:获取酒店订车信息
- * Name: getHotelOrderInfo
- * @param $order_id
- * @return array
- * @author 倪宗锋
- */
- public function getHotelOrderInfo($order_id)
- {
- $select = [
- 'a.order_id',
- 'c.hotel_name',
- 'c.hotel_id',
- 'c.room_name',
- 'c.room_id',
- 'a.prod_cnt',
- 'a.start_date',
- 'a.end_date',
- 'all_days' => new Expression("DATEDIFF(a.end_date,a.start_date)"),
- 'a.total_money',
- 'a.original_price',
- 'b.contacts_name',
- 'b.contacts_phone',
- 'c.total_details',
- 'c.remarks',
- 'a.system',
- 'c.address',
- 'users' => new Expression("(SELECT GROUP_CONCAT(contacts_name SEPARATOR ' ') from order_contacts where contacts_type = 3 and order_id = a.order_id)"),
- 'commission' => new Expression("ifnull((SELECT total_money from fx_commission_info where order_id = a.order_id and delete_flag = 0 limit 1),0)")
- ];
- $where = ['=', 'a.order_id', $order_id];
- $getInfo = self::find()->select($select)
- ->from(self::tableName() . ' a')
- ->innerJoin(OrderContacts::tableName() . ' b', 'a.order_id = b.order_id and b.contacts_type=1')
- ->innerJoin(OrderHotelExtra::tableName() . ' c', 'a.order_id = c.main_order_id')
- ->where($where)
- ->asArray()
- ->one();
- return $getInfo;
- }
-
- /**
- * Des:获取为支付订单列表
- * Name: getUnPayOrder
- * @param $start_time
- * @param $end_time
- * @return array|ActiveRecord[]
- * @author 倪宗锋
- */
- public function getUnPayOrder($start_time, $end_time)
- {
- $select = [
- 'a.order_id',
- 'b.contacts_phone'
- ];
- $where = [
- 'and',
- ['>=', 'a.create_time', $start_time],
- ['<', 'a.create_time', $end_time],
- ['=', 'a.order_status', 1]
- ];
- $getList = self::find()->select($select)
- ->from(self::tableName() . ' a')
- ->innerJoin(OrderContacts::tableName() . ' b', 'a.order_id = b.order_id')
- ->where($where)
- ->asArray()
- ->all();
- return $getList;
- }
-
- /**
- * Des:获取发送出行通知的 酒店订单
- * Name: getSendTravelTipsHotels
- * @return array
- * @author 倪宗锋
- */
- public function getSendTravelTipsHotels()
- {
- $date = date("Y-m-d", strtotime("+1 day"));
- $where = [
- 'and',
- ['in', 'a.order_status', [2, 3]],
- ['=', 'a.start_date', $date],
- ['=', 'a.category_id', 3],
- ['=', 'b.pay_type', 1]
- ];
- $select = [
- 'a.order_id',
- 'b.open_id',
- 'a.start_date',
- 'a.end_date',
- 'c.hotel_name',
- 'c.room_name'
- ];
- $getList = self::find()->select($select)
- ->from(static::tableName() . ' a')
- ->innerJoin(PayMain::tableName() . ' b', 'a.order_id = b.order_id')
- ->innerJoin(OrderHotelExtra::tableName() . ' c', 'a.order_id = c.main_order_id')
- ->where($where)
- ->asArray()
- ->all();
- if (empty($getList[0])) {
- return [];
- }
- return $getList;
- }
- }
|