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