| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace addons\CircleDistribution\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- /**
- * This is the model class for table "qimall_addons_circle_distribution_reward_config_log".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property string $source_table 来源表
- * @property int $source_table_id 来源表id
- * @property string $type 积分:score;佣金:commission
- * @property string $from_type 来源类型
- * @property string|null $basic_config 基础配置
- * @property string|null $reward_config 会员相关奖励配置
- * @property string|null $goods_config 商品独立配置
- * @property string|null $relation_ship 关系链等级
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- * @property int $user_id 发放佣金对应的用户ID
- * @property int $sequence 订单顺序,排序号
- * @property int $need_repurchase 是否需要复购
- */
- class DistributionCommissionBasisLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_circle_distribution_commission_basis_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'source_table_id', 'status', 'created_at', 'updated_at','user_id','sequence'], 'integer'],
- [['type'], 'required'],
- [['basic_config', 'reward_config', 'goods_config'], 'string'],
- [['source_table', 'type', 'from_type'], 'string', 'max' => 255],
- [['relation_ship'], 'string', 'max' => 2000],
- [['need_repurchase'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'source_table' => '来源表',
- 'source_table_id' => '来源表id',
- 'type' => '积分:score;佣金:commission',
- 'from_type' => '来源类型',
- 'basic_config' => '基础配置',
- 'reward_config' => '等级配置',
- 'goods_config' => '商品独立配置',
- 'relation_ship' => '关系链等级',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- /**
- * @desc:保存数据
- * @Author: hua
- * @Date: 2022/11/18
- * @Time: 14:11
- * @Copyright: copyright (c) 2022 广东七件事集团
- * @param array $params
- * @return DistributionCommissionBasisLog|false
- */
- public static function setData(array $params)
- {
- try {
- $model = self::findOne(['mall_id' => $params['mall_id'],
- 'source_table_id' => $params['source_table_id'],
- 'source_table' => $params['source_table'],
- 'type' => $params['type'],
- 'from_type' => $params['from_type'],
- 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (!empty($model)) return $model;
- $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;
- }
- }
- }
|