public function index()
 {
     $payment_id = intval($GLOBALS['request']['payment']);
     $money = floatval($GLOBALS['request']['money']);
     if ($money <= 0) {
         $root['status'] = 2;
         $root['info'] = $GLOBALS['lang']['PLEASE_INPUT_CORRECT_INCHARGE'];
         output($root);
     }
     $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_id);
     if (!$payment_info) {
         $root['status'] = 2;
         $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
         output($root);
     }
     if ($payment_info['fee_type'] == 0) {
         //定额
         $payment_fee = $payment_info['fee_amount'];
     } else {
         //比率
         $payment_fee = $money * $payment_info['fee_amount'];
     }
     //开始生成订单
     $now = NOW_TIME;
     $order['type'] = 1;
     //充值单
     $order['user_id'] = $GLOBALS['user_info']['id'];
     $order['create_time'] = $now;
     $order['total_price'] = $money + $payment_fee;
     $order['deal_total_price'] = $money;
     $order['pay_amount'] = 0;
     $order['pay_status'] = 0;
     $order['delivery_status'] = 5;
     $order['order_status'] = 0;
     $order['payment_id'] = $payment_id;
     $order['payment_fee'] = $payment_fee;
     //        $order['bank_id'] = strim($_REQUEST['bank_id']);
     do {
         $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(100, 999);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
         $order_id = intval($GLOBALS['db']->insert_id());
     } while ($order_id == 0);
     require_once APP_ROOT_PATH . "system/model/cart.php";
     $payment_notice_id = make_payment_notice($order['total_price'], $order_id, $payment_info['id']);
     //创建支付接口的付款单
     if ($payment_notice_id) {
         $root['order_id'] = $order_id;
         $root['info'] = 1;
     }
     //        print_r($root);exit;
     output($root);
     //        $rs = order_paid($order_id);
     //        if ($rs) {
     //            app_redirect(url("index", "payment#incharge_done", array("id" => $order_id))); //充值支付成功
     //        } else {
     //            app_redirect(url("index", "payment#pay", array("id" => $payment_notice_id)));
     //        }
 }
 public function do_incharge()
 {
     $order_id = intval($_REQUEST['order_id']);
     $payment_id = intval($_REQUEST['payment_id']);
     $payment_info = M("Payment")->getById($payment_id);
     $memo = $_REQUEST['memo'];
     $order_info = M("DealOrder")->where("id=" . $order_id . " and is_delete = 0 and type = 0")->find();
     if (!$order_info) {
         $this->error(l("INVALID_ORDER"));
     }
     if ($order_info['region_lv4'] > 0) {
         $region_id = $order_info['region_lv4'];
     } elseif ($order_info['region_lv3'] > 0) {
         $region_id = $order_info['region_lv3'];
     } elseif ($order_info['region_lv2'] > 0) {
         $region_id = $order_info['region_lv2'];
     } else {
         $region_id = $order_info['region_lv1'];
     }
     $delivery_id = $order_info['delivery_id'];
     $payment_id = intval($_REQUEST['payment_id']);
     $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
     $GLOBALS['user_info']['id'] = $order_info['user_id'];
     require_once APP_ROOT_PATH . "system/model/cart.php";
     $result = count_buy_total($region_id, $delivery_id, $payment_id, $account_money = 0, $all_account_money = 0, $ecvsn, $ecvpassword, $goods_list, $order_info['account_money'], $order_info['ecv_money'], $order_info['bank_id']);
     $user_money = M("User")->where("id=" . $order_info['user_id'])->getField("money");
     //$pay_amount = $order_info['deal_total_price']+ $order_info['delivery_fee']-$order_info['account_money']-$order_info['ecv_money']+$payment_info['fee_amount'];
     $pay_amount = $result['pay_price'];
     if ($payment_info['class_name'] == 'Account' && $user_money < $pay_amount) {
         $this->error(l("ACCOUNT_NOT_ENOUGH"));
     }
     $notice_id = make_payment_notice($pay_amount, $order_id, $payment_id, $memo);
     $order_info['total_price'] = $result['pay_total_price'];
     $order_info['payment_fee'] = $result['payment_fee'];
     $order_info['delivery_fee'] = $result['delivery_fee'];
     $order_info['discount_price'] = $result['user_discount'];
     $order_info['payment_id'] = $payment_info['id'];
     $order_info['update_time'] = NOW_TIME;
     M("DealOrder")->save($order_info);
     $payment_notice = M("PaymentNotice")->getById($notice_id);
     $rs = payment_paid($payment_notice['id']);
     if ($rs && $payment_info['class_name'] == 'Account') {
         //余额支付
         require_once APP_ROOT_PATH . "system/payment/Account_payment.php";
         require_once APP_ROOT_PATH . "system/model/user.php";
         $msg = sprintf($payment_lang['USER_ORDER_PAID'], $order_info['order_sn'], $payment_notice['notice_sn']);
         modify_account(array('money' => "-" . $payment_notice['money'], 'score' => 0), $payment_notice['user_id'], $msg);
     }
     if ($rs) {
         order_paid($order_id);
         $msg = sprintf(l("MAKE_PAYMENT_NOTICE_LOG"), $order_info['order_sn'], $payment_notice['notice_sn']);
         save_log($msg, 1);
         order_log($msg . $_REQUEST['memo'], $order_id);
         $this->assign("jumpUrl", U("DealOrder/view_order", array("id" => $order_id)));
         $this->success(l("ORDER_INCHARGE_SUCCESS"));
     } else {
         $this->assign("jumpUrl", U("DealOrder/view_order", array("id" => $order_id)));
         $this->success(l("ORDER_INCHARGE_FAILED"));
     }
 }
 public function order_done()
 {
     save_debug_log('order_done', 'request:' . json_encode($_REQUEST));
     $user_info = $GLOBALS['user_info'];
     $id = intval($_REQUEST['id']);
     //订单号
     $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and is_delete = 0");
     if (!$order) {
         showErr($GLOBALS['lang']['INVALID_ORDER_DATA']);
     }
     $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'])) : '';
     $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order['id']);
     //验证购物车
     if (!$user_info) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], 0, url("shop", "user#login"));
     }
     //验证支付方式的支持
     foreach ($goods_list as $k => $row) {
         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);
             }
         }
     }
     //结束验证购物车
     //开始验证订单接交信息
     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, $order['account_money'], $order['ecv_money']);
     if ($data['is_delivery'] == 1) {
         //配送验证
         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']);
         //					}
     }
     if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
         showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT']);
     }
     //结束验证订单接交信息
     //开始修正订单
     $now = get_gmtime();
     $order['total_price'] = $data['pay_total_price'];
     //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
     $order['memo'] = htmlspecialchars(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['delivery_fee'] = $data['delivery_fee'];
     $order['delivery_id'] = $data['delivery_info']['id'];
     $order['payment_id'] = $data['payment_info']['id'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['discount_price'] = $data['user_discount'];
     $order['bank_id'] = htmlspecialchars(addslashes(trim($_REQUEST['bank_id'])));
     $order['promote_description'] = "";
     foreach ($data['promote_description'] as $promote_item) {
         $order['promote_description'] .= $promote_item . "<br />";
     }
     $coupon_mobile = htmlspecialchars(addslashes(trim($_REQUEST['coupon_mobile'])));
     $user_info = es_session::get("user_info");
     if ($coupon_mobile != '') {
         $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $coupon_mobile . "' where id = " . intval($user_info['id']));
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'UPDATE', 'id=' . $order['id'], 'SILENT');
     if ($data['is_delivery'] == 1) {
         //保存收款人
         $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $order['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'] = $order['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');
         }
     }
     //生成order_id 后
     //1. 余额支付
     $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']);
     if ($rs) {
         app_redirect(url("shop", "payment#done", array("id" => $order['id'])));
         //支付成功
     } else {
         app_redirect(url("shop", "payment#pay", array("id" => $payment_notice_id)));
     }
 }
