{$suffix}
EOT;
return $icon;
}
}
function Kmod($bn, $sn)
{
//fmod() 函数返回除法的浮点数余数
return intval(fmod(floatval($bn), $sn));
}
function p($data, $die = false)
{
echo "";
print_r($data, $die);
echo "";
}
/**
* 保留两位小数
* @param $number
* @return float
*/
function fixed2Float($number)
{
return round(floatval((string)$number), 2);
}
/**
* @param $array
* @param $id
* @return array 树状Menu
*/
function recursion($array, $id = 0)
{
$resArray = [];
foreach ($array as $key => $value) {
if ($value['pid'] == $id) {
$resArray[$key] = $array[$key];
$resArray[$key]['children'] = recursion($array, $value['id']);
}
}
return array_merge($resArray);
}
// 基础状态
abstract class E_BASE_STATUS
{
const Default = 'default';
const Normal = 'normal';
const Hidden = 'hidden';
const Checking = 'checking';
}
abstract class E_MASSAGER_STATUS extends E_BASE_STATUS
{
const Checking = 'checking';
const Close = 'close';
}
abstract class E_GENDER_TYPE
{
const Man = "man";
const Woman = "woman";
}
// 服务分类
abstract class E_SERVICE_TYPE
{
const App = 'app';
const Store = 'store';
}
//订单状态
abstract class E_ORDER_STATUS
{
const Default = 'default'; // 默认状态
const Purchase = 'purchase'; // 已购买
const Proceed = 'proceed'; // 助教接单 - 进行中
const WaitFeedback = 'wait_feedback'; // 等待反馈
const Finish = 'finish'; // 服务完成
const Reject = 'reject'; // 助教拒绝
const Cancel = 'cancel'; // 用户取消取消
const AdminCancel = 'admin_cancel'; // 管理员终止订单
const AutoCancel = 'auto_cancel'; // 过期自动取消
}
const ALL_ORDER_STATUS = [
\E_ORDER_STATUS::Default,
\E_ORDER_STATUS::Purchase,
\E_ORDER_STATUS::Proceed,
\E_ORDER_STATUS::WaitFeedback,
\E_ORDER_STATUS::Finish,
\E_ORDER_STATUS::Reject,
\E_ORDER_STATUS::Cancel,
\E_ORDER_STATUS::AdminCancel,
\E_ORDER_STATUS::AutoCancel
];
// 取消退单
abstract class E_CHARGEBACK_TYPE
{
const TemporaryEmergency = 'temporary_emergency'; // 临时有事
const LooksMajor = 'looks_major'; // 理疗师长相或专业因素 50% 出行费不退
const Proceed = 'major_manner'; // 专业因素|服务态度 全退
const WaitFeedback = 'wait_feedback'; // 等待反馈
const Finish = 'finish'; // 服务完成
}
abstract class E_VOUCHER_STATUS extends E_BASE_STATUS
{
const Use = 'use';
const Expire = 'expire';
}
abstract class E_TRIP_TYPE
{
const Bus = 'bus';
const Taxi = "taxi";
}
abstract class E_ORDER_PAY_TYPE // 支付方式
{
const ALi = 'ali';
const Wechat = 'wechat';
const Balance = 'balance';
const Bank = 'bank';
}
const ALL_ORDER_PAY_TYPE = [\E_ORDER_PAY_TYPE::ALi, \E_ORDER_PAY_TYPE::Balance, \E_ORDER_PAY_TYPE::Wechat];
abstract class E_ORDER_PROGRESS_TYPE // 订单子进程
{
const Take = 'take'; // 接单
const Depart = 'depart';
const Arrive = 'arrive';
const Start = 'start';
const Over = 'over';
}
const ALL_ORDER_PROGRESS_TYPE = [
\E_ORDER_PROGRESS_TYPE::Take,
\E_ORDER_PROGRESS_TYPE::Depart,
\E_ORDER_PROGRESS_TYPE::Arrive,
\E_ORDER_PROGRESS_TYPE::Start,
\E_ORDER_PROGRESS_TYPE::Over,
];
abstract class E_USER_BILL_CURRENCY_TYPE
{
const Money = "money";
const Score = "score";
}
abstract class E_USER_BILL_CHANGE_TYPE
{
const BalanceWxRecharge = [1, "微信余额充值"];
const BalanceAliRecharge = [2, "支付宝余额充值"];
const BalanceOrderConsumption = [3, "订单消费余额"];
const BalanceOrderRefund = [4, "订单取消退还余额"];
const WxOrderConsumption = [5, "微信支付订单"];
const WxOrderRefund = [6, "微信支付订单退款"];
const AdminRecharge = [7, "管理员充值余额"];
const AdminReduce = [8, "管理员扣除余额"];
const ProfitIncrease = [9, "推荐分佣"];
const Deposit = [10, "提现"];
const MemberCharge = [11, "充值会员"];
const BalanceDeduction = [12, "余额抵扣"];
const BalanceDeductionRefund = [13, "余额抵扣退回"];
const ScoreOrderGive = [20, "订单赠送积分"];
const ScoreLotteryConsumption = [21, "抽奖消费积分"];
const ScoreExchangeVoucher = [22, "积分兑换优惠券"];
const ScoreOrderRefund = [23, "取消订单退还积分"];
}
abstract class E_PROFIT_BILL_CHANGE_TYPE
{
const Profit = "profit"; // 分润
const Drawings = "drawings"; // 提现
const ClosingExpend = "closing_expend"; // 结算支出
const ClosingIncome = "closing_income"; // 结算收入
const ChannelExpend = "channel_expend"; // 渠道支出
const ChannelIncome = "channel_income"; // 渠道收入
}
abstract class E_M_BILL_CHANGE_TYPE
{
const Profit = 101; // 服务费
const Travel = 102; // 出行费
const Deposit = 103; // 提现
const ClosingIncome = 104; // 结算收入
const ChannelExpend = 105; // 渠道支出
const ChannelIncome = 106; // 渠道收入
}
abstract class E_ADMIN_TYPE
{
const Platform = 'platform';
const Agency = 'agency';
const Store = 'store';
}
abstract class E_IDENTITY_TYPE extends E_ADMIN_TYPE
{
const Massager = 'massager';
const User = 'user';
}
class SResult
{
private $_code;
private $_msg = '';
private $_data = null;
public function __construct($code = 0, $msg = '', $data = null)
{
$this->_code = $code;
$this->_msg = $msg;
$this->_data = $data;
}
public function code()
{
return $this->_code;
}
public function msg()
{
return $this->_msg;
}
public function data()
{
return $this->_data;
}
}
function http_request($url, $get = null, $post = null)
{
if (isset($get))
$url .= ((substr_count($url, '?') > 0 ? "&" : "?") . http_build_query($get));
// 初始化一个cURL会话
$ch = curl_init($url);
if (isset($post)) {
curl_setopt($ch, CURLOPT_POST, TRUE); #开启post
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); #post数据
}
curl_setopt($ch, CURLOPT_HEADER, 0); #是否需要头部信息(否)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); #如果成功只将结果返回,不自动输出任何内容。
curl_setopt($ch, CURLOPT_TIMEOUT, 5); #设置允许执行的最长秒数。
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); #在发起连接前等待的时间,如果设置为0,则无限等待。
//忽略证书
if (substr($url, 0, 5) == 'https') {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
}
$curl_result = curl_exec($ch);
if ($curl_result) {
$data = $curl_result;
} else {
$data = curl_error($ch);
}
curl_close($ch); #关闭cURL会话
return json_decode($data);
}
function fmtMonth($m)
{
$m = (int)$m;
if ($m > 10)
return $m;
return "0{$m}";
}
function ym($year = null, $month = null)
{
if ($year && $month) {
$month = (int)$month;
return $month > 10 ? "{$year}-{$month}" : "{$year}-0{$month}";
}
return date('Y-m');
}
abstract class E_M_INTERIOR_SCORE
{
const Duration = "duration";
const Praise = "praise";
const Negative = "negative";
const Performance = "performance";
const Reorder = "reorder";
}
const ALL_E_M_I_S = [
"duration",
"praise",
"negative",
"performance",
"reorder"
];
function splittingDate($start_time, $end_time)
{
$minute_20 = 10 * 60;
$date_array = [];
while ($start_time <= $end_time) {
array_push($date_array, strtotime(date('Y-m-d H:i', $start_time)));
$start_time += $minute_20;
}
return $date_array;
}
if (!function_exists('qrcodeBase64')) {
function qrcodeBase64($url, $params)
{
$p_str = array_map(function ($key) use ($params) {
return "$key={$params[$key]}";
}, array_keys($params));
$qr = new Endroid\QrCode\QrCode($url . "?" . join("&", $p_str), new Endroid\QrCode\Encoding\Encoding("UTF-8"));
$pngWriter = new Endroid\QrCode\Writer\PngWriter();
$pngResult = $pngWriter->write($qr);
$base64 = $pngResult->getDataUri();
//默认普通上传文件
return upload_pic(explode(",", $base64)[1]);
}
}
if (!function_exists('upload_pic')) {
function upload_pic($thumb)
{
if (!$thumb) return null;
$fileroot = ROOT_PATH . 'public' . DS . 'uploads' . DS . 'qrcode';//设置图片保存路径
if (!is_dir($fileroot)) mkdir($fileroot, 0777, true);//没有保存目录则创建
$filename = date("YmdHis") . '_' . rand(10000, 99999) . '.png';//生成文件名
file_put_contents($fileroot . DS . $filename, base64_decode($thumb));
return DS . 'uploads' . DS . 'qrcode' . DS . $filename;
}
}
function parse_area($area_code)
{
$result = [
'p_code' => null,
'city_code' => null,
'county_code' => null
];
if (strlen((string)$area_code) != 6)
return $result;
$result['p_code'] = (int)($area_code / 1000) * 1000;
if ($area_code % 1000 > 0) {
$result['city_code'] = (int)($area_code / 100) * 100;
}
if ($area_code % 100 > 0) {
$result['county_code'] = $area_code;
}
return $result;
}