Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ReSentSMSOrderAction(){
- $get_key = getgpc('token', 'GPC', '');
- if(empty($get_key)){
- respon_json(array(
- 'status' => 0,
- 'msg' => 'No param: token',
- ));
- }
- if($get_key != get_config('secure_string')){
- respon_json(array(
- 'status' => 0,
- 'msg' => 'Token khong dung',
- ));
- }
- $id = (int) getgpc('order_id', 'GPC', 0);
- $text = getgpc('text', 'GPC', '');
- if($id == 0){
- respon_json(array(
- 'status' => 0,
- 'msg' => 'No param: order_id',
- ));
- }
- $result = resent_sms_order(array(
- 'order_id' => $id,
- 'text_add' => $text
- ));
- respon_json($result);
- }
- function resent_sms_order($data){
- global $app;
- try {
- if (!isset($data['order_id']) || (int)$data['order_id'] == 0) {
- return array(
- 'status' => 0,
- 'msg' => 'No order'
- );
- }
- $get_order = $app->load->model('payment')->getOrderInfo($data['order_id']);
- if ($get_order->num_rows == 0) {
- return array(
- 'status' => 0,
- 'msg' => 'No order exist'
- );
- }
- $thisOrder = $get_order->row;
- if($thisOrder['Status'] == 0){
- respon_json(array(
- 'status' => 0,
- 'msg' => 'Order chưa hoàn thành',
- ));
- }
- if($thisOrder['SendCardType'] != 'send_code'){
- return array(
- 'status' => 0,
- 'msg' => 'Không phải order sent code'
- );
- }
- if($thisOrder['Status'] != 1){
- return array(
- 'status' => 0,
- 'msg' => 'Order này chưa hoàn thành'
- );
- }
- $list_order_detail = $app->load->model('payment')->getListCardOfOrder((int) $data['order_id']);
- $list_order_detail_id = [];
- if($list_order_detail->num_rows > 0){
- foreach($list_order_detail->rows AS $order_detail) {
- $list_order_detail_id[] = $order_detail['Order_detail_id'];
- }
- }
- $re_get_listCard = $app->load->model('payment')->ListCardOfOrder(array(
- 'list_order_detail' => implode(',', $list_order_detail_id)
- ));
- $phone = $thisOrder['CustomerPhone'];
- $text_add = '.';
- if(!empty($data['text_add'])){
- $text_add = strval($data['text_add']);
- }
- if($re_get_listCard->num_rows > 0){
- $list_card = [
- 'data' => $re_get_listCard->rows
- ];
- if(sizeof($list_card['data']) == 1){
- $card = $list_card['data'][0];
- $content = getContent('sms_one_card');
- $data_send = array(
- 'order_id' => $data['order_id'],
- 'phone' => $phone,
- 'text' => lang('c_content', $content['c_content'], array(
- // 'daily' => strtoupper(get_session('ufullname')),
- 'menhgia' => number_format($card['ProductCode']),
- 'code' => $card['PrivateCode'],
- 'serial' => $card['SerialNumber']
- )). $text_add ,
- );
- $result_sms = send_sms_order($data_send);
- $content = getContent('export_card');
- $contact_sohagame = get_config_db('contact_sohagame', 'json');
- // Gửi Email khi xuất mã thẻ thành công
- $res = CURL_SendMail(array(
- 'from' => get_config('sent_email/email_from'),
- 'to' => $thisOrder['CustomerEmail'],
- 'subject' => lang('c_content', trim($content['subject'])),
- 'html' => lang('c_content', nl2br($content['c_content']), array(
- 'account' => strtoupper(get_session('ufullname')),
- 'order_id' => $thisOrder['Id'],
- 'PrivateCode' => $card['PrivateCode'],
- 'SerialNumber' => $card['SerialNumber'],
- 'total' => $thisOrder['Total'],
- 'total_paid' => $thisOrder['Total'],
- 'date_paid' => $thisOrder['LastModifyAt'],
- 'for_account' => $thisOrder['CustomerPhone'] !== '' ? $thisOrder['CustomerPhone'] : $thisOrder['CustomerEmail'],
- 'sohagame_contact_phone' => isset($contact_sohagame->phone) ? trim($contact_sohagame->phone) : '',
- 'sohagame_contact_email' => isset($contact_sohagame->email) ? trim($contact_sohagame->email) : '',
- ))
- ));
- return array(
- 'status' => 1,
- 'msg' => 'Sent Ok',
- 'data_sms' => $data_send,
- 'result_sms' => $result_sms
- );
- } else if(sizeof($list_card['data']) > 1){
- $get_short_link = $app->load->model('payment')->get_short_link($data['order_id']);
- if($get_short_link->num_rows > 0) {
- $thisLink = $get_short_link->row;
- $content = getContent('sms_shortlink');
- $data_send = array(
- 'order_id' => $data['order_id'],
- 'phone' => $phone,
- 'text' => lang('c_content', $content['c_content'], array(
- 'shortlink' => get_domain() . "?l=" . $thisLink['linkCode'],
- 'passcode' => $thisLink['Passcode'],
- )) . $text_add,
- );
- $result_sms = send_sms_order($data_send);
- return array(
- 'status' => 1,
- 'msg' => 'Sent Ok',
- 'data_sms' => $data_send,
- 'result_sms' => $result_sms
- );
- }
- } else {
- return array(
- 'status' => 0,
- 'msg' => 'List Card empty'
- );
- }
- } else {
- return $list_card;
- }
- } catch (Exception $e){
- zdebug_log('Exception_Error', array(
- 'file' => __FILE__,
- 'line' => __FILE__,
- 'msg' => $e->getMessage(),
- ), 'push');
- respon_json(array(
- 'status' => 0,
- 'msg' => $e->getMessage(),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement