コード例 #1
0
ファイル: simple -6-29.php プロジェクト: yongge666/sunupedu
 function getProducts()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $productObj = new IModel('products');
     $productsList = $productObj->query('goods_id = ' . $id, 'sell_price,id,spec_array,goods_id', 'store_nums', 'desc', 7);
     if ($productsList) {
         foreach ($productsList as $key => $val) {
             $productsList[$key]['specData'] = Block::show_spec($val['spec_array']);
         }
         echo JSON::encode($productsList);
     }
 }
コード例 #2
0
ファイル: cart2 - 12-27.php プロジェクト: yongge666/sunupedu
    ?>
" /></td>
								<td class="t_l">
									<a href="<?php 
    echo IUrl::creatUrl("/site/products/id/" . $item['goods_id'] . "");
    ?>
" class="blue"><?php 
    echo isset($item['name']) ? $item['name'] : "";
    ?>
</a>
									<?php 
    if (isset($item['spec_array'])) {
        ?>
									<p>
									<?php 
        $spec_array = Block::show_spec($item['spec_array']);
        ?>
									<?php 
        foreach ($spec_array as $specName => $specValue) {
            ?>
										<?php 
            echo isset($specName) ? $specName : "";
            ?>
:<?php 
            echo isset($specValue) ? $specValue : "";
            ?>
 &nbsp&nbsp
									<?php 
        }
        ?>
									</p>
コード例 #3
0
ファイル: order.php プロジェクト: chenyongze/iwebshop
 /**
  * @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');
 }