Example #1
0
 public function __construct($site_config = null)
 {
     if ($site_config == null) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $this->config = $site_config;
     } else {
         $this->config = $site_config;
     }
     if ($this->checkEmailConf($site_config)) {
         //使用系统mail函数发送
         if (isset($site_config['email_type']) && $site_config['email_type'] == '2') {
             $this->smtp = new ISmtp();
         } else {
             //使用外部SMTP服务器发送
             $server = $site_config['smtp'];
             $port = $site_config['smtp_port'];
             $account = $site_config['smtp_user'];
             $password = $site_config['smtp_pwd'];
             $this->smtp = new ISmtp($server, $port, $account, $password);
         }
         if (!$this->smtp) {
             $this->error = '无法创建smtp类';
         }
     } else {
         $this->error = '配置参数填写不完整';
     }
 }
Example #2
0
 public function __construct($site_config = null)
 {
     if ($site_config == null) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $this->config = $site_config;
     } else {
         $this->config = $site_config;
     }
     if ($this->checkEmailConf($site_config)) {
         $phpMailerDir = IWEB_PATH . 'core/util/phpmailer/PHPMailerAutoload.php';
         include_once $phpMailerDir;
         //创建实例
         $this->smtp = new PHPMailer();
         $this->smtp->Timeout = 60;
         $this->smtp->SMTPSecure = $site_config['email_safe'];
         $this->smtp->isHTML();
         //使用系统mail函数发送
         if (isset($site_config['email_type']) && $site_config['email_type'] == '2') {
             $this->smtp->isMail();
         } else {
             $this->smtp->isSMTP();
             $this->smtp->SMTPAuth = true;
             $this->smtp->Host = $site_config['smtp'];
             $this->smtp->Port = $site_config['smtp_port'];
             $this->smtp->Username = $site_config['smtp_user'];
             $this->smtp->Password = $site_config['smtp_pwd'];
         }
     } else {
         $this->error = '配置参数填写不完整';
     }
 }
Example #3
0
 function index()
 {
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $index_slide = isset($site_config['index_slide']) ? unserialize($site_config['index_slide']) : array();
     $this->index_slide = $index_slide;
     $this->redirect('index');
 }
Example #4
0
 function init()
 {
     $this->tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
     // 获取导航配置
     $guideObj = new IModel('guide');
     $guide_list = $guideObj->query('', '`order`,`name`,`link`', '`order`', 'desc');
     if (count($guide_list) > 0) {
         $this->guide_list = $guide_list;
     }
     $this->sort_type_map = array('0' => "{$this->tablePre}goods.sort ASC", '1' => "{$this->tablePre}goods.volume DESC", '2' => "{$this->tablePre}goods.discount ASC");
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->site_config = $site_config;
 }
Example #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'), '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');
     }
 }
Example #6
0
 public function merge_template()
 {
     $this->layout = 'print';
     $order_id = IFilter::act(IReq::get('id'), 'int');
     $seller_id = IFilter::act(IReq::get('seller_id'), 'int');
     $tb_order = new IModel('order');
     $data = $tb_order->getObj('id=' . $order_id);
     if ($seller_id) {
         $sellerObj = new IModel('seller');
         $config_info = $sellerObj->getObj('id = ' . $seller_id);
         $data['set']['name'] = isset($config_info['true_name']) ? $config_info['true_name'] : '';
         $data['set']['phone'] = isset($config_info['phone']) ? $config_info['phone'] : '';
         $data['set']['email'] = isset($config_info['email']) ? $config_info['email'] : '';
         $data['set']['url'] = isset($config_info['home_url']) ? $config_info['home_url'] : '';
     } else {
         $config = new Config("site_config");
         $config_info = $config->getInfo();
         $data['set']['name'] = isset($config_info['name']) ? $config_info['name'] : '';
         $data['set']['phone'] = isset($config_info['phone']) ? $config_info['phone'] : '';
         $data['set']['email'] = isset($config_info['email']) ? $config_info['email'] : '';
         $data['set']['url'] = isset($config_info['url']) ? $config_info['url'] : '';
     }
     //获取地区
     $data['address'] = join('&nbsp;', area::name($data['province'], $data['city'], $data['area'])) . "&nbsp;" . $data['address'];
     $data['seller_id'] = $seller_id;
     $this->setRenderData($data);
     $this->redirect("merge_template");
 }
Example #7
0
 /**
  * 获取商品的税金
  * @param $goodsSum float 商品总价格
  * @param $seller_id int 商家ID
  * @return $goodsTaxPrice float 商品的税金
  */
 public static function getGoodsTax($goodsSum, $seller_id = 0)
 {
     if ($seller_id) {
         $sellerDB = new IModel('seller');
         $sellerRow = $sellerDB->getObj('id = ' . $seller_id);
         $tax_per = $sellerRow['tax'];
     } else {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $tax_per = isset($site_config['tax']) ? $site_config['tax'] : 0;
     }
     $goodsTaxPrice = $goodsSum * ($tax_per * 0.01);
     return round($goodsTaxPrice, 2);
 }
Example #8
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;
 }
Example #9
0
 function merge_template()
 {
     $this->layout = 'print';
     $order_id = IFilter::string(IReq::get('id'));
     $tb_order = new IModel('order');
     $order_info = $tb_order->query('id=' . $order_id);
     $this->setRenderData($order_info[0]);
     //获得配置文件内容
     $data = array();
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $data['set']['name'] = isset($config_info['name']) ? $config_info['name'] : '';
     $data['set']['mobile'] = isset($config_info['mobile']) ? $config_info['mobile'] : '';
     $data['set']['email'] = isset($config_info['email']) ? $config_info['email'] : '';
     $data['set']['url'] = isset($config_info['url']) ? $config_info['url'] : '';
     $tb_deliver_doc = new IQuery('delivery_doc as dd');
     $tb_deliver_doc->join = 'left join delivery_goods as dg on dd.id = dg.delivery_id';
     $tb_deliver_doc->fields = 'dd.name,dd.mobile,dd.telphone,dd.address,dd.postcode,dd.delivery_type';
     $tb_deliver_doc->where = 'dd.order_id=' . $order_id;
     $deliver_doc_info = $tb_deliver_doc->find();
     if (count($deliver_doc_info) > 0) {
         $data['deliver'] = $deliver_doc_info[0];
     }
     $this->setRenderData($data);
     $this->redirect("merge_template");
 }
Example #10
0
 /**
  * @brief 订单详情
  * @return String
  */
 public function order_detail()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $order = new IModel('order');
     $order_info = $order->query('id = ' . $id);
     if (count($order_info) == 0) {
         IError::show(403, '订单信息不存在');
     }
     $this->order_info = $order_info[0];
     //查询地区
     $str_areas = '(';
     $area = new IModel('areas');
     $str_areas .= $this->order_info['province'] . ',' . $this->order_info['city'] . ',' . $this->order_info['area'] . ')';
     $area_rows = $area->query('area_id in ' . $str_areas);
     $area_tem = array();
     foreach ($area_rows as $area_row) {
         $area_tem[$area_row['area_id']] = $area_row['area_name'];
     }
     $this->area = $area_tem;
     //取得支付方式
     if (isset($this->order_info['pay_type']) && $this->order_info['pay_type'] == 0) {
         $this->pay_type = '货到付款';
     } else {
         $payment = new IModel('payment');
         $pay = $payment->getObj('id = ' . $this->order_info['pay_type']);
         if ($pay) {
             $this->pay_type = $pay['type'];
             $this->pay_name = $pay['name'];
             $this->pay_note = $pay['note'];
         } else {
             $this->pay_name = '不存在';
         }
     }
     //物流单号
     $tb_delivery_doc = new IQuery('delivery_doc as dd');
     $tb_delivery_doc->fields = 'd.name,dd.delivery_code,fc.freight_name';
     $tb_delivery_doc->where = 'order_id=' . $id;
     $tb_delivery_doc->join = 'left join delivery as d on dd.delivery_type=d.id left join freight_company as fc on d.freight_id=fc.id';
     $delivery_info = $tb_delivery_doc->find();
     $this->deliver_code = '';
     $this->deliver_name = '';
     if ($delivery_info) {
         $coun = count($delivery_info);
         $this->deliver_code = $delivery_info[$coun - 1]['delivery_code'];
         $this->deliver_name = $delivery_info[$coun - 1]['name'];
     }
     //快递跟踪是否开启
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $this->is_open = isset($config_info['express_open']) ? $config_info['express_open'] : '';
     $this->redirect('order_detail', false);
 }
