AddonsBossCommissionLog.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace addons\Boss\common\models;
  3. use common\enums\StatusEnum;
  4. use common\models\user\User;
  5. use Yii;
  6. /**
  7. * This is the model class for table "{{%addons_boss_commission_log}}".
  8. *
  9. * @property int $id
  10. * @property int $mall_id 商城ID
  11. * @property int $user_id 用户ID
  12. * @property float $amounts 结算总金额,单位:元
  13. * @property float $commission 永久/额外佣金,单位:元
  14. * @property float $sedimen_money 沉淀池金额,单位:元
  15. * @property int $type 奖励类型:1永久分红,2额外分红,3股东奖励
  16. * @property int $compute_period 结算周期:1天,2周,3月
  17. * @property int $start_time 结算开始日期
  18. * @property int $end_time 结算开始日期
  19. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  20. * @property int $created_at
  21. * @property int $updated_at
  22. * @property string $from_type
  23. */
  24. class AddonsBossCommissionLog extends \common\models\base\BaseActiveRecord
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return '{{%addons_boss_commission_log}}';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['mall_id', 'user_id', 'type', 'compute_period', 'start_time', 'end_time', 'status', 'created_at', 'updated_at'], 'integer'],
  40. [['amounts', 'commission', 'revenue','sedimen_money'], 'number'],
  41. [['from_type'], 'string', 'max' => 50]
  42. ];
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'ID',
  51. 'mall_id' => '商城ID',
  52. 'user_id' => '用户ID',
  53. 'amounts' => '结算总金额,单位:元',
  54. 'commission' => '永久/额外佣金,单位:元',
  55. 'revenue' => '本期营业额,单位:元',
  56. 'sedimen_money' => '沉淀池金额,单位:元',
  57. 'type' => '奖励类型:1永久分红,2额外分红,3股东奖励',
  58. 'compute_period' => '结算周期:1天,2周,3月',
  59. 'start_time' => '结算开始日期',
  60. 'end_time' => '结算开始日期',
  61. 'status' => '状态[-1:删除;0:禁用;1启用]',
  62. 'created_at' => 'Created At',
  63. 'updated_at' => 'Updated At',
  64. ];
  65. }
  66. public function getUser()
  67. {
  68. return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,nickname,mobile,username,avatar_url');
  69. }
  70. /**
  71. * 获取分红
  72. * @Author: lun
  73. * @DateTime: 2021/11/6 0006 11:53
  74. * @Copyright: copyright (c) 2021 广东七件事集团
  75. * @param array $cond
  76. * @param array $with
  77. * @param bool $is_array
  78. * @param string $select
  79. * @param string $order
  80. * @return array|\yii\db\ActiveRecord[]
  81. */
  82. public static function getBossCommissionLog(array $cond=[], array $with=[],bool $is_array=true,string $select='*',$order=""){
  83. $default_cond = [['<>','status',StatusEnum::DELETE]];
  84. $cond = array_merge($default_cond,$cond);
  85. $query = self::find()->select($select);
  86. self::paramPack(['where'=>$cond, 'with'=>$with],$query);
  87. isset($order) && $query->orderBy($order);
  88. $data = $query->asArray($is_array)->all();
  89. return $data;
  90. }
  91. }