Beispiel #4
0
 public function order_done()
 {
     require_once APP_ROOT_PATH . "system/model/deal.php";
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     global_run();
     $ajax = 1;
     $user_info = $GLOBALS['user_info'];
     $id = intval($_REQUEST['id']);
     //订单号
     $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and is_delete = 0 and user_id = " . $user_info['id']);
     if (!$order) {
         showErr($GLOBALS['lang']['INVALID_ORDER_DATA'], $ajax);
     }
     if ($order['refund_status'] == 1) {
         showErr($GLOBALS['lang']['REFUNDING_CANNOT_PAY'], $ajax);
     }
     if ($order['refund_status'] == 2) {
         showErr($GLOBALS['lang']['REFUNDED_CANNOT_PAY'], $ajax);
     }
     $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'] ? strim($_REQUEST['ecvsn']) : '';
     $ecvpassword = $_REQUEST['ecvpassword'] ? strim($_REQUEST['ecvpassword']) : '';
     $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order['id']);
     //验证购物车
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax, url("index", "user#login"));
     }
     //验证支付方式的支持
     foreach ($goods_list as $k => $row) {
         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);
             }
         }
     }
     //结束验证购物车
     $deal_s = $GLOBALS['db']->getAll("select distinct(deal_id) as deal_id from " . DB_PREFIX . "deal_order_item where order_id = " . $order['id']);
     //如果属于未支付的
     if ($order['pay_status'] == 0) {
         foreach ($deal_s as $row) {
             $checker = check_deal_number($row['deal_id'], 0);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
         foreach ($goods_list as $k => $v) {
             $checker = check_deal_number_attr($v['deal_id'], $v['attr_str'], 0);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
         //验证商品是否过期
         foreach ($deal_s as $row) {
             $checker = check_deal_time($row['deal_id']);
             if ($checker['status'] == 0) {
                 showErr($checker['info'] . " " . $GLOBALS['lang']['DEAL_ERROR_' . $checker['data']], $ajax);
             }
         }
     }
     //开始验证订单接交信息
     require_once APP_ROOT_PATH . "system/model/cart.php";
     $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list, $order['account_money'], $order['ecv_money']);
     if ($data['is_delivery'] == 1) {
         //配送验证
         if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['consignee']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'], $ajax);
         }
         if (trim($_REQUEST['address']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ADDRESS'], $ajax);
         }
         if (trim($_REQUEST['zip']) == '') {
             showErr($GLOBALS['lang']['FILL_CORRECT_ZIP'], $ajax);
         }
         if (trim($_REQUEST['mobile']) == '') {
             showErr($GLOBALS['lang']['FILL_MOBILE_PHONE'], $ajax);
         }
         if (!check_mobile(trim($_REQUEST['mobile']))) {
             showErr($GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'], $ajax);
         }
         if (!$data['delivery_info']) {
             showErr($GLOBALS['lang']['PLEASE_SELECT_DELIVERY'], $ajax);
         }
     }
     if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
         showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT'], $ajax);
     }
     //结束验证订单接交信息
     //开始修正订单
     $now = NOW_TIME;
     $order['total_price'] = $data['pay_total_price'];
     //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
     $order['memo'] = strim($_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'] = strim($_REQUEST['address']);
     $order['mobile'] = strim($_REQUEST['mobile']);
     $order['consignee'] = strim($_REQUEST['consignee']);
     $order['zip'] = strim($_REQUEST['zip']);
     $order['delivery_fee'] = $data['delivery_fee'];
     $order['delivery_id'] = $data['delivery_info']['id'];
     $order['payment_id'] = $data['payment_info']['id'];
     $order['payment_fee'] = $data['payment_fee'];
     $order['discount_price'] = $data['user_discount'];
     $order['bank_id'] = strim($_REQUEST['bank_id']);
     $order['promote_description'] = "";
     foreach ($data['promote_description'] as $promote_item) {
         $order['promote_description'] .= $promote_item . "<br />";
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'UPDATE', 'id=' . $order['id'], 'SILENT');
     if ($data['is_delivery'] == 1) {
         //保存收款人
         $consignee_id = intval($_REQUEST['consignee_id']);
         $user_consignee = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where user_id = " . $order['user_id'] . " and id = " . $consignee_id);
         $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'] = strim($_REQUEST['address']);
         $user_consignee['mobile'] = strim($_REQUEST['mobile']);
         $user_consignee['consignee'] = strim($_REQUEST['consignee']);
         $user_consignee['zip'] = strim($_REQUEST['zip']);
         $user_consignee['user_id'] = $order['user_id'];
         if (intval($user_consignee['id']) == 0) {
             //新增,修改订单不新增配送
             // 				$user_consignee['is_default'] = 1;
             // 				$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. 余额支付
     $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']);
     if ($rs) {
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#done", array("id" => $order['id']));
         ajax_return($data);
         //支付成功
     } else {
         distribute_order($order['id']);
         $data = array();
         $data['info'] = "";
         $data['jump'] = url("index", "payment#pay", array("id" => $payment_notice_id));
         ajax_return($data);
     }
 }
Beispiel #5
0
 public function index()
 {
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $money = floatval($user['money']);
     $root = array();
     $root['return'] = 1;
     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;
         }
         $payment = $GLOBALS['request']['payment_id'] ? intval($GLOBALS['request']['payment_id']) : 17;
         $account_money = floatval($GLOBALS['request']['use_user_money']);
         $address = strim($GLOBALS['request']['delivery_detail']);
         $consignee_mobile = strim($GLOBALS['request']['phone']);
         $zip = strim($GLOBALS['request']['postcode']);
         $consignee = strim($GLOBALS['request']['consignee']);
         $ecvsn = $GLOBALS['request']['ecv_sn'] ? strim($GLOBALS['request']['ecv_sn']) : '';
         $ecvpassword = $GLOBALS['request']['ecv_pwd'] ? strim($GLOBALS['request']['ecv_pwd']) : '';
         $order_memo = strim($GLOBALS['request']['content']);
         $send_mobile = strim($GLOBALS['request']['send_mobile']);
         $delivery_id = intval($GLOBALS['request']['delivery_id']);
         $order_time = $GLOBALS['request']['order_time'];
         $technician_id = $GLOBALS['request']['tech_id'];
         if (empty($order_time)) {
             $root['status'] = 0;
             $root['info'] = '请选择预约时间';
             output($root);
         }
         $order_time .= ':00';
         $order_time = strtotime($order_time);
         //$delivery_id = intval($GLOBALS['m_config']['delivery_id']);
         $coupon_mobile = htmlspecialchars($send_mobile);
         if ($coupon_mobile != '') {
             $i = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . $coupon_mobile . "' and id != " . intval($user_id)));
             if ($i > 0) {
                 $root['status'] = 0;
                 $root['info'] = '该手机号码,已经被占用';
                 output($root);
             }
         }
         $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'");
         if ($account_pay) {
             $all_account_money = 1;
         } else {
             $all_account_money = 0;
         }
         if ($GLOBALS['request']['from'] == "wap") {
             $cartdata = unserialize(base64_decode($GLOBALS['request']['cartdata']));
             $res = insertCartData($user_id, es_session::id(), $cartdata);
         } else {
             $cartdata = $GLOBALS['request']['cartdata'];
             $res = insertCartData($user_id, es_session::id(), $cartdata);
         }
         if ($res['info'] != '') {
             //失败有错误
             $root['status'] = 0;
             $root['info'] = $res['info'];
             output($root);
         } else {
             //可以提交订单
             $goods_list = $res['data'];
             require_once APP_ROOT_PATH . "system/model/cart.php";
             $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;
             }
             $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
             if ($data['is_delivery'] == 1) {
                 //配送验证
                 if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($address == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee_mobile == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!check_mobile(trim($consignee_mobile))) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!$data['delivery_info']) {
                     $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_DELIVERY'];
                     $root['status'] = 0;
                     output($root);
                 }
             }
             if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
                 $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
                 $root['status'] = 0;
                 output($root);
             } else {
                 //获取服务时间
                 foreach ($goods_list as $k => $v) {
                     $order['service_time'] = $v['service_time'];
                 }
                 //技师直约判断当前时间是否可约
                 if ($technician_id) {
                     $tech = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id=" . $technician_id);
                     $start_time = $order_time - $tech['distance_time'] * 60;
                     $end_time = $order_time + $tech['distance_time'] * 60 + $order['service_time'] * 60;
                     $order_able_sql = "SELECT \n                                                                * \n                                                              FROM\n                                                                " . DB_PREFIX . "deal_order DO \n                                                              WHERE  do.technician_id={$technician_id} \n                                                                  and order_status = 0 and is_delete = 0 and extra_status = 0 and after_sale = 0 and refund_status = 0 and  (\n                                                                  do.`order_time` + do.`service_time` * 60 BETWEEN " . $start_time . " \n                                                                  AND " . $end_time . " \n                                                                ) \n                                                                OR (\n                                                                  do.`order_time` BETWEEN " . $start_time . " \n                                                                  AND " . $end_time . "\n                                                                )";
                     $order_able = $GLOBALS['db']->getRow($order_able_sql);
                     if (!empty($order_able)) {
                         $root['info'] = "当前时间已被预约,请重新选择时间";
                         $root['status'] = 0;
                         output($root);
                     }
                 }
                 //验证成功
                 //开始生成订单
                 $now = time();
                 $order['type'] = 0;
                 //普通订单
                 $order['user_id'] = $user_id;
                 $order['user_name'] = $user['user_name'];
                 $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($order_memo);
                 $order['region_lv1'] = $region1_id;
                 $order['region_lv2'] = $region2_id;
                 $order['region_lv3'] = $region3_id;
                 $order['region_lv4'] = $region4_id;
                 $order['address'] = htmlspecialchars($address);
                 $order['mobile'] = htmlspecialchars($consignee_mobile);
                 $order['consignee'] = htmlspecialchars($consignee);
                 $order['zip'] = htmlspecialchars($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['bank_id'] = 0;
                 $order['order_time'] = $order_time;
                 $order['technician_id'] = $technician_id == '' ? 0 : $technician_id;
                 $order['order_end_time'] = $order_time + $order['service_time'] * 60;
                 //if($send_mobile!='')
                 //	$GLOBALS['db']->query("update ".DB_PREFIX."user set mobile = '".$send_mobile."' where id = ".$user_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);
                 //end 验证成功提交订单成功
                 //开始生成订单产品以及支付
                 //生成订单商品
                 foreach ($goods_list as $k => $v) {
                     $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['deal_icon'] = $v['icon'];
                     $goods_item['service_time'] = $v['service_time'];
                     $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id']));
                     $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);
                 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'] = $region1_id;
                     $user_consignee['region_lv2'] = $region2_id;
                     $user_consignee['region_lv3'] = $region3_id;
                     $user_consignee['region_lv4'] = $region4_id;
                     $user_consignee['address'] = htmlspecialchars($address);
                     $user_consignee['mobile'] = htmlspecialchars($consignee_mobile);
                     $user_consignee['consignee'] = htmlspecialchars($consignee);
                     $user_consignee['zip'] = htmlspecialchars($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) {
                     $GLOBALS['payment_lang'] = array('name' => '余额支付', 'account_credit' => '帐户余额', 'use_user_money' => '使用余额支付', 'use_all_money' => '全额支付', 'USER_ORDER_PAID' => '%s订单付款,付款单号%s');
                     $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);
                 }
                 $root['order_id'] = $order_id;
                 $rs = order_paid($order_id);
                 update_order_cache($order_id);
                 if ($rs) {
                     $root['pay_status'] = 1;
                 } else {
                     $root['pay_status'] = 0;
                 }
                 //end 订单产品生成及支付
                 $root['status'] = 1;
             }
             //end 提交订单
         }
     } else {
         $root['user_login_status'] = 0;
         $root['status'] = 0;
         $root['info'] = '请先登录';
         //未登录
     }
     output($root);
 }
