Пример #1
0
 public function genePayXML($bookid)
 {
     $model = new Model_Insurance_Booking($bookid);
     if (!$model->loaded()) {
         return false;
     }
     $curtime = time();
     $configsBase = $this->getHuizheConfig();
     $configModel = new Model_Sysconfig();
     $configsArr = $configModel->getConfig(0);
     $md5Str = md5($configsBase['key'] . $configsBase['partnerid'] . $model->ordersn);
     $asyncResUrl = $GLOBALS['cfg_basehost'] . '/insurance/notify.php';
     //生成判断部
     $xml = '<?xml version="1.0" encoding="utf-8"?>
         <OrderApplyRequest>
           <TransrNo>' . $model->ordersn . '</TransrNo>
           <CaseCode>' . $model->productcasecode . '</CaseCode>
           <MD5Str>' . $md5Str . '</MD5Str>
           <PartnerID>' . $configsBase['partnerid'] . '</PartnerID>';
     //生成member
     $xmlMember = '<Member>
         <Name>' . $configsArr['cfg_huizhe_member_name'] . '</Name>
         <Mobile>' . $configsArr['cfg_huizhe_member_mobile'] . '</Mobile>
         <Email>' . $configsArr['cfg_huizhe_member_email'] . '</Email>
         <Address>' . $configsArr['cfg_huizhe_member_address'] . '</Address>
         <Company>' . $configsArr['cfg_huizhe_member_company'] . '</Company>
         <CallBackUrl>' . $asyncResUrl . '</CallBackUrl>
       </Member>';
     //生成policy的XML
     $xmlPolicy = '<Policy><ApplicationDate>' . date('Y-m-d', $curtime) . '</ApplicationDate>
     <BeginDate>' . $model->begindate . '</BeginDate>
     <EndDate>' . $model->enddate . '</EndDate>
     <SinglePrice>' . $model->price . '</SinglePrice>
     <Destination>' . $model->destination . '</Destination>
     <TripPurposeId>' . $model->trippurposeid . '</TripPurposeId>
     <VisaCity>' . $model->visacity . '</VisaCity></Policy>';
     //生成applicant
     $xmlApplicant = '<Applicant><Name>' . $configsArr['cfg_insurance_buyer_name'] . '</Name>
     <NamePinYin>' . $configsArr['cfg_insurance_buyer_pinyin'] . '</NamePinYin>
     <CardType>' . $configsArr['cfg_insurance_buyer_cardtype'] . '</CardType>
     <CardCode>' . $configsArr['cfg_insurance_buyer_cardcode'] . '</CardCode>
     <Sex>' . $configsArr['cfg_insurance_buyer_sex'] . '</Sex>
     <Birthday>' . $configsArr['cfg_insurance_buyer_birthday'] . '</Birthday>
     <Address>' . $configsArr['cfg_insurance_buyer_address'] . '</Address>
     <PostCode>' . $configsArr['cfg_insurance_buyer_postcode'] . '</PostCode>
     <Phone>' . $configsArr['cfg_insurance_buyer_phone'] . '</Phone>
     <Mobile>' . $configsArr['cfg_insurance_buyer_mobile'] . '</Mobile>
     <Fax>' . $configsArr['cfg_insurance_buyer_fax'] . '</Fax>
     <Email>' . $configsArr['cfg_insurance_buyer_email'] . '</Email>
     <HomeAddress>' . $configsArr['cfg_insurance_buyer_homeaddress'] . '</HomeAddress>
     <JobCode>' . $configsArr['cfg_insurance_buyer_jobcode'] . '</JobCode>
     <JobLevel>' . $configsArr['cfg_insurance_buyer_joblevel'] . '</JobLevel>
     <Job>' . $configsArr['cfg_insurance_buyer_job'] . '</Job></Applicant>
     ';
     //生成insured
     $tourerModel = new Model_Insurance_Booking_Tourer();
     $tourers = $tourerModel->where('orderid', '=', $model->id)->get_all();
     $xmlInsured = '';
     foreach ($tourers as $k => $v) {
         $xmlInsured .= '<Insured>
         <Name>' . $v['name'] . '</Name>
         <NamePinYin>' . $v['pinyin'] . '</NamePinYin>
         <Sex>' . $v['sex'] . '</Sex>
         <CardType>' . $v['cardtype'] . '</CardType>
         <CardCode>' . $v['cardcode'] . '</CardCode>
         <Birthday>' . $v['birthday'] . '</Birthday>
         <Mobile>' . $v['mobile'] . '</Mobile>
         <JobCode>' . $v['jobcode'] . '</JobCode>
         <JObLevel>' . $v['joblevel'] . '</JObLevel>
         <Job>' . $v['job'] . '</Job>
         <FltNo>' . $v['fltno'] . '</FltNo>
         <City>' . $v['city'] . '</City>
         <InsurantRelation>' . $v['insurantrelation'] . '</InsurantRelation>
         <Count>' . $v['count'] . '</Count></Insured>';
     }
     $xml = $xml . $xmlMember . $xmlPolicy . $xmlInsured . $xmlApplicant . '</OrderApplyRequest>';
     return $xml;
 }
