StoreMerchantReduceProfit.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\models\user\User;
  4. /**
  5. * This is the model class for table "qimall_addons_store_merchant_reduce_profit".
  6. *
  7. * @property int $id
  8. * @property int $mall_id 商城ID
  9. * @property string $source 来源,插件名称
  10. * @property string $audit_remark 来源,插件名称
  11. * @property int $source_id 来源id
  12. * @property int $status 状态[-1:删除;0:禁用;1启用]
  13. * @property int $created_at
  14. * @property int $updated_at
  15. * @property int $user_id
  16. * @property int $audit_status
  17. * @property int $admins_id
  18. * @property int $audit_at
  19. * @property float $rate 让利比例
  20. */
  21. class StoreMerchantReduceProfit extends \common\models\base\BaseActiveRecord
  22. {
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return 'qimall_addons_store_merchant_reduce_profit';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['mall_id'], 'required'],
  37. [['mall_id', 'source_id', 'status', 'created_at', 'updated_at', 'user_id', 'audit_status', 'admins_id', 'audit_at'], 'integer'],
  38. [['rate'], 'number'],
  39. [['source'], 'string', 'max' => 30],
  40. [['audit_remark'], 'string', 'max' => 1000],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'ID',
  50. 'mall_id' => 'Mall ID',
  51. 'source' => 'Source',
  52. 'source_id' => 'Source ID',
  53. 'status' => 'Status',
  54. 'created_at' => 'Created At',
  55. 'updated_at' => 'Updated At',
  56. 'rate' => 'Rate',
  57. ];
  58. }
  59. public function getStore()
  60. {
  61. return $this->hasOne(Store::class, ['id' => 'source_id']);
  62. }
  63. public function getUser()
  64. {
  65. return $this->hasOne(User::class, ['id' => 'user_id']);
  66. }
  67. /**
  68. * @return StoreMerchantReduceProfit|mixed|string|null
  69. */
  70. public static function setData(int $mall_id, int $user_id, string $source, int $source_id, float $rate)
  71. {
  72. $model = new self();
  73. $model->mall_id = $mall_id;
  74. $model->source = $source;
  75. $model->source_id = $source_id;
  76. $model->rate = $rate;
  77. $model->user_id = $user_id;
  78. if (!$model->save()) return $model->getErrorMessage();
  79. return $model;
  80. }
  81. }