Exemplo n.º 1
0
    public function my_coupon(){
        $this->assign('infoType','coupon');
        $thisCard=$this->_thisCard();
        $this->assign('thisCard',$thisCard);
        
        $type   = $this->_get('type','intval')?$this->_get('type','intval'):1;
        $now    = time();
        $data   = array();

        $where  = array('token'=>$this->token,'attr'=>'0','statdate'=>array('lt',$now),'enddate'=>array('gt',$now),'is_check'=>1,'is_delete'=>0,'is_huodong'=>0);
        if($type == 1){
            $where['type'] = '1';
        }else if($type == 2){
            $where['type'] = '0';
        }else{
            $where['type'] = '2';
        }
        $where['cardid'] = (Int)($_GET['cardid']);
        $data   = M('Member_card_coupon')->where($where)->order('create_time desc')->select();

        $coupons    = new  WechatCoupons($this->wxuser);
        foreach ($data as $k=>$n){
            $data[$k]['info']       = html_entity_decode($n['info']);
            $cwhere = array('token'=>$this->token,'wecha_id'=>$this->wecha_id,'cardid'=>$thisCard['id'],'coupon_type'=>$type,'coupon_id'=>$n['id']);
            $count  = M('Member_card_coupon_record')->where($cwhere)->count();
            $data[$k]['get_count']  = $count;
            $data[$k]['count']      = 1 > $n['people']-$count ? 0 : $n['people']-$count;
            $data[$k]['cardExt']    = $coupons->cardSign($n['card_id'],$thisCard['id']);    
            $data[$k]['company_name']   = $n['company_id']?M('Company')->where('id='.$n['company_id'])->getField('name'):'所有门店';
        }
        
        

        $this->assign('firstItemID',$data[0]['id']);
        $this->assign('list',$data);
        $this->assign('type',$type);
        $this->display();
    }
Exemplo n.º 2
0
 public function getGiftCard($cardid)
 {
     $now = time();
     $gwhere = array('token' => $this->token, 'cardid' => $cardid, 'is_open' => '1', 'type' => '2', 'start' => array('lt', $now), 'end' => array('gt', $now));
     $gifts = M('Member_card_gifts')->where($gwhere)->select();
     $coupons = new WechatCoupons($this->wxuser);
     $js_api_item = '';
     $api_item = '';
     foreach ($gifts as $key => $value) {
         $cinfo = M('Member_card_coupon')->where(array('token' => $this->token, 'id' => $value['item_value']))->find();
         if ($cinfo['is_weixin'] == 1) {
             $js_api_item .= '{cardId:"' . $cinfo['card_id'] . '",cardExt:\'' . $coupons->cardSign($cinfo['card_id'], $cinfo['cardid']) . '\'},';
         }
     }
     $api_item = rtrim($js_api_item, ',');
     return $api_item;
 }
Exemplo n.º 3
0
 public function my_coupon()
 {
     $this->assign("infoType", "coupon");
     $thisCard = $this->_thisCard();
     $this->assign("thisCard", $thisCard);
     $type = $this->_get("type", "intval") ? $this->_get("type", "intval") : 1;
     $now = time();
     $data = array();
     $where = array("token" => $this->token, "attr" => "0", "statdate" => array("lt", $now), "enddate" => array("gt", $now), "is_check" => 1, "is_delete" => 0, "is_huodong" => 0);
     if ($type == 1) {
         $where["type"] = "1";
     } else {
         if ($type == 2) {
             $where["type"] = "0";
         } else {
             $where["type"] = "2";
         }
     }
     $where["cardid"] = (int) $_GET["cardid"];
     $data = M("Member_card_coupon")->where($where)->order("create_time desc")->select();
     $coupons = new WechatCoupons($this->wxuser);
     foreach ($data as $k => $n) {
         $data[$k]["info"] = html_entity_decode($n["info"]);
         $cwhere = array("token" => $this->token, "wecha_id" => $this->wecha_id, "cardid" => $thisCard["id"], "coupon_type" => $type, "coupon_id" => $n["id"]);
         $count = M("Member_card_coupon_record")->where($cwhere)->count();
         $data[$k]["get_count"] = $count;
         $data[$k]["count"] = $n["people"] - $count;
         $data[$k]["cardExt"] = $coupons->cardSign($n["card_id"], $thisCard["id"]);
         $data[$k]["company_name"] = $n["company_id"] ? M("Company")->where("id=" . $n["company_id"])->getField("name") : "所有门店";
     }
     $this->assign("firstItemID", $data[0]["id"]);
     $this->assign("list", $data);
     $this->assign("type", $type);
     $this->display();
 }