
- 新增 MiniProgramsApi 控制器,实现小程序相关的接口处理 - 添加订单查询、运营商查询、产品获取、充值等接口方法 - 实现与快手 API 的交互,包括获取 access_token 等功能 - 优化账户余额查询接口,适配新的 API - 增加渠道余额检查功能
108 lines
2.8 KiB
PHP
108 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace app\openapi\controller;
|
|
|
|
use app\channel\service\ChannelService;
|
|
use think\facade\Db;
|
|
|
|
class Port extends Core
|
|
{
|
|
protected $check = false;
|
|
|
|
#检测异常接口预警
|
|
public function check_notify()
|
|
{
|
|
$cur = time();
|
|
$time = 60*6;
|
|
$whereRaw = $cur . '-unix_timestamp(create_at) <=' . $time;
|
|
$data = DB::name('merchant_order')->field("id,merchant_order_id")->whereLike('merchant_callback_msg', 'error')->whereRaw('status = 2 and ' . $whereRaw)->select();
|
|
|
|
if($data->isEmpty()){
|
|
|
|
|
|
$this->yes('ok','暂无异常订单');
|
|
}
|
|
$errorOrder=[];
|
|
foreach ($data->toArray() as $vo) {
|
|
// var_dump($vo);die;
|
|
$errorOrder[] = $vo['merchant_order_id'];
|
|
}
|
|
if($errorOrder){
|
|
$errorMsg = implode("\n", $errorOrder);
|
|
$this->no(0 ,$errorMsg);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public function check_channel_balance()
|
|
{
|
|
$channel = DB::name('channel_list')->field("id,name,key")->where('status',1)->select();
|
|
if($channel->isEmpty()){
|
|
$this->yes('ok','暂无可用渠道');
|
|
}
|
|
|
|
$channelService = ChannelService::instance();
|
|
$day = input('day');
|
|
if (!$day) {
|
|
$day = date('Y-m-d', strtotime('-1 day'));
|
|
}
|
|
$tip_info=[];
|
|
|
|
foreach ($channel->toArray() as $vo){
|
|
try{
|
|
$account_data = $channelService->call('account', $vo['id'], $day);
|
|
|
|
if (is_array($account_data) && isset($account_data['account'])) {
|
|
$balance = $account_data['account'];
|
|
if(1< $balance && $balance < 10000){
|
|
$tip_info[] = $vo['name'].'余额不足,只剩下'.$balance;
|
|
}
|
|
|
|
}
|
|
}catch (\Exception $e){
|
|
|
|
}
|
|
|
|
}
|
|
if($tip_info && !empty($tip_info)){
|
|
$errorMsg = implode("\n", $tip_info);
|
|
$this->no(0 ,$errorMsg);
|
|
}
|
|
|
|
$this->yes('ok','暂时正常');
|
|
|
|
|
|
}
|
|
|
|
#检测异常订单error过期预警
|
|
public function check_orderparam()
|
|
{
|
|
$cur = time();
|
|
$time = 60*60*25;
|
|
$whereRaw = $cur . '-unix_timestamp(create_at) <=' . $time;
|
|
$data = DB::name('merchant_order')->field("id,merchant_order_id,mid")->whereLike('param', '%error%')->whereRaw( $whereRaw)->select();
|
|
|
|
if($data->isEmpty()){
|
|
|
|
|
|
$this->yes('ok','暂无异常订单信息');
|
|
}
|
|
$errorOrder=[];
|
|
foreach ($data->toArray() as $vo) {
|
|
if(!in_array($vo['mid'],$errorOrder)){
|
|
$errorOrder[] = $vo['mid'];
|
|
}
|
|
// var_dump($vo);die;
|
|
|
|
}
|
|
if($errorOrder){
|
|
$errorMsg = implode("\n", $errorOrder);
|
|
$this->no(0 ,$errorMsg);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |