Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

113 rader
3.6 KiB

  1. <?php
  2. namespace backend\modules\api\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "opera_tickets_distrib".
  6. *
  7. * @property integer $ID
  8. * @property integer $CREATE_USER_ID
  9. * @property string $CREATE_TIME
  10. * @property integer $UPDATE_USER_ID
  11. * @property string $UPDATE_TIME
  12. * @property integer $CANCEL_FLAG
  13. * @property integer $LINE_ID
  14. * @property integer $TICKET_ID
  15. * @property integer $SUPPLIER_ID
  16. * @property integer $SALE_TYPE
  17. * @property integer $COMMISION_FLAG
  18. * @property integer $COMMISION_TYPE
  19. * @property integer $BACK_COMMISION_TYPE
  20. * @property integer $BACK_COMMISION_METHOD
  21. * @property string $BACK_PERCENT
  22. * @property string $BACK_VALUE
  23. * @property string $PROD_PRICE
  24. * @property integer $AUTHORITY_STATUS
  25. */
  26. class OperaTicketsDistrib extends \yii\db\ActiveRecord
  27. {
  28. /**
  29. * @inheritdoc
  30. */
  31. public static function tableName()
  32. {
  33. return 'opera_tickets_distrib';
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function rules()
  39. {
  40. return [
  41. [['CREATE_USER_ID', 'UPDATE_USER_ID', 'CANCEL_FLAG', 'LINE_ID', 'TICKET_ID', 'SUPPLIER_ID', 'SALE_TYPE', 'COMMISION_FLAG', 'COMMISION_TYPE', 'BACK_COMMISION_TYPE', 'BACK_COMMISION_METHOD', 'AUTHORITY_STATUS'], 'integer'],
  42. [['CREATE_TIME'], 'required'],
  43. [['UPDATE_TIME'], 'safe'],
  44. [['BACK_PERCENT', 'BACK_VALUE', 'PROD_PRICE'], 'number'],
  45. [['CREATE_TIME'], 'string', 'max' => 20],
  46. ];
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function attributeLabels()
  52. {
  53. return [
  54. 'ID' => 'ID',
  55. 'CREATE_USER_ID' => '记录创建用户ID',
  56. 'CREATE_TIME' => '记录创建时间',
  57. 'UPDATE_USER_ID' => '记录最后更新用户ID',
  58. 'UPDATE_TIME' => '记录最后更新时间',
  59. 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
  60. 'LINE_ID' => '线路ID',
  61. 'TICKET_ID' => '票种ID',
  62. 'SUPPLIER_ID' => '渠道商ID,对应BASE_SUPPLIER.ID',
  63. 'SALE_TYPE' => '销售方式,对应DICT_TYPE.ID',
  64. 'COMMISION_FLAG' => '是否有佣金规则,1:有,0:无',
  65. 'COMMISION_TYPE' => '佣金类别,渠道定义或产品定义,对应DICT_TYPE.ID',
  66. 'BACK_COMMISION_TYPE' => '返佣类别,固定返佣,对应DICT_TYPE.ID',
  67. 'BACK_COMMISION_METHOD' => '返佣方式,按销售或按结算,对应DICT_TYPE.ID',
  68. 'BACK_PERCENT' => '返佣比例',
  69. 'BACK_VALUE' => '返佣固定金额',
  70. 'PROD_PRICE' => '分销价',
  71. 'AUTHORITY_STATUS' => '授权状态 0:关 1:开',
  72. ];
  73. }
  74. /**
  75. * Function Description:通过userid获取可售卖票种
  76. * Function Name: getUnsellTicketListByUserId
  77. * @param array $ticket_id_arr 票种id数组
  78. * @param int $user_id 用户id
  79. *
  80. * @return array|\yii\db\ActiveRecord[]
  81. *
  82. * @author Redstop
  83. */
  84. public function getUnsellTicketListByUserId( $user_id )
  85. {
  86. $sql_where = [
  87. 'and',
  88. ['=', 't.cancel_flag', 0],
  89. ['=', 't.authority_status', 0],
  90. ['=', 'u.id', $user_id],
  91. ];
  92. $result = self::find()
  93. ->select([
  94. 'ticket_id' => 't.ticket_id',//票种ID
  95. ])
  96. ->from(self::tableName() . ' as t')
  97. ->innerJoin(BaseUser::tableName() . ' as u', 't.supplier_id = u.org_id')
  98. ->where($sql_where)
  99. ->indexBy('ticket_id')
  100. ->asArray()->all();
  101. return $result;
  102. }
  103. }