Esempio n. 1
0
 /**
  * 生成订单
  */
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $taxes = IFilter::act(IReq::get('taxes'), 'float');
     $insured = IFilter::act(IReq::get('insured'), 'float');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = IFilter::act(IReq::get('direct_gid'), 'int');
     $num = IFilter::act(IReq::get('direct_num'), 'int');
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = IFilter::act(IReq::get('direct_active_id'), 'int');
     $takeself = IFilter::act(IReq::get('takeself'), 'int');
     $order_no = Order_Class::createOrderNum();
     $order_type = 0;
     $dataArray = array();
     //pr($_POST);
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //配送方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id);
     if ($deliveryRow['type'] == 0) {
         if ($payment == 0) {
             IError::show(403, '请选择正确的支付方式');
         }
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         } else {
             if ($deliveryRow['type'] == 2) {
                 if ($takeself == 0) {
                     IError::show(403, '请选择正确的自提点');
                 }
             }
         }
     }
     //如果不是自提方式自动清空自提点
     if ($deliveryRow['type'] != 2) {
         $takeself = 0;
     }
     //计算费用
     $countSumObj = new CountSum($user_id);
     //直接购买商品方式
     if ($type && $gid) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         IInterceptor::reg("cart@onFinishAction");
     }
     //判断商品商品是否存在
     if (is_string($goodsResult) || empty($goodsResult['goodsList'])) {
         IError::show(403, '商品数据错误');
         exit;
     }
     //需要选择的地址数
     $need_choose_addr_num = 1;
     if (count($goodsResult['goodsList']) == 1 && $goodsResult['count'] > 1) {
         $need_choose_addr_num = $goodsResult['count'];
     }
     //匹配收获地址
     $address_arr = IFilter::act(IReq::get('radio_address'), 'int');
     if (count($address_arr) != $need_choose_addr_num) {
         IError::show(403, '请选择' . $need_choose_addr_num . '个收货地址');
         exit;
     }
     //加入促销活动
     if ($promo && $active_id) {
         $activeObject = new Active($promo, $active_id, $user_id, $gid, $type, $num);
         $order_type = $activeObject->getOrderType();
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     $paymentObj = new IModel('payment');
     $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name');
     $paymentName = $paymentRow['name'];
     $paymentType = $paymentRow['type'];
     //记录seller_id
     $seller_id = 0;
     if ($gid) {
         $goodsObj = new IModel("goods");
         $sell = $goodsObj->getObj("id = " . $gid, 'seller_id');
         if ($sell['seller_id'] > 0) {
             $seller_id = $sell['seller_id'];
         }
     }
     //最终订单金额计算
     $orderData = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $province, $delivery_id, $payment, $goodsResult['freeFreight'], $insured, $taxes);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $orderData['deliveryOrigPrice'], 'real_freight' => $orderData['deliveryPrice'], 'pay_fee' => $orderData['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $taxes, 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'] + (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'order_amount' => $orderData['orderAmountPrice'] - (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'if_insured' => $insured ? 1 : 0, 'insured' => $insured, 'takeself' => $takeself, 'active_id' => $active_id, 'seller_id' => $seller_id, 'address_id' => implode(',', $address_arr));
     $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount'];
     if ($seller_id) {
         $sellerObj = new IModel('seller');
         $seller = $sellerObj->getObj("id = '{$seller_id}'");
         if ($seller) {
             //商家的预存款不足以扣除订单总价的1.2%
             $nedd = floatval($dataArray['order_amount'] * (1.2 * 0.01));
             if ($seller['balance'] <= 0 || $seller['balance'] < $nedd) {
                 IError::show(403, '商家预存款不足,不能进行购买');
                 exit;
             }
         }
     }
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderInstance = new Order_Class();
     $orderInstance->insertOrderGoods($this->order_id, $goodsResult);
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id, 'takeself' => $takeself)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     /* if($user_id)
     		{
     			$addressObj = new IModel('address');
     
     			//如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
     			$addressRow = $addressObj->getObj('user_id = '.$user_id);
     			if(empty($addressRow))
     			{
     				$addressData = array('default'=>'1','user_id'=>$user_id,'accept_name'=>$accept_name,'province'=>$province,'city'=>$city,'area'=>$area,'address'=>$address,'zip'=>$zip,'telphone'=>$telphone,'mobile'=>$mobile);
     				$addressObj->setData($addressData);
     				$addressObj->add();
     			}
     			else
     			{
     				//如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
     				$radio_address = intval(IReq::get('radio_address'));
     				if($radio_address != 0)
     				{
     					$addressDefRow = $addressObj->getObj('user_id = '.$user_id.' and `default` = 1');
     					if(empty($addressDefRow))
     					{
     						$addressData = array('default' => 1);
     						$addressObj->setData($addressData);
     						$addressObj->update('user_id = '.$user_id.' and id = '.$radio_address);
     					}
     				}
     			}
     		} */
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment = $paymentName;
     $this->paymentType = $paymentType;
     $this->delivery = $deliveryRow['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = Order_Class::updateOrderStatus($dataArray['order_no']);
         if ($order_id) {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->setRenderData($dataArray);
         $this->redirect('cart3');
     }
 }
