public function go_pay()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url_wap("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $paypassword = strim($_REQUEST['paypassword']);
     if ($paypassword == '') {
         showErr("请输入支付密码", 0);
     }
     if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) {
         showErr("支付密码错误", 0);
     }
     $consignee_id = intval($_REQUEST['consignee_id']);
     $credit = floatval($_REQUEST['credit']);
     $pay_score = intval($_REQUEST['pay_score']);
     if ($pay_score > 0) {
         $score_array = score_to_money($pay_score);
         $pay_score_money = $score_array['score_money'];
         $pay_score = $score_array['score'];
     } else {
         $pay_score = 0;
         $pay_score_money = 0;
     }
     $is_tg = intval($_REQUEST['is_tg']);
     if ($is_tg) {
         if (!$GLOBALS['is_user_tg']) {
             $jump_url = get_domain() . APP_ROOT . "/wap/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $GLOBALS['user_info']['id'];
             //$jump_url = get_domain().url_wap("collocation#CreateNewAcct",array('user_type'=>0,'user_id'=>$GLOBALS['user_info']['id']));
             showErr("您未绑定第三方接口无法支付,点击确定后跳转到绑定页面", 0, $jump_url);
         }
     }
     $memo = strim($_REQUEST['memo']);
     $payment_id = intval($_REQUEST['payment']);
     $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $id);
     if (!$deal_item) {
         app_redirect(url_wap("index"));
     } elseif ($deal_item['support_count'] >= $deal_item['limit_user'] && $deal_item['limit_user'] != 0) {
         app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id'])));
     }
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $deal_item['deal_id']);
     if (!$deal_info) {
         app_redirect(url_wap("index"));
     } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) {
         app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id'])));
     }
     if (intval($consignee_id) == 0 && $deal_item['is_delivery'] == 1) {
         showErr("请选择配送方式", 0, get_gopreview_wap());
     }
     //无私奉献
     if ($deal_item['type'] == 1) {
         $pay_money = floatval($_REQUEST['pay_money']);
         if ($pay_money <= 0) {
             showErr("您输入的金额错误", 0, url_wap("deal#show", array("id" => $deal_item['deal_id'])));
         }
         $deal_item['price'] = $pay_money;
         $order_info['type'] = 2;
     } else {
         $order_info['type'] = $deal_info['type'];
     }
     $order_info['deal_id'] = $deal_info['id'];
     $order_info['deal_item_id'] = $deal_item['id'];
     $order_info['user_id'] = intval($GLOBALS['user_info']['id']);
     $order_info['user_name'] = $GLOBALS['user_info']['user_name'];
     $order_info['total_price'] = $deal_item['price'] + $deal_item['delivery_fee'];
     $order_info['delivery_fee'] = $deal_item['delivery_fee'];
     $order_info['deal_price'] = $deal_item['price'];
     $order_info['support_memo'] = $memo;
     $order_info['payment_id'] = $payment_id;
     $order_info['bank_id'] = strim($_REQUEST['bank_id']);
     if ($deal_item['is_share'] == 1) {
         $order_info['share_fee'] = $deal_item['share_fee'];
         $order_info['share_status'] = 0;
     } else {
         $order_info['share_fee'] = 0;
     }
     /*
     $max_credit= $order_info['total_price']<$GLOBALS['user_info']['money']?$order_info['total_price']:$GLOBALS['user_info']['money'];
     $credit = $credit>$max_credit?$max_credit:$credit;
     */
     if (!$is_tg) {
         $credit_score_money = $pay_score_money + $credit;
         if ($credit > $GLOBALS['user_info']['money']) {
             showErr("余额最多只能用" . format_price($GLOBALS['user_info']['money']), 0);
         }
         if ($pay_score > $GLOBALS['user_info']['score']) {
             showErr("积分最多只能用" . $GLOBALS['user_info']['score']);
         }
         if ($credit_score_money > $order_info['total_price']) {
             showErr("支付超出");
         }
         if (intval(($order_info['total_price'] - $credit_score_money) * 100) > 0 && $payment_id == 0) {
             showErr("请选择支付方式");
         }
     }
     if ($credit > 0 && $GLOBALS['user_info']['money'] >= $credit) {
         $order_info['credit_pay'] = $credit;
     }
     if ($pay_score > 0 && $GLOBALS['user_info']['score'] >= $pay_score) {
         $order_info['score'] = $pay_score;
         $order_info['score_money'] = $pay_score_money;
     }
     //		$order_info['credit_pay'] = $credit;
     $order_info['online_pay'] = 0;
     $order_info['deal_name'] = $deal_info['name'];
     $order_info['order_status'] = 0;
     $order_info['create_time'] = NOW_TIME;
     if ($consignee_id > 0) {
         $consignee_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id = " . $consignee_id . " and user_id = " . intval($GLOBALS['user_info']['id']));
         if (!$consignee_info && $deal_item['is_delivery'] == 1) {
             showErr("请选择配送方式", 0, get_gopreview_wap());
         }
         $order_info['consignee'] = $consignee_info['consignee'];
         $order_info['zip'] = $consignee_info['zip'];
         $order_info['address'] = $consignee_info['address'];
         $order_info['province'] = $consignee_info['province'];
         $order_info['city'] = $consignee_info['city'];
         $order_info['mobile'] = $consignee_info['mobile'];
     }
     $order_info['is_success'] = $deal_info['is_success'];
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info);
     $order_id = $GLOBALS['db']->insert_id();
     if ($order_id > 0) {
         //			if($order_info['credit_pay']>0)
         //			{
         //				require_once APP_ROOT_PATH."system/libs/user.php";
         //				modify_account(array("money"=>"-".$order_info['credit_pay']),intval($GLOBALS['user_info']['id']),"支持".$order_info['deal_name']."项目支付");
         //			}
         $result = pay_order($order_id);
         if ($result['status'] == 0) {
             if ($is_tg) {
                 $sign = md5(md5($paypassword) . $order_id);
                 $url = get_domain() . APP_ROOT . "/wap/index.php?ctl=collocation&act=RegisterCreditor&order_id=" . $order_id . "&sign=" . $sign;
                 //showSuccess("",0,$url);
                 app_redirect($url);
             } else {
                 $money = $result['money'];
                 $payment_notice['create_time'] = NOW_TIME;
                 $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
                 $payment_notice['payment_id'] = $order_info['payment_id'];
                 $payment_notice['money'] = $money;
                 $payment_notice['order_id'] = $order_id;
                 $payment_notice['memo'] = $order_info['memo'];
                 $payment_notice['deal_id'] = $order_info['deal_id'];
                 $payment_notice['deal_item_id'] = $order_info['deal_item_id'];
                 $payment_notice['deal_name'] = $order_info['deal_name'];
                 do {
                     $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymdhi") . rand(10000, 99999);
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                     $notice_id = $GLOBALS['db']->insert_id();
                 } while ($notice_id == 0);
                 app_redirect(url_wap("cart#jump", array("id" => $notice_id)));
             }
         } elseif ($result['status'] == 1) {
             $data['pay_status'] = 0;
             $data['pay_info'] = '订单过期.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         } elseif ($result['status'] == 2) {
             $data['pay_status'] = 0;
             $data['pay_info'] = '订单无库存.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         } else {
             $data['pay_status'] = 1;
             $data['pay_info'] = '订单支付成功.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         }
         //app_redirect(url_wap("cart#pay_order",array("order_id"=>$order_id)));
     } else {
         showErr("下单失败", 0, get_gopreview_wap());
     }
 }
 public function verify()
 {
     $id = intval($_REQUEST['id']);
     $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $id);
     if (!$user_info) {
         showErr("没有该会员");
     }
     $verify = addslashes(trim($_REQUEST['code']));
     if ($user_info['verify'] != '' && $user_info['verify'] == $verify) {
         //成功
         //			send_register_success(0,$user_info);
         es_session::set("user_info", $user_info);
         $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . ",verify = '',is_effect = 1 where id =" . $user_info['id']);
         $GLOBALS['db']->query("update " . DB_PREFIX . "mail_list set is_effect = 1 where mail_address ='" . $user_info['email'] . "'");
         showSuccess("验证成功", 0, get_gopreview_wap());
     } elseif ($user_info['verify'] == '') {
         showErr("已验证过", 0, get_gopreview_wap());
     } else {
         showErr("验证失败", 0, get_gopreview_wap());
     }
 }
 public function del()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!$GLOBALS['user_info']) {
         showErr("", $ajax, url_wap("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal where id = " . $id . " and is_edit = 1 and user_id = " . intval($GLOBALS['user_info']['id'] . " and is_effect = 0 and is_delete = 0"));
     if ($GLOBALS['db']->affected_rows() > 0) {
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_item where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_item_image where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_comment where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_faq where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_focus_log where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_log where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_pay_log where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_support_log where deal_id = " . $id);
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_visit_log where deal_id = " . $id);
         showSuccess("", $ajax, get_gopreview_wap());
     } else {
         showErr("删除失败", $ajax);
     }
 }
Beispiel #4
0
 public function submitrefund()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!$GLOBALS['user_info']) {
         showErr("", $ajax, url_wap("user#login"));
     }
     $money = doubleval($_REQUEST['money']);
     $memo = strim($_REQUEST['memo']);
     if ($money <= 0) {
         showErr("提现金额出错", $ajax);
     }
     $ready_refund_money = doubleval($GLOBALS['db']->getOne("select sum(money) from " . DB_PREFIX . "user_refund where user_id = " . intval($GLOBALS['user_info']['id']) . " and is_pay = 0"));
     if ($ready_refund_money + $money > $GLOBALS['user_info']['money']) {
         showErr("提现超出限制", $ajax);
     }
     $refund_data['money'] = $money;
     $refund_data['user_id'] = $GLOBALS['user_info']['id'];
     $refund_data['create_time'] = NOW_TIME;
     $refund_data['memo'] = $memo;
     $GLOBALS['db']->autoExecute(DB_PREFIX . "user_refund", $refund_data);
     showSuccess("提交成功", $ajax, get_gopreview_wap());
 }
