AgentDelayLog.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace addons\Agent\common\models;
  3. use common\models\user\User;
  4. use Yii;
  5. use common\models\base\BaseActiveRecord;
  6. /**
  7. * This is the model class for table "{{%addons_agent_delay_log}}".
  8. *
  9. * @property int $id
  10. * @property int $mall_id 商城ID
  11. * @property int $user_id 用户ID
  12. * @property int $compute_type 结算方式, 0订单完成后,1订单支付后
  13. * @property string $wallet_type 资产类型
  14. * @property float $wallet_num 结算资产数量
  15. * @property int $day_num 延时天数
  16. * @property string|null $wallet_desc 资产变动说明
  17. * @property string|null $order_no 订单编号
  18. * @property string $capital_type 资金奖励类型
  19. * @property string|null $contributor_name 资产类型
  20. * @property float|null $contributor_money 分佣金额/手续费
  21. * @property int $contributor_id 贡献者id
  22. * @property int $status 状态,0未结算,1已结算
  23. * @property int $agented_at 结算时间
  24. * @property int $created_at 创建时间
  25. * @property int $updated_at 更新时间
  26. * @property int $source_table_id 来源表id
  27. * @property string $source_table 来源表
  28. */
  29. class AgentDelayLog extends BaseActiveRecord
  30. {
  31. const WALLET_TYPES = [
  32. 'commission' => '佣金',
  33. 'score' => '积分',
  34. 'digital' => '数字币'
  35. ];
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public static function tableName()
  40. {
  41. return '{{%addons_agent_delay_log}}';
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function rules()
  47. {
  48. return [
  49. [['mall_id', 'wallet_type', 'capital_type', 'contributor_id'], 'required'],
  50. [['mall_id', 'user_id', 'compute_type', 'day_num', 'contributor_id', 'status', 'agented_at', 'created_at', 'updated_at', 'source_table_id'], 'integer'],
  51. [['wallet_num', 'contributor_money'], 'number'],
  52. [['wallet_type', 'capital_type'], 'string', 'max' => 64],
  53. [['wallet_desc', 'contributor_name'], 'string', 'max' => 255],
  54. [['source_table'], 'string', 'max' => 100],
  55. [['order_no'], 'string', 'max' => 100],
  56. ];
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function attributeLabels()
  62. {
  63. return [
  64. 'id' => 'ID',
  65. 'mall_id' => '商城ID',
  66. 'user_id' => '用户ID',
  67. 'compute_type' => '结算方式, 0订单完成后,1订单支付后',
  68. 'wallet_type' => '资产类型',
  69. 'wallet_num' => '结算资产数量',
  70. 'day_num' => '延时天数',
  71. 'wallet_desc' => '资产变动说明',
  72. 'order_no' => '订单编号',
  73. 'capital_type' => '资金奖励类型',
  74. 'contributor_name' => '资产类型',
  75. 'contributor_money' => '分佣金额/手续费',
  76. 'contributor_id' => '贡献者id',
  77. 'status' => '状态,0未结算,1已结算',
  78. 'agented_at' => '结算时间',
  79. 'created_at' => '创建时间',
  80. 'updated_at' => '更新时间',
  81. ];
  82. }
  83. /**
  84. * @desc:关联会员信息
  85. * @Author: hua
  86. * @Date: 2022/1/18
  87. * @Time: 17:25
  88. * @Copyright: copyright (c) 2021 广东七件事集团
  89. * @return \yii\db\ActiveQuery
  90. */
  91. public function getUser(): \yii\db\ActiveQuery
  92. {
  93. return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,mobile,nickname,avatar_url');
  94. }
  95. public static function batchSave($data)
  96. {
  97. if (empty($data) || !is_array($data)) return false;
  98. foreach ($data as $item) {
  99. if (!is_array($item)) continue;
  100. $model = new self();
  101. foreach ($item as $k => $v) {
  102. $model->$k = $v;
  103. }
  104. $model->save();
  105. }
  106. return true;
  107. }
  108. }