Esempio n. 2
0
 /**
  * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户;
  * @param $payment_id int    支付方式ID
  * @param $type       string 信息获取方式 order:订单支付;recharge:在线充值;
  * @param $argument   mix    参数
  * @return array 支付提交信息
  */
 public static function getPaymentInfo($payment_id, $type, $argument)
 {
     //最终返回值
     $payment = array();
     //初始化配置参数
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     $configParam = $paymentInstance->configParam();
     foreach ($configParam as $key => $val) {
         $payment[$key] = '';
     }
     //获取公共信息
     $paymentRow = self::getPaymentById($payment_id, 'config_param');
     if ($paymentRow) {
         $paymentRow = JSON::decode($paymentRow);
         foreach ($paymentRow as $key => $item) {
             $payment[$key] = $item;
         }
     }
     if ($type == 'order') {
         $orderIdArray = $argument;
         $M_Amount = 0;
         $M_OrderNO = array();
         foreach ($orderIdArray as $key => $order_id) {
             //获取订单信息
             $orderObj = new IModel('order');
             $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
             if (empty($orderRow)) {
                 IError::show(403, '订单信息不正确,不能进行支付');
             }
             //判断商品库存
             $orderGoodsDB = new IModel('order_goods');
             $orderGoodsList = $orderGoodsDB->query('order_id = ' . $order_id);
             foreach ($orderGoodsList as $key => $val) {
                 if (!goods_class::checkStore($val['goods_nums'], $val['goods_id'], $val['product_id'])) {
                     IError::show(403, '商品库存不足无法支付,请重新下单');
                 }
             }
             $M_Amount += $orderRow['order_amount'];
             $M_OrderNO[] = $orderRow['order_no'];
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $M_Amount;
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
         //订单批量结算缓存机制
         $cacheObj = new ICache('file');
         $cacheObj->set($payment['M_OrderNO'], join(",", $M_OrderNO));
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Time'] = time();
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     return $payment;
 }
Esempio n. 3
0
 /**
  * @brief 保存修改订单
  */
 public function order_update()
 {
     //获取必要数据
     $order_id = IReq::get('id');
     //生成order数据
     $dataArray['invoice_title'] = IFilter::act(IReq::get('invoice_title'));
     $dataArray['invoice'] = IFilter::act(IReq::get('invoice'), 'int');
     $dataArray['insured'] = IFilter::act(IReq::get('insured'), 'float');
     $dataArray['if_insured'] = IFilter::act(IReq::get('if_insured'), 'int');
     $dataArray['pay_type'] = IFilter::act(IReq::get('pay_type'), 'int');
     $dataArray['accept_name'] = IFilter::act(IReq::get('accept_name'));
     $dataArray['postcode'] = IFilter::act(IReq::get('postcode'));
     $dataArray['telphone'] = IFilter::act(IReq::get('telphone'));
     $dataArray['province'] = IFilter::act(IReq::get('province'), 'int');
     $dataArray['city'] = IFilter::act(IReq::get('city'), 'int');
     $dataArray['area'] = IFilter::act(IReq::get('area'), 'int');
     $dataArray['address'] = IFilter::act(IReq::get('address'));
     $dataArray['mobile'] = IFilter::act(IReq::get('mobile'));
     $dataArray['discount'] = IFilter::act(IReq::get('discount'), 'float');
     $dataArray['postscript'] = IFilter::act(IReq::get('postscript'));
     $dataArray['distribution'] = IFilter::act(IReq::get('distribution'), 'int');
     $dataArray['accept_time'] = IFilter::act(IReq::get('accept_time'));
     $goods_id = IFilter::act(IReq::get('goods_id'));
     $product_id = IFilter::act(IReq::get('product_id'));
     $goods_nuns = IFilter::act(IReq::get('goods_nums'));
     //设置订单持有者
     $username = IFilter::act(IReq::get('username'));
     $userDB = new IModel('user');
     $userRow = $userDB->getObj('username = "******"');
     $dataArray['user_id'] = isset($userRow['id']) ? $userRow['id'] : 0;
     //拼接要购买的商品或货品数据,组装成固有的数据结构便于计算价格
     $length = count($product_id);
     $buyInfo = array('goods' => array('id' => array(), 'data' => array()), 'product' => array('id' => array(), 'data' => array()));
     for ($i = 0; $i < $length; $i++) {
         //货品数据
         if (intval($product_id[$i]) > 0) {
             $buyInfo['product']['id'][] = $product_id[$i];
             $buyInfo['product']['data'][$product_id[$i]] = array('count' => $goods_nuns[$i]);
         } else {
             $buyInfo['goods']['id'][] = $goods_id[$i];
             $buyInfo['goods']['data'][$goods_id[$i]] = array('count' => $goods_nuns[$i]);
         }
     }
     //开始算账
     $countSumObj = new CountSum();
     $goodsResult = $countSumObj->goodsCount($buyInfo);
     $orderFee = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $dataArray['province'], $dataArray['distribution'], $dataArray['pay_type'], $goodsResult['freeFreight'], $dataArray['if_insured'], $dataArray['invoice'], $dataArray['discount']);
     //获取原价的运费
     $dataArray['payable_freight'] = $orderFee['deliveryOrigPrice'];
     $dataArray['payable_amount'] = $goodsResult['sum'];
     $dataArray['real_amount'] = $goodsResult['final_sum'];
     $dataArray['real_freight'] = $orderFee['deliveryPrice'];
     $dataArray['insured'] = $orderFee['insuredPrice'];
     $dataArray['pay_fee'] = $orderFee['paymentPrice'];
     $dataArray['taxes'] = $orderFee['taxPrice'];
     $dataArray['promotions'] = $goodsResult['proReduce'] + $goodsResult['reduce'];
     $dataArray['order_amount'] = $orderFee['orderAmountPrice'];
     $dataArray['exp'] = $goodsResult['exp'];
     $dataArray['point'] = $goodsResult['point'];
     //生成订单
     $orderDB = new IModel('order');
     //修改操作
     if ($order_id) {
         $orderDB->setData($dataArray);
         $orderDB->update('id = ' . $order_id);
         //获取订单信息
         $orderRow = $orderDB->getObj('id = ' . $order_id);
         //记录日志信息
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "修改了订单信息", '订单号:' . $orderRow['order_no']));
     } else {
         $dataArray['create_time'] = date('Y-m-d H:i:s');
         $dataArray['order_no'] = Order_Class::createOrderNum();
         $orderDB->setData($dataArray);
         $order_id = $orderDB->add();
         //记录日志信息
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "添加了订单信息", '订单号:' . $dataArray['order_no']));
     }
     //同步order_goods表
     $orderInstance = new Order_Class();
     $orderInstance->insertOrderGoods($order_id, $goodsResult);
     $this->redirect('order_list');
 }
