Commit 1b9dd0d7 authored by luhongguang's avatar luhongguang

Merge branch 'test'

parents df46b0bf 58f6a3b5
......@@ -33,5 +33,6 @@ class DistributorException extends BaseException
14 => '用户id不能能为空',
15 => '活动id不能能为空',
16 => '商品id不能能为空',
17 => '验证码不正确或过期',
];
}
\ No newline at end of file
......@@ -41,5 +41,6 @@ class GoodsException extends BaseException
27 => 'TCC调用失败',
28 => '上架状态不能编辑,需先下架,再做编辑操作',
29 => '发布商品的生活号不存在',
30 => '当前商品已过期',
];
}
\ No newline at end of file
......@@ -31,6 +31,14 @@ class GoodsSkuSubShop extends MysqlBase
return self::selectMaster($colums, $where);
}
public static function getRecords($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::select($colums, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
......
......@@ -231,6 +231,15 @@ class GoodsController extends Base
$this->success(["result" => $data]);
}
public function goods_spu_shop_listAction()
{
$params = $this->params;
$data = GoodsService::getGoodsSkuSubShopList($params);
$this->success(["result" => $data]);
}
/**
......
......@@ -9,6 +9,14 @@ use \Validate\CheckIsDistributorValidate;
class DistributorController extends Base
{
public function get_distributorAction()
{
$params = $this->params;
$distributionList = DistributorService::getDistributorList($params);
$this->success(['result' => $distributionList]);
}
public function importAction()
{
$distributionList = DistributorService::import();
......
......@@ -9,6 +9,13 @@ use \Validate\MarketingGoodsRateValidate;
class MarketingController extends Base
{
public function get_marketing_listAction()
{
$params = $this->params;
$list = MarketingService::getMarketingList($params);
$distributionList['result'] = $list;
$this->success($distributionList);
}
/**
* 营销列表
* 后台管理
......
......@@ -61,8 +61,8 @@ class MarketinggoodsController extends Base
$goodsSkuInfo = GoodsSku::getRecord(['goods_sku_id' => $goodsSkuId]);
$goodsName = !empty($goodsSkuInfo['goods_name']) ? $goodsSkuInfo['goods_name'] : '';
$oldPrice = !empty($goodsSkuInfo['original_price']) ? $goodsSkuInfo['original_price'] : '';
$price = !empty($goodsSkuInfo['price']) ? $goodsSkuInfo['price'] : "0.00";
$oldPrice = !empty($goodsSkuInfo['original_price']) ? $goodsSkuInfo['original_price']/100 : '0.00';
$price = !empty($goodsSkuInfo['price']) ? $goodsSkuInfo['price']/100 : "0.00";
$goodsImg = "";
......@@ -92,11 +92,11 @@ class MarketinggoodsController extends Base
'nick_name' => $nickName,
'avatar' => $avatar,
];
$getImage = new GetImage();
$buyCount =1;
$getImage->getGoods($avatar,$goodsImg,$nickName, $goodsName,$goods_share_url,$price, $oldPrice,$buyCount);
//$result = ['result' => $data];
//$this->success($result);
}
......
......@@ -132,7 +132,6 @@ class ElasticGoodService
$result["count"] = $res["hits"]["total"]["value"];
foreach ($res["hits"]["hits"] as $key => $source) {
$result["list"][$key]["goods_desc_pic_url_list"] = [];
if (!empty($source["_source"]["goods_desc_pic_url"])) {
$ksyun = GoodsService::getUrlList($source["_source"]["goods_desc_pic_url"], 200, 200);
......@@ -154,7 +153,7 @@ class ElasticGoodService
$result["list"][$key]["life_account_id"] = $source["_source"]["life_account_id"];
$result["list"][$key]["life_account_name"] = $source["_source"]["life_account_name"];
$result["list"][$key]["life_account_icon"] = $source["_source"]["life_account_icon"];
$result["list"][$key]["distance"] = empty($source["sort"][1]) ? "" : round($source["sort"][1], 2) . "km";
$result["list"][$key]["distance"] = empty($source["sort"][0]) ? "" : round($source["sort"][0], 2) . "km";
$result["list"][$key]["update_time"] = $source["_source"]["update_time"];
}
}
......@@ -187,7 +186,7 @@ class ElasticGoodService
["price_sort" => "asc"],
];
$sortInit = empty($sortList[$sortType - 1]) ? $sortList[0] : $sortList[$sortType - 1];
$sortInit = isset($sortList[$sortType]) ? $sortList[$sortType] : $sortList[0];
$sort = array_merge($sortInit, $subjectSort);
$data = [
"sort" => $sort,
......@@ -201,7 +200,7 @@ class ElasticGoodService
],
"order" => "asc",
"unit" => "km",
"distance_type" => "plane",
"distance_type" => "plane",//更快但精度稍差的 plane 计算方法
];
}
return $data;
......@@ -232,6 +231,9 @@ class ElasticGoodService
["term" => ["audit_status" => GoodsSku::STATUS_PASS]],
["term" => ["online_status" => GoodsSku::ONLINE_STATUS_ONLINE]],
];
//gte 是大于等于; gt是大于; lte是小于等于; lt是小于
$data["query"]["bool"]["filter"][]["range"] = ["inventory_rest" => [["gt" => 0]]];
if (!empty($searchContent) || (!empty($subjectName) && $subjectName != "本周上新")) {
$multiMatch = [["multi_match" => [
"query" => $searchContent.$subjectName,
......@@ -249,7 +251,7 @@ class ElasticGoodService
}
if (!empty($latitude) && !empty($longitude)) {
$data["query"]["bool"]["filter"]["geo_distance"] = [
$data["query"]["bool"]["filter"][]["geo_distance"] = [
"distance" => "50km",
"shop_location" => [
"lat" => $latitude,
......@@ -257,7 +259,6 @@ class ElasticGoodService
]
];
}
return $data;
}
......
......@@ -355,6 +355,12 @@ class GoodsService
if ($sku["audit_status"] == GoodsSku::STATUS_PASS || $sku["audit_status"] == GoodsSku::STATUS_REJECT) {
throw new GoodsException(["cus" => 10]);
}
if ($status == GoodsSku::STATUS_PASS && $sku["expiration_time"] < date("Y-m-d H:i:s")) {
throw new GoodsException(["cus" => 30]);
}
if ($status == GoodsSku::STATUS_PASS && $sku["inventory_rest"] <= 0) {
throw new GoodsException(["cus" => 24]);
}
$goodsSkuId = $sku["goods_sku_id"];
$rejectedReason = strlen(trim($params["rejected_reason"])) == 0 ? "" : $params["rejected_reason"];
......@@ -437,6 +443,12 @@ class GoodsService
if ($sku["audit_status"] != GoodsSku::STATUS_PASS) {
throw new GoodsException(["cus" => 14]);
}
if ($onlineStatus == GoodsSku::ONLINE_STATUS_ONLINE && $sku["expiration_time"] < date("Y-m-d H:i:s")) {
throw new GoodsException(["cus" => 30]);
}
if ($onlineStatus == GoodsSku::ONLINE_STATUS_ONLINE && $sku["inventory_rest"] <= 0) {
throw new GoodsException(["cus" => 24]);
}
$goodsSkuId = $sku["goods_sku_id"];
GoodsSku::save(["online_status" => $onlineStatus], ["goods_sku_id" => $goodsSkuId]);
......@@ -580,6 +592,7 @@ class GoodsService
throw new GoodsException(['cus' => 16]);
}
$inventoryCount = $skuData["inventory_rest"] + $params["inventory_add"];
//$inventoryCount = $params["inventory"];
if ($inventoryCount < 0) {
throw new GoodsException(['cus' => 18]);
}
......@@ -625,6 +638,7 @@ class GoodsService
"rule_start_time" => empty($params["rule_start_time"]) ? "" : $params["rule_start_time"],
"rule_end_time" => empty($params["rule_end_time"]) ? "" : $params["rule_end_time"],
"inventory_total" => $skuData["inventory_total"] + $params["inventory_add"],
//"inventory_total" => $params["inventory"],
"inventory_rest" => $inventoryCount,
"original_price" => $params["original_price"] * 100,
"price" => $params["price"] * 100,
......@@ -733,7 +747,8 @@ class GoodsService
$data["goods_info"]["original_price"] = $sku["original_price"] / 100;
$data["goods_info"]["price"] = $sku["price"] / 100;
$data["goods_info"]["inventory"] = $sku["inventory_rest"];
$categoryNameList = Category::select("name", ["category_id" => [$sku["category_1_id"], $sku["category_2_id"]]]);
$data["goods_info"]["category_1_name"] = $categoryNameList[0];
$data["goods_info"]["category_2_name"] = $categoryNameList[1];
......@@ -765,12 +780,14 @@ class GoodsService
$data["goods_info"]["is_tuanzhang"] = true;
if (!empty($runningMarketing)) {
//分销返现多少钱
$data["goods_info"]["cash_back"] = $runningMarketing[$sku["goods_sku_id"]] * $data["goods_info"]["price"];
$data["goods_info"]["cash_back"] = sprintf("%.2f",$runningMarketing[$sku["goods_sku_id"]] * $data["goods_info"]["price"]);
}
}
}
}
}
$recordList = GoodsOperationRecord::select("*", ["goods_spu_id" => $goodsSpuId, "ORDER" => ["create_time" => "DESC"]]);
if (!empty($recordList)) {
foreach ($recordList as $key => $record) {
......@@ -867,7 +884,7 @@ class GoodsService
$data["goods_info"]["is_tuanzhang"] = true;
if (!empty($runningMarketing)) {
//分销返现多少钱
$data["goods_info"]["cash_back"] = $runningMarketing[$params["goods_sku_id"]] * $data["goods_info"]["price"];
$data["goods_info"]["cash_back"] = sprintf("%.2f",$runningMarketing[$params["goods_sku_id"]] * $data["goods_info"]["price"]);
}
}
}
......@@ -1310,6 +1327,32 @@ class GoodsService
return $list;
}
/**
* 获取 GoodsSku 列表
* @param $params
* @return array
* @throws GoodsException
*/
public static function getGoodsSkuSubShopList($params)
{
$where = [];
if (empty($params)) {
return [];
}
if (!empty($params['goods_sku_id'])) {
$where['goods_sku_id'] = $params['goods_sku_id'];
}
if (!empty($params['sub_shop_id'])) {
$where['sub_shop_id'] = $params['sub_shop_id'];
}
$list = GoodsSkuSubShop::getRecords($where);
return $list;
}
/**
* 获取图片地址,这里因为bucket可能不同,不保证图片顺序
* @param $picUrlStr
......@@ -1323,20 +1366,18 @@ class GoodsService
$strList = explode(",", $picUrlStr);
foreach ($strList as $key => $str) {
$arr = explode("/", $str);
if (count($arr) == 1) {
if (preg_match("/^http[s]{0,1}:\/\/([\w.]+\/?)\S*/", $str)) {
$data[] = $str;
if (preg_match("/^http[s]{0,1}:\/\/([\w.]+\/?)\S*/", $str)) {
$data[] = $str;
} else if (count($arr) == 1) {
if (!empty($widthSize) && !empty($highSize)) {
$urlRes = Ks3Api::picEncryptUrl($str, $widthSize, $highSize);
} else {
if (!empty($widthSize) && !empty($highSize)) {
$urlRes = Ks3Api::picEncryptUrl($str, $widthSize, $highSize);
} else {
$urlRes = Ks3Api::picEncryptUrl($str);
}
if ($urlRes["response"]["data"]["url"]) {
$data[] = $urlRes["response"]["data"]["url"];
} else {
continue;
}
$urlRes = Ks3Api::picEncryptUrl($str);
}
if (!empty($urlRes["response"]["data"]["url"]) && $urlRes["response"]["data"]["url"]) {
$data[] = $urlRes["response"]["data"]["url"];
} else {
continue;
}
} else {
$bucket = $arr[0];
......
......@@ -17,6 +17,8 @@ use Api\PhpServices\ShopImage\GetImage;
use Api\PhpServices\ShopImage\QR;
use App\Exception\custom\InterfaceException;
use App\Services\goods\GoodsService;
use Api\PhpUtils\Http\Request;
use App\Exception\BaseException;
class DistributorService
{
......@@ -71,7 +73,7 @@ class DistributorService
$countWhere = [
'parent_user_id' => !empty($params['user_id']) ? $params['user_id'] : '',
"create_time[><]" => [date("Y-m-d 00:00:00"), date("Y-m-d 23:59:59")]
"create_time[<>]" => [date("Y-m-d 00:00:00"), date("Y-m-d 23:59:59")]
];
$todayNum = Distributor::getCount($countWhere, "*");
......@@ -181,6 +183,10 @@ class DistributorService
if (empty($smsCode)) {
throw new DistributorException(['cus'=>11]);
}
$sms = self::checkSmsCode($params);
if ($sms['code'] != 0) {
throw new BaseException(['code'=>$sms['code'],'msg' => $sms['reason']]);
}
$jwUserId = '';
// if (empty($distributorCode)) {
......@@ -292,6 +298,39 @@ class DistributorService
}
}
/**
* 发送短信验证码
*
*/
public static function checkSmsCode($params)
{
$url = config('interface','service.user.check_sms_code');
if(!$url){
throw new CodeSpecialException("failed");
}
$params = [
'mobile' => !empty($params['mobile']) ? $params['mobile'] : '',
'appid' => !empty($params['appid']) ? $params['appid'] : 'hubble',
'code' => !empty($params['sms_code']) ? $params['sms_code'] : '',
'key' => 'f16bdd46292480b4b82c841d90a6ba02',
'partner' => !empty($params['appid']) ? $params['appid'] : 'hubble',
"scene" => "distributor"
];
$sms = (new Request())->get($url, $params);
if(!$sms){
throw new CodeSpecialException("timeout");
}
if (!empty($sms) && $sms['code'] == 0) {
return $sms['response'];
}else{
return $sms;
}
}
/**
* 发送短信验证码
*
......@@ -309,10 +348,10 @@ class DistributorService
$params = [
'mobile' => !empty($params['mobile']) ? $params['mobile'] : '',
'appid' => 'hubble',
'appid' => !empty($params['appid']) ? $params['appid'] : 'hubble',
'code' => '123456',
'key' => 'f16bdd46292480b4b82c841d90a6ba02',
'partner' => 'merchant-b',
'partner' => !empty($params['appid']) ? $params['appid'] : 'hubble',
'template' =>7,
'code_lenght' => 6,
'ticket_expire' => 86400,
......@@ -320,7 +359,7 @@ class DistributorService
'retry_times' => 100
];
$sms = (new TimeOut())->runGet($url, $params);
$sms = (new Request())->get($url, $params);
if(!$sms){
throw new CodeSpecialException("timeout");
}
......@@ -333,7 +372,7 @@ class DistributorService
}
/**
* 获取二维码
* 是否是团长
*
*/
public static function distributor($params)
......@@ -350,8 +389,7 @@ class DistributorService
$data = [];
$info = Distributor::getRecord($where);
$data = $info;
$param = [
'user_id' => !empty($where['user_id']) ? $where['user_id'] : '',
];
......@@ -429,6 +467,17 @@ class DistributorService
return $info;
}
public static function getDistributorList($params)
{
$where['user_id'] = !empty($params['user_id']) ? $params['user_id'] : '';
$info = Distributor::getRecords($where);
return $info;
}
/**
* 更新数据
*
......
......@@ -14,6 +14,7 @@ use App\Exception\custom\MarketingException;
use App\Services\common\CommonService;
use Api\PhpServices\Sensitive\Sensitive;
use App\Services\goods\GoodsService;
use Helpers\Aes;
class MarketingGoodsService
{
public static function getMarketingGoodsList($params)
......@@ -38,8 +39,8 @@ class MarketingGoodsService
$list[$key] = $value;
$list[$key]['marketing_name'] = !empty($marketing['marketing_name']) ? $marketing['marketing_name'] : '';
$list[$key]['commission_mode'] = !empty($marketing['commission_mode']) ? $marketing['commission_mode'] : '';
$list[$key]['first_commission_value'] = !empty($marketing['first_commission_value']) ? $marketing['first_commission_value'] : '';
$list[$key]['second_commission_value'] = !empty($marketing['second_commission_value']) ? $marketing['second_commission_value'] : '';
$list[$key]['first_commission_value'] = !empty($marketing['first_commission_value']) ? $marketing['first_commission_value']/100 : '';
$list[$key]['second_commission_value'] = !empty($marketing['second_commission_value']) ? $marketing['second_commission_value']/100 : '';
$list[$key]['create_user_email'] = !empty($marketing['create_user_email']) ? $marketing['create_user_email'] : '';
$list[$key]['good_count'] = !empty($marketing['good_count']) ? $marketing['good_count'] : '';
$list[$key]['start_time'] = !empty($marketing['start_time']) ? $marketing['start_time'] : '';
......@@ -119,28 +120,33 @@ class MarketingGoodsService
$list[$i]['goods_name'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_name']) ? $goodsSkuList[$value['goods_sku_id']]['goods_name'] : '';
$list[$i]['goods_desc'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc']) ? $goodsSkuList[$value['goods_sku_id']]['desc'] : '';
$list[$i]['goods_spu_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_spu_id']) ? $goodsSkuList[$value['goods_sku_id']]['goods_spu_id'] : '';
$list[$i]['original_price'] = !empty($goodsSkuList[$value['goods_sku_id']]['original_price']) ? $goodsSkuList[$value['goods_sku_id']]['original_price'] : '';
$list[$i]['price'] = !empty($goodsSkuList[$value['goods_sku_id']]['price']) ? $goodsSkuList[$value['goods_sku_id']]['price'] : '';
$list[$i]['original_price'] = !empty($goodsSkuList[$value['goods_sku_id']]['original_price']) ? $goodsSkuList[$value['goods_sku_id']]['original_price']/100 : '';
$list[$i]['price'] = !empty($goodsSkuList[$value['goods_sku_id']]['price']) ? $goodsSkuList[$value['goods_sku_id']]['price']/100 : '';
$list[$i]['total_amount_order'] = !empty($goodsSkuList[$value['goods_sku_id']]['total_amount_order']) ? $goodsSkuList[$value['goods_sku_id']]['total_amount_order'] : '';
$list[$i]['desc_pic_url'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc_pic_url']) ? GoodsService::getUrlList($goodsSkuList[$value['goods_sku_id']]['desc_pic_url']) : '';
$shopId = !empty($list[$i]['shop_id']) ? $list[$i]['shop_id'] : '';
$list[$i]['shop_name'] = !empty($subShopList[$shopId]['shop_name']) ? $subShopList[$shopId]['shop_name'] : '';
$commissionMode = !empty($marketingList[$value['marketing_id']]['commission_mode']) ? $marketingList[$value['marketing_id']]['commission_mode'] : '';
$firstCommission = !empty($marketingList[$value['marketing_id']]['first_commission_value']) ? $marketingList[$value['marketing_id']]['first_commission_value'] : 0;
$secondCommission = !empty($marketingList[$value['marketing_id']]['second_commission_value']) ? $marketingList[$value['marketing_id']]['second_commission_value']/100 : 0;
//
$list[$i]['share_price'] = 0;
//比例
if (!empty($commissionMode) && $commissionMode == 1) {
if (!empty($secondCommission) && $commissionMode == 1) {
$price = !empty($list[$i]['price']) ? $list[$i]['price'] : 0;
$list[$i]['share_price'] = $firstCommission*$price/100;
$list[$i]['share_price'] = sprintf("%.2f",$secondCommission*$price/100);
}
//固定
if (!empty($commissionMode) && $commissionMode == 2) {
$list[$i]['share_price'] = $firstCommission;
$list[$i]['share_price'] = sprintf("%.2f",$secondCommission/100);
}
$content = $userId .'_' .$value['marketing_id'];
$goodsShareId = Aes::encrypt($content);
$list[$i]['goods_share_code'] = $goodsShareId;
$i++;
}
......@@ -173,7 +179,7 @@ class MarketingGoodsService
$data = [];
foreach ($marketingInfoIds as $goodsSkuId => $marketingId) {
if (!empty($marketingList[$marketingId]["second_commission_value"])) {
$data[$goodsSkuId] = $marketingList[$marketingId]["second_commission_value"] / 100;
$data[$goodsSkuId] = $marketingList[$marketingId]["second_commission_value"] / 10000;
}
}
return $data;
......
......@@ -202,13 +202,13 @@ class MarketingService
throw new MarketingException(['cus'=>0]);
}
if (empty($firstCommissionRate)) {
throw new MarketingException(['cus'=>3]);
}
// if (empty($secondCommissionRate)) {
// throw new MarketingException(['cus'=>4]);
// if (empty($firstCommissionRate)) {
// throw new MarketingException(['cus'=>3]);
// }
if (empty($secondCommissionRate)) {
throw new MarketingException(['cus'=>4]);
}
if (self::utf8Strlen($marketingName) > 50) {
throw new MarketingException(['cus'=>1]);
......@@ -378,6 +378,14 @@ class MarketingService
return $info;
}
public static function getMarketingList($params)
{
$where['marketing_id'] = !empty($params['marketing_id']) ? $params['marketing_id'] : '';
$marketing_list = Marketing::getMarketingList($where);
return $marketing_list;
}
......
......@@ -14,7 +14,8 @@ class Goods implements DaemonServiceInterface
sleep(2);
$orderData = [
'online_status' => 1,
'expiration_time[<]' => date("Y-m-d H:i:s",time())
'expiration_time[<]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$goodsList = GoodsSku::getRecords($orderData);
DaemonLog::info('DaemonServiceInterface_goods', json_encode($goodsList));
......
......@@ -15,7 +15,8 @@ class Marketing implements DaemonServiceInterface
sleep(2);
$orderData = [
'online_status' => 1,
'end_time[<]' => date("Y-m-d H:i:s",time())
'end_time[<]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$orderInfoList = MarketingDao::getMarketingList($orderData);
DaemonLog::info('DaemonServiceInterface_marketing', json_encode($orderInfoList));
......@@ -25,7 +26,7 @@ class Marketing implements DaemonServiceInterface
$colums = [
'online_status' => 3,
];
MarketingDao::updateRecord($colums, $where);
MarketingDao::updateRecord($colums, $where);
}
}
......
......@@ -8,9 +8,9 @@ class IdCertification
{
private const key = '_v7QkFPgzb887YD6BuBqzHPJMJalJ6Zt';
private const secret = 'mDenoicZs2U_wd2jVmQQpCOPeM8jaFRu';
private const kuangshi_ocr_url = 'https://api.megvii.com/faceid/v3/ocridcard';
private const kuangshi_get_token = 'https://api.megvii.com/faceid/v3/sdk/get_biz_token';
private const kuangshi_face_compare = 'https://api.megvii.com/faceid/v3/sdk/verify';
public const kuangshi_ocr_url = 'https://api.megvii.com/faceid/v3/ocridcard';
public const kuangshi_get_token = 'https://api.megvii.com/faceid/v3/sdk/get_biz_token';
public const kuangshi_face_compare = 'https://api.megvii.com/faceid/v3/sdk/verify';
/**
* 身份证合法校验
......@@ -232,6 +232,7 @@ class IdCertification
$final_data['birth_year'] = $ocr_data['response']['birth_year']['result'] ?? '';
$final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1;
$final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[];
$final_data['code'] = $ocr_data['response']['code'] ?? -1;
return $final_data;
}
......@@ -247,6 +248,7 @@ class IdCertification
$final_data['valid_date_end'] = $ocr_data['response']['valid_date_end']['result'] ?? '';
$final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1;
$final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[];
$final_data['code'] = $ocr_data['response']['code'] ?? -1;
return $final_data;
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ class SocialCreditCertification
{
private const account = 'BJyimingzhineng';
private const app_key = 'deee9c9877e5452f8838cfc5130ac5ad';
private const ocr_bussiness_url = 'http://apistore.xmturui.com/apistore/ocr-new';
public const ocr_bussiness_url = 'http://apistore.xmturui.com/apistore/ocr-new';
private const engine_type = 'blic-new';
/**
......
......@@ -8,7 +8,7 @@ class ThreeElementsCertification
{
private const app_key = '392df35aa98721c597cf20b85d21eebc';
//运营商三要素检测接口
private const test_mobile3_ele_Sim_url = 'https://api.goodsdatas.com:8443/credit/Mobile3EleSim';
public const test_mobile3_ele_Sim_url = 'https://api.goodsdatas.com:8443/credit/Mobile3EleSim';
//加密需要的相关参数
private const salt = 'A99BC8325635E303';
......
......@@ -263,11 +263,12 @@ class Daemon
*/
protected function set_base_config(){
ini_set("display_errors", 1);
error_reporting('E_ALL');
ini_set('date.timezone','Asia/Shanghai');
ini_set("memory_limit", '2048M');
error_reporting(E_ALL);
//日志存储到 php-error.log
/*
//创建任务日志文件
$log_dir = ROOT_PATH.'/logs/daemon/'.$this->task_name;
$log_path = $log_dir.'/'.$this->task_name.'.log';
......@@ -280,6 +281,7 @@ class Daemon
die($log_path."文件无法创建"."\n");
}
}
*/
$this->log_signature = "daemon:".$this->task_name;
}
......
......@@ -14,6 +14,7 @@ use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request;
use App\Exception\custom\CodeSpecialException;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Mon\MonUtil;
class JwUser
{
......@@ -61,7 +62,16 @@ class JwUser
$params = ["userId" => $params['user_id']];
//$user_info = (new TimeOut())->runPost($url, $params);
$user_info = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$begin = microtime(true);
$user_info = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin),4) * 1000;
if(!empty($user_info['response'])){
$code = $user_info['response']['code'];
}else{
$code = -1;
}
MonUtil::proxyMon($url, $code, 'jw_user', $total_time);
FileLog::info('jw_user_getUserByUserId', json_encode($user_info));
if (!$user_info) {
throw new CodeSpecialException("timeout");
......
......@@ -47,7 +47,7 @@ class Ks3Api
"signature" => $signature,
"type" => $type,
];
return HttpUtil::POST($url, $params);
return HttpUtil::post($url, $params);
}
/**
......@@ -59,12 +59,11 @@ class Ks3Api
* @param $headers
* @return array
*/
public static function signature($resource, $httpMethod, $contentType, $contentMd5, $headers)
public static function signature($resource, $httpMethod, $contentType, $contentMd5, $headers, $date)
{
$url = self::BASE_URL . self::PATH_SIGNATURE;
$timestamp = self::msectime();
$date = gmdate(self::KS_DATE_SCHEME);
$md5Str = $httpMethod . "&" . $contentType . "&" . $contentMd5 . "&" . $date . "&" . $resource . "&" . $headers . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
......@@ -79,7 +78,7 @@ class Ks3Api
"resource" => $resource,
"headers" => $headers,
];
return HttpUtil::POST($url, $params);
return HttpUtil::post($url, $params);
}
/**
......@@ -113,7 +112,7 @@ class Ks3Api
"content_type" => $contentType,
"extend" => $extendJsonStr,
];
return HttpUtil::POST($url, $params);
return HttpUtil::post($url, $params);
}
/**
......@@ -140,7 +139,7 @@ class Ks3Api
"signature" => $signature,
"extend" => $extendJsonStr,
];
return HttpUtil::POST($url, $params);
return HttpUtil::post($url, $params);
}
/**
......
......@@ -2,6 +2,7 @@
namespace Api\PhpServices\Ksy;
use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Mon\MonUtil;
class Ksyun
{
......@@ -39,8 +40,16 @@ class Ksyun
'bucket' => $bucket,
'expire' => $expire_time,
];
$begin = microtime(true);
$res = (new Request())->post(self::get_down_from_ksyun, $post_data,50, 'json',[],1,true);
$end = microtime(true);
$total_time = round(($end - $begin),4) * 1000;
if(isset($res['response']['code'])){
$code = $res['response']['code'];
}else{
$code = -1;
}
MonUtil::proxyMon(self::get_down_from_ksyun, $code, 'merchant', $total_time);
if (isset($res['code'],$res['response']['status']) && $res['response']['status'] === 'success') {
return $res['response']['data'];
}
......
......@@ -173,7 +173,7 @@ class GetImage
// 底部二维码
$qr = new QR($qr_string);
$qr_size = 121;
$qr_size = 100;
$qr->setSize($qr_size);
$qr->setRoundBlockSize(QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN);
$qr_string = $qr->get();
......@@ -252,7 +252,44 @@ class GetImage
return $image_thump;
}
private function curlImage($url, $save_dir='',$filename='',$type=0){
$mimes = array(
'image/bmp'=>'bmp',
'image/gif'=>'gif',
'image/jpeg'=>'jpg',
'image/png'=>'png',
'image/tiff'=>'tiff',
'image/x-icon'=>'ico',
'mage/vnd.wap.wbmp'=>'wbmp',
'image/fax'=>'fax',
'image/pnetvue'=>'net',
'image/vnd.rn-realpix'=>'rp'
);
//创建保存目录
if(!file_exists($save_dir)&&!mkdir($save_dir,0777,true)){
return false;
}
// 获取响应头
if(($headers = get_headers($url, 1))!==false){
$type = $headers['Content-Type'];
if(isset($mimes[$type]))
{
$this->extension = $mimes[$type];
$file_path = $save_dir.$filename.".".$this->extension;
$contents = file_get_contents($url);
if(file_put_contents($file_path , $contents))
{
return $save_dir.$filename.".".$this->extension;
}
}
}
}
private function curlImageBak($url, $save_dir='',$filename='',$type=0){
if(trim($url)==''){
return array('file_name'=>'','save_path'=>'','error'=>1);
}
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ use Api\PhpUtils\Redis\RedisUtil;
class FrequencyLockUtil
{
const MIN_FREQUENCY_SECONDS = 30; // 频率锁默认最小间隔秒数
const MIN_FREQUENCY_SECONDS = 3; // 频率锁默认最小间隔秒数
const MIN_FREQUENCY_TIMES = 1; // 频率锁默认最小间隔秒数内最大访问次数
const PREFIX_FREQUENCY_LOCK = 'flk:';
......@@ -41,7 +41,7 @@ class FrequencyLockUtil
if ($current_times == 1) {
self::$handler->expire($key, $expire);
}
return ($current_times > $times) ? false : true;
return ($current_times > $times) ? true : false;
}
/**
......
......@@ -173,6 +173,10 @@ abstract class MysqlBase
*/
public static function getConnection($type, $flush = false)
{
if(PHP_SAPI == 'cli'){
// cli模式下,不走单例,gone away
$flush = true;
}
if (!isset(self::$dbConnect[static::CONFIG_INDEX.':'.$type]) || $flush) {
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = new Medoo(self::getDbConf($type));
}
......@@ -495,4 +499,20 @@ abstract class MysqlBase
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->action($actions);
}
/**
* 销毁所有已存在的连接,守护进程需要手动调用
*
* @return void
*/
public static function destroyConnetion()
{
if(self::$dbConnect) {
foreach(self::$dbConnect as $conn) {
$conn->pdo = null;
unset($conn);
}
self::$dbConnect = [];
}
}
}
......@@ -32,7 +32,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '4f8e8782a402f2ef95b6b5b9b21c23da94816828',
'reference' => '68ce832c192189e953b0bb2c9ce62aa9e5a5c3db',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -45,7 +45,7 @@ private static $installed = array (
array (
0 => '9999999-dev',
),
'reference' => 'f7b44c008d561d3785797073d0eb875fb2f16756',
'reference' => 'cc3be45aa9bfc968b35f1d60c43115dae5f80da3',
),
'api/php_utils' =>
array (
......@@ -55,7 +55,7 @@ private static $installed = array (
array (
0 => '9999999-dev',
),
'reference' => 'e4bc1258fafead42eb6ac7b84ae743f08d557a99',
'reference' => '44ddb35fa8ffe201baa7d71da8e42cc3e41d40b4',
),
'bacon/bacon-qr-code' =>
array (
......@@ -196,11 +196,10 @@ private static $installed = array (
),
'psr/log' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'aliases' =>
array (
0 => '1.1.x-dev',
),
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
),
......@@ -299,7 +298,7 @@ private static $installed = array (
array (
0 => '1.23.x-dev',
),
'reference' => 'eca0bf41ed421bed1b57c4958bab16aa86b757d0',
'reference' => '19d03c391c6abb6791f5f757fb36e551bffeaa68',
),
'symfony/property-access' =>
array (
......@@ -308,7 +307,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '13c33f29a76bd99976ba7ee20297fa16d5a53a59',
'reference' => 'cb1aad06e7733a116f49033b1b3048a08e59ddd2',
),
'symfony/property-info' =>
array (
......@@ -317,7 +316,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '718f093ae4cac054db2bbb39ebf86fd898583ac8',
'reference' => '36f5c26e3dbf6873b61b593cd86fe4616153d239',
),
'symfony/string' =>
array (
......@@ -335,7 +334,7 @@ private static $installed = array (
'aliases' =>
array (
),
'reference' => '4f8e8782a402f2ef95b6b5b9b21c23da94816828',
'reference' => '68ce832c192189e953b0bb2c9ce62aa9e5a5c3db',
),
),
);
......
......@@ -102,6 +102,7 @@ return array(
'App\\Models\\goods\\mysql\\GoodsSnapshot' => $baseDir . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => $baseDir . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => $baseDir . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\LifeAccountShopNum' => $baseDir . '/application/models/goods/mysql/LifeAccountShopNum.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => $baseDir . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => $baseDir . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => $baseDir . '/application/models/goods/mysql/Tcc.php',
......
......@@ -331,6 +331,7 @@ class ComposerStaticInit90e85a2e64f8339192f3e91b8700b9f2
'App\\Models\\goods\\mysql\\GoodsSnapshot' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSnapshot.php',
'App\\Models\\goods\\mysql\\GoodsSpu' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSpu.php',
'App\\Models\\goods\\mysql\\InventoryOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/InventoryOperationRecord.php',
'App\\Models\\goods\\mysql\\LifeAccountShopNum' => __DIR__ . '/../..' . '/application/models/goods/mysql/LifeAccountShopNum.php',
'App\\Models\\goods\\mysql\\PaySuccessGoodsCallbackRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/PaySuccessGoodsCallbackRecord.php',
'App\\Models\\goods\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => __DIR__ . '/../..' . '/application/models/goods/mysql/Tcc.php',
......
......@@ -7,7 +7,7 @@
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "f7b44c008d561d3785797073d0eb875fb2f16756"
"reference": "cc3be45aa9bfc968b35f1d60c43115dae5f80da3"
},
"require": {
"api/php_utils": "dev-master",
......@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0",
"php": "7.2.*"
},
"time": "2021-07-14T09:06:17+00:00",
"time": "2021-07-19T12:51:28+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -34,7 +34,7 @@
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "e4bc1258fafead42eb6ac7b84ae743f08d557a99"
"reference": "44ddb35fa8ffe201baa7d71da8e42cc3e41d40b4"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3",
"php": "7.2.*"
},
"time": "2021-07-14T08:30:41+00:00",
"time": "2021-07-19T16:13:22+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -950,8 +950,8 @@
},
{
"name": "psr/log",
"version": "dev-master",
"version_normalized": "dev-master",
"version": "1.1.4",
"version_normalized": "1.1.4.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
......@@ -967,7 +967,6 @@
"php": ">=5.3.0"
},
"time": "2021-05-03T11:20:27+00:00",
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
......@@ -1685,18 +1684,18 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0"
"reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0",
"reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/19d03c391c6abb6791f5f757fb36e551bffeaa68",
"reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"time": "2021-02-19T12:13:01+00:00",
"time": "2021-07-13T14:34:27+00:00",
"default-branch": true,
"type": "library",
"extra": {
......@@ -1747,7 +1746,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0"
"source": "https://github.com/symfony/polyfill-php80/tree/main"
},
"funding": [
{
......@@ -1772,12 +1771,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "13c33f29a76bd99976ba7ee20297fa16d5a53a59"
"reference": "cb1aad06e7733a116f49033b1b3048a08e59ddd2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/13c33f29a76bd99976ba7ee20297fa16d5a53a59",
"reference": "13c33f29a76bd99976ba7ee20297fa16d5a53a59",
"url": "https://api.github.com/repos/symfony/property-access/zipball/cb1aad06e7733a116f49033b1b3048a08e59ddd2",
"reference": "cb1aad06e7733a116f49033b1b3048a08e59ddd2",
"shasum": ""
},
"require": {
......@@ -1792,7 +1791,7 @@
"suggest": {
"psr/cache-implementation": "To cache access methods."
},
"time": "2021-07-03T09:16:21+00:00",
"time": "2021-07-17T18:34:10+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -1856,12 +1855,12 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-info.git",
"reference": "718f093ae4cac054db2bbb39ebf86fd898583ac8"
"reference": "36f5c26e3dbf6873b61b593cd86fe4616153d239"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-info/zipball/718f093ae4cac054db2bbb39ebf86fd898583ac8",
"reference": "718f093ae4cac054db2bbb39ebf86fd898583ac8",
"url": "https://api.github.com/repos/symfony/property-info/zipball/36f5c26e3dbf6873b61b593cd86fe4616153d239",
"reference": "36f5c26e3dbf6873b61b593cd86fe4616153d239",
"shasum": ""
},
"require": {
......@@ -1888,7 +1887,7 @@
"symfony/doctrine-bridge": "To use Doctrine metadata",
"symfony/serializer": "To use Serializer metadata"
},
"time": "2021-07-03T09:16:21+00:00",
"time": "2021-07-18T16:31:21+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......
......@@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => '4f8e8782a402f2ef95b6b5b9b21c23da94816828',
'reference' => '68ce832c192189e953b0bb2c9ce62aa9e5a5c3db',
'name' => 'yidian/yaf_demo',
),
'versions' =>
......@@ -19,7 +19,7 @@
array (
0 => '9999999-dev',
),
'reference' => 'f7b44c008d561d3785797073d0eb875fb2f16756',
'reference' => 'cc3be45aa9bfc968b35f1d60c43115dae5f80da3',
),
'api/php_utils' =>
array (
......@@ -29,7 +29,7 @@
array (
0 => '9999999-dev',
),
'reference' => 'e4bc1258fafead42eb6ac7b84ae743f08d557a99',
'reference' => '44ddb35fa8ffe201baa7d71da8e42cc3e41d40b4',
),
'bacon/bacon-qr-code' =>
array (
......@@ -170,11 +170,10 @@
),
'psr/log' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'aliases' =>
array (
0 => '1.1.x-dev',
),
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
),
......@@ -273,7 +272,7 @@
array (
0 => '1.23.x-dev',
),
'reference' => 'eca0bf41ed421bed1b57c4958bab16aa86b757d0',
'reference' => '19d03c391c6abb6791f5f757fb36e551bffeaa68',
),
'symfony/property-access' =>
array (
......@@ -282,7 +281,7 @@
'aliases' =>
array (
),
'reference' => '13c33f29a76bd99976ba7ee20297fa16d5a53a59',
'reference' => 'cb1aad06e7733a116f49033b1b3048a08e59ddd2',
),
'symfony/property-info' =>
array (
......@@ -291,7 +290,7 @@
'aliases' =>
array (
),
'reference' => '718f093ae4cac054db2bbb39ebf86fd898583ac8',
'reference' => '36f5c26e3dbf6873b61b593cd86fe4616153d239',
),
'symfony/string' =>
array (
......@@ -309,7 +308,7 @@
'aliases' =>
array (
),
'reference' => '4f8e8782a402f2ef95b6b5b9b21c23da94816828',
'reference' => '68ce832c192189e953b0bb2c9ce62aa9e5a5c3db',
),
),
);
......@@ -16,7 +16,7 @@ This component provides features added to PHP 8.0 core:
- [`get_resource_id`](https://php.net/get_resource_id)
More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
License
=======
......
......@@ -630,7 +630,7 @@ class PropertyAccessor implements PropertyAccessorInterface
private function getWriteInfo(string $class, string $property, $value): PropertyWriteInfo
{
$useAdderAndRemover = \is_array($value) || $value instanceof \Traversable;
$useAdderAndRemover = is_iterable($value);
$key = str_replace('\\', '.', $class).'..'.$property.'..'.(int) $useAdderAndRemover;
if (isset($this->writePropertyCache[$key])) {
......
......@@ -66,9 +66,9 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();
$this->contextFactory = new ContextFactory();
$this->phpDocTypeHelper = new PhpDocTypeHelper();
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : ReflectionExtractor::$defaultMutatorPrefixes;
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : ReflectionExtractor::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : ReflectionExtractor::$defaultArrayMutatorPrefixes;
$this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes;
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
}
/**
......
......@@ -85,9 +85,9 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
*/
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET)
{
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes;
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes;
$this->mutatorPrefixes = $mutatorPrefixes ?? self::$defaultMutatorPrefixes;
$this->accessorPrefixes = $accessorPrefixes ?? self::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? self::$defaultArrayMutatorPrefixes;
$this->enableConstructorExtraction = $enableConstructorExtraction;
$this->methodReflectionFlags = $this->getMethodsFlags($accessFlags);
$this->propertyReflectionFlags = $this->getPropertyFlags($accessFlags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment