This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.haxianhe; | |
import static com.haxianhe.ClassA.test; | |
import java.util.function.Predicate; | |
/** | |
* @author haxianhe <haxianhe@gmail.com> | |
* Created on 2021-12-27 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @Desc: csv处理函数 | |
* @User: haxianhe | |
* @Date: 2019/4/2 | |
* @Time: 5:03 PM | |
*/ | |
abstract class CSV | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//获取分页 | |
public static function getOffsetLimit($page = 1, $perpage = 50) { | |
if (empty($perpage)) { | |
$perpage = 50; | |
} | |
$page = max(1, $page); | |
$page = min(1000000, $page); | |
$perpage = max($perpage, 1); | |
$perpage = min(10000, $perpage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* brief: 格式化数据写入到文件中, 主要是写csv文件 | |
* | |
* @param $arrData //要写入是的数据。二位数组。[['title' => '标题1', 'title2' => '标题2']] | |
* @param $arrTitle //标题,一维数组。定义顺序。和数据的key一致。 | |
* @param $filepath //写入文件路径 | |
* @param $write_type //1: 保留原来数据,往后插入。 2: 保留原来数据,在头部写入. 注意,如果是文件头写入,是覆盖式写入,不是插入式。且从第一行开始. 这个时候就需要预先写入空行,且空行占用字节数应该大于等于要写入头部的字节数。否则会覆盖。 | |
* | |
* @return bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
/* | |
* 判断两个数组是否相等 | |
*/ | |
public static function judgeArrayEquals($array1, $array2) | |
{ | |
if (!is_array($array1) || !is_array($array2)) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$abnormalOrderIds = array_filter($abnormalOrderIds, function ($item) use ($completeOrders) { | |
return !isset($completeOrders[$item['code']]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 数组按某一个元素值进行分组,正如数据库的group by语句 | |
* @param $array | |
* @param $key | |
* @return array | |
*/ | |
public function array_group_by($array, $key) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function filterArray($oldArray,$keyArray) | |
{ | |
$newArray=array_intersect_key($oldArray, array_flip($keyArray)); | |
return $newArray; | |
} | |
$promotion = array_intersect_key($promotion, array('id', 'promotion_id', 'promotion_actived', 'promotion_title', | |
'promotion_detail', 'promotion_type', 'promotion_type_name', 'sku_info', 'start_time', 'cancel_time','effect_scene')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
/** | |
* 对二维数组去重 | |
* @param $array2D | |
* @return array | |
*/ | |
function unique_array_more($array2D) | |
{ | |
foreach ($array2D[0] as $key => $value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait Service_Data_Base_Singleton | |
{ | |
private static $singleton; | |
private function __construct(){} | |
public static function getInstance() { | |
if( !(self::$singleton instanceof self) ) { | |
self::$singleton = new self(); | |
} |
NewerOlder