input(); if(!$this->input['mid']){ $this->no(-1); } $this->mid = $this->input['mid']; $this->product = $this->input['product_key']; $this->getMerchant(); $param['cash'] = $this->input['cash']; $param['mobile'] = $this->input['account']; if($this->product == 'dhcz_mnp'){ $param['old_product'] = $this->input['old_product'] = $this->product; $this->getMnp_isp($this->input['account']); if(isset($this->input['mnp_isp_array'])){ $param['mnp_isp_array'] = $this->input['mnp_isp_array']; } } $param['product'] =$this->product; $param['order'] = $this->input['order_no']; $data = ChannelService::instance()->use($this->mid, $this->product, $param, true); $this->yes($data); } #检测运营商并更新运营商 public function getMnp_isp($mobile) { $settingPhoneMNPStatus = sysconf('settingPhoneMNPStatus'); if ($settingPhoneMNPStatus == 1) { $param = [ 'mobile' => $mobile, ]; $mnp_cid = sysconf('PhoneMnp_cid'); if($mnp_cid){ $mnp_array = ChannelService::instance()->call('phone_mnp', $mnp_cid, $param); if(is_array($mnp_array) && isset($mnp_array['new_isp'])){ $mnp_isp = $mnp_array['new_isp']; if($mnp_isp == 1){ $this->product = 'ydcz'; $this->input['mnp_isp_array'] = $mnp_array; $this->Kou_Mnp($mobile); return $this->product ; }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){ $this->product = 'dxcz'; $this->input['mnp_isp_array'] = $mnp_array; $this->Kou_Mnp($mobile); return $this->product ; } } } } // die; $isp = Service::instance()->isp($mobile); if ($isp == 1) { $this->product = 'ydcz'; } elseif ($isp == 2) { $this->product = 'ltcz'; } elseif ($isp == 3) { $this->product = 'dxcz'; } return $this->product ; } public function Kou_Mnp($mobile) { $new_cash = 0.002; if ($this->merchant['account_surplus'] >= $new_cash) { $account_type = 1; } elseif ($this->merchant['credit_surplus'] >= $new_cash) { $account_type = 2; } $redis = RedisService::getInstance(); // 记录扣费到 Redis // 根据 this->mid 分别记录不同用户的调用次数 $redis_key = 'merchant_cash_deduction:' . $this->mid; $deduction_count = $redis->incr($redis_key,1); if ($deduction_count % 10 == 0) { $new_cash = $new_cash*10; MerchantLogService::instance()->add($this->mid, $new_cash, $account_type, 3, 'API扣费: 业务余额扣除 - 10次调用携号转网'); // 重置 Redis 中的调用次数 $redis->set($redis_key, 0); } } protected function maketime($v): float|false|int|string { if (!$v) { return ''; } if (is_numeric($v)) { return $v; } if (is_array($v)) { $v = $v[1]; } if (strstr($v, ' ')) { $t = explode(' ', $v); $v = $t[0]; $s = explode(':', $t[1]); } else { $s = array(0, 0, 0); } if (!isset($s[1])) { $s[1] = 0; } if (!isset($s[2])) { $s[2] = 0; } if (strstr($v, '-')) { $t = explode('-', $v); } elseif (strstr($v, '/')) { $u = explode('/', $v); $t[0] = $u[2]; $t[1] = $u[0]; $t[2] = $u[1]; } if (!isset($t)) { $t = array(0, 0, 0); } if (!isset($t[1])) { $t[1] = 0; } if (!isset($t[2])) { $t[2] = 0; } $v = mktime($s[0], $s[1], $s[2], $t[1], $t[2], $t[0]); return $v; } }