更新
This commit is contained in:
parent
260bdba280
commit
e3a378df36
@ -40,7 +40,7 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['level_two', 'level_one', 'organization_code', 'city', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'],
|
||||
'=' => ['organization_code', 'city', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'],
|
||||
'%like%' => ['company_name'],
|
||||
];
|
||||
}
|
||||
@ -111,7 +111,7 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
return Company::where('company_type',30)
|
||||
->field(['is_authentication','id', 'level_two', 'level_one', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->field(['is_authentication','id', 'company_name', 'organization_code', 'city', 'area', 'street', 'company_type', 'master_name', 'master_position', 'master_phone', 'master_email', 'other_contacts', 'area_manager', 'is_contract', 'deposit', 'deposit_time', 'qualification', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
|
@ -3,8 +3,10 @@ namespace app\api\controller;
|
||||
|
||||
use app\common\logic\finance\ShareProfit;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use think\facade\Log;
|
||||
|
||||
class CeshiController extends BaseApiController
|
||||
{
|
||||
@ -12,11 +14,15 @@ class CeshiController extends BaseApiController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$all=TaskSchedulingPlan::whereDay('end_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select();
|
||||
halt($all);
|
||||
//,'yesterday'
|
||||
$all=TaskSchedulingPlan::whereDay('end_time')->where('is_pay',0)->with(['template_info','scheduling'])->select();
|
||||
foreach($all as $k=>$data){
|
||||
$task_id=explode(',',$data['task_id']);
|
||||
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
|
||||
if(empty($task_count)){
|
||||
Log::error('任务结算失败,任务id:'.$task_id);
|
||||
continue;
|
||||
}
|
||||
if(count($task_count)==count($task_id)){
|
||||
$name_arr=[];
|
||||
foreach ($task_count as $key => $value) {
|
||||
@ -26,8 +32,10 @@ halt($all);
|
||||
$arr['money']=$data['template_info']['money'];
|
||||
$arr['company_id']=$data['scheduling']['company_id'];
|
||||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||||
$arr['proportion_one']=$data['template_info']['proportion_one'];
|
||||
$arr['proportion_two']=$data['template_info']['proportion_two'];
|
||||
$arr['sn']=$data['sn'];
|
||||
$arr['user_id']=$data['user_id'];
|
||||
$arr['id']=$data['id'];
|
||||
(new ShareProfit())->first($arr);
|
||||
}
|
||||
}
|
||||
@ -38,9 +46,14 @@ halt(2);
|
||||
// $time=strtotime(date('Y-m-d',strtotime('+1 day')));
|
||||
$time=strtotime(date('Y-m-d'));
|
||||
$tiem_end=$time+86399;
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling','company'])->select()->toArray();
|
||||
$company_id=0;
|
||||
foreach($all as $k=>$v){
|
||||
TaskLogic::CronAdd($v);
|
||||
$company_id=$v['company_id'];
|
||||
}
|
||||
if($company_id!=0){
|
||||
Company::where('id',$company_id)->inc('day_count')->update();
|
||||
}
|
||||
halt(TaskLogic::getError());
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ class CompanyLogic extends BaseLogic
|
||||
// if (!empty($exist)) {
|
||||
// throw new ValidateException('该账号已经注册过企业');
|
||||
// }
|
||||
$level_one = $params['contract']['party_a'] ?? 0;
|
||||
$arr=[
|
||||
'company_name' => $params['company_name'],
|
||||
'organization_code' => $params['organization_code'],
|
||||
@ -73,7 +72,6 @@ class CompanyLogic extends BaseLogic
|
||||
'qualification' => $params['qualification'],
|
||||
'responsible_area' => $params['responsible_area'],
|
||||
'admin_id' => 0,
|
||||
'level_one' => $level_one,
|
||||
];
|
||||
$data = Company::create($arr);
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
@ -149,7 +147,6 @@ class CompanyLogic extends BaseLogic
|
||||
'other_contacts' => $params['other_contacts'],
|
||||
'area_manager' => $params['area_manager'] ?? 0,
|
||||
'qualification' => $params['qualification'],
|
||||
'level_one' => $params['contract']['party_a'] ?? 0,
|
||||
'responsible_area' => $params['responsible_area'],
|
||||
];
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace app\common\logic\finance;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
@ -12,39 +13,43 @@ class ShareProfit
|
||||
{
|
||||
public function first($data)
|
||||
{
|
||||
$company=Company::where('id',$data['company_id'])->field('id,deposit,company_money,user_id')->find();// 可能要判断预存金是否满足
|
||||
|
||||
$company=Company::where('id',$data['company_id'])->field('id,deposit,company_money,user_id,day_count')->find();// 可能要判断预存金是否满足
|
||||
if($company['day_count']<=$data['proportion_one']){
|
||||
$proportion=$data['proportion_one'];
|
||||
}else{
|
||||
$proportion=$data['proportion_two'];
|
||||
}
|
||||
//总金额除以2等于不可提现账号金额和收益
|
||||
$master_maoney=bcdiv($data['money'],2,2);
|
||||
//收益的百分之25为负责人的收益其余为成员的平分收益
|
||||
$master_maoney_user=bcdiv($master_maoney,2,2);
|
||||
$company_money=$master_maoney_user;
|
||||
|
||||
//公司账户预存金
|
||||
$company_money=$master_maoney;
|
||||
//成员数量
|
||||
$userAll=User::where('company_id',$data['company_id'])->where('admin_id',0)->field('id,user_money')->select();
|
||||
$yser_all_count=count($userAll);
|
||||
|
||||
$merber_money=bcdiv(bcsub($data['money'],$master_maoney,2),$yser_all_count,2);
|
||||
$member_maoney_user=bcdiv($merber_money,2,2);
|
||||
|
||||
$member_maoney_user=bcdiv($master_maoney_user,$yser_all_count,2);
|
||||
//负责人
|
||||
Db::startTrans();
|
||||
try {
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得收益'.$master_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得收益'.$master_maoney_user.'元',['company_id'=>$data['company_id'],'proportion'=>$proportion]];
|
||||
$this->master($arr);
|
||||
|
||||
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$master_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$master_maoney_user.'元',['company_id'=>$data['company_id'],'proportion'=>$proportion]];
|
||||
$this->master($arr);
|
||||
|
||||
//成员
|
||||
foreach ($userAll as $key => $value) {
|
||||
$company_money+=$member_maoney_user;
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得收益'.$member_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得收益'.$member_maoney_user.'元',['company_id'=>$data['company_id'],'proportion'=>$proportion]];
|
||||
$this->member($arr);
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$member_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$member_maoney_user.'元',['company_id'=>$data['company_id'],'proportion'=>$proportion]];
|
||||
$this->member($arr);
|
||||
}
|
||||
//公司
|
||||
Company::where('id',$data['company_id'])->update(['company_money'=>$company_money,'deposit'=>$company_money]);
|
||||
|
||||
Company::where('id',$data['company_id'])->inc('deposit',$company_money)->inc('company_money',$data['money'])->update();
|
||||
TaskSchedulingPlan::where('id',$data['id'])->update(['is_pay'=>1]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
|
@ -100,6 +100,11 @@ class TaskLogic extends BaseLogic
|
||||
'update_time' => time(),
|
||||
];
|
||||
$data = $arr;
|
||||
if($v['company']&& $v['company']['day_count']>$v['template_info']['stage_day_one']){
|
||||
$data['proportion']=$v['template_info']['proportion_two'];
|
||||
}else{
|
||||
$data['proportion']=$v['template_info']['proportion_one'];
|
||||
}
|
||||
$task_id[] = (new Task())->insertGetId($data);
|
||||
}
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => implode(',', $task_id), 'is_execute' => 1]);
|
||||
@ -127,6 +132,14 @@ class TaskLogic extends BaseLogic
|
||||
'update_time' => time(),
|
||||
];
|
||||
$data = $arr;
|
||||
if($v['company']&& $v['company']['day_count']>$v['template_info']['stage_day_one']){
|
||||
$data['proportion']=$v['template_info']['proportion_two'];
|
||||
}else{
|
||||
$data['proportion']=$v['template_info']['proportion_one'];
|
||||
}
|
||||
if($v['template_info']['type'] == 32){
|
||||
$data['director_uid']=$v['company']['user_id'];
|
||||
}
|
||||
$task_id = (new Task())->insertGetId($data);
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => $task_id, 'is_execute' => 1]);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace app\common\logic\task_scheduling_plan;
|
||||
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
@ -41,9 +42,11 @@ class TaskSchedulingPlanLogic extends BaseLogic
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
$company_id=TaskScheduling::where('id',$params['scheduling_id'])->value('company_id');
|
||||
try {
|
||||
TaskSchedulingPlan::create([
|
||||
'create_user_id' => $params['create_user_id'],
|
||||
'company_id' => $company_id,
|
||||
'template_id' => $params['template_id'],
|
||||
'scheduling_id' => $params['scheduling_id'],
|
||||
'start_time' => $params['start_time'],
|
||||
@ -72,8 +75,10 @@ class TaskSchedulingPlanLogic extends BaseLogic
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
$company_id=TaskScheduling::where('id',$params['scheduling_id'])->value('company_id');
|
||||
try {
|
||||
TaskSchedulingPlan::where('id', $params['id'])->update([
|
||||
'company_id' => $company_id,
|
||||
'create_user_id' => $params['create_user_id'],
|
||||
'template_id' => $params['template_id'],
|
||||
'scheduling_id' => $params['scheduling_id'],
|
||||
|
@ -16,6 +16,7 @@ namespace app\common\model\task_scheduling_plan;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\model\user\User;
|
||||
@ -49,6 +50,10 @@ class TaskSchedulingPlan extends BaseModel
|
||||
{
|
||||
return $this->hasOne(TaskTemplate::class, 'id', 'template_id');
|
||||
}
|
||||
public function company()
|
||||
{
|
||||
return $this->hasOne(Company::class, 'id', 'company_id')->field('id,day_count,user_id');
|
||||
}
|
||||
public function scheduling(){
|
||||
return $this->hasOne(TaskScheduling::class,'id','scheduling_id');
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace app\job;
|
||||
use app\common\logic\finance\ShareProfit;
|
||||
use app\common\model\task\Task;
|
||||
use think\queue\Job;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 任务结算执行的具体逻辑
|
||||
@ -19,6 +20,10 @@ class TaskInformationJob
|
||||
}
|
||||
$task_id=explode(',',$data['task_id']);
|
||||
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
|
||||
if(empty($task_count)){
|
||||
Log::error('任务结算失败,任务id:'.$task_id);
|
||||
continue;
|
||||
}
|
||||
if(count($task_count)==count($task_id)){
|
||||
$name_arr=[];
|
||||
foreach ($task_count as $key => $value) {
|
||||
@ -28,8 +33,10 @@ class TaskInformationJob
|
||||
$arr['money']=$data['template_info']['money'];
|
||||
$arr['company_id']=$data['scheduling']['company_id'];
|
||||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||||
$arr['proportion_one']=$data['template_info']['proportion_one'];
|
||||
$arr['proportion_two']=$data['template_info']['proportion_two'];
|
||||
$arr['sn']=$data['sn'];
|
||||
$arr['user_id']=$data['user_id'];
|
||||
$arr['id']=$data['id'];
|
||||
(new ShareProfit())->first($arr);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ use app\job\TaskAdd;
|
||||
use app\job\TaskInformationJob;
|
||||
use think\facade\Log;
|
||||
use yunwuxin\cron\Task;
|
||||
use app\common\model\Company;
|
||||
|
||||
class TaskCron extends Task{
|
||||
|
||||
public function configure()
|
||||
@ -23,7 +25,7 @@ class TaskCron extends Task{
|
||||
Log::error('定时任务执行成功'.date('Y-m-d H:i:s'));
|
||||
|
||||
//任务结算
|
||||
$all=TaskSchedulingPlan::whereDay('start_time','yesterday')->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all=TaskSchedulingPlan::whereDay('start_time','yesterday')->where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
@ -32,8 +34,14 @@ class TaskCron extends Task{
|
||||
$time=strtotime(date('Y-m-d'));
|
||||
$tiem_end=$time+86399;
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
$company_id=0;
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskAdd::class,$v);
|
||||
$company_id=$v['company_id'];
|
||||
}
|
||||
if($company_id!=0){
|
||||
|
||||
Company::where('id',$company_id)->inc('day_count')->update();
|
||||
}
|
||||
Log::error('定时任务执行成功2');
|
||||
//...具体的任务执行
|
||||
|
Loading…
x
Reference in New Issue
Block a user