本文整理匯總了PHP中Block::updateStore方法的典型用法代碼示例。如果您正苦於以下問題:PHP Block::updateStore方法的具體用法?PHP Block::updateStore怎麽用?PHP Block::updateStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Block
的用法示例。
在下文中一共展示了Block::updateStore方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: order_status
public function order_status()
{
$op = IReq::get('op');
$id = IFilter::act(IReq::get('id'), 'int');
$model = new IModel('order');
if ($op == 'cancel') {
$model->setData(array('status' => 3));
//修改庫存
Block::updateStore($id);
//修改紅包狀態
$prop_obj = $model->getObj('id=' . $id, 'prop');
$prop_id = isset($prop_obj['prop']) ? $prop_obj['prop'] : '';
if ($prop_id != '') {
$prop = new IModel('prop');
$prop->setData(array('is_close' => 0));
$prop->update('id=' . $prop_id);
}
} else {
if ($op == 'confirm') {
$order_goods = new IModel('order_goods');
$goods = $order_goods->query('order_id=' . $id, 'goods_id');
$order_no = IFilter::act(IReq::get('order_no'));
$user_id = $this->user['user_id'];
$date = date('Y-m-d H:i:s');
$comment = new IModel('comment');
foreach ($goods as $good) {
$attr = array('goods_id' => $good['goods_id'], 'order_no' => $order_no, 'user_id' => $user_id, 'time' => $date);
$comment->setData($attr);
$comment->add();
}
$model->setData(array('status' => 5, 'completion_time' => date('Y-m-d h:i:s')));
}
}
$model->update("id = " . $id);
$this->redirect("order_detail/id/{$id}");
}
示例2: 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');
}
示例3: cart3
//.........這裏部分代碼省略.........
$dataArray = array('order_no' => $order_no, 'user_id' => $user_id, 'accept_name' => $accept_name, 'pay_type' => $payment, 'distribution' => $delivery_id, 'status' => 1, 'pay_status' => 0, 'distribution_status' => 0, 'postcode' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile, 'create_time' => ITime::getDateTime(), 'invoice' => $is_tax, 'postscript' => $order_message, 'invoice_title' => $tax_title, 'accept_time' => $accept_time, 'exp' => $exp_r, 'point' => $point_r, 'type' => $order_type, 'prop' => isset($dataArray['prop']) ? $dataArray['prop'] : null, 'payable_amount' => $goodsResult['sum'], 'real_amount' => $goodsResult['final_sum'], 'payable_freight' => $deliveryPrice, 'real_freight' => $deliveryPrice_r, 'pay_fee' => $payment_fee, 'taxes' => $tax, 'promotions' => $proReduce_r + $reduce_r, 'order_amount' => $order_amount, 'if_insured' => $if_insured, 'insured' => $protect_price);
$orderObj = new IModel('order');
$orderObj->setData($dataArray);
$this->order_id = $orderObj->add();
if ($this->order_id == false) {
IError::show(403, '訂單生成錯誤');
}
/*將訂單中的商品插入到order_goods表*/
$orderGoodsObj = new IModel('order_goods');
$goodsArray = array('order_id' => $this->order_id);
$findType = array('goods' => 'goodsList', 'product' => 'productList');
foreach ($findType as $key => $list) {
if (isset($goodsResult[$list]) && count($goodsResult[$list]) > 0) {
foreach ($goodsResult[$list] as $k => $val) {
//拚接商品名稱和規格數據
$specArray = array('name' => $val['name'], 'value' => '');
if ($key == 'product') {
$goodsArray['product_id'] = $val['id'];
$goodsArray['goods_id'] = $val['goods_id'];
$spec = block::show_spec($val['spec_array']);
foreach ($spec as $skey => $svalue) {
$specArray['value'] .= $skey . ':' . $svalue . ' , ';
}
} else {
$goodsArray['goods_id'] = $val['id'];
$goodsArray['product_id'] = 0;
}
$specArray = serialize($specArray);
$goodsArray['goods_price'] = $val['sell_price'];
$goodsArray['real_price'] = $val['sell_price'] - $val['reduce'];
$goodsArray['goods_nums'] = $val['count'];
$goodsArray['goods_weight'] = $val['weight'];
$goodsArray['goods_array'] = $specArray;
$orderGoodsObj->setData($goodsArray);
$orderGoodsObj->add();
}
}
}
//更改購買商品的庫存數量
Block::updateStore($this->order_id, 'reduce');
//記錄用戶默認習慣的數據
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_fee = $payment_fee;
$this->payment = $paymentName;
$this->delivery = $deliveryList[$delivery_id]['name'];
$this->tax_title = $tax_title;
$this->deliveryType = $deliveryRow['type'];
$this->paymentType = $paymentType;
$this->paymentNote = $paymentNote;
//訂單金額為0時,訂單自動完成
if ($this->final_sum <= 0) {
$order_id = payment::updateOrder($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->redirect('cart3');
}
}