Example #11
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;
 }
Example #12
0
 /**
  * 快递跟踪
  */
 public function express()
 {
     //配置信息
     $siteConfigObj = new Config("site_config");
     $config_info = $siteConfigObj->getInfo();
     $data = array();
     $data['express_key'] = isset($config_info['express_key']) ? $config_info['express_key'] : '';
     $data['express_open'] = isset($config_info['express_open']) ? $config_info['express_open'] : '0';
     $this->setRenderData($data);
     $this->redirect('express');
 }
Example #13
0
 /**
  * @brief 保存修改商品信息
  */
 function goods_update()
 {
     //获得post的数据
     $goods_id = IFilter::act(IReq::get('goods_id'), 'int');
     $goods_name = IFilter::act(IReq::get('goods_name'));
     $goods_category = IReq::get('goods_category');
     $goods_model = IFilter::act(IReq::get('goods_model'), 'int');
     $goods_brand = IFilter::act(IReq::get('goods_brand'), 'int');
     $goods_status = IFilter::act(IReq::get('goods_status'), 'int');
     $goods_notes = IFilter::act(IReq::get('goods_notes'));
     $goods_from = IFilter::act(IReq::get('goods_from'));
     $goods_sellernick = IFilter::act(IReq::get('goods_sellernick'));
     $goods_commission = IFilter::act(IReq::get('goods_commission'), 'float');
     $goods_url = IFilter::act(IReq::get('goods_url'));
     $goods_img = IFilter::act(IReq::get('goods_img'));
     $list_img = IFilter::act(IReq::get('list_img'));
     $show_img = IFilter::act(IReq::get('small_img'));
     $sell_price = IFilter::act(IReq::get('sell_price'), 'float');
     $market_price = IFilter::act(IReq::get('market_price'), 'float');
     $discount = IFilter::act(IReq::get('discount'), 'float');
     $store_nums = IFilter::act(IReq::get('store_nums'), 'int');
     $weight = IFilter::act(IReq::get('weight'), 'float');
     $store_unit = IFilter::act(IReq::get('store_unit'));
     $content = IFilter::act(IReq::get('content'), 'text');
     $seo_keywords = IReq::get('seo_keywords');
     $seo_description = IReq::get('seo_description');
     $point = IFilter::act(IReq::get('point'), 'int');
     $exp = IFilter::act(IReq::get('exp'), 'int');
     $sort = IFilter::act(IReq::get('sort'));
     $focus_photo = IFilter::act(IReq::get('focus_photo'));
     $goods_no = IFilter::act(IReq::get('goods_no'));
     $keywords_for_search = IFilter::act(IReq::get('keywords_for_search'));
     $tb_goods = new IModel('goods');
     if (!$goods_no) {
         //如用户没有输入商品货号,则默认货号
         $goods_no = Block::goods_no($goods_id);
     } else {
         $goods_info = $tb_goods->query("goods_no='" . $goods_no . "'");
         $flag = 2;
         if (count($goods_info) > 0) {
             if (count($goods_info) == 1) {
                 if ($goods_info[0]['id'] != $goods_id) {
                     $flag = 1;
                 }
             } else {
                 $flag = 1;
             }
         }
         if ($flag == 1) {
             $type = array('gid' => $goods_id, 'admin_name' => $this->admin['admin_name'], 'admin_pwd' => $this->admin['admin_pwd']);
             $goods_in_fo = $tb_goods->getObj('id=' . $goods_id);
             $goods = new goods_class();
             $data = $goods->edit($type, $goods_in_fo);
             $this->setRenderData($data);
             $this->redirect('goods_edit', false);
             Util::showMessage("您输入的货号已存在!");
         }
     }
     //标签关键词
     $keywords_for_search = trim($keywords_for_search, ",");
     if ($keywords_for_search) {
         $keywords_for_search_array = array();
         foreach (explode(",", $keywords_for_search) as $value) {
             if (IString::getStrLen($value) <= 15) {
                 keywords::add($value, 0);
                 $keywords_for_search_array[] = $value;
             }
         }
         if ($keywords_for_search_array) {
             $data = array('goods_id' => $goods_id, 'keywords' => join(',', $keywords_for_search_array));
             $obj_goods_keywords = new IModel("goods_keywords");
             $obj_goods_keywords->setData($data);
             if ($obj_goods_keywords->getObj("goods_id={$goods_id}")) {
                 $obj_goods_keywords->update("goods_id={$goods_id}");
             } else {
                 $obj_goods_keywords->add();
             }
         }
     }
     //大图片
     $show_img = $focus_photo;
     $list_img = $focus_photo;
     if ($focus_photo) {
         $foot = substr($focus_photo, strpos($focus_photo, '.'));
         //图片扩展名
         $head = substr($focus_photo, 0, strpos($focus_photo, '.'));
         //获得配置文件中的数据
         $config = new Config("site_config");
         $config_info = $config->getInfo();
         $list_thumb_width = isset($config_info['list_thumb_width']) ? $config_info['list_thumb_width'] : 175;
         $list_thumb_height = isset($config_info['list_thumb_height']) ? $config_info['list_thumb_height'] : 175;
         $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
         $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
         //list
         $list_img = $head . '_' . $list_thumb_width . '_' . $list_thumb_height . $foot;
         //show
         $show_img = $head . '_' . $show_thumb_width . '_' . $show_thumb_height . $foot;
     } elseif ($goods_img) {
         $focus_photo = $goods_img;
     }
     //规格
     $spec_va = IReq::get('spec_va');
     $spec = array();
     $spec_array = array();
     if ($spec_va) {
         $arr = explode(';', $spec_va);
         $i = 0;
         foreach ($arr as $value) {
             if ($value) {
                 $brr = explode('|', $value);
                 $j = 0;
                 foreach ($brr as $va) {
                     $crr = explode(',', $va);
                     $spec[$i][$j]['id'] = $crr[1];
                     $spec[$i][$j]['name'] = $crr[2];
                     $spec[$i][$j]['type'] = $crr[3];
                     //商品规格类型
                     $spec_array[$j]['id'] = $crr[1];
                     if (!isset($spec_array[$j]['value'])) {
                         $spec_array[$j]['value'] = $crr[2] . ',';
                     } else {
                         if (!strpos(',,' . $spec_array[$j]['value'], ',' . $crr[2] . ',')) {
                             $spec_array[$j]['value'] .= $crr[2] . ',';
                         }
                     }
                     $spec_array[$j]['type'] = $crr[3];
                     $spec_array[$j]['name'] = $crr[4];
                     $j++;
                 }
                 $i++;
             }
         }
     }
     /*goods表操作*/
     $tb_goods->setData(array('name' => $goods_name, 'notes' => $goods_notes, 'goods_no' => $goods_no, 'sell_price' => $sell_price, 'market_price' => $market_price, 'discount' => $discount, 'store_nums' => $store_nums, 'brand_id' => $goods_brand, 'is_del' => $goods_status, 'from' => $goods_from, 'sellernick' => $goods_sellernick, 'commission' => $goods_commission, 'url' => $goods_url, 'content' => $content, 'keywords' => $seo_keywords, 'description' => $seo_description, 'weight' => $weight, 'unit' => $store_unit, 'point' => $point, 'exp' => $exp, 'sort' => $sort, 'small_img' => $show_img, 'img' => $focus_photo, 'list_img' => $list_img));
     $tb_goods->update('id=' . $goods_id);
     //商品扩展分类
     $tb_category = new IModel('category_extend');
     $tb_category->del('goods_id=' . $goods_id);
     if ($goods_category) {
         $tb_category->setData(array('goods_id' => $goods_id, 'category_id' => $goods_category));
         $tb_category->add();
     }
     /*commend_goods表操作*/
     $goods_commend = IReq::get('goods_commend');
     $tb_commend = new IModel('commend_goods');
     $tb_commend->del('goods_id=' . $goods_id);
     if (!empty($goods_commend)) {
         if (is_array($goods_commend)) {
             for ($i = 0; $i < count($goods_commend); $i++) {
                 $tb_commend->setData(array('commend_id' => $goods_commend[$i], 'goods_id' => $goods_id));
                 $tb_commend->add();
             }
         } else {
             $tb_commend->setData(array('commend_id' => $goods_commend, 'goods_id' => $goods_id));
             $tb_commend->add();
         }
     }
     /*goods_photo_relation表操作*/
     $photo_name = IReq::get('photo_name');
     $tb_goods_relation = new IModel('goods_photo_relation');
     $tb_goods_relation->del('goods_id=' . $goods_id);
     if ($photo_name) {
         $photo_name = substr($photo_name, 0, -1);
         $arr = explode(',', $photo_name);
         if (count($arr) > 0) {
             foreach ($arr as $value) {
                 //当图片存在的时候保存
                 if (file_exists($value)) {
                     $tb_goods_relation->setData(array('goods_id' => $goods_id, 'photo_id' => md5_file($value)));
                     $tb_goods_relation->add();
                 }
             }
         }
     }
     /*products表以及group_price的操作*/
     $member_ids = IFilter::act(IReq::get('member_ids'));
     $group_id = IFilter::act(IReq::get('group_id'));
     $products_id = IFilter::act(IReq::get('products_id'));
     //先对products表操作,先修改,再删除没有了的pro
     $tb_products = new Imodel('products');
     $tb_group_ob = new Imodel('group_price');
     if ($group_id) {
         $tb_group_ob->del('id in (' . $group_id . ')');
     }
     $store_nums = 0;
     //商品数量
     if ($spec_va) {
         $sell_price_array = array();
         //所有货品的销售价格
         $market_price_array = array();
         //所有货品的市场价格
         $discount_array = array();
         //所有货品的成本价格
         $weight_array = array();
         //所有货品的重量
         $arr = explode(';', $spec_va);
         $i = 0;
         foreach ($arr as $value) {
             if ($value) {
                 $brr = explode('|', $value);
                 $j = 0;
                 $ids = array();
                 $spec_md5 = '';
                 $pro_id = '';
                 $new_pro = '';
                 foreach ($brr as $va) {
                     $crr = explode(',', $va);
                     $pro_id = $crr[0];
                     $new_pro = $pro_id;
                     //判断商品是否为新添加的,如果是则pro_id以a开头
                     if (stristr($pro_id, 'a') != '') {
                         $pro_id = substr($pro_id, 1);
                     }
                     $ids[$j]['id'] = $crr[1];
                     $ids[$j]['value'] = $crr[2];
                     $spec_md5 .= md5($ids[$j]['value']) . ',';
                     $j++;
                 }
                 $specTemp = explode(',', trim($spec_md5, ','));
                 sort($specTemp);
                 $spec_md5 = md5(serialize($specTemp));
                 $store_nums += IReq::get('store_nums' . $pro_id);
                 $tb_products->setData(array('goods_id' => $goods_id, 'products_no' => IReq::get('goods_no' . $pro_id) ? IReq::get('goods_no' . $pro_id) : $goods_no . '-' . ($i + 1), 'spec_array' => serialize($ids), 'market_price' => IReq::get('market_price' . $pro_id) ? IReq::get('market_price' . $pro_id) : $market_price, 'sell_price' => IReq::get('sell_price' . $pro_id) ? IReq::get('sell_price' . $pro_id) : $sell_price, 'store_nums' => IReq::get('store_nums' . $pro_id) ? IReq::get('store_nums' . $pro_id) : $store_nums, 'discount' => IReq::get('discount' . $pro_id) ? IReq::get('discount' . $pro_id) : $discount, 'weight' => IReq::get('weight' . $pro_id) ? IReq::get('weight' . $pro_id) : $weight, 'spec_md5' => $spec_md5));
                 //获得所有的货品的销售价格、市场价格、成本价格、货品的重量
                 $sell_price_array[] = IReq::get('sell_price' . $pro_id) ? IReq::get('sell_price' . $pro_id) : $sell_price;
                 $market_price_array[] = IReq::get('market_price' . $pro_id) ? IReq::get('market_price' . $pro_id) : $market_price;
                 $discount_array[] = IReq::get('discount' . $pro_id) ? IReq::get('discount' . $pro_id) : $discount;
                 $weight_array[] = IReq::get('weight' . $pro_id) ? IReq::get('weight' . $pro_id) : $weight;
                 $mem_array = explode(',', $member_ids);
                 if (strpos('|' . $new_pro, 'a') > 0) {
                     $pr_id = $tb_products->add();
                     foreach ($mem_array as $cc) {
                         $gro_price = IFilter::act(IReq::get('mem_0_' . $new_pro . '_' . $cc), 'int');
                         if ($gro_price > 0 && $pr_id != 0) {
                             $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pr_id, 'group_id' => $cc, 'price' => $gro_price));
                             $tb_group_ob->add();
                         }
                     }
                 } else {
                     $tb_products->update('id=' . $pro_id);
                     $group_arr = explode(',', $group_id . ',0');
                     if ($group_arr) {
                         foreach ($group_arr as $va) {
                             foreach ($mem_array as $cc) {
                                 $gro_price = IFilter::act(IReq::get('mem_' . $va . '_' . $pro_id . '_' . $cc), 'int');
                                 if ($gro_price > 0) {
                                     $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pro_id, 'group_id' => $cc, 'price' => $gro_price));
                                     $tb_group_ob->add();
                                 }
                             }
                         }
                     } else {
                         foreach ($mem_array as $cc) {
                             $gro_price = IFilter::act(IReq::get('mem_0_' . $pro_id . '_' . $cc), 'int');
                             if ($gro_price > 0) {
                                 $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pro_id, 'group_id' => $cc, 'price' => $gro_price));
                                 $tb_group_ob->add();
                             }
                         }
                     }
                 }
             }
             $i++;
         }
         //如果商品的价格为空,则将货品的销售价格中最低的赋予
         $addition = array('store_nums' => $store_nums);
         if (!empty($sell_price_array)) {
             $addition['sell_price'] = min($sell_price_array);
         }
         if (!empty($market_price_array)) {
             $addition['market_price'] = min($market_price_array);
         }
         if (!empty($discount_array)) {
             $addition['discount'] = min($discount_array);
         }
         if (!empty($weight_array)) {
             $addition['weight'] = min($weight_array);
         }
         $tb_goods->setData($addition);
         //如果有products数据,则将products中的货品数量全部相加并送入goods表
         $tb_goods->update('id=' . $goods_id);
     }
     $mem_array = explode(',', $member_ids);
     $group_arr = explode(',', $group_id . ',0');
     if ($group_arr) {
         foreach ($group_arr as $va) {
             foreach ($mem_array as $cc) {
                 $gro_price = IFilter::act(IReq::get('mem_' . $va . '_0_' . $cc), 'int');
                 if ($gro_price > 0) {
                     $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => 0, 'group_id' => $cc, 'price' => $gro_price));
                     $tb_group_ob->add();
                 }
             }
         }
     }
     //获得删除的products_id
     $del_products_id = IFilter::act(IReq::get('del_products_id'));
     if ($del_products_id) {
         $del_products_id = substr($del_products_id, 0, -1);
         $info = explode(',', $del_products_id);
         foreach ($info as $value) {
             if (strpos('|' . $value, 'a') == false) {
                 $tb_products->del('id=' . $value);
             }
         }
     }
     $this->redirect("goods_list");
 }
