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.
 
 
 
 
 
 

114 lines
3.7 KiB

  1. <?php
  2. namespace backend\modules\hotel\models;
  3. use common\models\zModel;
  4. /**
  5. * This is the model class for table "order_comment".
  6. *
  7. * @property integer $ID
  8. * @property integer $ORDER_ID
  9. * @property integer $COMMENT_TYPE
  10. * @property string $COMMENT_TXT
  11. * @property integer $CANCEL_FLAG
  12. * @property integer $CREATE_USER_ID
  13. * @property string $CREATE_TIME
  14. * @property integer $UPDATE_USER_ID
  15. * @property string $UPDATE_TIME
  16. * @property integer $SPECIAL_FLAG
  17. */
  18. class OrderComment extends zModel
  19. {
  20. const TYPE_CANCEL_NOTE = 3; //对接取消原因
  21. const TYPE_INTERNAL = 0; //内部
  22. const TYPE_PUBLIC = 1; //外部
  23. const TYPE_UPDATE_REASON = 2;
  24. //特殊标记(用于渠道直连标记渠道的不同备注信息)
  25. //1:携程的订单备注
  26. const SPECIAL_FLAG_COMMENT = 1;
  27. // 2:携程订单的特殊要求
  28. const SPECIAL_FLAG_SERVICE = 1;
  29. // 3:携程订单的附加服务
  30. const SPECIAL_FLAG_EXTRA=3;
  31. /**
  32. * @inheritdoc
  33. */
  34. public static function tableName()
  35. {
  36. return 'order_comment';
  37. }
  38. /**
  39. * @inheritdoc
  40. */
  41. public function rules()
  42. {
  43. return [
  44. [['ORDER_ID'], 'required'],
  45. [['ORDER_ID', 'COMMENT_TYPE', 'CANCEL_FLAG', 'CREATE_USER_ID', 'UPDATE_USER_ID', 'SPECIAL_FLAG'], 'integer'],
  46. [['COMMENT_TXT'], 'string'],
  47. [['CREATE_TIME', 'UPDATE_TIME'], 'string', 'max' => 20],
  48. ];
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'ID' => 'ID',
  57. 'ORDER_ID' => '订单ID,ORDER_MAIN.ORDER_ID',
  58. 'COMMENT_TYPE' => '备注类型:0内部 1外部 2退改原因 3携程申请取消原因',
  59. 'COMMENT_TXT' => '备注内容',
  60. 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
  61. 'CREATE_USER_ID' => '记录创建用户ID',
  62. 'CREATE_TIME' => '记录创建时间',
  63. 'UPDATE_USER_ID' => '记录最后更新用户ID',
  64. 'UPDATE_TIME' => '记录最后更新时间',
  65. 'SPECIAL_FLAG' => '特殊标记(用于渠道直连标记渠道的不同备注信息)1:携程的订单备注 2:携程订单的特殊要求 3:携程订单的附加服务',
  66. ];
  67. }
  68. public function getUser()
  69. {
  70. return $this->hasOne(\common\models\User::className(), ['ID' => 'CREATE_USER_ID']);
  71. }
  72. /**
  73. * @Author wanglg
  74. * @Desc 获取订单备注内容
  75. * @param $order_id
  76. * @return array|\yii\db\ActiveRecord[]
  77. */
  78. public function getCommentList($order_id)
  79. {
  80. $query = OrderComment::find()
  81. ->select(['IF(COMMENT_TYPE=0,"内部备注","公共备注") as COMMENT_NAME', 'TRUE_NAME', 'COMMENT_TXT', 'a.CREATE_TIME'])
  82. ->joinWith('user', false)
  83. ->where(['ORDER_ID' => $order_id, 'COMMENT_TYPE' => [0, 1], 'a.CANCEL_FLAG' => 0])->from('order_comment a')
  84. // -> createCommand() -> getSql();
  85. ->asArray()->all();
  86. return $query;
  87. }
  88. /**
  89. * @Author wanglg
  90. * @Desc 获取供应商后台备注弹框,公共备注列表
  91. * @param $order_id
  92. * @return array|\yii\db\ActiveRecord[]
  93. */
  94. public function getPublicComment($order_id)
  95. {
  96. $query = OrderComment::find()
  97. ->select(['TRUE_NAME', 'COMMENT_TXT', 'a.CREATE_TIME'])
  98. ->joinWith('user', false)
  99. ->where(['ORDER_ID' => $order_id, 'COMMENT_TYPE' => 1, 'a.CANCEL_FLAG' => 0])->from('order_comment a')
  100. ->asArray()->all();
  101. return $query;
  102. }
  103. }