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.
 
 
 
 
 
 

84 lines
2.4 KiB

  1. <?php
  2. namespace backend\modules\hotel\models;
  3. use backend\modules\api\models\BaseUser;
  4. use Yii;
  5. /**
  6. * This is the model class for table "base_supplier_purchase".
  7. *
  8. * @property integer $ID
  9. * @property integer $CREATE_USER_ID
  10. * @property string $CREATE_TIME
  11. * @property integer $UPDATE_USER_ID
  12. * @property string $UPDATE_TIME
  13. * @property integer $CANCEL_FLAG
  14. * @property integer $SUPPLIER_ID
  15. * @property integer $PRODUCT_TYPE
  16. * @property string $PURCHASER_NAME
  17. */
  18. class BaseSupplierPurchase extends \yii\db\ActiveRecord
  19. {
  20. /**
  21. * @inheritdoc
  22. */
  23. public static function tableName()
  24. {
  25. return 'base_supplier_purchase';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['CREATE_USER_ID', 'UPDATE_USER_ID', 'CANCEL_FLAG', 'SUPPLIER_ID', 'PRODUCT_TYPE'], 'integer'],
  34. [['CREATE_TIME'], 'required'],
  35. [['UPDATE_TIME'], 'safe'],
  36. [['CREATE_TIME', 'PURCHASER_NAME'], 'string', 'max' => 20],
  37. ];
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'ID' => 'ID',
  46. 'CREATE_USER_ID' => '记录创建用户ID',
  47. 'CREATE_TIME' => '记录创建时间',
  48. 'UPDATE_USER_ID' => '记录最后更新用户ID',
  49. 'UPDATE_TIME' => '记录最后更新时间',
  50. 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
  51. 'SUPPLIER_ID' => '供应商或渠道商ID,对应BASE_SUPPLIER.ID',
  52. 'PRODUCT_TYPE' => '采购产品类别',
  53. 'PURCHASER_NAME' => '采购人',
  54. ];
  55. }
  56. public function getBaseUser()
  57. {
  58. return $this->hasOne(BaseUser::className(), ['ID' => 'PURCHASER_NAME']);
  59. }
  60. /**
  61. * @Author wanglg
  62. * @Desc 获取酒店采购负责人信息
  63. * @param $s_id供应商id
  64. * @return array|\yii\db\ActiveRecord[]
  65. */
  66. public function getPurchaseName($s_id)
  67. {
  68. $res = BaseSupplierPurchase::find()
  69. -> select(['b.ID', 'b.TRUE_NAME'])
  70. -> joinWith('baseUser as b')
  71. -> from('base_supplier_purchase a')
  72. -> where(['a.CANCEL_FLAG' => 0, 'a.SUPPLIER_ID' => $s_id, 'b.CANCEL_FLAG' => 0, 'a.PRODUCT_TYPE' => 25])
  73. -> groupBy('b.ID') -> asArray() -> all();
  74. return $res;
  75. }
  76. }