Пример #2
0
 public function paySuccess($ordersn, $paySource, $params = null)
 {
     $sql = "select * from sline_member_order where ordersn='{$ordersn}'";
     $arr1 = DB::query(1, $sql)->execute()->as_array();
     $arr = $arr1[0];
     if ($arr['status'] == 2) {
         return true;
     }
     $configModel = new Model_Sysconfig();
     $configs = $configModel->getConfig(0);
     if (substr($ordersn, 0, 2) == 'dz') {
         $ordertype = 'dz';
         $updatesql = "update sline_dzorder set status=2,paysource='{$paySource}' where ordersn='{$ordersn}'";
     } else {
         $ordertype = 'sys';
         $updatesql = "update sline_member_order set ispay=1,status=2,paysource='{$paySource}' where ordersn='{$ordersn}'";
         //付款标志置为1,交易成功
     }
     DB::query(Database::UPDATE, $updatesql)->execute();
     //logResult('更新成功');
     //$subject='你成功预订'.$arr['productname'].'产品';
     //$text="尊敬的{$arr['linkman']},你已经成功在{$GLOBALS['cfg_webname']}预订{$arr['productname']},数量{$arr['dingnum']}.";
     //sendMsg($subject,$text,$arr['handletel'],$ordersn);
     if ($ordertype != 'dz') {
         $msgInfo = Common::getDefineMsgInfo($arr['typeid'], 3);
         $memberModel = ORM::factory('member', $arr['memberid']);
         $memberInfo = Common::getMemberInfo($arr['memberid']);
         $nickname = !empty($memberInfo['nickname']) ? $memberInfo['nickname'] : $memberInfo['mobile'];
         $orderAmount = Common::StatisticalOrderAmount($arr);
         if (isset($msgInfo['isopen'])) {
             $content = $msgInfo['msg'];
             $content = str_replace('{#MEMBERNAME#}', $nickname, $content);
             $content = str_replace('{#PRODUCTNAME#}', $arr['productname'], $content);
             $content = str_replace('{#PRICE#}', $orderAmount['priceDescript'], $content);
             $content = str_replace('{#NUMBER#}', $orderAmount['numberDescript'], $content);
             $content = str_replace('{#TOTALPRICE#}', $orderAmount['totalPrice'], $content);
             $content = str_replace('{#WEBNAME#}', $configs['cfg_webname'], $content);
             $content = str_replace('{#ORDERSN#}', $ordersn, $content);
             Common::sendMsg($memberInfo['mobile'], $nickname, $content);
             //发送短信.
         }
         $emailInfo = Common::getEmailMsgConfig2($arr['typeid'], 3);
         if ($emailInfo['isopen'] == 1 && !empty($memberInfo['email'])) {
             // $nickname = !empty($memberInfo['nickname']) ? $memberInfo['nickname'] : $memberInfo['mobile'];
             $title = "订单支付成功";
             $content = $emailInfo['msg'];
             $content = str_replace('{#MEMBERNAME#}', $nickname, $content);
             $content = str_replace('{#PRODUCTNAME#}', $arr['productname'], $content);
             $content = str_replace('{#PRICE#}', $orderAmount['priceDescript'], $content);
             $content = str_replace('{#NUMBER#}', $orderAmount['numberDescript'], $content);
             $content = str_replace('{#TOTALPRICE#}', $orderAmount['totalPrice'], $content);
             $content = str_replace('{#WEBNAME#}', $configs['cfg_webname'], $content);
             $content = str_replace('{#ORDERSN#}', $ordersn, $content);
             $content = str_replace('{#EMAIL#}', $memberInfo['email'], $content);
             Common::ordermaill($memberInfo['email'], $title, $content);
         }
         //支付成功后添加预订送积分
         if (!empty($arr['jifenbook'])) {
             $addjifen = intval($arr['jifenbook']);
             $memberModel->jifen = $memberModel->jifen + $addjifen;
             if ($memberModel->save()) {
                 Common::addJifenLog($arr['memberid'], "预订{$arr['productname']}获得积分{$addjifen}", $addjifen, 2);
             }
         }
         //如果是酒店订单,则把子订单置为交易成功状态
         if ($arr['typeid'] == 2) {
             $s = "update sline_member_order set ispay=1,paysource='{$paySource}' where pid='{$arr['id']}'";
             DB::query(Database::UPDATE, $s);
         }
     }
 }
