分销订单-分销会员到期后,不生成分销订单;分销续期的时候,只更新分销会员时间,不生成分销用户;购买分销会员的时候,更新字段fx_effective_time

pull/1/head
674780036@qq.com 9 months ago
parent e167dba8f4
commit 55e11a59bf
  1. 10
      app/api/model/dealer/Order.php
  2. 2
      app/api/service/identity/PaySuccess.php
  3. 50
      app/command/CalDealerTime.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);
// 保存分销订单记录

@ -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);

@ -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 '</pre>';
// 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
]);
});
}

Loading…
Cancel
Save