Example #14
0
 /**
  * @brief 商品添加后图片的链接地址
  */
 function goods_photo_link()
 {
     $img = IReq::get('img');
     $img = substr($img, 1);
     $foot = substr($img, strpos($img, '.'));
     //图片扩展名
     $head = substr($img, 0, strpos($img, '.'));
     //获得配置文件中的数据
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $list_thumb_width = isset($config_info['list_thumb_width']) ? $config_info['list_thumb_width'] : 175;
     $list_thumb_height = isset($config_info['list_thumb_height']) ? $config_info['list_thumb_height'] : 175;
     $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
     $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
     $data['img'] = IUrl::creatUrl() . $img;
     $data['list_img'] = IUrl::creatUrl() . $head . '_' . $list_thumb_width . '_' . $list_thumb_height . $foot;
     $data['small_img'] = IUrl::creatUrl() . $head . '_' . $show_thumb_width . '_' . $show_thumb_height . $foot;
     $this->setRenderData($data);
     $this->redirect('goods_photo_link');
 }
Example #15
0
 /**
  *导入CSV文件
  * @param <文件路径> $name
  * @param <文件标示> $mark
  */
 function import($name, $mark)
 {
     $handle = fopen($name, 'r');
     $goods_col = array();
     $goods_col['1'] = 'name';
     $goods_col['2'] = 'goods_no';
     $goods_col['3'] = 'model_id';
     $goods_col['4'] = 'sell_price';
     $goods_col['5'] = 'market_price';
     $goods_col['6'] = 'cost_price';
     $goods_col['7'] = 'create_time';
     $goods_col['8'] = 'store_nums';
     $goods_col['9'] = 'img';
     $goods_col['10'] = 'is_del';
     $goods_col['11'] = 'content';
     $goods_col['12'] = 'keywords';
     $goods_col['13'] = 'description';
     $goods_col['14'] = 'tag_ids';
     $goods_col['15'] = 'weight';
     $goods_col['16'] = 'point';
     $goods_col['17'] = 'unit';
     $goods_col['18'] = 'brand_id';
     $goods_col['19'] = 'visit';
     $goods_col['20'] = 'favorite';
     $goods_col['21'] = 'sort';
     $goods_col['22'] = 'list_img';
     $goods_col['23'] = 'small_img';
     $goods_col['24'] = 'spec_array';
     $goods_col['25'] = 'exp';
     $gid = '';
     $products_id = '';
     $total = 0;
     //数据总条数
     $suce = 0;
     //成功的总条数
     $group = array();
     $product = array();
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $list_thumb_width = isset($config_info['list_thumb_width']) ? $config_info['list_thumb_width'] : 175;
     $list_thumb_height = isset($config_info['list_thumb_height']) ? $config_info['list_thumb_height'] : 175;
     $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
     $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
     while ($data = fgetcsv($handle)) {
         $total++;
         $arr = array();
         $num = count($data);
         //导入goods表
         for ($i = 0; $i < $num; $i++) {
             if ($i == $num) {
                 break;
             }
             if ($data[0] == '*cols*') {
                 break;
             }
             if ($data[0] == 'gid') {
                 if ($i > 0 && $i < 26) {
                     $arr[$goods_col[$i]] = $this->i($data[$i]);
                     if ($goods_col[$i] == 'spec_array' || $goods_col[$i] == 'content') {
                         $arr[$goods_col[$i]] = addslashes($arr[$goods_col[$i]]);
                     }
                 }
                 if ($i == 26) {
                     $goods_no = $data[2];
                     $obj_goods = new IQuery('goods');
                     $obj_goods->fields = 'id';
                     $obj_goods->where = "goods_no='{$goods_no}'";
                     $goods_info = $obj_goods->find();
                     if (file_exists($arr['img'])) {
                         $arr['list_img'] = IImage::thumb($arr['img'], $list_thumb_width, $list_thumb_height, '_' . $list_thumb_width . '_' . $list_thumb_height);
                         $arr['small_img'] = IImage::thumb($arr['img'], $show_thumb_width, $show_thumb_height, '_' . $show_thumb_width . '_' . $show_thumb_height);
                     }
                     if (count($goods_info) == 0 || empty($goods_no)) {
                         $tb_goods = new IModel('goods');
                         $tb_goods->setData($arr);
                         $gid = $tb_goods->add();
                         $suce++;
                         //如果新添加的,则处理图片
                     } else {
                         if ($mark == 1) {
                             //生成新的商品
                             $tb_goods = new IModel('goods');
                             $tb_goods->setData($arr);
                             $gid = $tb_goods->update('id=' . $goods_info[0]['id']);
                             $suce++;
                         } else {
                             $tb_goods = new IModel('goods');
                             $tb_goods->setData($arr);
                             $gid = $tb_goods->add();
                             $suce++;
                             //如果新添加的,则处理图片
                         }
                     }
                 }
                 //保存图片
                 if ($i == 29) {
                     if (!empty($data[$i])) {
                         $photo = explode(',', substr($data[$i], 0, -1));
                         foreach ($photo as $v) {
                             if (count($goods_info) == 0 || empty($goods_no) || $mark == 2) {
                                 if (file_exists(str_replace("'", "", $v))) {
                                     $md5 = md5_file(str_replace("'", "", $v));
                                     //照片图库表
                                     $tb_goods_photo = new IModel('goods_photo');
                                     $goods_photo = $tb_goods_photo->getObj("id='" . $md5 . "'");
                                     if (count($goods_photo) == 0) {
                                         $tb_goods_photo->setData(array('id' => $md5, 'img' => str_replace("'", "", $v)));
                                         $tb_goods_photo->add();
                                     }
                                     //商品照片的关联表
                                     $tb_goods_photo_relation = new IModel('goods_photo_relation');
                                     $tb_goods_photo_relation->setData(array('goods_id' => $gid, 'photo_id' => $md5));
                                     $tb_goods_photo_relation->add();
                                 }
                             }
                         }
                     }
                 }
                 //保存商品标签
                 if ($i == 30) {
                     if (!empty($data[$i])) {
                         $commend = explode(',', substr($data[$i], 0, -1));
                         foreach ($commend as $v) {
                             $tb_commend_goods = new IModel('commend_goods');
                             $tb_commend_goods->setData(array('goods_id' => $gid, 'commend_id' => $v));
                             $tb_commend_goods->add();
                         }
                     }
                 }
                 //会员组价格
                 if ($i == 31) {
                     if (!empty($data[$i])) {
                         $group = explode(';', substr($data[$i], 0, -1));
                         foreach ($group as $gva) {
                             $gprice = explode(',', $gva);
                             $tb_group_price = new IModel('group_price');
                             $tb_group_price->setData(array('goods_id' => $gid, 'products_id' => $gprice[0], 'group_id' => $gprice[1], 'price' => $gprice[2]));
                             $tb_group_price->add();
                         }
                     }
                 }
                 //商品扩展分类
                 if ($i == 32) {
                     if (!empty($data[$i])) {
                         $cate_extend = explode('|', substr($data[$i], 0, -1));
                         foreach ($cate_extend as $cva) {
                             $tb_cate_extend = new IModel('category_extend');
                             $tb_cate_extend->setData(array('goods_id' => $gid, 'category_id' => $cva));
                             $tb_cate_extend->add();
                         }
                     }
                 }
                 //商品属性
                 if ($i > 32) {
                     if (!empty($data[$i])) {
                         if (strstr($data[$i], '**a**')) {
                             $tb_goods_attribute = new IModel('goods_attribute');
                             $attr = explode('|', $data[$i]);
                             $tb_goods_attribute->setData(array('goods_id' => $gid, 'attribute_id' => str_replace('**a**', '', $attr[0]), 'attribute_value' => $this->i($data[$i + 1]), 'model_id' => $data[4]));
                             $tb_goods_attribute->add();
                         }
                         if (strstr($data[$i], '**s**')) {
                             $tb_goods_attribute = new IModel('goods_attribute');
                             $spec = explode('|', $data[$i]);
                             $tb_goods_attribute->setData(array('goods_id' => $gid, 'spec_id' => str_replace('**s**', '', $spec[0]), 'spec_value' => $this->i($data[$i + 1]), 'model_id' => $data[4]));
                             $tb_goods_attribute->add();
                         }
                     }
                 }
             }
         }
         //导入products表
         if ($data[0] == 'pid') {
             $arr = array('goods_id' => $gid, 'products_no' => $data[2], 'sell_price' => $data[5], 'market_price' => $data[6], 'store_nums' => $data[8], 'weight' => $data[15], 'spec_array' => $data[24], 'cost_price' => $data[27], 'spec_md5' => $data[28]);
             $tb_product = new IModel('products');
             $tb_product->setData($arr);
             $products_id = $tb_product->add();
             $product[$products_id] = $data[1];
             $suce++;
         }
     }
     fclose($handle);
     //修改用户组会员价的货品ID
     if (count($product) > 0) {
         foreach ($product as $keys => $value) {
             $tb_group_price = new IModel('group_price');
             $group_price_info = $tb_group_price->query('products_id=' . $value);
             if (count($group_price_info) > 0) {
                 foreach ($group_price_info as $va) {
                     $tb_group_price->setData(array('products_id' => $keys));
                     $tb_group_price->update('id=' . $va['id']);
                 }
             }
         }
     }
     if ($suce == 0) {
         return -1;
     }
     return $total - $suce - 1;
 }
