| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace addons\SalesCompany\common\models;
- use Yii;
- use common\models\base\BaseActiveRecord;
- use common\enums\StatusEnum;
- /**
- * This is the model class for table "{{%addons_sales_company_commission_log}}".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property string $source_table 来源表
- * @property int $source_table_id 来源表id
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- * @property float $total_money 总金额,单位:元
- * @property int $user_id 用户ID
- * @property float $money 实际到账金额,单位:元
- * @property float $rate 平台抽佣比例
- */
- class CommissionLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_sales_company_commission_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'source_table_id', 'status', 'created_at', 'updated_at', 'user_id','is_frozen','agent_user_id','num'], 'integer'],
- [['total_money', 'money', 'rate','unit_goods_price'], 'number'],
- [['source_table','desc'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'source_table' => 'Source Table',
- 'source_table_id' => 'Source Table ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'total_money' => 'Total Money',
- 'user_id' => 'User ID',
- 'money' => 'Money',
- 'rate' => 'Rate',
- 'is_frozen' => 'Is Frozen',
- 'agent_user_id' => 'agent_user_id',
- 'desc' => 'desc',
- 'unit_goods_price' => 'unit_goods_price',
- 'num' => 'num',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new \Exception('数据不存在或已删除');
- } 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;
- }
- }
- }
|