This commit is contained in:
mkm 2023-09-15 13:37:21 +08:00
parent 2a65246c06
commit 9866432e21
6 changed files with 159 additions and 127 deletions

View File

@ -371,20 +371,24 @@ class CompanyController extends BaseAdminController
if (empty($params['master_name'])) {
throw new Exception('商户法人名称不能为空');
}
$master_email=Db::name('company_form')->where('organization_code',$params['organization_code'])->value('master_email');
if($master_email){
}else{
$master_email=substr(md5(uniqid()),rand(0, 22),10)."@lihai.com";
}
$data = [
'mer_intention_id' => $params['mer_intention_id'], // 商城商户入驻申请id签约完成后回调使用
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'address' => $params['address'],
'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'],
'master_email' => substr(md5(uniqid()),rand(0, 22),10)."@lihai.com",
'mer_intention_id' => $params['mer_intention_id']??'', // 商城商户入驻申请id签约完成后回调使用
'company_name' => $params['company_name']??'',
'organization_code' => $params['organization_code']??'',
'city' => $params['city']??'',
'area' => $params['area']??'',
'street' => $params['street']??'',
'address' => $params['address']??'',
'master_name' => $params['master_name']??'',
'master_phone' => $params['master_phone']??'',
'master_email' => $master_email??'',
'face_create_status' => 1,
'qualification' => $params['images']
'qualification' => !empty($params['images'])?$params['images']:json_encode([])
];
$shopMerchantModel = ShopMerchant::create($data);

View File

