| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace common\models\user;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%digital_log}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $user_id
- * @property string $change_type 操作类型:add-增加,sub-减少
- * @property float $change_num 操作数量
- * @property float $current_num 当前数量
- * @property string $desc 变动说明
- * @property string $source_table
- * @property int $source_table_id 操作来源业务id
- * @property string $from_type 来源类型
- * @property string $capital_type 资金类型
- * @property string $order_no 订单编号
- * @property string $contributor_name 名称
- * @property float $contributor_money 分佣金额
- * @property int $contributor_id 贡献者id
- * @property int $status 状态,-1:失效,1:正常
- * @property int $send_status 状态,-1:失效,1:正常,9:冻结
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- */
- class DigitalLog extends \common\models\base\BaseActiveRecord
- {
- const SEND_STATUS_INVALID = -1;
- const SEND_STATUS_NORMAL = 1;
- const SEND_STATUS_FROZEN = 9;
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%digital_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'source_table_id', 'contributor_id', 'status', 'created_at', 'updated_at','send_status'], 'integer'],
- [['change_num', 'current_num', 'contributor_money'], 'number'],
- [['change_type'], 'string', 'max' => 12],
- [['desc', 'source_table', 'from_type', 'capital_type', 'contributor_name'], 'string', 'max' => 255],
- [['order_no'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'change_type' => 'Change Type',
- 'change_num' => 'Change Num',
- 'current_num' => 'Current Num',
- 'desc' => 'Desc',
- 'source_table' => 'Source Table',
- 'source_table_id' => 'Source Table ID',
- 'from_type' => 'From Type',
- 'capital_type' => 'Capital Type',
- 'order_no' => 'Order No',
- 'contributor_name' => 'Contributor Name',
- 'contributor_money' => 'Contributor Money',
- 'contributor_id' => 'Contributor ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool|UserInfo
- */
- public static function setData(array $params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|