StoreBossCommissionLog.php 3.1 KB

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