function close_expire_order() { $success = 0; $msg = ''; $id = $_POST['id']; if (empty($id) || !current_user_can('edit_users')) { $msg = '系统出错或你无权限执行该动作'; } else { global $wpdb; $prefix = $wpdb->prefix; $table = $prefix . 'tin_orders'; $id = intval($id); $check = $wpdb->get_row("select * from " . $table . " where id=" . $id); if ($check) { $wpdb->query("UPDATE {$table} SET order_status=9, order_success_time=NOW() WHERE id='{$id}'"); if (!empty($check->user_email)) { store_email_template($check->order_id, '', $check->user_email); } $success = 1; } } $return = array('success' => $success, 'msg' => $msg); echo json_encode($return); exit; }
function create_the_vip_order() { $success = 0; $order_id = ''; $msg = ''; if (!is_user_logged_in()) { $msg = '请先登录'; } else { $user_info = wp_get_current_user(); $uid = $user_info->ID; $user_name = $user_info->display_name; $user_email = $user_info->user_email; $product_id = $_POST['product_id']; if ($product_id == -4) { $order_price = um_get_setting('life_mb_price', 120); $order_name = '终身会员'; } elseif ($product_id == -3) { $order_price = um_get_setting('annual_mb_price', 45); $order_name = '年费会员'; } elseif ($product_id == -2) { $order_price = um_get_setting('quarterly_mb_price', 12); $order_name = '季费会员'; } else { $order_price = um_get_setting('monthly_mb_price', 5); $order_name = '月费会员'; } $ratio = um_get_setting('aff_ratio', 10); $rewards = $order_price * $ratio / 100; $rewards = (int) $rewards; $insert = insert_order($product_id, $order_name, $order_price, 1, $order_price, 1, '', $uid, $_POST['aff_user_id'], $rewards, $user_name, $user_email, '', '', '', '', ''); if ($insert) { $success = 1; $order_id = $insert; if (!empty($user_email)) { store_email_template($order_id, '', $user_email); } } else { $msg = '创建订单失败,请重新再试'; } } $return = array('success' => $success, 'msg' => $msg, 'order_id' => $order_id); echo json_encode($return); exit; }
} } elseif ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') { //判断该笔订单是否在商户网站中已经做过处理 global $wpdb; $row = $wpdb->get_row("select * from " . $table . " where order_id=" . $out_trade_no); $product_id = $row->product_id; if ($row) { if ($row->order_status <= 3) { $success_time = $_POST['notify_time']; $wpdb->query("UPDATE {$table} SET order_status=4, trade_no='{$trade_no}', order_success_time='{$success_time}', user_alipay='{$buyer_alipay}' WHERE order_id='{$out_trade_no}'"); update_success_order_product($row->product_id, $row->order_quantity); if (!empty($row->user_email)) { $email = $row->user_email; } //发送订单状态变更email store_email_template($out_trade_no, '', $email); //发送购买可见内容或下载链接或会员状态变更 send_goods_by_order($out_trade_no, '', $email); } } //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 } else { echo "<br /><br />"; } echo "<br /><br />"; //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } else { //验证失败 //如要调试,请看alipay_notify.php页面的verifyReturn函数
function create_the_vip_order() { $success = 0; $order_id = ''; $msg = ''; if (!is_user_logged_in()) { $msg = '请先登录'; } else { $user_info = wp_get_current_user(); $uid = $user_info->ID; $user_name = $user_info->display_name; $user_email = $user_info->user_email; $product_id = $_POST['product_id']; if ($product_id == -3) { $order_price = ot_get_option('vip_annual_price', 90); $order_name = '年费会员'; } elseif ($product_id == -2) { $order_price = ot_get_option('vip_quarterly_price', 25); $order_name = '季费会员'; } else { $order_price = ot_get_option('vip_monthly_price', 10); $order_name = '月费会员'; } $insert = insert_order($product_id, $order_name, $order_price, 1, $order_price, 1, '', $uid, $user_name, $user_email, '', '', '', '', ''); if ($insert) { $success = 1; $order_id = $insert; if (!empty($user_email)) { store_email_template($order_id, '', $user_email); } } else { $msg = '创建订单失败,请重新再试'; } } $return = array('success' => $success, 'msg' => $msg, 'order_id' => $order_id); echo json_encode($return); exit; }