Esempio n. 4
0
 /**
  * @brief 保存修改订单
  */
 public function order_update()
 {
     //获取必要数据
     $order_id = IFilter::act(IReq::get('id'), 'int');
     //生成order数据
     $dataArray['invoice_title'] = IFilter::act(IReq::get('invoice_title'));
     $dataArray['invoice'] = IFilter::act(IReq::get('invoice'), 'int');
     $dataArray['pay_type'] = IFilter::act(IReq::get('pay_type'), 'int');
     $dataArray['accept_name'] = IFilter::act(IReq::get('accept_name'));
     $dataArray['postcode'] = IFilter::act(IReq::get('postcode'));
     $dataArray['telphone'] = IFilter::act(IReq::get('telphone'));
     $dataArray['province'] = IFilter::act(IReq::get('province'), 'int');
     $dataArray['city'] = IFilter::act(IReq::get('city'), 'int');
     $dataArray['area'] = IFilter::act(IReq::get('area'), 'int');
     $dataArray['address'] = IFilter::act(IReq::get('address'));
     $dataArray['mobile'] = IFilter::act(IReq::get('mobile'));
     $dataArray['discount'] = $order_id ? IFilter::act(IReq::get('discount'), 'float') : 0;
     $dataArray['postscript'] = IFilter::act(IReq::get('postscript'));
     $dataArray['distribution'] = IFilter::act(IReq::get('distribution'), 'int');
     $dataArray['accept_time'] = IFilter::act(IReq::get('accept_time'));
     $dataArray['takeself'] = IFilter::act(IReq::get('takeself'));
     //设置订单持有者
     $username = IFilter::act(IReq::get('username'));
     $userDB = new IModel('user');
     $userRow = $userDB->getObj('username = "******"');
     $dataArray['user_id'] = isset($userRow['id']) ? $userRow['id'] : 0;
     //拼接要购买的商品或货品数据,组装成固有的数据结构便于计算价格
     $goodsId = IFilter::act(IReq::get('goods_id'));
     $productId = IFilter::act(IReq::get('product_id'));
     $num = IFilter::act(IReq::get('goods_nums'));
     $goodsArray = array();
     $productArray = array();
     foreach ($goodsId as $key => $goods_id) {
         $pid = $productId[$key];
         $nVal = $num[$key];
         if ($pid > 0) {
             $productArray[$pid] = $nVal;
         } else {
             $goodsArray[$goods_id] = $nVal;
         }
     }
     //开始算账
     $countSumObj = new CountSum($dataArray['user_id']);
     $cartObj = new Cart();
     $goodsResult = $countSumObj->goodsCount($cartObj->cartFormat(array("goods" => $goodsArray, "product" => $productArray)));
     $orderData = $countSumObj->countOrderFee($goodsResult, $dataArray['province'], $dataArray['distribution'], $dataArray['pay_type'], $dataArray['invoice'], $dataArray['discount']);
     if (is_string($orderData)) {
         IError::show(403, $orderData);
         exit;
     }
     //根据商品所属商家不同批量生成订单
     foreach ($orderData as $seller_id => $goodsResult) {
         //获取原价的运费
         $dataArray['payable_freight'] = $goodsResult['deliveryOrigPrice'];
         $dataArray['payable_amount'] = $goodsResult['sum'];
         $dataArray['real_amount'] = $goodsResult['final_sum'];
         $dataArray['real_freight'] = $goodsResult['deliveryPrice'];
         $dataArray['insured'] = $goodsResult['insuredPrice'];
         $dataArray['pay_fee'] = $goodsResult['paymentPrice'];
         $dataArray['taxes'] = $goodsResult['taxPrice'];
         $dataArray['promotions'] = $goodsResult['proReduce'] + $goodsResult['reduce'];
         $dataArray['order_amount'] = $goodsResult['orderAmountPrice'];
         $dataArray['exp'] = $goodsResult['exp'];
         $dataArray['point'] = $goodsResult['point'];
         //商家ID
         $dataArray['seller_id'] = $seller_id;
         //生成订单
         $orderDB = new IModel('order');
         //修改操作
         if ($order_id) {
             //获取订单信息
             $orderRow = $orderDB->getObj('id = ' . $order_id);
             //修改订单不能加入其他商家产品
             if (count($orderData) != 1 || $orderRow['seller_id'] != $seller_id) {
                 IError::show(403, "此订单中不能混入其他商家的商品");
                 exit;
             }
             $orderDB->setData($dataArray);
             $orderDB->update('id = ' . $order_id);
             //记录日志信息
             $logObj = new log('db');
             $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "修改了订单信息", '订单号:' . $orderRow['order_no']));
         } else {
             $dataArray['create_time'] = date('Y-m-d H:i:s');
             $dataArray['order_no'] = Order_Class::createOrderNum();
             $orderDB->setData($dataArray);
             $order_id = $orderDB->add();
             //记录日志信息
             $logObj = new log('db');
             $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "添加了订单信息", '订单号:' . $dataArray['order_no']));
         }
         //同步order_goods表
         $orderInstance = new Order_Class();
         $orderInstance->insertOrderGoods($order_id, $goodsResult['goodsResult']);
     }
     $this->redirect('order_list');
 }
