AddonsBossCommissionLog.php 3.2 KB

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