Example #16
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');
     }
 }
Example #17
0
 /**
  * @brief 获取订单中的支付信息
  * @payment_id   支付方式信息
  * @type         信息获取方式 order:订单支付;recharge:在线充值;
  * @argument     参数
  * @return array 支付提交信息
  * R表示店铺 ; P表示用户;
  */
 public function getPaymentInfo($payment_id, $type, $argument)
 {
     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['type'] == 1) {
             $regimentRelationObj = new IModel('regiment_user_relation');
             $relationRow = $regimentRelationObj->getObj('order_no = "' . $orderRow['order_no'] . '"');
             if (empty($relationRow)) {
                 IError::show(403, '团购订单已经失效');
                 exit;
             } else {
                 if (abs(ITime::getDiffSec($relationRow['join_time'])) > regiment::time_limit() * 60) {
                     IError::show(403, '支付时间已经过期');
                     exit;
                 }
             }
         }
         $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'];
         $payment['P_Email'] = '';
     } 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' => Block::createOrderNum(), 'account' => $argument['account'], 'time' => ITime::getDateTime(), 'payment_name' => $argument['payment_type'], 'status' => 0);
             $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_Def_Amount'] = 0.01;
     $payment['M_Time'] = time();
     $payment['M_Goods'] = '';
     $payment['M_Language'] = "zh_CN";
     $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'] : '';
     $payment['R_Postcode'] = '';
     $payment['R_Email'] = '';
     return $payment;
 }
