更新
This commit is contained in:
parent
2ec4cd262f
commit
90415446b8
@ -18,6 +18,7 @@ namespace app\adminapi\lists;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\Company;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -39,7 +40,7 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['level_two', 'level_one', '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'],
|
||||
'=' => ['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'],
|
||||
'%like%' => ['company_name'],
|
||||
];
|
||||
}
|
||||
@ -56,10 +57,35 @@ class CompanyLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params=$this->request->param();
|
||||
$where=[];
|
||||
if($this->adminInfo['root']!=1){
|
||||
$where['area_manager']=$this->adminId;
|
||||
}
|
||||
if(isset($params['company_id']) && $params['company_id']!=''){
|
||||
$arr= Company::where('company_name','like','%'.$params['company_id'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['party_a|party_b','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['area_manager']) && $params['area_manager']!=''){
|
||||
$arr= Admin::where('name','like','%'.$params['area_manager'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['area_manager','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['area']) && $params['area']!=''){
|
||||
$arr= Db::name('geo_area')->where('area_name','like','%'.$params['area'].'%')->column('area_code');
|
||||
if($arr){
|
||||
$where[]=['area','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['street']) && $params['street']!=''){
|
||||
$arr= Db::name('geo_street')->where('street_name','like','%'.$params['street'].'%')->column('street_code');
|
||||
if($arr){
|
||||
$where[]=['street','in',$arr];
|
||||
}
|
||||
}
|
||||
return Company::where($this->searchWhere)
|
||||
->where($where)
|
||||
->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'])
|
||||
|
@ -18,6 +18,8 @@ namespace app\adminapi\lists\contract;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\Company;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
@ -39,7 +41,6 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
return [
|
||||
'=' => ['contract_type', 'contract_no', 'status'],
|
||||
'%like%' => ['company_id', 'party_a', 'party_b', 'area_manager'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -66,7 +67,18 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$where[] = ['check_status', 'in',[2,3]];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($params['company_id']) && $params['company_id']!=''){
|
||||
$arr= Company::where('company_name','like','%'.$params['company_id'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['party_a|party_b','in',$arr];
|
||||
}
|
||||
}
|
||||
if(isset($params['area_manager']) && $params['area_manager']!=''){
|
||||
$arr= Admin::where('name','like','%'.$params['area_manager'].'%')->column('id');
|
||||
if($arr){
|
||||
$where[]=['area_manager','in',$arr];
|
||||
}
|
||||
}
|
||||
return Contract::where($this->searchWhere)->where($where)->with(['companyName','party_a_info','contractType'])
|
||||
// ->field(['id', 'company_id', 'contract_type', 'contract_no', 'status', 'party_a', 'party_b', 'area_manager'])
|
||||
|
@ -15,10 +15,13 @@ class CeshiController extends BaseApiController
|
||||
$all=TaskSchedulingPlan::whereDay('start_time')->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('nikename')->select();
|
||||
halt(count($task_count)==count($task_id));
|
||||
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
|
||||
if(count($task_count)==count($task_id)){
|
||||
$name=implode(',',$task_count);
|
||||
$name_arr=[];
|
||||
foreach ($task_count as $key => $value) {
|
||||
$name_arr[$key]=$value['director_info']['nickname'];
|
||||
}
|
||||
$name=implode(',',$name_arr);
|
||||
$arr['money']=$data['template_info']['money'];
|
||||
$arr['company_id']=$data['scheduling']['company_id'];
|
||||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||||
@ -27,16 +30,18 @@ class CeshiController extends BaseApiController
|
||||
(new ShareProfit())->first($arr);
|
||||
}
|
||||
}
|
||||
halt($all);
|
||||
halt(2);
|
||||
}
|
||||
|
||||
public function ceshi(){
|
||||
// $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])->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
halt($all);
|
||||
foreach($all as $k=>$v){
|
||||
TaskLogic::CronAdd($v);
|
||||
}
|
||||
halt(TaskLogic::getError());
|
||||
}
|
||||
}
|
@ -72,6 +72,8 @@ class AccountLogEnum
|
||||
const UM_INC = [
|
||||
self::UM_INC_ADMIN,
|
||||
self::UM_INC_RECHARGE,
|
||||
self::UM_INC_TASK,
|
||||
self::UM_INC_TASKUSER,
|
||||
];
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace app\common\logic;
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\user\UserAccountLog;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 账户流水记录逻辑层
|
||||
@ -43,11 +44,13 @@ class AccountLogLogic extends BaseLogic
|
||||
{
|
||||
$user = User::findOrEmpty($userId);
|
||||
if($user->isEmpty()) {
|
||||
Log::error('账户流水记录:用户不存在', ['sourceSn' => $sourceSn, 'userId' => $userId]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$changeObject = AccountLogEnum::getChangeObject($changeType);
|
||||
if(!$changeObject) {
|
||||
Log::error('账户流水记录:变动类型不存在', ['sourceSn' => $sourceSn, 'userId' => $userId, 'changeType' => $changeType]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,10 +61,17 @@ class AccountLogLogic extends BaseLogic
|
||||
break;
|
||||
// 其他
|
||||
}
|
||||
|
||||
if($extra){
|
||||
$company_id=$extra['company_id']??0;
|
||||
$extra=json_encode($extra, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$extra='';
|
||||
$company_id=0;
|
||||
}
|
||||
$data = [
|
||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||
'user_id' => $userId,
|
||||
'company_id'=>$company_id,
|
||||
'change_object' => $changeObject,
|
||||
'change_type' => $changeType,
|
||||
'action' => $action,
|
||||
@ -69,7 +79,7 @@ class AccountLogLogic extends BaseLogic
|
||||
'change_amount' => $changeAmount,
|
||||
'source_sn' => $sourceSn,
|
||||
'remark' => $remark,
|
||||
'extra' => $extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : '',
|
||||
'extra' => $extra,
|
||||
];
|
||||
return UserAccountLog::create($data);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\logic\AccountLogLogic;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class ShareProfit
|
||||
{
|
||||
@ -18,38 +20,51 @@ class ShareProfit
|
||||
|
||||
$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);
|
||||
|
||||
//负责人
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得收益'.$master_maoney_user.'元'];
|
||||
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']]];
|
||||
$this->master($arr);
|
||||
$arr=[$company['user_id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$master_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$master_maoney_user.'元'];
|
||||
|
||||
|
||||
$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']]];
|
||||
$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.'元'];
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得收益'.$member_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$this->member($arr);
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$member_maoney_user.'元'];
|
||||
$arr=[$value['id'], AccountLogEnum::UM_INC_TASKUSER, AccountLogEnum::INC,$member_maoney_user,$data['sn'],$data['msg'].'获得账户余额'.$member_maoney_user.'元',['company_id'=>$data['company_id']]];
|
||||
$this->member($arr);
|
||||
}
|
||||
//公司
|
||||
Company::where('id',$data['company_id'])->update(['company_money'=>$company_money,'deposit'=>$company_money]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error('任务结算失败:'.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**负责人的分润
|
||||
* @param $data
|
||||
*/
|
||||
private function master($data): void{
|
||||
AccountLogLogic::add($data[0],$data[1],$data[2],$data[3],$data[4]);
|
||||
private function master($data){
|
||||
return AccountLogLogic::add($data[0],$data[1],$data[2],$data[3],$data[4],$data[5],$data[6]);
|
||||
}
|
||||
|
||||
/**成员分润
|
||||
* @param $data
|
||||
*/
|
||||
private function member($data): void{
|
||||
AccountLogLogic::add($data[0],$data[1],$data[2],$data[3],$data[4]);
|
||||
private function member($data){
|
||||
return AccountLogLogic::add($data[0],$data[1],$data[2],$data[3],$data[4],$data[5],$data[6]);
|
||||
}
|
||||
}
|
@ -70,11 +70,13 @@ class TaskLogic extends BaseLogic
|
||||
*/
|
||||
public static function CronAdd(array $v): bool
|
||||
{
|
||||
|
||||
if ($v['template_info'] != null) {
|
||||
$extend = [];
|
||||
try{
|
||||
if ($v['template_info']['type'] == 31) {
|
||||
$res = self::random_informationg($v['scheduling']['company_id']);
|
||||
if(!$res){
|
||||
return true;
|
||||
}
|
||||
$task_id=[];
|
||||
foreach ($res as $key => $value) {
|
||||
$extend['informationg']['arr'] = $value['id'];
|
||||
@ -86,6 +88,7 @@ class TaskLogic extends BaseLogic
|
||||
'template_id' => $v['template_id'],
|
||||
'scheduling_plan_id' => $v['id'],
|
||||
'company_id' => $v['scheduling']['company_id'],
|
||||
'director_uid' => $value['create_user_id'],
|
||||
'title' => $v['template_info']['title'],
|
||||
'money' => $v['template_info']['money'],
|
||||
'type' => $v['template_info']['type'],
|
||||
@ -99,7 +102,8 @@ class TaskLogic extends BaseLogic
|
||||
$data = $arr;
|
||||
$task_id[] = (new Task())->insertGetId($data);
|
||||
}
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => implode(',', $task_id)]);
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => implode(',', $task_id), 'is_execute' => 1]);
|
||||
return true;
|
||||
} else {
|
||||
// foreach ($res as $key => $value) {
|
||||
// $extend['informationg']['arr']=$value['id'];
|
||||
@ -123,16 +127,16 @@ class TaskLogic extends BaseLogic
|
||||
'update_time' => time(),
|
||||
];
|
||||
$data = $arr;
|
||||
$task_id = (new Task())->insertGetId($data);
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => $task_id, 'is_execute' => 1]);
|
||||
}
|
||||
$task_id = (new Task())->insertGetId($data);
|
||||
TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => $task_id]);
|
||||
}
|
||||
if ($res) {
|
||||
return true;
|
||||
} else {
|
||||
Log::error('定时任务添加失败');
|
||||
return self::setError('写入失败');
|
||||
}catch(\Exception $e){
|
||||
Log::error('定时任务添加失败',[$e->getMessage()]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,10 +20,14 @@ class TaskInformationJob
|
||||
$task_id=explode(',',$data['task_id']);
|
||||
$task_count=Task::where('id','in',$task_id)->field('nikename')->select();
|
||||
if(count($task_count)==count($task_id)){
|
||||
$name=implode(',',$task_count);
|
||||
$name_arr=[];
|
||||
foreach ($task_count as $key => $value) {
|
||||
$name_arr[$key]=$value['director_info']['nickname'];
|
||||
}
|
||||
$name=implode('、',$name_arr);
|
||||
$arr['money']=$data['template_info']['money'];
|
||||
$arr['company_id']=$data['scheduling']['company_id'];
|
||||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||||
$arr['sn']=$data['sn'];
|
||||
$arr['user_id']=$data['user_id'];
|
||||
(new ShareProfit())->first($arr);
|
||||
|
@ -5,12 +5,14 @@ namespace app\task;
|
||||
use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
|
||||
use app\job\TaskAdd;
|
||||
use app\job\TaskInformationJob;
|
||||
use think\facade\Log;
|
||||
use yunwuxin\cron\Task;
|
||||
class TaskCron extends Task{
|
||||
|
||||
public function configure()
|
||||
{
|
||||
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
|
||||
// $this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
|
||||
$this->everyMinute();
|
||||
}
|
||||
/**
|
||||
* 执行任务
|
||||
@ -18,18 +20,22 @@ class TaskCron extends Task{
|
||||
*/
|
||||
protected function execute()
|
||||
{
|
||||
Log::error('定时任务执行成功1');
|
||||
|
||||
//任务结算
|
||||
$all=TaskSchedulingPlan::whereDay('start_time')->with(['template_info','scheduling'])->select()->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskInformationJob::class,$v);
|
||||
}
|
||||
//任务下发
|
||||
$time=strtotime(date('Y-m-d',strtotime('+1 day')));
|
||||
// $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])->with(['template_info','scheduling'])->select()->toArray();
|
||||
$all=TaskSchedulingPlan::where('start_time','between',[$time,$tiem_end])->where('is_execute',0)->with(['template_info','scheduling'])->select()->toArray();
|
||||
foreach($all as $k=>$v){
|
||||
queue(TaskAdd::class,$v);
|
||||
}
|
||||
Log::error('定时任务执行成功2');
|
||||
//...具体的任务执行
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user