Beispiel #5
0
 public function save_consignee()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!$GLOBALS['user_info']) {
         app_redirect(url_wap("user#login"));
     }
     if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . intval($GLOBALS['user_info']['id'])) > 10) {
         showErr("每个会员只能预设10个配送地址", $ajax, "");
     }
     $id = intval($_REQUEST['id']);
     $consignee = strim($_REQUEST['consignee']);
     $province = strim($_REQUEST['province']);
     $city = strim($_REQUEST['city']);
     $address = strim($_REQUEST['address']);
     $zip = strim($_REQUEST['zip']);
     $mobile = strim($_REQUEST['mobile']);
     if ($consignee == "") {
         showErr("请填写收货人姓名", $ajax, "");
     }
     if ($province == "") {
         showErr("请选择省份", $ajax, "");
     }
     if ($city == "") {
         showErr("请选择城市", $ajax, "");
     }
     if ($address == "") {
         showErr("请填写详细地址", $ajax, "");
     }
     if (!check_postcode($zip)) {
         showErr("请填写正确的邮编", $ajax, "");
     }
     if ($mobile == "") {
         showErr("请填写收货人手机号码", $ajax, "");
     }
     if (!check_mobile($mobile)) {
         showErr("请填写正确的手机号码", $ajax, "");
     }
     $data = array();
     $data['consignee'] = $consignee;
     $data['province'] = $province;
     $data['city'] = $city;
     $data['address'] = $address;
     $data['zip'] = $zip;
     $data['mobile'] = $mobile;
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     if (!check_ipop_limit(get_client_ip(), "setting_save_consignee", 5)) {
         showErr("提交太频繁", $ajax, "");
         exit;
     }
     if ($id > 0) {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data, "UPDATE", "id=" . $id);
     } else {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data);
     }
     showSuccess("保存成功", $ajax, get_gopreview_wap());
     //$res = save_user($user_data);
 }
