| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace addons\Happiness\common\models;
- use common\models\user\User;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_happiness_store_commission".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $store_id 门店id
- * @property int $user_id 会员id
- * @property string $order_no 订单编号
- * @property float $order_money 订单金额
- * @property float $pay_money 支付金额
- * @property float $discount_money 优惠金额
- * @property float $service_charge 服务费
- * @property float $amount_received 实际货款收益金额
- * @property float $store_scale 货款收益比例
- * @property float $all_commission 总佣金,订单金额*货款收益比例
- * @property float $share_commission 用户分享收益
- * @property float $store_share_commission 店主分享收益
- * @property int $type 订单类型,1线上订单,2收款码订单
- * @property int $is_settlement 结算状态 0:待结算;1:已结算
- * @property int $created_at
- * @property int $updated_at
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $settle_type 分佣1,2,3平台承担,4门店承担
- */
- class HappinessStoreCommission extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_happiness_store_commission';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'user_id', 'is_settlement', 'created_at', 'updated_at', 'status', 'settle_type', 'platform_ratio','type'], 'integer'],
- [['order_money', 'pay_money', 'discount_money', 'service_charge', 'amount_received', 'score_money','store_scale', 'all_commission', 'share_commission', 'store_share_commission'], 'number'],
- [['order_no'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => 'Store ID',
- 'user_id' => 'User ID',
- 'order_no' => 'Order No',
- 'order_money' => 'Order Money',
- 'pay_money' => 'Pay Money',
- 'discount_money' => 'Discount Money',
- 'service_charge' => 'Service Charge',
- 'amount_received' => 'Amount Received',
- 'is_settlement' => 'Is Settlement',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'status' => 'Status',
- 'settle_type' => 'Settle Type',
- 'type' => 'Type No',
- 'all_commission' => 'All Commission',
- 'share_commission' => 'Share Commission',
- 'store_share_commission' => 'Store Share Commission',
- 'store_scale' => 'Store Scale'
- ];
- }
- public function getUser() {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['mall_id']) && !empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id']]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- }
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|