Article.php 11 KB
<?php
/**
 * tpshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
 * 网站地址: http://www.tp-shop.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: IT宇宙人 2015-08-10 $
 */ 
namespace app\mobile\controller;
use think\Db;
use think\Page;
class Article extends MobileBase {
    // public $lists;
    public function index(){       
        $article_id = I('article_id/d',38);
    	$article = D('article')->where("article_id", $article_id)->find();
    	$this->assign('article',$article);
        return $this->fetch('',getMobileStoId());
    }
 

    /**
     * 文章内列表页
     */


    // public function articleList(){        
    //     $list = M('Article')->where('is_open',1)->select();
    //     $article_categroy=M('Article_cat')->order('sort_order asc')->select();
    //     $this->assign('list',$list);
    //     $this->assign('article_categroy',$article_categroy);
    //     //return $this->fetch('',getMobileStoId());
    //     //return $this->fetch('articleList1');
    //     return $this->fetch();
    // }    

      public function articleList(){        
    //     //$list = M('Article')->where('is_open',1)->select();
    //     $p = I('p');
    //     $count = M('Article')->where('is_open',1)->count();
    //     //$pager = new Page($count,2);
    // if($p==0){
           // $pagercount = 2;
    // }else{
    //     $pagercount = $p*2+2;
    // }
    

        
         // $sql = "SELECT * FROM __PREFIX__article WHERE is_open = 1 ORDER BY article_id DESC LIMIT 0,".$pagercount;
         // $list = DB::query($sql);
    //    // $lists = $lists.$list;
         $article_categroy=M('Article_cat')->where(' show_in_nav=1 and  store_id='.getMobileStoId())->order('sort_order asc')->select();

    //     //$show = $pager->show();
    //     $this->assign('page',$show);
         // $this->assign('list',$list);
         $this->assign('article_categroy',$article_categroy);

    //     //return $this->fetch('',getMobileStoId());
    //     //return $this->fetch('articleList1');
        return $this->fetch();
    }

   public function articleList2()
   {
       //$list = M('Article')->where('is_open',1)->select();
       $p = I('p');
       $stoid = I('stoid');

       $categroy = I('categroy');

       if ($categroy == 0 || empty($categroy)) {

           $count = M('Article')->where(array('is_open' => 1, 'store_id' => $stoid))->count();
       }
       else {
           $count = M('Article')->where(array('is_open' => 1,'cat_id'=>$categroy, 'store_id' => $stoid))->count();
       }
       $pcount = 10;
        $pager = new Page($count,$pcount);

        $first = $p*$pcount;
        
        if ($categroy==0  || empty($categroy) ) {
            
             $sql = "SELECT article_id,cat_id,title,description,thumb,click,store_id FROM __PREFIX__article WHERE is_open = 1 and store_id = $stoid ORDER BY article_id DESC LIMIT ".$first.",".$pcount;
        }else{
           
            $sql = "SELECT article_id,cat_id,title,description,thumb,click,store_id FROM __PREFIX__article WHERE is_open = 1 and cat_id=$categroy and store_id = $stoid ORDER BY article_id DESC LIMIT ".$first.",".$pcount;
        }
       // mlog($sql);
        $list = DB::query($sql);
        $article_categroy=M('Article_cat')->where(' store_id='.getMobileStoId())->order('sort_order asc')->select();

       if ($count>0)
       {
           $jsonlist['state']="1";
           $jsonlist['msg']='成功';
           $jsonlist['page']=$pager->totalPages;
       }
       else
       {
           $jsonlist['state']="0";
           $jsonlist['msg']='无数据';
       }
       $jsonlist['item']=$list;
         return json($jsonlist);
    }




