public function addcart() { if (empty($_REQUEST['id'])) { $res = array('ret' => '102', 'msg' => '参数不得为空'); ajax_return($res); } $id = intval($_REQUEST['id']); save_debug_log("addcart", 'post:' . json_encode($_POST)); save_debug_log("addcart", 'get:' . json_encode($_GET)); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id=" . $id); $session_id = "app"; if (!$deal_info) { $res = array('ret' => '-1', 'msg' => '该商品不存在'); ajax_return($res); } else { $attr_str = '0'; $verify_code = md5($id . "_" . $attr_str); $cart_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cart where session_id='" . $session_id . "' and user_id = " . intval($GLOBALS['user_info']['id']) . " and verify_code = '" . $verify_code . "'"); $add_number = $number = intval($_REQUEST['number']) <= 0 ? 1 : intval($_REQUEST['number']); //开始运算购物车的验证 if ($cart_item) { $check = check_deal_time($cart_item['deal_id']); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => "商品:" . $check['info'] . "不在可购买时间内"); ajax_return($res); } $check = check_user_bought_day($cart_item['deal_id'], $add_number, $session_id); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => $check['info']); ajax_return($res); } $check = check_deal_number($cart_item['deal_id'], $add_number); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => "商品:" . $check['info'] . "库存不足"); ajax_return($res); } } else { $check = check_deal_time($cart_item['deal_id']); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => "商品:" . $check['info'] . "不在可购买时间内"); ajax_return($res); } $check = check_user_bought_day($deal_info['id'], $add_number); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => $check['info']); ajax_return($res); } $check = check_deal_number($deal_info['id'], $add_number); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => "商品:" . $check['info'] . "库存不足"); ajax_return($res); } } if ($deal_info['return_score'] < 0) { //需要积分兑换 $user_score = intval($GLOBALS['db']->getOne("select score from " . DB_PREFIX . "user where id = " . intval($GLOBALS['user_info']['id']))); if ($user_score < abs(intval($deal_info['return_score']) * $add_number)) { $res['err'] = 1; $res['open_win'] = 1; $res['html'] = $check['info'] . " " . $GLOBALS['lang']['NOT_ENOUGH_SCORE']; $res['number'] = $GLOBALS['db']->getOne("select sum(number) from " . DB_PREFIX . "deal_cart where session_id = '" . es_session::id() . "' and user_id = " . intval($GLOBALS['user_info']['id'])); ajax_return($res); } } //验证over if (!$cart_item) { $attr_price = $GLOBALS['db']->getOne("select sum(price) from " . DB_PREFIX . "deal_attr where id in({$attr_str})"); $cart_item['session_id'] = $session_id; $cart_item['user_id'] = intval($GLOBALS['user_info']['id']); $cart_item['deal_id'] = $id; //属性 if ($attr_name != '') { $cart_item['name'] = $deal_info['name'] . " [" . $attr_name . "]"; $cart_item['sub_name'] = $deal_info['sub_name'] . " [" . $attr_name . "]"; } else { $cart_item['name'] = $deal_info['name']; $cart_item['sub_name'] = $deal_info['sub_name']; } $cart_item['name'] = addslashes($cart_item['name']); $cart_item['sub_name'] = addslashes($cart_item['sub_name']); $cart_item['attr'] = $attr_str; $cart_item['unit_price'] = $deal_info['current_price'] + $attr_price; $cart_item['number'] = $number; $cart_item['total_price'] = $cart_item['unit_price'] * $cart_item['number']; $cart_item['verify_code'] = $verify_code; $cart_item['create_time'] = get_gmtime(); $cart_item['update_time'] = get_gmtime(); $cart_item['return_score'] = $deal_info['return_score']; $cart_item['return_total_score'] = $deal_info['return_score'] * $cart_item['number']; $cart_item['return_money'] = $deal_info['return_money']; $cart_item['return_total_money'] = $deal_info['return_money'] * $cart_item['number']; $cart_item['buy_type'] = $deal_info['buy_type']; $cart_item['supplier_id'] = $deal_info['supplier_id']; $cart_item['attr_str'] = $attr_name_str; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_cart", $cart_item); } else { if ($number > 0) { $cart_item['number'] += $number; $cart_item['total_price'] = $cart_item['unit_price'] * $cart_item['number']; $cart_item['return_total_score'] = $deal_info['return_score'] * $cart_item['number']; $cart_item['return_total_money'] = $deal_info['return_money'] * $cart_item['number']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_cart", $cart_item, "UPDATE", "id=" . $cart_item['id']); } } $res['number'] = $GLOBALS['db']->getOne("select sum(number) from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "' and user_id = " . intval($GLOBALS['user_info']['id'])); $res['ret'] = '0'; save_debug_log('add cart', 'post :' . json_encode($_POST) . ' res:' . json_encode($res)); ajax_return($res); } }
public function done() { save_debug_log('cart done', 'request:' . json_encode($_REQUEST)); $region4_id = intval($_REQUEST['region_lv4']); $region3_id = intval($_REQUEST['region_lv3']); $region2_id = intval($_REQUEST['region_lv2']); $region1_id = intval($_REQUEST['region_lv1']); if ($region4_id == 0) { if ($region3_id == 0) { if ($region2_id == 0) { $region_id = $region1_id; } else { $region_id = $region2_id; } } else { $region_id = $region3_id; } } else { $region_id = $region4_id; } $delivery_id = intval($_REQUEST['delivery']); $payment = intval($_REQUEST['payment']); $account_money = floatval($_REQUEST['account_money']); $all_account_money = intval($_REQUEST['all_account_money']); $ecvsn = $_REQUEST['ecvsn'] ? addslashes(trim($_REQUEST['ecvsn'])) : ''; $ecvpassword = $_REQUEST['ecvpassword'] ? addslashes(trim($_REQUEST['ecvpassword'])) : ''; $user_id = intval($GLOBALS['user_info']['id']); $session_id = es_session::id(); $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cart where session_id='" . $session_id . "' and user_id=" . $user_id); if (!$goods_list) { showErr($GLOBALS['lang']['CART_EMPTY_TIP'], $ajax); } //验证购物车 if (!$GLOBALS['user_info']) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax, url("shop", "user#login")); } $deal_ids = $GLOBALS['db']->getAll("select distinct(deal_id) as deal_id,number from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "' and user_id = " . $user_id); foreach ($deal_ids as $row) { $checker = check_deal_time($row['deal_id']); if ($checker['status'] == 0) { showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index")); } $check = check_user_bought_day($row['deal_id'], $row['number']); if ($check['status'] == 0) { $res = array('ret' => '-1', 'info' => $check['info']); showErr($check['info'], $ajax, url("shop", "cart#index")); } $checker = check_deal_number($row['deal_id']); if ($checker['status'] == 0) { showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index")); } //验证支付方式的支持 if ($GLOBALS['db']->getOne("select define_payment from " . DB_PREFIX . "deal where id = " . $row['deal_id']) == 1) { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where deal_id = " . $row['deal_id'] . " and payment_id = " . $payment)) { showErr($GLOBALS['lang']['INVALID_PAYMENT'], $ajax, url("shop", "cart#index")); } } } //开始验证关于属性的库存 $deal_attr_ids = $GLOBALS['db']->getAll("select deal_id,attr,name,attr_str from " . DB_PREFIX . "deal_cart where session_id = '" . es_session::id() . "' and user_id = " . $user_id); foreach ($deal_attr_ids as $row) { $attr_setting_str = ''; if ($row['attr_str'] != '') { $attr_setting_str = $row['attr_str']; } if ($attr_setting_str != '') { $checker = check_deal_number_attr($row['deal_id'], $attr_setting_str); if ($checker['status'] == 0) { if ($ajax == 1) { showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']] . "|" . $row['deal_id'] . "|" . $checker['attr'], $ajax, url("shop", "cart#index")); } else { showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax, url("shop", "cart#index")); } } } } //结束验证购物车 //开始验证订单接交信息 require_once APP_ROOT_PATH . "system/libs/cart.php"; $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list); if ($data['is_delivery'] == 1) { // 如果服务站为空或者服务站为“暂不支持配送” $region4 = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "delivery_region where id=" . $region4_id); if ($region4 == false) { showErr($GLOBALS['lang']['DELIVERY_REGION_LV4_IS_NONE']); } if ($region4 == $GLOBALS['lang']['DELETERY_REGION_LV4_NOT_SUPPORT_STR']) { showErr($GLOBALS['lang']['DELETERY_REGION_LV4_NOT_SUPPORT']); } //配送验证 if (!$data['region_info'] || $data['region_info']['region_level'] != 4) { showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS']); } if (trim($_REQUEST['consignee']) == '') { showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE']); } if (trim($_REQUEST['address']) == '') { showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS']); } // if(trim($_REQUEST['zip'])=='') // { // showErr($GLOBALS['lang']['FILL_CORRECT_ZIP']); // } if (trim($_REQUEST['mobile']) == '') { showErr($GLOBALS['lang']['FILL_MOBILE_PHONE']); } if (!check_mobile(trim($_REQUEST['mobile']))) { showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE']); } // if(!$data['delivery_info']) // { // showErr($GLOBALS['lang']['PLEASE_SELECT_DELIVERY']); // } } //TODO if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) { showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT']); } //结束验证订单接交信息 //开始生成订单 $now = get_gmtime(); $order['type'] = 0; //普通订单 $order['user_id'] = $user_id; $order['create_time'] = $now; $order['total_price'] = $data['pay_total_price']; //应付总额 商品价 - 会员折扣 + 运费 + 支付手续费 $order['pay_amount'] = 0; $order['pay_status'] = 0; //新单都为零, 等下面的流程同步订单状态 $order['delivery_status'] = $data['is_delivery'] == 0 ? 5 : 0; $order['order_status'] = 0; //新单都为零, 等下面的流程同步订单状态 $order['return_total_score'] = $data['return_total_score']; //结单后送的积分 $order['return_total_money'] = $data['return_total_money']; //结单后送的现金 $order['memo'] = htmlspecialchars(addslashes(trim($_REQUEST['memo']))); $order['region_lv1'] = intval($_REQUEST['region_lv1']); $order['region_lv2'] = intval($_REQUEST['region_lv2']); $order['region_lv3'] = intval($_REQUEST['region_lv3']); $order['region_lv4'] = intval($_REQUEST['region_lv4']); $order['address'] = htmlspecialchars(addslashes(trim($_REQUEST['address']))); $order['mobile'] = htmlspecialchars(addslashes(trim($_REQUEST['mobile']))); $order['consignee'] = htmlspecialchars(addslashes(trim($_REQUEST['consignee']))); $order['zip'] = htmlspecialchars(addslashes(trim($_REQUEST['zip']))); $order['deal_total_price'] = $data['total_price']; //团购商品总价 $order['discount_price'] = $data['user_discount']; $order['delivery_fee'] = $data['delivery_fee']; $order['ecv_money'] = 0; $order['account_money'] = 0; $order['ecv_sn'] = ''; $order['delivery_id'] = $data['delivery_info']['id']; $order['payment_id'] = $data['payment_info']['id']; $order['payment_fee'] = $data['payment_fee']; $order['payment_fee'] = $data['payment_fee']; $order['bank_id'] = htmlspecialchars(addslashes(trim($_REQUEST['bank_id']))); foreach ($data['promote_description'] as $promote_item) { $order['promote_description'] .= $promote_item . "<br />"; } //更新来路 $order['referer'] = $GLOBALS['referer']; $user_info = es_session::get("user_info"); $order['user_name'] = $user_info['user_name']; $coupon_mobile = htmlspecialchars(addslashes(trim($_REQUEST['coupon_mobile']))); if ($coupon_mobile != '') { $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $coupon_mobile . "' where id = " . intval($user_info['id'])); } do { $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99); $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT'); $order_id = intval($GLOBALS['db']->insert_id()); } while ($order_id == 0); //生成订单商品 foreach ($goods_list as $k => $v) { $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id'])); $goods_item = array(); $goods_item['deal_id'] = $v['deal_id']; $goods_item['number'] = $v['number']; $goods_item['unit_price'] = $v['unit_price']; $goods_item['total_price'] = $v['total_price']; $goods_item['name'] = addslashes($v['name']); $goods_item['sub_name'] = addslashes($v['sub_name']); $goods_item['attr'] = $v['attr']; $goods_item['verify_code'] = $v['verify_code']; $goods_item['order_id'] = $order_id; $goods_item['return_score'] = $v['return_score']; $goods_item['return_total_score'] = $v['return_total_score']; $goods_item['return_money'] = $v['return_money']; $goods_item['return_total_money'] = $v['return_total_money']; $goods_item['buy_type'] = $v['buy_type']; $goods_item['attr_str'] = $v['attr_str']; $goods_item['balance_unit_price'] = $deal_info['balance_price']; $goods_item['balance_total_price'] = $deal_info['balance_price'] * $v['number']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $goods_item, 'INSERT', '', 'SILENT'); } //开始更新订单表的deal_ids $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id); $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set deal_ids = '" . $deal_ids . "' where id = " . $order_id); $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_cart where session_id = '" . $session_id . "' and user_id = " . $user_id); if ($data['is_delivery'] == 1) { //保存收款人 $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $user_id . " order by id desc"); $user_consignee['region_lv1'] = intval($_REQUEST['region_lv1']); $user_consignee['region_lv2'] = intval($_REQUEST['region_lv2']); $user_consignee['region_lv3'] = intval($_REQUEST['region_lv3']); $user_consignee['region_lv4'] = intval($_REQUEST['region_lv4']); $user_consignee['address'] = htmlspecialchars(addslashes(trim($_REQUEST['address']))); $user_consignee['mobile'] = htmlspecialchars(addslashes(trim($_REQUEST['mobile']))); $user_consignee['consignee'] = htmlspecialchars(addslashes(trim($_REQUEST['consignee']))); $user_consignee['zip'] = htmlspecialchars(addslashes(trim($_REQUEST['zip']))); $user_consignee['user_id'] = $user_id; if (intval($user_consignee['id']) == 0) { //新增 $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'INSERT', '', 'SILENT'); } else { //更新 $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $user_consignee, 'UPDATE', 'id=' . $user_consignee['id'], 'SILENT'); rm_auto_cache("consignee_info", array("consignee_id" => intval($user_consignee['id']))); } } //生成order_id 后 //1. 代金券支付 $ecv_data = $data['ecv_data']; if ($ecv_data) { $ecv_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'"); $payment_notice_id = make_payment_notice($ecv_data['money'], $order_id, $ecv_payment_id); require_once APP_ROOT_PATH . "system/payment/Voucher_payment.php"; $voucher_payment = new Voucher_payment(); $voucher_payment->direct_pay($ecv_data['sn'], $ecv_data['password'], $payment_notice_id); } //2. 余额支付 $account_money = $data['account_money']; if (floatval($account_money) > 0) { $account_payment_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Account'"); $payment_notice_id = make_payment_notice($account_money, $order_id, $account_payment_id); require_once APP_ROOT_PATH . "system/payment/Account_payment.php"; $account_payment = new Account_payment(); $account_payment->get_payment_code($payment_notice_id); } //3. 相应的支付接口 $payment_info = $data['payment_info']; if ($payment_info && $data['pay_price'] > 0) { $payment_notice_id = make_payment_notice($data['pay_price'], $order_id, $payment_info['id']); //创建支付接口的付款单 } $rs = order_paid($order_id); save_debug_log('cart done', 'order_paid rs:' . $rs . 'order_id:' . $order_id); if ($rs) { app_redirect(url("shop", "payment#done", array("id" => $order_id))); //支付成功 } else { app_redirect(url("shop", "payment#pay", array("id" => $payment_notice_id))); } }
/** * 下订单 */ public function add_deal_order() { if (empty($_REQUEST['deal_id'])) { echo json_encode(array('ret' => '-1', 'msg' => '请求参数为空')); } else { save_debug_log("add_deal_order post", json_encode($_POST)); $deal_id = $_REQUEST['deal_id']; $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id =" . $deal_id); if (!$deal_info) { $res = array('ret' => '-1', 'msg' => '该商品不存在'); ajax_return($res); } $number = empty($_REQUEST['number']) ? 1 : $_REQUEST['number']; $is_cash_pay = isset($_REQUEST['is_cash_pay']) ? $_REQUEST['is_cash_pay'] : 0; //是否货到付款 if ($is_cash_pay && !is_deal_cash_pay($deal_id)) { //检测商品是否支持货到付款 $res = array('ret' => '-1', 'msg' => "该商品不支持货到付款"); ajax_return($res); } $check = check_deal_number($deal_id, $number, "app"); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => $check['info']); ajax_return($res); } $check = check_user_bought_day($deal_id, $number); if ($check['status'] == 0) { $res = array('ret' => '-1', 'msg' => $check['info']); ajax_return($res); } $check_deal_time = check_deal_time($deal_id); if ($check_deal_time['status'] == 0) { $res = array('ret' => '-1', 'msg' => "商品:" . $check['info'] . "不在可购买时间内"); ajax_return($res); } $deal_order = array(); $deal_order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(10, 99); $deal_order['type'] = 0; $deal_order['user_id'] = $GLOBALS['user_info']['id']; $deal_order['create_time'] = time(); $deal_order['pay_status'] = 0; $deal_order['pay_amount'] = 0; $deal_order['delivery_status'] = $deal_info['is_delivery'] == 0 ? 5 : 0; //$deal_order['delivery_status'] = 0; $deal_order['is_delete'] = 0; $deal_order['return_total_score'] = 0; $deal_order['refund_amount'] = 0; if ($deal_info['is_delivery'] == 1) { // 填写收货地址 if (!empty($_POST['consignee_id'])) { $consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id=" . $_POST['consignee_id']); } else { $consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id=" . $GLOBALS['user_info']['id'] . " and isdef=1"); } save_debug_log("add_deal_order consignee", json_encode($consignee)); if ($consignee) { $is_region_lv4_exist = $GLOBALS['db']->getOne("select count(1) from " . DB_PREFIX . "delivery_region where id=" . $consignee['region_lv4']); save_debug_log('is_region_lv4', "sql " . "select count(1) from " . DB_PREFIX . "delivery_region where id=" . $consignee['region_lv4'] . " is_regioin_lv4: {$is_region_lv4_exist}"); if ($is_region_lv4_exist <= 0) { $res = array('ret' => '-1', 'msg' => "所选地址服务站不存在,请重新选择"); ajax_return($res); } $deal_order['region_lv1'] = $consignee['region_lv1']; $deal_order['region_lv2'] = $consignee['region_lv2']; $deal_order['region_lv3'] = $consignee['region_lv3']; $deal_order['region_lv4'] = $consignee['region_lv4']; //判断收货地址是否支持货到付款 if ($is_cash_pay && !is_region_cash_pay($deal_order['region_lv4'])) { $res = array('ret' => '-1', 'msg' => '所选地址服务站不支持货到付款'); ajax_return($res); } $deal_order['address'] = $consignee['address']; $deal_order['mobile'] = $consignee['mobile']; $deal_order['zip'] = $consignee['zip']; } else { $res = array('ret' => '-1', 'msg' => "收货地址不得为空"); ajax_return($res); } } $deal_order['deal_ids'] = $deal_id; $deal_order['user_name'] = $GLOBALS['user_info']['user_name']; $total_price = $deal_info['current_price'] * $number; $deal_order['total_price'] = $total_price; // 需要计算 $deal_order['deal_total_price'] = $total_price; $deal_order['discount_price'] = 0; $deal_order['delivery_fee'] = 0; $deal_order['ecv_money'] = 0; $deal_order['account_money'] = 0; $deal_order['delivery_id'] = 0; $deal_order['payment_id'] = $is_cash_pay ? 22 : 0; $deal_order['payment_fee'] = 0; $deal_order['return_total_money'] = 0; $deal_order['extra_status'] = 0; $deal_order['after_sale'] = 0; $deal_order['refund_money'] = 0; $deal_order['refund_status'] = 0; $deal_order['retake_status'] = 0; if ($GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $deal_order, "INSERT")) { $order_id = $GLOBALS['db']->insert_id(); // 成功插入订单数据后 $deal_order_item = array(); $deal_order_item['deal_id'] = $deal_info['id']; $deal_order_item['number'] = $number; $deal_order_item['unit_price'] = $deal_info['current_price']; $deal_order_item['total_price'] = $total_price; $deal_order_item['delivery_status'] = $deal_info['is_delivery'] == 0 ? 5 : 0; $deal_order_item['name'] = $deal_info['name']; $deal_order_item['sub_name'] = $deal_info['sub_name']; $deal_order_item['return_score'] = 0; $deal_order_item['return_total_score'] = 0; $deal_order_item['order_id'] = $order_id; $deal_order_item['attr'] = ''; $deal_order_item['verify_code'] = ''; $deal_order_item['return_money'] = 0; $deal_order_item['return_total_money'] = 0; $deal_order_item['buy_type'] = $deal_info['buy_type']; $deal_order_item['is_balance'] = 0; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_item", $deal_order_item, "INSERT"); echo json_encode(array('ret' => '0', 'order_id' => $order_id, 'order_sn' => $deal_order['order_sn'])); save_debug_log('add_deal_order ret id', json_encode(array('ret' => '0', 'order_id' => $order_id, 'order_sn' => $deal_order['order_sn'])) . "\n"); } else { echo json_encode(array('ret' => '-1', 'msg' => '订单添加失败')); } } }