Esempio n. 5
0
 /**
  * 生成订单
  */
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $taxes = IFilter::act(IReq::get('taxes'), 'int');
     $tax_title = IFilter::act(IReq::get('tax_title'));
     $gid = IFilter::act(IReq::get('direct_gid'), 'int');
     $num = IFilter::act(IReq::get('direct_num'), 'int');
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = IFilter::act(IReq::get('direct_active_id'), 'int');
     $takeself = IFilter::act(IReq::get('takeself'), 'int');
     $ticketUserd = IFilter::act(IReq::get('ticketUserd'), 'int');
     $order_type = 0;
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //配送方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id);
     if ($deliveryRow['type'] == 0) {
         if ($payment == 0) {
             IError::show(403, '请选择正确的支付方式');
         }
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         } else {
             if ($deliveryRow['type'] == 2) {
                 if ($takeself == 0) {
                     IError::show(403, '请选择正确的自提点');
                 }
             }
         }
     }
     //如果不是自提方式自动清空自提点
     if ($deliveryRow['type'] != 2) {
         $takeself = 0;
     }
     //计算费用
     $countSumObj = new CountSum($user_id);
     $goodsResult = $countSumObj->cart_count($gid, $type, $num, $promo, $active_id);
     if (!$gid) {
         //清空购物车
         IInterceptor::reg("cart@onFinishAction");
     }
     //判断商品商品是否存在
     if (is_string($goodsResult) || empty($goodsResult['goodsList'])) {
         IError::show(403, '商品数据错误');
         exit;
     }
     //加入促销活动
     if ($promo && $active_id) {
         $activeObject = new Active($promo, $active_id, $user_id, $gid, $type, $num);
         $order_type = $activeObject->getOrderType();
     }
     $paymentObj = new IModel('payment');
     $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name');
     $paymentName = $paymentRow['name'];
     $paymentType = $paymentRow['type'];
     //最终订单金额计算
     $orderData = $countSumObj->countOrderFee($goodsResult, $province, $delivery_id, $payment, $taxes, 0, $promo, $active_id);
     if (is_string($orderData)) {
         IError::show(403, $orderData);
         exit;
     }
     //根据商品所属商家不同批量生成订单
     $orderIdArray = array();
     $orderNumArray = array();
     $final_sum = 0;
     foreach ($orderData as $seller_id => $goodsResult) {
         //生成的订单数据
         $dataArray = array('order_no' => Order_Class::createOrderNum(), 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $goodsResult['deliveryOrigPrice'], 'real_freight' => $goodsResult['deliveryPrice'], 'pay_fee' => $goodsResult['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $goodsResult['taxPrice'], 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'], 'order_amount' => $goodsResult['orderAmountPrice'], 'insured' => $goodsResult['insuredPrice'], 'takeself' => $takeself, 'active_id' => $active_id, 'seller_id' => $seller_id, 'note' => '');
         //获取红包减免金额
         if ($ticket_id && $ticketUserd == $seller_id) {
             $memberObj = new IModel('member');
             $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
             //游客手动添加或注册用户道具中已有的代金券
             if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
                 $propObj = new IModel('prop');
                 $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
                 if (!$ticketRow) {
                     IError::show(403, '代金券不可用');
                 }
                 if ($ticketRow['seller_id'] == 0 || $ticketRow['seller_id'] == $seller_id) {
                     $ticketRow['value'] = $ticketRow['value'] >= $goodsResult['final_sum'] ? $goodsResult['final_sum'] : $ticketRow['value'];
                     $dataArray['prop'] = $ticket_id;
                     $dataArray['promotions'] += $ticketRow['value'];
                     $dataArray['order_amount'] -= $ticketRow['value'];
                     $goodsResult['promotion'][] = array("plan" => "代金券", "info" => "使用了¥" . $ticketRow['value'] . "代金券");
                     //锁定红包状态
                     $propObj->setData(array('is_close' => 2));
                     $propObj->update('id = ' . $ticket_id);
                 }
             }
         }
         //促销规则
         if (isset($goodsResult['promotion']) && $goodsResult['promotion']) {
             foreach ($goodsResult['promotion'] as $key => $val) {
                 $dataArray['note'] .= " 【" . $val['info'] . "】 ";
             }
         }
         $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount'];
         //生成订单插入order表中
         $orderObj = new IModel('order');
         $orderObj->setData($dataArray);
         $order_id = $orderObj->add();
         if ($order_id == false) {
             IError::show(403, '订单生成错误');
         }
         /*将订单中的商品插入到order_goods表*/
         $orderInstance = new Order_Class();
         $orderInstance->insertOrderGoods($order_id, $goodsResult['goodsResult']);
         //订单金额小于等于0直接免单
         if ($dataArray['order_amount'] <= 0) {
             Order_Class::updateOrderStatus($dataArray['order_no']);
         } else {
             $orderIdArray[] = $order_id;
             $orderNumArray[] = $dataArray['order_no'];
             $final_sum += $dataArray['order_amount'];
         }
     }
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id, 'takeself' => $takeself)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
         if (!$addressDefRow) {
             $radio_address = IFilter::act(IReq::get('radio_address'), 'int');
             $addressObj->setData(array('default' => 1));
             $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_id = join(",", $orderIdArray);
     $this->final_sum = $final_sum;
     $this->order_num = join(",", $orderNumArray);
     $this->payment = $paymentName;
     $this->paymentType = $paymentType;
     $this->delivery = $deliveryRow['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order');
     } else {
         $this->setRenderData($dataArray);
         $this->redirect('cart3');
     }
 }
