function handSend() { $order_id = (int) $this->req->post['order_id']; $order = $this->load->model('order')->findById($order_id); $order_info = $this->load->model('orderInfo')->findInfoById($order_id); if (!empty($order) && !empty($order_info)) { // 商品信息 $product_info = ""; foreach ($order_info as $key => $value) { $product_info = $product_info . $value['name'] . 'x' . $value['piece']; } //需要远程提交的数据 $data = array('name' => $order['name'], 'phone' => $order['phone'], 'address' => $order['address'], 'order_id' => $order['order_id'], 'order_code' => $order['order_code'], 'money' => $order['money'], 'product' => $product_info); $ret = phppost(CLIENTURL, $data); if ($ret == 'success') { //改变订单状态为已经发送 $result = $this->load->model('order')->updateSend($order_id); if ($result) { setHint('远程提交订单成功'); } else { setHint('远程提交订单成功,但本地失败', 'bad'); } } else { setHint('未发送成功', 'bad'); } } else { setHint('此订单不存在', 'bad'); } $this->res->red('order/notSend'); }
function pay_callback() { $this->res->json(); require_once ALIPAY . "alipay.config.php"; require_once ALIPAY . "alipay_notify.class.php"; $post = $this->req->post; // //计算得出通知验证结果 $alipayNotify = new AlipayNotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); $error_str = ""; foreach ($post as $key => $value) { $error_str .= $key . "=>" . $value; } logs($error_str); // $verify_result = true; if ($verify_result) { //商户订单号 $order_code = $post['out_trade_no']; //支付宝交易号 $trade_no = $post['trade_no']; //交易状态 $trade_status = $post['trade_status']; if (empty($order_code) || empty($trade_no)) { echo 'fail'; return; } if ($trade_status == 'TRADE_FINISHED' || $trade_status == 'TRADE_SUCCESS') { //检查此订单是否已经有快递单号 $result_order = $this->load->model('order')->findByOrdercode($order_code); if ($result_order) { if (empty($result_order['rebate_tag'])) { //处理系统返佣等业务 $user_id = (int) $result_order['user_id']; $order_id = (int) $result_order['order_id']; $user = $this->load->model('user')->findById($user_id); $products = $this->load->model('orderInfo')->findInfoById($order_id); //开始事务 $this->db->begin(); //为上级业务员返利 $result_ret = $this->returnMoneyByProduct($products, $user); //更新订单信息 $result_update = $this->load->model('order')->updateRebatetag($result_order['order_id'], $trade_no); if ($result_ret && $result_update) { // $this->db->commit(); $remote_result = phppost('http://www.vipaida.com/YlFyS93/sslorder2.php', $this->getSendOrderInfo($order_id)); if (trim($remote_result) == 'success') { //更新订单send= 1 $result_send = $this->load->model('order')->updateSend($order_id); if (!$result_send) { logs('error upadte order send id=' . $order_id); } } echo 'success'; } else { $this->db->rollback(); logs('pay_callback error'); echo 'fail'; } //缺少给何发送订单 } else { echo 'fail'; } } else { echo 'fail'; //订单号不存在 } } else { echo 'fail'; } } else { echo 'fail'; } }