From 55e11a59bff9a9e64ba55f59abdf30a28990ada1 Mon Sep 17 00:00:00 2001 From: "674780036@qq.com" <674780036@qq.com> Date: Tue, 27 Feb 2024 02:23:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E8=AE=A2=E5=8D=95-=E5=88=86?= =?UTF-8?q?=E9=94=80=E4=BC=9A=E5=91=98=E5=88=B0=E6=9C=9F=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=88=90=E5=88=86=E9=94=80=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=EF=BC=9B=E5=88=86=E9=94=80=E7=BB=AD=E6=9C=9F=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E5=8F=AA=E6=9B=B4=E6=96=B0=E5=88=86=E9=94=80?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E6=97=B6=E9=97=B4=EF=BC=8C=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=88=86=E9=94=80=E7=94=A8=E6=88=B7=EF=BC=9B=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E5=88=86=E9=94=80=E4=BC=9A=E5=91=98=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=AD=97=E6=AE=B5fx=5Feffe?= =?UTF-8?q?ctive=5Ftime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/model/dealer/Order.php | 10 +++++ app/api/service/identity/PaySuccess.php | 2 + app/command/CalDealerTime.php | 50 ++++++++++++++++++++----- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/app/api/model/dealer/Order.php b/app/api/model/dealer/Order.php index e7830882..1e9a5ca5 100644 --- a/app/api/model/dealer/Order.php +++ b/app/api/model/dealer/Order.php @@ -21,6 +21,8 @@ use app\api\model\Order as OrderApiModel; use app\common\enum\order\PayStatus as PayStatusEnum; use app\common\model\UserAddress as UserAddessModel; use cores\exception\BaseException; +use app\api\model\User as UserApiModel; +use app\common\enum\user\UserTypeEnum; /** @@ -123,6 +125,14 @@ class Order extends DealerOrderModel if (!$dealerUser['first_user_id']) { return false; } + //如果上级已经不是分销商 + if(!User::isDealerUser($dealerUser['first_user_id'])){ + return false; + } + //如果上级已经不是分销商 + if(!UserApiModel::where('user_id',$dealerUser['first_user_id'])->value('user_type') !== UserTypeEnum::DEALER){ + return false; + } // 计算订单分销佣金 $capital = static::getCapitalByOrder($order); // 保存分销订单记录 diff --git a/app/api/service/identity/PaySuccess.php b/app/api/service/identity/PaySuccess.php index b952704c..e86f9438 100644 --- a/app/api/service/identity/PaySuccess.php +++ b/app/api/service/identity/PaySuccess.php @@ -382,6 +382,7 @@ class PaySuccess extends BaseService if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) { $time = $userInfo['effective_time']; } + } if (!User::isDealerUser($userInfo['user_id'])) { // 新增分销商用户 @@ -392,6 +393,7 @@ class PaySuccess extends BaseService 'mobile' => $mobile, ]); } + $up['fx_effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time))); } $up['effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time))); $userModel->where(['user_id' => $userInfo['user_id']])->save($up); diff --git a/app/command/CalDealerTime.php b/app/command/CalDealerTime.php index b345a5b8..457245ff 100644 --- a/app/command/CalDealerTime.php +++ b/app/command/CalDealerTime.php @@ -6,6 +6,7 @@ namespace app\command; use think\facade\Db; use app\api\model\User; +use app\api\model\dealer\User as DealerUserModel; use think\console\Input; use think\console\Output; use app\api\model\PreSale; @@ -15,6 +16,7 @@ use app\api\model\PreSaleMessage; use app\api\model\{Goods as GoodsModel}; use app\common\enum\user\UserTypeEnum; + // /www/server/php/74/bin/php /server/wwwroot/yanzong/think CalDealerTime class CalDealerTime extends Command { @@ -37,21 +39,49 @@ class CalDealerTime extends Command // print_r($list->toArray()); // print ''; // die; + $del_fx_user_ids = []; + $del_hy_user_ids = []; foreach ($list as $item) { - //如果分销商到期,改成会员 - if(strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d'))){ - User::where('user_id',$item['user_id'])->update([ - 'user_type'=>UserTypeEnum::MEMBER - ]); + //如果分销商到期,改成会员;并且删除分销商 + if(isset($item['fx_effective_time']) && strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d'))){ + $del_fx_user_ids[] = $item['user_id']; + // User::where('user_id',$item['user_id'])->update([ + // 'user_type'=>UserTypeEnum::MEMBER + // ]); + // //分销商表软删除 + // DealerUserModel::where('user_id',$item['user_id'])->update(['is_delete'=>1]); } - //如果会员到期,但是分销商没到期,还是分销商;分销商到期了,改成普通用户 - if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && (strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d')))){ - User::where('user_id',$item['user_id'])->update([ - 'user_type'=>UserTypeEnum::NORMAL - ]); + //如果会员到期,分销商到期了,改成普通用户 + if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && (isset($item['fx_effective_time']) && strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d')))){ + $del_hy_user_ids[] = $item['user_id']; + // User::where('user_id',$item['user_id'])->update([ + // 'user_type'=>UserTypeEnum::NORMAL + // ]); + } + //如果会员到期,分销商根本没有,改成普通用户 + if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && !isset($item['fx_effective_time'])){ + $del_hy_user_ids[] = $item['user_id']; + // User::where('user_id',$item['user_id'])->update([ + // 'user_type'=>UserTypeEnum::NORMAL + // ]); } } + //var_dump([$del_fx_user_ids, $del_hy_user_ids]);die; + Db::transaction(function () use ($del_fx_user_ids, $del_hy_user_ids) { + //如果分销商到期,改成会员;并且删除分销商 + User::whereIn('user_id',$del_fx_user_ids)->update([ + 'user_type'=>UserTypeEnum::MEMBER + ]); + //分销商表软删除 + DealerUserModel::whereIn('user_id',$del_fx_user_ids)->update(['is_delete'=>1]); + + //如果会员到期,分销商到期了/根本没有,改成普通用户 + User::whereIn('user_id',$del_hy_user_ids)->update([ + 'user_type'=>UserTypeEnum::NORMAL + ]); + + }); }