Esempio n. 6
0
 /**
  * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户;
  * @param $payment_id 			int    支付方式ID
  * @param $type      			string 信息获取方式 order:订单支付;recharge:在线充值;
  * @param $argument   			mix    参数
  * @return array 支付提交信息
  */
 public static function getPaymentInfo($payment_id, $type, $argument)
 {
     //最终返回值
     $payment = array();
     //初始化配置参数
     $paymentInstance = Payment::createPaymentInstance($payment_id);
     $configParam = $paymentInstance->configParam();
     foreach ($configParam as $key => $val) {
         $payment[$key] = '';
     }
     //获取公共信息
     $paymentRow = self::getPaymentById($payment_id, 'config_param');
     if ($paymentRow) {
         $paymentRow = JSON::decode($paymentRow);
         foreach ($paymentRow as $key => $item) {
             $payment[$key] = $item;
         }
     }
     //print_r($payment);die;
     if ($type == 'order') {
         $order_id = $argument;
         //获取订单信息
         $orderObj = new IModel('order');
         $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
         if (empty($orderRow)) {
             IError::show(403, '订单信息不正确,不能进行支付');
         }
         //是商家的订单的话,收款信息为商家个人
         if ($orderRow['seller_id'] > 0) {
             $configParam = $paymentInstance->sellerConfigParam($orderRow['seller_id']);
             if ($configParam == 0) {
                 IError::show(403, '商家收款信息未填写,不能进行支付');
             } else {
                 //重写收款信息
                 foreach ($configParam as $key => $val) {
                     $payment[$key] = $val;
                 }
             }
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $orderRow['order_amount'];
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Time'] = time();
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     return $payment;
 }
Esempio n. 7
0
 /**
  * @brief 获取订单中的支付信息 M:必要信息; R表示店铺; P表示用户;
  * @param $payment_id int    支付方式ID
  * @param $type       string 信息获取方式 order:订单支付;recharge:在线充值;
  * @param $argument   mix    参数
  * @return array 支付提交信息
  */
 public static function getPaymentInfo($payment_id, $type, $argument)
 {
     //最终返回值
     $payment = array();
     //获取公共信息
     $paymentRow = self::getPaymentById($payment_id);
     $payment['M_PartnerId'] = $paymentRow['partner_id'];
     $payment['M_PartnerKey'] = $paymentRow['partner_key'];
     if ($type == 'order') {
         $order_id = $argument;
         //获取订单信息
         $orderObj = new IModel('order');
         $orderRow = $orderObj->getObj('id = ' . $order_id . ' and status = 1');
         if (empty($orderRow)) {
             IError::show(403, '订单信息不正确,不能进行支付');
         }
         $payment['M_Remark'] = $orderRow['postscript'];
         $payment['M_OrderId'] = $orderRow['id'];
         $payment['M_OrderNO'] = $orderRow['order_no'];
         $payment['M_Amount'] = $orderRow['order_amount'];
         //用户信息
         $payment['P_Mobile'] = $orderRow['mobile'];
         $payment['P_Name'] = $orderRow['accept_name'];
         $payment['P_PostCode'] = $orderRow['postcode'];
         $payment['P_Telephone'] = $orderRow['telphone'];
         $payment['P_Address'] = $orderRow['address'];
     } else {
         if ($type == 'recharge') {
             if (ISafe::get('user_id') == null) {
                 IError::show(403, '请登录系统');
             }
             if (!isset($argument['account']) || $argument['account'] <= 0) {
                 IError::show(403, '请填入正确的充值金额');
             }
             $rechargeObj = new IModel('online_recharge');
             $reData = array('user_id' => ISafe::get('user_id'), 'recharge_no' => Order_Class::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['paymentName']);
             $rechargeObj->setData($reData);
             $r_id = $rechargeObj->add();
             //充值时用户id跟随交易号一起发送,以"_"分割
             $payment['M_OrderNO'] = 'recharge_' . $reData['recharge_no'];
             $payment['M_OrderId'] = $r_id;
             $payment['M_Amount'] = $reData['account'];
         }
     }
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //交易信息
     $payment['M_Time'] = time();
     $payment['M_Paymentid'] = $payment_id;
     //店铺信息
     $payment['R_Address'] = isset($site_config['address']) ? $site_config['address'] : '';
     $payment['R_Name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $payment['R_Mobile'] = isset($site_config['mobile']) ? $site_config['mobile'] : '';
     $payment['R_Telephone'] = isset($site_config['phone']) ? $site_config['phone'] : '';
     return $payment;
 }
Esempio n. 8
0
 /**
  * 生成订单
  */
 function cart3()
 {
     $accept_name = IFilter::act(IReq::get('accept_name'));
     $province = IFilter::act(IReq::get('province'), 'int');
     $city = IFilter::act(IReq::get('city'), 'int');
     $area = IFilter::act(IReq::get('area'), 'int');
     $address = IFilter::act(IReq::get('address'));
     $mobile = IFilter::act(IReq::get('mobile'));
     $telphone = IFilter::act(IReq::get('telphone'));
     $zip = IFilter::act(IReq::get('zip'));
     $delivery_id = IFilter::act(IReq::get('delivery_id'), 'int');
     $accept_time = IFilter::act(IReq::get('accept_time'));
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $order_message = IFilter::act(IReq::get('message'));
     $ticket_id = IFilter::act(IReq::get('ticket_id'), 'int');
     $taxes = IFilter::act(IReq::get('taxes'), 'float');
     $insured = IFilter::act(IReq::get('insured'), 'float');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = IFilter::act(IReq::get('direct_gid'), 'int');
     $num = IFilter::act(IReq::get('direct_num'), 'int');
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者货品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = IFilter::act(IReq::get('direct_active_id'), 'int');
     $order_no = Order_Class::createOrderNum();
     $order_type = 0;
     $dataArray = array();
     //防止表单重复提交
     if (IReq::get('timeKey') != null) {
         if (ISafe::get('timeKey') == IReq::get('timeKey')) {
             IError::show(403, '订单数据不能被重复提交');
             exit;
         } else {
             ISafe::set('timeKey', IReq::get('timeKey'));
         }
     }
     if ($province == 0 || $city == 0 || $area == 0) {
         IError::show(403, '请填写收货地址的省市地区');
     }
     if ($delivery_id == 0) {
         IError::show(403, '请选择配送方式');
     }
     $user_id = $this->user['user_id'] == null ? 0 : $this->user['user_id'];
     //活动特殊处理
     if ($promo != '' && $active_id != '') {
         //团购
         if ($promo == 'groupon') {
             $hashId = $user_id ? $user_id : ICookie::get("regiment_{$active_id}");
             //此团购还存在已经报名但是未付款的情况
             if (regiment::hasJoined($active_id, $hashId) == true) {
                 IError::show(403, '您已经参加过此次团购,请先完成支付');
                 exit;
             }
             //团购已经达到限定的人数
             if (regiment::isFull($active_id) == true) {
                 IError::show(403, '此团购的参加人数已满');
                 exit;
             }
             $order_type = 1;
             //团购开始报名
             $joinUserId = $user_id ? $user_id : null;
             $resultData = regiment::join($active_id, $joinUserId);
             $is_success = '';
             if ($resultData['flag'] == true) {
                 $regimentRelationObj = new IModel('regiment_user_relation');
                 $regimentRelationObj->setData(array('order_no' => $order_no));
                 $is_success = $regimentRelationObj->update('id = ' . $resultData['relation_id']);
             }
             if ($is_success == '' || $resultData['flag'] == false) {
                 $errorMsg = isset($resultData['data']) && $resultData['data'] != '' ? $resultData['data'] : '团购报名失败';
                 IError::show(403, $errorMsg);
                 exit;
             }
         } else {
             if ($promo == 'time') {
                 $order_type = 2;
             }
         }
     }
     //付款方式,判断是否为货到付款
     $deliveryObj = new IModel('delivery');
     $deliveryRow = $deliveryObj->getObj('id = ' . $delivery_id);
     if ($deliveryRow['type'] == 0 && $payment == 0) {
         IError::show(403, '请选择支付方式');
     } else {
         if ($deliveryRow['type'] == 1) {
             $payment = 0;
         }
     }
     //计算费用
     $countSumObj = new CountSum();
     //直接购买商品方式
     if ($type != '' && $gid != 0) {
         //计算$gid商品
         $goodsResult = $countSumObj->direct_count($gid, $type, $num, $promo, $active_id);
     } else {
         //计算购物车中的商品价格$goodsResult
         $goodsResult = $countSumObj->cart_count();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     //获取红包减免金额
     if ($ticket_id != '') {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'prop,custom');
         if (ISafe::get('ticket_' . $ticket_id) == $ticket_id || stripos(',' . trim($memberRow['prop'], ',') . ',', ',' . $ticket_id . ',') !== false) {
             $propObj = new IModel('prop');
             $ticketRow = $propObj->getObj('id = ' . $ticket_id . ' and NOW() between start_time and end_time and type = 0 and is_close = 0 and is_userd = 0 and is_send = 1');
             if (!empty($ticketRow)) {
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $paymentType = 0;
     } else {
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,name');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
     }
     //最终订单金额计算
     $orderData = $countSumObj->countOrderFee($goodsResult['sum'], $goodsResult['final_sum'], $goodsResult['weight'], $province, $delivery_id, $payment, $goodsResult['freeFreight'], $insured, $taxes);
     //生成的订单数据
     $dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'postscript' => $order_message, 'accept_time' => $accept_time, 'exp' => $goodsResult['exp'], 'point' => $goodsResult['point'], 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $orderData['deliveryOrigPrice'], 'real_freight' => $orderData['deliveryPrice'], 'pay_fee' => $orderData['paymentPrice'], 'invoice' => $taxes ? 1 : 0, 'invoice_title' => $tax_title, 'taxes' => $taxes, 'promotions' => $goodsResult['proReduce'] + $goodsResult['reduce'] + (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'order_amount' => $orderData['orderAmountPrice'] - (isset($ticketRow['value']) ? $ticketRow['value'] : 0), 'if_insured' => $insured ? 1 : 0, 'insured' => $insured);
     $dataArray['order_amount'] = $dataArray['order_amount'] <= 0 ? 0 : $dataArray['order_amount'];
     $orderObj = new IModel('order');
     $orderObj->setData($dataArray);
     $this->order_id = $orderObj->add();
     if ($this->order_id == false) {
         IError::show(403, '订单生成错误');
     }
     /*将订单中的商品插入到order_goods表*/
     $orderInstance = new Order_Class();
     $orderInstance->insertOrderGoods($this->order_id, $goodsResult);
     //记录用户默认习惯的数据
     if (!isset($memberRow['custom'])) {
         $memberObj = new IModel('member');
         $memberRow = $memberObj->getObj('user_id = ' . $user_id, 'custom');
     }
     $memberData = array('custom' => serialize(array('payment' => $payment, 'delivery' => $delivery_id)));
     $memberObj->setData($memberData);
     $memberObj->update('user_id = ' . $user_id);
     //收货地址的处理
     if ($user_id) {
         $addressObj = new IModel('address');
         //如果用户之前没有收货地址,那么会自动记录此次的地址信息并且为默认
         $addressRow = $addressObj->getObj('user_id = ' . $user_id);
         if (empty($addressRow)) {
             $addressData = array('default' => '1', 'user_id' => $user_id, 'accept_name' => $accept_name, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'zip' => $zip, 'telphone' => $telphone, 'mobile' => $mobile);
             $addressObj->setData($addressData);
             $addressObj->add();
         } else {
             //如果用户有收货地址,但是没有设置默认项,那么会自动设置此次地址信息为默认
             $radio_address = intval(IReq::get('radio_address'));
             if ($radio_address != 0) {
                 $addressDefRow = $addressObj->getObj('user_id = ' . $user_id . ' and `default` = 1');
                 if (empty($addressDefRow)) {
                     $addressData = array('default' => 1);
                     $addressObj->setData($addressData);
                     $addressObj->update('user_id = ' . $user_id . ' and id = ' . $radio_address);
                 }
             }
         }
     }
     //获取备货时间
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->stockup_time = isset($site_config['stockup_time']) ? $site_config['stockup_time'] : 2;
     //数据渲染
     $this->order_num = $dataArray['order_no'];
     $this->final_sum = $dataArray['order_amount'];
     $this->payment = $paymentName;
     $this->paymentType = $paymentType;
     $this->delivery = $deliveryRow['name'];
     $this->tax_title = $tax_title;
     $this->deliveryType = $deliveryRow['type'];
     //订单金额为0时,订单自动完成
     if ($this->final_sum <= 0) {
         $order_id = Order_Class::updateOrderStatus($dataArray['order_no']);
         if ($order_id != '') {
             if ($user_id) {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货") . '/?callback=ucenter/order_detail/id/' . $order_id);
             } else {
                 $this->redirect('/site/success/message/' . urlencode("订单确认成功,等待发货"));
             }
         } else {
             IError::show(403, '订单修改失败');
         }
     } else {
         $this->setRenderData($dataArray);
         $this->redirect('cart3');
     }
 }