CloudStockDelayLog.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace addons\CloudStock\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_cloud_stock_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 $type 0:云库存默认的(货款佣金,奖励之类);1:云仓货款
  27. */
  28. class CloudStockDelayLog extends BaseActiveRecord
  29. {
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return '{{%addons_cloud_stock_delay_log}}';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['mall_id', 'wallet_type', 'capital_type', 'contributor_id'], 'required'],
  44. [['mall_id', 'user_id', 'compute_type', 'day_num', 'contributor_id', 'status', 'agented_at', 'created_at', 'updated_at','type'], 'integer'],
  45. [['wallet_num', 'contributor_money'], 'number'],
  46. [['wallet_type', 'capital_type'], 'string', 'max' => 64],
  47. [['wallet_desc', 'contributor_name'], 'string', 'max' => 255],
  48. [['order_no'], 'string', 'max' => 100],
  49. ];
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'mall_id' => '商城ID',
  59. 'user_id' => '用户ID',
  60. 'compute_type' => '结算方式, 0订单完成后,1订单支付后',
  61. 'wallet_type' => '资产类型',
  62. 'wallet_num' => '结算资产数量',
  63. 'day_num' => '延时天数',
  64. 'wallet_desc' => '资产变动说明',
  65. 'order_no' => '订单编号',
  66. 'capital_type' => '资金奖励类型',
  67. 'contributor_name' => '资产类型',
  68. 'contributor_money' => '分佣金额/手续费',
  69. 'contributor_id' => '贡献者id',
  70. 'status' => '状态,0未结算,1已结算',
  71. 'agented_at' => '结算时间',
  72. 'created_at' => '创建时间',
  73. 'updated_at' => '更新时间',
  74. ];
  75. }
  76. /**
  77. * @desc:关联会员信息
  78. * @Author: hua
  79. * @Date: 2022/1/18
  80. * @Time: 17:25
  81. * @Copyright: copyright (c) 2021 广东七件事集团
  82. * @return \yii\db\ActiveQuery
  83. */
  84. public function getUser(): \yii\db\ActiveQuery
  85. {
  86. return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,mobile,nickname,avatar_url');
  87. }
  88. public static function batchSave($data)
  89. {
  90. if (empty($data) || !is_array($data)) return false;
  91. foreach ($data as $item) {
  92. if (!is_array($item)) continue;
  93. $model = new self();
  94. foreach ($item as $k => $v) {
  95. $model->$k = $v;
  96. }
  97. $model->save();
  98. }
  99. return true;
  100. }
  101. }