本文整理汇总了PHP中Card::toJson方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::toJson方法的具体用法?PHP Card::toJson怎么用?PHP Card::toJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card::toJson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explode
}
$arr = explode('=', $da);
$post[$arr[0]] = trim($arr[1]);
}
$out['errno'] = 1;
$out['error'] = '';
$post['logo_url'] = empty($post['logo_url']) ? $setting['logourl'] : trim($post['logo_url']);
$base = new Card('GENERAL_COUPON', $post);
if (is_error($base->general_coupon->base_info)) {
$out['errno'] = 0;
$out['error'] = $base->general_coupon->base_info['message'];
exit(json_encode($out));
}
$base->get_card()->set_default_detail(urlencode(trim($post['default_detail'])));
$acc = new coupon($acid);
$status = $acc->CreateCard($base->toJson());
if (is_error($status)) {
$out['errno'] = 0;
$out['error'] = $status['message'];
exit(json_encode($out));
}
$post['card_id'] = $status['card_id'];
$post['date_info'] = array('time_type' => $post['time_type'], 'time_limit_start' => $post['time_limit[start]'], 'time_limit_end' => $post['time_limit[end]'], 'deadline' => $post['deadline'], 'limit' => $post['limit']);
$post['date_info'] = iserializer($post['date_info']);
if (!empty($post['location-select'])) {
$location = explode('-', $post['location-select']);
$post['location_id_list'] = iserializer($location);
} else {
$post['location_id_list'] = iserializer(array());
}
$post['uniacid'] = $_W['uniacid'];
示例2: DateInfo
//.........这里部分代码省略.........
//折扣卡
if (!isset($extra_data["discount"])) {
exit("discount must be set!");
}
$card->get_card()->set_discount($extra_data["discount"]);
//必填
break;
case $this->CARD_TYPE[3]:
//礼品卡
if (!isset($extra_data["gift"])) {
exit("gift must be set!");
}
$card->get_card()->set_gift($extra_data["gift"]);
//必填
break;
case $this->CARD_TYPE[4]:
//代金券
if (isset($extra_data["least_cost"])) {
$card->get_card()->set_least_cost($extra_data["least_cost"]);
}
if (!isset($extra_data["reduce_cost"])) {
exit("reduce_cost must be set!");
}
$card->get_card()->set_reduce_cost($extra_data["reduce_cost"]);
//必填
break;
case $this->CARD_TYPE[5]:
//会员卡
if (!isset($extra_data["supply_bonus"]) || !isset($extra_data["supply_balance"]) || !isset($extra_data["prerogative"])) {
exit("supply_bonus and supply_balance and prerogative must be set!");
}
$card->get_card()->set_supply_bonus($extra_data["supply_bonus"]);
//必填
$card->get_card()->set_supply_balance($extra_data["supply_balance"]);
//必填
$card->get_card()->set_prerogative($extra_data["prerogative"]);
//必填
//bind_old_card_url or activate_url must be set one!
if (!isset($extra_data["bonus_rules"]) && !isset($extra_data["bonus_rules"])) {
exit("bind_old_card_url or activate_url must be set one!");
} else {
if (isset($extra_data["bind_old_card_url"])) {
$card->get_card()->set_bind_old_card_url($extra_data["bind_old_card_url"]);
}
if (isset($extra_data["activate_url"])) {
$card->get_card()->set_activate_url($extra_data["activate_url"]);
}
}
if (isset($extra_data["bonus_cleared"])) {
$card->get_card()->set_bonus_cleared($extra_data["bonus_cleared"]);
}
if (isset($extra_data["bonus_rules"])) {
$card->get_card()->set_bonus_rules($extra_data["bonus_rules"]);
}
if (isset($extra_data["balance_rules"])) {
$card->get_card()->set_balance_rules($extra_data["balance_rules"]);
}
break;
case $this->CARD_TYPE[6]:
//门票
if (isset($extra_data["ticket_class"])) {
$card->get_card()->set_ticket_class($extra_data["ticket_class"]);
}
if (isset($extra_data["guide_url"])) {
$card->get_card()->set_guide_url($extra_data["guide_url"]);
}
break;
case $this->CARD_TYPE[7]:
//电影票
if (isset($extra_data["detail"])) {
$card->get_card()->set_detail($extra_data["detail"]);
}
break;
break;
case $this->CARD_TYPE[8]:
//飞机票
if (!isset($extra_data["from"]) || !isset($extra_data["to"]) || !isset($extra_data["flight"]) || !isset($extra_data["departure_time"]) || !isset($extra_data["landing_time"])) {
exit("from and to and flight and departure_time and landing_time must be set!");
}
$card->get_card()->set_from($extra_data["from"]);
//必填
$card->get_card()->set_to($extra_data["to"]);
//必填
$card->get_card()->set_flight($extra_data["flight"]);
//必填
$card->get_card()->set_departure_time($extra_data["departure_time"]);
//必填
$card->get_card()->set_landing_time($extra_data["landing_time"]);
//必填
break;
case $this->CARD_TYPE[9]:
//红包,无额外数据
break;
default:
exit("CardType Error");
}
//cardjson
$jsondata = json_decode($card->toJson(), true);
return $this->postapi("card/create", $jsondata);
}
示例3: createCard
public function createCard($id, $is_edit = 0)
{
$info = M('Member_card_coupon')->where('id=' . $id)->find();
if ($info['company_id'] == 0) {
$company = M('Company')->where('token="' . $info['token'] . '" AND location_id!=0')->order('isbranch ASC')->select();
} else {
$company = M('Company')->where('token="' . $info['token'] . '" AND id=' . $info['company_id'])->select();
}
if (empty($company)) {
return array('errcode' => '-1', 'errmsg' => '商家门店未导入');
exit;
}
$logo_url = $this->getLogoUrl($info['logourl'], $id);
$location_id_list = array();
foreach ($company as $key => $value) {
if ($value['location_id']) {
$location_id_list[] = $value['location_id'];
}
}
switch ($info['type']) {
case '0':
$card_type = 'CASH';
$coupon_type = 2;
break;
case '1':
$card_type = 'GENERAL_COUPON';
$coupon_type = 1;
break;
case '2':
$card_type = 'GIFT';
$coupon_type = 3;
break;
default:
$card_type = 'GENERAL_COUPON';
break;
}
$base_info = new BaseInfo($logo_url['url'], $company[0]['name'], 0, $info['title'], $info['color'], '使用时向店员员出示此券', $company[0]['tel'], $info['info'], new DateInfo(1, intval($info['statdate']), intval($info['enddate'])), new Sku($info['total']));
$base_info->set_sub_title('');
$base_info->set_use_limit(1);
$base_info->set_get_limit(intval($info['people']));
$base_info->set_use_custom_code(false);
$base_info->set_bind_openid(false);
$base_info->set_can_share(false);
$base_info->set_can_give_friend(false);
$base_info->set_location_id_list($location_id_list);
$base_info->set_url_name_type(1);
$base_info->set_custom_url_name('立即使用');
$base_info->set_custom_url(U('Wap/Card/consume', array('token' => $info['token'], 'cardid' => $info['cardid'], 'from' => 'weixin'), '', '', true));
$card = new Card($card_type, $base_info);
switch ($info['type']) {
case '0':
$card->get_card()->set_least_cost($info['least_cost'] * 100);
$card->get_card()->set_reduce_cost($info['reduce_cost'] * 100);
break;
case '1':
$card->get_card()->set_default_detail($company[0]['intro']);
break;
case '2':
$card->get_card()->set_gift($info['gift_name']);
break;
default:
$card->get_card()->set_default_detail($company[0]['intro']);
break;
}
$post_data = $card->toJson();
$url = 'https://api.weixin.qq.com/card/create?access_token=' . $this->access_token;
$res = $this->https_request($url, $post_data);
return $res;
}
示例4: sort
array_push($this->data, (string) $str);
}
function get_signature()
{
sort($this->data, SORT_STRING);
return sha1(implode($this->data));
}
}
//------------------------set base_info-----------------------------
$base_info = new BaseInfo("http://www.supadmin.cn/uploads/allimg/120216/1_120216214725_1.jpg", "海底捞", 0, "132元双人火锅套餐", "Color010", "使用时向服务员出示此券", "020-88888888", "不可与其他优惠同享\n 如需团购券发票,请在消费时向商户提出\n 店内均可使用,仅限堂食\n 餐前不可打包,餐后未吃完,可打包\n 本团购券不限人数,建议2人使用,超过建议人数须另收酱料费5元/位\n 本单谢绝自带酒水饮料", new DateInfo(1, 1397577600, 1399910400), new Sku(50000000));
$base_info->set_sub_title("");
$base_info->set_use_limit(1);
$base_info->set_get_limit(3);
$base_info->set_use_custom_code(false);
$base_info->set_bind_openid(false);
$base_info->set_can_share(true);
$base_info->set_url_name_type(1);
$base_info->set_custom_url("http://www.qq.com");
//---------------------------set_card--------------------------------
$card = new Card("GROUPON", $base_info);
$card->get_card()->set_deal_detail("以下锅底2 选1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可选):\n 大锅1 份12 元\n 小锅2 份16 元\n 以下菜品2 选1\n 特级肥牛1 份30 元\n 洞庭鮰鱼卷1 份20元\n 其他\n鲜菇猪肉滑1 份18 元\n 金针菇1 份16 元\n 黑木耳1 份9 元\n 娃娃菜1 份8 元\n 冬瓜1份6 元\n 火锅面2 个6 元\n 欢乐畅饮2 位12 元\n 自助酱料2 位10 元");
//--------------------------to json--------------------------------
echo $card->toJson();
//----------------------check signature------------------------
$signature = new Signature();
$signature->add_data("875e5cc094b78f230b0588c2a5f3c49f");
$signature->add_data("wx57bf46878716c27e");
$signature->add_data("213168808");
$signature->add_data("12345");
$signature->add_data("55555");
echo $signature->get_signature();