HappinessStoreCommission.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_store_commission".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $store_id 门店id
  11. * @property int $user_id 会员id
  12. * @property string $order_no 订单编号
  13. * @property float $order_money 订单金额
  14. * @property float $pay_money 支付金额
  15. * @property float $discount_money 优惠金额
  16. * @property float $service_charge 服务费
  17. * @property float $amount_received 实际货款收益金额
  18. * @property float $store_scale 货款收益比例
  19. * @property float $all_commission 总佣金,订单金额*货款收益比例
  20. * @property float $share_commission 用户分享收益
  21. * @property float $store_share_commission 店主分享收益
  22. * @property int $type 订单类型,1线上订单,2收款码订单
  23. * @property int $is_settlement 结算状态 0:待结算;1:已结算
  24. * @property int $created_at
  25. * @property int $updated_at
  26. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  27. * @property int $settle_type 分佣1,2,3平台承担,4门店承担
  28. */
  29. class HappinessStoreCommission extends \common\models\base\BaseActiveRecord
  30. {
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public static function tableName()
  35. {
  36. return 'qimall_addons_happiness_store_commission';
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function rules()
  42. {
  43. return [
  44. [['mall_id', 'store_id', 'user_id', 'is_settlement', 'created_at', 'updated_at', 'status', 'settle_type', 'platform_ratio','type'], 'integer'],
  45. [['order_money', 'pay_money', 'discount_money', 'service_charge', 'amount_received', 'score_money','store_scale', 'all_commission', 'share_commission', 'store_share_commission'], 'number'],
  46. [['order_no'], 'string', 'max' => 100],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => 'ID',
  56. 'mall_id' => 'Mall ID',
  57. 'store_id' => 'Store ID',
  58. 'user_id' => 'User ID',
  59. 'order_no' => 'Order No',
  60. 'order_money' => 'Order Money',
  61. 'pay_money' => 'Pay Money',
  62. 'discount_money' => 'Discount Money',
  63. 'service_charge' => 'Service Charge',
  64. 'amount_received' => 'Amount Received',
  65. 'is_settlement' => 'Is Settlement',
  66. 'created_at' => 'Created At',
  67. 'updated_at' => 'Updated At',
  68. 'status' => 'Status',
  69. 'settle_type' => 'Settle Type',
  70. 'type' => 'Type No',
  71. 'all_commission' => 'All Commission',
  72. 'share_commission' => 'Share Commission',
  73. 'store_share_commission' => 'Store Share Commission',
  74. 'store_scale' => 'Store Scale'
  75. ];
  76. }
  77. public function getUser() {
  78. return $this->hasOne(User::class, ['id' => 'user_id']);
  79. }
  80. public static function setData(array $params)
  81. {
  82. try {
  83. if (!empty($params['mall_id']) && !empty($params['id'])) {
  84. $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id']]);
  85. if (empty($model)) {
  86. $model = new self();
  87. $model->loadDefaultValues();
  88. }
  89. } else {
  90. $model = new self();
  91. $model->loadDefaultValues();
  92. }
  93. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  94. if (!$model->save()) throw new \Exception($model->getErrorMessage());
  95. return $model;
  96. } catch (\Exception $e) {
  97. self::$static_error = $e->getMessage();
  98. return false;
  99. }
  100. }
  101. }