1.把报错信息全部贴上去,把报错信息全部贴上去,把报错信息全部贴上去!!!!
能用文字就不要用截图,截图无法搜索!!!
2.你这个IP, 172.22.0.1
是内网IP?查不到抛出异常!
3.重新处理了一下,你打开文件 ./addons/fecmall/fecfa/services/Fa.php ,覆盖一下内容试试
<?php
/*
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecfa\services;
use fecshop\services\Service;
use GeoIp2\Database\Reader;
use Yii;
/**
* FA service.
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Fa extends Service
{
/**
* @param $ipStr | string, ip字符串,譬如:111.21.3.4
* @return array, 根据ip地址,得到对应的国家,省,市 信息数组
*/
public function getCountryCityByIp($ipStr)
{
$geoIpDataMmdb = Yii::getAlias('@common/lib/GeoLite2-City/GeoLite2-City.mmdb');
if (!file_exists($geoIpDataMmdb)) {
return null;
}
try {
$reader = new Reader($geoIpDataMmdb);
$record = $reader->city($ipStr);
$countryCode = $record->country->isoCode ; // 'US'
$countryName = $record->country->name ; // 'United States'
$countryCnName = $record->country->names['zh-CN']; // '美国'
$stateName = $record->mostSpecificSubdivision->name;
$stateCnName = $record->mostSpecificSubdivision->names['zh-CN'];
$cityName = $record->city->name;
$cityCnName = $record->city->names['zh-CN'];
return [
'country' => [
'code' => $countryCode,
'name' => $countryName,
'cn_name' => $countryCnName ,
] ,
'state' => [
'name' => $stateName,
'cn_name' => $stateCnName,
],
'city' => [
'name' => $cityName,
'cn_name' => $cityCnName,
],
];
} catch (\Exception $e) {
$errors = $e->getMessage();
Yii::$service->helper->errors->add($errors);
return [
'country' => [
] ,
'state' => [
],
'city' => [
],
];
}
}
/**
* 连续创建几天的db库表索引,供未来使用,
*/
protected $initAfterDays = 5;
/**
* 初始化mongo db index
*
*/
public function initDBIndexes()
{
$websites = Yii::$service->fa->website->getAllActiveWebsite();
//var_dump($websites);
if (!is_array($websites) || empty($websites)) {
return true;
}
foreach ($websites as $website) {
$websiteId = $website['website_id'];
for ($i=0;$i<=$this->initAfterDays;$i++) {
$dateStr = date('Y-m-d',strtotime('+ '.$i.' days'));
$this->createInitDbIndexes($dateStr, $websiteId);
}
}
}
/**
* @param $dateStr | string ,时间字符串,譬如: 2020-10-11
* @param $websiteId | string,website Id,
* 创建trace和customer 的coll索引。
*/
public function createInitDbIndexes($dateStr, $websiteId)
{
// trace 系列表,加索引
$traceDbName = Yii::$service->fa->mdb->getTraceDbNameByDate($dateStr);
$traceCollName = Yii::$service->fa->mdb->getTraceDataCollName($websiteId);
$traceIndexes = [
['key' => ['order.invoice'], 'background' => true],
['key' => ['uuid', '_id'], 'background' => true],
['key' => ['ip'], 'background' => true],
['key' => ['customer_id'], 'background' => true],
['key' => ['uuid', 'service_timestamp'], 'background' => true],
];
Yii::$service->fa->mdb->createIndexes($traceDbName, $traceCollName, $traceIndexes);
// customer表加索引
$customerDbName = Yii::$service->fa->mdb->getCustomerDbName();
$customerCollName = Yii::$service->fa->mdb->getCustomerCollName($websiteId);
$customerIndexes = [
['key' => ['customer_id'], 'background' => true],
['key' => ['uuids'], 'background' => true],
['key' => ['emails'], 'background' => true],
];
Yii::$service->fa->mdb->createIndexes($customerDbName, $customerCollName, $customerIndexes);
}
}