Пример #3
0
 public function action_ajax_getconfig()
 {
     $webid = Arr::get($_POST, 'webid');
     $model = new Model_Sysconfig();
     $arr = $model->getConfig($webid);
     echo json_encode($arr);
 }
Пример #4
0
 public static function ordermaill($maillto, $title, $content)
 {
     $configModel = new Model_Sysconfig();
     $configs = $configModel->getConfig(0);
     //如果没有自定义SMTP配置
     if ($configs['cfg_mail_smtp'] == '') {
         $configs['cfg_mail_smtp'] = "smtp.163.com";
     }
     if ($configs['cfg_mail_port'] == '') {
         $configs['cfg_mail_port'] = 25;
     }
     if ($configs['cfg_mail_user'] == '') {
         $configs['cfg_mail_user'] = "******";
         $configs['cfg_mail_pass'] = "******";
     }
     $smtpserver = $configs['cfg_mail_smtp'];
     //SMTP服务器
     $smtpserverport = $configs['cfg_mail_port'];
     //SMTP服务器端口
     $smtpusermail = $configs['cfg_mail_user'];
     //SMTP服务器的用户邮箱
     $smtpemailto = $maillto;
     //发送给谁
     $smtpuser = $configs['cfg_mail_user'];
     //SMTP服务器的用户帐号
     $smtppass = $configs['cfg_mail_pass'];
     //SMTP服务器的用户密码
     $mailtype = "HTML";
     //邮件格式(HTML/TXT),TXT为文本邮件
     ##########################################
     if ($smtpserverport == 25) {
         $mailsubject = iconv('UTF-8', 'GB2312//IGNORE', $title);
         //邮件主题
         $mailbody = iconv('UTF-8', 'GB2312//IGNORE', $content);
         //邮件内容
         $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);
         //这里面的一个true是表示使用身份验证,否则不使用身份验证.
         $smtp->debug = false;
         //是否显示发送的调试信息
         $status = $smtp->sendmail($smtpemailto, $smtpuser, $mailsubject, $mailbody, $mailtype);
     } else {
         $mail = new Mysendmail();
         $mail->setServer($smtpserver, $smtpuser, $smtppass, 465, true);
         //设置smtp服务器,到服务器的SSL连接
         $mail->setFrom($smtpuser);
         //设置发件人
         $mail->setReceiver($smtpemailto);
         //设置收件人,多个收件人,调用多次
         $mail->setMail($title, $content);
         //设置邮件主题、内容
         $status = $mail->sendMail();
         //发送
     }
     return $status;
 }