Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

116 řádky
2.7 KiB

  1. <?php
  2. namespace backend\modules\api\models;
  3. use backend\modules\api\util\Util;
  4. use common\models\Msg;
  5. use yii\base\Exception;
  6. use yii\db\ActiveRecord;
  7. use Yii;
  8. use yii\db\Expression;
  9. /**
  10. * This is the model class for table "order_insurance_connect".
  11. *
  12. * @property integer $id
  13. * @property integer $main_order_id
  14. * @property integer $insurance_order_id
  15. * @property string $create_time
  16. */
  17. class OrderInsuranceConnect extends \yii\db\ActiveRecord
  18. {
  19. /**
  20. * @inheritdoc
  21. */
  22. public static function tableName()
  23. {
  24. return 'order_insurance_connect';
  25. }
  26. /**
  27. * @inheritdoc
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['main_order_id', 'insurance_order_id'], 'integer'],
  33. [['create_time'], 'safe'],
  34. ];
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'main_order_id' => 'Main Order ID',
  44. 'insurance_order_id' => 'Insurance Order ID',
  45. 'create_time' => 'Create Time',
  46. ];
  47. }
  48. /**
  49. * ���ݶ����Ų�ѯ��ʿ�����Ƿ��������
  50. * @param $order_id
  51. * @return array
  52. */
  53. public function getOneInfo($order_id)
  54. {
  55. try {
  56. $result = self::find()
  57. ->from(self::tableName())
  58. ->where([
  59. 'OR',
  60. ['=', 'MAIN_ORDER_ID', $order_id],
  61. ['=', 'INSURANCE_ORDER_ID', $order_id]
  62. ])->asArray()->all();
  63. } catch (Exception $e) {
  64. $result = null;
  65. }
  66. return $result;
  67. }
  68. /**
  69. * Des:添加新记录
  70. * Name: addOne
  71. * @param $insuranceDate
  72. * @return int
  73. * @author 倪宗锋
  74. */
  75. public function addOne($insuranceDate)
  76. {
  77. $values = [
  78. 'create_time' => date('Y-m-d H:i:s'),
  79. 'main_order_id' => $insuranceDate['main_order_id'],
  80. 'insurance_order_id' => $insuranceDate['insurance_order_id'],
  81. ];
  82. $this->attributes = $values;
  83. $res = $this->insert();
  84. if ($res == false) {
  85. return 0;
  86. }
  87. return $this->id;
  88. }
  89. /**
  90. * Function Description:根据主订单id 查出关联的保险id
  91. * Function Name: GetInsuranceOrderId
  92. * @param $order_main_id
  93. *
  94. * @return array|ActiveRecord[]
  95. *
  96. * @author 娄梦宁
  97. */
  98. public function GetInsuranceOrderId($order_main_id)
  99. {
  100. $result=self::find()->select('insurance_order_id')
  101. ->from(self::tableName())
  102. ->where(['main_order_id'=>$order_main_id])
  103. ->asArray()
  104. ->all();
  105. return $result;
  106. }
  107. }