    /**
     * 文章内容页
     */
    public function article(){
    	$article_id = I('article_id/d',1);
    	$article = D('article')->alias('a')->join("wxd_article_cat b","a.cat_id=b.cat_id")->field("a.*,b.cat_name")->where("article_id", $article_id)->find();
        $this->assign('article',$article);
    	D('article')->where("article_id",$article_id)->setInc('click');
    	upload_ylp_log('文章内容详情');
        return $this->fetch('',getMobileStoId());
    }

    /**
     * 图文文章内容页
     */
    public function articletw(){
        $article_id = I('article_id/d',1);
        $article = D('wx_menulistdet')->alias('a')->field("a.*")->where("id", $article_id)->find();
        $this->assign('article',$article);
        D('wx_menulistdet')->where("id",$article_id)->setInc('click');
        upload_ylp_log('图文文章内容详情');
        return $this->fetch('',getMobileStoId());
    }

    /*--充值预存款--*/
    public function Yucun_add($vipid,$rs,$tk)
    {
//        $data=array(
//            'VIPId' => $vipid,//会员ID
//            'BillDate'=>date('Y-m-d H:m:s'),//单据日期
//            'AdvanceItemId'=>$rs["yucun_Advance_Id"],//预存款项目id
//            'AddSum'=>$rs["price"],//预存金额
//            'Remark'=>$rs["integral_remark"],//摘要
//            'FromBillId'=>$rs["order_sn"],//来源ID
//            'kind'=>'',//空:自定义充值 非空:促销充值ID
//        );
        $data=array(
            'FromId' => "1000201705094649303510",//会员ID
            'CashRepNo'=>"201705094209303510",//单据日期
            'Sum'=>0.01,//预存款项目id
            'Operator'=>'微信商城',//来源
            'Integral'=>-50,//预存金额
            'vipRemark'=>"50积分兑换0.01元微券(少军专用)",//摘要
            'Remark'=>"50积分兑换0.01元微券(少军专用111)",//来源ID
            'Id'=>"6BBBF1B0-7E86-43C7-B6EA-458071E0A27A",//空:自定义充值 非空:促销充值ID
        );
//        {"FromId":"1000201705094649303510","CashRepNo":"201705094209303510","Sum":0.01,"Integral":-50,"vipRemark":"50\u79ef\u5206\u5151\u63620.01\u5143\u5fae\u5238(\u65e0\u9650\u5236)","Remark":"50\u79ef\u5206\u5151\u63620.01\u5143\u5fae\u5238","Id":"6BBBF1B0-7E86-43C7-B6EA-458071E0A27A"}

        $re1=getApiData("wxd.vip.intertocash",$tk['api_token'],array($data,));
        /*---
        $list = array("access_token"=>"wxd.vip.intertocash");
        $array =array(
            'token'=>$tk['api_token'],
            'data'=>array(
                $data,
            ),//$data,
            'map'=>"",
            'order'=>"",
        );
        $json=json_encode($array);
        mlog("微券:".$json,"weiquan");
        $url=GetSignUrl($list);

        if(empty($url)){
            return json(["code"=>"-1","msg"=>"生成签名错误"]);
        }
        $rs=http_post_json($url,$json);---*/
        upload_ylp_log('充值预存款');
        return $rs;

    }