@ -1,4 +1,5 @@
<?php
namespace app\api\controller;
use app\common\logic\CompanyLogic;
@ -14,126 +15,111 @@ use app\common\model\user\UserAccountLog;
use think\facade\Log;
use app\job\TaskAdd;
use app\job\TaskInformationJob;
use app\job\TaskTenZehn;
use app\api\controller\JunziqianController;
use think\facade\Db;
use app\common\model\ShopMerchant;
use app\common\model\contract\ShopContract;
class CeshiController extends BaseApiController
{
public array $notNeedLogin = ['index','ceshi','ceshi1','ceshi2'];
public array $notNeedLogin = ['index', 'ceshi', 'ceshi1', 'ceshi2'];
/**
* 任务结算
*/
public function index()
{
{ //1201
// $transaction_pool=780;
// $shang_date_total_price=[
// 'arr'=>['total_price'=>305,'day_money'=>580]
// ];
// if(bcadd($shang_date_total_price['arr']['total_price'],$transaction_pool,2)>$shang_date_total_price['arr']['day_money']){
// if($shang_date_total_price['arr']['total_price']<$shang_date_total_price['arr']['day_money']){
// $shang_date_total_price['arr']['supplement']=bcsub($shang_date_total_price['arr']['day_money'],$shang_date_total_price['arr']['total_price'],2);
// }else{
// $shang_date_total_price['arr']['supplement']=0;
// $shang_date_total_price['arr']['after_transaction_pool']=0;
$id = 9;
$shopMerchant = ShopMerchant::find(['id', $id]);
// $data=json_decode($parmas['data'],true);
// if($data['status']==1){
// if($data['organizationRegNo']!=$shopMerchant->organization_code){
// Log::error(['认证回调错误:',$parmas]);
// return json(['success' => false, 'msg' => '认证回调错误']);
// }
// $shang_date_total_price['arr']['before_transaction_pool']=$transaction_pool;
// Task::where('id', 839)->update(['status' => 3,'extend'=>json_encode($shang_date_total_price)]);
// $day_money=bcsub($shang_date_total_price['arr']['total_price'],$shang_date_total_price['arr']['day_money'],2);//当天还剩多少
// TaskTemplate::where('id',109)->update(['transaction_pool'=>bcadd($transaction_pool,$day_money,2)]);
// }
$all=TaskSchedulingPlan::where('id',943)->with(['template_info','scheduling'])->select()->toArray();
foreach($all as $k=>$v){
queue(TaskInformationJob::class,$v);
}
return true;
$plan_all = TaskScheduling::where('id',119)->with('company_info')->select()->toArray();
$plan_ids = [];
foreach ($plan_all as $k => $v) {
$all = TaskTemplate::where('id', 116)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray();
$plan_ids[] = $v['id'];
if ($all) {
$plan_all[$k]['template'] = $all;
} else {
unset($plan_all[$k]);
}
}
$company_id = [];
foreach ($plan_all as $k => $v) {
foreach ($v['template'] as $kk => $vv) {
queue(TaskAdd::class,['data'=>$vv,'data_two'=>$v]);
}
$company_id[] = $v['company_id'];
}
}
/**
* 任务刷新
*/
public function ceshi(){
return false;
$time=strtotime(date('Y-m-d'));
// $time=strtotime(date('Y-m-d'));
// $tiem_end=$time+86399;where('cron_time','<',$time)->
$plan_all=TaskScheduling::where('id',99)->with('company_info')->select()->toArray();
foreach($plan_all as $k=>$v){
$all=TaskTemplate::where('status',1)->where('task_scheduling',$v['id'])->limit(30)->select()->toArray();
if($all){
$plan_all[$k]['template']=$all;
}else{
unset($plan_all[$k]);
}
}
$company_id=[];
foreach($plan_all as $k=>$v){
foreach($v['template'] as $kk=>$vv){
TaskLogic::CronAdd($vv,$v);
}
$company_id[]=$v['company_id'];
}
Company::where('id','in',$company_id)->inc('day_count')->update();
}
public function stage_inspection($v,$moeny_type='moeny',$title='一'){
$count_moeny=0;
foreach($v['template'] as $kkkk=>$vvvv){
$count_moeny+=$vvvv[$moeny_type];
}
if($count_moeny>200){
Log::info($title.'阶段金额大于200无法下达'.json_encode($v['company_info']));
return false;
}
return true;
}
//三轮车判断
public function ceshi1(){
$params=[
'car_id'=>3,
'start_time'=>'2023-08-18',
'end_time'=>'2023-08-18 23:59:59'
$shopMerchant->save(['is_authentication' => 1]);
// 生成合同
$createContractData = [
'id' => $id,
'party_a' => 1,
'party_a_name' => '泸州市海之农科技有限公司',
'party_b' => $id,
'party_b_name' => $shopMerchant->company_name,
'contract_type' => 22,
];
$task=Task::where('id',487)->select()->toArray();
foreach($task as $k=>$v){
if(isset($v['extend']['terminus']['lnglat'])&& isset($v['extend']['transfer']['lnglat'])){
$arr=$v['extend']['terminus']['lnglat'];
$a=app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
$arr_two=$v['extend']['transfer']['lnglat'];
$b=app(RemoteController::class)->coordinate($params,$arr_two[0],$arr_two[1]);
if($a<500 && $b<500){
Task::where('id',$v['id'])->update(['status'=>3]);
}
$model = new ShopContract();
$model->contract_no = time();
$model->create_time = time();
$model->check_status = 1;
$model->update_time = time();
$model->setAttrs($createContractData);
$res = $model->save($createContractData);
// }
halt($res);
$select = Db::name('company_form')->where('type', 0)
->select();
$id = 0;
foreach ($select as $key => $value) {
$id = $value['id'];
if ($value['organization_code'] != '' || $value['organization_code'] != null) {
// $pattern = "/\*/";
$name = $value['master_name'];
// if(preg_match($pattern, $name)){
// $name=$value['master_name'];
// }
// if ($value['master_email']) {
$email = $value['master_email'];
// } else {
// $email = substr(md5(uniqid()), rand(0, 22), 10) . "@lihai.com";
// }
$shopMerchantCertificationData = [
'name' => $name,
'organization_code' => $value['organization_code'],
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
'master_name' => $value['master_name'],
'master_email' => $email,
'id' => $value['id'],
];
// Db::name('company_form')->where('id', $value['id'])->update(['master_email' => $email]);
queue(TaskTenZehn::class,$shopMerchantCertificationData);
} else {
Db::name('company_form')->where('id', $value['id'])->update(['type' => -1]);
continue;
}
// $a=app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
}
halt($id);
}
public function ceshi2(){
$company = Company::where(['id'=>238])->find();
$re = CompanyLogic::originationFaceCreate($company);
halt($re);
public function ceshi1()
{
//认证一条龙
$shopMerchantCertificationData = [
'name' => 1212,
'organization_code' => 2323,
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
'master_name' => 3423,
'master_email' => 343,
'id' => 123,
];
app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
halt(111);
}
}
public function ceshi2()
{
//重新认证
$shopMerchantCertificationData = [
'name' => 1212,
'organization_code' => 2323,
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
'master_name' => 3423,
'master_email' => 343,
'id' => 123,
];
app(JunziqianController::class)->organizationReapply($shopMerchantCertificationData);
halt(111);
}
}

View File

@ -108,7 +108,7 @@ class IndexController extends BaseApiController
if ($find) {
if ($find['signing_timer'] == 0) {
Db::name('contract')->where('id', $a['id'])->update(['signing_timer' => 1]);
return true;
return json(['success' => true, 'msg' => '成功']);
} else if ($find['signing_timer'] == 1) {
Db::name('contract')->where('id', $a['id'])->update(['status' => 1, 'signing_timer' => 2]);
if ($find['type'] == 1) {
@ -126,7 +126,7 @@ class IndexController extends BaseApiController
/**商户合同签约回调 */
public function shopContractNotifyUrl()
{
$a = Request()->get();
$a = Request()->param();
Log::info(['商户合同签约回调', $a]);
// 获取合同详情
if ($a) {
@ -136,7 +136,7 @@ class IndexController extends BaseApiController
// 合同一方已签约
if ($find['signing_timer'] == 0) {
Db::name('shop_contract')->where('id', $a['id'])->update(['signing_timer' => 1]);
return true;
return json(['success' => true, 'msg' => '成功']);
} else if ($find['signing_timer'] == 1) {
// 合同另一方已签约,修改合同状态,修改公司状态
Db::name('shop_contract')->where('id', $a['id'])->update(['status' => 1, 'signing_timer' => 2]);
@ -531,10 +531,17 @@ class IndexController extends BaseApiController
{
$parmas = Request()->param();
Log::info(['认证回调:',$parmas]);
try {
$data=json_decode($parmas['data'],true);
if($data['status']==2){
return json(['success' => false, 'msg' => '失败']);
}
if ($parmas) {
// 商城系统商户入驻
if (isset($parmas['type']) && $parmas['type'] == 'shop_merchant') {
Db::name('company_form')->where('master_email',$data['emailOrMobile'])->update(['type' => 1]);
$this->shopMerchantCall($parmas);
return json(['success' => true, 'msg' => '成功']);
} else {
@ -560,7 +567,7 @@ class IndexController extends BaseApiController
}
} catch (\Exception $e) {
Log::error('认证回调错误:'.$e->getMessage());
Log::error('认证回调错误569:'.$e->getMessage());
}
return json(['success' => false, 'msg' => '失败,没有参数']);
@ -569,8 +576,18 @@ class IndexController extends BaseApiController
private function shopMerchantCall($parmas)
{
$shopMerchant = ShopMerchant::find(['id', $parmas['id']]);
Log::error($shopMerchant);
if($shopMerchant==null){
// Log::error(['没有商户580:',$parmas]);
return json(['success' => false, 'msg' => '认证回调错误']);
}
$data=json_decode($parmas['data'],true);
if($data['status']==1){
if($data['organizationRegNo']!=$shopMerchant['organization_code']){
Log::error(['认证回调错误586:',$parmas]);
return json(['success' => false, 'msg' => '认证回调错误']);
}
$shopMerchant->save(['is_authentication' => 1]);
// 生成合同
$createContractData = [

26
app/job/TaskTenZehn.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace app\job;
use app\common\logic\task\TaskLogic;
use think\queue\Job;
use app\api\controller\JunziqianController;
/**
* 任务下发执行的具体逻辑
*/
class TaskTenZehn
{
public function fire(Job $job, $data)
{
if ($job->attempts() > 3) {
//通过这个方法可以检查这个任务已经重试了几次了
}
$a=app(JunziqianController::class)->organizationReapply($data);
// TaskLogic::CronAdd($data['data'],$data['data_two']);
//如果任务执行成功后 记得删除任务不然这个任务会重复执行直到达到最大重试次数后失败后执行failed方法
$job->delete();
}
}

View File

@ -10,7 +10,7 @@
// +----------------------------------------------------------------------
return [
'default' => 'sync',
'default' => 'redis',
'connections' => [
'sync' => [
'type' => 'sync',

View File

@ -1 +0,0 @@
jvGPsGV8dSY3kiokKm83QbY7p7AzLpoiYRDILKtqxTw.ygZpRA3Elso4JmfhhS2sEZzf8WSBgcsagKxvXavv6_M