12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- // 接口公共方法
- use think\Db;
- function get_order_sn(){
- $order_id_main = date('YmdHis') . rand(10000000,99999999);
- $order_id_len = strlen($order_id_main);
- $order_id_sum = 0;
- for($i=0; $i<$order_id_len; $i++){
- $order_id_sum += (int)(substr($order_id_main,$i,1));
- }
- $osn = $order_id_main . str_pad((100 - $order_id_sum % 100) % 100,2,'0',STR_PAD_LEFT);
- return $osn;
- }
- function encrypt_password($password){
- return password_hash($password,PASSWORD_DEFAULT);
- }
- function check_password($password,$hash)
- {
- return password_verify($password,$hash);
- }
- // 获取日历 默认最近7天
- function get_calendar($day = 7,$type='asc'){
- $data = [];
- $week_arr = ['日','一','二','三','四','五','六'];
- for($i=0;$i<$day;$i++) {
- $day_time = date('Y-m-d',strtotime("-$i days"));
- $day_title= trim(date('m月d日',strtotime("-$i days")),'0');
- $time_int = strtotime($day_time);
- $week_day =$week_arr[date('w',strtotime($day_time))];
- $data[] = ['day_time' => $day_time,'week_day'=>$week_day,'time_int'=>$time_int,'day_title'=>$day_title];
- }
- if($type == 'asc') array_multisort(array_column($data,'time_int'),SORT_ASC,$data);
- return $data;
- }
|