當前位置: 首頁>>代碼示例>>PHP>>正文


PHP block::createOrderNum方法代碼示例

本文整理匯總了PHP中block::createOrderNum方法的典型用法代碼示例。如果您正苦於以下問題:PHP block::createOrderNum方法的具體用法?PHP block::createOrderNum怎麽用?PHP block::createOrderNum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在block的用法示例。


在下文中一共展示了block::createOrderNum方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: order_update

 /**
  * @brief 保存添加訂單
  * */
 public function order_update()
 {
     //獲取post參數-----order表中
     $user_id = IFilter::act(IReq::get('user_id'), 'int');
     $payment = IFilter::act(IReq::get('payment'), 'int');
     $payable_amount = IFilter::act(IReq::get('total'), 'float');
     $real_amount = IFilter::act(IReq::get('real_total'), 'float');
     $payable_freight = IFilter::act(IReq::get('delivery_price'), 'float');
     $real_freight = IFilter::act(IReq::get('real_freight'), 'float');
     $taxes = IFilter::act(IReq::get('taxes'), 'float');
     $pay_fee = IFilter::act(IReq::get('pay_fee'), 'float');
     $order_no = block::createOrderNum();
     //獲得貨到付款
     $pay_type = IFilter::act(IReq::get('pay_type'));
     if ($pay_type == 1) {
         $payment = IFilter::act(IReq::get('paymen'), 'int');
     }
     //獲得order表對象
     $tb_order = new IModel('order');
     $tb_order->setData(array('user_id' => $user_id, 'accept_name' => IFilter::act(IReq::get('accept_name')), 'pay_code' => IFilter::act(IReq::get('pay_code')), 'distribution' => IFilter::act(IReq::get('delivery'), 'int'), 'pay_type' => $payment, 'status' => 1, 'pay_status' => 0, 'distribution_status' => 0, 'postcode' => IFilter::act(IReq::get('postcode')), 'telphone' => IFilter::act(IReq::get('telphone')), 'province' => IFilter::act(IReq::get('province'), 'int'), 'city' => IFilter::act(IReq::get('city'), 'int'), 'area' => IFilter::act(IReq::get('area'), 'int'), 'mobile' => IFilter::act(IReq::get('mobile')), 'address' => IFilter::act(IReq::get('address')), 'postscript' => IFilter::act(IReq::get('postscript')), 'create_time' => date('Y-m-d H:i:s'), 'payable_amount' => $payable_amount, 'real_amount' => $real_amount, 'payable_freight' => $payable_freight, 'real_freight' => $real_freight, 'order_no' => $order_no, 'invoice' => IFilter::act(IReq::get('invoice'), 'int'), 'invoice_title' => IFilter::act(IReq::get('invoice_title')), 'promotions' => $payable_amount - $real_amount, 'taxes' => $taxes, 'pay_fee' => $pay_fee, 'order_amount' => $real_amount + $real_freight + $taxes + $pay_fee, 'accept_time' => '任意'));
     //保存order數據,並且獲得order_id
     $order_id = $tb_order->add();
     //實付總金額
     $real_amount = 0;
     //第二步獲得order_goods表的內容,包括order_id,goods_id,products_id等主要項目
     $goods_id = IFilter::act(IReq::get('goods_id'));
     $product_id = IFilter::act(IReq::get('p_id'));
     $goods_price = IFilter::act(IReq::get('price'));
     $real_price = IFilter::act(IReq::get('real_price'));
     $goods_nums = IFilter::act(IReq::get('number'));
     $goods_weight = IFilter::act(IReq::get('weight'));
     $g_id_arr = explode(',', $goods_id);
     $p_id_arr = explode(',', $product_id);
     $g_pr_arr = explode(',', $goods_price);
     $r_pr_arr = explode(',', $real_price);
     $g_nu_arr = explode(',', $goods_nums);
     $g_we_arr = explode(',', $goods_weight);
     $point = 0;
     $exp = 0;
     //循環保存order_goods表中數據
     $tb_goods = new IModel('goods');
     $tb_order_goods = new IModel('order_goods');
     $tb_products = new IModel('products');
     foreach ($g_id_arr as $key => $value) {
         //根據會員組獲得產品的實際價格
         $tb_order_goods->setData(array('order_id' => $order_id, 'goods_id' => $g_id_arr[$key], 'product_id' => $p_id_arr[$key], 'goods_price' => $g_pr_arr[$key], 'real_price' => $r_pr_arr[$key], 'goods_nums' => $g_nu_arr[$key], 'goods_weight' => $g_we_arr[$key]));
         $og_id = $tb_order_goods->add();
         $ids = array();
         $ids['name'] = '';
         $info = $tb_goods->query('id=' . $g_id_arr[$key]);
         if (count($info) > 0) {
             $ids['name'] = $info[0]['name'];
             //計算積分
             $point += $g_nu_arr[$key] * $info[0]['point'];
             $exp += $g_nu_arr[$key] * $info[0]['exp'];
         }
         $ids['value'] = '';
         $p_info = $tb_products->query('id=' . $p_id_arr[$key]);
         if (count($p_info) > 0) {
             $spec_array = Block::show_spec($p_info[0]['spec_array']);
             foreach ($spec_array as $ky => $vaa) {
                 $ids['value'] .= $ky . ':' . $vaa . ',';
             }
         }
         $tb_order_goods->setData(array('goods_array' => serialize($ids)));
         $tb_order_goods->update('id=' . $og_id);
         //減goods表中以及products中的庫存
         Block::updateStore($order_id, $type = 'reduce');
         //計算實付總金額
         $real_amount = $real_amount + $real_price * $g_nu_arr[$key];
     }
     if ($point) {
         //更新積分
         $tb_order->setData(array('point' => $point, 'exp' => $exp));
         $tb_order->update('id=' . $order_id);
     }
     //獲取post值,看用戶是否要保存收貨地址
     $if_save = IReq::get('if_save');
     if ($if_save) {
         $tb_address = new IModel('address');
         $tb_address->setData(array('user_id' => $user_id, 'accept_name' => IFilter::act(IReq::get('accept_name')), 'zip' => IFilter::act(IReq::get('postcode')), 'telphone' => IFilter::act(IReq::get('telphone')), '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')), 'default' => 0));
         $tb_address->add();
     }
     //生成訂單日誌
     $tb_order_log = new IModel('order_log');
     $tb_order_log->setData(array('order_id' => $order_id, 'user' => $this->admin['admin_id'], 'action' => '添加', 'result' => '成功', 'note' => '訂單【' . $order_no . '】創建', 'addtime' => date('Y-m-d H:i:s')));
     $tb_order_log->add();
     $logObj = new log('db');
     $logObj->write('operation', array("管理員:" . ISafe::get('admin_name'), "生成了新訂單", '訂單號:' . $order_no));
     $this->redirect('order_list');
 }
開發者ID:chenyongze,項目名稱:iwebshop,代碼行數:94,代碼來源:order.php

示例2: cart3

 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_radio = IFilter::act(IReq::get('accept_time_radio'), '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');
     $is_tax = IFilter::act(IReq::get('is_tax'), 'int');
     $tax_title = IFilter::act(IReq::get('tax_title'), 'text');
     $gid = intval(IReq::get('direct_gid'));
     $num = intval(IReq::get('direct_num'));
     $type = IFilter::act(IReq::get('direct_type'));
     //商品或者貨品
     $promo = IFilter::act(IReq::get('direct_promo'));
     $active_id = intval(IReq::get('direct_active_id'));
     $tourist = IReq::get('tourist');
     //遊客方式購物
     $order_no = block::createOrderNum();
     $order_type = 0;
     $is_protectPrice = IFilter::act(IReq::get('protect_price'));
     $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, 'type');
     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();
//.........這裏部分代碼省略.........
開發者ID:chenyongze,項目名稱:iwebshop,代碼行數:101,代碼來源:simple.php


注:本文中的block::createOrderNum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。