|
@@ -54,7 +54,7 @@ function arr_to_url($array, $has_sign = false)
|
|
|
{
|
|
|
ksort($array);
|
|
|
reset($array);
|
|
|
- $arg = "";
|
|
|
+ $arg = "";
|
|
|
while (list($name, $val) = each($array)) {
|
|
|
if ($name == 'sign' && !$has_sign) continue;
|
|
|
if (strpos($name, "_") === 0)
|
|
@@ -102,10 +102,10 @@ function array_to_object($arr)
|
|
|
}
|
|
|
foreach ($arr as $k => $v) {
|
|
|
if (gettype($v) == 'array' || getType($v) == 'object') {
|
|
|
- $arr[$k] = (object) array_to_object($v);
|
|
|
+ $arr[$k] = (object)array_to_object($v);
|
|
|
}
|
|
|
}
|
|
|
- return (object) $arr;
|
|
|
+ return (object)$arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -115,13 +115,13 @@ function array_to_object($arr)
|
|
|
*/
|
|
|
function object_to_array($obj)
|
|
|
{
|
|
|
- $obj = (array) $obj;
|
|
|
+ $obj = (array)$obj;
|
|
|
foreach ($obj as $k => $v) {
|
|
|
if (gettype($v) == 'resource') {
|
|
|
return;
|
|
|
}
|
|
|
if (gettype($v) == 'object' || gettype($v) == 'array') {
|
|
|
- $obj[$k] = (array) object_to_array($v);
|
|
|
+ $obj[$k] = (array)object_to_array($v);
|
|
|
}
|
|
|
}
|
|
|
return $obj;
|
|
@@ -207,7 +207,7 @@ function collectionTransform($trans, $data)
|
|
|
|
|
|
function paginationTransform($trans, $paginator)
|
|
|
{
|
|
|
- $ret = [];
|
|
|
+ $ret = [];
|
|
|
$ret['list'] = [];
|
|
|
if ($paginator) {
|
|
|
foreach ($paginator as $item) {
|
|
@@ -215,16 +215,17 @@ function paginationTransform($trans, $paginator)
|
|
|
}
|
|
|
|
|
|
$ret['meta'] = [
|
|
|
- 'total' => (int) $paginator->total(),
|
|
|
- 'per_page' => (int) $paginator->perPage(),
|
|
|
- 'current_page' => (int) $paginator->currentPage(),
|
|
|
- 'last_page' => (int) $paginator->lastPage(),
|
|
|
- 'next_page_url' => (string) $paginator->nextPageUrl(),
|
|
|
- 'prev_page_url' => (string) $paginator->previousPageUrl()
|
|
|
+ 'total' => (int)$paginator->total(),
|
|
|
+ 'per_page' => (int)$paginator->perPage(),
|
|
|
+ 'current_page' => (int)$paginator->currentPage(),
|
|
|
+ 'last_page' => (int)$paginator->lastPage(),
|
|
|
+ 'next_page_url' => (string)$paginator->nextPageUrl(),
|
|
|
+ 'prev_page_url' => (string)$paginator->previousPageUrl()
|
|
|
];
|
|
|
}
|
|
|
return $ret;
|
|
|
}
|
|
|
+
|
|
|
function ImageNewsToArray($datas)
|
|
|
{
|
|
|
if (empty($datas)) return null;
|
|
@@ -232,8 +233,8 @@ function ImageNewsToArray($datas)
|
|
|
$datas = json_decode($datas);
|
|
|
}
|
|
|
$send_data = array();
|
|
|
- foreach ($datas as $no => $data) {
|
|
|
- foreach ($data as $_data) {
|
|
|
+ foreach ($datas as $no => $data) {
|
|
|
+ foreach ($data as $_data) {
|
|
|
foreach ($_data as $key => $one_data) {
|
|
|
$send_data[$no][$key] = $one_data;
|
|
|
}
|
|
@@ -282,7 +283,7 @@ function decodeDistributionChannelId($code)
|
|
|
return $db_encrypt_info->distribution_channel_id;
|
|
|
}*/
|
|
|
$hashids = new \Hashids\Hashids('', 16, 'abcdefghjklmnopqrstuvwxyz1234567890');
|
|
|
- $res = $hashids->decode($code);
|
|
|
+ $res = $hashids->decode($code);
|
|
|
if ($res && isset($res[0])) {
|
|
|
return $res[0];
|
|
|
}
|
|
@@ -347,7 +348,7 @@ function saveExcelData($header, $data, $path, $remark = '')
|
|
|
$conditional1->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_YELLOW);
|
|
|
|
|
|
foreach ($remark as $key => $value) {
|
|
|
- $conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle($value['cell'])->getConditionalStyles();
|
|
|
+ $conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle($value['cell'])->getConditionalStyles();
|
|
|
$conditionalStyles[] = $conditional1;
|
|
|
$objPHPExcel->getActiveSheet()->getStyle($value['cell'])->setConditionalStyles($conditionalStyles);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($value['cell'], $value['contents']);
|
|
@@ -382,7 +383,7 @@ function saveExcelDataToMultiSheet(array $param, $path)
|
|
|
//\Log::info($sheet_num);
|
|
|
//\Log::info($param);
|
|
|
$objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
|
|
- $new_sheet = null;
|
|
|
+ $new_sheet = null;
|
|
|
for ($j = 0; $j < $sheet_num; $j++) {
|
|
|
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
|
|
if ($j > 0) {
|
|
@@ -399,7 +400,7 @@ function saveExcelDataToMultiSheet(array $param, $path)
|
|
|
return false;
|
|
|
}
|
|
|
$header = $param[$j]['header'];
|
|
|
- $ini = 65; //A的acsii码
|
|
|
+ $ini = 65; //A的acsii码
|
|
|
foreach ($header as $value) {
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension(chr($ini))->setAutoSize(true);
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue(chr($ini++) . '1', $value);
|
|
@@ -408,7 +409,7 @@ function saveExcelDataToMultiSheet(array $param, $path)
|
|
|
return false;
|
|
|
}
|
|
|
$data = $param[$j]['data'];
|
|
|
- $i = 2;
|
|
|
+ $i = 2;
|
|
|
|
|
|
foreach ($data as $val) {
|
|
|
$ini = 65;
|
|
@@ -454,7 +455,7 @@ function redisEnvMulti(...$key)
|
|
|
|
|
|
function get_client_ip($type = 0, $adv = false)
|
|
|
{
|
|
|
- $type = $type ? 1 : 0;
|
|
|
+ $type = $type ? 1 : 0;
|
|
|
static $ip = null;
|
|
|
if (null !== $ip) {
|
|
|
return $ip[$type];
|
|
@@ -516,9 +517,9 @@ function specialChannelAuthInfo()
|
|
|
'4444' => 'wx431a3a692700b63a',
|
|
|
'4445' => 'wx3c53a641ee53b984',
|
|
|
'4456' => 'wxc8c1cfb70e568f0c',
|
|
|
- '976' => 'wx21506dfd22a0dc9c',
|
|
|
- '928' => 'wx76da3531773c1f39',
|
|
|
- '157' => 'wx5ebe6187c0fb0bd5',
|
|
|
+ '976' => 'wx21506dfd22a0dc9c',
|
|
|
+ '928' => 'wx76da3531773c1f39',
|
|
|
+ '157' => 'wx5ebe6187c0fb0bd5',
|
|
|
'4175' => 'wx64cf3051ceb145ae',
|
|
|
'4604' => 'wxc177995c55b5e75e'
|
|
|
];
|
|
@@ -631,34 +632,34 @@ function specialChannelAuthInfoV2($distribution_channel_id)
|
|
|
|
|
|
function generateMonthOrderUrl($user_id)
|
|
|
{
|
|
|
- $app_id = env('MONTH_ORDER_APPID');
|
|
|
+ $app_id = env('MONTH_ORDER_APPID');
|
|
|
$app_secret = env('MONTH_ORDER_APP_SECRET');
|
|
|
- $key = env('MONTH_ORDER_KEY');
|
|
|
- $plan_id = env('MONTH_ORDER_PLAN_ID');
|
|
|
- $ip = _getIp();
|
|
|
- $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
- $sign = strtoupper($sign);
|
|
|
+ $key = env('MONTH_ORDER_KEY');
|
|
|
+ $plan_id = env('MONTH_ORDER_PLAN_ID');
|
|
|
+ $ip = _getIp();
|
|
|
+ $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
+ $sign = strtoupper($sign);
|
|
|
$return_web = 1;
|
|
|
- $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign', 'return_web'));
|
|
|
+ $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign', 'return_web'));
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
function generateMonthOrderUrlV2($user_id, $plan_id, $ip)
|
|
|
{
|
|
|
- $app_id = env('MONTH_ORDER_APPID');
|
|
|
+ $app_id = env('MONTH_ORDER_APPID');
|
|
|
$app_secret = env('MONTH_ORDER_APP_SECRET');
|
|
|
- $key = env('MONTH_ORDER_KEY');
|
|
|
- $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
- $sign = strtoupper($sign);
|
|
|
+ $key = env('MONTH_ORDER_KEY');
|
|
|
+ $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
+ $sign = strtoupper($sign);
|
|
|
$return_web = 1;
|
|
|
- $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign', 'return_web'));
|
|
|
+ $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign', 'return_web'));
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
function getMillisecond()
|
|
|
{
|
|
|
list($microsecond, $time) = explode(' ', microtime());
|
|
|
- return (float) sprintf('%.0f', (floatval($microsecond) + floatval($time)) * 1000);
|
|
|
+ return (float)sprintf('%.0f', (floatval($microsecond) + floatval($time)) * 1000);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -727,6 +728,42 @@ function getProp($param, $key, $default = '')
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 求最大公约数 Greatest Common Divisor(GCD)
|
|
|
+ * @param $a
|
|
|
+ * @param $b
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+function gcd($a, $b)
|
|
|
+{
|
|
|
+ // 防止因除数为0而崩溃
|
|
|
+ if ($a === 0 || $b === 0) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($a % $b === 0) {
|
|
|
+ return $b;
|
|
|
+ }
|
|
|
+
|
|
|
+ return gcd($b, $a % $b);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 格式化比例值
|
|
|
+ * @param $value1
|
|
|
+ * @param $value2
|
|
|
+ * @param $gcd
|
|
|
+ * @return array|float[]|int[]
|
|
|
+ */
|
|
|
+function proportion($value1, $value2, $gcd)
|
|
|
+{
|
|
|
+ if ($gcd === 0) {
|
|
|
+ return [$value1, $value2];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [$value1 / $gcd, $value2 / $gcd];
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* 钉钉通知异常
|
|
|
* @param $message
|
|
|
*/
|