| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654 |
- <?php
- namespace api\modules\v1\controllers\user;
- use addons\AlipayMiniInvite\common\events\InviteOldUserRewardEvent;
- use addons\Area\common\models\AreaCommunity;
- use addons\FunTown\common\helper\GameAsyncHelper;
- use addons\Recharge\common\models\AddonsRechargeActive;
- use addons\Store\common\models\Store;
- use addons\Store\common\models\StoreCollect;
- use addons\Store\common\models\StoreGoods;
- use api\controllers\OnAuthController;
- use api\services\WechatUserService;
- use common\enums\AddonsEnum;
- use common\enums\MemberLabelEnum;
- use common\enums\RabbitMqEnum;
- use common\enums\StatusEnum;
- use common\enums\UserWalletEnum;
- use common\events\user\UserModifyPayPwdEvent;
- use common\events\user\UserModifyPwdEvent;
- use common\events\user\UserUpdateEvent;
- use common\events\user\UserPositionChangeEvent;
- use common\globals\GlobalInvoke;
- use common\helpers\ApiCode;
- use common\helpers\sms\Sms;
- use common\logic\memberLabel\MemberLabelLogic;
- use common\models\common\BalanceLog;
- use common\models\common\CapitalLog;
- use common\models\common\GlobalVarMap;
- use common\models\common\MallSetting;
- use common\models\common\Region;
- use common\models\common\UserBankCard;
- use common\models\common\UserThirdPartyAddress;
- use common\models\goods\Goods;
- use common\models\goods\GoodsCollect;
- use common\models\mall\MallAddons;
- use common\models\statistics\UserStatisticsTotal;
- use common\models\user\MemberBenefit;
- use common\models\user\Town;
- use common\models\user\User;
- use common\models\user\UserAddress;
- use common\models\user\UserExtra;
- use common\models\user\UserFollow;
- use common\models\user\UserLevel;
- use common\models\user\UserInfo;
- use common\models\user\UserInviteCode;
- use common\models\user\UserLevelExpired;
- use common\models\user\UserPartitionRelationship;
- use common\models\user\UserSignAgreement;
- use common\models\user\UserTeamStatistics;
- use common\models\user\UserWallet;
- use common\models\user\UserWithdrawLog;
- use common\enums\PayTypeEnum;
- use common\helpers\DateHelper;
- use common\models\user\BalanceRechargeLog;
- use common\helpers\LockHelper;
- use common\models\user\UserFreezeCommission;
- use common\models\user\UserTeamProfitStatistics;
- use Yii;
- use yii\db\Exception;
- use yii\db\Expression;
- class UserController extends OnAuthController
- {
- public $modelClass = '';
- /**
- *
- * 不用进行登录验证的方法
- *
- * 例如: ['index', 'update', 'create', 'view', 'delete']
- * 默认全部需要验证
- *
- * @var array
- */
- protected $authOptional = ['login', 'mobile-login', 'sms-code', 'register', 'up-pwd','user-agree','visit', 'is-subscribe', 'address-info', 'update-user-position', 'user-info'];
- /**
- * 获取用户基本加额外信息
- * @return array|mixed
- */
- public function actionUserInfo()
- {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [[['capital','extra','level_sel'], 'safe']]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- if (empty($this->user_id)) return $this->success('请登录', ['is_login' => false]);
- $info = \Yii::$app->services->apiAccessToken->getTokenToCache($this->access_token, '');
- $user_level_arr = UserLevel::getUserLevelList($this->mall_id, 'id, name, pic_url, level');
- $data['user_id'] = empty($this->user_id) ? 0 : $this->user_id;
- $data['nickname'] = empty($info->user->nickname) ? '' : $info->user->nickname;
- $data['username'] = empty($info->user->username) ? '' : $info->user->username;
- $data['avatar_url'] = empty($info->user->avatar_url) ? '' : $info->user->avatar_url;
- $data['mobile'] = empty($info->user->mobile) ? '' : $info->user->mobile;
- $data['level_name'] = empty($user_level_arr[$info->user->level]['name']) ? MallSetting::getDefaultLevelName($this->mall_id) : $user_level_arr[$info->user->level]['name'];
- $data['level_pic_url'] = empty($user_level_arr[$info->user->level]['pic_url']) ? '' : $user_level_arr[$info->user->level]['pic_url'];
- $data['level'] = empty($info->user->level) ? 0 : $info->user->level;
- $data['tag'] = [];
- // 用户资产
- if (!empty($params['capital']) && !empty($this->user_id)) {
- $data['capital'] = UserInfo::getCapital($this->mall_id, $this->user_id, $params['capital']);
- }
- $data['extra_capital'] = UserInfo::getExtraCapital($this->user_id, $data);
- // 个人资料
- if (!empty($params['extra']) && !empty($this->user_id)) {
- $extra = UserExtra::getUserExtra($this->user_id);
- if ($extra == false) return $this->error(UserExtra::getStaticError());
- $extra['address'] = trim($extra['province'] .' '.$extra['city'] .' '.$extra['area']);
- $data = array_merge($data,$extra);
- }
- // 是否显示个人主页
- $personal_home_addons = MallAddons::getPersonalHomeAddons($this->mall_id,array_keys(AddonsEnum::getPersonalHomeAddonsMap()));
- $is_show_personal_home = !empty($personal_home_addons);
- $data['is_show_personal_home'] = $is_show_personal_home;
- if($is_show_personal_home){
- $extra = UserExtra::getUserExtra($this->user_id);
- $data['personal_home']['personal_home_bg'] = $extra['personal_home_bg'] ?? '';
- $data['personal_home']['personal_signature'] = $extra['personal_signature'] ?? '';
- }
- $data['third_party_address'] = '';
- $third_party_address = UserThirdPartyAddress::getOne([['mall_id' => $this->mall_id], ['user_id' => $this->user_id], ['status' => StatusEnum::ENABLED]], true, [], false, 'third_party_address');
- $data['third_party_address'] = $third_party_address['third_party_address'] ?? $data['third_party_address'];
- $data['invite_code'] = '';
- $relation_setting = \Yii::$app->services->setting->mall->get($this->mall_id, 'user_relation_setting.relation_setting');
- $setting = [];
- if (!empty($relation_setting)) $setting = json_decode($relation_setting, true);
- if(isset($setting['status']) && $setting['status'] == 1){
- if($setting['become_child_way'] == 5){
- $data['invite_code'] = UserInviteCode::find()->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]])->select('code')->scalar() ?? '';
- }
- }
- $model_s = UserTeamStatistics::findOne(['user_id'=>$this->user_id,'status'=>StatusEnum::ENABLED]);
- $data['user_direct'] =$model_s['user_direct_total']??0;
- $data['is_bind_popups'] = UserPartitionRelationship::getIsNeedPopups($this->mall_id, $this->user_id ?? 0);
- // 判断用户接收验证码的手机号是新还是旧手机号
- $is_accept_mobile_code = Yii::$app->services->setting->mall->get($this->mall_id, 'user.is_accept_mobile_code');
- $data['is_accept_mobile_code'] = !empty($is_accept_mobile_code) ? $is_accept_mobile_code : 0;
- $data['is_show_reserve_order_toolbar'] = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_RESERVATION_SERVICE) ||
- MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_HOME_MAKING) ?
- StatusEnum::ENABLED : StatusEnum::DISABLED;
- $parent = [];
- if(!empty($this->user['parent_id'])){
- $parent = User::getOne([['id'=>$this->user['parent_id']]],true,[],false,'id,nickname,avatar_url,mobile');
- }
- $data['parent'] = $parent;
- // 返回过期时间
- $data['is_show_user_level_expired_at'] = (bool)Yii::$app->services->setting->mall->get($this->mall_id, 'user.is_show_user_level_expired_at');
- if ($data['is_show_user_level_expired_at']) {
- // 查询是否有过期时间
- $user_level_expired_at = UserLevelExpired::find()
- ->select('expired_at')
- ->where(['user_id' => $this->user_id, 'level' => $this->user->level, 'status' => StatusEnum::ENABLED])
- ->orderBy('id desc')
- ->scalar();
- $data['user_level_expired_at'] = $user_level_expired_at ? date('Y-m-d', $user_level_expired_at) : null;
- }
- // 用户插件身份
- if (!empty($params['level_sel']) && !empty($this->user_id)) {
- $data['level_sel'] = UserInfo::getExtraLevel($this->mall_id, $this->user_id, $params['level_sel']);
- }
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $data);
- }
- /**
- * 个人主页
- * @Author bing
- * @DateTime 2021-12-23 17:34:28
- * @copyright: Copyright (c) 2020 广东七件事集团
- * @return void
- */
- public function actionPersonalHome(){
- if (\Yii::$app->request->isGet) {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['user_id','type'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $data['personal_home_addons'] = MallAddons::getPersonalHomeAddons($this->mall_id,array_keys(AddonsEnum::getPersonalHomeAddonsMap()));
- //把指定得插件放到第一位
- if($data['personal_home_addons']) {
- $select_key = '';
- foreach ($data['personal_home_addons'] as $k => $v){
- if($params['type'] == $v){
- $select_key = $k;
- }
- }
- if($select_key>0){
- $data['personal_home_addons'][$select_key] = $data['personal_home_addons'][0];
- $data['personal_home_addons'][0] = $params['type'];
- }
- }
- if(empty($data['personal_home_addons'])) return $this->error('相关插件未安装或已禁用');
- $data['personal_home_addons_map'] = AddonsEnum::getPersonalHomeAddonsMap();
- //统计我关注的人数
- $user_id = $params['user_id'] ? $params['user_id']:$this->user_id;
- $userextra = UserExtra::getOne([['user_id' => $user_id]],true,['user']);
- $data['follow_count'] = $userextra['follow_count'] ? $userextra['follow_count']:0;
- $data['fans_count'] = $userextra['fans_count'] ? $userextra['fans_count']:0;
- $data['personal_home_bg'] = $userextra['personal_home_bg']?$userextra['personal_home_bg']:'';
- $data['personal_signature'] = $userextra['personal_signature']?$userextra['personal_signature']:'';
- $data['user']['username'] = $userextra['user']['username'];
- $data['user']['nickname'] = $userextra['user']['nickname'];
- $data['user']['avatar_url'] = $userextra['user']['avatar_url'];
- $follow = UserFollow::getOne([['follow_id' => $params['user_id']],['user_id' => $this->user_id]]);
- if($follow && $follow['status'] == StatusEnum::ENABLED) {
- $data['user']['is_follow'] = 1;
- }else{
- $data['user']['is_follow'] = 0;
- }
- return $this->success(ApiCode::CODE_SUCCESS_TITLE,$data);
- }
- }
- /**
- * @Author: ltm
- * @DateTime: 2021/12/24 0024 9:31
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return bool
- */
- public function actionEditPersonalHome(){
- if (\Yii::$app->request->isPost) {
- try {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['personal_home_bg','personal_signature'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $model = UserExtra::findOne(['user_id' => $this->user_id]);
- $params = UserExtra::exceptNullVal($params);//去除参数的空
- if($params['personal_home_bg']) $model->personal_home_bg = $params['personal_home_bg'];
- if($params['personal_signature']) $model->personal_signature = $params['personal_signature'];
- if(!$model->save()){
- throw new Exception($model->getErrorMessage());
- }
- if ($model === false) return $this->error(UserInfo::getStaticError());
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- /**
- * 设置支付密码
- * @return mixed|void
- */
- public function actionSetTransactionPassword()
- {
- try {
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['mobile', 'captcha', 'password', 'confirm_password'], 'required'],
- // ['mobile', 'match', 'pattern' => '/^1\d{10}$/', 'message' => '请输入正确的手机号码'],
- [['mobile'], 'integer'],
- ['password', 'string', 'length' => [6, 11]],
- ['confirm_password', 'compare', 'compareAttribute' => 'password', 'message' => '两次密码不一致'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $user = $this->user;
- if($user['mobile']!=$params['mobile']) return $this->error('请输入绑定的手机号码');
- //短信验证码
- if (YII_ENV == 'prod') {
- if (!Sms::checkValidateCode($params['mobile'], $params['captcha'],Sms::SMS_TYPE_UPDATE_PAY_PASS)) return $this->error('验证码不正确');
- }
- $user->transaction_password = Yii::$app->getSecurity()->generatePasswordHash($params['password']);
- if ($user->save() === false) return $this->error(User::getStaticError());
- $event = new UserModifyPayPwdEvent($this->mall_id);
- Yii::$app->services->events->dispatch($event, [
- 'operator_user_id' => $this->user_id,
- 'mobile' => $user->mobile,
- 'new_pwd' => trim($params['password']),
- 'user_id' => $this->user_id,
- 'mall_id' => $this->mall_id
- ], $event->listeners);
- return $this->success('设置成功');
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 设置登录密码
- * @return mixed|void
- */
- public function actionSetLoginPassword()
- {
- try {
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['mobile', 'captcha', 'password', 'confirm_password'], 'required'],
- // ['mobile', 'match', 'pattern' => '/^1\d{10}$/', 'message' => '请输入正确的手机号码'],
- [['mobile'], 'integer'],
- ['password', 'string', 'length' => [6, 11]],
- ['confirm_password', 'compare', 'compareAttribute' => 'password', 'message' => '两次密码不一致'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $user = $this->user;
- if($user['mobile']!=$params['mobile']) return $this->error('请输入绑定的手机号码');
- //短信验证码
- if (YII_ENV == 'prod') {
- if (!Sms::checkValidateCode($params['mobile'], $params['captcha'],Sms::SMS_TYPE_UPDATE_PASS)) return $this->error('验证码不正确');
- }
- $user->password = Yii::$app->getSecurity()->generatePasswordHash(trim($params['password']));
- if ($user->save() === false) return $this->error(User::getStaticError());
- $event = new UserModifyPwdEvent($this->mall_id);
- Yii::$app->services->events->dispatch($event, [
- 'operator_user_id' => $this->user_id,
- 'mobile' => $user->mobile,
- 'new_pwd' => trim($params['password']),
- 'user_id' => $this->user_id,
- 'mall_id' => $this->mall_id
- ], $event->listeners);
- return $this->success('设置成功');
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 设置收货地址
- * @return mixed|void
- */
- public function actionUserAddressSave()
- {
- try {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['province'], 'required', 'message' => '省份不能为空'],
- [['city'], 'required', 'message' => '城市不能为空'],
- [['district'], 'required', 'message' => '区县不能为空'],
- [['detail'], 'required', 'message' => '详细地址不能为空'],
- [['mobile'], 'required', 'message' => '手机号码不能为空'],
- [['name'], 'required', 'message' => '收货人不能为空'],
- ['name', 'string', 'length' => [2, 10]],
- // ['mobile', 'match', 'pattern' => '/^1\d{10}$/', 'message' => '请输入正确的手机号码'],
- [['id', 'is_default','town','town_id','province_id','city_id','district_id', 'community_id'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['user_id'] = $this->user_id;
- if(empty($params['province_id'])&&!empty($params['province'])){
- $region = Region::findOne(['name'=>$params['province'],'level'=>1]);
- if(empty($region)) return $this->error('查无该省份');
- $params['province_id'] = $region['id'];
- }
- $order_config = \Yii::$app->services->setting->mall->get($this->mall_id, 'order');
- if (isset($order_config['limit_multi_province']) && $order_config['limit_multi_province']) {
- $user_address_list = UserAddress::lists([
- 'where' => [
- ['user_id' => $this->user_id],
- ['status' => StatusEnum::ENABLED]
- ],
- 'select' => 'province_id'
- ]);
- $address_province_ids = array_column($user_address_list, 'province_id') ?? [];
- $address_province_ids = array_unique($address_province_ids);
- $count = count($address_province_ids);
- if($count > 1){
- return $this->error('不可添加多个省份的地址,请确认~');
- }elseif($count == 1 && $address_province_ids[0] != $params['province_id']){
- return $this->error('不可添加多个省份的地址,请确认~');
- }
- }
- if(empty($params['city_id'])){
- if(empty($params['city'])) return $this->error('请填写城市');
- $region = Region::findOne(['name'=>$params['city'],'level'=>2]);
- if(empty($region)) return $this->error('查无该城市');
- $parent_region = Region::findOne(['id'=> $region['parent_id']]);
- $params['province'] = $parent_region['name'];
- $params['province_id'] = $region['parent_id'];
- $params['city_id'] = $region['id'];
- }
- if(empty($params['district_id'])&&!empty($params['district'])){
- $region = Region::findOne(['name'=>$params['district'],'level'=>3,'parent_id'=>$params['city_id']]);
- if(empty($region)) return $this->error('查无该区');
- $params['district_id'] = $region['id'];
- }
- // 是否有提交小区
- if (!empty($params['community_id'])) {
- $params['community'] = AreaCommunity::find()->where(['id' => $params['community_id']])
- ->andWhere(['status' => StatusEnum::ENABLED])->select('community_name')->scalar();
- if (empty($params['community'])) {
- return $this->error('查无该小区');
- }
- }
- $orderConfig = \Yii::$app->services->setting->mall->get($this->mall_id, 'order');
- // 必须在有第四级的情况下才需要校验
- if ($orderConfig['is_town'] && !$params['town'] &&
- !empty(Town::find()->where(['district_id' => $params['district_id']])->count())) throw new Exception('收货地址缺少镇乡');
- $params['detail'] = (string)$params['detail'];
- $address_str = $params['province'] . $params['city'] . $params['district'] . $params['town'] . $params['detail'];
- $result_data = \common\helpers\map\QqMapHelper::Geocoder($address_str);
- if($result_data['status']==0){
- $params['longitude'] = (string)$result_data['result']['location']['lng'];
- $params['latitude'] = (string)$result_data['result']['location']['lat'];
- }else{
- // throw new \Exception('获取配送地址的经纬度失败');
- }
- $res = UserAddress::setData($params);
- if ($res === false) return $this->error(UserAddress::getStaticError());
- return $this->success('操作成功',[$res->id]);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 删除收货地址
- * @return mixed|void
- */
- public function actionUserAddressDelete()
- {
- try {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['id'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $param = [
- 'id' => $params['id'],
- 'user_id' => $this->user_id,
- 'status' => StatusEnum::DELETE,
- ];
- $res = UserAddress::setData($param);
- if ($res === false) return $this->error(UserAddress::getStaticError());
- return $this->success('删除成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 获取省市区数据
- * @return \yii\web\Response
- */
- public function actionAddressInfo()
- {
- $list = Region::getRegionList([['<>', 'parent_id', -1]], 'id,name,parent_id,level', [], 1);
- return $this->success('ok', $list);
- }
- /**
- * 收货地址列表
- * @return mixed|void
- */
- public function actionUserAddressList()
- {
- // 查询参数
- $params = Yii::$app->request->get();
- $where[] = ['in', 'status', [StatusEnum::DISABLED, StatusEnum::ENABLED]];
- $where[] = ['user_id' => $this->user_id];
- $params['order'] = 'id desc';
- $params['select'] = 'id,province,province_id,city,city_id,town,town_id,detail,district,district_id,
- is_default,latitude,location,longitude,mobile,name,community_id,community';
- $params['where'] = $where;
- $page_data = UserAddress::listPage($params, false);
- return $this->success('操作成功', $page_data);
- }
- /**
- * 地址详情
- * @return mixed|void
- */
- public function actionUserAddressDetail()
- {
- $request = Yii::$app->request;
- // 查询参数
- $where[] = ['in', 'status', [StatusEnum::DISABLED, StatusEnum::ENABLED]];
- $where[] = ['id' => $request->get('id', '')];
- $where[] = ['user_id' => $this->user_id];
- $user_address = UserAddress::getOne($where, true);
- unset($user_address['created_at']);
- unset($user_address['updated_at']);
- // 是否开启了小区代收货地址显示
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_AREA)) {
- $enabled_community = \Yii::$app->services->setting
- ->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_AREA, 'basic.shopping_address_community_enable');
- $user_address['enabled_community'] = !empty($enabled_community) ? $enabled_community : StatusEnum::DISABLED;
- }
- return $this->success('操作成功', $user_address ? $user_address : []);
- }
- /**
- * 添加收货地址的时候是否需要展示小区
- * @return mixed|null
- */
- public function actionUserAddressCommunity()
- {
- $ret['enabled_community'] = StatusEnum::DISABLED;
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_AREA)) {
- $enabled_community = \Yii::$app->services->setting
- ->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_AREA, 'basic.shopping_address_community_enable');
- $ret['enabled_community'] = !empty($enabled_community) ? $enabled_community : StatusEnum::DISABLED;
- }
- return $this->success('操作成功', $ret);
- }
- /**
- * 获取乡镇列表
- * @return mixed|void
- */
- public function actionGetTownList()
- {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['district_id'], 'required', 'message' => 'district_id必传'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['district_id' => !empty($params['district_id']) ? $params['district_id'] : ''];
- $params['order'] = 'id desc';
- $params['select'] = 'id,adcode,name';
- $params['limit'] = 100;
- $params['where'] = $where;
- $page_data = Town::listPage($params, false);
- return $this->success('操作成功', $page_data);
- }
- /**
- * 我的客户
- * @return mixed|void
- */
- public function actionMyCustomer()
- {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['level'], 'required', 'message' => 'level,必传'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- //渠道数据配置
- $team_data_config = \Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_TEAM_DATA, 'basic');
- $user_custom_text = \Yii::$app->services->setting->mall->get($this->mall_id, 'user_custom_text');
- $user_operate = \Yii::$app->services->setting->mall->get($this->mall_id, 'user_operate');
- $params['user_id'] = $this->user_id;
- $params['user_custom_text'] = $user_custom_text ?? [];
- // $data = UserRelationship::myCustomer($params);
- $data = UserPartitionRelationship::myCustomer($params, $team_data_config);
- $data['nickname'] = $this->user->nickname??'';
- $data['avatar_url'] = $this->user->avatar_url??'';
- $data['level_name'] = MallSetting::getDefaultLevelName($this->mall_id);
- $data['authority'] = '0';// 是否可查看运营数据0=否,1=是
- $data['is_show_user_parent'] = !empty($user_operate['is_show_user_parent']);
- if (!empty($data['is_show_user_parent']) && !empty($this->user['parent_id'])) {
- $data['p_user'] = User::getUser([['id' => $this->user['parent_id'], 'mall_id' => $this->mall_id]], 'id, mobile, level, nickname, avatar_url', [], 1);
- }
- $authority = Yii::$app->services->setting->mall->get($this->mall_id, 'user_operate.authority');
- if($authority){
- $authority = json_decode($authority, true);
- if (in_array($this->user->level, $authority) || in_array('-1', $authority)) $data['authority'] = '1';
- }
- // 获取用户权重列表
- $level_arr = UserLevel::getUserLevelArr($this->mall_id);
- $level_list = $level_arr;
- $level_list[0] = MallSetting::getDefaultLevelName($this->mall_id);
- $data['level_arr'] = array_merge([0 => MallSetting::getDefaultLevelName($this->mall_id)], $level_arr);
- if(!empty($this->user->level)) $data['level_name'] =$level_list[$this->user->level];
- if (!empty($data['p_user'])) {
- $data['p_user']['level_name'] = $level_list[$data['p_user']['level']] ?? '';
- }
- $data['team_info'] = UserTeamProfitStatistics::getTeamInfo($this->mall_id, $params['user_id']);
- $data['team_finish_order_price_total'] = UserTeamStatistics::getTeamFinishOrderPriceTotal($params['user_id']);
- return $this->success('操作成功',$data );
- }
- /**
- * 我的客户列表
- * @return mixed|void
- */
- public function actionMyChildrenList()
- {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['level'], 'required', 'message' => 'level,必传'],
- [['sort', 'keyword', 'type', 'sort_type'], 'string'],
- [['user_level'], 'integer'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['user_id'] = $this->user_id;
- $params['mall_id'] = $this->mall_id;
- $data = UserPartitionRelationship::myChildrenList($params);
- return $this->success('操作成功', $data);
- }
- /**
- * 我的客户的业绩订单
- *
- * @return void
- */
- public function actionMyChildrenOrders()
- {
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['level'], 'required', 'message' => 'level,必传'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['user_id'] = $this->user_id;
- $params['mall_id'] = $this->mall_id;
- $data = UserPartitionRelationship::myChildrenOrders($params);
- return $this->success('操作成功', $data);
- }
- /**
- * 我的钱包
- * @return mixed|void
- */
- public function actionBalanceDetail()
- {
- $params = \Yii::$app->request->get();
- $where = [];
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['user_id' => $this->user_id];
- $where[] = ['status' => [0,1]];
- if (!empty($params['search_type'])) $where[] = ['from_type' => $params['search_type']];
- if(!empty($params['date'])){
- $start_time = $params['date'] . ' 00:00:00';
- $end_time = strtotime(date('Ymd', strtotime($params['date'] . '+1 month -1 day')) . ' 23:59:59');
- $where[] = ['>=', 'created_at', $start_time];
- $where[] = ['<=', 'created_at', $end_time];
- }
- $params['order'] = 'id desc';
- $params['select'] = 'id,change_type,desc,change_num ,current_num ,created_at,from_type,capital_type';
- $params['where'] = $where;
- $list = BalanceLog::listPage($params);
- $list['from_type_map'] = GlobalVarMap::getEnumMapByType('FromTypeMap', $this->mall_id);
- $list['capital_type_map'] = GlobalVarMap::getEnumMapByType('CapitalTypeMap');
- // $list['from_type_map'] = UserWalletEnum::getFromTypeMapByBalance();
- // $list['capital_type_map'] = UserWalletEnum::getCapitalTypeMapByBalance();
- return $this->success('操作成功', $list);
- }
- /**
- * @return mixed|void
- */
- public function actionBalanceLogTotal()
- {
- $params = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['date'], 'required', 'message' => 'date,必传'],
- [['search_type'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [];
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['user_id' => $this->user_id];
- $where[] = ['status' => [0,1]];
- if (!empty($params['search_type'])) $where[] = ['from_type' => $params['search_type']];
- if(!empty($params['date'])){
- $start_time = strtotime($params['date'] . ' 00:00:00');
- $end_time = strtotime(date('Ymd', strtotime($params['date'] . '+1 month -1 day')) . ' 23:59:59');
- $where[] = ['>=', 'created_at', $start_time];
- $where[] = ['<=', 'created_at', $end_time];
- }
- $params['order'] = 'id desc';
- $params['select'] = 'change_type,sum(change_num) as change_num';
- $params['where'] = $where;
- $params['group'] = 'change_type';
- $list = BalanceLog::listPage($params);
- $add = $sub = 0;
- if (!empty($list['list'])) {
- foreach ($list['list'] as $v) {
- if ($v['change_type'] == 'add') $add = $v['change_num'];
- if ($v['change_type'] == 'sub') $sub = $v['change_num'];
- }
- }
- return $this->success('操作成功', ['add' => $add, 'sub' => abs($sub)]);
- }
- /**
- * 余额明细搜索类型
- * @return array
- */
- public function actionBalanceDetailFrom()
- {
- return $this->success('操作成功', UserWalletEnum::getFromTypeMapByBalance($this->mall_id));
- }
- /**
- * 获取用户信息
- * @return array|mixed
- */
- public function actionGetUser()
- {
- $params = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['user_id'], 'required', 'message' => 'user_id,必传'],
- [['type'], 'safe'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
- if($params['type'] == 1){
- $where[] = ['mobile' => $params['user_id']];
- }else if($params['type'] == 2){
- $where[] = [
- 'or',
- ['like', 'mobile', $params['user_id']],
- ['like', 'id', $params['user_id']],
- ];
- }else{
- $where[] = ['id' => $params['user_id']];
- }
- $user = User::getOne($where, true, [], false, 'id,avatar_url,mall_id,mobile,nickname,status,birthday');
- if (empty($user)) return $this->error('暂无此用户');
- return $this->success(ApiCode::CODE_SUCCESS_TITLE, $user);
- }
- /**
- * @desc:修改个人资料
- * @Author: hua
- * @Date: 2021/10/28
- * @Time: 9:56
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionUpdateData()
- {
- try {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['nickname'], 'required'],
- [[ 'avatar_url','birthday','province','city','area', 'town'], 'string'],
- [['sex'], 'integer'],
- [['wechat', 'mobile'], 'safe'],
- [['new_mobile', 'captcha'], 'string'],
- ['new_mobile', 'match', 'pattern' => '/^1\d{10}$/', 'message' => '请输入正确的手机号码'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params = array_filter($params);
- $old_mobile = '';
- if(isset($params['new_mobile']) && !empty($params['new_mobile'])){
- //检验新的手机号
- if($params['new_mobile'] == $this->user['mobile']){
- throw new \Exception('手机号与原手机号一致');
- }
- $captcha = $params['captcha'] ?? '';
- if(!$captcha){
- throw new \Exception('请输入验证码');
- }
- $where[] = ['mall_id' => $this->mall_id];
- $where[] = ['mobile' => $params['new_mobile']];
- if (User::getUser($where)) throw new \Exception( '手机号码已注册');
- //验证码
- // 判断用户接收验证码的手机号是新还是旧手机号
- $is_accept_mobile_code = Yii::$app->services->setting->mall->get($this->mall_id, 'user.is_accept_mobile_code');
- $data['is_accept_mobile_code'] = !empty($is_accept_mobile_code) ? $is_accept_mobile_code : 0;
- $verification_mobile = $data['is_accept_mobile_code'] == 1 ? $params['new_mobile'] : $params['mobile'];
- if (!Sms::checkValidateCode($verification_mobile, $params['captcha'],Sms::SMS_TYPE_UPDATE_MOBILE)) throw new \Exception('验证码不正确');
- // 验证好玩小镇那边是否已经存在当前号码
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_FUN_TOWN)) {
- GameAsyncHelper::validMobile($this->mall_id, $params['new_mobile']);
- }
- $params['mobile'] = $params['new_mobile'];
- $params['username'] = $params['new_mobile'];
- $params['mall_id'] = $this->mall_id;
- unset($params['captcha']);
- unset($params['new_mobile']);
- // 取出之前的手机号码
- $old_mobile = User::find()->where(['id' => $this->user_id])->select('mobile')->scalar();
- }
- $params['id'] = $this->user_id;
- $res = User::change($params);
- if ($res === false) return $this->error(User::getStaticError());
- // 保存额外数据
- $params['user_id'] = $this->user_id;
- $res = UserExtra::setData($params);
- if ($res === false) return $this->error(UserExtra::getStaticError());
- \Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK, RabbitMqEnum::TASK_QUEUE, [
- 'user_id'=>$this->user_id,
- 'mall_id'=>$this->mall_id,
- 'cate_ids'=>[MemberLabelEnum::USER_AGE]
- ], MemberLabelLogic::class, 'executeSyncCateId11');
- // 触发用户信息修改事件
- $event = new UserUpdateEvent($this->mall_id);
- Yii::$app->services->events->dispatch($event,['user_id'=>$this->user_id, 'mall_id' => $this->mall_id, 'old_mobile' => $old_mobile], $event->listeners);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * @desc:会员权益
- * @Author: hua
- * @Date: 2021/10/29
- * @Time: 15:06
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionMemberBenefitList()
- {
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $params['level'] = $this->user->level;
- $result = MemberBenefit::memberBenefitList($params);
- return $this->success('操作成功', $result);
- }
- /**
- * @desc:充值配置
- * @Author: hua
- * @Date: 2021/10/29
- * @Time: 15:32
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionRechargeConfig()
- {
- $setting = Yii::$app->services->setting->mall->get($this->mall_id, 'recharge');
- $config['is_open_recharge'] = isset($setting['is_open_recharge']) ? $setting['is_open_recharge'] : 0;
- $config['is_user_recharge_num'] = isset($setting['is_user_recharge_num']) ? $setting['is_user_recharge_num'] : 0;
- $config['min_recharge_num'] = isset($setting['min_recharge_num']) ? $setting['min_recharge_num'] : 0.1;
- $list = isset($setting['def_recharge_num']) ? \Qiniu\json_decode($setting['def_recharge_num']) : [100, 200, 300];
- $config['has_give'] = 0;
- $has_addons = Yii::$app->services->addons->findByName(AddonsEnum::ADDONS_NAME_RECHARGE);
- $config['active'] = [];
- if ($has_addons) {
- if(MallAddons::isInstall($this->mall_id,'Recharge')){
- $active = new AddonsRechargeActive();
- $config['active'] = $active->getNowActive($this->mall_id);
- if (!empty($config['active'])) {
- $give_info = [];
- if(!empty($config['active']['give_info'])){
- foreach ($config['active']['give_info'] as $k=>$v){
- if(in_array($v['num'],$list)){
- $give_info[] = $v;
- }
- }
- $config['active']['give_info'] = $give_info;
- }
- $config['has_give'] = !empty($give_info)?1:0;
- }
- }
- }
- // $list = [];
- // for ($i = 1; $i <= 6; $i++) {
- // if ($setting['recharge_money' . $i] <= 0) continue;
- // $list[] = [
- // 'id' => $i,
- // 'recharge_money' => $setting['recharge_money' . $i],
- // 'give_money' => $setting['give_money' . $i],
- // ];
- // }
- $pay_type_list = Yii::$app->services->pay->getEnablePayment($this->mall_id, $this->platform);
- //线下充值
- $config['is_open_recharge_offline'] = $setting['is_open_recharge_offline'] ?? 0;
- if (!empty($setting['is_open_recharge_offline'])) {
- $protocol = ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://';
- $host = $protocol.$_SERVER['HTTP_HOST'];
- $name = PayTypeEnum::getMap()[PayTypeEnum::OFFLINE] ?? '';
- $pay_type_list[] = [
- 'action' => "offline",
- 'img' => "{$host}/resources/img/payment/balance.png",
- 'name' => $name,
- 'pay_type' => PayTypeEnum::OFFLINE,
- 'trade_type' => "offline",
- 'qrcode_url' => $setting['recharge_offline_code'] ?? '',
- ];
- }
- $balance = UserWallet::find()->select('balance')->where(['user_id' => $this->user_id])->scalar();
- return $this->success('操作成功', ['list' => $list,'config'=>$config, 'payment' => $pay_type_list, 'balance' => $balance]);
- }
- /**
- * 保存提现银行卡信息
- * User: wniu
- * Date: 2021/11/4
- * Time: 10:27 上午
- *
- */
- public function actionAddUserBankCard()
- {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['payer_name', 'bank', 'bank_card_no', 'id'], 'string'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['user_id'] = $this->user_id;
- $params['mall_id'] = $this->mall_id;
- $model = new UserBankCard();
- $history = [];
- if ($params['id']) {
- $history = $model->getOne([['id' => $params['id']]]);
- }
- if ($history) {
- $history->bank = $params['bank'];
- $history->bank_card_no = $params['bank_card_no'];
- $history->payer_name = $params['payer_name'];
- $history->save();
- } else {
- $model->attributes = $params;
- $model->save();
- }
- $list = $model->lists(['where' => [['user_id' => $this->user_id], ['status' => StatusEnum::ENABLED]], 'select' => 'bank,bank_card_no,id,payer_name,is_delete']);
- return $this->success('操作成功', $list);
- }
- public function actionDelBankCard()
- {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['id'], 'required', 'message' => 'id,必传'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $card = UserBankCard::getOne([['id' => $params['id']]]);
- $card->status = StatusEnum::DELETE;
- $card->save();
- return $this->success('操作成功');
- }
- /**
- * @desc:推广中心
- * @Author: hua
- * @Date: 2021/11/12
- * @Time: 9:12
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionPromotionCenter()
- {
- $data = [];
- $user_wallet_model = UserWallet::findOne(['user_id'=>$this->user_id]);
- $total_commission = $user_wallet_model['total_commission']??0;
- $frozen_commission = $user_wallet_model['frozen_commission']??0;
- $data['frozen_commission'] = $frozen_commission;
- $data['total_commission'] = $total_commission+$frozen_commission;
- $data['commission'] = $user_wallet_model['commission']??0;
- $ori_data = $data;
- $data = GlobalInvoke::exec(GlobalInvoke::INVOKE_PROMOTION_CENTER, $this->mall_id,['mall_id' => $this->mall_id,'user_id' => $this->user_id, 'data' => $data]);
- if(is_array($data) && empty($data)){
- $data = $ori_data;
- }
- $data['ori_commission'] = $data['commission'];
- $freeze_commission = UserFreezeCommission::handlePromotionCenter($this->mall_id, $this->user_id);
- if(!empty($freeze_commission['is_freeze_commission'])){
- $data['commission'] -= $freeze_commission['freeze_amount'];
- $data['commission'] < 0 && $data['commission'] = 0;
- }
- $data = array_merge($data, $freeze_commission);
- $data['today_income'] = 0;
- //计算今日收益
- $today = date('Y-m-d',time());
- $start_time = strtotime($today.' 00:00:00');
- $end_time = strtotime($today.' 23:59:59');
- $wallet_type = 'commission';
- CapitalLog::$capitalType = "{$wallet_type}_frozen";
- $today_frozen_commission = CapitalLog::find()
- ->where(['user_id'=>$this->user_id,'status' => CapitalLog::STATUS_WAIT_SEND,'change_type'=>'add'])
- ->andWhere(['<=','created_at',$end_time])->andWhere(['>=','created_at',$start_time])->sum('change_num');
- CapitalLog::$capitalType = "{$wallet_type}";
- $today_commission = CapitalLog::find()
- ->where(['user_id' => $this->user_id, 'change_type' => 'add'])
- ->andWhere(['<=', 'created_at', $end_time])->andWhere(['>=', 'created_at', $start_time])
- ->andWhere(['<>','capital_type','withdrawal_refund'])
- ->sum('change_num');
- if($today_frozen_commission) $data['today_income']+=$today_frozen_commission;
- if($today_commission) $data['today_income'] += $today_commission;
- $data['today_frozen_income'] = $today_frozen_commission ?: 0; // 今日未结算收益
- $data['today_settled_income'] = $today_commission ?: 0; // 今日已结算收益
- //累计增值
- $total_added_num = CapitalLog::find()->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'from_type' => 'ScoreGame', 'capital_type' => 'day_increment'])->sum('change_num');
- $yesterDay = DateHelper::yesterDay();
- $yesteday_added_num = CapitalLog::find()
- ->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'from_type' => 'ScoreGame', 'capital_type' => 'day_increment'])
- ->andWhere(['>=', 'created_at', $yesterDay['start']])
- ->andWhere(['<=', 'created_at', $yesterDay['end']])
- ->sum('change_num');
- $data['total_added_num'] = $total_added_num ?? 0; //总增值
- $data['yesteday_added_num'] = $yesteday_added_num ?? 0; //昨日增值
- $data['total_cash'] = $user_wallet_model['commission_withdrawal']??0;
- // 公共调用获取个人应用佣金数额
- $data['list'] = GlobalInvoke::exec(GlobalInvoke::PROMOTION, $this->mall_id,['mall_id' => $this->mall_id,'user_id' => $this->user_id]);
- // 总收益减去提现驳回的
- // $back_m = UserWithdrawLog::find()->where(['user_id'=>$this->user_id,'status'=>UserWithdrawLog::STATUS_ALREADY_REJECT])->sum('num');
- // if($data['total_commission'] - $back_m > 0){
- // $data['total_commission'] -= $back_m;
- // }
- $show_type = \Yii::$app->services->setting->mall->get($this->mall_id, 'withdraw_income');
- $data['show_type'] = $show_type['show_type'] ?? 1;
- $data['is_show_today_income'] = $show_type['is_show_today_income'] ?? 1;
- $data['promotion_center_title'] = $show_type['promotion_center_title'] ?? '推广中心';
- return $this->success('操作成功',$data);
- }
- /**
- * @desc:我的收藏
- * @Author: hua
- * @Date: 2021/11/12
- * @Time: 14:20
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionCollectList(){
- $params = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($params, [
- [['type'], 'required', 'message' => '类型必传'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $list = [];
- switch ($params['type']){
- case 'goods':
- $params['where'] = [['gc.user_id'=>$this->user_id],['g.status'=>StatusEnum::ENABLED],['gc.status'=>StatusEnum::ENABLED]];
- $params['alias'] = 'gc';
- $params['join'] = [['left join',Goods::tableName().' as g','gc.goods_id=g.id']];
- $params['select'] = 'gc.goods_id,g.goods_name,g.cover_pic,g.price';
- $list = GoodsCollect::listPage($params);
- break;
- case 'store':
- if(MallAddons::isInstall($this->mall_id,'Store')){
- $params['where'] = [['sc.user_id'=>$this->user_id],['s.status'=>StatusEnum::ENABLED],['sc.status'=>StatusEnum::ENABLED]];
- $params['alias'] = 'sc';
- $params['join'] = [['left join',Store::tableName().' as s','sc.store_id=s.id']];
- $params['select'] = 's.id,s.store_name,s.logo_img,s.store_desc,s.sales_volume,s.praise,s.show_style,s.address,s.business_time_end,s.business_time_start';
- $list = StoreCollect::listPage($params);
- if(!empty($list['list'])){
- $store_ids = array_column($list['list'],'id');
- $goods_list =StoreGoods::lists([
- 'where'=>[['store_id'=>$store_ids]],
- 'select'=>'sum(virtual_sales) as virtual_sales,sum(sales_num) as sales_num,store_id',
- 'group'=>'store_id',
- 'index'=>'store_id'
- ]);
- foreach ($list['list'] as &$item){
- if(isset($goods_list[$item['id']])){
- $item['sales_volume'] =$goods_list[$item['id']]['virtual_sales']+$goods_list[$item['id']]['sales_num'];
- }
- }
- }
- }
- break;
- }
- return $this->success('操作成功',$list);
- }
- /**
- * @desc:收益明细
- * @Author: hua
- * @Date: 2021/11/23
- * @Time: 16:25
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionCommissionList(){
- $get = Yii::$app->request->get();
- $where[]=['mall_id'=>$this->mall_id];
- $where[]=['user_id'=>$this->user_id];
- // $where[]=['change_type'=>CapitalLog::CHANGE_TYPE_ADD];
- if(!empty($get['from_type'])){
- $where[]=['from_type'=>$get['from_type']];
- }else{
- // $from_type = GlobalVarMap::getEnumNameByType( 'IncomeMap',$this->mall_id);
- // $from_type[] = 'StoreBoss'; //门店股东
- // $where[]=['from_type'=>$from_type];
- }
- if(isset($get['show_type'])&&$get['show_type']==1){
- $time_type = $get['time_type']??1;
- $created_at_condition = time()-7*24*3600;
- switch ($time_type){
- case 2:
- $created_at_condition = time()-30*24*3600;
- break;
- case 3:
- $created_at_condition=strtotime(date("Y-m-d",mktime(0,0,0,date("m")-3,date("d"),date("Y")))." 00:00:00");
- break;
- }
- if ($time_type == 4) {
- if (!empty($get['start_time']) && !empty($get['end_time'])) {
- $start_time = strtotime($get['start_time'] . '00:00:00');
- $end_time = strtotime($get['end_time'] . '23:59:59');
- $where[] = ['between', 'created_at', $start_time, $end_time];
- }
- } else {
- $where[] = ['>=', 'created_at',$created_at_condition];
- }
- }
- //过滤该插件
- $where[]= ['!=', 'from_type', AddonsEnum::ADDONS_NAME_NI_BAO_ACHIEVEMENT];
- if(!empty($get['date'])){
- $start_time = strtotime($get['date'] . ' 00:00:00');
- $end_time = strtotime(date('Ymd', strtotime($get['date'] . '+1 month -1 day')) . ' 23:59:59');
- $where[] = ['>=', 'created_at', $start_time];
- $where[] = ['<=', 'created_at', $end_time];
- }
- $wallet_type = 'commission';
- $type = 'frozen';
- if(!empty($get['type'])&&$get['type']==$type){
- //冻结
- CapitalLog::$capitalType = "{$wallet_type}_{$type}";
- $where[] = ['status'=>StatusEnum::DISABLED];
- }else{
- CapitalLog::$capitalType = "{$wallet_type}";
- }
- $where[]=['change_type'=>CapitalLog::CHANGE_TYPE_ADD];
- $params['where'] = $where;
- $list = CapitalLog::listPage(array_merge($params, ['order' => 'id desc']));
- if (!empty($list['list'])) {
- foreach ($list['list'] as &$item) {
- $item['show_detail'] = 0;
- if(substr($item['order_no'], 0, 3) == 'CSF'){
- $item['show_detail'] = 2;
- } else if (substr($item['order_no'], 0, 1) == 's' && is_numeric(substr($item['order_no'], 1, 1))) {
- $item['show_detail'] = 1;
- }
- }
- }
- $select = new Expression("sum(change_num) as total_commission,FROM_UNIXTIME(created_at,'%Y-%m') as times");
- $params['select'] = $select;
- $params['group'] = 'times';
- $where[] = ['<>','capital_type','withdrawal_refund'];
- $params['where'] = $where;
- $result = CapitalLog::lists($params);
- $list['total_list'] = array_column($result,'total_commission','times');
- $list['form_type'] = GlobalVarMap::getEnumMapByType('IncomeMap', $this->mall_id);
- foreach ($list['form_type'] as $addons=>$addons_name) {
- if(in_array($addons,['ConsumeGift','MembersCard','OperatingNote','UserGift','GroupRush','Recommen','Sudoku','CloudStockTwo','CloudStock','LuckyGroup','Bargain','BlindBox','BlindBoxs',
- 'TeamLevel','Seed','EightOutTwo','Rebate'])){
- unset($list['form_type'][$addons]);
- continue;
- }
- $configs = \Yii::$app->services->setting->addons->get($this->mall_id, $addons, 'basic');
- if((isset($configs['is_show_at_center'])&&$configs['is_show_at_center']==0)){
- unset($list['form_type'][$addons]);
- }
- }
- return $this->success('操作成功',$list);
- }
- /**
- * @desc:提现明细汇总部分
- * @Author: hua
- * @Date: 2021/11/24
- * @Time: 14:35
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionCashDetail(){
- $user_wallet = UserWallet::findOne(['mall_id'=>$this->mall_id,'user_id'=>$this->user_id]);
- $data['commission'] = $user_wallet['commission']??0;//可用佣金
- $freeze_commission = UserFreezeCommission::handlePromotionCenter($this->mall_id, $this->user_id);
- if(!empty($freeze_commission['is_freeze_commission'])){
- $data['commission'] -= $freeze_commission['freeze_amount'];
- $data['commission'] < 0 && $data['commission'] = 0;
- }
- // $data['commission_withdrawal'] = $user_wallet['commission_withdrawal']??0;//已提现得总佣金
- $start_time = strtotime(date('Y-m-1',time()). ' 00:00:00');
- $end_time = strtotime(date('Y-m-t',time()). ' 23:59:59');
- $where = ['user_id'=>$this->user_id,'mall_id'=>$this->mall_id,'from'=>1,'status'=>[UserWithdrawLog::STATUS_ALREADY_TRANS]];
- $commission_withdrawal = UserWithdrawLog::find()->where($where)
- ->sum('num');
- $data['commission_withdrawal'] = $commission_withdrawal??0;//已提现得总佣金
- $month_num = UserWithdrawLog::find()->where($where)
- ->andWhere(['>=', 'created_at', $start_time])->andWhere(['<=', 'created_at', $end_time])
- ->sum('num');
- $monday_time = strtotime(date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)).' 00:00:00');
- $sunday_time = strtotime(date('Y-m-d', (time() + (7 - (date('w') == 0 ? 7 : date('w'))) * 24 * 3600)).' 23:59:59');
- $week_num = UserWithdrawLog::find()->where($where)
- ->andWhere(['>=', 'created_at', $monday_time])->andWhere(['<=', 'created_at', $sunday_time])
- ->sum('num');
- $data['month_num'] = $month_num??0;
- $data['week_num'] = $week_num??0;
- //手续费名称
- $payment = \Yii::$app->services->setting->mall->get($this->mall_id, 'withdraw_income');
- $data['poundage_name'] = isset($payment['profit_withdrawal_rule']) ? $payment['profit_withdrawal_rule'] : '手续费';
- return $this->success('操作成功',$data);
- }
- /**
- * @desc:提现列表
- * @Author: hua
- * @Date: 2021/11/24
- * @Time: 14:46
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionCashList(){
- $params = $get = Yii::$app->request->get();
- $where[]=['mall_id'=>$this->mall_id];
- $where[]=['user_id'=>$this->user_id];
- $where[]=['from'=>1];
- if(isset($params['status'])&&$params['status']!=='') $where[]=['status'=>$params['status']];
- $params['where'] = $where;
- $params['select'] = 'id,mall_id,user_id,order_no,num,actual_num,poundage_num,poundage_ratio,content,status,type';
- $params['order'] = 'id desc';
- $list = UserWithdrawLog::listPage($params);
- $list['status_map'] = UserWithdrawLog::$status_msg;
- $list['type_map'] = UserWithdrawLog::$type_msg;
- if (!empty($list['list'])) {
- $ids = array_column($list['list'], 'id');
- if ($this->platform == 'mp-wx') {
- $mini_program = Yii::$app->services->setting->mall->get($this->mall_id, 'mini_program', true);
- $appId = $mini_program['app_id'] ?? '';
- } else {
- $wechat_conf = Yii::$app->services->setting->mall->get($this->mall_id, 'wechat', true);
- $appId = $wechat_conf['app_id'] ?? '';
- }
- $wechat_transfer_log_list = \common\models\wechat\WechatTransferLog::lists(['where' => [['cash_id' => $ids]], 'index' => 'cash_id']);
- foreach ($list['list'] as &$v) {
- $v['content'] = json_decode($v['content'], true);
- $v['transfer_result'] = [];
- if (isset($wechat_transfer_log_list[$v['id']])) {
- $payment_conf = \Yii::$app->services->setting->mall->get($this->mall_id, 'pay.wechat', true);
- $payment_conf = json_decode($payment_conf, true);
- $mchId = $payment_conf['wechat_mch_id'] ?? '';
- $wechat_transfer = $wechat_transfer_log_list[$v['id']];
- $transfer_result = json_decode($wechat_transfer['transfer_result'], true);
- $transfer_result['mchId'] = $mchId;
- $transfer_result['appId'] = $appId;
- $v['transfer_result'] = $transfer_result;
- }
- }
- }
- return $this->success('操作成功',$list);
- }
- /**
- * 获取用户协议接口
- * @Author: ltm
- * @DateTime: 2021/12/8 0030 14:20
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|void
- */
- public function actionUserAgree()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isPost) {
- try {
- $user_setting = Yii::$app->services->setting->mall->get($this->mall_id, 'user_agree');
- $this->success('获取成功', $user_setting);
- } catch (\Exception $e) {
- $this->error('获取失败,mag=' . $e->getMessage());
- }
- }
- }
- /**
- * @Author: ltm
- * @DateTime: 2022/1/7 0007 17:00
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return bool
- */
- public function actionFollow(){
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['follow_id'], 'required']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- if($params['follow_id'] == $this->user_id) return $this->error('自己不可以关注自己');
- $res = UserFollow::setData($params);
- //记录我关注
- $model_follow = UserExtra::findOne(['user_id'=>$this->user_id]);
- if($model_follow){
- if($res == StatusEnum::ENABLED){
- $model_follow -> follow_count = $model_follow -> follow_count + 1;
- }else{
- $model_follow -> follow_count = $model_follow -> follow_count - 1;
- }
- $model_follow ->save();
- }
- //记录粉丝
- $model_fans = UserExtra::findOne(['user_id'=>$params['follow_id']]);
- if($model_fans){
- if($res == StatusEnum::ENABLED){
- $model_fans -> fans_count = $model_fans -> fans_count + 1;
- }else{
- $model_fans -> fans_count = $model_fans -> fans_count - 1;
- }
- $model_fans ->save();
- }
- if ($res === false) throw new Exception(UserFollow::getStaticCodeError()['error']);
- return $this->success('操作成功');
- }
- }
- /**
- * @Author: ltm
- * 我关注的记录
- * @DateTime: 2022/1/10 0010 18:49
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return String
- */
- public function actionFollowList(){
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['user_id'], 'safe'],
- ]);
- $params = UserFollow::exceptNullVal($params);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $user_id = $params['user_id'] ? $params['user_id'] : $this->user_id;
- $params['where'][] = ['status' => StatusEnum::ENABLED];
- $params['where'][] = ['user_id' => $user_id];
- $params['with'] = ['follow','userextra'];
- $params['order'] = 'status desc';
- $list = UserFollow::listPage($params);
- if($list['list']) {
- foreach ($list['list'] as $k => $v){
- $list['list'][$k]['user'] = $v['follow'];
- $list['list'][$k]['user']['signature_content'] = $v['userextra']['personal_signature'];
- unset($list['list'][$k]['follow']);
- }
- }
- return $this->success('操作成功',$list);
- }
- }
- /**
- * @Author: ltm
- * 我关注的记录
- * @DateTime: 2022/1/10 0010 18:49
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $data
- * @return String
- */
- public function actionFansList(){
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['user_id'], 'safe'],
- ]);
- $params = UserFollow::exceptNullVal($params);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $user_id = $params['user_id'] ? $params['user_id'] : $this->user_id;
- $params['where'][] = ['follow_id' => $user_id];
- $params['where'][] = ['status' => StatusEnum::ENABLED];
- $params['with'] = ['fans','userextrafans','userFollow'];
- $list = UserFollow::listPage($params);
- if($list['list']) {
- foreach ($list['list'] as $k => $v){
- $list['list'][$k]['user'] = $v['fans'];
- $list['list'][$k]['status'] = $v['userFollow']['status'];
- $list['list'][$k]['user']['signature_content'] = $v['userextrafans']['personal_signature'];
- unset($list['list'][$k]['fans']);
- }
- }
- return $this->success('操作成功',$list);
- }
- }
- /**
- * 刷新最后活跃时间
- * @return string
- */
- public function actionRefreshLastLoginAt()
- {
- try {
- if (!MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_ALIPAY_MINI_INVITE)) {
- throw new \Exception("未安装当前插件");
- }
- // 这里执行刷新
- // 判断今天有没有刷新过,有刷新过就不再进行刷新
- $date = date("Y-m-d");
- $key = "refresh:{$date}";
- if (Yii::$app->redis->getbit($key, $this->user_id)) {
- throw new \Exception('今天已经刷新过');
- }
- // 使用bit会比较合适
- Yii::$app->redis->setbit($key, $this->user_id, StatusEnum::ENABLED);
- if (!Yii::$app->redis->ttl($key)) {
- Yii::$app->redis->expireat($key, date('Y-m-d') . " 23:59:59"); // 一天后过期
- }
- // 获取用户最后活跃时间
- $last_login_at = $this->user['last_login_at'];
- // 更新用户最后登录时间
- User::updateAll(['last_login_at' => time()], ['id' => $this->user_id]);
- $invite_user_id = intval(Yii::$app->request->get('invite', 0));
- if ($invite_user_id > 0) { // 如果有带邀请激活人的ID那么就执行事件
- // 执行事件
- if (User::find()->where(['mall_id' => $this->mall_id])->andWhere(['id' => $invite_user_id])->count() > 0) {
- $event = new InviteOldUserRewardEvent($this->mall_id);
- Yii::$app->services->events->dispatch($event, [
- 'last_login_at' => $last_login_at,
- 'user_id' => $this->user_id,
- 'invite_user_id'=> $invite_user_id,
- 'mall_id' => $this->mall_id,
- ], $event->listeners);
- }
- }
- return $this->success('刷新成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- /**
- * 地址解析
- * @return mixed|void
- */
- public function actionAddressParse()
- {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['address'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $address = $params['address'];
- $res = \common\helpers\AddressParse\AddressParseHelper::smart($address);
- return $this->success('操作成功',$res);
- }
- public function actionVisit(){
- if ($this->user_id) {
- UserStatisticsTotal::setUserStatisticsTotal($this->mall_id,$this->user_id,['visit_nums'=>1]);
- Yii::$app->services->rabbitMq->push(RabbitMqEnum::EXCHANGE_TASK, RabbitMqEnum::TASK_QUEUE, [
- 'user_id'=>$this->user_id,
- 'mall_id'=>$this->mall_id,
- 'cate_ids'=>[MemberLabelEnum::ACTIVE]
- ], MemberLabelLogic::class, 'executeSync');
- }
- return $this->success('操作成功',[]);
- }
- public function actionBindByCode(){
- try{
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['code'], 'required'],
- [['code'], 'string'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $result = UserPartitionRelationship::bindUserByCode($this->mall_id, $this->user_id, $params['code']);
- if($result === false) throw new \Exception(UserPartitionRelationship::getStaticError());
- return $this->success('绑定成功');
- }catch(\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- /**
- * 获取权重
- * @return mixed|null
- */
- public function actionLevelList()
- {
- $list = UserLevel::getUserLevelArr($this->mall_id);
- if (!empty(UserLevel::getStaticError())) return $this->error(UserLevel::getStaticError());
- return $this->success('获取成功', $list);
- }
- public function actionUpdatePersonalSign()
- {
- try {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['personal_signature'], 'required']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $res = UserExtra::setData($params);
- if ($res === false) return $this->error(UserExtra::getStaticError());
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- public function actionGetUpgradeAgree()
- {
- $retuest = Yii::$app->request;
- if ($retuest->isGet) {
- try {
- $this->success('获取成功', ['upgrade_agree' => UserSignAgreement::getUpgradeAgree($this->mall_id)]);
- } catch (\Exception $e) {
- $this->error('获取失败,mag=' . $e->getMessage());
- }
- }
- }
- /**
- * 上传支付凭证
- * @return mixed|void
- */
- public function actionSaveEvidence(){
- $key = sprintf('SaveEvidence:%s', $this->user_id);
- if (LockHelper::fLock($key)) return $this->error('请勿频繁请求');
- try {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['payment_evidence','num'], 'required']
- ]);
- if ($res === false) throw new \Exception(Yii::$app->services->validate->getErrorMessage());
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $res = BalanceRechargeLog::setData($params);
- if ($res === false) throw new \Exception(BalanceRechargeLog::getStaticError());
- LockHelper::unFLock($key);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- LockHelper::unFLock($key);
- return $this->error($e->getMessage());
- }
- }
- /**
- * 支付凭证列表
- * @return mixed|void
- */
- public function actionEvidenceList(){
- $get = Yii::$app->request->get();
- $where[]=['mall_id'=>$this->mall_id];
- $where[]=['user_id'=>$this->user_id];
- $params['where'] = $where;
- $params['select'] = 'created_at,num,withdraw_status,remark,payment_evidence';
- $params['order'] = 'id desc';
- $list = BalanceRechargeLog::listPage($params);
- if(!empty($list['list'])){
- foreach($list['list'] as &$item){
- $item['created_at'] = date('Y-m-d H:i:s',$item['created_at']);
- }
- }
- return $this->success('操作成功',$list);
- }
- /**
- * 用户是否订阅公众号
- *
- * @return string
- */
- public function actionIsSubscribe()
- {
- // 未登录情况下返回未关注
- if (empty($this->user_id)) return $this->success('ok', ['subscribe' => false]);
- $service = new WechatUserService(['mall_id' => $this->mall_id]);
- $subscribe = $service->isSubscribe((int)$this->user_id);
- return $this->success('ok', ['subscribe' => $subscribe]);
- }
- /**
- * 关于我们版权信息
- * @return mixed|null
- */
- public function actionCopyright()
- {
- // 获取版权信息
- $settings = MallSetting::getConfByGroup($this->mall_id, ['copyright'], true);
- $certificates = $usageAgreement = [];
- if (!empty($settings['copyright']['certificates'])) {
- $certificates_images = !empty($settings['copyright']['certificates']['value']) ? json_decode($settings['copyright']['certificates']['value'], true) : [];
- $certificates = [
- 'name' => $settings['copyright']['certificates']['name'],
- 'value' => $certificates_images,
- ];
- }
- if (!empty($settings['copyright']['usage_agreement'])) {
- $usageAgreement = [
- 'name' => $settings['copyright']['usage_agreement']['name'],
- 'value' => $settings['copyright']['usage_agreement']['value'] ?? '',
- ];
- }
- return $this->success('请求成功', ['certificates' => $certificates, 'usageAgreement' => $usageAgreement]);
- }
- public function actionUpdateUserPosition()
- {
- try {
- if (\Yii::$app->request->isPost) {
- $params = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($params, [
- [['longitude', 'latitude'], 'required'],
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- if (empty($this->user_id)) {
- //未登录的不处理
- return $this->success('操作成功');
- }
- $key = sprintf('Position:%s', $this->mall_id . '_' . $this->user_id);
- //每个用户限制5分钟更新一次
- if (LockHelper::fLock($key, 300)) $this->success('操作成功');
- $params['mall_id'] = $this->mall_id;
- $params['user_id'] = $this->user_id;
- $event = new UserPositionChangeEvent($this->mall_id);
- Yii::$app->services->events->dispatch($event, $params, $event->listeners);
- return $this->success('操作成功', null);
- }
- } catch (\Exception $e) {
- LockHelper::unFLock($key);
- return $this->error($e->getMessage());
- }
- }
- }
|