Example #18
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;
 }
Example #19
0
 /**
  * 修改商品
  */
 public function edit($type, $goods_info)
 {
     $data = array();
     $data['goods_id'] = $type['gid'];
     $data['form'] = array('goods_name' => $goods_info['name'], 'goods_no' => $goods_info['goods_no'], 'goods_model' => $goods_info['model_id'], 'brand_id' => $goods_info['brand_id'], 'is_del' => $goods_info['is_del'], 'up_time' => $goods_info['up_time'], 'down_time' => $goods_info['down_time'], 'sell_price' => $goods_info['sell_price'], 'market_price' => $goods_info['market_price'], 'cost_price' => $goods_info['cost_price'], 'store_nums' => $goods_info['store_nums'], 'weight' => $goods_info['weight'], 'unit' => $goods_info['unit'], 'point' => $goods_info['point'], 'focus_photo' => $goods_info['img'], 'content' => $goods_info['content'], 'seo_keywords' => $goods_info['keywords'], 'seo_description' => $goods_info['description'], 'sort' => $goods_info['sort'], 'exp' => $goods_info['exp'], 'spec_array' => $goods_info['spec_array'], 'keywords_for_search' => array());
     $data['admin_name'] = $type['admin_name'];
     $data['admin_pwd'] = $type['admin_pwd'];
     //获得配置文件中的数据
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
     $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
     //show
     $show_img = '_' . $show_thumb_width . '_' . $show_thumb_height;
     $data['form']['thumb'] = $show_img;
     //获取keywords信息
     $obj = new IModel('goods_keywords');
     $keywords_for_search = $obj->getObj('goods_id=' . $type['gid']);
     if ($keywords_for_search) {
         $data['form']['keywords_for_search'] = explode(",", $keywords_for_search['keywords']);
     }
     //加载推荐类型
     $tb_commend_goods = new IModel('commend_goods');
     $commend_goods = $tb_commend_goods->query('goods_id=' . $type['gid']);
     $data['commend_goods'] = '';
     if (count($commend_goods) > 0) {
         foreach ($commend_goods as $value) {
             $data['commend_goods'] .= $value['commend_id'];
         }
     }
     //加载分类
     $tb_category = new IModel('category');
     $data['category'] = $this->sortdata($tb_category->query(false, '*', 'sort', 'asc'), 0, ' &nbsp;&nbsp; ');
     //所有扩展属性
     $tb_attribute = new IModel('attribute');
     $attribute_info = $tb_attribute->query('model_id=' . $data['form']['goods_model']);
     $data['attribute'] = $attribute_info;
     $data['attribute_ids'] = '';
     if (count($attribute_info) > 0) {
         foreach ($attribute_info as $value) {
             $data['attribute_ids'] .= $value['id'] . ',';
         }
         $data['attribute_ids'] = substr($data['attribute_ids'], 0, -1);
     }
     //goods_attribute
     $tb_goods_attribute = new IQuery('goods_attribute');
     $tb_goods_attribute->fields = 'attribute_id,attribute_value';
     $tb_goods_attribute->where = "goods_id=" . $type['gid'] . " and attribute_id!=''";
     $goods_attribute = $tb_goods_attribute->find();
     $data['goods_attribute'] = ',';
     if (count($goods_attribute) > 0) {
         foreach ($goods_attribute as $value) {
             $data['goods_attribute'] .= $value['attribute_id'] . '|' . $value['attribute_value'] . ',';
         }
     }
     //相册
     $tb_goods_photo = new IQuery('goods_photo_relation as ghr');
     $tb_goods_photo->join = 'left join goods_photo as gh on ghr.photo_id=gh.id';
     $tb_goods_photo->fields = 'gh.img';
     $tb_goods_photo->where = 'ghr.goods_id=' . $type['gid'];
     $tb_goods_photo->order = 'ghr.id asc';
     $goods_photo_info = $tb_goods_photo->find();
     $data['goods_photo'] = $goods_photo_info;
     if (count($goods_photo_info) > 0) {
         $data['photo_name'] = '';
         foreach ($goods_photo_info as $value) {
             $data['photo_name'] .= $value['img'] . ',';
         }
     }
     //相册属性
     //获得配置文件中的数据
     $config = new Config("site_config");
     $config_info = $config->getInfo();
     $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
     $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
     $data['show_attr'] = '_' . $show_thumb_width . '_' . $show_thumb_height;
     //规格属性
     $tb_spec_attr = new IQuery('goods_attribute as ga');
     $tb_spec_attr->fields = 'ga.spec_id';
     $tb_spec_attr->group = 'spec_id';
     $tb_spec_attr->where = "goods_id=" . $type['gid'] . " and ga.spec_id!=''";
     $spec_attr_info = $tb_spec_attr->find();
     $data['spec_attr'] = count($spec_attr_info);
     $data['spec_id'] = '';
     if (count($spec_attr_info) > 0) {
         foreach ($spec_attr_info as $value) {
             $data['spec_id'] .= $value['spec_id'] . ',';
         }
         $data['spec_id'] = substr($data['spec_id'], 0, -1);
     }
     //加载会员级别
     $tb_user_group = new IModel('user_group');
     $info = $tb_user_group->query();
     $ids = '';
     if (count($info) > 0) {
         foreach ($info as $value) {
             $ids .= $value['id'] . ',';
         }
         $ids = substr($ids, 0, -1);
     }
     $data['ids'] = $ids;
     return $data;
 }
Example #20
0
 /**
  * 快递单
  * */
 function exdelivry()
 {
     $id = IReq::get('id');
     $tb_delivery_doc = new IQuery('delivery_doc as dd');
     $tb_delivery_doc->fields = 'd.name,dd.delivery_code,fc.freight_name';
     $tb_delivery_doc->where = 'order_id=' . $id;
     $tb_delivery_doc->join = 'left join delivery as d on dd.delivery_type=d.id left join freight_company as fc on d.freight_id=fc.id';
     $delivery_info = $tb_delivery_doc->find();
     $get_content = '暂无相关信息!';
     if (count($delivery_info) > 0) {
         //获得用户申请的id
         $config = new Config("site_config");
         $config_info = $config->getInfo();
         $express_key = isset($config_info['express_key']) ? $config_info['express_key'] : '';
         if ($express_key) {
             //获得物流名称和物流单号
             $delivery_code = $delivery_info[0]['delivery_code'];
             $name = $delivery_info[0]['freight_name'];
             $get_content = '物流公司或者货运单号错误';
             $type = '1';
             if ($delivery_code != '' && $name != '') {
                 $name = str_replace(' ', '', $name);
                 $delivery_code = str_replace(' ', '', $delivery_code);
                 $sUrl = $this->module->getBasePath();
                 include $sUrl . 'plugins/freight/company.php';
                 $company = new Company();
                 $name = $company->getCompany($name);
                 $AppKey = $express_key;
                 $url = 'http://api.kuaidi100.com/api?id=' . $AppKey . '&com=' . $name . '&nu=' . $delivery_code . '&show=2&muti=1&order=asc';
                 //请勿删除变量$powered 的信息,否者本站将不再为你提供快递接口服务。
                 $powered = '查询数据由:<a href="http://kuaidi100.com" target="_blank">KuaiDi100.Com (快递100)</a> 网站提供 ';
                 //优先使用curl模式发送数据
                 if (function_exists('curl_init') == 1) {
                     $curl = curl_init();
                     curl_setopt($curl, CURLOPT_URL, $url);
                     curl_setopt($curl, CURLOPT_HEADER, 0);
                     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                     curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
                     curl_setopt($curl, CURLOPT_TIMEOUT, 5);
                     $get_content = curl_exec($curl);
                     $type = '2';
                     curl_close($curl);
                 } else {
                     include $sUrl . 'plugins/freight/snoopy.php';
                     $snoopy = new snoopy();
                     $snoopy->referer = 'http://www.google.com/';
                     //伪装来源
                     $snoopy->fetch($url);
                     $get_content = $snoopy->results;
                     $type = '2';
                 }
             }
         } else {
             $get_content = '您还没有申请ID,请到<a href="http://kuaidi100.com" target="_blank">KuaiDi100.Com (快递100)</a>申请!';
         }
     }
     $this->setRenderData(array('conent' => $get_content, 'type' => $type));
     $this->redirect('exdelivry');
 }
