public function index() { $city_name = strim($GLOBALS['request']['city_name']); //城市名称 //检查用户,用户密码 $user = $GLOBALS['user_info']; $user_id = intval($user['id']); $root = array(); $root['return'] = 1; if ($user_id > 0) { $root['user_login_status'] = 1; $order_id = intval($GLOBALS['request']['id']); require_once APP_ROOT_PATH . "system/model/deal_order.php"; $order_table_name = get_user_order_table_name($user_id); //echo $order_id; exit; $sql = "select o.*,r1.name as r1_name, r2.name as r2_name, r3.name as r3_name, r4.name as r4_name from " . $order_table_name . " as o " . "left outer join " . DB_PREFIX . "delivery_region as r1 on r1.id = o.region_lv1 " . "left outer join " . DB_PREFIX . "delivery_region as r2 on r2.id = o.region_lv2 " . "left outer join " . DB_PREFIX . "delivery_region as r3 on r3.id = o.region_lv3 " . "left outer join " . DB_PREFIX . "delivery_region as r4 on r4.id = o.region_lv4 " . " where o.is_delete = 0 and o.user_id = {$user_id} and o.id = {$order_id} limit 1"; $order_info = $GLOBALS['db']->getRow($sql); if ($order_info) { $root = get_order_goods($order_info); $root['return'] = 1; $root['user_login_status'] = 1; $deliveryAddr = array(); $deliveryAddr['consignee'] = $order_info['consignee']; //联系人姓名 $deliveryAddr['delivery'] = $order_info['r1_name'] . $order_info['r2_name'] . $order_info['r3_name'] . $order_info['r4_name']; $deliveryAddr['region_lv1'] = $order_info['region_lv1']; //国家 $deliveryAddr['region_lv2'] = $order_info['region_lv2']; //省 $deliveryAddr['region_lv3'] = $order_info['region_lv3']; //城市 $deliveryAddr['region_lv4'] = $order_info['region_lv4']; //地区/县 $deliveryAddr['delivery_detail'] = $order_info['address']; //详细地址 $deliveryAddr['phone'] = $order_info['mobile']; //手机号码 $deliveryAddr['postcode'] = $order_info['zip']; //邮编 $root['deliveryAddr'] = $deliveryAddr; $root['delivery_status_2'] = $order_info['delivery_status']; $root['content'] = $order_info['memo']; //订单备注 $root['send_mobile'] = $user['mobile']; //团购券手机 $root['tax_title'] = $order_info['tax_title']; //发票抬头 $root['tax_id'] = 0; //发票内容 $root['deliver_time_id'] = 0; //配送日期ID 默认没有这个参数,所以填0 $root['delivery_list'] = $GLOBALS['m_config']['delivery_list']; //$default_payment_id = $GLOBALS['m_config']['select_payment_id']; if ($GLOBALS['request']['payment_id']) { $default_payment_id = intval($GLOBALS['request']['payment_id']); } else { $default_payment_id = $order_info['payment_id']; } //$default_payment_id = $order_info['payment_id']; $root['payment_id'] = $default_payment_id; //支付方式 $root['order_parm'] = init_order_parm($GLOBALS['m_config']); $root['order_parm']['has_ecv'] = 0; //订单付款不支持代金券 $root['evc_sn'] = ''; //优惠券序号 $root['evc_pwd'] = ''; //优惠券序号 $order_item_table_name = get_user_order_item_table_name($user_id); $goods_list = $GLOBALS['db']->getAll("select * from " . $order_item_table_name . " where order_id = " . $order_id); $ids = array(); $cart_ids = array(); $root['dp_able'] = 0; $root['goods_list'] = $goods_list; foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); array_push($cart_ids, $cart_goods['id']); if (empty($cart_goods['dp_id'])) { if ($root['pay_status'] == 2 && $root['order_status'] == 1 && ($root['delivery_status_code'] == 2 || $root['delivery_status_code'] == 5)) { $root['dp_able'] = 1; $root['dp_deal_id'] = $cart_goods['id']; } } } $ids_str = implode(",", $ids); $cart_ids_str = implode(",", $cart_ids); $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if ($is_delivery == 0) { $delivery_id = 0; $root['order_parm']['has_delivery'] = 0; } else { if ($GLOBALS['request']['delivery_id']) { $delivery_id = intval($GLOBALS['request']['delivery_id']); } else { $delivery_id = $order_info['delivery_id']; //配送方式; } //$delivery_id = $order_info['delivery_id']; $root['order_parm']['has_delivery'] = 1; } $root['delivery_id'] = $delivery_id; //配送方式 $has_coupon = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_coupon = 1 and id in (" . $ids_str . ")")); if ($has_coupon == 0) { $root['order_parm']['has_moblie'] = 0; $root['order_parm']['has_mcod'] = 1; } else { $root['order_parm']['has_moblie'] = 1; $root['order_parm']['has_mcod'] = 0; //有团购券商品,不能做:货到付款 } foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['code'] == 'Mcod' && $root['order_parm']['has_mcod'] == 0) { unset($root['order_parm']['payment_list'][$k]); } } $forbid_payment = $GLOBALS['db']->getAll("select payment_id from " . DB_PREFIX . "deal_payment where deal_id in (" . $ids_str . ")"); foreach ($forbid_payment as $forbid_payment_item) { foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['payment_id']) { unset($root['order_parm']['payment_list'][$k]); } } } $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } //数组按顺序排序 $payment_list = array(); foreach ($root['order_parm']['payment_list'] as $k => $v) { $payment_list[] = $v; } $root['order_parm']['payment_list'] = $payment_list; $delivery_list = array(); foreach ($root['order_parm']['delivery_list'] as $k => $v) { $delivery_list[] = $v; } $root['order_parm']['delivery_list'] = $delivery_list; $region4_id = intval($order_info['region_lv4']); $region3_id = intval($order_info['region_lv3']); $region2_id = intval($order_info['region_lv2']); $region1_id = intval($order_info['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; } require_once APP_ROOT_PATH . "system/model/cart.php"; //订单的显示参数 if ($order_info['pay_status'] == 0) { $root['has_cancel'] = 1; } else { $root['has_cancel'] = 0; } $delivery_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "delivery_notice where order_item_id in (" . $cart_ids_str . ") order by delivery_time desc limit 1"); if ($delivery_notice) { $express = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "express where id = " . intval($delivery_notice['express_id'])); $express['config'] = unserialize($express['config']); $root['kd_com'] = $express['config']['app_code']; if ($root['kd_com']) { $root['kd_sn'] = $delivery_notice['notice_sn']; } } if ($order_info['pay_status'] != 2) { if ($root['order_parm']['has_delivery'] == 1) { $root['has_edit_delivery'] = 1; } else { $root['has_edit_delivery'] = 0; } $root['has_edit_delivery_time'] = 0; $root['has_edit_invoice'] = 0; $root['has_edit_ecv'] = 0; $root['has_edit_message'] = 1; if ($root['order_parm']['has_moblie'] == 1) { $root['has_edit_moblie'] = 1; } else { $root['has_edit_moblie'] = 0; } $GLOBALS['user_info']['id'] = $user_id; $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $default_payment_id, $account_money = 0, $all_account_money = 1, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } else { $data = count_buy_total($region_id, $delivery_id, $default_payment_id, $account_money = 0, $all_account_money = 0, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } //print_r($data);exit; if ($data['pay_price'] == 0) { if ($data['account_money'] > 0 || $data['ecv_money'] > 0) { $root['has_pay'] = 1; $root['use_user_money'] = $data['account_price']; } else { $root['has_pay'] = 0; $root['use_user_money'] = 0; } $root['pay_money'] = 0; //还需要支付金额 } else { $root['has_pay'] = 1; $root['pay_money'] = $data['pay_price']; //还需要支付金额 $root['use_user_money'] = 0; } if ($root['has_pay'] == 0) { $root['has_edit_delivery'] = 0; $root['has_edit_delivery_time'] = 0; $root['has_edit_invoice'] = 0; $root['has_edit_ecv'] = 0; $root['has_edit_message'] = 0; $root['has_edit_moblie'] = 0; } $root['feeinfo'] = getFeeItem($data); } else { $root['has_pay'] = 0; $root['has_edit_delivery'] = 0; $root['has_edit_delivery_time'] = 0; $root['has_edit_invoice'] = 0; $root['has_edit_ecv'] = 0; $root['has_edit_message'] = 0; $root['has_edit_moblie'] = 0; $data['pay_total_price'] = $order_info['total_price']; $data['return_total_score'] = $order_info['return_total_score']; $data['total_price'] = $order_info['deal_total_price']; $data['delivery_fee'] = $order_info['delivery_fee']; $data['account_money'] = $order_info['account_money']; $data['ecv_money'] = $order_info['ecv_money']; $root['pay_money'] = 0; //还需要支付金额 $root['use_user_money'] = 0; $root['feeinfo'] = getFeeItem($data); //有团购券,再显示团购券列表 $couponlist = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_coupon where user_id = {$user_id} and order_id = " . $order_id); foreach ($couponlist as $k => $v) { $list[$k]['couponSn'] = $v['sn']; $list[$k]['couponPw'] = $v['password']; $list[$k]['qrcode'] = str_replace('sjmapi', '', get_domain() . gen_qrcode($v['password'])); } $root['couponlist'] = $couponlist; } $root['complain_status'] = 0; $complain = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal_order_complain WHERE order_id=" . $order_id . " AND user_id=" . $user_id); if (!empty($complain)) { $root['complain_status'] = 1; $root['complain_id'] = $complain['id']; } $order_item_info = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "deal_order_item WHERE order_id=" . $order_id . " "); $root['order_item_info'] = $order_item_info; } else { $root['return'] = 0; $root['info'] = "订单不存在."; } } else { $root['user_login_status'] = 0; } $root['pay_status'] = $order_info['pay_status']; $root['refund_status'] = $order_info['refund_status']; $root['page_title'] = '订单明细'; $root['city_name'] = $city_name; output($root); }
public function index() { $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); $root = array(); $root['return'] = 1; $root['first_calc'] = $GLOBALS['request']['first_calc']; if ($user_id > 0) { $root['user_login_status'] = 1; $region4_id = intval($GLOBALS['request']['region_lv4']); $region3_id = intval($GLOBALS['request']['region_lv3']); $region2_id = intval($GLOBALS['request']['region_lv2']); $region1_id = intval($GLOBALS['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; } require_once APP_ROOT_PATH . "system/libs/cart.php"; $order_id = intval($GLOBALS['request']['id']); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id); $root['order_parm'] = init_order_parm($GLOBALS['m_config']); //$delivery_id = $GLOBALS['m_config']['delivery_id']; $delivery_id = $GLOBALS['request']['delivery_id']; $payment_id = intval($GLOBALS['request']['payment_id']); $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id); $ids = array(); foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); } $ids_str = implode(",", $ids); $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } //开始计算订单 $GLOBALS['user_info']['id'] = $user_id; $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 1, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } else { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 0, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } $root['feeinfo'] = getFeeItem($data); $root['use_user_money'] = $data['account_money']; $root['pay_money'] = $data['pay_price']; $root['info'] = ''; //"订单已重新计算"; $root['status'] = 1; //end 计算订单 } else { $root['user_login_status'] = 0; $root['status'] = 0; } output($root); }
public function index() { $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); $root = array(); $root['return'] = 1; if ($user_id > 0) { $root['user_login_status'] = 1; $order_id = intval($GLOBALS['request']['id']); //echo $order_id; exit; $sql = "select o.*,r1.name as r1_name, r2.name as r2_name, r3.name as r3_name, r4.name as r4_name from " . DB_PREFIX . "deal_order as o " . "left outer join " . DB_PREFIX . "delivery_region as r1 on r1.id = o.region_lv1 " . "left outer join " . DB_PREFIX . "delivery_region as r2 on r2.id = o.region_lv2 " . "left outer join " . DB_PREFIX . "delivery_region as r3 on r3.id = o.region_lv3 " . "left outer join " . DB_PREFIX . "delivery_region as r4 on r4.id = o.region_lv4 " . " where o.is_delete = 0 and o.user_id = {$user_id} and o.id = {$order_id} limit 1"; $order_info = $GLOBALS['db']->getRow($sql); if ($order_info) { $root = get_order_goods($order_info); $root['return'] = 1; $root['user_login_status'] = 1; $deliveryAddr = array(); $deliveryAddr['consignee'] = $order_info['consignee']; //联系人姓名 $deliveryAddr['delivery'] = $order_info['r1_name'] . $order_info['r2_name'] . $order_info['r3_name'] . $order_info['r4_name']; $deliveryAddr['region_lv1'] = $order_info['region_lv1']; //国家 $deliveryAddr['region_lv2'] = $order_info['region_lv2']; //省 $deliveryAddr['region_lv3'] = $order_info['region_lv3']; //城市 $deliveryAddr['region_lv4'] = $order_info['region_lv4']; //地区/县 $deliveryAddr['delivery_detail'] = $order_info['address']; //详细地址 $deliveryAddr['phone'] = $order_info['mobile']; //手机号码 $deliveryAddr['postcode'] = $order_info['zip']; //邮编 $root['deliveryAddr'] = $deliveryAddr; $root['content'] = $order_info['memo']; //订单备注 $root['send_mobile'] = $user['mobile']; //团购券手机 $root['tax_title'] = $item['tax_title']; //发票抬头 $root['tax_id'] = 0; //发票内容 $root['deliver_time_id'] = 0; //配送日期ID 默认没有这个参数,所以填0 //$default_payment_id = $GLOBALS['m_config']['select_payment_id']; $default_payment_id = $order_info['payment_id']; $root['payment_id'] = $default_payment_id; //支付方式 $root['order_parm'] = init_order_parm($GLOBALS['m_config']); $root['order_parm']['has_ecv'] = 0; //订单付款不支持代金券 $root['evc_sn'] = ''; //优惠券序号 $root['evc_pwd'] = ''; //优惠券序号 $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id); $ids = array(); $cart_ids = array(); foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); array_push($cart_ids, $cart_goods['id']); } $ids_str = implode(",", $ids); $cart_ids_str = implode(",", $cart_ids); $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if ($is_delivery == 0) { $delivery_id = 0; $root['order_parm']['has_delivery'] = 0; } else { $delivery_id = $order_info['delivery_id']; $root['order_parm']['has_delivery'] = 1; } $root['delivery_id'] = $delivery_id; //配送方式 $has_coupon = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_coupon = 1 and id in (" . $ids_str . ")")); if (!$has_coupon) { $root['order_parm']['has_moblie'] = 0; } else { $root['order_parm']['has_moblie'] = 1; } $root['order_parm']['has_mcod'] = 1; $forbid_payment = $GLOBALS['db']->getAll("select payment_id from " . DB_PREFIX . "deal_payment where deal_id in (" . $ids_str . ")"); foreach ($forbid_payment as $forbid_payment_item) { foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['payment_id']) { unset($root['order_parm']['payment_list'][$k]); } } } $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } $region4_id = intval($order_info['region_lv4']); $region3_id = intval($order_info['region_lv3']); $region2_id = intval($order_info['region_lv2']); $region1_id = intval($order_info['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; } require_once APP_ROOT_PATH . "system/libs/cart.php"; //订单的显示参数 if ($order_info['pay_status'] == 0) { $root['has_cancel'] = 1; } else { $root['has_cancel'] = 0; } $delivery_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "delivery_notice where order_item_id in (" . $cart_ids_str . ") order by delivery_time desc limit 1"); if ($delivery_notice) { $express = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "express where id = " . intval($delivery_notice['express_id'])); $express['config'] = unserialize($express['config']); $root['kd_com'] = $express['config']['app_code']; if ($root['kd_com']) { $root['kd_sn'] = $delivery_notice['notice_sn']; } } if ($order_info['pay_status'] != 2) { $root['has_edit_delivery'] = 1; $root['has_edit_delivery_time'] = 0; $root['has_edit_invoice'] = 0; $root['has_edit_ecv'] = 0; $root['has_edit_message'] = 1; $root['has_edit_moblie'] = 1; $GLOBALS['user_info']['id'] = $user_id; $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $default_payment_id, $account_money = 0, $all_account_money = 1, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } else { $data = count_buy_total($region_id, $delivery_id, $default_payment_id, $account_money = 0, $all_account_money = 0, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } //print_r($data);exit; if ($data['pay_price'] == 0) { if ($data['account_money'] > 0 || $data['ecv_money'] > 0) { $root['has_pay'] = 1; $root['use_user_money'] = $data['account_price']; } else { $root['has_pay'] = 0; $root['use_user_money'] = 0; } $root['pay_money'] = 0; //还需要支付金额 } else { $root['has_pay'] = 1; $root['pay_money'] = $data['pay_price']; //还需要支付金额 $root['use_user_money'] = 0; } $root['feeinfo'] = getFeeItem($data); } else { $root['has_pay'] = 0; $root['has_edit_delivery'] = 0; $root['has_edit_delivery_time'] = 0; $root['has_edit_invoice'] = 0; $root['has_edit_ecv'] = 0; $root['has_edit_message'] = 0; $root['has_edit_moblie'] = 0; $data['pay_total_price'] = $order_info['total_price']; $data['return_total_score'] = $order_info['return_total_score']; $data['total_price'] = $order_info['deal_total_price']; $data['delivery_fee'] = $order_info['delivery_fee']; $data['account_money'] = $order_info['account_money']; $data['ecv_money'] = $order_info['ecv_money']; $root['pay_money'] = 0; //还需要支付金额 $root['use_user_money'] = 0; $root['feeinfo'] = getFeeItem($data); } } else { $root['return'] = 0; $root['info'] = "订单不存在."; } } else { $root['user_login_status'] = 0; } output($root); }
public function index() { $root = array(); $mobile = trim($GLOBALS['request']['mobile']); $code = strim($GLOBALS['request']['code']); /*验证码*/ $ref_uid = intval($GLOBALS['request']['ref_uid']); /*邀请id*/ $city_name = strim($GLOBALS['request']['city_name']); //城市名称 if (!empty($mobile)) { if (!check_mobile($mobile)) { $root['status'] = 2; $root['info'] = "请输入正确的手机号码"; output($root); } //print_r($GLOBALS['request']); if ($code == '') { $root['info'] = "请输入验证码!"; $root['status'] = 2; output($root); } $db_code = $GLOBALS['db']->getRow("select id,code,add_time from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = '{$mobile}' order by id desc"); //print_r($db_code['code']); //$root['code']="select id,code,add_time from ".DB_PREFIX."sms_mobile_verify where status=0 and mobile_phone = '$mobile' and type=0 order by id desc"; if ($db_code['code'] != $code) { $root['info'] = "请输入正确的验证码!"; $root['status'] = 2; output($root); } $new_time = get_gmtime(); if ($new_time - $db_code['add_time'] > 60 * 30) { $root['info'] = "验证码已失效,请重新获取!"; $root['status'] = 2; $GLOBALS['db']->query("delete from " . DB_PREFIX . "sms_mobile_verify where mobile_phone = " . $mobile . ""); output($root); } //$GLOBALS['db']->query("update ".DB_PREFIX."sms_mobile_verify set status = 1 where id=".$db_code['id'].""); $GLOBALS['db']->query("delete from " . DB_PREFIX . "sms_mobile_verify where id=" . $db_code['id'] . ""); $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where mobile = '{$mobile}'"); require_once APP_ROOT_PATH . "/system/model/user.php"; if (!$user_data) { //自动注册一个用户; $pwd = rand(1111, 9999); $pwd = md5($pwd); $user_data = mobile_reg($mobile, $pwd, $ref_uid); } else { $mobile = $user_data['mobile']; $pwd = $user_data['user_pwd']; } //检查用户,用户密码 auto_do_login_user($mobile, $pwd, false); $user = $GLOBALS['user_info']; $user_id = intval($user['id']); if ($user_id > 0) { $root['mobile_user_id'] = $user_id; $root['mobile_user_name'] = $user['user_name']; $root['mobile_user_pwd'] = $user['user_pwd']; } else { $root['info'] = "用户登陆失败!"; $root['status'] = 2; } } else { //检查用户,用户密码 $user = $GLOBALS['user_info']; $user_id = intval($user['id']); } $root['return'] = 1; $root['first_calc'] = $GLOBALS['request']['first_calc']; if ($user_id > 0) { //用户登陆状态:1:成功登陆;0:未成功登陆 $root['user_login_status'] = 1; //第一次计算,主要是处理一些初始化参数,比如:默认配送地址 if ($GLOBALS['request']['first_calc'] == 1) { $delivery = getUserAddr($user_id, false, 1); $root['delivery'] = $delivery; $delivery_region = array('region_lv1' => intval($delivery['region_lv1']), 'region_lv2' => intval($delivery['region_lv2']), 'region_lv3' => intval($delivery['region_lv3']), 'region_lv4' => intval($delivery['region_lv4'])); $root['send_mobile'] = $user['mobile']; //默认填上用户手机号码 $payment_id = intval($GLOBALS['m_config']['select_payment_id']); //默认支付方式 //$payment_id = intval($root['order_parm']['select_payment_id']);//默认支付方式 $delivery_id = intval($GLOBALS['m_config']['delivery_id']); //配送方式; } else { $delivery_region = array('region_lv1' => intval($GLOBALS['request']['region_lv1']), 'region_lv2' => intval($GLOBALS['request']['region_lv2']), 'region_lv3' => intval($GLOBALS['request']['region_lv3']), 'region_lv4' => intval($GLOBALS['request']['region_lv4'])); if ($GLOBALS['request']['payment_id']) { $payment_id = intval($GLOBALS['request']['payment_id']); } else { $payment_id = intval($GLOBALS['m_config']['select_payment_id']); //默认支付方式 } if ($GLOBALS['request']['delivery_id']) { $delivery_id = intval($GLOBALS['request']['delivery_id']); } else { $delivery_id = intval($GLOBALS['m_config']['delivery_id']); //配送方式; } } if ($GLOBALS['request']['from'] == "wap") { //用户信息 $cartdata = unserialize(base64_decode($GLOBALS['request']['cartdata'])); $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); $root['user_info'] = $user_info; $root['delivery_list'] = $GLOBALS['m_config']['delivery_list']; //商品信息 $res = insertCartData($user_id, es_session::id(), $cartdata); $cart_info = $res['data']; foreach ($cart_info as $k => $v) { //查询数据库,获取商品信息 $deal = $GLOBALS['db']->getRow("select img,max_bought from " . DB_PREFIX . "deal where id=" . $v['deal_id']); //单价*数量=总价 $cart_info[$k]['current_price_format'] = format_price($v['unit_price']); $cart_info[$k]['img'] = get_abs_img_root($deal['img']); $cart_info[$k]['max_bought'] = $deal['max_bought']; $cart_info[$k]['current_price'] = round($v['unit_price'], 2); $cart_info[$k]['tech_id'] = $v['tech_id']; $tech_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $v['tech_id']); $cart_info[$k]['tech_name'] = $tech_info['user_name']; } $root['cartinfo'] = $cart_info; } else { $cartdata = $GLOBALS['request']['cartdata']; $res = insertCartData($user_id, es_session::id(), $cartdata); } if ($res['info'] != '') { //不可购买 $root['info'] = $res['info']; $root['status'] = 0; } else { //可以购买 $root['status'] = 1; //$delivery_id = intval($requestData['delivery_id']);//配送方式; if ($delivery_id == 0) { $delivery_id = intval($GLOBALS['m_config']['delivery_id']); } //取系统配置 $root['select_delivery_id'] = $delivery_id; $ecvSn = strim($GLOBALS['request']['ecv_sn']); //优惠券 $ecvPassword = strim($GLOBALS['request']['ecv_pwd']); //优惠券密码 require_once APP_ROOT_PATH . "system/model/cart.php"; $region4_id = intval($delivery_region['region_lv4']); $region3_id = intval($delivery_region['region_lv3']); $region2_id = intval($delivery_region['region_lv2']); $region1_id = intval($delivery_region['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; } $goods_list = $res['data']; $GLOBALS['user_info']['id'] = $user_id; $ids = array(); foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); } $ids_str = implode(",", $ids); $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if ($is_delivery == 0) { $delivery_id = 0; } $root['is_delivery'] = $is_delivery; $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $payment_id, 0, 1, $ecvSn, $ecvPassword, $goods_list); } else { $data = count_buy_total($region_id, $delivery_id, $payment_id, 0, 0, $ecvSn, $ecvPassword, $goods_list); } $root['use_user_money'] = floatval($data['account_money']); //使用会员余额支付金额 $root['pay_money'] = $data['pay_price']; //还需要支付金额 $root['feeinfo'] = getFeeItem($data); $root['order_parm'] = init_order_parm($GLOBALS['m_config']); $root['order_parm']['delivery_id'] = $delivery_id; $root['order_parm']['payment_id'] = $payment_id; $ecv_payment_id = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'")); //重新为order_parm赋值 if ($ecv_payment_id) { $forbid_ecv = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where payment_id =" . $ecv_payment_id . " and deal_id in (" . $ids_str . ")"); if ($forbid_ecv) { $root['order_parm']['has_ecv'] = 0; } //无优惠券 } else { $root['order_parm']['has_ecv'] = 0; } //无优惠券 $has_coupon = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_coupon = 1 and id in (" . $ids_str . ")")); if ($has_coupon == 0) { $root['order_parm']['has_moblie'] = 0; $root['order_parm']['has_mcod'] = 1; } else { $root['order_parm']['has_moblie'] = 1; $root['order_parm']['has_mcod'] = 0; //有团购券商品,不能做:货到付款 } //下单时需要绑定手机号码 if (intval($GLOBALS['m_config']['order_has_bind_mobile']) == 1) { //前面已经绑定手机号码了,这时不能再修改手机号码 $root['order_parm']['has_moblie'] = 0; } foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['code'] == 'Mcod' && $root['order_parm']['has_mcod'] == 0) { unset($root['order_parm']['payment_list'][$k]); } } $has_delivery = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if (!$has_delivery) { $root['order_parm']['has_delivery'] = 0; } else { $root['order_parm']['has_delivery'] = 1; } //$root['order_parm']['has_mcod'] = 1; $forbid_payment = $GLOBALS['db']->getAll("select payment_id from " . DB_PREFIX . "deal_payment where deal_id in (" . $ids_str . ")"); foreach ($forbid_payment as $forbid_payment_item) { foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['payment_id']) { unset($root['order_parm']['payment_list'][$k]); } } } $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } //数组按顺序排序 $payment_list = array(); foreach ($root['order_parm']['payment_list'] as $k => $v) { $payment_list[] = $v; } $root['order_parm']['payment_list'] = $payment_list; $delivery_list = array(); foreach ($root['order_parm']['delivery_list'] as $k => $v) { $delivery_list[] = $v; } $root['order_parm']['delivery_list'] = $delivery_list; //has_delivery_list //$root['order_parm']['delivery_list'] = $GLOBALS['db']->getAll("select id,name from ".DB_PREFIX."delivery"); } } else { //未登录 $root['user_login_status'] = 0; } $root['page_title'] = '确认订单'; $root['city_name'] = $city_name; output($root); }
public function index() { //检查用户,用户密码 $user = $GLOBALS['user_info']; $user_id = intval($user['id']); $root = array(); $root['return'] = 1; $root['first_calc'] = $GLOBALS['request']['first_calc']; if ($user_id > 0) { $root['user_login_status'] = 1; $region4_id = intval($GLOBALS['request']['region_lv4']); $region3_id = intval($GLOBALS['request']['region_lv3']); $region2_id = intval($GLOBALS['request']['region_lv2']); $region1_id = intval($GLOBALS['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; } require_once APP_ROOT_PATH . "system/model/cart.php"; $order_id = intval($GLOBALS['request']['id']); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id); $root['order_parm'] = init_order_parm($GLOBALS['m_config']); //$delivery_id = $GLOBALS['m_config']['delivery_id']; $delivery_id = $GLOBALS['request']['delivery_id']; $payment_id = intval($GLOBALS['request']['payment_id']); $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id); $ids = array(); foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); } $ids_str = implode(",", $ids); $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_delivery_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } $has_coupon = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_coupon = 1 and id in (" . $ids_str . ")")); if ($has_coupon == 0) { $root['order_parm']['has_moblie'] = 0; $root['order_parm']['has_mcod'] = 1; } else { $root['order_parm']['has_moblie'] = 1; $root['order_parm']['has_mcod'] = 0; //有团购券商品,不能做:货到付款 } //下单时需要绑定手机号码 if (intval($GLOBALS['m_config']['order_has_bind_mobile']) == 1) { //前面已经绑定手机号码了,这时不能再修改手机号码 $root['order_parm']['has_moblie'] = 0; } foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['code'] == 'Mcod' && $root['order_parm']['has_mcod'] == 0) { unset($root['order_parm']['payment_list'][$k]); } } $has_delivery = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if (!$has_delivery) { $root['order_parm']['has_delivery'] = 0; } else { $root['order_parm']['has_delivery'] = 1; } $forbid_payment = $GLOBALS['db']->getAll("select payment_id from " . DB_PREFIX . "deal_payment where deal_id in (" . $ids_str . ")"); foreach ($forbid_payment as $forbid_payment_item) { foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['payment_id']) { unset($root['order_parm']['payment_list'][$k]); } } } //数组按顺序排序 $payment_list = array(); foreach ($root['order_parm']['payment_list'] as $k => $v) { $payment_list[] = $v; } $root['order_parm']['payment_list'] = $payment_list; $delivery_list = array(); foreach ($root['order_parm']['delivery_list'] as $k => $v) { $delivery_list[] = $v; } $root['order_parm']['delivery_list'] = $delivery_list; //开始计算订单 $GLOBALS['user_info']['id'] = $user_id; $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 1, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } else { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 0, '', '', $goods_list, $order_info['account_money'], $order_info['ecv_money']); } $root['feeinfo'] = getFeeItem($data); $root['use_user_money'] = $data['account_money']; $root['pay_money'] = $data['pay_price']; $root['info'] = ''; //"订单已重新计算"; $root['status'] = 1; //end 计算订单 } else { $root['user_login_status'] = 0; $root['status'] = 0; } output($root); }
public function index() { $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); //print_r($user); exit; $cartdata = $GLOBALS['request']['cartdata']; $root = array(); $root['return'] = 1; $root['first_calc'] = $GLOBALS['request']['first_calc']; if ($user_id > 0) { //用户登陆状态:1:成功登陆;0:未成功登陆 $root['user_login_status'] = 1; //第一次计算,主要是处理一些初始化参数,比如:默认配送地址 if ($GLOBALS['request']['first_calc'] == 1) { $delivery = getUserAddr($user_id, false); $root['delivery'] = $delivery; $delivery_region = array('region_lv1' => intval($delivery['region_lv1']), 'region_lv2' => intval($delivery['region_lv2']), 'region_lv3' => intval($delivery['region_lv3']), 'region_lv4' => intval($delivery['region_lv4'])); $root['send_mobile'] = $user['mobile']; //默认填上用户手机号码 $payment_id = intval($root['order_parm']['select_payment_id']); //默认支付方式 } else { $delivery_region = array('region_lv1' => intval($GLOBALS['request']['region_lv1']), 'region_lv2' => intval($GLOBALS['request']['region_lv2']), 'region_lv3' => intval($GLOBALS['request']['region_lv3']), 'region_lv4' => intval($GLOBALS['request']['region_lv4'])); $payment_id = intval($GLOBALS['request']['payment_id']); } $res = insertCartData($user_id, session_id(), $cartdata); if ($res['info'] != '') { //不可购买 $root['info'] = $res['info']; $root['status'] = 0; } else { //可以购买 $root['status'] = 1; $delivery_id = intval($requestData['delivery_id']); //配送方式; if ($delivery_id == 0) { $delivery_id = intval($GLOBALS['m_config']['delivery_id']); } //取系统配置 $root['select_delivery_id'] = $delivery_id; $ecvSn = strim($GLOBALS['request']['ecv_sn']); //优惠券 $ecvPassword = strim($GLOBALS['request']['ecv_pwd']); //优惠券密码 require_once APP_ROOT_PATH . "system/libs/cart.php"; $region4_id = intval($delivery_region['region_lv4']); $region3_id = intval($delivery_region['region_lv3']); $region2_id = intval($delivery_region['region_lv2']); $region1_id = intval($delivery_region['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; } $goods_list = $res['data']; $GLOBALS['user_info']['id'] = $user_id; $ids = array(); foreach ($goods_list as $cart_goods) { array_push($ids, $cart_goods['deal_id']); } $ids_str = implode(",", $ids); $is_delivery = intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if ($is_delivery == 0) { $delivery_id = 0; } $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'"); if ($account_pay) { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 1, $ecvSn, $ecvPassword, $goods_list); } else { $data = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 0, $ecvSn, $ecvPassword, $goods_list); } $root['use_user_money'] = floatval($data['account_money']); //使用会员余额支付金额 $root['pay_money'] = $data['pay_price']; //还需要支付金额 $root['feeinfo'] = getFeeItem($data); $root['order_parm'] = init_order_parm($GLOBALS['m_config']); $ecv_payment_id = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "payment where class_name = 'Voucher'")); //重新为order_parm赋值 if ($ecv_payment_id) { $forbid_ecv = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_payment where payment_id =" . $ecv_payment_id . " and deal_id in (" . $ids_str . ")"); if ($forbid_ecv) { $root['order_parm']['has_ecv'] = 0; } //无优惠券 } else { $root['order_parm']['has_ecv'] = 0; } //无优惠券 $has_coupon = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_coupon = 1 and id in (" . $ids_str . ")")); if (!$has_coupon) { $root['order_parm']['has_moblie'] = 0; } else { $root['order_parm']['has_moblie'] = 1; } $has_delivery = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where is_delivery = 1 and id in (" . $ids_str . ")")); if (!$has_delivery) { $root['order_parm']['has_delivery'] = 0; } else { $root['order_parm']['has_delivery'] = 1; } $root['order_parm']['has_mcod'] = 1; $forbid_payment = $GLOBALS['db']->getAll("select payment_id from " . DB_PREFIX . "deal_payment where deal_id in (" . $ids_str . ")"); foreach ($forbid_payment as $forbid_payment_item) { foreach ($root['order_parm']['payment_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['payment_id']) { unset($root['order_parm']['payment_list'][$k]); } } } $forbid_delivery = $GLOBALS['db']->getAll("select delivery_id from " . DB_PREFIX . "deal_delivery where deal_id in (" . $ids_str . ")"); foreach ($forbid_delivery as $forbid_delivery_item) { foreach ($root['order_parm']['delivery_list'] as $k => $v) { if ($v['id'] == $forbid_payment_item['delivery_id']) { unset($root['order_parm']['delivery_list'][$k]); } } } //has_delivery_list //$root['order_parm']['delivery_list'] = $GLOBALS['db']->getAll("select id,name from ".DB_PREFIX."delivery"); } } else { //未登录 $root['user_login_status'] = 0; } output($root); }