| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace addons\HiGo\common\models;
- use addons\HiGo\common\enums\HiGoEnum;
- use common\enums\StatusEnum;
- use common\models\common\CapitalLog;
- use Yii;
- use Exception;
- /**
- * This is the model class for table "{{%addons_higo_wallet_freeze_log}}".
- * 嗨呗/嗨值钱包冻结记录表,对应wallet表中freeze字段
- * @property int $id
- * @property int $mall_id
- * @property int $user_id
- * @property string $wallet_type 类型[hi_bei:嗨呗,hi_value:嗨值]
- * @property string $change_type 操作类型:add-增加,sub-减少
- * @property float $change_num 操作数量
- * @property float $after_num 变动后数量
- * @property string $desc 变动说明
- * @property string $source_table 来源表
- * @property int $source_table_id 操作来源业务id
- * @property string $from_type 来源类型
- * @property int $status 状态:0:未结算,1:已结算,-1:无效
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- * @property string $addon_name 来源插件名称
- */
- class HigoWalletFreezeLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_higo_wallet_freeze_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'source_table_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['change_num', 'after_num'], 'number'],
- [['wallet_type'], 'string', 'max' => 20],
- [['change_type'], 'string', 'max' => 12],
- [['desc', 'source_table', 'from_type'], 'string', 'max' => 255],
- [['addon_name'], 'string', 'max' => 64],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'wallet_type' => 'Wallet Type',
- 'change_type' => 'Change Type',
- 'change_num' => 'Change Num',
- 'after_num' => 'After Num',
- 'desc' => 'Desc',
- 'source_table' => 'Source Table',
- 'source_table_id' => 'Source Table ID',
- 'from_type' => 'From Type',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'addon_name' => 'Addon Name',
- ];
- }
- /**
- * 检测奖励是否发放过
- * @param $mall_id
- * @param $user_id
- * @param $source_table
- * @param $source_id
- * @param $from_type
- * @param $wallet_type
- * @param $addons_name
- * @return HigoWalletLog|null
- */
- public static function checkSend($mall_id, $user_id, $source_table, $source_id, $from_type, $wallet_type,$addons_name = HiGoEnum::ADDONS_NAME)
- {
- return self::findOne(['mall_id' => $mall_id,'user_id' => $user_id,'wallet_type' => $wallet_type,
- 'change_type' => CapitalLog::CHANGE_TYPE_ADD,'source_table' => $source_table,'source_table_id' => $source_id,
- 'from_type' => $from_type,'status' => StatusEnum::ENABLED,
- 'addon_name' => $addons_name
- ]);
- }
- /**
- * 保存数据
- * @param array $params
- * @return boolean|self
- */
- 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;
- }
- }
- }
|