コード例 #1
0
 public function index()
 {
     $op = ggp('op');
     if ($op == 'do') {
         $this->isLogin();
         list($address, $realname) = explode('@', $this->my['device_token']);
         $this->my['decive_token'] = unserialize($this->my['device_token']);
         if (!$address || !$this->my['mobile'] || !$realname) {
             $this->myError('请完善您的收货信息', U('member/address'));
         }
         $jf_goods_id = ggp('jf_goods_id:i');
         $jfitem = M('jf_goods')->where('state=1')->find($jf_goods_id);
         empty($jfitem) && $this->myError('没有该商品');
         $jfitem['jf_goods_jf'] > $this->my['jifen'] && $this->myError('您的积分不足');
         MemberModel::I()->decJf($this->my['uid'], $jfitem['jf_goods_jf']);
         M('jf_log')->add(array('uid' => $this->my['uid'], 'uname' => $this->my['uname'], 'order_id' => $jfitem['jf_goods_id'], 'state' => 0, 'jf_goods_jf' => -$jfitem['jf_goods_jf'], 'ctime' => TIME, 'beizhu' => serialize(array('jf_goods_name' => $jfitem['jf_goods_name'], 'address' => $address, 'realname' => $realname, 'mobile' => $this->my['mobile']))));
         if ($jfitem['jf_goods_num'] > 0) {
             if (intval($jfitem['jf_goods_num']) === 1) {
                 M('jf_goods')->where("jf_goods_id='{$jfitem['jf_goods_id']}'")->save(array('state' => 0));
             }
             M('jf_goods')->where("jf_goods_id='{$jfitem['jf_goods_id']}'")->setDec('jf_goods_num');
         }
         $this->mySuccess('兑换成功');
     }
     $hot_goods = M('goods')->where("state=1")->order('`order` DESC,hits DESC,goods_id DESC')->limit(8)->select();
     $this->assign('hot_goods', $hot_goods);
     $list = M('jf_goods')->where("state=1")->order('`order` desc,jf_goods_id desc')->select();
     $this->a('$list', $list);
     $this->d();
 }
コード例 #2
0
 public function index()
 {
     $keywords = ggp('keywords:t2');
     $this->assign('keyword', $keywords);
     if (!$keywords) {
         $this->error('请输入搜索的关键词');
     }
     $sx_price = I('get.price');
     $sx_from = I('get.from');
     $discount = I('get.discount');
     $where['state'] = 1;
     $where['title'] = array('like', "%{$keywords}%");
     if ($sx_from == 'tmall') {
         $where['goods_type'] = 'tmall';
     } elseif ($sx_from == 'taobao') {
         $where['goods_type'] = 'taobao';
     } elseif ($sx_from == 'qugoumai') {
         $where['goods_type'] = 'qugoumai';
     }
     if ($sx_price == 'asc') {
         $orderby = '`discount_price` ASC';
     } elseif ($sx_price == 'desc') {
         $orderby = '`discount_price` DESC';
     }
     if ($discount == 'asc') {
         $orderby = $orderby ? $orderby . ',discount_price/price ASC' : 'discount_price/price ASC';
     } elseif ($discount == 'desc') {
         $orderby = $orderby ? $orderby . ',discount_price/price DESC' : 'discount_price/price DESC';
     }
     if ($sx_price || $discount) {
         $orderby .= ",`order` DESC,goods_id DESC";
     }
     $goodsdb = M('goods');
     $count = $goodsdb->where($where)->count();
     $once = 20;
     $Page = $this->iniPage($count, $once);
     $result = D('Goods')->_getGoodsList($Page, $where, $orderby);
     if (false) {
     } else {
         $totalPage = ceil($goodsdb->where($where)->count() / $once);
         $shaixuan['price'] = $sx_price;
         $shaixuan['from'] = $sx_from;
         $shaixuan['discount'] = $discount;
         $this->assign('goods', $result);
         $this->assign('shaixuan', $shaixuan);
         $this->assign('totalPage', $totalPage);
         if (IS_AJAX) {
             $page = I('get.p', '', 'intval');
             $this->assign('page', $page + 1);
             $this->display('Ajax:ajgetgoods');
         } else {
             $this->display();
         }
     }
 }
コード例 #3
0
 public function postArticle()
 {
     $op = ggp('op');
     $this->a('art', $art = M('article')->find(ggp('aid:i')));
     $this->a('sort', $sort = M('sort')->where("type=2 and state=1")->select());
     if ($op == 'do') {
         $title = ggp('title:t2');
         !$title && $this->myError('请填写标题');
         $content = ggp('content:h2');
         !$content && $this->myError('请填写文章内容');
         $sort_id = ggp('sort_id:i');
         $p = array('title' => $title, 'content' => $content, 'sort_id' => $sort_id, 'state' => -1, 'ctime' => TIME);
         M('article')->add($p);
         $this->mySuccess('提交成功,请耐心等待理员审核');
     }
     $this->d();
 }
コード例 #4
0
 public function favor()
 {
     $this->isLogin();
     $op = ggp('op');
     if ($op == 'do') {
         $goods_id = ggp('id:i');
         if (D('Member')->addFavor($this->my['uid'], $goods_id)) {
             $this->success('收藏成功');
         } else {
             $this->success('您已经收藏该商品');
         }
     }
     $pre = getPre();
     $goods = M()->field('g.*')->table("{$pre}favor f")->join("{$pre}goods g on f.goods_id=g.goods_id")->where("f.uid='{$this->my['uid']}'")->select();
     $this->assign('goods', $goods);
     $this->display();
 }
