You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "order_contacts".
  6. *
  7. * @property integer $id
  8. * @property integer $order_id
  9. * @property string $contacts_name
  10. * @property string $contacts_phone
  11. * @property string $contacts_ID
  12. * @property integer $contacts_type
  13. * @property string $update_time
  14. * @property string $create_time
  15. * @property integer $delete_flag
  16. * @property integer $bus_run_id
  17. */
  18. class OrderContacts extends \yii\db\ActiveRecord
  19. {
  20. /**
  21. * @inheritdoc
  22. */
  23. public static function tableName()
  24. {
  25. return 'order_contacts';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['order_id', 'contacts_name'], 'required'],
  34. [['order_id', 'contacts_type', 'delete_flag', 'bus_run_id'], 'integer'],
  35. [['update_time', 'create_time'], 'safe'],
  36. [['contacts_name'], 'string', 'max' => 120],
  37. [['contacts_phone', 'contacts_ID'], 'string', 'max' => 20],
  38. ];
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'order_id' => 'Order ID',
  48. 'contacts_name' => 'Contacts Name',
  49. 'contacts_phone' => 'Contacts Phone',
  50. 'contacts_ID' => 'Contacts ID',
  51. 'contacts_type' => 'Contacts Type',
  52. 'update_time' => 'Update Time',
  53. 'create_time' => 'Create Time',
  54. 'delete_flag' => 'Delete Flag',
  55. 'bus_run_id' => 'Bus Run ID',
  56. ];
  57. }
  58. /**
  59. * Function Description:插入联系人表
  60. * Function Name: insertContacts
  61. * @param $param_arr
  62. * @param $orderId
  63. *
  64. * @return bool
  65. *
  66. * @author 娄梦宁
  67. */
  68. public function insertContacts($param_arr, $orderId)
  69. {
  70. $values = [
  71. 'order_id' => $orderId,
  72. 'contacts_name' => $param_arr['contacts_name'],
  73. 'contacts_phone' => $param_arr['contacts_phone'],
  74. 'contacts_ID' => empty($param_arr['contacts_ID']) ? '' : $param_arr['contacts_ID'],
  75. 'bus_run_id' => empty($param_arr['run_id']) ? 0 : $param_arr['run_id'],
  76. 'create_time' => date('Y-m-d H:i:s'),
  77. ];
  78. $this->attributes = $values;
  79. $res = $this->insert();
  80. if (!$res) {
  81. return false;
  82. }
  83. return true;
  84. }
  85. /**
  86. * Des:获取订单拓展信息
  87. * Name: getRowByOrderId
  88. * @param $orderId
  89. * @return array
  90. * @author 倪宗锋
  91. */
  92. public function getRowByOrderId($orderId)
  93. {
  94. $where = ['and'];
  95. $where[] = ['=', 'order_id', $orderId];
  96. $where[] = ['=', 'contacts_type', 1];
  97. $return = $this->find()->select(['contacts_name', 'contacts_phone', 'contacts_ID', 'contacts_type', 'bus_run_id', 'order_id'])
  98. ->from(static::tableName())
  99. ->where($where)
  100. ->asArray(true)
  101. ->one();
  102. return $return;
  103. }
  104. /**
  105. * Des:获取保险数量
  106. * Name: getInsurance
  107. * @param $orderId
  108. * @return int
  109. * @author 倪宗锋
  110. */
  111. public function getInsuranceCnt($orderId)
  112. {
  113. $where = ['and'];
  114. $where[] = ['=', 'order_id', $orderId];
  115. $where[] = ['=', 'contacts_type', 2];
  116. $return = $this->find()->select(['contacts_name', 'contacts_phone', 'contacts_ID', 'contacts_type', 'bus_run_id', 'order_id'])
  117. ->from(static::tableName())
  118. ->where($where)
  119. ->asArray(true)
  120. ->count();
  121. return $return;
  122. }
  123. }