Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. function ReSentSMSOrderAction(){
  2. $get_key = getgpc('token', 'GPC', '');
  3. if(empty($get_key)){
  4. respon_json(array(
  5. 'status' => 0,
  6. 'msg' => 'No param: token',
  7. ));
  8. }
  9. if($get_key != get_config('secure_string')){
  10. respon_json(array(
  11. 'status' => 0,
  12. 'msg' => 'Token khong dung',
  13. ));
  14. }
  15. $id = (int) getgpc('order_id', 'GPC', 0);
  16. $text = getgpc('text', 'GPC', '');
  17. if($id == 0){
  18. respon_json(array(
  19. 'status' => 0,
  20. 'msg' => 'No param: order_id',
  21. ));
  22. }
  23.  
  24. $result = resent_sms_order(array(
  25. 'order_id' => $id,
  26. 'text_add' => $text
  27. ));
  28. respon_json($result);
  29. }
  30.  
  31.  
  32.  
  33. function resent_sms_order($data){
  34. global $app;
  35. try {
  36. if (!isset($data['order_id']) || (int)$data['order_id'] == 0) {
  37. return array(
  38. 'status' => 0,
  39. 'msg' => 'No order'
  40. );
  41. }
  42. $get_order = $app->load->model('payment')->getOrderInfo($data['order_id']);
  43. if ($get_order->num_rows == 0) {
  44. return array(
  45. 'status' => 0,
  46. 'msg' => 'No order exist'
  47. );
  48. }
  49. $thisOrder = $get_order->row;
  50.  
  51.  
  52. if($thisOrder['Status'] == 0){
  53. respon_json(array(
  54. 'status' => 0,
  55. 'msg' => 'Order chưa hoàn thành',
  56. ));
  57. }
  58.  
  59. if($thisOrder['SendCardType'] != 'send_code'){
  60. return array(
  61. 'status' => 0,
  62. 'msg' => 'Không phải order sent code'
  63. );
  64. }
  65.  
  66. if($thisOrder['Status'] != 1){
  67. return array(
  68. 'status' => 0,
  69. 'msg' => 'Order này chưa hoàn thành'
  70. );
  71. }
  72.  
  73.  
  74.  
  75. $list_order_detail = $app->load->model('payment')->getListCardOfOrder((int) $data['order_id']);
  76. $list_order_detail_id = [];
  77. if($list_order_detail->num_rows > 0){
  78. foreach($list_order_detail->rows AS $order_detail) {
  79. $list_order_detail_id[] = $order_detail['Order_detail_id'];
  80. }
  81. }
  82.  
  83. $re_get_listCard = $app->load->model('payment')->ListCardOfOrder(array(
  84. 'list_order_detail' => implode(',', $list_order_detail_id)
  85. ));
  86.  
  87.  
  88.  
  89. $phone = $thisOrder['CustomerPhone'];
  90.  
  91.  
  92. $text_add = '.';
  93. if(!empty($data['text_add'])){
  94. $text_add = strval($data['text_add']);
  95. }
  96.  
  97.  
  98. if($re_get_listCard->num_rows > 0){
  99. $list_card = [
  100. 'data' => $re_get_listCard->rows
  101. ];
  102. if(sizeof($list_card['data']) == 1){
  103. $card = $list_card['data'][0];
  104. $content = getContent('sms_one_card');
  105. $data_send = array(
  106. 'order_id' => $data['order_id'],
  107. 'phone' => $phone,
  108. 'text' => lang('c_content', $content['c_content'], array(
  109. // 'daily' => strtoupper(get_session('ufullname')),
  110. 'menhgia' => number_format($card['ProductCode']),
  111. 'code' => $card['PrivateCode'],
  112. 'serial' => $card['SerialNumber']
  113. )). $text_add ,
  114. );
  115. $result_sms = send_sms_order($data_send);
  116.  
  117. $content = getContent('export_card');
  118. $contact_sohagame = get_config_db('contact_sohagame', 'json');
  119.  
  120. // Gửi Email khi xuất mã thẻ thành công
  121. $res = CURL_SendMail(array(
  122. 'from' => get_config('sent_email/email_from'),
  123. 'to' => $thisOrder['CustomerEmail'],
  124. 'subject' => lang('c_content', trim($content['subject'])),
  125. 'html' => lang('c_content', nl2br($content['c_content']), array(
  126. 'account' => strtoupper(get_session('ufullname')),
  127. 'order_id' => $thisOrder['Id'],
  128. 'PrivateCode' => $card['PrivateCode'],
  129. 'SerialNumber' => $card['SerialNumber'],
  130. 'total' => $thisOrder['Total'],
  131. 'total_paid' => $thisOrder['Total'],
  132. 'date_paid' => $thisOrder['LastModifyAt'],
  133. 'for_account' => $thisOrder['CustomerPhone'] !== '' ? $thisOrder['CustomerPhone'] : $thisOrder['CustomerEmail'],
  134. 'sohagame_contact_phone' => isset($contact_sohagame->phone) ? trim($contact_sohagame->phone) : '',
  135. 'sohagame_contact_email' => isset($contact_sohagame->email) ? trim($contact_sohagame->email) : '',
  136. ))
  137. ));
  138.  
  139. return array(
  140. 'status' => 1,
  141. 'msg' => 'Sent Ok',
  142. 'data_sms' => $data_send,
  143. 'result_sms' => $result_sms
  144. );
  145.  
  146. } else if(sizeof($list_card['data']) > 1){
  147.  
  148. $get_short_link = $app->load->model('payment')->get_short_link($data['order_id']);
  149. if($get_short_link->num_rows > 0) {
  150. $thisLink = $get_short_link->row;
  151. $content = getContent('sms_shortlink');
  152. $data_send = array(
  153. 'order_id' => $data['order_id'],
  154. 'phone' => $phone,
  155. 'text' => lang('c_content', $content['c_content'], array(
  156. 'shortlink' => get_domain() . "?l=" . $thisLink['linkCode'],
  157. 'passcode' => $thisLink['Passcode'],
  158. )) . $text_add,
  159. );
  160. $result_sms = send_sms_order($data_send);
  161. return array(
  162. 'status' => 1,
  163. 'msg' => 'Sent Ok',
  164. 'data_sms' => $data_send,
  165. 'result_sms' => $result_sms
  166. );
  167. }
  168.  
  169.  
  170. } else {
  171. return array(
  172. 'status' => 0,
  173. 'msg' => 'List Card empty'
  174. );
  175. }
  176.  
  177. } else {
  178. return $list_card;
  179. }
  180.  
  181.  
  182. } catch (Exception $e){
  183. zdebug_log('Exception_Error', array(
  184. 'file' => __FILE__,
  185. 'line' => __FILE__,
  186. 'msg' => $e->getMessage(),
  187. ), 'push');
  188. respon_json(array(
  189. 'status' => 0,
  190. 'msg' => $e->getMessage(),
  191. ));
  192. }
  193.  
  194.  
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement