diff --git a/app/channel/service/system/Core.php b/app/channel/service/system/Core.php index 5810ee4..1d90983 100644 --- a/app/channel/service/system/Core.php +++ b/app/channel/service/system/Core.php @@ -147,14 +147,11 @@ class Core if (isset($this->channel['order_limit']) && $this->channel['order_limit'] > 0) { $status = -3; } - $state = $this->create($param['order'], '', $merchant_order, $param['cash'], '', $this->data, $response, $status, $account, $parent_order_id, $this->card_id, false); - if (!$state) { return '余额不足下单失败'; } - if ($status == 1) { #判断卡库提单,如果为卡库提单,则储存普通数据,不执行队列 @@ -162,10 +159,16 @@ class Core #当产品为cardbuy卡密采购,则搜索商户设置 $merchant = MerchantService::instance()->get($this->data['merchant']); if(isset($merchant['kami_status']) && $merchant['kami_status'] == 1 && $merchant['merchant_type'] != 1){ - $redis = RedisService::getInstance(); - $redis_key = 'Kami_wait_'.$param['order']; + if(isset($merchant['other_param']) && str_contains($merchant['other_param'], '"autoCardSoftware":"3"')){ + #"autoCardSoftware":"3" + $this->queue('submit', $this->data); + }else{ + $redis = RedisService::getInstance(); + $redis_key = 'Kami_wait_'.$param['order']; + + $redis->set($redis_key, $this->data, 6000); + } - $redis->set($redis_key, $this->data, 6000); }else{ $this->queue('submit', $this->data); diff --git a/app/merchant/controller/Merchant.php b/app/merchant/controller/Merchant.php index 8291835..855ff80 100644 --- a/app/merchant/controller/Merchant.php +++ b/app/merchant/controller/Merchant.php @@ -530,13 +530,15 @@ class Merchant extends Controller if (isset($maSuDa_message_config) && isset($other_param_arr_new['maSuDa_message_config'])){ #判断是否变化,进行消息修改 TODO + } $other_json = json_encode($other_param_arr_new); $up = MerchantService::instance()->db()->where(array('id' => $id))->update(['other_param'=>$other_json]); - if($up == false){ - $this->error('修改失败,请联系技术处理!'); +// return $up; + if(!$up){ + $this->error('修改失败,请核查是否未变动!请联系技术处理!'); }else{ $this->success('自动发货软件修改成功!', ''); } diff --git a/app/merchant/view/merchant/autoCard.html b/app/merchant/view/merchant/autoCard.html index 903a53f..4cded06 100644 --- a/app/merchant/view/merchant/autoCard.html +++ b/app/merchant/view/merchant/autoCard.html @@ -6,7 +6,7 @@ 自动发卡设置 - {foreach [1=> '阿奇索', 2=>'码速达'] as $k => + {foreach [1=> '阿奇索', 2=>'码速达',3=>'老版本阿奇索'] as $k => $v} {if isset($autoCardSoftware) and $autoCardSoftware eq $k} {$v|default=''} @@ -52,7 +52,8 @@ - . 消息订阅详情 + + 消息订阅详情 diff --git a/app/openapi/controller/Kami91.php b/app/openapi/controller/Kami91.php index cc859b1..1845750 100644 --- a/app/openapi/controller/Kami91.php +++ b/app/openapi/controller/Kami91.php @@ -3,6 +3,7 @@ namespace app\openapi\controller; use app\channel\service\ChannelService; +use app\channel\service\ProductBaseService; use app\gateway\service\CurlService; use app\gateway\service\RedisService as redisObj; use app\merchant\service\MerchantService; @@ -85,7 +86,7 @@ class Kami91 extends Controller if(isset($info['create_at'] )){ $timestamp = strtotime($info['create_at']); $now = time(); - $time = $timestamp + 60*10 ; + $time = $timestamp + 60*5 ; if($now < $time){ $this->no(); } @@ -150,7 +151,7 @@ class Kami91 extends Controller if(isset($info['create_at'] )){ $timestamp = strtotime($info['create_at']); $now = time(); - $time = $timestamp + 60*10 ; + $time = $timestamp + 60*5 ; if($now < $time){ $this->no(); } @@ -222,7 +223,7 @@ class Kami91 extends Controller if(isset($info['create_at'] )){ $timestamp = strtotime($info['create_at']); $now = time(); - $time = $timestamp + 60*10 ; + $time = $timestamp + 60*5 ; if($now < $time){ $this->no(); } @@ -245,7 +246,7 @@ class Kami91 extends Controller if(isset($info['create_at'] )){ $timestamp = strtotime($info['create_at']); $now = time(); - $time = $timestamp + 60*10 ; + $time = $timestamp + 60*5 ; if($now < $time){ $this->no(); } @@ -390,8 +391,6 @@ class Kami91 extends Controller } - - /** * @return string */ @@ -469,7 +468,6 @@ class Kami91 extends Controller } - public function dc_charge(): void { $this->submit(); @@ -512,7 +510,7 @@ class Kami91 extends Controller if (isset($input['proid'])) { $input['proid'] = $this->mapping($input['proid'] ); # 根据产品id 获取信息 - $pinfo = \app\channel\service\ProductBaseService::instance()->getOne($input['proid']); + $pinfo = ProductBaseService::instance()->getOne($input['proid']); if (!$pinfo) { $this->no(-2); } @@ -520,7 +518,7 @@ class Kami91 extends Controller $data['product_key'] = $pinfo['key']; $data['cash'] = $pinfo['value'] ; - $pid = \app\channel\service\ProductBaseService::instance()->getProductId($pinfo['service_id']); + $pid = ProductBaseService::instance()->getProductId($pinfo['service_id']); $data['pid'] = $pid['id']; } else { @@ -560,7 +558,7 @@ class Kami91 extends Controller ]; $data['merchant_order_id'] = $merchant_order; $data['notifyurl'] = $input['notify']; - + $data['api_key'] = 'agiso_old'; $result = Kami91OrderService::instance()->up($where,$data); if(!is_numeric($result)){ diff --git a/app/openapi/controller/Test.php b/app/openapi/controller/Test.php index 206596f..5fdb487 100644 --- a/app/openapi/controller/Test.php +++ b/app/openapi/controller/Test.php @@ -99,6 +99,28 @@ class Test extends Core } + public function dy_msd_message() + { + $maSuDa = \app\openapi\controller\maSuDaApi\Order::class; + $param = input(); + $maSuDa->message_config($param['mid'],$param['tops'],$param['status']); + + } + + # 对回调再次处理,如果渠道回调失败,同时商户回调失败,将使用该方法进行再次发起回调,5分钟执行一次 + public function call() + { + $orderService = OrderService::instance(); + $data = $orderService->db()->whereRaw('merchant_callback_error = 2 and mid = 2 and merchant_callback_num < 5 and status in(2,3)')->order('id asc')->select(); + + + if ($data) { + foreach ($data as $k => $v) { + OrderService::instance()->callSend($v, 1); + } + } + } + @@ -275,6 +297,120 @@ class Test extends Core } + public function suoka_testly() + { + $data = Db::name('test_wait_suoka')->whereNotNull('merchant_order_id')->select()->toArray(); + $channelService = ChannelService::instance(); + foreach ($data as $vo) { +// $order = Db::name('merchant_order')->where(['merchant_order_id'=>$vo['merchant_order_id']])->find(); +// if(!$order){ +// $order = Db::name('merchant_order_lastweek_history')->where(['merchant_order_id'=>$vo['merchant_order_id']])->find(); +// if(!$order){ +// continue; +// } +// } + $num = $this->getNum_suoka(); + if ($num >= 20) { + # 等会儿再执行 + sleep(10); + +// return true; + } + + + $this->popen_suoka($vo['merchant_order_id']); +// $suoka = $channelService->call('lockCard', $order['cid'], $order); +// if($suoka !== 'ok' && $suoka !== 'old_ok'){ +// Db::name('test_wait_suoka')->where('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 +// Log::write('test_error_suoka', 'test_error_suoka', $vo['merchant_order_id']);#写入到日志里 +// +// var_dump($vo); +// }else{ +// Db::name('merchant_order')->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status' => 3]); +// Log::write('test_wait_suoka', 'test_wait_suoka', $vo['merchant_order_id']);#写入到日志里 +// Db::name('test_wait_suoka')->where('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 +// Db::name('test_suoka_yes')->insert(['merchant_order_id'=>$vo['merchant_order_id']]); +// } + + + } + + + + } + + public function run_suoka() + { + + $channelService = ChannelService::instance(); + + if (isset($_SERVER["argv"][2]) && $_SERVER["argv"][2]) { + $orders = $_SERVER["argv"][2]; + } else { + $orders = input('order'); + } + + $data = Db::name('merchant_order')->where(['merchant_order_id'=>$orders])->find(); + if(!$data){ + $data = Db::name('merchant_order_lastweek_history')->where(['merchant_order_id'=>$orders])->find(); + if(!$data){ + if(!$data){ + Db::name('test_suoka_wait_error')->insert(['merchant_order_id'=>$orders]); + Db::name('test_wait_suoka')->where('merchant_order_id', $orders)->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 + + +// $data = Db::name('merchant_order_last_history')->where(['merchant_order_id'=>$orders])->find(); + if(!$data){ + exit('error'); + } + } + } + } + + + if (isset($data['order_id']) && $data['order_id']) { +// if ($popen) { +//// $this->runOne +// +// +// $this->popen_suoka($data['order_id']); +// } else { + $suoka = $channelService->call('lockCard', $data['cid'], $data); + if($suoka !== 'ok' && $suoka !== 'old_ok'){ + Db::name('test_wait_suoka')->where('merchant_order_id', $data['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 + Log::write('test_error_suoka', 'test_error_suoka', $data['merchant_order_id']);#写入到日志里 + + }else{ + Db::name('merchant_order')->where(['merchant_order_id'=>$data['merchant_order_id']])->update(['status' => 3]); + Log::write('test_suoka_yes', 'test_suoka_yes', $data['merchant_order_id']);#写入到日志里 + Db::name('test_wait_suoka')->where('merchant_order_id', $data['merchant_order_id'])->delete();//这个用like会不会太范了?不会,因为order是唯一只是怕空格影响 + Db::name('test_suoka_yes')->insert(['merchant_order_id'=>$data['merchant_order_id']]); + } + + exit('ok'); + +// } + } + } + + public function getNum_suoka() + { + $command = 'ps -ef | grep openapi/test/run_suoka | grep -v grep | wc -l'; + $num = exec($command); + return $num; + } + + # 将数据推到子进程处理 + public function popen_suoka($order) + { + $command = 'php /www/wwwroot/reapi/public/index.php openapi/test/run_suoka ' . $order . ' 1>/dev/null 2>&1 &'; +// var_dump($command);die; + + exec($command); + } + + + public function finishOne_lasts() { diff --git a/app/openapi/controller/maSuDaApi/Order.php b/app/openapi/controller/maSuDaApi/Order.php index 0d58ede..0b3a008 100644 --- a/app/openapi/controller/maSuDaApi/Order.php +++ b/app/openapi/controller/maSuDaApi/Order.php @@ -37,6 +37,9 @@ class Order extends Controller ); + protected string $uid = ''; + protected string $secretKey = ''; + public function message() { @@ -370,55 +373,10 @@ class Order extends Controller $this->yes($response); -// $order_data = $this->get_Order($buyer_open_uid, $merchant_order, $secret_key); -// -// if (isset($order_data['orders']['outer_iid'])) { -// $datas['productNo'] = $this->mapping($datas['productNo'] ); -// # 根据产品id 获取信息 -// $pinfo = \app\channel\service\ProductBaseService::instance()->getOne($datas['productNo']); -// if (!$pinfo) { -// $this->no(1100); -// } -// -// -// $data['product_key'] = $pinfo['key']; -// $data['cash'] = $pinfo['value'] ; -// $pid = \app\channel\service\ProductBaseService::instance()->getProductId($pinfo['service_id']); -// -// $data['pid'] = $pid['id']; -// } else { -// $this->no(1100); -// } -// -// -// $data['status'] = '1'; -// $data['param'] = json_encode($datas); -// -// -// $where = [ -// 'mid' => $data['mid'], -// 'merchant_order_id' => $merchant_order -// ]; -// $data['merchant_order_id'] = $merchant_order; -// $data['notifyurl'] = $this->host_url; -// -// -// $result = Kami91OrderService::instance()->up($where,$data); -// -// if(!is_numeric($result)){ -// $this->no(-1000); -// } -// -// $response = [ -// 'orderNo' => $merchant_order, -// 'orderStatus' => 10, -// 'outTradeNo'=>'D'.$merchant_order, -// ]; -// $this->yes($response); - - }else{ $data['product_key'] = $orderData['product_key']; + #判断是否为非卡密 + if(!str_contains($orderData['product_key'], '_cardbuy'))return '暂时不处理非卡密订单'; $data['cash'] = $orderData['cash'] ; $data['pid'] = $orderData['pid']; @@ -665,5 +623,67 @@ class Order extends Controller throw new HttpResponseException(json($response)); } + #订阅消息 + public function message_config($mid,$topics,$status){ + $merchant = $this->getMid_info($mid); + $host = sysconf('system_host'); + + if (!$host) { + if (isset($_SERVER['SERVER_PORT']) && isset($_SERVER['HTTP_HOST'])) { + $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; + $host = $protocol.$_SERVER['HTTP_HOST']; + } else { + $host = 'https://reapi.gcdat.com'; + } + } + + $param = [ + 'uid'=>$this->uid, + 'method'=>'message_config', + 'timestamp'=>time(), + 'status'=>$status, + 'message_url'=>$host.'/openapi/maSuDaApi/Order/message?mid='.$mid, + 'topics'=>$topics + ]; + $param['sign'] =$this->_sign($param,$this->secretKey ); + + $response = $this->curl('post', $this->host_url,$param); +// var_dump($param);die; + $msg = json_decode($response,true); + + + if(is_array($msg) && isset($msg['code']) && $msg['code'] == '10000'){ + + return 'ok'; + + + }else{ + return 'fail'; + } + + } + + public function test_dy_message(){ + $param = input(); + return $this->message_config($param['mid'],$param['tops'],$param['status']); + + + } + + public function getMid_info($mid){ + $merchantService = MerchantService::instance(); + $merchant = $merchantService->getInfo($mid); + if(!$merchant){ + return $this->no(-100,'商户不存在'); + } + + $array = json_decode($merchant['other_param'],true); + + $this->uid = $array['maSuDa_uid']??''; + $this->secretKey = $array['maSuDa_secret_key']??''; + return $merchant; + + } + } \ No newline at end of file diff --git a/app/queue/command/kami91order/KamiOrderChanelNotify.php b/app/queue/command/kami91order/KamiOrderChanelNotify.php index 4d19db7..4422310 100644 --- a/app/queue/command/kami91order/KamiOrderChanelNotify.php +++ b/app/queue/command/kami91order/KamiOrderChanelNotify.php @@ -178,6 +178,9 @@ class KamiOrderChanelNotify extends Command } } + }elseif(isset($info['api_key']) && $info['api_key'] == 'agiso_old'){ + $kami91server->upStatus($vo['order_id'], 2, 'success'); + $kami91->huidiao($vo['order_id']); }else{ $up_msg=$agiso->notify($info['notifyurl'], $param,$getMerchantInfo); if($up_msg == 'success'){ @@ -298,6 +301,9 @@ class KamiOrderChanelNotify extends Command } + }elseif(isset($info['api_key']) && $info['api_key'] == 'agiso_old'){ + $kami91server->upStatus($vo['order_id'], 2, 'success'); + $kami91->huidiao($vo['order_id']); }else{ $up_msg=$agiso->notify($info['notifyurl'], $param,$getMerchantInfo); if($up_msg == 'success'){ @@ -328,6 +334,9 @@ class KamiOrderChanelNotify extends Command } + }elseif(isset($info['api_key']) && $info['api_key'] == 'agiso_old'){ + $kami91server->upStatus($vo['order_id'], 2, 'success'); + $kami91->huidiao($vo['order_id']); }else{ $check = $agiso->queryFaka($vo['merchant_order_id']);