Beispiel #6
0
function getInchargeDone($payment_id, $money, $bank_id, $memo, $pingzheng)
{
    $status = array('status' => 0, 'show_err' => '');
    if ($money <= 0) {
        $status['status'] = 0;
        $status['show_err'] = $GLOBALS['lang']['PLEASE_INPUT_CORRECT_INCHARGE'];
        return $status;
    }
    $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_id);
    if (!$payment_info) {
        $status['status'] = 0;
        $status['show_err'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
        return $status;
    }
    $order['bank_id'] = $bank_id;
    $order['memo'] = $memo;
    //开始生成订单
    $now = TIME_UTC;
    $order['type'] = 1;
    //充值单
    $order['user_id'] = $GLOBALS['user_info']['id'];
    $order['create_time'] = $now;
    if ($payment_info['fee_type'] == 0) {
        $order['total_price'] = $money + $payment_info['fee_amount'];
    } else {
        $order['total_price'] = $money + $payment_info['fee_amount'] * $money;
    }
    $order['deal_total_price'] = $money;
    $order['pay_amount'] = 0;
    $order['pay_status'] = 0;
    $order['delivery_status'] = 5;
    $order['order_status'] = 0;
    $order['payment_id'] = $payment_id;
    if ($payment_info['fee_type'] == 0) {
        $order['payment_fee'] = $payment_info['fee_amount'];
    } else {
        $order['payment_fee'] = $payment_info['fee_amount'] * $money;
    }
    if ($payment_info['class_name'] == 'Otherpay' && $order['memo'] != "") {
        $payment_info['config'] = unserialize($payment_info['config']);
        $order['memo'] = "银行流水单号:" . $order['memo'];
        $order['memo'] .= "<br>开户行:" . $payment_info['config']['pay_bank'][$order['bank_id']];
        $order['memo'] .= "<br>充值银行:" . $payment_info['config']['pay_name'][$order['bank_id']];
        $order['memo'] .= "<br>帐号:" . $payment_info['config']['pay_account'][$order['bank_id']];
        $order['memo'] .= "<br>用户:" . $payment_info['config']['pay_account_name'][$order['bank_id']];
        if ($pingzheng != "") {
            $order['memo'] .= "<br>凭证:<a href='" . $pingzheng . "' target='_blank'>查看</a>";
        }
    }
    do {
        $order['order_sn'] = to_date(TIME_UTC, "Ymdhis") . rand(100, 999);
        $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
        $order_id = intval($GLOBALS['db']->insert_id());
    } while ($order_id == 0);
    require_once APP_ROOT_PATH . "system/libs/cart.php";
    $payment_notice_id = make_payment_notice($order['total_price'], $order_id, $payment_info['id'], $order['memo']);
    //创建支付接口的付款单
    $status['payment_info'] = $payment_info;
    $status['status'] = 1;
    $status['payment_notice_id'] = $payment_notice_id;
    $status['order_id'] = $order_id;
    $rs = order_paid($order_id);
    if ($rs) {
        $status['pay_status'] = 1;
    } else {
        $status['pay_status'] = 0;
    }
    return $status;
}
 public function index()
 {
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $order_id = intval($GLOBALS['request']['id']);
     $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;
     }
     $payment_id = intval($GLOBALS['request']['payment_id']);
     $consignee = strim($GLOBALS['request']['consignee']);
     $delivery_detail = strim($GLOBALS['request']['delivery_detail']);
     $phone = strim($GLOBALS['request']['phone']);
     $postcode = strim($GLOBALS['request']['postcode']);
     $content = strim($GLOBALS['request']['content']);
     $send_mobile = strim($GLOBALS['request']['send_mobile']);
     //$delivery_id = $GLOBALS['m_config']['delivery_id'];
     $delivery_id = $GLOBALS['request']['delivery_id'];
     $root = array();
     $root['return'] = 1;
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         //开始计算订单
         $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id);
         if (!$order_info) {
             $root['status'] = 0;
             $root['info'] = '订单不存在';
             output($root);
         }
         require_once APP_ROOT_PATH . "system/libs/cart.php";
         $goods_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
         $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']);
         }
         if ($data['is_delivery'] == 1) {
             //配送验证
             if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'];
                 output($root);
             }
             if ($consignee == '') {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'];
                 output($root);
             }
             if ($delivery_detail == '') {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ADDRESS'];
                 output($root);
             }
             if ($postcode == '') {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ZIP'];
                 output($root);
             }
             if ($phone == '') {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_MOBILE_PHONE'];
                 output($root);
             }
             if (!check_mobile($phone)) {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
                 output($root);
             }
             if (!$data['delivery_info']) {
                 $root['status'] = 0;
                 $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_DELIVERY'];
                 output($root);
             }
         }
         if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
             $root['status'] = 0;
             $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
             output($root);
         }
         //结束验证订单接交信息
         //开始修正订单
         $now = get_gmtime();
         $order_info['total_price'] = $data['pay_total_price'];
         //应付总额  商品价 - 会员折扣 + 运费 + 支付手续费
         $order_info['memo'] = htmlspecialchars($content);
         $order_info['region_lv1'] = intval($region1_id);
         $order_info['region_lv2'] = intval($region2_id);
         $order_info['region_lv3'] = intval($region3_id);
         $order_info['region_lv4'] = intval($region4_id);
         $order_info['address'] = htmlspecialchars($delivery_detail);
         $order_info['mobile'] = htmlspecialchars($phone);
         $order_info['consignee'] = htmlspecialchars($consignee);
         $order_info['zip'] = htmlspecialchars($postcode);
         $order_info['delivery_fee'] = $data['delivery_fee'];
         $order_info['delivery_id'] = $data['delivery_info']['id'];
         $order_info['payment_id'] = $data['payment_info']['id'];
         $order_info['payment_fee'] = $data['payment_fee'];
         $order_info['delivery_fee'] = $data['delivery_fee'];
         $order_info['discount_price'] = $data['user_discount'];
         $coupon_mobile = htmlspecialchars($send_mobile);
         if ($coupon_mobile != '') {
             $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $coupon_mobile . "' where id = " . intval($user_id));
         }
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info, 'UPDATE', 'id=' . $order_info['id'], 'SILENT');
         //生成order_id 后
         //1. 余额支付
         $account_money = $data['account_money'];
         if (floatval($account_money) > 0) {
             $GLOBALS['payment_lang'] = array('name' => '余额支付', 'account_credit' => '帐户余额', 'use_user_money' => '使用余额支付', 'use_all_money' => '全额支付', 'USER_ORDER_PAID' => '%s订单付款,付款单号%s');
             $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_info['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);
         }
         $rs = order_paid($order_info['id']);
         $root['status'] = 1;
         $root['info'] = '';
         $root['has_pay'] = 1;
         $root['order_id'] = $order_id;
     } else {
         $root['user_login_status'] = 0;
         $root['status'] = 0;
         $root['info'] = '请先登录';
     }
     output($root);
 }
