Exemplo n.º 1
0
 public function get_wallet()
 {
     if ($this->wecha_id && $this->token && $this->action_id) {
         $way = (int) $_GET['way'];
         $msg = $way == 1 ? '领取' : '充值';
         $w_share = array('hongbao_id' => $this->action_id, 'share_key' => $this->my_packets['grabber_shareid'], 'is_opened' => 2);
         $share_times = M('hongbao_share')->where($w_share)->count();
         if ($share_times < $this->action['sharetimes']) {
             exit('分享次数不够' . $this->action['sharetimes'] . '次,不能' . $msg);
         }
         $pack = M('hongbao_grabber')->where(array('hongbao_id' => $this->action_id, 'token' => $this->token, 'grabber_wechaid' => $this->wecha_id))->find();
         if (!empty($pack)) {
             if ($pack['money'] < 1 && $way == 1) {
                 exit('红包金额需超过1.00元才可领取');
             }
             if ($pack['isgrabbed'] == 2) {
                 exit('你已经' . $msg . ',请勿重复' . $msg);
             }
             if ($pack["isgrabbed"] != 2) {
                 if ($way == 1) {
                     $config = array();
                     $config['nick_name'] = $this->action['reply_title'];
                     $config['send_name'] = $this->action['reply_title'];
                     $config['wishing'] = $this->action['reply_content'];
                     $config['act_name'] = $this->action['action_name'];
                     $config['remark'] = $this->action['action_desc'];
                     $config['token'] = $this->token;
                     $config['openid'] = $this->wecha_id;
                     $config['money'] = $pack['money'];
                     $hb = new Hongbao($config);
                     $res = json_decode($hb->send(), true);
                 } else {
                     $return_recharge = $this->recharge($this->token, $pack['grabber_wechaid'], $pack['money']);
                     $res = json_decode($return_recharge, true);
                 }
             }
             if ($res['status'] == 'SUCCESS') {
                 $save = M('hongbao_grabber')->where(array('hongbao_id' => $pack['hongbao_id'], 'token' => $pack['token'], 'grabber_wechaid' => $pack['grabber_wechaid']))->save(array('isgrabbed' => 2));
                 exit('success');
             } else {
                 exit($res['msg'] . ',请稍后再试');
             }
         } else {
             exit('不存在你的红包');
         }
     } else {
         exit('非法操作');
     }
 }
Exemplo n.º 2
0
	public function get_wallet()
	{
		if ($this->wecha_id && $this->token && $this->action_id) {
			$action = M("hongbao")->where(array("id" => $this->action_id, "token" => $this->token, "status" => "1"))->find();
			$way = (int) $_GET["way"];
			$msg = ($way == 1 ? "领取" : "充值");
			$w_share = array("hongbao_id" => $this->action_id, "share_key" => $this->my_packets["grabber_shareid"], "is_opened" => 2);
			$share_times = M("hongbao_share")->where($w_share)->count();

			if ($share_times < $action["sharetimes"]) {
				exit("分享次数不够" . $action["sharetimes"] . "次,不能" . $msg);
			}

			$pack = M("hongbao_grabber")->where(array("hongbao_id" => $this->action_id, "token" => $this->token, "grabber_wechaid" => $this->wecha_id))->find();

			if (!empty($pack)) {
				if (($pack["money"] < 1) && ($way == 1)) {
					exit("红包金额需超过1.00元才可领取");
				}

				if ($pack["isgrabbed"] == 2) {
					exit("你已经" . $msg . ",请勿重复" . $msg);
				}

				if ($pack["isgrabbed"] != 2) {
					if ($way == 1) {
						$config = array();
						$config["nick_name"] = $action["reply_title"];
						$config["send_name"] = $action["reply_title"];
						$config["wishing"] = $action["reply_content"];
						$config["act_name"] = $action["action_name"];
						$config["remark"] = $action["action_desc"];
						$config["token"] = $this->token;
						$config["openid"] = $this->wecha_id;
						$config["money"] = $pack["money"];
						$hb = new Hongbao($config);
						$res = json_decode($hb->send(), true);
					}
					else {
						$return_recharge = $this->recharge($this->token, $pack["grabber_wechaid"], $pack["money"]);
						$res = json_decode($return_recharge, true);
					}
				}

				if ($res["status"] == "SUCCESS") {
					$save = M("hongbao_grabber")->where(array("hongbao_id" => $pack["hongbao_id"], "token" => $pack["token"], "grabber_wechaid" => $pack["grabber_wechaid"]))->save(array("isgrabbed" => 2));
					exit("success");
				}
				else {
					exit($res["msg"] . ",请稍后再试");
				}
			}
			else {
				exit("不存在你的红包");
			}
		}
		else {
			exit("非法操作");
		}
	}