Beispiel #6
0
 public function go_pay()
 {
     if (es_session::get("confirm") == $_REQUEST['t']) {
         app_redirect(url_wap("index"));
         //支付过期时跳转回首页
         //            echo '网页过期';
         exit;
     }
     if (!$GLOBALS['user_info']) {
         app_redirect(url_wap("user#login"));
     }
     $isap = $_REQUEST['isap'];
     $id = intval($_REQUEST['id']);
     $is_address = intval($_REQUEST['is_address']);
     $consignee_id = intval($_REQUEST['consignee_id']);
     if ($is_address == 1) {
         if (empty($consignee_id)) {
             $consignee = strim($_REQUEST['consignee']);
             $province = strim($_REQUEST['province']);
             $city = strim($_REQUEST['city']);
             $address = strim($_REQUEST['address']);
             $zip = strim($_REQUEST['zip']);
             $mobile = strim($_REQUEST['mobile']);
             $data = array();
             $data['consignee'] = $consignee;
             $data['province'] = $province;
             $data['city'] = $city;
             $data['address'] = $address;
             $data['zip'] = $zip;
             $data['mobile'] = $mobile;
             $data['user_id'] = intval($GLOBALS['user_info']['id']);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data);
             $consignee_id = $GLOBALS['db']->insert_id();
         }
     }
     $credit = doubleval($_REQUEST['credit']);
     $memo = strim($_REQUEST['memo']);
     $payment_id = intval($_REQUEST['payment_id']);
     $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $id);
     if (!$deal_item) {
         app_redirect(url_wap("index"));
     } elseif ($deal_item['support_count'] >= $deal_item['limit_user'] && $deal_item['limit_user'] != 0) {
         app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id'])));
     }
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $deal_item['deal_id']);
     if (!$deal_info) {
         app_redirect(url_wap("index"));
     } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) {
         app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id'])));
     }
     if (intval($consignee_id) == 0 && $deal_item['is_delivery'] == 1) {
         showErr("请选择配送方式", 0, get_gopreview_wap());
     }
     $order_info['deal_id'] = $deal_info['id'];
     $order_info['deal_item_id'] = $deal_item['id'];
     $order_info['user_id'] = intval($GLOBALS['user_info']['id']);
     $order_info['user_name'] = $GLOBALS['user_info']['user_name'];
     $order_info['total_price'] = $deal_item['price'] + $deal_item['delivery_fee'];
     $order_info['delivery_fee'] = $deal_item['delivery_fee'];
     $order_info['deal_price'] = $deal_item['price'];
     $order_info['support_memo'] = $memo;
     $order_info['payment_id'] = $payment_id;
     $order_info['bank_id'] = strim($_REQUEST['bank_id']);
     //积分商城项目增加积分方和积分兑换率
     if ($isap == "1") {
         $order_info['is_ap'] = $isap;
         $order_info['ap_partner_id'] = 2;
         $order_info['ap_ratio'] = $deal_item['ap_ratio'];
     }
     $max_credit = $order_info['total_price'] < $GLOBALS['user_info']['money'] ? $order_info['total_price'] : $GLOBALS['user_info']['money'];
     $credit = $credit > $max_credit ? $max_credit : $credit;
     $order_info['credit_pay'] = $credit;
     $order_info['online_pay'] = 0;
     $order_info['deal_name'] = $deal_info['name'];
     $order_info['order_status'] = 0;
     $order_info['create_time'] = NOW_TIME;
     if ($consignee_id > 0) {
         $consignee_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id = " . $consignee_id . " and user_id = " . intval($GLOBALS['user_info']['id']));
         if (!$consignee_info && $deal_item['is_delivery'] == 1) {
             showErr("请选择配送方式", 0, get_gopreview_wap());
         }
         $order_info['consignee'] = $consignee_info['consignee'];
         $order_info['zip'] = $consignee_info['zip'];
         $order_info['address'] = $consignee_info['address'];
         $order_info['province'] = $consignee_info['province'];
         $order_info['city'] = $consignee_info['city'];
         $order_info['mobile'] = $consignee_info['mobile'];
     }
     $order_info['is_success'] = $deal_info['is_success'];
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info);
     $order_id = $GLOBALS['db']->insert_id();
     if ($order_id > 0) {
         if ($order_info['credit_pay'] > 0) {
             require_once APP_ROOT_PATH . "system/libs/user.php";
             modify_account(array("money" => "-" . $order_info['credit_pay']), intval($GLOBALS['user_info']['id']), "支持" . $order_info['deal_name'] . "项目支付");
         }
         $result = pay_order($order_id);
         if ($result['status'] == 0) {
             $money = $result['money'];
             $payment_notice['create_time'] = NOW_TIME;
             $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
             $payment_notice['payment_id'] = $order_info['payment_id'];
             $payment_notice['money'] = $money;
             $payment_notice['order_id'] = $order_id;
             $payment_notice['memo'] = $order_info['memo'];
             $payment_notice['deal_id'] = $order_info['deal_id'];
             $payment_notice['deal_item_id'] = $order_info['deal_item_id'];
             $payment_notice['deal_name'] = $order_info['deal_name'];
             //积分商城项目增加积分方和积分兑换率
             if ($isap == "1") {
                 $payment_notice['partner_id'] = $order_info['ap_partner_id'];
                 $payment_notice['ap_ratio'] = $order_info['ap_ratio'];
             }
             do {
                 $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                 $notice_id = $GLOBALS['db']->insert_id();
             } while ($notice_id == 0);
             /*if($isap=="1"){
                   app_redirect(url("cart#ap_jump",array("notice_id"=>$notice_id,"order_id"=>$order_id)));
               }*/
             if ($isap == "1") {
                 //调用积分支付方法类
                 require_once APP_ROOT_PATH . "system/payment/Appay_payment.php";
                 $o = new Appay_payment();
                 $res = $o->user_pay($notice_id);
                 $data = array();
                 $data['deal_id'] = $order_info['deal_id'];
                 $data['deal_item_id'] = $order_info['deal_item_id'];
                 $data['order_id'] = $order_id;
                 //                    $_COOKIE["confirm"] = false;
                 es_session::set("confirm", $_REQUEST['t']);
                 switch ($res) {
                     case 1:
                         $GLOBALS['tmpl']->assign('data', $data);
                         $GLOBALS['tmpl']->display('pay_sucess.html');
                         break;
                     case -1:
                         $data['pay_info'] = '积分不足.';
                         //                            $GLOBALS['tmpl']->assign('msg','积分不足');
                         $GLOBALS['tmpl']->assign('data', $data);
                         $GLOBALS['tmpl']->display('pay_error.html');
                         break;
                     case 0:
                         $data['pay_info'] = '订单为空.';
                         $GLOBALS['tmpl']->assign('data', $data);
                         //                            $GLOBALS['tmpl']->assign('msg','订单为空');
                         $GLOBALS['tmpl']->display('pay_error.html');
                         break;
                 }
                 exit;
             }
             //                echo $payment_id;
             if ($_REQUEST['isqr'] !== '1') {
                 app_redirect(url("cart#jump", array("id" => $notice_id)));
             } else {
                 app_redirect(url("cart#jump_wxzf", array("id" => $notice_id)));
             }
         } elseif ($result['status'] == 1) {
             $data['pay_status'] = 0;
             $data['pay_info'] = '订单过期.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         } elseif ($result['status'] == 2) {
             $data['pay_status'] = 0;
             $data['pay_info'] = '订单无库存.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         } else {
             $data['pay_status'] = 1;
             $data['pay_info'] = '订单支付成功.';
             $data['show_pay_btn'] = 0;
             $GLOBALS['tmpl']->assign('data', $data);
             $GLOBALS['tmpl']->display('pay_order_index.html');
         }
         //app_redirect(url_wap("cart#pay_order",array("order_id"=>$order_id)));
     } else {
         showErr("下单失败", 0, get_gopreview_wap());
     }
 }