function getInchargeDone($payment_id, $money, $memo)
{
    $status = array('status' => 0, 'show_err' => '');
    if ($money <= 0) {
        $status['status'] = 0;
        $status['show_err'] = '请输入正确的充值金额';
        return $status;
    }
    $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_id);
    if (!$payment_info) {
        $status['status'] = 0;
        $status['show_err'] = '请选择支付方式';
        return $status;
    }
    $order['memo'] = $memo;
    // 开始生成订单
    $now = TIME_UTC;
    $order['type'] = 1;
    // 充值单
    $order['user_id'] = $GLOBALS['user_info']['id'];
    $order['create_time'] = $now;
    if ($payment_info['fee_type'] == 0) {
        $order['total_price'] = $money + $payment_info['fee_amount'];
    } else {
        $order['total_price'] = $money + $payment_info['fee_amount'] * $money;
    }
    $order['deal_total_price'] = $money;
    $order['pay_amount'] = 0;
    $order['pay_status'] = 0;
    $order['delivery_status'] = 5;
    $order['order_status'] = 0;
    $order['payment_id'] = $payment_id;
    if ($payment_info['fee_type'] == 0) {
        $order['payment_fee'] = $payment_info['fee_amount'];
    } else {
        $order['payment_fee'] = $payment_info['fee_amount'] * $money;
    }
    if ($order['memo'] != "") {
        $order['memo'] = $order['memo'];
    }
    do {
        $order['order_sn'] = to_date(TIME_UTC, "Ymdhis") . rand(100, 999);
        $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
        $order_id = intval($GLOBALS['db']->insert_id());
    } while ($order_id == 0);
    require_once APP_ROOT_PATH . "system/libs/cart.php";
    $payment_notice_id = make_payment_notice($order['total_price'], $order_id, $payment_info['id'], $order['memo']);
    // 创建支付接口的付款单
    $status['payment_info'] = $payment_info;
    $status['status'] = 1;
    $status['payment_notice_id'] = $payment_notice_id;
    $status['order_id'] = $order_id;
    $rs = order_paid($order_id);
    if ($rs) {
        $status['pay_status'] = 1;
    } else {
        $status['pay_status'] = 0;
    }
    return $status;
}
Beispiel #9
0
 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['response_code'] = 1;
     if ($user_id > 0) {
         $order_id = intval($GLOBALS['request']['order_id']);
         $root['user_login_status'] = 1;
         $root['pay_status'] = 0;
         //0:订单未收款(全额);1:订单已经收款(全额)
         $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where user_id = {$user_id} and id = " . $order_id);
         if (empty($order)) {
             $root['pay_status'] = 1;
             $root['pay_info'] = '订单不存在.';
             $root['show_pay_btn'] = 0;
             output($root);
         }
         if ($order['pay_status'] == 2) {
             $root['pay_status'] = 1;
             $root['pay_code'] = '';
             $root['order_id'] = $order_id;
             $root['order_sn'] = $order['order_sn'];
             $root['pay_info'] = '订单已经收款.';
             $root['show_pay_btn'] = 0;
             output($root);
         }
         $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id=" . intval($order['payment_id']));
         $pay_code = strtolower($payment_info['class_name']);
         if (!($pay_code == 'malipay' || $pay_code == 'mtenpay' || $pay_code == 'mcod' || $pay_code == 'walipay' || $pay_code == 'wtenpay')) {
             $root['response_code'] = 0;
             $root['pay_info'] = '手机版本不支付,无法在手机上支付.' . $pay_code;
             $root['show_pay_btn'] = 0;
             output($root);
         }
         //3. 相应的支付接口
         $pay_price = $order['total_price'] - $order['pay_amount'];
         if ($payment_info && $pay_price > 0) {
             require_once APP_ROOT_PATH . "system/libs/cart.php";
             $payment_notice_id = make_payment_notice($pay_price, $order_id, $payment_info['id']);
             //创建支付接口的付款单
         }
         //创建了支付单号,通过支付接口创建支付数据
         require_once APP_ROOT_PATH . "system/payment/" . $payment_info['class_name'] . "_payment.php";
         $payment_class = $payment_info['class_name'] . "_payment";
         $payment_object = new $payment_class();
         $pay = $payment_object->get_payment_code($payment_notice_id);
         $root['response_code'] = 1;
         $root['pay_code'] = $pay['pay_code'];
         $root['order_id'] = $order_id;
         $root['order_sn'] = $order['order_sn'];
         $root['show_pay_btn'] = 0;
         //0:不显示,支付按钮; 1:显示支付按钮
         //支付接口支付 malipay,支付宝;mtenpay,财付通;mcod,货到付款/现金支付
         if ($pay['pay_code'] == 'malipay') {
             $root['pay_money_format'] = $pay['total_fee_format'];
             $root['pay_money'] = $pay['total_fee'];
             $root['pay_info'] = $pay['body'];
             $root['malipay'] = $pay;
             if ($root['pay_money'] > 0) {
                 $root['show_pay_btn'] = 1;
             }
         } else {
             if ($pay['pay_code'] == 'mtenpay') {
                 $root['pay_money_format'] = $pay['total_fee_format'];
                 $root['pay_money'] = $pay['total_fee'];
                 $root['pay_info'] = $pay['body'];
                 $root['mtenpay'] = $pay;
                 if ($root['pay_money'] > 0) {
                     $root['show_pay_btn'] = 1;
                 }
             } else {
                 if ($pay['pay_code'] == 'mcod') {
                     $root['pay_money_format'] = $pay['total_fee_format'];
                     $root['pay_money'] = $pay['total_fee'];
                     $root['pay_info'] = $pay['body'];
                     $root['mcod'] = $pay;
                     $root['show_pay_btn'] = 0;
                 } else {
                     if ($pay['pay_code'] == 'walipay') {
                         $root['pay_money_format'] = $pay['total_fee_format'];
                         $root['pay_money'] = $pay['total_fee'];
                         $root['pay_info'] = $pay['body'];
                         $root['pay_wap'] = $pay['notify_url'];
                         $root['walipay'] = $pay;
                         if ($root['pay_money'] > 0) {
                             $root['show_pay_btn'] = 1;
                         }
                     } else {
                         if ($pay['pay_code'] == 'wtenpay') {
                             $root['pay_money_format'] = $pay['total_fee_format'];
                             $root['pay_money'] = $pay['total_fee'];
                             $root['pay_info'] = $pay['body'];
                             $root['pay_wap'] = $pay['notify_url'];
                             $root['wtenpay'] = $pay;
                             if ($root['pay_money'] > 0) {
                                 $root['show_pay_btn'] = 1;
                             }
                         } else {
                             $root['response_code'] = 0;
                             $root['pay_info'] = '手机版本不支付,无法在手机上支付.';
                             $root['show_pay_btn'] = 0;
                         }
                     }
                 }
             }
         }
         output($root);
     } else {
         $root['user_login_status'] = 0;
         output($root);
     }
 }
 public function incharge_done()
 {
     echo "404";
     exit;
     $payment_id = intval($_REQUEST['payment']);
     $money = floatval($_REQUEST['money']);
     if ($money <= 0) {
         showErr($GLOBALS['lang']['PLEASE_INPUT_CORRECT_INCHARGE']);
     }
     $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_id);
     //		if(!$payment_info)
     //		{
     //			showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT']);
     //		}
     //开始生成订单
     $now = get_gmtime();
     $order['type'] = 1;
     //充值单
     $order['user_id'] = $GLOBALS['user_info']['id'];
     $order['create_time'] = $now;
     $order['total_price'] = $money + $payment_info['fee_amount'];
     $order['deal_total_price'] = $money;
     $order['pay_amount'] = 0;
     $order['pay_status'] = 0;
     $order['delivery_status'] = 5;
     $order['order_status'] = 0;
     $order['payment_id'] = $payment_id;
     $order['payment_fee'] = $payment_info['fee_amount'];
     $order['bank_id'] = addslashes(htmlspecialchars(trim($_REQUEST['bank_id'])));
     do {
         $order['order_sn'] = to_date(get_gmtime(), "Ymdhis") . rand(100, 999);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order, 'INSERT', '', 'SILENT');
         $order_id = intval($GLOBALS['db']->insert_id());
     } while ($order_id == 0);
     require_once APP_ROOT_PATH . "system/libs/cart.php";
     $payment_notice_id = make_payment_notice($order['total_price'], $order_id, $payment_info['id']);
     //创建支付接口的付款单
     $rs = order_paid($order_id);
     if ($rs) {
         app_redirect(url("shop", "payment#incharge_done", array("id" => $order_id)));
         //充值支付成功
     } else {
         app_redirect(url("shop", "payment#pay", array("id" => $payment_notice_id)));
     }
 }