Example #21
0
 function conf_base($form_index = null)
 {
     //配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $main_config = (include IWeb::$app->config['basePath'] . 'config/config.php');
     $configArray = array_merge($main_config, $site_config);
     $configArray['form_index'] = $form_index;
     $this->confRow = $configArray;
     $this->redirect('conf_base', false);
     if ($form_index != null) {
         Util::showMessage('保存成功');
     }
 }
Example #22
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_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();
         //清空购物车
         $cartObj = new Cart();
         $cartObj->clear();
     }
     //判断商品商品是否存在
     if (empty($goodsResult['goodsList']) && empty($goodsResult['productList'])) {
         IError::show(403, '商品数据不存在');
         exit;
     }
     $sum_r = $goodsResult['sum'];
     $proReduce_r = $goodsResult['proReduce'];
     $reduce_r = $goodsResult['reduce'];
     $final_sum_r = $goodsResult['final_sum'];
     $freeFreight_r = $goodsResult['freeFreight'];
     $point_r = $goodsResult['point'];
     $exp_r = $goodsResult['exp'];
     //计算运费$deliveryPrice和保价$protect_price
     $deliveryList = Delivery::getDelivery($province, $goodsResult['weight'], $final_sum_r);
     $deliveryPrice = $deliveryList[$delivery_id]['price'];
     if ($is_protectPrice == null) {
         $protect_price = 0;
         $if_insured = 0;
     } else {
         $protect_price = $deliveryList[$delivery_id]['protect_price'];
         $if_insured = 1;
     }
     if ($freeFreight_r == true) {
         $deliveryPrice_r = 0;
     } else {
         $deliveryPrice_r = $deliveryPrice;
     }
     //获取红包减免金额
     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)) {
                 $ticket_value = $ticketRow['value'];
                 $reduce_r += $ticket_value;
                 $final_sum_r -= $ticket_value;
                 $dataArray['prop'] = $ticket_id;
             }
             //锁定红包状态
             $propObj->setData(array('is_close' => 2));
             $propObj->update('id = ' . $ticket_id);
         }
     }
     //获取税率$tax
     if ($is_tax == 1) {
         $siteConfigObj = new Config("site_config");
         $site_config = $siteConfigObj->getInfo();
         $tax_per = isset($site_config['tax']) ? $site_config['tax'] : 0;
         $tax = $final_sum_r * ($tax_per / 100);
     } else {
         $tax = 0;
     }
     //货到付款的方式
     if ($payment == 0) {
         $paymentName = '货到付款';
         $payment_fee = 0;
         $paymentType = 0;
         $paymentNote = '';
     } else {
         //计算支付手续费
         $paymentObj = new IModel('payment');
         $paymentRow = $paymentObj->getObj('id = ' . $payment, 'type,poundage,poundage_type,name,note');
         $paymentName = $paymentRow['name'];
         $paymentType = $paymentRow['type'];
         $paymentNote = $paymentRow['note'];
         if ($paymentRow['poundage_type'] == 1) {
             $payment_fee = ($final_sum_r + $tax + $deliveryPrice_r + $protect_price) * ($paymentRow['poundage'] / 100);
         } else {
             $payment_fee = $paymentRow['poundage'];
         }
     }
     //最终订单金额计算
     $order_amount = $final_sum_r + $deliveryPrice_r + $payment_fee + $tax + $protect_price;
     $order_amount = $order_amount <= 0 ? 0 : round($order_amount, 2);
     //生成的订单数据
     $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');
     }
 }
Example #23
0
 /**
  * 获取商品的税金
  * @param $goodsSum float 商品总价格
  * @return $goodsTaxPrice float 商品的税金
  */
 public static function getGoodsTax($goodsSum)
 {
     $goodsTaxPrice = 0;
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $tax_per = isset($site_config['tax']) ? $site_config['tax'] : 0;
     $goodsTaxPrice = $goodsSum * ($tax_per * 0.01);
     return $goodsTaxPrice;
 }
Example #24
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');
     }
 }
Example #25
0
</a>
			<?php 
}
?>
			</span>
		</div>

		<div id="admin_left">
			<ul class="submenu"></ul>
			<div id="copyright"></div>
		</div>

		<div id="admin_right">
			<?php 
$siteConfigObj = new Config("site_config");
$site_config = $siteConfigObj->getInfo();
$configArray = array_merge(IWeb::$app->config, $site_config);
if (isset($this->confRow)) {
    $configArray = array_merge($configArray, $this->confRow);
}
$configArray['form_index'] = IReq::get('form_index') ? IFilter::act(IReq::get('form_index')) : "";
$this->confRow = $configArray;
?>