    public function  tempUser(){
echo microtime_format('Ymd H:i:s,x',microtime_float());exit;
//        $vipid="841370ce-908e-462d-9979-537a3b40e19e";
//        $rs = M('recharge')->where('order_sn', "vop201704281641455906")->find();
//        $tk=M("store")->where("store_id","1")->field("api_token")->find();
//        $this->yucun_add($vipid,$rs,$tk);exit;
        //$user = session('user');
//        $users = D("users")->where("user_id", "2627")->find();
//
//        if(empty($users["erpvipid"])){
//            return json(["code"=>"-1","msg"=>"会员信息错误"]);
//        }
//        $id = $users["erpvipid"];
//        $id = "{".$id."}";
//        $data=array(
//            'VIPId' => "841370ce-908e-462d-9979-537a3b40e19e",//会员ID
//            'BillDate'=>date('Y-m-d'),//单据日期
//            'AdvanceItemId'=>'3ec13990-ba52-44c4-8124-94f0bc5b7a0f',//预存款项目id
//            'AddSum'=>'100',//预存金额
//            'Remark'=>'摘要',//摘要
//            'FromBillId'=>'robred2016092215225209265428',//来源ID
//            'kind'=>'',//空:自定义充值 非空:促销充值ID
//        );

//        $where['VIPId']=array('=','EF7CBA26-0F6C-43A4-A231-8C16DC831376');
//        //$where["VIPId"]=array('=','441d2837-a651-4518-a55e-19f6aad644e1');
//        //$where["VIPId"]=array('=','441d2837-a651-4518-a55e-19f6aad644e1');
//        //$where['MobileTel']=array('=','13599906619');
////        $where['VIPNo']=array('=','1052');
//        /*--测试用常量--*/
//        $store = I('stoid');
//        $tk=M("store")->where("store_id","1")->field("api_token")->find();
//
//        $list = array("access_token"=>"wxd.vip.addactlist");
//        /*--post数据--*/
//        $array =array(
//            'token'=>"beba071ae1ed9b303938838955edd09b",//"d916271336cd2f3dfcf275d2bba47715",   //$tk['api_token'],
//            'data'=>"",//$data,
//            'map'=>"",
//            'order'=>"",
//        );
//
//        $json=json_encode($array);
//        //dump($json);exit;
//        $url=GetSignUrl($list);
//
//        if(empty($url)){
//            return json(["code"=>"-1","msg"=>"生成签名错误"]);
//        }
//        $rs=http_post_json($url,$json);
////        $offinfo=json_decode(urldecode($rs[0]),true);
////        $yucun_money=$offinfo["data"][0]["VIPSum"];//
////        echo $yucun_money;exit;
//         echo $rs[0];exit;
//        $aa=json_decode(urldecode($rs[0]),true);
//        //echo $rs[0];exit;
//        echo $rs["data"][0]["VIPSum"]; exit;
//        //dump($aa["data"][0]["Sum"]);exit;
//
//
//        if($rs){
//            return json_decode(urldecode($rs[0]),true);
//            //return json($rs[0]);
//        }else{
//            //return json(["code"=>"-1","msg"=>"获取接口数据错误"]);
//        }


        $data=array(
            'FromId' => "1000201705094649303510",//会员ID
            'CashRepNo'=>"201705094209303510",//单据日期
            'Sum'=>"0.01",//预存款项目id
            'Integral'=>"-50",//预存金额
            'vipRemark'=>"50积分兑换0.01元微券(少军专用)",//摘要
            'Remark'=>"50积分兑换0.01元微券(少军专用111)",//来源ID
            'Id'=>"6BBBF1B0-7E86-43C7-B6EA-458071E0A27A",//空:自定义充值 非空:促销充值ID
        );
//        {"FromId":"1000201705094649303510","CashRepNo":"201705094209303510","Sum":0.01,"Integral":-50,"vipRemark":"50\u79ef\u5206\u5151\u63620.01\u5143\u5fae\u5238(\u65e0\u9650\u5236)","Remark":"50\u79ef\u5206\u5151\u63620.01\u5143\u5fae\u5238","Id":"6BBBF1B0-7E86-43C7-B6EA-458071E0A27A"}

        /*----
        $list = array("access_token"=>"wxd.vip.intertocash");
        $array =array(
            'token'=>"beba071ae1ed9b303938838955edd09b",
            'data'=>array(
                $data,
            ),//$data,
            'map'=>"",
            'order'=>"",
        );

        $json=json_encode($array);
        mlog("微券:".$json,"weiquan");
        $url=GetSignUrl($list);---*/


        if(empty($url)){
            return json(["code"=>"-1","msg"=>"生成签名错误"]);
        }
        $rs=http_post_json($url,$json);
        return $rs;
    }

  

}