SplitbillItem.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace addons\YunfastPay\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_yunfast_pay_splitbill_item}}".
  6. *
  7. * @property int $id
  8. * @property int $mall_id
  9. * @property int $log_id 分账记录ID
  10. * @property int $store_id 店铺ID
  11. * @property float $amount 分账金额
  12. * @property string|null $role 分账角色
  13. * @property string|null $mcht_cd 接收方商户号
  14. * @property int|null $fee_party 手续费承担方,只能有一方承担,是 0:否,1:是,部分通道不支持
  15. * @property int $updated_at
  16. * @property int $created_at
  17. */
  18. class SplitbillItem extends ActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addons_yunfast_pay_splitbill_item}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'log_id', 'store_id'], 'required'],
  34. [['mall_id', 'log_id', 'store_id', 'fee_party', 'updated_at', 'created_at'], 'integer'],
  35. [['amount'], 'number'],
  36. [['role', 'mcht_cd'], 'string', 'max' => 32],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'mall_id' => 'Mall ID',
  47. 'log_id' => 'Log ID',
  48. 'store_id' => 'Store ID',
  49. 'amount' => 'Amount',
  50. 'role' => 'Role',
  51. 'mcht_cd' => 'Mcht Cd',
  52. 'fee_party' => 'Fee Party',
  53. 'updated_at' => 'Updated At',
  54. 'created_at' => 'Created At',
  55. ];
  56. }
  57. /**
  58. * @param integer $id
  59. * @return static|null
  60. */
  61. public static function getLogById(int $id)
  62. {
  63. return static::find()
  64. ->where(['id' => $id])
  65. ->one();
  66. }
  67. /**
  68. * 是否有代付订单
  69. *
  70. * @return boolean
  71. */
  72. public function hasAgentOrder()
  73. {
  74. return !empty(AgentOrder::find()
  75. ->where(['withdraw_id' => $this->id])
  76. ->select('id')
  77. ->one())
  78. ? true
  79. : false;
  80. }
  81. }