where('order_no',$result['out_trade_no'])->find(); if ($order){ Db::startTrans(); try { $da['pay_time'] = time(); $da['status'] = 1; $da['return_success_info'] = json_encode($result,true); Order::where('id',$order['id'])->update($da); Common::order_status($order['id'],'微信支付成功'); Db::commit(); $arr = array( 'return_code' => 'SUCCESS', 'return_msg' => 'OK', ); return $this->arrayToXml($arr); }catch (Exception $e) { Db::rollback(); file_put_contents("order_pay_error.txt", file_get_contents("php://input") . "\n" . json_encode($result) . "\n" . "\n", FILE_APPEND); } } } } /** * 微信支付--加班费支付成功回调订单 */ public function overtime_pay_order(){ $payXml = file_get_contents("php://input"); //将xml格式转化为json格式 $jsonXml = json_encode(simplexml_load_string($payXml, 'SimpleXMLElement', LIBXML_NOCDATA)); //将json格式转成数组格式 $result['out_trade_no'] $result = json_decode($jsonXml, true); if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') { $order = Order::where('overtime_pay_status',1)->where('overtime_pay_order_no',$result['out_trade_no'])->find(); if ($order){ Db::startTrans(); try { $da['overtime_pay_time'] = time(); $da['overtime_pay_status'] = 2; $da['overtime_return_success_info'] = json_encode($result,true); Order::where('id',$order['id'])->update($da); Common::order_status($order['id'],'微信支付加班费成功'); Db::commit(); $arr = array( 'return_code' => 'SUCCESS', 'return_msg' => 'OK', ); return $this->arrayToXml($arr); }catch (Exception $e) { Db::rollback(); file_put_contents("order_pay_error.txt", file_get_contents("php://input") . "\n" . json_encode($result) . "\n" . "\n", FILE_APPEND); } } } } /** * 支付宝支付--商品支付成功回调订单 */ public function alipay_order(){ $result = input('post.'); if ($result['trade_status'] == 'TRADE_SUCCESS' || $result['trade_status'] == 'TRADE_FINISHED') { $order = Order::where('status',0)->where('order_no',$result['out_trade_no'])->find(); if ($order){ Db::startTrans(); try { $da['pay_time'] = time(); $da['status'] = 1; $da['return_success_info'] = json_encode($result,true); Order::where('id',$order['id'])->update($da); Common::order_status($order['id'],'支付宝支付成功'); Db::commit(); echo 'success'; }catch (Exception $e) { Db::rollback(); file_put_contents("order_alipay_error.txt", file_get_contents("php://input") . "\n" . json_encode($result) . "\n" . "\n", FILE_APPEND); } } } } /** * 支付宝支付--商品支付成功回调订单 */ public function overtime_alipay_order(){ $result = input('post.'); if ($result['trade_status'] == 'TRADE_SUCCESS' || $result['trade_status'] == 'TRADE_FINISHED') { $order = Order::where('overtime_pay_status',1)->where('overtime_pay_order_no',$result['out_trade_no'])->find(); if ($order){ Db::startTrans(); try { $da['overtime_pay_time'] = time(); $da['overtime_pay_status'] = 2; $da['overtime_return_success_info'] = json_encode($result,true); Order::where('id',$order['id'])->update($da); Common::order_status($order['id'],'支付宝支付加班费成功'); Db::commit(); echo 'success'; }catch (Exception $e) { Db::rollback(); file_put_contents("order_alipay_error.txt", file_get_contents("php://input") . "\n" . json_encode($result) . "\n" . "\n", FILE_APPEND); } } } } /** * 数组转xml * @ApiInternal */ public function arrayToXml($arr) { $xml = ""; foreach ($arr as $key => $val) { if (is_numeric($val)) { $xml .= "<" . $key . ">" . $val . ""; } else $xml .= "<" . $key . ">"; } $xml .= ""; return $xml; } }