Merge branch 'main' of http://git.njrzwl.cn:3000/wangmingchuan/yanzong
commit
b5cbc8b4f1
@ -0,0 +1,39 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\api\controller\dealer; |
||||
|
||||
use think\response\Json; |
||||
use app\api\controller\Controller; |
||||
use app\api\model\dealer\Capital as CapitalModel; |
||||
|
||||
/** |
||||
* 分销商佣金 |
||||
* Class Order |
||||
* @package app\api\controller\user\dealer |
||||
*/ |
||||
class Capital extends Controller |
||||
{ |
||||
/** |
||||
* 分销商佣金列表 |
||||
* @return Json |
||||
* @throws \cores\exception\BaseException |
||||
* @throws \think\db\exception\DbException |
||||
*/ |
||||
public function list(): Json |
||||
{ |
||||
// 分销商订单列表 |
||||
$model = new CapitalModel; |
||||
$list = $model->getList($this->request->param(),$this->request->storeId()); |
||||
return $this->renderSuccess(compact('list')); |
||||
} |
||||
} |
@ -0,0 +1,90 @@ |
||||
<?php |
||||
|
||||
declare (strict_types=1); |
||||
|
||||
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; |
||||
use think\console\Command; |
||||
use app\api\model\PreSaleLog; |
||||
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 |
||||
{ |
||||
protected function configure() |
||||
{ |
||||
// 指令配置 |
||||
$this->setName('CalDealerTime') |
||||
->setDescription('自动计算分销时间'); |
||||
} |
||||
|
||||
protected function execute(Input $input, Output $output) |
||||
{ |
||||
//todo wmc这边代码需要优化 |
||||
//$list = User::where('status', 1) |
||||
$list = User::where('user_type', 'in', [UserTypeEnum::MEMBER,UserTypeEnum::DEALER]) |
||||
->where('is_delete', '=', 0) |
||||
//->where('store_id',10001) |
||||
->select(); |
||||
// print '<pre>'; |
||||
// print_r($list->toArray()); |
||||
// print '</pre>'; |
||||
// die; |
||||
$del_fx_user_ids = []; |
||||
$del_hy_user_ids = []; |
||||
foreach ($list as $item) { |
||||
//如果分销商到期,改成会员;并且删除分销商 |
||||
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'))) && (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…
Reference in new issue