更新
This commit is contained in:
parent
41bcbab415
commit
24455e8f69
@ -4,35 +4,79 @@ namespace app\api\controller;
|
||||
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use think\facade\Log;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
|
||||
class RemoteController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['index'];
|
||||
public function index()
|
||||
|
||||
public function shang_date_total_price($company)
|
||||
{
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day', time()));
|
||||
$parmas = [
|
||||
"brigade_id" => "3",
|
||||
"city_code" => "510500",
|
||||
"district_code" => "510502",
|
||||
"street_code" => "510502106",
|
||||
"village_code" => "510502106201",
|
||||
"start_date" => "2023-08-12",
|
||||
"end_date" => "2023-08-12"
|
||||
"start_date" => $yesterday,
|
||||
"end_date" => $yesterday
|
||||
];
|
||||
switch ($company['company_type']) {
|
||||
case 18:
|
||||
$parmas['brigade_id'] = $company['brigade'];
|
||||
$parmas['village_code'] = $company['village'];
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 17:
|
||||
$parmas['village_code'] = $company['village'];
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 16:
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 15:
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 14:
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
default:
|
||||
Log::error('任务结算失败,公司类型错误:' . $company['company_type']);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$res = HttpClient::create()->request('GET', 'https://crmeb-test.shop.lihaink.cn/api/order/statistics', [
|
||||
'query' => $parmas,
|
||||
]);
|
||||
$arr = json_decode($res->getContent(), true);
|
||||
if ($arr['status'] == 200) {
|
||||
$data['total_price'] = $arr['data']['total_price'];
|
||||
$json = json_decode($res->getContent(), true);
|
||||
$arr['total_price'] = 0;
|
||||
$arr['status'] = 0;
|
||||
$name = '片区交易';
|
||||
if ($json['status'] == 200) {
|
||||
$arr['total_price'] = $json['data']['total_price'];
|
||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||
$user_count = UserInformationg::where('company_id', $company['id'])->count();
|
||||
$user_count_two = 5 * $company['day_count'];
|
||||
if ($user_count_two > $user_count) {
|
||||
$user_count_money = 58 * $user_count;
|
||||
} else {
|
||||
$user_count_money = 58 * $user_count_two;
|
||||
}
|
||||
if ($json['data']['total_price'] > $user_count_money) {
|
||||
$arr['status'] = 1;
|
||||
$name = '片区交易';
|
||||
}
|
||||
} else {
|
||||
$data['total_price'] = 0;
|
||||
Log::error('获取订单金额失败:' . $arr . '参数:' . json_encode($parmas));
|
||||
Log::error('获取订单金额失败:' . $json . '参数:' . json_encode($parmas));
|
||||
}
|
||||
return ['name' => $name, 'arr' => $arr];
|
||||
} catch (\Exception $e) {
|
||||
halt($e->getMessage());
|
||||
Log::error('获取订单金额失败:' . $e->getMessage() . '参数:' . json_encode($parmas));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\user\User;
|
||||
|
||||
@ -37,8 +38,17 @@ class TaskController extends BaseApiController{
|
||||
->field(['id', 'title','money','template_id','director_uid', 'company_id', 'start_time', 'end_time', 'director_uid', 'type', 'status', 'content','extend'])
|
||||
->page($page,25)
|
||||
->order(['id' => 'desc','status'=>'asc'])
|
||||
->select()
|
||||
->toArray();
|
||||
->select()->each(function($item){
|
||||
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')->find(); // 可能要判断预存金是否满足
|
||||
$res=App(RemoteController::class)->shang_date_total_price($company);
|
||||
if($res!=false){
|
||||
$item->extend['transaction']=$res;
|
||||
}else{
|
||||
$item->extend['transaction']='';
|
||||
}
|
||||
}
|
||||
})->toArray();
|
||||
return $this->success('ok', $res);
|
||||
}
|
||||
}
|
@ -91,6 +91,7 @@ class TaskLogic extends BaseLogic
|
||||
$data['money'] = self::task_money($v);
|
||||
if($v['template_info']['type'] == 31){
|
||||
$data["extend"]=json_encode(['informationg'=>['count'=>5,'update'=>0]]);
|
||||
TaskTemplate::where('id',$v['template_id'])->inc('information_day_count',5)->update();
|
||||
}else{
|
||||
$data["extend"]=json_encode([]);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\job;
|
||||
|
||||
use app\api\controller\RemoteController;
|
||||
use app\common\logic\finance\ShareProfit;
|
||||
use app\common\model\task\Task;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
@ -9,6 +10,7 @@ use think\queue\Job;
|
||||
use think\facade\Log;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\informationg\UserInformationg;
|
||||
use think\facade\App;
|
||||
|
||||
/**
|
||||
* 任务结算执行的具体逻辑
|
||||
@ -33,69 +35,13 @@ class TaskInformationJob
|
||||
} elseif
|
||||
//交易金额
|
||||
($data['template_info']['type'] == 33) {
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day', time()));
|
||||
$parmas = [
|
||||
"start_date" => $yesterday,
|
||||
"end_date" => $yesterday
|
||||
];
|
||||
switch ($company['company_type']) {
|
||||
case 18:
|
||||
$parmas['brigade_id'] = $company['brigade'];
|
||||
$parmas['village_code'] = $company['village'];
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 17:
|
||||
$parmas['village_code'] = $company['village'];
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 16:
|
||||
$parmas['street_code'] = $company['street'];
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 15:
|
||||
$parmas['district_code'] = $company['area'];
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
case 14:
|
||||
$parmas['city_code'] = $company['city'];
|
||||
break;
|
||||
default:
|
||||
Log::error('任务结算失败,公司类型错误:' . $company['company_type']);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$res = HttpClient::create()->request('GET', 'https://crmeb-test.shop.lihaink.cn/api/order/statistics', [
|
||||
'query' => $parmas,
|
||||
]);
|
||||
$json = json_decode($res->getContent(), true);
|
||||
$arr['total_price'] = 0;
|
||||
$name = '片区交易';
|
||||
if ($json['status'] == 200) {
|
||||
$arr['total_price'] = $json['data']['total_price'];
|
||||
//基础金额*(每日基户数*天数)//且户数小于公司总户数
|
||||
$user_count = UserInformationg::where('company_id', $data['company_id'])->count();
|
||||
$user_count_two = 5 * $company['day_count'];
|
||||
if ($user_count_two > $user_count) {
|
||||
$user_count_money = 58 * $user_count;
|
||||
} else {
|
||||
$user_count_money = 58 * $user_count_two;
|
||||
}
|
||||
if ($json['data']['total_price'] > $user_count_money) {
|
||||
$arr['status'] = 1;
|
||||
$name = '片区交易';
|
||||
}
|
||||
} else {
|
||||
Log::error('获取订单金额失败:' . $json . '参数:' . json_encode($parmas));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('获取订单金额失败:' . $e->getMessage() . '参数:' . json_encode($parmas));
|
||||
$shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company);
|
||||
if ($shang_date_total_price == false) {
|
||||
Log::info('任务结算失败,交易金额未达到要求:' . json_encode($data));
|
||||
return false;
|
||||
}
|
||||
$name = $shang_date_total_price['name'];
|
||||
$arr['status'] = $shang_date_total_price['arr']['status'];
|
||||
} else {
|
||||
$task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find();
|
||||
if (empty($task_count)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user