|
- <?php
-
- namespace backend\modules\api\models;
-
- use backend\modules\api\util\Util;
- use common\models\Msg;
- use yii\base\Exception;
- use yii\db\ActiveRecord;
- use Yii;
- use yii\db\Expression;
-
- /**
- * This is the model class for table "order_insurance_connect".
- *
- * @property integer $id
- * @property integer $main_order_id
- * @property integer $insurance_order_id
- * @property string $create_time
- */
- class OrderInsuranceConnect extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'order_insurance_connect';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['main_order_id', 'insurance_order_id'], 'integer'],
- [['create_time'], 'safe'],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'main_order_id' => 'Main Order ID',
- 'insurance_order_id' => 'Insurance Order ID',
- 'create_time' => 'Create Time',
- ];
- }
-
- /**
- * ���ݶ����Ų�ѯ��ʿ�����Ƿ��������
- * @param $order_id
- * @return array
- */
- public function getOneInfo($order_id)
- {
- try {
- $result = self::find()
- ->from(self::tableName())
- ->where([
- 'OR',
- ['=', 'MAIN_ORDER_ID', $order_id],
- ['=', 'INSURANCE_ORDER_ID', $order_id]
- ])->asArray()->all();
- } catch (Exception $e) {
- $result = null;
- }
- return $result;
- }
-
- /**
- * Des:添加新记录
- * Name: addOne
- * @param $insuranceDate
- * @return int
- * @author 倪宗锋
- */
- public function addOne($insuranceDate)
- {
- $values = [
- 'create_time' => date('Y-m-d H:i:s'),
- 'main_order_id' => $insuranceDate['main_order_id'],
- 'insurance_order_id' => $insuranceDate['insurance_order_id'],
- ];
- $this->attributes = $values;
- $res = $this->insert();
- if ($res == false) {
- return 0;
- }
- return $this->id;
- }
-
- /**
- * Function Description:根据主订单id 查出关联的保险id
- * Function Name: GetInsuranceOrderId
- * @param $order_main_id
- *
- * @return array|ActiveRecord[]
- *
- * @author 娄梦宁
- */
- public function GetInsuranceOrderId($order_main_id)
- {
- $result=self::find()->select('insurance_order_id')
- ->from(self::tableName())
- ->where(['main_order_id'=>$order_main_id])
- ->asArray()
- ->all();
- return $result;
- }
- }
|