更新任务结算和下发
This commit is contained in:
parent
9398bf0843
commit
07bccac83b
@ -42,11 +42,11 @@ class CeshiController extends BaseApiController
|
|||||||
|
|
||||||
// TaskTemplate::where('id',109)->update(['transaction_pool'=>bcadd($transaction_pool,$day_money,2)]);
|
// TaskTemplate::where('id',109)->update(['transaction_pool'=>bcadd($transaction_pool,$day_money,2)]);
|
||||||
// }
|
// }
|
||||||
$all=TaskSchedulingPlan::where('id',893)->with(['template_info','scheduling'])->select()->toArray();
|
// $all=TaskSchedulingPlan::where('id',893)->with(['template_info','scheduling'])->select()->toArray();
|
||||||
foreach($all as $k=>$v){
|
// foreach($all as $k=>$v){
|
||||||
queue(TaskInformationJob::class,$v);
|
// queue(TaskInformationJob::class,$v);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
$plan_all = TaskScheduling::where('id',119)->with('company_info')->select()->toArray();
|
$plan_all = TaskScheduling::where('id',119)->with('company_info')->select()->toArray();
|
||||||
$plan_ids = [];
|
$plan_ids = [];
|
||||||
foreach ($plan_all as $k => $v) {
|
foreach ($plan_all as $k => $v) {
|
||||||
|
@ -5,13 +5,14 @@ namespace app\api\controller;
|
|||||||
use Symfony\Component\HttpClient\HttpClient;
|
use Symfony\Component\HttpClient\HttpClient;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use app\common\model\informationg\UserInformationg;
|
use app\common\model\informationg\UserInformationg;
|
||||||
|
use app\common\model\task_template\TaskTemplate;
|
||||||
|
|
||||||
class RemoteController extends BaseApiController
|
class RemoteController extends BaseApiController
|
||||||
{
|
{
|
||||||
|
|
||||||
public array $notNeedLogin = ['index'];
|
public array $notNeedLogin = ['index'];
|
||||||
|
|
||||||
public function shang_date_total_price($company,$isDay=1,$arr=[])
|
public function shang_date_total_price($company,$isDay=1,$arr=[],$template_id)
|
||||||
{
|
{
|
||||||
if($isDay==1){
|
if($isDay==1){
|
||||||
$start_time = date('Y-m-d');
|
$start_time = date('Y-m-d');
|
||||||
@ -75,11 +76,12 @@ class RemoteController extends BaseApiController
|
|||||||
$arr['total_price'] = $json['data']['total_price'];
|
$arr['total_price'] = $json['data']['total_price'];
|
||||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||||
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
||||||
|
$day_count=TaskTemplate::where('id',$template_id)->value('day_count');
|
||||||
//
|
//
|
||||||
if($company['day_count']==0){
|
if($day_count==0){
|
||||||
$user_count_two = 5 * 1;
|
$user_count_two = 5 * 1;
|
||||||
}else{
|
}else{
|
||||||
$user_count_two = 5 * $company['day_count'];
|
$user_count_two = 5 * $day_count;
|
||||||
}
|
}
|
||||||
if ($user_count_two > $user_count) {
|
if ($user_count_two > $user_count) {
|
||||||
$user_count_money = 58 * $user_count;
|
$user_count_money = 58 * $user_count;
|
||||||
|
@ -58,7 +58,7 @@ class TaskController extends BaseApiController
|
|||||||
foreach ($res as $k => $item) {
|
foreach ($res as $k => $item) {
|
||||||
if ($item['type'] == 33) {
|
if ($item['type'] == 33) {
|
||||||
$company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足
|
$company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足
|
||||||
$find = App(RemoteController::class)->shang_date_total_price($company,1,$param);
|
$find = App(RemoteController::class)->shang_date_total_price($company,1,$param,$item['template_id']);
|
||||||
if ($find != false) {
|
if ($find != false) {
|
||||||
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
|
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
|
||||||
if($transaction_pool==0){
|
if($transaction_pool==0){
|
||||||
|
@ -21,6 +21,8 @@ class ShareProfit
|
|||||||
// } else {
|
// } else {
|
||||||
// $proportion = $data['proportion_two'];
|
// $proportion = $data['proportion_two'];
|
||||||
// }
|
// }
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
$proportion = 0;
|
$proportion = 0;
|
||||||
//总金额除以2等于不可提现账号金额和收益
|
//总金额除以2等于不可提现账号金额和收益
|
||||||
$master_maoney = bcdiv($data['money'], 2, 2);
|
$master_maoney = bcdiv($data['money'], 2, 2);
|
||||||
@ -34,8 +36,7 @@ class ShareProfit
|
|||||||
$member_maoney_user = bcdiv($master_maoney_user, $yser_all_count, 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'], 'proportion' => $proportion], $data['status']];
|
$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], $data['status']];
|
||||||
$this->master($arr);
|
$this->master($arr);
|
||||||
$arr_two = [$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], $data['status']];
|
$arr_two = [$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], $data['status']];
|
||||||
@ -57,13 +58,14 @@ class ShareProfit
|
|||||||
$this->AccountLog($data['company_id'], $company_money_count, $master_maoney);
|
$this->AccountLog($data['company_id'], $company_money_count, $master_maoney);
|
||||||
|
|
||||||
Company::where('id', $data['company_id'])->update(['deposit' => Db::raw('deposit+' . $master_maoney), 'company_money' => Db::raw('company_money+' . $master_maoney)]);
|
Company::where('id', $data['company_id'])->update(['deposit' => Db::raw('deposit+' . $master_maoney), 'company_money' => Db::raw('company_money+' . $master_maoney)]);
|
||||||
|
|
||||||
} elseif ($data['company_account_type'] == 2) {
|
} elseif ($data['company_account_type'] == 2) {
|
||||||
$company_money_count = bcadd($company['shareholder_money'], $data['money'], 2);
|
$company_money_count = bcadd($company['shareholder_money'], $data['money'], 2);
|
||||||
$this->AccountLog($data['company_id'], $company_money_count, $data['money'], 1, 2);
|
$this->AccountLog($data['company_id'], $company_money_count, $data['money'], 1, 2);
|
||||||
Company::where('id', $data['company_id'])->update(['deposit'=>Db::raw('deposit+' . $master_maoney),
|
Company::where('id', $data['company_id'])->update([
|
||||||
|
'deposit' => Db::raw('deposit+' . $master_maoney),
|
||||||
'company_money' => Db::raw('company_money+' . $master_maoney),
|
'company_money' => Db::raw('company_money+' . $master_maoney),
|
||||||
'shareholder_money'=>Db::raw('shareholder_money+' . $datas['template_info']['over_decimal'])]);
|
'shareholder_money' => Db::raw('shareholder_money+' . $datas['template_info']['over_decimal'])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($datas['template_info']['type']) && $datas['template_info']['type'] == 35) {
|
if (isset($datas['template_info']['type']) && $datas['template_info']['type'] == 35) {
|
||||||
@ -103,7 +105,8 @@ class ShareProfit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function AccountLog($companyId,$left_amount,$changeAmount,$change_object=1,$change_type=1,$action=1){
|
public function AccountLog($companyId, $left_amount, $changeAmount, $change_object = 1, $change_type = 1, $action = 1)
|
||||||
|
{
|
||||||
$company_log = [
|
$company_log = [
|
||||||
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
'sn' => generate_sn(UserAccountLog::class, 'sn', 20),
|
||||||
'company_id' => $companyId,
|
'company_id' => $companyId,
|
||||||
|
@ -187,26 +187,26 @@ class TaskLogic extends BaseLogic
|
|||||||
private static function task_money($v, $datas)
|
private static function task_money($v, $datas)
|
||||||
{
|
{
|
||||||
if ($v['types'] == 1 || $v['types'] == 3) {
|
if ($v['types'] == 1 || $v['types'] == 3) {
|
||||||
if ($datas['company_info'] && $datas['company_info']['day_count'] <= $v['stage_day_one']) {
|
if ($v['day_count'] <= $v['stage_day_one']) {
|
||||||
return $v['money'];
|
return $v['money'];
|
||||||
} else {
|
} else {
|
||||||
return $v['money_two'];
|
return $v['money_two'];
|
||||||
}
|
}
|
||||||
} elseif ($v['types'] == 2) {
|
} elseif ($v['types'] == 2) {
|
||||||
if ($datas['company_info']['day_count'] <= $v['stage_day_one']) {
|
if ($v['day_count'] <= $v['stage_day_one']) {
|
||||||
return $v['money'];
|
return $v['money'];
|
||||||
} elseif ($datas['company_info']['day_count'] <= $v['stage_day_two']) {
|
} elseif ($v['day_count'] <= $v['stage_day_two']) {
|
||||||
return $v['money_two'];
|
return $v['money_two'];
|
||||||
} else {
|
} else {
|
||||||
return $v['money_three'];
|
return $v['money_three'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($datas['company_info']['day_count'] <= $v['stage_day_one']) {
|
if ($v['day_count'] <= $v['stage_day_one']) {
|
||||||
$a = $v['money'];
|
$a = $v['money'];
|
||||||
} else {
|
} else {
|
||||||
$a = $v['money_two'];
|
$a = $v['money_two'];
|
||||||
}
|
}
|
||||||
if ($datas['company_info'] && $datas['company_info']['day_count'] >= $v['stage_day_two']) {
|
if ($v['day_count'] >= $v['stage_day_two']) {
|
||||||
TaskTemplate::where('id', $v['id'])->update(['status' => 0]);
|
TaskTemplate::where('id', $v['id'])->update(['status' => 0]);
|
||||||
}
|
}
|
||||||
return $a;
|
return $a;
|
||||||
|
@ -23,7 +23,6 @@ class TaskInformationJob
|
|||||||
// if ($job->attempts() > 1) {
|
// if ($job->attempts() > 1) {
|
||||||
// //通过这个方法可以检查这个任务已经重试了几次了
|
// //通过这个方法可以检查这个任务已经重试了几次了
|
||||||
// }
|
// }
|
||||||
Db::startTrans();
|
|
||||||
try {
|
try {
|
||||||
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]);
|
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]);
|
||||||
$company = Company::where('id', $data['company_id'])->field('id,deposit,responsible_area,company_money,shareholder_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
$company = Company::where('id', $data['company_id'])->field('id,deposit,responsible_area,company_money,shareholder_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
|
||||||
@ -124,23 +123,20 @@ class TaskInformationJob
|
|||||||
$arr['status'] = 1;
|
$arr['status'] = 1;
|
||||||
$arr['money'] = $task_count['money'];
|
$arr['money'] = $task_count['money'];
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('line:'.$e->getLine().'异常报错:任务结算失败:' . $data['template_info']['title'] . $e->getMessage() . json_encode($data));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($arr['status'] == 1) {
|
||||||
$arr['company_id'] = $data['scheduling']['company_id'];
|
$arr['company_id'] = $data['scheduling']['company_id'];
|
||||||
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成方:' . $name . ',任务结算';
|
$arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成方:' . $name . ',任务结算';
|
||||||
// $arr['proportion_one'] = $data['template_info']['proportion_one'];
|
// $arr['proportion_one'] = $data['template_info']['proportion_one'];
|
||||||
// $arr['proportion_two'] = $data['template_info']['proportion_two'];
|
// $arr['proportion_two'] = $data['template_info']['proportion_two'];
|
||||||
$arr['sn'] = $data['sn'];
|
$arr['sn'] = $data['sn'];
|
||||||
$arr['id'] = $data['id'];
|
$arr['id'] = $data['id'];
|
||||||
Db::commit();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
Log::error('line:'.$e->getLine().'异常报错:任务结算失败:' . $data['template_info']['title'] . $e->getMessage() . json_encode($data));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($arr['status'] == 1) {
|
|
||||||
(new ShareProfit())->first($arr, $company,$data);
|
(new ShareProfit())->first($arr, $company,$data);
|
||||||
} else {
|
} else {
|
||||||
Task::where('id', $data['task_id'])->update(['status' => 5,'extend'=>json_encode($shang_date_total_price)]);
|
Task::where('id', $data['task_id'])->update(['status' => 5]);
|
||||||
Log::info('任务status=0结算失败:' . $data['template_info']['title'] . '未完成' . json_encode($data));
|
Log::info('任务status=0结算失败:' . $data['template_info']['title'] . '未完成' . json_encode($data));
|
||||||
}
|
}
|
||||||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||||||
|
Loading…
x
Reference in New Issue
Block a user