Exemple #1
0
 function register_service_exten()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (User::is_block()) {
         echo "no_permission";
         exit;
     }
     //get user
     $user = User::$current->data;
     $user_name = $user['user_name'];
     //Kieu thanh toan
     $payment_types = (int) Url::get('payment_types');
     //Thong tin gia han
     $order_service_id = (int) Url::get('order_service_id', 0);
     //id order service
     $time_exten = (int) Url::get('time_exten', 0);
     //thoi gian gia han (thang)
     $aryOrderService = array();
     if ($order_service_id) {
         $aryOrderService = DB::select("order_services", "id={$order_service_id}");
     }
     if ($aryOrderService) {
         //kiểm tra thông tin đầu vào
         if ($aryOrderService['user_use'] != $user_name) {
             echo "error";
             exit;
         }
         if ($aryOrderService['active'] != 1) {
             echo "error";
             exit;
         }
         $price = $aryOrderService['price'] / $aryOrderService['time_use'] * $time_exten;
     } else {
         echo "error";
         exit;
     }
     if ($payment_types == 1) {
         $full_name = Url::get("full_name");
         $mobile = Url::get("mobile");
         if (!$full_name || !$mobile) {
             echo "error";
             exit;
         }
         $price = $aryOrderService['price'] / $aryOrderService['time_use'] * $time_exten;
         $orderInfo = array("user_use" => $user_name, "type_scs" => $aryOrderService['type_scs'], "date_reg" => TIME_NOW, "up_count" => $aryOrderService['up_count'], "cpc_count" => $aryOrderService['cpc_count'], "item_count" => $aryOrderService['item_count'], "take_care" => $aryOrderService['take_care'], "price" => $price, "payment_types" => $payment_types, "time_use" => $time_exten, "active" => -4, "reg_exten_stt" => 1);
         //insert
         $id = DB::insert('order_services', $orderInfo);
         if ($id) {
             $order_code = "GH_{$order_service_id}_{$id}";
             $return_url = WEB_ROOT . "payment_scs.html?cmd=complete_exten&exten_order_id={$id}&payment_types=1&order_service_id={$order_service_id}&time_exten={$time_exten}";
             $transaction_info = "Thanh toán DV gia hạn Siêu Chăm Sóc {$aryOrderService['type_scs']} cho {$full_name} [ {$user['user_name']} ], số ĐT liên hệ: {$mobile}";
             $order_email = $user['email'];
             //insert payment_scs exten
             $pay_info = $full_name . "," . $user['email'] . "," . $mobile . "," . $aryOrderService['type_scs'];
             $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_type_soha" => 0, "payment_info" => $pay_info, "order_code" => $order_code, "price" => $price, "time" => time(), "error_text" => "Đang chờ thanh toán", "payment_status" => -1, "reg_exten_stt" => 1);
             //insert
             DB::insert('payment_scs', $paymentInfo);
             //Tạo link thanh toán đến Soha Payment
             $url = SohaPay::buildCheckoutUrl($return_url, $transaction_info, $order_code, $price, $order_email, SCS_MERCHANT_SITE_CODE, SCS_SECURE_CODE);
             echo $url;
             exit;
         } else {
             echo "error_connect";
             exit;
         }
     } else {
         if ($payment_types == 2) {
             global $display;
             if ($aryOrderService) {
                 $orderInfo = array("user_use" => $user_name, "type_scs" => $aryOrderService['type_scs'], "date_reg" => TIME_NOW, "up_count" => $aryOrderService['up_count'], "cpc_count" => $aryOrderService['cpc_count'], "item_count" => $aryOrderService['item_count'], "take_care" => $aryOrderService['take_care'], "price" => $price, "payment_types" => $payment_types, "time_use" => $time_exten, "active" => -3, "reg_exten_stt" => 1);
                 //insert
                 $id = DB::insert('order_services', $orderInfo);
             }
             if ($id) {
                 $payment_info = "";
                 $full_name = AZLib::getParam('ho_ten');
                 $dienthoai = AZLib::getParam('dien_thoai');
                 $dia_chi = AZLib::getParam('dia_chi');
                 $thanh_pho = AZLib::getParam('thanh_pho');
                 $ngay = AZLib::getParam('ngay');
                 $time = AZLib::getParam('time');
                 $payment_info .= $full_name . "," . $dienthoai . "," . $dia_chi . "," . $thanh_pho . "," . $ngay . "," . $time;
                 //Send email here;
                 $display->add('eb_url', WEB_ROOT);
                 $display->add('user_id', $user['id']);
                 $display->add('user_name', $user['user_name']);
                 $display->add('full_name', $full_name);
                 $display->add('dia_chi', $dia_chi);
                 $display->add('thanh_pho', SohaPay::infoForUser($thanh_pho, 'tp'));
                 $display->add('ngay', $ngay);
                 $display->add('time', SohaPay::infoForUser($time, 'time'));
                 $display->add('service_name', $aryOrderService['type_scs']);
                 $display->add('price', number_format($price));
                 $display->add('time_exten', $time_exten);
                 $content_email = $display->output('payment_online_exten_2', 1, 'PaymentScs');
                 $send_mail_stt = "-1";
                 if (System::sendEBEmail($user['email'], '[AzNetGroup] Gia hạn thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                     $send_mail_stt = "1";
                 }
                 //tao mang du lieu cho bang payment scs
                 $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $price, "payment_status" => 0, "send_mail_stt" => $send_mail_stt, "reg_exten_stt" => 1);
                 //insert
                 DB::insert('payment_scs', $paymentInfo);
                 $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}&exten=1";
                 echo $url;
                 exit;
             }
         } else {
             if ($payment_types == 3) {
                 global $display;
                 if ($aryOrderService) {
                     $orderInfo = array("user_use" => $user_name, "type_scs" => $aryOrderService['type_scs'], "date_reg" => TIME_NOW, "up_count" => $aryOrderService['up_count'], "cpc_count" => $aryOrderService['cpc_count'], "item_count" => $aryOrderService['item_count'], "take_care" => $aryOrderService['take_care'], "price" => $price, "payment_types" => $payment_types, "time_use" => $time_exten, "active" => -3, "reg_exten_stt" => 1);
                     //insert
                     $id = DB::insert('order_services', $orderInfo);
                 }
                 if ($id) {
                     $payment_info = "";
                     if ($user['mobile_phone'] == "") {
                         $phone = $user['home_phone'];
                     } else {
                         $phone = $user['mobile_phone'];
                     }
                     $payment_info .= $user['email'] . "," . $phone;
                     //Send email here;
                     $display->add('eb_url', WEB_ROOT);
                     $display->add('user_id', $user['id']);
                     $display->add('user_name', $user['user_name']);
                     $display->add('service_name', $aryOrderService['type_scs']);
                     $display->add('price', number_format($price));
                     $display->add('time_exten', $time_exten);
                     $content_email = $display->output('payment_online_reg_3', 1, 'PaymentScs');
                     $send_mail_stt = "-1";
                     if (System::sendEBEmail($user['email'], '[AzNetGroup] Gia hạn thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                         $send_mail_stt = "1";
                     }
                     //tao mang du lieu cho bang payment scs
                     $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $price, "payment_status" => 0, "send_mail_stt" => $send_mail_stt, "reg_exten_stt" => 1);
                     //insert
                     DB::insert('payment_scs', $paymentInfo);
                     $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}&exten=1";
                     echo $url;
                     exit;
                 }
             } else {
                 if ($payment_types == 4) {
                     global $display;
                     if ($aryOrderService) {
                         $orderInfo = array("user_use" => $user_name, "type_scs" => $aryOrderService['type_scs'], "date_reg" => TIME_NOW, "up_count" => $aryOrderService['up_count'], "cpc_count" => $aryOrderService['cpc_count'], "item_count" => $aryOrderService['item_count'], "take_care" => $aryOrderService['take_care'], "price" => $price, "payment_types" => $payment_types, "time_use" => $time_exten, "active" => -3, "reg_exten_stt" => 1);
                         //insert
                         $id = DB::insert('order_services', $orderInfo);
                     }
                     if ($id) {
                         $banking_type = Url::get('banking_type');
                         $banking_code = SohaPay::listBankCode($banking_type);
                         $payment_info = "";
                         if ($user['mobile_phone'] == "") {
                             $phone = $user['home_phone'];
                         } else {
                             $phone = $user['mobile_phone'];
                         }
                         $payment_info .= $user['email'] . "," . $phone . "," . $banking_code;
                         //Send email here;
                         $display->add('eb_url', WEB_ROOT);
                         $display->add('user_id', $user['id']);
                         $display->add('user_name', $user['user_name']);
                         $display->add('service_name', $aryOrderService['type_scs']);
                         $display->add('price', number_format($price));
                         $display->add('banking_type', $banking_type);
                         $display->add('accNumber', SohaPay::listAccountNumber($banking_code));
                         $display->add('banking_name', SohaPay::listBanking($banking_code));
                         $display->add('banking_note', SohaPay::listBanking($banking_code, true));
                         $display->add('time_exten', $time_exten);
                         $content_email = $display->output('payment_online_reg_4', 1, 'PaymentScs');
                         $send_mail_stt = "-1";
                         if (System::sendEBEmail($user['email'], '[AzNetGroup] Gia hạn thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                             $send_mail_stt = "1";
                         }
                         //tao mang du lieu cho ban payment scs
                         $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $price, "payment_status" => 0, "send_mail_stt" => $send_mail_stt, "reg_exten_stt" => 1);
                         //insert
                         DB::insert('payment_scs', $paymentInfo);
                         $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}&exten=1";
                         echo $url;
                         exit;
                     }
                 }
             }
         }
     }
 }
 function payment_bill()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (User::is_block()) {
         echo "no_perm";
         exit;
     }
     $bill_id = Url::get("bill_id");
     $full_name = Url::get('full_name');
     $mobile = Url::get('mobile');
     $user = User::$current->data;
     if ($bill_id) {
         if (!$full_name || !$mobile) {
             echo "error_info";
             exit;
         }
         $arr = explode(",", $bill_id);
         $id_arr = array();
         foreach ($arr as $payid) {
             $id_arr[$payid] = $payid;
         }
         $p_premium = array();
         #################################################################################
         #Lấy ra bản các bản ghi và kiểm tra
         $re = DB::query("SELECT * FROM payment_premium WHERE id IN({$bill_id})");
         $price = 0;
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 if ($row['user_id'] == User::id() && $row['status'] == 0) {
                     if (isset($id_arr[$row['id']])) {
                         unset($id_arr[$row['id']]);
                     }
                     $price += $row['price'];
                     $p_premium[$row['id']] = $row;
                 }
             }
         }
         if ($id_arr || $price == 0) {
             echo 'error_service';
             exit;
         }
         //$order_code         = "{$service_code}_{$user['user_name']}_".TIME_NOW;
         $return_url = WEB_ROOT . "personal.html?cmd=bill_payment&bill_id={$bill_id}";
         $transaction_info = "Thanh toán hóa đơn trả sau cho các GD trả sau có mã {$bill_id}, trị giá " . number_format($price, 0, '', '.') . " VNĐ) cho {$full_name} ({$user['user_name']}), số ĐT liên hệ: {$mobile}";
         $payment_ebp = array("item_id" => 0, "log_id" => $bill_id, "user_id" => User::id(), "user_name" => User::user_name(), "service_type" => 2, "service_code" => "Bill", "payment_info" => $transaction_info, "order_code" => '', "price" => $price, "time" => TIME_NOW, "payment_time" => 0, "error_text" => '', "payment_status" => 0, "sent_mail" => 0, "mobile" => $this->check_mobile($mobile));
         $payid = DB::insert("payment_ebp", $payment_ebp);
         if ($payid) {
             $order_code = "Bill_{$payid}";
             if (DB::update("payment_ebp", array("order_code" => $order_code), "id={$payid}")) {
                 //Tạo link thanh toán đến Soha Payment
                 $url = SohaPay::buildCheckoutUrl($return_url, $transaction_info, $order_code, $price, $user['email'], EBP_MERCHANT_SITE_CODE, EBP_SECURE_CODE);
                 echo $url;
                 exit;
             }
         }
     }
     echo "error_service";
     exit;
 }
