HappinessCommissionLog.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use common\models\user\User;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_happiness_commission_log".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户ID
  10. * @property float $money 获得佣金
  11. * @property int $status
  12. * @property int $commission_status 状态:0 未结算 1 已结算 2 已到账 3 已取消
  13. * @property int $commission_type 佣金类型: 0 分享收益 1 锁定收益 2 推广收益 3 代理收益
  14. * @property int $mall_id
  15. * @property int $agent_id 来源代理user_id
  16. * @property string $order_no
  17. * @property int $order_id
  18. * @property int $remark
  19. * @property float $order_money 获得佣金
  20. * @property int $send_time 延迟发放时间
  21. * @property int $store_id
  22. * @property int $created_at
  23. * @property int $updated_at
  24. */
  25. class HappinessCommissionLog extends \common\models\base\BaseActiveRecord
  26. {
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public static function tableName()
  31. {
  32. return 'qimall_addons_happiness_commission_log';
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['user_id', 'status', 'commission_status', 'mall_id','agent_id','store_id', 'order_id', 'send_time', 'created_at', 'updated_at','send_time'], 'integer'],
  41. [['money','order_money'], 'number'],
  42. [['order_no','commission_type'], 'string', 'max' => 255],
  43. [['remark'], 'string'],
  44. ];
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function attributeLabels()
  50. {
  51. return [
  52. 'id' => 'ID',
  53. 'user_id' => 'User ID',
  54. 'money' => 'Money',
  55. 'status' => 'Status',
  56. 'store_id' => 'Store ID',
  57. 'commission_status' => 'Commission Status',
  58. 'commission_type' => 'Commission Type',
  59. 'mall_id' => 'Mall ID',
  60. 'agent_id' => 'Agent ID',
  61. 'order_no' => 'Order No',
  62. 'order_id' => 'Order ID',
  63. 'order_money' => 'Order Money',
  64. 'send_time' => 'Send Time',
  65. 'remark' => 'Remark',
  66. 'created_at' => 'Created At',
  67. 'updated_at' => 'Updated At',
  68. ];
  69. }
  70. public function getUser()
  71. {
  72. return $this->hasOne(User::class, ['id' => 'user_id']);
  73. }
  74. public function getStore()
  75. {
  76. return $this->hasOne(HappinessStore::class, ['id' => 'store_id']);
  77. }
  78. public static function setData($params)
  79. {
  80. try {
  81. if (isset($params['id']) && !empty($params['id']))
  82. $model = self::findOne($params['id']);
  83. else {
  84. $model = new self();
  85. $model->loadDefaultValues();
  86. }
  87. if (!$model->load($params, '') || !$model->save()) {
  88. throw new \Exception($model->getErrorMessage());
  89. }
  90. return $model;
  91. } catch (\Exception $e) {
  92. self::$static_error = $e->getMessage();
  93. return false;
  94. }
  95. }
  96. }