<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/editor/kindeditor-min.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/editor/lang/zh_CN.js"></script><script type="text/javascript">window.KindEditor.options.uploadJson = "/index.php?controller=pic&action=upload_json";window.KindEditor.options.fileManagerJson = "/index.php?controller=pic&action=file_manager_json";</script>
Example #26
0
 function find($defaultWhere, &$goodsObj)
 {
     //获取配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //开始查询
     $goodsObj = new IQuery("goods as go");
     $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $goodsObj->pagesize = isset($site_config['list_num']) ? $site_config['list_num'] : 20;
     $goodsObj->fields = ' go.* ';
     /*where条件拼接*/
     //(1),当前产品分类
     $where = ' go.is_del = 0 ';
     //(2),商品属性,规格筛选
     $attrCond = array();
     $specCond = array();
     $childSql = '';
     $attrArray = IReq::get('attr');
     $specArray = IReq::get('spec');
     if (!empty($attrArray)) {
         foreach ($attrArray as $key => $val) {
             if ($key != '' && $val != '') {
                 $attrCond[] = ' attribute_id = ' . $key . ' and FIND_IN_SET("' . $val . '",`attribute_value`)';
             }
         }
     }
     if (!empty($specArray)) {
         foreach ($specArray as $key => $val) {
             if ($key != '' && $val != '') {
                 $specCond[] = ' spec_id = ' . $key . ' and spec_value like "_|' . $val . '" ';
             }
         }
     }
     //合并规格与属性的值,并且生成SQL查询语句
     $GoodsId = array();
     $sumCond = array_merge($attrCond, $specCond);
     if (!empty($sumCond)) {
         $tempArray = array();
         foreach ($sumCond as $key => $cond) {
             $tempArray[] = '(' . $cond . ')';
         }
         $childSql = join(' or ', $tempArray);
         $goodsAttrObj = new IQuery('goods_attribute');
         $goodsAttrObj->fields = 'goods_id';
         $goodsAttrObj->where = $childSql;
         $goodsAttrObj->group = 'goods_id';
         $goodsAttrObj->having = 'count(goods_id) >= ' . count($sumCond);
         $goodsIdArray = $goodsAttrObj->find();
         if (empty($goodsIdArray)) {
             $GoodsId[] = 0;
         } else {
             foreach ($goodsIdArray as $key => $val) {
                 $GoodsId[] = $val['goods_id'];
             }
         }
     }
     //(3),处理defaultWhere条件
     if (is_array($defaultWhere)) {
         $where .= isset($defaultWhere['goods']) ? ' and ' . $defaultWhere['goods'] : '';
         $currentCatGoods = array();
         if (isset($defaultWhere['category_extend']) && $defaultWhere['category_extend'] != '') {
             $categoryExtendObj = new IModel('category_extend');
             $categoryExtendList = $categoryExtendObj->query("category_id in (" . $defaultWhere['category_extend'] . ")", 'goods_id');
             foreach ($categoryExtendList as $val) {
                 $currentCatGoods[] = $val['goods_id'];
             }
             if ($GoodsId) {
                 $GoodsId = array_intersect($currentCatGoods, $GoodsId);
             } else {
                 $GoodsId = $currentCatGoods;
             }
             $GoodsId = empty($GoodsId) ? array(0) : $GoodsId;
         }
     } else {
         if ($defaultWhere != '') {
             $where .= ' and ' . $defaultWhere;
         }
     }
     if ($GoodsId) {
         $where .= " and go.id in (" . join(',', $GoodsId) . ") ";
     }
     //(4),商品价格
     $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : '';
     $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : '';
     //(5),商品品牌
     $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : '';
     //排序类别
     $order = IReq::get('order');
     if ($order == null) {
         $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new';
         $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc';
     } else {
         if (stripos($order, '_toggle')) {
             $order = str_replace('_toggle', '', $order);
             $asc = 'asc';
         } else {
             $order = IFilter::act($order);
             $asc = 'desc';
         }
     }
     switch ($order) {
         //销售量
         case "sale":
             $goodsObj->join = ' left join order_goods as ord on (go.id = ord.goods_id) ';
             $goodsObj->fields .= ' , sum(ord.goods_nums) as sell_num';
             $goodsObj->order = ' sell_num ' . $asc;
             $goodsObj->group = ' go.id ';
             break;
             //评分
         //评分
         case "cpoint":
             $goodsObj->join = ' left join comment as co on (go.id = co.goods_id) ';
             $goodsObj->fields .= ' ,sum(co.point) as sum_point ';
             $goodsObj->order = ' sum_point ' . $asc;
             $goodsObj->group = 'go.id';
             break;
             //最新上架
         //最新上架
         case "new":
             $goodsObj->order = ' go.id ' . $asc;
             break;
             //价格
         //价格
         case "price":
             $goodsObj->order = ' go.sell_price ' . $asc;
             break;
     }
     //设置IQuery类的各个属性
     $goodsObj->where = $where;
     $goodsList = $goodsObj->find();
     //拼接goodsID
     $goodsIdArray = array();
     foreach ($goodsList as $val) {
         $goodsIdArray[] = $val['id'];
     }
     $goodsIdStr = join(',', $goodsIdArray);
     //查找订单和评论
     $resultArray = array();
     if (!empty($goodsIdArray)) {
         /*由于 sale 的排序的方式会查询 order_goods 所以当 order 为 sale 方式时可以不必查询 order_goods */
         if ($order != 'sale') {
             //订单对象
             $orderObj = new IQuery('order_goods as ord');
             $orderObj->fields = 'ord.goods_id , sum(ord.goods_nums) as sell_num';
             $orderObj->where = 'goods_id in (' . $goodsIdStr . ')';
             $orderObj->group = 'ord.goods_id';
             $orderList = $orderObj->find();
             foreach ($orderList as $val) {
                 $resultArray[$val['goods_id']]['sell_num'] = $val['sell_num'];
             }
         }
         //评论对象
         $commentObj = new IQuery('comment as co');
         $commentObj->fields = 'co.goods_id , count(*) as comments_num , sum(co.point) / count(co.goods_id) as average_point';
         $commentObj->where = ' goods_id in (' . $goodsIdStr . ') and co.status = 1 ';
         $commentObj->group = 'co.goods_id';
         $commentList = $commentObj->find();
         foreach ($commentList as $val) {
             $resultArray[$val['goods_id']]['comments_num'] = $val['comments_num'];
             $resultArray[$val['goods_id']]['average_point'] = $val['average_point'];
         }
         //拼接goodsList中
         foreach ($goodsList as $key => $val) {
             if ($order != 'sale') {
                 $sellNum = isset($resultArray[$val['id']]['sell_num']) ? $resultArray[$val['id']]['sell_num'] : 0;
                 $goodsList[$key]['sell_num'] = $sellNum;
             }
             //拼接评论和积分数据
             $commentsNum = isset($resultArray[$val['id']]['comments_num']) ? $resultArray[$val['id']]['comments_num'] : 0;
             $average_point = isset($resultArray[$val['id']]['average_point']) ? $resultArray[$val['id']]['average_point'] : 0;
             $goodsList[$key]['comments_num'] = $commentsNum;
             $goodsList[$key]['average_point'] = $average_point;
         }
     }
     return $goodsList;
 }
Example #27
0
 /**
  * @brief 商品检索,可以直接读取 $_GET 全局变量:attr,order,brand,min_price,max_price
  *        在检索商品过程中计算商品结果中的进一步属性和规格的筛选
  * @param mixed $defaultWhere string(条件) or array('search' => '模糊查找','category_extend' => '商品分类ID','字段' => 对应数据)
  * @param int $limit 读取数量
  * @param bool $isCondition 是否筛选出商品的属性,价格等数据
  * @return IQuery
  */
 public static function find($defaultWhere = '', $limit = 21, $isCondition = true)
 {
     //获取配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $orderArray = array();
     //排序
     //开始查询
     $goodsObj = new IQuery("goods as go");
     $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $goodsObj->fields = ' go.* ';
     $goodsObj->pagesize = $limit;
     /*where条件拼接*/
     //(1),当前产品分类
     $where = ' go.is_del = 0 ';
     //(2),商品属性,规格筛选
     $attrCond = array();
     $childSql = '';
     $attrArray = IReq::get('attr') ? IFilter::act(IReq::get('attr')) : array();
     foreach ($attrArray as $key => $val) {
         if ($key && $val) {
             $attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",attribute_value)';
         }
     }
     //合并规格与属性的值,并且生成SQL查询语句
     $GoodsId = null;
     if ($attrCond) {
         $tempArray = array();
         foreach ($attrCond as $key => $cond) {
             $tempArray[] = '(' . $cond . ')';
         }
         $childSql = join(' or ', $tempArray);
         $goodsAttrObj = new IQuery('goods_attribute');
         $goodsAttrObj->fields = 'goods_id';
         $goodsAttrObj->where = $childSql;
         $goodsAttrObj->group = 'goods_id';
         $goodsAttrObj->having = 'count(goods_id) >= ' . count($attrCond);
         //每个子条件都有一条记录,则存在几个count(条件)必须包含count(goods_id)条数量
         $goodsIdArray = $goodsAttrObj->find();
         $goodsIds = array();
         foreach ($goodsIdArray as $key => $val) {
             $goodsIds[] = $val['goods_id'];
         }
         $GoodsId = $GoodsId === null ? array_unique($goodsIds) : array_unique(array_intersect($goodsIds, $GoodsId));
     }
     //(3),处理defaultWhere条件 goods, category_extend
     if ($defaultWhere) {
         //兼容array 和 string 数据类型的goods条件筛选
         $goodsCondArray = array();
         if (is_string($defaultWhere)) {
             $goodsCondArray[] = $defaultWhere;
         } else {
             if (is_array($defaultWhere)) {
                 foreach ($defaultWhere as $key => $val) {
                     if (!$val) {
                         continue;
                     }
                     //商品分类检索
                     if ($key == 'category_extend') {
                         $currentCatGoods = array();
                         $categoryExtendObj = new IModel('category_extend');
                         $categoryExtendList = $categoryExtendObj->query("category_id in (" . $val . ")", 'goods_id', 'id', 'desc');
                         foreach ($categoryExtendList as $key => $val) {
                             $currentCatGoods[] = $val['goods_id'];
                         }
                         $GoodsId = $GoodsId === null ? array_unique($currentCatGoods) : array_unique(array_intersect($currentCatGoods, $GoodsId));
                     } else {
                         if ($key == 'search') {
                             $wordWhere = array();
                             $wordLikeOrder = array();
                             //检查输入的内容是否为分词形式
                             if (preg_match("#\\s+#", $defaultWhere['search']) == false) {
                                 $wordWhere[] = ' name like "%' . $defaultWhere['search'] . '%" or find_in_set("' . $defaultWhere['search'] . '",search_words) ';
                                 $wordLikeOrder[] = $defaultWhere['search'];
                             }
                             //进行分词
                             if (IString::getStrLen($defaultWhere['search']) >= 4 || IString::getStrLen($defaultWhere['search']) <= 100) {
                                 $wordData = words_facade::run($defaultWhere['search']);
                                 if (isset($wordData['data']) && count($wordData['data']) >= 2) {
                                     foreach ($wordData['data'] as $word) {
                                         $wordWhere[] = ' name like "%' . $word . '%" ';
                                         $wordLikeOrder[] = $word;
                                     }
                                 }
                             }
                             //分词排序
                             if (count($wordLikeOrder) > 1) {
                                 $orderTempArray = array();
                                 foreach ($wordLikeOrder as $key => $val) {
                                     $orderTempArray[] = "(CASE WHEN name LIKE '%" . $val . "%' THEN " . $key . " ELSE 100 END)";
                                 }
                                 $orderArray[] = " (" . join('+', $orderTempArray) . ") asc ";
                             }
                             $goodsCondArray[] = join(' or ', $wordWhere);
                         } else {
                             $goodsCondArray[] = $key . ' = "' . $val . '"';
                         }
                     }
                 }
             }
         }
         //goods 条件
         if ($goodsCondArray) {
             $goodsDB = new IModel('goods as go');
             $goodsCondData = $goodsDB->query(join(" and ", $goodsCondArray), "id");
             $goodsCondId = array();
             foreach ($goodsCondData as $key => $val) {
                 $goodsCondId[] = $val['id'];
             }
             $GoodsId = $GoodsId === null ? array_unique($goodsCondId) : array_unique(array_intersect($goodsCondId, $GoodsId));
         }
     }
     //过滤商品ID被删除的情况
     if ($GoodsId) {
         if (!isset($goodsDB)) {
             $goodsDB = new IModel("goods as go");
         }
         $goodsCondData = $goodsDB->query("go.id in (" . join(',', $GoodsId) . ") and go.is_del = 0 ", "id");
         $GoodsId = array();
         foreach ($goodsCondData as $key => $val) {
             $GoodsId[] = $val['id'];
         }
     }
     $GoodsId = $GoodsId === array() || $GoodsId === null ? array(0) : array_unique($GoodsId);
     //存在商品ID数据
     if ($GoodsId) {
         $GoodsId = array_slice($GoodsId, 0, search_goods::MAX_GOODSID);
         $where .= " and go.id in (" . join(',', $GoodsId) . ") ";
         //商品属性进行检索
         if ($isCondition == true) {
             /******属性 开始******/
             $attrTemp = array();
             $goodsAttrDB = new IModel('goods_attribute');
             $attrData = $goodsAttrDB->query("goods_id in (" . join(',', $GoodsId) . ")");
             foreach ($attrData as $key => $val) {
                 //属性
                 if ($val['attribute_id']) {
                     if (!isset($attrTemp[$val['attribute_id']])) {
                         $attrTemp[$val['attribute_id']] = array();
                     }
                     $checkSelectedArray = explode(",", $val['attribute_value']);
                     foreach ($checkSelectedArray as $k => $v) {
                         if (!in_array($v, $attrTemp[$val['attribute_id']])) {
                             $attrTemp[$val['attribute_id']][] = $v;
                         }
                     }
                 }
             }
             //属性的数据拼接
             if ($attrTemp) {
                 $attrDB = new IModel('attribute');
                 $attrData = $attrDB->query("id in (" . join(',', array_keys($attrTemp)) . ") and search = 1", "*", "id", "asc", 8);
                 foreach ($attrData as $key => $val) {
                     self::$attrSearch[] = array('id' => $val['id'], 'name' => $val['name'], 'value' => $attrTemp[$val['id']]);
                 }
             }
             /******属性 结束******/
             /******品牌 开始******/
             $brandQuery = new IModel('brand as b,goods as go');
             self::$brandSearch = $brandQuery->query("go.brand_id = b.id and go.id in (" . join(',', $GoodsId) . ")", "distinct b.id,b.name", "b.sort", "asc", 10);
             /******品牌 结束******/
             /******价格 开始******/
             self::$priceSearch = goods_class::getGoodsPrice(join(',', $GoodsId));
             /******价格 结束******/
         }
     }
     //(4),商品价格
     $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : '';
     $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : '';
     //(5),商品品牌
     $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : '';
     //排序类别
     $order = IFilter::act(IReq::get('order'), 'url');
     if ($order == null) {
         $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new';
         $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc';
     } else {
         if (stripos($order, '_toggle')) {
             $order = str_replace('_toggle', '', $order);
             $asc = 'asc';
         } else {
             $asc = 'desc';
         }
     }
     switch ($order) {
         //销售量
         case "sale":
             $orderArray[] = ' go.sale ' . $asc;
             break;
             //评分
         //评分
         case "cpoint":
             $orderArray[] = ' go.grade ' . $asc;
             break;
             //最新上架
         //最新上架
         case "new":
             $orderArray[] = ' go.id ' . $asc;
             break;
             //价格
         //价格
         case "price":
             $orderArray[] = ' go.sell_price ' . $asc;
             break;
             //根据排序字段
         //根据排序字段
         default:
             $orderArray[] = ' go.sort asc ';
     }
     //设置IQuery类的各个属性
     $goodsObj->where = $where;
     $goodsObj->order = join(',', $orderArray);
     return $goodsObj;
 }
