This commit is contained in:
mkm 2023-08-10 10:29:57 +08:00
parent e656eebb76
commit 5ff06c1446
6 changed files with 49 additions and 10 deletions

View File

@ -20,7 +20,8 @@ use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\task\TaskLists;
use app\common\logic\task\TaskLogic;
use app\adminapi\validate\task\TaskValidate;
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\task_template\TaskTemplate;
/**
* 任务控制器
@ -69,6 +70,11 @@ class TaskController extends BaseAdminController
return $this->fail(TaskLogic::getError());
}
public function CronAdd(){
$all=TaskSchedulingPlan::whereDay('start_time')->with('template_info')->select();
TaskLogic::CronAdd($all->toArray());
halt($all->toArray());
}
/**
* @notes 编辑任务

View File

@ -123,14 +123,14 @@ class ContractLogic extends BaseLogic
->withAttr('party_b_info', function ($value, $data) {
if ($data['type'] == 1) {
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
qualification'];
$company = Company::where(['id' => $data['party_b']])->field($field)->find();
$company['qualification'] = json_decode($company['qualification'], true);
return $company;
} else {
$filed = ['id,id_card,avatar,nickname,sex,mobile,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,nickname master_name,
qualification'];
$user = User::where('id', $data['party_b'])->field($filed)->find();
$user['qualification'] = json_decode($user['qualification'], true);
@ -139,7 +139,7 @@ class ContractLogic extends BaseLogic
})
->withAttr('party_a_info', function ($value, $data) {
$field = ['id,company_name,company_type,company_type company_type_name,organization_code,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,
province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name,
qualification'];
$company = Company::where(['id' => $data['party_a']])->field($field)->find();
$company['qualification'] = json_decode($company['qualification'], true);

View File

@ -10,16 +10,16 @@ class ShareProfit
{
public function first($data)
{
$company=Company::where('id',$data['company_id'])->field('id,deposit,company_money')->find();
// $company=Company::where('id',$data['company_id'])->field('id,deposit,company_money')->find(); 可能要判断预存金是否满足
$master_maoney=bcdiv($data['money'],2,2);
$master_maoney_user=bcdiv($master_maoney,2,2);
$company_money=$master_maoney_user;
$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);
$master_maoney_user=bcdiv($merber_money,2,2);
$member_maoney_user=bcdiv($merber_money,2,2);
//负责人
$arr=[$data['user_id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得收益'.$master_maoney_user.'元'];
@ -29,13 +29,14 @@ class ShareProfit
//成员
foreach ($userAll as $key => $value) {
$arr=[$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得收益'.$master_maoney_user.'元'];
$company_money+=$member_maoney_user;
$arr=[$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得收益'.$member_maoney_user.'元'];
$this->member($arr);
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$master_maoney_user.'元'];
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$member_maoney_user.'元'];
$this->member($arr);
}
//公司
Company::where('id',$data['company_id'])->update(['company_money'=>bcadd($company['company_money'],$data['money'],2)]);
Company::where('id',$data['company_id'])->update(['company_money'=>$company_money,'deposit'=>$company_money]);
}
/**负责人的分润

View File

@ -64,6 +64,14 @@ class TaskLogic extends BaseLogic
}
}
public static function CronAdd(array $params): bool
{
// foreach($params as $k=>$v){
// if()
// }
return false;
}
/**
* @notes 编辑任务

View File

@ -43,4 +43,8 @@ class TaskSchedulingPlan extends BaseModel
{
return $this->hasOne(TaskTemplate::class, 'id', 'template_id')->bind(['template_name'=>'title']);
}
public function templateInfo()
{
return $this->hasOne(TaskTemplate::class, 'id', 'template_id');
}
}

20
app/task/TaskCron.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace app\task;
use yunwuxin\cron\Task;
class TaskCron extends Task{
public function configure()
{
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
}
/**
* 执行任务
* @return mixed
*/
protected function execute()
{
//...具体的任务执行
}
}