Beispiel #11
0
 public function index()
 {
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     //检查用户,用户密码
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $root = array();
     $root['return'] = 1;
     $root['page_title'] = '订单支付';
     $root['city_name'] = $city_name;
     if ($user_id > 0) {
         $order_id = intval($GLOBALS['request']['order_id']);
         if ($order_id == 0) {
             $payment_notice_sn = $GLOBALS['request']['out_trade_no'];
             $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where notice_sn = '" . $payment_notice_sn . "'");
             $order_id = intval($payment_notice['order_id']);
         }
         $root['user_login_status'] = 1;
         $root['pay_status'] = 0;
         //0:订单未收款(全额);1:订单已经收款(全额)
         $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where user_id = {$user_id} and id = " . $order_id);
         if (empty($order)) {
             $root['pay_status'] = 1;
             $root['pay_info'] = '订单不存在.';
             $root['show_pay_btn'] = 0;
             output($root);
         }
         if ($order['pay_status'] == 2) {
             $root['pay_status'] = 1;
             $root['pay_code'] = '';
             //$pay['pay_code'];
             $root['order_id'] = $order_id;
             $root['order_sn'] = $order['order_sn'];
             $root['pay_info'] = '订单已经收款.';
             $root['show_pay_btn'] = 0;
             //有团购券,再显示团购券列表
             $list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_coupon where user_id = {$user_id} and order_id = " . $order_id);
             $couponlist = array();
             foreach ($list as $k => $v) {
                 $couponlist[$k]['couponSn'] = $v['sn'];
                 $couponlist[$k]['couponPw'] = $v['password'];
                 $couponlist[$k]['qrcode'] = str_replace('sjmapi', '', get_domain() . gen_qrcode($v['password']));
             }
             $root['couponlist'] = $couponlist;
             output($root);
         }
         $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id=" . intval($order['payment_id']));
         $pay_code = strtolower($payment_info['class_name']);
         /*online_pay 支付方式:1:在线支付;0:线下支付;2:手机wap;3:手机sdk */
         $online_pay = intval($payment_info['online_pay']);
         if ($GLOBALS['request']['from'] == "wap") {
             if (!($pay_code == 'wtenpay' || $pay_code == 'walipay' || $pay_code == 'mcod' || $pay_code == 'account' || $online_pay == 2)) {
                 $root['return'] = 0;
                 $root['pay_info'] = '手机版本不支付,无法在手机上支付.' . $pay_code;
                 $root['show_pay_btn'] = 0;
                 output($root);
             }
         } else {
             if (!($pay_code == 'malipay' || $pay_code == 'mtenpay' || $pay_code == 'mcod' || $pay_code == 'walipay' || $pay_code == 'wtenpay' || $online_pay == 2 || $online_pay == 3)) {
                 $root['return'] = 0;
                 $root['pay_info'] = '手机版本不支付,无法在手机上支付.' . $pay_code;
                 $root['show_pay_btn'] = 0;
                 output($root);
             }
         }
         // fwb update 2014-08-27
         //3. 相应的支付接口
         $pay_price = $order['total_price'] - $order['pay_amount'];
         if ($payment_info && $pay_price > 0) {
             require_once APP_ROOT_PATH . "system/model/cart.php";
             $payment_notice_id = make_payment_notice($pay_price, $order_id, $payment_info['id']);
             //创建支付接口的付款单
         }
         //创建了支付单号,通过支付接口创建支付数据
         require_once APP_ROOT_PATH . "system/payment/" . $payment_info['class_name'] . "_payment.php";
         $payment_class = $payment_info['class_name'] . "_payment";
         $payment_object = new $payment_class();
         $pay = $payment_object->get_payment_code($payment_notice_id);
         $root['return'] = 1;
         $root['pay_code'] = $pay['pay_code'];
         $root['order_id'] = $order_id;
         $root['order_sn'] = $order['order_sn'];
         $root['show_pay_btn'] = 0;
         //0:不显示,支付按钮; 1:显示支付按钮
         $root['is_wap_url'] = $pay['is_wap_url'];
         //0:不显示,支付按钮; 1:显示支付按钮
         if ($pay['wap_notify_url']) {
             $root['wap_notify_url'] = $pay['wap_notify_url'];
         }
         $root['is_wap'] = intval($pay['is_wap']);
         //支付接口支付 malipay,支付宝;mtenpay,财付通;mcod,货到付款/现金支付
         if ($GLOBALS['request']['from'] == "wap") {
             if ($root['is_wap'] == 1) {
                 $root['pay_money_format'] = $pay['total_fee_format'];
                 $root['pay_money'] = $pay['total_fee'];
                 $root['pay_info'] = $pay['body'];
                 $root['pay_wap'] = $pay['notify_url'];
                 if ($root['pay_money'] > 0) {
                     $root['show_pay_btn'] = 1;
                 }
             } else {
                 if ($pay['pay_code'] == 'mcod') {
                     $root['pay_money_format'] = $pay['total_fee_format'];
                     $root['pay_money'] = $pay['total_fee'];
                     $root['pay_info'] = $pay['body'];
                     $root['mcod'] = $pay;
                     $root['show_pay_btn'] = 0;
                 } else {
                     $root['return'] = 0;
                     $root['pay_info'] = '手机版本不支付,无法在手机上支付.';
                     $root['show_pay_btn'] = 0;
                 }
             }
             $root['payment_name'] = strtolower($payment_info['name']);
             output($root);
         } else {
             if ($root['is_wap'] == 1) {
                 $root['pay_money_format'] = $pay['total_fee_format'];
                 $root['pay_money'] = $pay['total_fee'];
                 $root['pay_info'] = $pay['body'];
                 $root['pay_wap'] = $pay['notify_url'];
                 if ($root['pay_money'] > 0) {
                     $root['show_pay_btn'] = 1;
                 }
             } else {
                 if ($pay['pay_code'] == 'malipay') {
                     $root['pay_money_format'] = $pay['total_fee_format'];
                     $root['pay_money'] = $pay['total_fee'];
                     $root['pay_info'] = $pay['body'];
                     $root['malipay'] = $pay;
                     if ($root['pay_money'] > 0) {
                         $root['show_pay_btn'] = 1;
                     }
                 } else {
                     if ($pay['pay_code'] == 'mtenpay') {
                         $root['pay_money_format'] = $pay['total_fee_format'];
                         $root['pay_money'] = $pay['total_fee'];
                         $root['pay_info'] = $pay['body'];
                         $root['mtenpay'] = $pay;
                         if ($root['pay_money'] > 0) {
                             $root['show_pay_btn'] = 1;
                         }
                     } else {
                         if ($pay['pay_code'] == 'mcod') {
                             $root['pay_money_format'] = $pay['total_fee_format'];
                             $root['pay_money'] = $pay['total_fee'];
                             $root['pay_info'] = $pay['body'];
                             $root['mcod'] = $pay;
                             $root['show_pay_btn'] = 0;
                         } else {
                             if ($pay['pay_code'] == 'walipay') {
                                 $root['pay_money_format'] = $pay['total_fee_format'];
                                 $root['pay_money'] = $pay['total_fee'];
                                 $root['pay_info'] = $pay['body'];
                                 $root['walipay'] = $pay;
                                 if ($root['pay_money'] > 0) {
                                     $root['show_pay_btn'] = 1;
                                 }
                             } else {
                                 if ($pay['pay_code'] == 'wtenpay') {
                                     $root['pay_money_format'] = $pay['total_fee_format'];
                                     $root['pay_money'] = $pay['total_fee'];
                                     $root['pay_info'] = $pay['body'];
                                     $root['wtenpay'] = $pay;
                                     if ($root['pay_money'] > 0) {
                                         $root['show_pay_btn'] = 1;
                                     }
                                 } else {
                                     $root['return'] = 0;
                                     $root['pay_info'] = '手机版本不支付,无法在手机上支付.';
                                     $root['show_pay_btn'] = 0;
                                 }
                             }
                         }
                     }
                 }
             }
             output($root);
         }
         // fwb update 2014-08-27
     } else {
         $root['user_login_status'] = 0;
         output($root);
     }
 }
