64], [['unionid'], 'string', 'max' => 255], [['platform'], 'string', 'max' => 45], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'user_id' => 'User ID', 'openid' => 'openid', 'unionid' => '用户所属平台的唯一标识', 'platform' => '平台名字:app:微信授权、wechat:公众号、mp-wx:小程序', 'platform_data' => '授权数据', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } /** * 保存数据 * @param array $params * @return bool|UserInfo */ public static function setData(array $params) { try { $model = new self(); $model->loadDefaultValues(); $params['platform_data'] = json_encode($params['platform_data'] ?? [], JSON_NUMERIC_CHECK); if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } /** * 获取会员中心的用户资产 * @Author: lun * @DateTime: 2021/11/15 0015 10:39 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $mall_id * @param $user_id * @param $capital */ public static function getCapital($mall_id, $user_id, $capital) { $capitalArr = Json::decode($capital, true); $wallet = UserWallet::getOne([['user_id' => $user_id]], true, [], false, 'score,balance,commission'); $data = []; foreach ($capitalArr as $code) { $value = 0; switch ($code) { case 'balance': case 'score': //2023-04-18 if($code == 'balance'){ //判断是否有卡券插件 if (MallAddons::isInstall($mall_id,AddonsEnum::ADDONS_NAME_CARD_COUPONS)) { $allMoney = CardCouponsScoreGive::find() ->where(['mall_id' => $mall_id, 'receive_user_id'=>$user_id,'is_active'=>CardCouponsScoreGive::ACTIVATED,'status'=>StatusEnum::ENABLED,'is_open'=>CardCouponsScoreGive::OPEN]) ->andWhere(['<=','start_at',time()]) ->andWhere(['>=','end_at',time()]) ->sum('can_use_money'); $wallet['balance'] = bcadd($wallet['balance'], $allMoney,2); } } //2023-04-18 $value = $wallet[$code] ?: 0; $title = Yii::$app->services->setting->mall->get($mall_id, "{$code}.{$code}_name"); $path[$code] = $code == 'balance' ? '/plugins/pages/assets/balance/index' : '/plugins/pages/assets/currency/index'; break; case 'commission': $value = $wallet[$code] ?: 0; $title = '分红'; $path[$code] = '/plugins/public/promotion/index'; break; case 'coupon': $value = 0; $coupon_where = "acu.end_time > " . time() . " and acu.status = " . StatusEnum::ENABLED . " and acu.user_id = " . $user_id . " and acu.is_use = 0 and acu.giving_status <> 2 and acu.is_force_failure = 0"; // $coupon_where .= " and ac.status=" . StatusEnum::ENABLED; $coupon_where .= " and acu.giving_status in (0,1) and acu.coupon_status not in (3, 4)"; // 过滤掉已失效和已过期优惠券 if (MallAddons::isInstall($mall_id,'Coupon')) { $count = AddonsCouponUserRelate::find() ->alias("acu") // ->rightJoin(AddonsCoupon::tableName() . ' as ac', 'ac.id = acu.coupon_id') ->select('id') ->where($coupon_where) ->count(); if($count) $value+=$count; } if(MallAddons::isInstall($mall_id,'Store')){ $coupon_where = "acu.end_time > " . time() . " and acu.status = " . StatusEnum::ENABLED . " and acu.user_id = " . $user_id . " and acu.is_use = 0 and acu.giving_status <> 2 and acu.is_force_failure = 0"; $coupon_where .= " and acu.giving_status in (0,1) and acu.coupon_status not in (3, 4)"; $count = StoreCouponUserRelate::find() ->alias("acu") // ->rightJoin(StoreCoupon::tableName() . ' as ac', 'ac.id = acu.coupon_id') ->select('id') ->where($coupon_where) ->count(); if($count) $value+=$count; } $title = '优惠券'; $path[$code] = '/plugins/pages/coupon/index'; break; case 'redpack': $redpack = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'Redpack', 'status' => StatusEnum::ENABLED]]); if ($redpack) { $value = 0; $redpack_wallet = RedpackWallet::getOne([['user_id' => $user_id, 'status' => StatusEnum::ENABLED]]); if ($redpack_wallet) { $value = bcadd($redpack_wallet['redpack'], $redpack_wallet['frozen_redpack'], 2); } } $redpack_name = Yii::$app->services->setting->addons->get($mall_id, 'Redpack', 'basic.redpack_name'); $title = empty($redpack_name) ? '红包' : $redpack_name; $path[$code] = '/plugins/Redpack/redEnvelopes'; break; case 'hi_bei': $higo = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'HiGo', 'status' => StatusEnum::ENABLED]]); if ($higo) { $value = 0; $higo_wallet = HigoWallet::getOne([['user_id' => $user_id]]); if ($higo_wallet) $value = bcmul($higo_wallet['hi_bei'], 1, 3); } $name = WalletLogic::getWalletTypeMsg($mall_id, 'hi_bei'); $title = $name ?? '嗨贝'; $path[$code] = '/plugins/HiGo/HiCurrency/index'; break; case 'score-expansion': $scoreExpansion = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'ScoreExpansion', 'status' => StatusEnum::ENABLED]]); if ($scoreExpansion) { $value = 0; $scoreExpansionWallet = ScoreExpansionWallet::getOne([['user_id' => $user_id]]); if ($scoreExpansionWallet) { $value = bcadd($scoreExpansionWallet['integral'], $scoreExpansionWallet['frozen_integral'], 2); } } $scoreExpansionName = Yii::$app->services->setting->addons->get($mall_id, 'ScoreExpansion', 'basic.integral_name'); $title = empty($scoreExpansionName) ? '积分拓客' : $scoreExpansionName; $path[$code] = '/plugins2/ScoreExpansion/redEnvelopes'; break; case 'contribution-currency': $ContributionCurrency = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'ContributionCurrency', 'status' => StatusEnum::ENABLED]]); if ($ContributionCurrency) { $value = 0; $ContributionCurrencyWallet = ContributionWallet::getOne([['user_id' => $user_id]]); if ($ContributionCurrencyWallet) { $value = $ContributionCurrencyWallet['contribution_value'] ?: 0; } } $title = '贡献值'; $path[$code] = '/plugins2/ContributionCurrency/index'; break; case 'nibao': case 'nibao_score': $nibao = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'NiBao', 'status' => StatusEnum::ENABLED]]); if ($nibao) { $value = 0; $nibao_wallet = NibaoWallet::getUserWalletValue($mall_id, $user_id); if ($nibao_wallet) $value = bcmul($nibao_wallet[$code], 1, 3); } $text_arr = NiBaoEnum::getWalletText($mall_id); $title = $text_arr[$code]; $path_arr = [ 'nibao' => '/plugins2/NiBao/index', 'nibao_score' => '/plugins2/NiBaoAchievement/GreenIntegrateList' ]; $path[$code] = $path_arr[$code]; break; case 'equity': $nibao_equity = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'NiBaoEquity', 'status' => StatusEnum::ENABLED]]); if ($nibao_equity) { $value = 0; $nibao_equity_wallet = NibaoEquityWallet::getOne([['user_id' => $user_id]]); if ($nibao_equity_wallet) $value = $nibao_equity_wallet[$code]; } $text_arr = NiBaoEquityEnum::getWalletText($mall_id); $title = $text_arr[$code]; $path[$code] = '/plugins2/NiBaoEquity/EquityList'; break; case 'energy_value': $energy_value = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'EnergyValue', 'status' => StatusEnum::ENABLED]]); if ($energy_value) { $energy_user_wallet_class = \addons\EnergyValue\common\services\WalletService::class; $value = $energy_user_wallet_class::getUserWallet($mall_id, $user_id); } $text_arr = EnergyValueEnum::getWalletText($mall_id); $title = $text_arr[$code]; $path[$code] = '/plugins2/EnergyValue/index'; break; case 'write_off': $WriteOff = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'WriteOff', 'status' => StatusEnum::ENABLED]]); if ($WriteOff) { $value = 0; $WriteOffMember = WriteOffMember::getOne([['user_id' => $user_id,'status' => StatusEnum::ENABLED]]); if ($WriteOffMember) { $value = $WriteOffMember['num'] ?: 0; } } $title = '核销码'; $path[$code] = '/plugins3/WWriteOff/check_code'; break; case 'digital': $user_digital = UserDigital::getOne([['mall_id' => $mall_id], ['user_id' => $user_id], ['status' => StatusEnum::ENABLED]], true, [], false, 'digital'); $value = $user_digital[$code] ?: 0; $title = Yii::$app->services->setting->mall->get($mall_id, "{$code}.name"); $path[$code] = '/plugins3/ContributionRelease/currency/list'; break; case 'devote_redpack': $redpack = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'Devote', 'status' => StatusEnum::ENABLED]]); if ($redpack) { $value = 0; /** @var \addons\Devote\common\models\DevoteWallet $devote_wallet_class */ $devote_wallet_class = \addons\Devote\common\models\DevoteWallet::class; $devote_wallet = $devote_wallet_class::getOne([['user_id' => $user_id]]); if ($devote_wallet) { $value = bcadd($devote_wallet['redpack'], $devote_wallet['frozen_redpack'], 2); } } $redpack_name = Yii::$app->services->setting->addons->get($mall_id, 'Devote', 'basic.redpack_name'); $title = empty($redpack_name) ? '红包' : $redpack_name; $path[$code] = '/plugins3/ContributionRelease/currency/digitalList'; break; case 'redeem_card': if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_REDEEM_CARD)) { $service = new UserService(); $value = $service->wallet($mall_id, $user_id); $title = $service->symbolName($mall_id); } $title = empty($title) ? '兑换卡' : $title; $path[$code] = "/plugins2/partnerDistributor/redemptionCard/redemptionCard"; break; case 'boss_shares': $BossWeightBonus = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'BossWeightBonus', 'status' => StatusEnum::ENABLED]]); if ($BossWeightBonus) { $value = 0; $BossShares = AddonsBossShares::getOne([['user_id' => $user_id,'status' => StatusEnum::ENABLED]]); if ($BossShares) { $value = $BossShares['shares_num'] ?: 0; } } $title = '股指'; $path[$code] = '/plugins3/BossWeightBonus/index'; break; case 'dividend_value_reward': // 分红值 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_DIVIDEND_VALUE_REWARD)) { $service = new \addons\DividendValueReward\common\service\UserService(); $value = $service->wallet($mall_id, $user_id); $title = $service->symbolName($mall_id); } $title = empty($title) ? '分红值' : $title; $path[$code] = "/plugins4/DividendValueReward/index"; break; case 'contribute_cy': case 'midou_cy': case 'gold_coin_cy': $title = ''; $page = ''; if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_FUN_TOWN)) { $serv = new \addons\FunTown\common\services\BackendService(); $value = $serv->getUserWallet($mall_id, $user_id, $code); $page_name = $serv->getWalletPageName($code); $title = $page_name['name']; $page = $page_name['page']; } $path[$code] = $page; break; case 'secondary_card': $title = '次卡'; $path[$code] = DiyEnum::SECONDARY_CARD_LIST; if (MallAddons::isInstall($mall_id, 'SecondaryCard')) { $count = \addons\SecondaryCard\common\models\SecondaryCardOrder::find()->where(['user_id'=>$user_id,'order_status'=>0]) ->andWhere(['>','open_time',0]) ->count(); if(!empty($count)) { $value = $count; } } break; case 'lvse': // 绿色积分 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('lvse',$mall_id, $user_id); $title = $service->get_capital_name('lvse',$mall_id); } $title = empty($title) ? '绿色积分' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=1"; break; case 'shengtai': // 生态积分 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('shengtai',$mall_id, $user_id); $title = $service->get_capital_name('shengtai',$mall_id); } $title = empty($title) ? '生态积分' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=2"; break; case 'gongxian': // 贡献值 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('gongxian',$mall_id, $user_id); $title = $service->get_capital_name('gongxian',$mall_id); } $title = empty($title) ? '贡献值' : $title; $path[$code] = "/plugins4/LoveMall/rights"; break; case 'gongyi': // 公益基金 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('gongyi',$mall_id, $user_id); $title = $service->get_capital_name('gongyi',$mall_id); } $title = empty($title) ? '公益基金' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=5"; break; case 'jintie': // 津贴券 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('jintie',$mall_id, $user_id); $title = $service->get_capital_name('jintie',$mall_id); } $title = empty($title) ? '津贴券' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=3"; break; case 'tongzheng': // 通证积分 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('tongzheng',$mall_id, $user_id); $title = $service->get_capital_name('tongzheng',$mall_id); } $title = empty($title) ? '通证积分' : $title; $path[$code] = "/plugins4/LoveMall/rights"; break; case 'tongzhengquan': // 通证券 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('tongzhengquan',$mall_id, $user_id); $title = $service->get_capital_name('tongzhengquan',$mall_id); } $title = empty($title) ? '通证券' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=4"; break; case 'qiquan': // 期权股 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_LOVE_MALL)) { $service = new \addons\LoveMall\common\service\CommonService(); $value = $service->get_capital_value('qiquan',$mall_id, $user_id); $title = $service->get_capital_name('qiquan',$mall_id); } $title = empty($title) ? '期权股' : $title; $path[$code] = "/plugins4/LoveMall/propertys?type=6"; break; case 'consumer_coupons': $consumer_coupons = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => 'ConsumerCoupons', 'status' => StatusEnum::ENABLED]]); if ($consumer_coupons) { $value = 0; $consumer_coupons_wallet = ConsumerCouponsWallet::getOne([['user_id' => $user_id]]); if ($consumer_coupons_wallet) { $value = bcadd($consumer_coupons_wallet['money'], $consumer_coupons_wallet['frozen_money'], 2); } } $consumer_coupons_name = Yii::$app->services->setting->addons->get($mall_id, 'ConsumerCoupons', 'basic.custom_name'); $title = empty($consumer_coupons_name) ? '消费券' : $consumer_coupons_name; $path[$code] = '/plugins4/ConsumerCoupons/index'; break; case 'drip': //分红池-酒滴 case 'bottle'://分红池-酒权 if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_BONUS_POOL)) { $configs = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_BONUS_POOL, 'basic'); if ($configs['is_enable'] == 1) { $bonus_pool_user_wallet = BonusPoolUserWallet::getOne([ ['mall_id' => $mall_id], ['user_id' => $user_id], ['status' => StatusEnum::ENABLED] ], true); $drip_name = $configs['bottle_name'] ? $configs['bottle_name']: '酒滴'; $bottle_name = $configs['bottle_other_name'] ? $configs['bottle_other_name']: '酒滴'; $title = $code == 'drip' ? $drip_name : $bottle_name; $value = $code == 'drip' ? $bonus_pool_user_wallet['drip'] : $bonus_pool_user_wallet['bottle']; $path[$code] = $code == 'drip' ? '/customAddons/BonusPool/currency?type=drip' : '/customAddons/BonusPool/currency?type=bottle'; } } break; case 'coin': $configs = \Yii::$app->services->setting->addons->get($mall_id, BottleCouponEnum::ADDONS_NAME, 'basic'); $title = $configs['coin_name'] ? $configs['coin_name'] : '金币'; if (MallAddons::isInstall($mall_id, 'BottleCoupon')) { $count = \addons\BottleCoupon\common\models\BottleCouponUserWallet::find()->where(['user_id'=>$user_id,'mall_id'=> $mall_id]) ->one(); if(!empty($count)) { $value = $count['coin']; } } $path[$code] = '/plugins/pages/assets/currency/index?home_type=coin'; break; case 'bottle_coupon': $configs = \Yii::$app->services->setting->addons->get($mall_id, BottleCouponEnum::ADDONS_NAME, 'basic'); $title = $configs['coupon_name'] ? $configs['coupon_name'] : '酒券'; if (MallAddons::isInstall($mall_id, 'BottleCoupon')) { $count = \addons\BottleCoupon\common\models\BottleCouponUserWallet::find()->where(['user_id'=>$user_id,'mall_id'=> $mall_id]) ->one(); if(!empty($count)) { $value = $count['coupon']; } } $path[$code] = '/plugins/pages/assets/currency/index?home_type=bottle_coupon'; break; case 'quota': $configs = \Yii::$app->services->setting->addons->get($mall_id, BottleCouponEnum::ADDONS_NAME, 'basic'); $title = $configs['quota_name'] ? $configs['quota_name'] : '酒券奖励'; if (MallAddons::isInstall($mall_id, 'BottleCoupon')) { $count = \addons\BottleCoupon\common\models\BottleCouponUserWallet::find()->where(['user_id'=>$user_id,'mall_id'=> $mall_id]) ->one(); if(!empty($count)) { $value = $count['quota']; } } $path[$code] = '/plugins/pages/assets/currency/index?home_type=quota'; break; case 'huidian': $configs = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_HUI_DIAN, 'basic'); $title = $configs['custom_name'] ?? '惠点'; if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_HUI_DIAN) && $configs['is_enable']) { $count = \addons\HuiDian\common\models\Huidian::find()->where(['user_id'=>$user_id, 'mall_id'=> $mall_id]) ->one(); if(!empty($count)) { $value = $count['amount']; } } $path[$code] = '/customAddons/HuiDianAssets/index'; break; case 'gold_bean': $configs = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_GOLD_BEAN, 'basic'); $title = $configs['custom_name'] ?? '金豆'; if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_NAME_GOLD_BEAN) && $configs['is_enable']) { $count = \addons\GoldBean\common\models\GoldBean::find()->where(['user_id'=>$user_id, 'mall_id'=> $mall_id]) ->one(); if(!empty($count)) { $value = $count['frozen_amount']; } } $path[$code] = '/customAddons/GoldBean/index'; break; case 'cost_score': case 'gold_score': case 'partner_score': case 'consumer_card': case 'score_secondary_card': case 'shop_score': $title = ''; $page = ''; if (MallAddons::isInstall($mall_id, AddonsEnum::ADDONS_SCORE_GAME)) { $serv = new \addons\ScoreGame\common\logic\UserLogic(); $user_wallet = $serv->getUserWallet($mall_id, $user_id, $code); if(!$user_wallet['is_show']) break; $value = $user_wallet['num']; $title = $user_wallet['name']; $page = $user_wallet['page']; } $path[$code] = $page; break; case 'zhaike_score': //宅客体脂秤-门店积分 $title = '门店积分'; if (MallAddons::isInstall($mall_id, 'ZhaiKe')) { $count = \addons\ZhaiKe\common\models\ZhaiKeUserWallet::find()->where(['user_id'=>$user_id,'mall_id'=> $mall_id]) ->select('id,user_id,sum(score) as total_score')->groupBy('user_id')->all(); if(!empty($count)) { $value = $count[0]['total_score']; } } $path[$code] = '/customAddons/BodyFatScale/store-score/index'; break; case 'grain_num': $configs = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_PUB_METHOD, 'basic'); $title = $configs['grain_name'] ? $configs['grain_name'] : '酒粮'; if (MallAddons::isInstall($mall_id, 'PubMethod')) { $count = \addons\PubMethod\common\models\PubMethodUser::find()->where(['user_id' => $user_id, 'mall_id' => $mall_id]) ->one(); if(!empty($count)) { $value = $count['grain_num']; } } $path[$code] = '/customAddons2/PubMethod/pubMethodDetails'; break; case 'drinks_num': $configs = \Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_PUB_METHOD, 'basic'); $title = $configs['drinks_name'] ? $configs['drinks_name'] : '酒水'; if (MallAddons::isInstall($mall_id, 'PubMethod')) { $count = \addons\PubMethod\common\models\PubMethodUser::find()->where(['user_id' => $user_id, 'mall_id' => $mall_id]) ->one(); if(!empty($count)) { $value = $count['drinks_num']; } } $path[$code] = '/customAddons2/PubMethod/pubMethodDetails'; break; case 'frozen-perk-asset': $FrozenPerkAsset = MallAddons::getOne([['mall_id' => $mall_id, 'addons_name' => AddonsEnum::ADDONS_NAME_FROZEN_PERK_ASSET, 'status' => StatusEnum::ENABLED]]); if ($FrozenPerkAsset) { $value = 0; $AssetWallet = FrozenPerkAsset::getOne([['user_id' => $user_id],['mall_id' => $mall_id],['status' => StatusEnum::ENABLED]]); if ($AssetWallet) { $value = $AssetWallet['frozen_money']; } } $AssetName = Yii::$app->services->setting->addons->get($mall_id, AddonsEnum::ADDONS_NAME_FROZEN_PERK_ASSET, 'basic.asset_name'); $title = empty($AssetName) ? '冻结补贴' : $AssetName; $path[$code] = '/customAddons2/FrozenPerkAsset/index'; break; } if(isset($path[$code])){ $data[] = ['code' => $code, 'route' => $path[$code], 'title' => $title, 'value' => empty($value) ? 0 : $value]; } } return $data; } public static function getExtraCapital($user_id, $data){ $commission = 0; $func = function ($user_id){ $wallet = UserWallet::getOne([['user_id' => $user_id]], true, [], false, 'commission'); return $wallet['commission'] ?? 0; }; if(isset($data['capital']) && !empty($data['capital'])) { $tmp_capital = array_column($data['capital'], 'value', 'code'); if(isset($tmp_capital['commission'])){ $commission = $tmp_capital['commission']; }else{ $commission = $func($user_id); } }else{ $commission = $func($user_id);; } return compact('commission'); } public static function getExtraLevel($mall_id,$user_id, $code){ $data = []; if (MallAddons::isInstall($mall_id, $code) == 0) return $data; switch ($code) { case AddonsEnum::ADDONS_NAME_AGENT: $agent = Agent::getOne([['user_id' => $user_id], ['status' => [StatusEnum::DISABLED, StatusEnum::ENABLED]]], true, ['agentLevel']); $data['level_name'] = $agent['agentLevel']['name'] ?? '默认等级'; $data['level'] = $agent['agentLevel']['level']; break; case AddonsEnum::ADDONS_NAME_AGENT_BASE: $agent = AgentBase::getOne([['user_id' => $user_id], ['status' => [StatusEnum::DISABLED, StatusEnum::ENABLED]]], true, ['agentLevel']); $data['level_name'] = $agent['agentLevel']['name'] ?? '默认等级'; $data['level'] = $agent['agentLevel']['level']; break; } return $data; } /** * 清除用户公众号及小程序授权 * * @param $mallId * @param $userId * @param $platform * * @return void */ public static function clearAuth($mallId, $userId = 0, $platform = '') { $where = ['mall_id' => $mallId]; if (!$platform) { $where['platform'] = ['mp-wx', 'wechat']; } else { $where['platform'] = $platform; } if ($userId) { $where['user_id'] = $userId; } self::updateAll(['status' => -1], $where); // 清除登录授权信息 $where['status'] = -1; $user_ids = self::find()->select('user_id')->where($where)->column(); while (count($user_ids) > 0) { $user_id = array_shift($user_ids); $token = AccessToken::findOne(['user_id' => $user_id]); if (!empty($token)) { \Yii::$app->services->apiAccessToken->disableByAccessToken($token->access_token); } } } }