Exemple #3
0
 function register_service()
 {
     if (!User::is_login()) {
         echo "not_login";
         exit;
     }
     if (User::is_block()) {
         echo "no_permission";
         exit;
     }
     $soha = new SohaPay();
     $user = User::$current->data;
     $user_name = $user['user_name'];
     $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
     $countItemOrder = DB::count('order_services', $whereOrderCheck);
     if ($countItemOrder > 0 && !User::is_root()) {
         echo "over_reg_scs";
         exit;
     }
     $payment_types = (int) Url::get('payment_types');
     $type_service = (int) Url::get('type_service');
     if ($type_service <= 0 || $type_service > 5) {
         echo "error_service";
         exit;
     } else {
         $service = DB::select("services_group", "id={$type_service}");
         if (!$service || $service && $service['price'] <= 0) {
             echo "error";
             exit;
         }
     }
     if ($payment_types == 1) {
         //check submit nhieu lan
         $user_name = $user['user_name'];
         $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
         $countItemOrder = DB::count('order_services', $whereOrderCheck);
         if ($countItemOrder > 0 && !User::is_root()) {
             exit;
         }
         //tao mang du lieu cho bang services_group
         $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
         if ($aryServiceGroup) {
             $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "active" => -4);
             //insert
             $id = DB::insert('order_services', $orderInfo);
         }
         if ($id) {
             $full_name = Url::get("full_name");
             $mobile = Url::get("mobile");
             if (!$full_name || !$mobile) {
                 echo "error";
                 exit;
             }
             $order_code = $type_service . "_" . $id;
             $return_url = WEB_ROOT . "payment_scs.html?cmd=complete&order_id={$id}&payment_types=1&type_service={$type_service}";
             $transaction_info = "Thanh toán DV Siêu Chăm Sóc {$service['service_name']} cho {$full_name} [ {$user['user_name']} ], số ĐT liên hệ: {$mobile}";
             $order_email = $user['email'];
             $price = (int) $service['price'];
             //insert vao payment_scs
             $pay_info = $full_name . "," . $user['email'] . "," . $mobile . "," . $service['service_name'];
             $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_type_soha" => 0, "payment_info" => $pay_info, "order_code" => $order_code, "price" => $price, "time" => time(), "error_text" => "Đang chờ thanh toán", "payment_status" => -1);
             //insert
             DB::insert('payment_scs', $paymentInfo);
             //end
             //Tạo link thanh toán đến Soha Payment
             /*$url= SohaPay::buildCheckoutUrl($return_url, $transaction_info, $order_code, $price, $order_email,SCS_MERCHANT_SITE_CODE,SCS_SECURE_CODE);*/
             /*note_soha #4*/
             $url = $soha->buildCheckoutUrl($return_url, $transaction_info, $order_code, $price, $order_email, $mobile);
             echo $url;
             exit;
         } else {
             echo "error_connect";
             exit;
         }
     } else {
         if ($payment_types == 2) {
             global $display;
             //check submit nhieu lan
             $user_name = $user['user_name'];
             $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
             $countItemOrder = DB::count('order_services', $whereOrderCheck);
             if ($countItemOrder > 0 && !User::is_root()) {
                 exit;
             }
             //tao mang du lieu cho bang services_group
             $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
             if ($aryServiceGroup) {
                 $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "active" => 0);
                 //insert
                 $id = DB::insert('order_services', $orderInfo);
             }
             if ($id) {
                 $payment_info = "";
                 $full_name = EClassApi::getParam('ho_ten');
                 $dienthoai = EClassApi::getParam('dien_thoai');
                 $dia_chi = EClassApi::getParam('dia_chi');
                 $thanh_pho = EClassApi::getParam('thanh_pho');
                 $ngay = EClassApi::getParam('ngay');
                 $time = EClassApi::getParam('time');
                 $payment_info .= $full_name . "," . $dienthoai . "," . $dia_chi . "," . $thanh_pho . "," . $ngay . "," . $time;
                 //Send email here;
                 $display->add('eb_url', WEB_ROOT);
                 $display->add('user_id', $user['id']);
                 $display->add('user_name', $user['user_name']);
                 $display->add('full_name', $full_name);
                 $display->add('dia_chi', $dia_chi);
                 $display->add('thanh_pho', SohaPay::infoForUser($thanh_pho, 'tp'));
                 $display->add('ngay', $ngay);
                 $display->add('time', SohaPay::infoForUser($time, 'time'));
                 $display->add('service_name', $aryServiceGroup['service_name']);
                 $display->add('price', number_format($aryServiceGroup['price']));
                 $content_email = $display->output('payment_online_reg_2', 1, 'PaymentScs');
                 $send_mail_stt = "-1";
                 if (System::sendEBEmail($user['email'], '[ChọnMón.vn] Đăng ký thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                     $send_mail_stt = "1";
                 }
                 //tao mang du lieu cho ban payment scs
                 $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $aryServiceGroup['price'], "payment_status" => 0, "send_mail_stt" => $send_mail_stt);
                 //insert
                 DB::insert('payment_scs', $paymentInfo);
                 $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}";
                 echo $url;
                 exit;
             }
         } else {
             if ($payment_types == 3) {
                 global $display;
                 //check submit nhieu lan
                 $user_name = $user['user_name'];
                 $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
                 $countItemOrder = DB::count('order_services', $whereOrderCheck);
                 if ($countItemOrder > 0 && !User::is_root()) {
                     exit;
                 }
                 //tao mang du lieu cho bang services_group
                 $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
                 if ($aryServiceGroup) {
                     $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "active" => 0);
                     //insert
                     $id = DB::insert('order_services', $orderInfo);
                 }
                 if ($id) {
                     $payment_info = "";
                     if ($user['mobile_phone'] == "") {
                         $phone = $user['home_phone'];
                     } else {
                         $phone = $user['mobile_phone'];
                     }
                     $payment_info .= $user['email'] . "," . $phone;
                     //Send email here;
                     $display->add('eb_url', WEB_ROOT);
                     $display->add('user_id', $user['id']);
                     $display->add('user_name', $user['user_name']);
                     $display->add('service_name', $aryServiceGroup['service_name']);
                     $display->add('price', number_format($aryServiceGroup['price']));
                     $content_email = $display->output('payment_online_reg_3', 1, 'PaymentScs');
                     $send_mail_stt = "-1";
                     if (System::sendEBEmail($user['email'], '[ChọnMón.vn] Đăng ký thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                         $send_mail_stt = "1";
                     }
                     //tao mang du lieu cho ban payment scs
                     $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $aryServiceGroup['price'], "payment_status" => 0, "send_mail_stt" => $send_mail_stt);
                     //insert
                     DB::insert('payment_scs', $paymentInfo);
                     $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}";
                     echo $url;
                     exit;
                 }
             } else {
                 if ($payment_types == 4) {
                     global $display;
                     //check submit nhieu lan
                     $user_name = $user['user_name'];
                     $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
                     $countItemOrder = DB::count('order_services', $whereOrderCheck);
                     if ($countItemOrder > 0 && !User::is_root()) {
                         exit;
                     }
                     //tao mang du lieu cho bang services_group
                     $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
                     if ($aryServiceGroup) {
                         $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "active" => 0);
                         //insert
                         $id = DB::insert('order_services', $orderInfo);
                     }
                     if ($id) {
                         $banking_type = Url::get('banking_type');
                         $banking_code = SohaPay::listBankCode($banking_type);
                         $payment_info = "";
                         if ($user['mobile_phone'] == "") {
                             $phone = $user['home_phone'];
                         } else {
                             $phone = $user['mobile_phone'];
                         }
                         $payment_info .= $user['email'] . "," . $phone . "," . $banking_code;
                         //Send email here;
                         $display->add('eb_url', WEB_ROOT);
                         $display->add('user_id', $user['id']);
                         $display->add('user_name', $user['user_name']);
                         $display->add('service_name', $aryServiceGroup['service_name']);
                         $display->add('price', number_format($aryServiceGroup['price']));
                         $display->add('banking_type', $banking_type);
                         $display->add('accNumber', SohaPay::listAccountNumber($banking_code));
                         $display->add('banking_name', SohaPay::listBanking($banking_code));
                         $display->add('banking_note', SohaPay::listBanking($banking_code, true));
                         $content_email = $display->output('payment_online_reg_4', 1, 'PaymentScs');
                         $send_mail_stt = "-1";
                         if (System::sendEBEmail($user['email'], '[ChọnMón.vn] Đăng ký thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                             $send_mail_stt = "1";
                         }
                         //tao mang du lieu cho ban payment scs
                         $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $aryServiceGroup['price'], "payment_status" => 0, "send_mail_stt" => $send_mail_stt);
                         //insert
                         DB::insert('payment_scs', $paymentInfo);
                         $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}";
                         echo $url;
                         exit;
                     }
                 } else {
                     if ($payment_types == 5) {
                         //hinh thuc mua tra sau
                         global $display;
                         //check submit nhieu lan
                         $user_name = $user['user_name'];
                         $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
                         $countItemOrder = DB::count('order_services', $whereOrderCheck);
                         if ($countItemOrder > 0 && !User::is_root()) {
                             exit;
                         }
                         //tao mang du lieu cho bang services_group
                         $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
                         if ($aryServiceGroup) {
                             //check xem user co the tiep tuc mua hay khong
                             $user_onDB = DB::select('account', "id={$user['id']}");
                             if ($user_onDB['money_quota'] * 1000 < $user_onDB['money_used'] * 1000 + $aryServiceGroup['price']) {
                                 echo "over_money";
                                 exit;
                             }
                             //luu lai so tien da su dung
                             $last_money_used = $user_onDB['money_used'] + $aryServiceGroup['price'] / 1000;
                             DB::update('account', array('money_used' => $last_money_used), "user_name='{$user_name}'");
                             if (MEMCACHE_ON) {
                                 $user['money_used'] = $last_money_used;
                                 eb_memcache::do_put("user:{$user['id']}", $user);
                             }
                             $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "active" => 0);
                             //insert
                             $id = DB::insert('order_services', $orderInfo);
                         }
                         if ($id) {
                             $payment_info = "";
                             if ($user['mobile_phone'] == "") {
                                 $phone = $user['home_phone'];
                             } else {
                                 $phone = $user['mobile_phone'];
                             }
                             $payment_info .= $user['email'] . "," . $phone . "," . $user['address'];
                             //Send email here;
                             $display->add('eb_url', WEB_ROOT);
                             $display->add('user_id', $user['id']);
                             $display->add('user_name', $user['user_name']);
                             $display->add('service_name', $aryServiceGroup['service_name']);
                             $display->add('price', number_format($aryServiceGroup['price']));
                             $content_email = $display->output('payment_online_reg_5', 1, 'PaymentScs');
                             $send_mail_stt = "-1";
                             if (System::sendEBEmail($user['email'], '[ChọnMón.vn] Đăng ký thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                                 $send_mail_stt = "1";
                             }
                             //insert vao bang payment_premium
                             $premium_scs = array("log_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "type" => 3, "pay_info" => "Mua SCS gói [{$aryServiceGroup['service_name']}]", "price" => $aryServiceGroup['price'], "time" => TIME_NOW, "status" => 0);
                             //insert
                             DB::insert('payment_premium', $premium_scs);
                             //tao mang du lieu cho ban payment scs
                             $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $aryServiceGroup['price'], "payment_status" => 0, "send_mail_stt" => $send_mail_stt);
                             //insert
                             DB::insert('payment_scs', $paymentInfo);
                             $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}";
                             echo $url;
                             exit;
                         }
                     } else {
                         if ($payment_types == 8) {
                             global $display;
                             //check submit nhieu lan
                             $user_name = $user['user_name'];
                             $whereOrderCheck = "user_use='" . $user_name . "' AND (active = 1 OR active = 0)";
                             $countItemOrder = DB::count('order_services', $whereOrderCheck);
                             if ($countItemOrder > 0 && !User::is_root()) {
                                 exit;
                             }
                             //lay thong tin goi dich vu
                             $aryServiceGroup = DB::select('services_group', 'id=' . $type_service);
                             //check gold
                             $user = DB::select("account", "id=" . User::id());
                             $gold_used = $aryServiceGroup['price'];
                             if ($gold_used > $user['gold']) {
                                 echo 'over_price';
                                 exit;
                             }
                             //tao mang du lieu cho bang services_group
                             if ($aryServiceGroup) {
                                 $orderInfo = array("user_use" => $user['user_name'], "type_scs" => $aryServiceGroup['service_name'], "date_reg" => TIME_NOW, "up_count" => $aryServiceGroup['up_count'], "cpc_count" => $aryServiceGroup['cpc_count'], "item_count" => $aryServiceGroup['item_count'], "take_care" => $aryServiceGroup['take_care'], "price" => $aryServiceGroup['price'], "payment_types" => $payment_types, "payment_status" => 1, "active" => 0);
                                 //insert
                                 $id = DB::insert('order_services', $orderInfo);
                             }
                             if ($id) {
                                 $payment_info = "";
                                 if ($user['mobile_phone'] == "") {
                                     $phone = $user['home_phone'];
                                 } else {
                                     $phone = $user['mobile_phone'];
                                 }
                                 $payment_info .= $user['email'] . "," . $phone;
                                 //Send email here;
                                 $display->add('eb_url', WEB_ROOT);
                                 $display->add('user_id', $user['id']);
                                 $display->add('user_name', $user['user_name']);
                                 $display->add('service_name', $aryServiceGroup['service_name']);
                                 $display->add('up_count', $aryServiceGroup['up_count']);
                                 $display->add('cpc_count', $aryServiceGroup['cpc_count']);
                                 $display->add('item_count', $aryServiceGroup['item_count']);
                                 $display->add('take_care', $aryServiceGroup['take_care']);
                                 $display->add('price', number_format($aryServiceGroup['price']));
                                 $content_email = $display->output('payment_online_success', 1, 'PaymentScs');
                                 $send_mail_stt = "-1";
                                 if (System::sendEBEmail($user['email'], '[ChọnMón.vn] Đăng ký thành công dịch vụ Siêu Chăm Sóc!', $content_email)) {
                                     $send_mail_stt = "1";
                                 }
                                 //tao mang du lieu cho bang payment scs
                                 $paymentInfo = array("order_service_id" => $id, "user_id" => $user['id'], "user_name" => $user['user_name'], "payment_types" => $payment_types, "payment_info" => $payment_info, "price" => $aryServiceGroup['price'], "payment_status" => 1, "send_mail_stt" => $send_mail_stt);
                                 //insert
                                 DB::insert('payment_scs', $paymentInfo);
                                 //Trừ gold trong tài khoản và ghi vào bảo gold_log
                                 $order_info = "Sử dụng " . number_format($gold_used, 0, ',', '.') . " GOLD mua dịch vụ SCS: {$aryServiceGroup['service_name']}";
                                 if (DB::query("UPDATE account SET gold = gold - {$gold_used} WHERE id={$user['id']}")) {
                                     User::getUser($user['id'], 0, 1);
                                     $gold_log = array('log_id' => $id, 'user_id_buy' => User::id(), 'user_name_buy' => User::user_name(), 'user_id' => User::id(), 'user_name' => User::user_name(), 'admin_id' => 0, 'admin_name' => '', 'time' => TIME_NOW, 'gold' => 0 - $gold_used, 'gold_before' => $user['gold'], 'gold_after' => $user['gold'] - $gold_used, 'price' => 1000 * ceil($gold_used / 1000), 'type' => 0, 'type_use' => 4, 'type_gold' => 3, 'note' => "{$order_info}");
                                     //insert
                                     $log_id = DB::insert("gold_log", $gold_log);
                                     $data['log_id'] = $log_id;
                                 }
                                 $url = WEB_ROOT . "payment_scs.html?cmd=payment_finish&id={$id}";
                                 echo $url;
                                 exit;
                             }
                         }
                     }
                 }
             }
         }
     }
     //end gold
 }