509 lines
13 KiB
PHP
Raw Normal View History

2024-09-29 15:43:18 +08:00
<?php
namespace app\gateway\controller\api;
use app\merchant\service\OrderService;
/**
* 回调处理
* Class Handle
* @package app\gateway\api
*/
class Notify extends Core
{
# 是否检测数据
protected $check = false;
# 普通回调
public function call(): void
{
//$this->log(222222);
$log['type'] = 'notify';
$input = input();
/*
$input = '{"s_type":1,"s_order":"Q202012136344128716383742","voucherNo":"","sign":"345AF8D8CAF418BD7973C5750597C4C4","mid":"1367893433324477","orderNum":"Q202012133351677645780669","cardNo":"1000113700013929562","status":"1"}';
$input = json_decode($input, true);
*/
$order_id = $input['s_order'];
$log['order_id'] = $order_id;
if ($input['s_type'] == 2) {
$input = file_get_contents("php://input");
$input = json_decode($input, true);
} else {
unset($input['s_type']);
}
$log['request'] = $input;
$this->log($log);
if ($order_id) {
$this->notify($order_id, $log['request']);
}
echo 'error';die;
}
# maihan回调
public function ze(): void
{
$this->notify_call('order_no');
}
public function dyr(): void
{
$input = input();
if (isset($input[0]) && $input[0]) {
if (is_string($input[0])) {
$input = json_decode($input[0], true);
} else {
$input = $input[0];
}
}
$log['type'] = 'notify';
$log['request'] = $input;
$this->log($log);
if(isset($input['out_trade_num']) && $input['out_trade_num']) {
$order_id = $input['out_trade_num'];
if ($order_id) {
if (strstr($order_id, '-')) {
$temp = explode('-', $order_id);
$order_id = $temp[0];
}
$orderService = OrderService::instance();
$order = $orderService->get($order_id);
if(isset($order['channel_order_id']) && $input['order_number'] != $order['channel_order_id']) {
echo 'error';die;
}
$this->notify($order_id, $log['request']);
}
}
echo 'error';die;
// $this->notify_call('out_trade_num');
}
# maihan回调
public function maihan()
{
$this->notify_call('ret_para');
}
#金嘉奇
public function jinjiaqi()
{
$this->notify_call('UserOrderId');
}
#金嘉奇
public function shenghui()
{
$this->notify_call('thirdOrderNo');
}
# 趣传回调
public function shouka()
{
$this->notify_call('MerchantOrderID');
}
# 小马系统回调
public function ma()
{
$this->notify_call('merchant_order_id');
}
# 小马系统回调
public function rainend()
{
$this->notify_call('outOrderId');
}
# 系统回调
public function feinimoshu()
{
$this->notify_call('morder');
}
# 博鼎城回调
public function bodingcheng()
{
$this->notify_call('downstreamSerialno');
}
# 达尚回调
public function dashang()
{
$this->notify_call('downstreamSerialno');
}
# 明盛回调
public function mingsheng()
{
$this->notify_call('downstreamSerialno');
}
# 首浩回调
public function shouhao_call()
{
$this->notify_call('orderNum');
}
public function flow_call()
{
$this->notify_call('consumerNo');
}
public function feizhidu()
{
$this->notify_call('third_id');
}
# 首浩回调,主动发起
public function shouhao()
{
return;
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 10018;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
$class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
$result = $channelService->call('query', $v['cid'], $v['order_id']);
$class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] < 3) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
# 主动发起
public function dy()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 48;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
$class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
$result = $channelService->call('query', $v['cid'], $v);
$class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] < 3) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
# 平安回调
public function pingan()
{
$this->notify_call('ret_para');
}
# 联创回调
public function lianchuang()
{
$this->notify_call('partnerOrderNo');
}
# 辽宁鑫宏
public function hongxin()
{
$this->notify_call('orderNum');
}
# 聚合
public function juhe()
{
$this->notify_call('orderid');
}
#
public function zhierbei()
{
$this->notify_call('consumerNo');
}
public function guorui()
{
$this->notify_call('user_order');
}
public function jiashi()
{
$this->notify_call('orderId');
}
public function niuniu()
{
$this->notify_call('tmporder');
}
public function yuanju()
{
$this->notify_call('orderApiNo');
}
public function lupay()
{
$this->notify_call('OutID');
}
public function gufeng()
{
$this->notify_call('order_num');
}
public function huachuang()
{
$this->notify_call('serialNo');
}
public function qianfan()
{
$this->notify_call('user_order');
}
public function niubite()
{
$this->notify_call('third_id');
}
public function weizhixing()
{
$this->notify_call('trans_no');
}
public function yinhuochong()
{
$this->notify_call('customerOrderId');
}
public function kutu()
{
$this->notify_call('orderId');
}
public function manxiangyou()
{
$args = input('args');
$log['type'] = 'notify';
$log['request'] = $args;
$this->log($log);
# 解密
$channelService = \app\channel\service\ChannelService::instance();
$input = $channelService->call('decode', 10080, $args);
$key = 'sn';
$log['type'] = 'notify';
$log['request'] = $input;
$this->log($log);
if(isset($input[$key]) && $input[$key]) {
$order_id = $input[$key];
if ($order_id) {
if (strstr($order_id, '-')) {
$temp = explode('-', $order_id);
$order_id = $temp[0];
}
$this->notify($order_id, $log['request']);
}
}
echo 'error';die;
}
public function jingheng()
{
$this->notify_call('ext');
}
public function xinjunhui()
{
$this->notify_call('orderNo');
}
public function huifen()
{
$this->notify_call('orderNo');
}
public function huashang()
{
$this->notify_call('rechargeNo');
}
public function huadan()
{
$this->notify_call('order_id');
}
# 公共回调方法
private function notify_call($key)
{
$input = input();
if (isset($input[0]) && $input[0]) {
if (is_string($input[0])) {
$input = json_decode($input[0], true);
} else {
$input = $input[0];
}
}
$log['type'] = 'notify';
$log['request'] = $input;
$this->log($log);
if(isset($input[$key]) && $input[$key]) {
$order_id = $input[$key];
if ($order_id) {
if (strstr($order_id, '-')) {
$temp = explode('-', $order_id);
$order_id = $temp[0];
}
$this->notify($order_id, $log['request']);
}
}
echo 'error';die;
}
# 卡有回调,主动查询
public function kayou()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 8;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
$class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
$result = $channelService->call('query', $v['cid'], $v);
$class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] < 3) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
# 卡有回调,主动查询
public function yixunlian()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 18;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
$class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
$result = $channelService->call('query', $v['cid'], $v['order_id']);
$class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['nFlag']) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
# 渠道僧下卡密,主动查询
public function shengxiakami()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 5;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
$class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
// var_dump($v);die;
$result = $channelService->call('query', $v['cid'], $v);
// var_dump($v);die;
$class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] == 7) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
# 渠道僧下卡密,主动查询
public function xunmai()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 2;
$where['status'] = 1;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
// $class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
// var_dump($v);die;
$result = $channelService->call('query', $v['cid'], $v);
// if($result['status'] == 7)
// var_dump($result);die;
// $class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] == 7) {
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
public function niannian()
{
$channelService = \app\channel\service\ChannelService::instance();
$class = \app\merchant\service\OrderService::instance();
$where['cid'] = 2;
$where['status'] = 4;
$data = $class->db()->where($where)->order('id asc')->limit(100)->select()->toArray();
if ($data) {
foreach ($data as $k => $v) {
// $class->db()->where(array('id' => $v['id']))->update(array('status' => 6));
// var_dump($v);die;
$result = $channelService->call('query', $v['cid'], $v);
// var_dump($v);die;
// $class->db()->where(array('id' => $v['id']))->update(array('status' => 4));
if ($result['status'] != 4) {
// var_dump($v['order_id'],$result['status']);
$this->notify($v['order_id'], $result, false, false);
}
}
}
}
public function queue_query($order_id,$result){
2024-11-02 15:27:08 +08:00
2024-09-29 15:43:18 +08:00
$this->notify($order_id, $result, false, false);
}
}