fix: 修改文件名大小写
- 优化查单,减少查单范围,限制到只能查询最近一周订单
This commit is contained in:
parent
afbb5bc3c3
commit
29511e09f5
@ -2,22 +2,23 @@
|
||||
|
||||
namespace app\gateway\controller\v4;
|
||||
|
||||
use app\channel\service\ChannelService;
|
||||
use app\channel\service\ProductBaseService;
|
||||
use app\core\Service;
|
||||
use app\merchant\service\MerchantLogService;
|
||||
use app\merchant\service\OrderLastHistoryService;
|
||||
use app\merchant\service\OrderLastweekHistoryService;
|
||||
use app\merchant\service\OrderTwoHistoryService;
|
||||
use think\admin\Controller;
|
||||
use app\gateway\service\AuthService;
|
||||
use app\gateway\service\RedisService;
|
||||
use app\merchant\service\MerchantLogService;
|
||||
use app\merchant\service\MerchantService;
|
||||
use app\merchant\service\OrderService;
|
||||
use app\merchant\service\OrderHistoryService;
|
||||
use app\merchant\service\OrderAutoService;
|
||||
use app\channel\service\ChannelService;
|
||||
use app\merchant\service\OrderHistoryService;
|
||||
use app\merchant\service\OrderLastHistoryService;
|
||||
use app\merchant\service\OrderLastweekHistoryService;
|
||||
use app\merchant\service\OrderService;
|
||||
use app\merchant\service\OrderTwoHistoryService;
|
||||
use app\merchant\service\PercentService;
|
||||
use app\merchant\service\ProductService as MerchantProductService;
|
||||
use dever\Log;
|
||||
use think\facade\Db;
|
||||
use think\admin\Controller;
|
||||
|
||||
/**
|
||||
* 接口核心控制器
|
||||
@ -46,7 +47,7 @@ class Core extends Controller
|
||||
protected array $use_product = array();
|
||||
# sign_type
|
||||
protected $sign_type = 1;
|
||||
protected string $request_ip= '';
|
||||
protected string $request_ip = '';
|
||||
# code码定义
|
||||
protected array $code = array
|
||||
(
|
||||
@ -87,9 +88,10 @@ class Core extends Controller
|
||||
);
|
||||
|
||||
#找不到方法错误响应
|
||||
public function __call($name, $arguments){
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
|
||||
$this->error('请求'.$name.'错误', '{-null-}', -802);
|
||||
$this->error('请求' . $name . '错误', '{-null-}', -802);
|
||||
}
|
||||
|
||||
public function initialize(): void
|
||||
@ -118,7 +120,7 @@ class Core extends Controller
|
||||
$this->proid = input('proid');
|
||||
if ($this->proid) {
|
||||
# 根据产品id 获取信息
|
||||
$pinfo = \app\channel\service\ProductBaseService::instance()->getOne($this->proid);
|
||||
$pinfo = ProductBaseService::instance()->getOne($this->proid);
|
||||
if (!$pinfo) {
|
||||
$this->no(-2);
|
||||
}
|
||||
@ -141,8 +143,6 @@ class Core extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!$this->product) {
|
||||
$this->no(-2);
|
||||
}
|
||||
@ -151,10 +151,8 @@ class Core extends Controller
|
||||
$this->getMerchant();
|
||||
|
||||
|
||||
|
||||
|
||||
#验证安全进价是否匹配
|
||||
if($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])){
|
||||
if ($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])) {
|
||||
$safe_price = $this->input['safe_price'];
|
||||
// $actual_price = ;
|
||||
}
|
||||
@ -165,90 +163,82 @@ class Core extends Controller
|
||||
*/
|
||||
protected function check()
|
||||
{
|
||||
if(!str_contains($this->request->header('content_type'), "application/json"))$this->no(-103);
|
||||
#校验请求类型
|
||||
if (!str_contains($this->request->header('content_type'), "application/json")) $this->no(-103);
|
||||
|
||||
|
||||
$this->input();
|
||||
$input = $this->input;
|
||||
|
||||
|
||||
if($this->product == 'dy'){
|
||||
if(!isset($this->input['num'])){
|
||||
$this->no(-105,'该产品需要输入数量');
|
||||
if ($this->product == 'dy') {
|
||||
if (!isset($this->input['num'])) {
|
||||
$this->no(-105, '该产品需要输入数量');
|
||||
}
|
||||
$num_cash = $this->input['cash'] * $this->input['num']??1;
|
||||
if($num_cash < 10){
|
||||
$this->no(-105,'面值至少10元及以上');
|
||||
$num_cash = $this->input['cash'] * $this->input['num'] ?? 1;
|
||||
if ($num_cash < 10) {
|
||||
$this->no(-105, '面值至少10元及以上');
|
||||
}
|
||||
}
|
||||
|
||||
$ip_white_data = $this->merchant['ip_white'];
|
||||
$request_ip = $this->getRealIp();
|
||||
// if()
|
||||
$ip_white_array = $ip_white_data?explode(',', $ip_white_data):[];
|
||||
$ip_white_array = $ip_white_data ? explode(',', $ip_white_data) : [];
|
||||
|
||||
|
||||
if(!$ip_white_array || !in_array($request_ip, $ip_white_array)){
|
||||
$this->no(-801,'ip:'.$request_ip.',请求错误,不在白名单内。');
|
||||
if (!$ip_white_array || !in_array($request_ip, $ip_white_array)) {
|
||||
$this->no(-801, 'ip:' . $request_ip . ',请求错误,不在白名单内。');
|
||||
}
|
||||
// var_dump(1);die;
|
||||
if ($this->proid && !str_contains($this->product, '_cash')) {
|
||||
unset($input['cash']);
|
||||
}
|
||||
|
||||
if($input['appid'] != 'app574223018568' ){#测试验签
|
||||
if(isset($this->input['signature'])){
|
||||
if (isset($this->input['signature'])) {
|
||||
$this->no(-10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $input['signature'] = $this->input['sign'];
|
||||
// unset($input['sign']);
|
||||
#兼容v4.0版本以下接口签名字段方法
|
||||
$signature = AuthService::check($input, $this->key, $this->sign_type);
|
||||
|
||||
if (is_numeric($signature)) {
|
||||
$this->no($signature);
|
||||
}
|
||||
}
|
||||
|
||||
if( $this->mid==1 &&isset($this->merchant['other_param']) && str_contains($this->merchant['other_param'],'mnp_SProduct_isp')){
|
||||
$other_param = json_decode($this->merchant['other_param'],true);
|
||||
if(is_array($other_param) && isset($other_param['mnp_SProduct_isp'])){
|
||||
|
||||
// 检测如果商户开启了特定商品指定携转检测,则进入此验证
|
||||
if (isset($this->merchant['other_param']) && str_contains($this->merchant['other_param'], 'mnp_SProduct_isp')) {
|
||||
$other_param = json_decode($this->merchant['other_param'], true);
|
||||
if (is_array($other_param) && isset($other_param['mnp_SProduct_isp'])) {
|
||||
|
||||
if (strlen($this->product) >= 2) {
|
||||
$pp_isp = '_' . substr($this->product, 0, 2).'_mnp';
|
||||
$pp_isp = '_' . substr($this->product, 0, 2) . '_mnp';
|
||||
|
||||
if(str_contains($other_param['mnp_SProduct_isp'], $pp_isp) && isset($this->input['cash'])){
|
||||
if (str_contains($other_param['mnp_SProduct_isp'], $pp_isp) && isset($this->input['cash'])) {
|
||||
$this->getMnp_isp($this->input['mobile']);
|
||||
|
||||
if(isset($this->input['mnp_isp_array'] ) && isset($other_param['mnp_SPISP_'.$this->product.$pp_isp]) && str_contains($other_param['mnp_SPISP_'.$this->product.$pp_isp],$this->input['cash'])){
|
||||
$this->input['product'] =$this->product.$pp_isp;
|
||||
if (isset($this->input['mnp_isp_array']) && isset($other_param['mnp_SPISP_' . $this->product . $pp_isp]) && str_contains($other_param['mnp_SPISP_' . $this->product . $pp_isp], $this->input['cash'])) {
|
||||
$this->input['product'] = $this->product . $pp_isp;
|
||||
|
||||
}
|
||||
$this->product =$this->input['product'] ;
|
||||
$this->product = $this->input['product'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// var_dump($this->product);die;
|
||||
|
||||
}
|
||||
|
||||
if($this->product == 'dhcz_mnp'){
|
||||
// 检测当产品为三网携转识别,则送入携转识别渠道
|
||||
if ($this->product == 'dhcz_mnp') {
|
||||
$this->getMnp_isp($this->input['mobile']);
|
||||
$this->input['product'] =$this->product;
|
||||
$this->input['product'] = $this->product;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
unset($this->input['sign']);
|
||||
// unset($this->input['signature']);
|
||||
if (isset($this->input['nonce'])) {
|
||||
unset($this->input['nonce']);
|
||||
}
|
||||
@ -280,33 +270,32 @@ class Core extends Controller
|
||||
$param = [
|
||||
'mobile' => $mobile,
|
||||
];
|
||||
if($mnp_cid){
|
||||
if ($mnp_cid) {
|
||||
$mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param);
|
||||
|
||||
|
||||
if(is_array($mnp_array) && isset($mnp_array['new_isp'])){
|
||||
if (is_array($mnp_array) && isset($mnp_array['new_isp'])) {
|
||||
$mnp_isp = $mnp_array['new_isp'];
|
||||
if($mnp_isp == 1){
|
||||
if ($mnp_isp == 1) {
|
||||
$this->product = 'ydcz';
|
||||
$this->input['mnp_isp_array'] = $mnp_array;
|
||||
$this->Kou_Mnp($mobile);
|
||||
return $this->product ;
|
||||
return $this->product;
|
||||
|
||||
}elseif($mnp_isp == 2){
|
||||
} elseif ($mnp_isp == 2) {
|
||||
$this->product = 'ltcz';
|
||||
$this->input['mnp_isp_array'] = $mnp_array;
|
||||
$this->Kou_Mnp($mobile);
|
||||
return $this->product ;
|
||||
}elseif($mnp_isp == 3){
|
||||
return $this->product;
|
||||
} elseif ($mnp_isp == 3) {
|
||||
$this->product = 'dxcz';
|
||||
$this->input['mnp_isp_array'] = $mnp_array;
|
||||
$this->Kou_Mnp($mobile);
|
||||
return $this->product ;
|
||||
return $this->product;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -321,7 +310,7 @@ class Core extends Controller
|
||||
} elseif ($isp == 3) {
|
||||
$this->product = 'dxcz';
|
||||
}
|
||||
return $this->product ;
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function Kou_Mnp($mobile)
|
||||
@ -337,9 +326,9 @@ class Core extends Controller
|
||||
// 记录扣费到 Redis
|
||||
// 根据 this->mid 分别记录不同用户的调用次数
|
||||
$redis_key = 'merchant_cash_deduction:' . $this->mid;
|
||||
$deduction_count = $redis->incr($redis_key,1);
|
||||
$deduction_count = $redis->incr($redis_key, 1);
|
||||
if ($deduction_count % 10 == 0) {
|
||||
$new_cash = $new_cash*10;
|
||||
$new_cash = $new_cash * 10;
|
||||
MerchantLogService::instance()->add($this->mid, $new_cash, $account_type, 3, 'API扣费: 业务余额扣除 - 10次调用携号转网');
|
||||
|
||||
// 重置 Redis 中的调用次数
|
||||
@ -347,7 +336,6 @@ class Core extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
# 检测开放或者维护时间
|
||||
@ -419,7 +407,7 @@ class Core extends Controller
|
||||
}
|
||||
|
||||
# 查找订单
|
||||
protected function getOrder($order_id, $merchant_order_id = false)
|
||||
protected function getOrder($order_id, $merchant_order_id = false,$time_type = false)
|
||||
{
|
||||
$orderService = OrderService::instance();
|
||||
$order = $orderService->get($order_id, $merchant_order_id, $this->mid);
|
||||
@ -427,18 +415,31 @@ class Core extends Controller
|
||||
$orderLastweekHistoryService = OrderLastweekHistoryService::instance();
|
||||
$order = $orderLastweekHistoryService->get($order_id, $merchant_order_id, $this->mid);
|
||||
}
|
||||
# 默认情况下只允许查找最新一周订单
|
||||
if(!$time_type ){
|
||||
return $order;
|
||||
}
|
||||
if (!$order) {
|
||||
$orderLastHistoryService = OrderLastHistoryService::instance();
|
||||
$order = $orderLastHistoryService->get($order_id, $merchant_order_id, $this->mid);
|
||||
}
|
||||
|
||||
if($time_type == 2){
|
||||
return $order;
|
||||
}
|
||||
if (!$order) {
|
||||
$orderTwoHistoryService = OrderTwoHistoryService::instance();
|
||||
$order = $orderTwoHistoryService->get($order_id, $merchant_order_id, $this->mid);
|
||||
}
|
||||
if($time_type == 3){
|
||||
return $order;
|
||||
}
|
||||
|
||||
if (!$order) {
|
||||
$orderHistoryService = OrderHistoryService::instance();
|
||||
$order = $orderHistoryService->get($order_id, $merchant_order_id, $this->mid);
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
@ -479,7 +480,7 @@ class Core extends Controller
|
||||
$up = true;
|
||||
}
|
||||
|
||||
if(isset($order['channel_order_id']) && $order['channel_order_id'] && isset($request['channel_order_id']) && $request['channel_order_id'] && $order['channel_order_id'] != $request['channel_order_id']) {
|
||||
if (isset($order['channel_order_id']) && $order['channel_order_id'] && isset($request['channel_order_id']) && $request['channel_order_id'] && $order['channel_order_id'] != $request['channel_order_id']) {
|
||||
$this->no(-104);
|
||||
}
|
||||
|
||||
@ -495,7 +496,6 @@ class Core extends Controller
|
||||
$channelService = ChannelService::instance();
|
||||
|
||||
|
||||
|
||||
$update = $channelService->call('notify', $order['cid'], $request, false, $order);
|
||||
$merchant = MerchantService::instance()->get($order['mid']);
|
||||
if (isset($order['param']) && $order['param']) {
|
||||
@ -527,7 +527,6 @@ class Core extends Controller
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($update['status'] == 3 && isset($merchant['stop']) && $merchant['stop'] > 2) {
|
||||
# 是否暂停
|
||||
$num = $order['num'] + 1;
|
||||
@ -546,9 +545,11 @@ class Core extends Controller
|
||||
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
echo $update['yes'];
|
||||
die;
|
||||
}
|
||||
echo 'success';die;
|
||||
echo 'success';
|
||||
die;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -568,9 +569,11 @@ class Core extends Controller
|
||||
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
echo $update['yes'];
|
||||
die;
|
||||
}
|
||||
echo 'success';die;
|
||||
echo 'success';
|
||||
die;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -587,7 +590,7 @@ class Core extends Controller
|
||||
}
|
||||
$isp = false;
|
||||
if (isset($order['isp']) && $order['isp'] && $order['isp'] > 0) {
|
||||
$isp_config = \app\merchant\service\PercentService::instance()->getIsp();
|
||||
$isp_config = PercentService::instance()->getIsp();
|
||||
$isp = $isp_config[$order['isp']];
|
||||
}
|
||||
$new_product = $this->getProduct($order['mid'], $order['product_key'], $this->use_product, $order['cash'], $isp);
|
||||
@ -598,9 +601,11 @@ class Core extends Controller
|
||||
$channelService->use($order['mid'], $new_product, $order['param'], false, $new_order_id, $this->use_product);
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
echo $update['yes'];
|
||||
die;
|
||||
}
|
||||
echo 'success';die;
|
||||
echo 'success';
|
||||
die;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@ -663,16 +668,19 @@ class Core extends Controller
|
||||
}
|
||||
if ($die) {
|
||||
if (isset($update['yes']) && $update['yes']) {
|
||||
echo $update['yes'];die;
|
||||
echo $update['yes'];
|
||||
die;
|
||||
}
|
||||
echo 'success';die;
|
||||
echo 'success';
|
||||
die;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($die) {
|
||||
echo 'fail';die;
|
||||
echo 'fail';
|
||||
die;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user