Beispiel #7
0
 public function save_consignee()
 {
     $ajax = 1;
     if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_consignee where user_id = " . intval($GLOBALS['user_info']['id'])) > 10) {
         showErr("每个会员只能预设10个配送地址", $ajax, "");
     }
     $id = intval($_REQUEST['id']);
     $consignee = strim($_REQUEST['consignee']);
     $province = strim($_REQUEST['province']);
     $city = strim($_REQUEST['city']);
     $address = strim($_REQUEST['address']);
     $zip = strim($_REQUEST['zip']);
     $mobile = strim($_REQUEST['mobile']);
     if ($consignee == "") {
         showErr("请填写收货人姓名", $ajax, "");
     }
     if ($province == "") {
         showErr("请选择省份", $ajax, "");
     }
     if ($city == "") {
         showErr("请选择城市", $ajax, "");
     }
     if ($address == "") {
         showErr("请填写详细地址", $ajax, "");
     }
     if (!check_postcode($zip)) {
         showErr("请填写正确的邮编", $ajax, "");
     }
     if ($mobile == "") {
         showErr("请填写收货人手机号码", $ajax, "");
     }
     if (!check_mobile($mobile)) {
         showErr("请填写正确的手机号码", $ajax, "");
     }
     $data = array();
     $data['consignee'] = $consignee;
     $data['province'] = $province;
     $data['city'] = $city;
     $data['address'] = $address;
     $data['zip'] = $zip;
     $data['mobile'] = $mobile;
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     if (isset($_REQUEST['isdefault'])) {
         $data['is_default'] = $_REQUEST['isdefault'] ? 1 : 0;
         //新地址设为默认地址时将其它地址更新为非默认地址
         $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "user_consignee SET is_default = 0 where (user_id = " . intval($GLOBALS['user_info']['id']) . " and is_default = 1)");
     }
     if (!check_ipop_limit(get_client_ip(), "setting_save_consignee", 5)) {
         showErr("提交太频繁", $ajax, "");
         exit;
     }
     //id 是用来更新地址的
     if ($id > 0) {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data, "UPDATE", "id=" . $id);
     } else {
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data);
     }
     showSuccess("保存成功", $ajax, get_gopreview_wap());
     //$res = save_user($user_data);
 }
 public function del_focus()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url_wap("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $deal_id = $GLOBALS['db']->getOne("select deal_id from " . DB_PREFIX . "deal_focus_log where id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']));
     $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_focus_log where id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']));
     $GLOBALS['db']->query("update " . DB_PREFIX . "deal set focus_count = focus_count - 1 where id = " . intval($deal_id));
     $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_deal_notify where user_id = " . intval($GLOBALS['user_info']['id']) . " and deal_id = " . $deal_id);
     app_redirect(get_gopreview_wap());
 }