コード例 #5
0
 public function index()
 {
     $once = 20;
     $where = 'state=1';
     $sort_id = ggp('sort_id:i');
     $this->a('sort_id', $sort_id);
     $keywords = ggp('keywords:t2');
     $this->a('keywords', $keywords);
     $sort_id && ($where .= " and sort_id='{$sort_id}'");
     $keywords && ($where .= " and title like '%{$keywords}%'");
     $goodsdb = M('goods');
     $count = $goodsdb->where($where)->count();
     $totalPage = ceil($count / $once);
     $page = $this->iniPage($count, $once);
     $this->assign('goods', $goodsdb->where($where)->order("`order` desc,goods_id desc")->limit("{$page->firstRow},{$page->listRows}")->select());
     $this->assign('totalPage', $totalPage);
     $this->display(ggp('ajax') ? 'ajaxindex' : '');
 }
コード例 #6
0
 public function settingSlide()
 {
     $op = ggp('op');
     if ($op == 'do') {
         for ($i = 0; $i < 5; $i++) {
             $slide[$i] = ggp("slide{$i}:t2");
         }
         $_POST['slide'] = serialize($slide);
         $this->_setting();
     }
     $slide = unserialize($this->setting['slide']);
 }
コード例 #7
0
$parentSort = IndexModel::I()->getSortById($sort['p_id']);
?>
                <?php 
if ($parentSort) {
    ?>
<a href="<?php 
    echo U('article/artlist', array('id' => $parentSort['sort_id']));
    ?>
"><?php 
    echo $parentSort['sort_name'];
    ?>
</a> &gt;<?php 
}
?>
                <a href="<?php 
echo U('article/artlist', array('id' => ggp('id:i')));
?>
"><?php 
echo $sort['sort_name'];
?>
</a>
            </h2>
        </div>
    </div>
    <div class="row">
        <div class="span9">
            <div class="" id="artlist">
            <ul>
             <?php 
if (is_array($artList)) {
    $i = 0;
コード例 #8
0
 public function myGoods()
 {
     $op = ggp('op');
     $goodsM = M('goods');
     if ($op == 'del') {
         $goods_id = ggp('goods_id');
         $goodsM->where("goods_id='{$goods_id}'")->delete();
         $this->mySuccess('操作成功');
     }
     $where = "1 and add_uname='{$this->my['uname']}'";
     $page = $this->iniPage($goodsM->where($where)->count());
     $myGoods = $goodsM->where($where)->limit("{$page->firstRow},{$page->listRows}")->order('goods_id desc')->select();
     $this->a('myGoods', $myGoods);
     $this->a('page', $page->show());
     $this->d();
 }
コード例 #9
0
 public function wxPay()
 {
     $order_id = ggp('order_id:i');
     vendor('WxPayPubHelper.WxPay', '', '.pub.config.php');
     WxPayConf_pub::$SSLCERT_PATH .= $_SERVER['SERVER_NAME'] . '_cert.pem';
     WxPayConf_pub::$SSLKEY_PATH .= $_SERVER['SERVER_NAME'] . '_key.pem';
     WxPayConf_pub::$APPID = $this->setting['wx_appid'];
     WxPayConf_pub::$MCHID = $this->setting['wx_mchid'];
     WxPayConf_pub::$KEY = $this->setting['wx_key'];
     WxPayConf_pub::$APPSECRET = $this->setting['wx_appsecret'];
     vendor('WxPayPubHelper.WxPayPubHelper');
     $where = "order_id='{$order_id}' and state=6";
     $order = M('order')->where($where)->find();
     if (empty($order)) {
         exit('没有找到订单');
     }
     $unifiedOrder = new UnifiedOrder_pub();
     $unifiedOrder->setParameter("body", $order['store_name']);
     //商品描述
     $unifiedOrder->setParameter("out_trade_no", $order['order_sn']);
     //商户订单号
     $unifiedOrder->setParameter("total_fee", $order['pay_price'] * 100);
     //总金额
     $notify = "http://{$_SERVER['SERVER_NAME']}/wx_notify.php";
     $unifiedOrder->setParameter("notify_url", $notify);
     //通知地址
     $unifiedOrder->setParameter("trade_type", "NATIVE");
     //交易类型
     $unifiedOrderResult = $unifiedOrder->getResult();
     //商户根据实际情况设置相应的处理流程
     if ($unifiedOrderResult["return_code"] == "FAIL") {
         //商户自行增加处理流程
         echo "通信出错:" . $unifiedOrderResult['return_msg'] . "<br>";
     } elseif ($unifiedOrderResult["result_code"] == "FAIL") {
         //商户自行增加处理流程
         echo "错误代码:" . $unifiedOrderResult['err_code'] . "<br>";
         echo "错误代码描述:" . $unifiedOrderResult['err_code_des'] . "<br>";
     } elseif ($unifiedOrderResult["code_url"] != NULL) {
         //从统一支付接口获取到code_url
         $codeUrl = $unifiedOrderResult["code_url"];
     }
     $this->a('codeUrl', $codeUrl);
     $this->a('order_id', $order_id);
     $this->d("Order:wxpay");
 }