app = $app; } //查询订单 public function Queryorder($transaction_id){ @file_put_contents('./weixinQuery.txt','in_query',FILE_APPEND); $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); if(array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { $arr = json_decode($result['attach'] , true); switch ($arr['type']){ case 'Balance': //余额卡 $order_model = new \app\farm\model\BalanceOrder(); break; case 'Claim': //认养 $order_model = new \app\farm\model\ClaimOrder(); break; case 'Land': //土地 $order_model = new \app\farm\model\LandOrder(); break; case 'ClaimSend': //配送订单 $order_model = new \app\farm\model\SendOrder(); break; case 'Breed': //养殖订单 $order_model = new \app\farm\model\BreedOrder(); break; case 'SchoolShop': //商城订单 $order_model = new \app\farm\model\ShopOrder(); break; } $order_model->orderResult($arr['out_trade_no'],$transaction_id); } return false; } //重写回调处理函数 public function NotifyProcess($data, &$msg) { $notfiyOutput = array(); if(!array_key_exists("transaction_id", $data)){ file_put_contents('./weixinQuery.txt','输入参数不正确',FILE_APPEND); $msg = "输入参数不正确"; return false; } file_put_contents('./weixinQuery.txt','abc',FILE_APPEND); //查询订单,判断订单真实性 if(!$this->Queryorder($data["transaction_id"],$data[''])){ $msg = "订单查询失败"; return false; } return true; } }