Example #28
0
 /**
  * @brief 商品检索,可以直接读取 $_GET 全局变量:attr,spec,order,brand,min_price,max_price
  * @param $defaultWhere string or array('goods' => '查询信息','category_extend' => '商品分类ID')
  * @return IQuery
  */
 public static function find($defaultWhere = '')
 {
     //获取配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     //开始查询
     $goodsObj = new IQuery("goods as go");
     $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $goodsObj->pagesize = isset($site_config['list_num']) ? $site_config['list_num'] : 20;
     $goodsObj->fields = ' go.* ';
     /*where条件拼接*/
     //(1),当前产品分类
     $where = ' go.is_del = 0 ';
     //(2),商品属性,规格筛选
     $attrCond = array();
     $specCond = array();
     $childSql = '';
     $attrArray = IFilter::act(IReq::get('attr'));
     $specArray = IFilter::act(IReq::get('spec'));
     if ($attrArray) {
         foreach ($attrArray as $key => $val) {
             if ($key && $val) {
                 $attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",`attribute_value`)';
             }
         }
     }
     if ($specArray) {
         foreach ($specArray as $key => $val) {
             if ($key && $val) {
                 $specCond[] = ' spec_id = ' . intval($key) . ' and spec_value = "' . $val . '"';
             }
         }
     }
     //合并规格与属性的值,并且生成SQL查询语句
     $GoodsId = array();
     $sumCond = array_merge($attrCond, $specCond);
     if ($sumCond) {
         $tempArray = array();
         foreach ($sumCond as $key => $cond) {
             $tempArray[] = '(' . $cond . ')';
         }
         $childSql = join(' or ', $tempArray);
         $goodsAttrObj = new IQuery('goods_attribute');
         $goodsAttrObj->fields = 'goods_id';
         $goodsAttrObj->where = $childSql;
         $goodsAttrObj->group = 'goods_id';
         $goodsAttrObj->having = 'count(goods_id) >= ' . count($sumCond);
         $goodsIdArray = $goodsAttrObj->find();
         if ($goodsIdArray) {
             foreach ($goodsIdArray as $key => $val) {
                 $GoodsId[] = $val['goods_id'];
             }
         } else {
             $GoodsId[] = 0;
         }
     }
     //(3),处理defaultWhere条件
     if (is_array($defaultWhere)) {
         $where .= isset($defaultWhere['goods']) ? ' and ' . $defaultWhere['goods'] : '';
         $currentCatGoods = array();
         if (isset($defaultWhere['category_extend']) && $defaultWhere['category_extend']) {
             $categoryExtendObj = new IModel('category_extend');
             $categoryExtendList = $categoryExtendObj->query("category_id in (" . $defaultWhere['category_extend'] . ")", 'goods_id');
             foreach ($categoryExtendList as $val) {
                 $currentCatGoods[] = $val['goods_id'];
             }
             $GoodsId = $GoodsId ? array_intersect($currentCatGoods, $GoodsId) : $currentCatGoods;
             if (!$GoodsId) {
                 $GoodsId = array(0);
             }
         }
     } else {
         if ($defaultWhere != '') {
             $where .= ' and ' . $defaultWhere;
         }
     }
     if ($GoodsId) {
         $where .= " and go.id in (" . join(',', $GoodsId) . ") ";
     }
     //(4),商品价格
     $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : '';
     $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : '';
     //(5),商品品牌
     $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : '';
     //排序类别
     $order = IFilter::act(IReq::get('order'), 'url');
     if ($order == null) {
         $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new';
         $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc';
     } else {
         if (stripos($order, '_toggle')) {
             $order = str_replace('_toggle', '', $order);
             $asc = 'asc';
         } else {
             $asc = 'desc';
         }
     }
     switch ($order) {
         //销售量
         case "sale":
             $goodsObj->order = ' go.sale ' . $asc;
             break;
             //评分
         //评分
         case "cpoint":
             $goodsObj->order = ' go.grade ' . $asc;
             break;
             //最新上架
         //最新上架
         case "new":
             $goodsObj->order = ' go.id ' . $asc;
             break;
             //价格
         //价格
         case "price":
             $goodsObj->order = ' go.sell_price ' . $asc;
             break;
     }
     //设置IQuery类的各个属性
     $goodsObj->where = $where;
     return $goodsObj;
 }