| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace addons\HiGo\common\models;
- use addons\HiGo\common\enums\HiGoEnum;
- use common\models\user\User;
- use common\enums\StatusEnum;
- use Yii;
- use Exception;
- /**
- * 嗨呗/嗨值钱包等待处理记录表【订单在走模式发放奖励时:先写入该表,后面结算再写入wallet_log 表】
- * This is the model class for table "{{%qimall_addons_higo_wallet_frozen_log}}".
- *
- * @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 来源插件:默认HiGo
- * @property int $is_send
- * @property string $setting
- */
- class HigoWalletFrozenLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_higo_wallet_frozen_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'source_table_id', 'status', 'created_at', 'updated_at','is_send'], 'integer'],
- [['change_num', 'after_num'], 'number'],
- [['wallet_type'], 'string', 'max' => 20],
- [['change_type'], 'string', 'max' => 12],
- [['addon_name'], 'string', 'max' => 64],
- [['desc', 'source_table', 'from_type'], 'string', 'max' => 255],
- [['setting'],'string']
- ];
- }
- /**
- * {@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',
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool
- */
- 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;
- }
- }
- /**
- * 检测奖励是否发放过
- * @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)
- {
- $log = self::findOne(['mall_id' => $mall_id,'user_id' => $user_id,'wallet_type' => $wallet_type,
- 'change_type' => 'add','source_table' => $source_table,'source_table_id' => $source_id,'from_type' => $from_type,
- 'status' => StatusEnum::ENABLED,
- 'addon_name' => $addons_name
- ]);
- return $log;
- }
- }
|