'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'amount' => 'Amount', 'from' => 'From', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'type' => 'Type', ]; } /** * 保存数据 * @param array $params * @return bool|UserWallet */ public static function setData(array $params) { try { if (!empty($params['user_id'])) { $model = self::findOne(['user_id' => $params['user_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED], 'type' => $params['type']]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } else { if (empty($model)) throw new Exception('用户尚未注册,请先注册'); } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } public static function resetCashAmount($params){ $user_id = $params['user_id']; $mall_id = $params['mall_id']; $payment = \Yii::$app->services->setting->mall->get($mall_id, 'withdraw_income'); if(!empty($payment["withdraws_limit_enable"])){ $withdraws_limit_money = isset($payment["withdraws_limit_money"]) ? $payment["withdraws_limit_money"] : 0; $withdrawsLimitLog = self::findOne(['user_id' => $user_id, 'status' => StatusEnum::ENABLED,'from'=>1, 'type' => self::COMMON_LIMIT]); if(!empty($withdrawsLimitLog)){ $withdrawsLimitLog->amount = $withdraws_limit_money; if(!$withdrawsLimitLog->save()){ \Yii::error('提现额度保存失败,user_id:'.$user_id); return false; } } if (!empty($payment['is_independent_balance_withdraw'])) { $withdraws_limit_money = $payment["independent_balance_withdraw_max_amount"] ?? 0; $withdrawsLimitLog = self::findOne(['user_id' => $user_id, 'status' => StatusEnum::ENABLED,'from'=>1, 'type' => self::BALANCE_LIMIT]); if(!empty($withdrawsLimitLog)){ $withdrawsLimitLog->amount = $withdraws_limit_money; if(!$withdrawsLimitLog->save()){ \Yii::error('提现额度保存失败,user_id:'.$user_id); return false; } } } } return true; } /** * 根据配置如果开启了 提现余额限额 则type=1 * * @param int $mallId * @param string $withdrawType * @param array $setting * * @return int */ public static function getType(int $mallId, string $withdrawType, array $setting = []): int { if ($withdrawType !== 'balance') { return self::COMMON_LIMIT; } if (empty($setting)) { $setting = \Yii::$app->services->setting->mall->get($mallId, 'withdraw_income'); } return !empty($setting['withdraws_limit_enable']) && !empty($setting['is_independent_balance_withdraw']) ? self::BALANCE_LIMIT : self::COMMON_LIMIT; } }