Beispiel #12
0
//需http://格式的完整路径,不允许加?id=123这类自定义参数
//页面跳转同步通知页面路径
$call_back_url = SITE_DOMAIN . APP_ROOT . "/call_back_url.php";
//需http://格式的完整路径,不允许加?id=123这类自定义参数
//卖家支付宝帐户
$seller_email = $alipay_config['account'];
//必填
//商户网站订单系统中唯一订单号,必填
//订单名称
$subject = $order['order_sn'];
//必填
//付款金额
$pay_price = $order['total_price'] - $order['pay_amount'];
if ($payment_info && $pay_price > 0) {
    require_once APP_ROOT_PATH . "system/libs/cart.php";
    $payment_notice_id = make_payment_notice($pay_price, $order_id, $payment_info['id']);
    //创建支付接口的付款单
}
//创建了支付单号,通过支付接口创建支付数据
require_once APP_ROOT_PATH . "system/payment/" . $payment_info['class_name'] . "_payment.php";
$payment_class = $payment_info['class_name'] . "_payment";
$payment_object = new $payment_class();
$pay = $payment_object->get_payment_code($payment_notice_id);
//商户订单号
$out_trade_no = $pay['out_trade_no'];
$total_fee = $pay['total_fee'];
//必填
//请求业务参数详细
$req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee></direct_trade_create_req>';
//必填
/************************************************************/
 public function index()
 {
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $money = floatval($user['money']);
     $root = array();
     $root['return'] = 1;
     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;
         }
         $payment = intval($GLOBALS['request']['payment_id']);
         $account_money = floatval($GLOBALS['request']['use_user_money']);
         $address = strim($GLOBALS['request']['delivery_detail']);
         $consignee_mobile = strim($GLOBALS['request']['phone']);
         $zip = strim($GLOBALS['request']['postcode']);
         $consignee = strim($GLOBALS['request']['consignee']);
         $ecvsn = $GLOBALS['request']['ecv_sn'] ? strim($GLOBALS['request']['ecv_sn']) : '';
         $ecvpassword = $GLOBALS['request']['ecv_pwd'] ? strim($GLOBALS['request']['ecv_pwd']) : '';
         $order_memo = strim($GLOBALS['request']['content']);
         $send_mobile = strim($GLOBALS['request']['send_mobile']);
         $delivery_id = intval($GLOBALS['request']['delivery_id']);
         //$delivery_id = intval($GLOBALS['m_config']['delivery_id']);
         $account_pay = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where class_name = 'Account'");
         if ($account_pay) {
             $all_account_money = 1;
         } else {
             $all_account_money = 0;
         }
         $res = insertCartData($user_id, session_id(), $GLOBALS['request']['cartdata']);
         if ($res['info'] != '') {
             //失败有错误
             $root['status'] = 0;
             $root['info'] = $res['info'];
             output($root);
         } else {
             //可以提交订单
             $goods_list = $res['data'];
             require_once APP_ROOT_PATH . "system/libs/cart.php";
             $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;
             }
             $data = count_buy_total($region_id, $delivery_id, $payment, $account_money, $all_account_money, $ecvsn, $ecvpassword, $goods_list);
             if ($data['is_delivery'] == 1) {
                 //配送验证
                 if (!$data['region_info'] || $data['region_info']['region_level'] != 4) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_CONSIGNEE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($address == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ADDRESS'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($zip == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_ZIP'];
                     $root['status'] = 0;
                     output($root);
                 } elseif ($consignee_mobile == '') {
                     $root['info'] = $GLOBALS['lang']['FILL_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!check_mobile(trim($consignee_mobile))) {
                     $root['info'] = $GLOBALS['lang']['FILL_CORRECT_MOBILE_PHONE'];
                     $root['status'] = 0;
                     output($root);
                 } elseif (!$data['delivery_info']) {
                     $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_DELIVERY'];
                     $root['status'] = 0;
                     output($root);
                 }
             }
             if (round($data['pay_price'], 4) > 0 && !$data['payment_info']) {
                 $root['info'] = $GLOBALS['lang']['PLEASE_SELECT_PAYMENT'];
                 $root['status'] = 0;
                 output($root);
             } else {
                 //验证成功
                 //开始生成订单
                 $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($order_memo);
                 $order['region_lv1'] = $region1_id;
                 $order['region_lv2'] = $region2_id;
                 $order['region_lv3'] = $region3_id;
                 $order['region_lv4'] = $region4_id;
                 $order['address'] = htmlspecialchars($address);
                 $order['mobile'] = htmlspecialchars($consignee_mobile);
                 $order['consignee'] = htmlspecialchars($consignee);
                 $order['zip'] = htmlspecialchars($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'] = 0;
                 if ($send_mobile != '') {
                     $GLOBALS['db']->query("update " . DB_PREFIX . "user set mobile = '" . $send_mobile . "' where id = " . $user_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);
                 //end 验证成功提交订单成功
                 //开始生成订单产品以及支付
                 //生成订单商品
                 foreach ($goods_list as $k => $v) {
                     $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'];
                     $deal_info = load_auto_cache("cache_deal_cart", array("id" => $v['deal_id']));
                     $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);
                 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'] = $region1_id;
                     $user_consignee['region_lv2'] = $region2_id;
                     $user_consignee['region_lv3'] = $region3_id;
                     $user_consignee['region_lv4'] = $region4_id;
                     $user_consignee['address'] = htmlspecialchars($address);
                     $user_consignee['mobile'] = htmlspecialchars($consignee_mobile);
                     $user_consignee['consignee'] = htmlspecialchars($consignee);
                     $user_consignee['zip'] = htmlspecialchars($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) {
                     $GLOBALS['payment_lang'] = array('name' => '余额支付', 'account_credit' => '帐户余额', 'use_user_money' => '使用余额支付', 'use_all_money' => '全额支付', 'USER_ORDER_PAID' => '%s订单付款,付款单号%s');
                     $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);
                 }
                 $root['order_id'] = $order_id;
                 $rs = order_paid($order_id);
                 if ($rs) {
                     $root['pay_status'] = 1;
                 } else {
                     $root['pay_status'] = 0;
                 }
                 //end 订单产品生成及支付
                 $root['status'] = 1;
             }
             //end 提交订单
         }
     } else {
         $root['user_login_status'] = 1;
         $root['status'] = 0;
         //未登录
     }
     output($root);
 }