0 ? $day.'天' : ''; $hour = floor(($remain_time % (3600*24)) / 3600); $hour = $hour > 0 ? $hour.'小时' : ''; if($is_hour && $is_minutes) { $minutes = floor((($remain_time % (3600*24)) % 3600) / 60); $minutes = $minutes > 0 ? $minutes.'分钟' : ''; return $day.$hour.$minutes; } if($hour) { return $day.$hour; } return $day; } /** * get请求 * @param $url * @param string $msg * @return mixed */ function requestGet($url , $msg = ''){ // 1. 初始化一个cURL会话 $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //执行并获取HTML文档内容 $response = curl_exec($ch); // 4. 释放cURL句柄,关闭一个cURL会话 curl_close($ch); return $response; } //获取全图片地址 $image_data function image_path($image_data){ if(empty($image_data)){ return $image_data; } if (strpos($image_data,'|')!==false){ $image_res = explode('|',$image_data); }elseif(strpos($image_data,',')!==false){ $image_res = explode(',',$image_data); }else{ $image_res = array($image_data); } return $image_res; } 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 get_goods_price($goods_id,$serve_type_id,$phone_type_id = 0){ $goods_info = Db::name('store_goods')->field('id,cate_id')->where('status',1)->where('id',$goods_id)->where('is_deleted',0)->find(); if(empty($goods_info)){ $this->error('服务信息有误'); } $data = array('code'=>1,'msg'=>'获取成功'); if($goods_info['cate_id'] == 0){ //金刚区服务 if(empty($phone_type_id)){ $data['code'] = 0; $data['msg'] = '参数错误'; } $serve_type_name = Db::name('store_goods_type')->where('id',$serve_type_id)->value('spec_name'); $phone_type_name = Db::name('store_goods_type')->where('id',$phone_type_id)->value('spec_name'); $goods_price = Db::name('store_goods_list')->where('goods_id',$goods_id)->where('goods_spec','like','%'.$serve_type_name.'%')->where('goods_spec','like','%'.$phone_type_name.'%')->value('price_selling'); }else{ $serve_type_name = Db::name('store_goods_type')->where('id',$serve_type_id)->value('spec_name'); $goods_price = Db::name('store_goods_list')->where('goods_id',$goods_id)->where('goods_spec','like','%'.$serve_type_name.'%')->value('price_selling'); } if($goods_price <= 0){ $data['code'] = 0; $data['msg'] = '价格信息有误'; } $data['price'] = $goods_price; return $data; } //邮箱推送 function mail_push($mail_str,$order_id){ //查询订单信息 $order_info = Db::name('store_order')->field('goods_id,serve_type,client_tel,client_qq,price_amount,describe,create_at')->where('id',$order_id)->find(); $order_info['goods_title'] = Db::name('store_goods')->where('id',$order_info['goods_id'])->value('title'); $body = "服务类目:".$order_info['goods_title']."
服务类型:".$order_info['serve_type']."
用户手机:".$order_info['client_tel']."
用户QQ:".$order_info['client_qq']."
订单金额:".$order_info['price_amount']."
附加信息:".$order_info['describe']."
下单时间:".$order_info['create_at']; require_once env('root_path').'/vendor/aliyunmail/aliyun-php-sdk-core/Config.php'; //需要设置对应的region名称,如华东1(杭州)设为cn-hangzhou,新加坡Region设为ap-southeast-1,澳洲Region设为ap-southeast-2。 $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "LTAI5tSMNtYuD3TdEkM65fyp", "lcmARfziFDS4PUJ0K7AKTf3Ytl3Z8O"); $client = new DefaultAcsClient($iClientProfile); $request = new Dm\SingleSendMailRequest(); $request->setAccountName("feisu@tsguangsu.com"); $request->setFromAlias("飞速"); $request->setAddressType(1); $request->setTagName("feisu"); $request->setReplyToAddress("true"); $request->setToAddress($mail_str); $request->setSubject("新订单通知,请及时处理"); $request->setHtmlBody($body); try { $client->getAcsResponse($request); } catch (ClientException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } catch (ServerException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } }