Exemple #1
0
 public function getCartTotal()
 {
     $member = get_member_account(false);
     $openid = $member['openid'];
     $cartotal = mysqld_selectcolumn("select sum(total) from " . table('shop_cart') . " where session_id='" . $openid . "'");
     return empty($cartotal) ? 0 : $cartotal;
 }
Exemple #2
0
<?php

$member = get_member_account(false);
$member = member_get($member['openid']);
if (empty($member['openid'])) {
    $member = get_member_account(false);
    $member['createtime'] = time();
}
$is_login = is_login_account();
$cfg = globaSetting();
$weixinfans = get_weixin_fans_byopenid($member['openid'], $member['openid']);
if (!empty($weixinfans) && !empty($weixinfans['avatar'])) {
    $avatar = $weixinfans['avatar'];
}
include themePage('fansindex');
Exemple #3
0
<?php

$member_account = get_member_account();
$openid = $member['openid'];
$order = mysqld_select("SELECT * FROM " . table('shop_order') . " WHERE  id=:id limit 1", array(':id' => $orderid));
$getmember = member_get($openid);
if ($getmember['gold'] >= $order['price']) {
    $usegold = member_gold($openid, $order['price'], 'usegold', "消费金额:" . $order['price'] . ",订单编号:" . $order['ordersn']);
    if ($usegold) {
        mysqld_update('shop_order', array('status' => '1', 'paytype' => '1'), array('id' => $orderid));
        message('订单提交成功,收货后请验货!', WEBSITE_ROOT . mobile_url('myorder'), 'success');
    } else {
        message('付款失败!', WEBSITE_ROOT . mobile_url('myorder'), 'error');
    }
} else {
    message('余额不足,无法完成付款!', WEBSITE_ROOT . mobile_url('myorder'), 'error');
}
Exemple #4
0
<?php

$member = get_member_account(true, true);
$openid = $member['openid'];
$member = member_get($openid);
$paymentconfig = "";
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')) {
    $paymentconfig = " and code!='alipay'";
} else {
    if (is_mobile_request()) {
        $paymentconfig = " and code!='weixin'";
    }
}
$paymentlist = mysqld_selectall("select * from " . table("payment") . " where `enabled`=1  and `code`!='gold' and `online`=1 {$paymentconfig} ");
$paymentscount = mysqld_selectcolumn("select count(id) from " . table("payment") . " where `enabled`=1  and `code`!='gold' and `online`=1 {$paymentconfig} ");
if (empty($paymentscount)) {
    message("未找到可用的在线支付方式,暂时不支持余额充值。");
}
if (checksubmit("submit")) {
    if (empty($_GP['charge']) || round($_GP['charge'], 2) <= 0) {
        message("请输入要充值的金额");
    }
    $paytypecode = $_GP['paymentcode'];
    if (empty($paytypecode)) {
        message("请选择充值方式。");
    }
    $payment = mysqld_select("select * from " . table("payment") . " where `enabled`=1 and `code`=:code and `code`!='gold' and `online`=1", array('code' => $paytypecode));
    if (empty($payment['id'])) {
        message("未找到付款方式,付款失败");
    }
    $goodtitle = "余额充值" . $_GP['charge'] . "元";
Exemple #5
0
 public function do_getaward()
 {
     global $_GP;
     $reply = mysqld_select("SELECT * FROM " . table("bigwheel_reply") . "  ORDER BY `id` DESC");
     $member = get_member_account(true, intval($reply['needreg']) == 1);
     $openid = $member['openid'];
     $from_user = $openid;
     if ($reply == false) {
         $this->message();
     }
     if ($reply['isshow'] != 1) {
         //活动已经暂停,请稍后...
         $this->message(array("success" => 2, "msg" => '活动暂停,请稍后...'), "");
     }
     if ($reply['starttime'] > time()) {
         $this->message(array("success" => 2, "msg" => '活动还没有开始呢,请等待...'), "");
     }
     $endtime = $reply['endtime'] + 68399;
     if ($endtime < time()) {
         $this->message(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!'), "");
     }
     $fansID = 0;
     //第一步,判断有没有已经领取奖品了,如果领取了,则不能再领取了
     $fans = mysqld_select("SELECT * FROM " . table("bigwheel_fans") . " WHERE  from_user='******'");
     if ($fans == false) {
         //不存在false的情况,如果是false,则表明是非法
         //$this->message();
         $fans = array('fansID' => $fansID, 'from_user' => $openid, 'todaynum' => 0, 'totalnum' => 0, 'awardnum' => 0, 'createtime' => time());
         mysqld_insert("bigwheel_fans", $fans);
         $fans['id'] = mysqld_insertid();
     }
     //更新当日次数
     $nowtime = mktime(0, 0, 0);
     if ($fans['last_time'] < $nowtime) {
         $fans['todaynum'] = 0;
     }
     //判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
     if ($fans['totalnum'] >= $reply['number_times'] && $reply['number_times'] > 0) {
         // $this->message('', '超过抽奖总限制次数');
         $this->message(array("success" => 2, "msg" => '您超过抽奖总次数了,不能抽奖了!'), "");
     }
     //判断当日是否超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
     if ($fans['todaynum'] >= $reply['most_num_times'] && $reply['most_num_times'] > 0) {
         //$this->message('', '超过当日限制次数');
         $this->message(array("success" => 2, "msg" => '您超过当日抽奖次数了,不能抽奖了!'), "");
     }
     $last_time = strtotime(date("Y-m-d", mktime(0, 0, 0)));
     //当天抽奖次数
     mysqld_update('bigwheel_fans', array('todaynum' => $fans['todaynum'] + 1, 'last_time' => $last_time), array('id' => $fans['id']));
     //总抽奖次数
     mysqld_update('bigwheel_fans', array('totalnum' => $fans['totalnum'] + 1), array('id' => $fans['id']));
     $gifts = array("one" => array("name" => $reply['c_name_one'], "type" => $reply['c_type_one'], "probalilty" => $reply['c_rate_one'], "total" => $reply['c_num_one'], "draw" => $reply['c_draw_one']), "two" => array("name" => $reply['c_name_two'], "type" => $reply['c_type_two'], "probalilty" => $reply['c_rate_two'], "total" => $reply['c_num_two'], "draw" => $reply['c_draw_two']), "three" => array("name" => $reply['c_name_three'], "type" => $reply['c_type_three'], "probalilty" => $reply['c_rate_three'], "total" => $reply['c_num_three'], "draw" => $reply['c_draw_three']), "four" => array("name" => $reply['c_name_four'], "type" => $reply['c_type_four'], "probalilty" => $reply['c_rate_four'], "total" => $reply['c_num_four'], "draw" => $reply['c_draw_four']), "five" => array("name" => $reply['c_name_five'], "type" => $reply['c_type_five'], "probalilty" => $reply['c_rate_five'], "total" => $reply['c_num_five'], "draw" => $reply['c_draw_five']), "six" => array("name" => $reply['c_name_six'], "type" => $reply['c_type_six'], "probalilty" => $reply['c_rate_six'], "total" => $reply['c_num_six'], "draw" => $reply['c_draw_six']));
     //计算每个礼物的概率
     $probability = 0;
     $rate = 1;
     $award = array();
     $awards = array();
     //奖品名字 (同时可中多个奖品,然后随机派奖)
     foreach ($gifts as $name => $gift) {
         if ($gift['total'] - $gift['draw'] <= 0) {
             continue;
         }
         if (empty($gift['probalilty'])) {
             continue;
         }
         $probability = $gift['probalilty'];
         if ($probability < 1) {
             $temp = explode('.', $probability);
             $temp = pow(10, strlen($temp[1]));
             $rate = $temp < $rate ? $rate : $temp;
             $probability = $probability * $rate;
         }
         $award[] = array('prizetype' => $name, 'name' => $gift['name'], 'probalilty' => $probability, 'total' => $gift['total']);
     }
     $all = 100 * $rate;
     mt_srand((double) microtime() * 1000000);
     $rand = mt_rand(1, $all);
     foreach ($award as $gift) {
         if ($rand > 0 && $rand <= $gift['probalilty'] && $gift['total'] > 0) {
             $awards[] = $gift['prizetype'];
         }
     }
     $prizetype = "";
     $awardtype = "";
     $awardname = "";
     if (count($awards) > 0) {
         mt_srand((double) microtime() * 1000000);
         $randid = mt_rand(0, count($awards) - 1);
         $prizetype = $awards[$randid];
         $awardtype = $gifts[$prizetype]['type'];
         $awardname = $gifts[$prizetype]['name'];
     }
     if (!empty($prizetype) && (!empty($reply['award_times']) && $fans['awardnum'] < $reply['award_times']) || empty($reply['award_times'])) {
         //中奖
         $sn = random(16);
         mysqld_update('bigwheel_reply', array('c_draw_' . $prizetype => $reply['c_draw_' . $prizetype] + 1), array('id' => $reply['id']));
         //保存sn到award中
         $insert = array('fansID' => $fansID, 'from_user' => $from_user, 'name' => $awardtype, 'description' => $awardname, 'prizetype' => $prizetype, 'award_sn' => $sn, 'createtime' => time(), 'status' => 1);
         $temp = mysqld_insert('bigwheel_award', $insert);
         //保存中奖人信息到fans中
         mysqld_update('bigwheel_fans', array('awardnum' => $fans['awardnum'] + 1), array('id' => $fans['id']));
         $k = 0;
         if ($prizetype == 'one') {
             $k = 1;
         } else {
             if ($prizetype == 'two') {
                 $k = 2;
             }
         }
         if ($prizetype == 'three') {
             $k = 3;
         }
         if ($prizetype == 'four') {
             $k = 4;
         }
         if ($prizetype == 'five') {
             $k = 5;
         }
         if ($prizetype == 'six') {
             $k = 6;
         }
         $data = array('name' => $reply['c_type_' . $prizetype], 'award' => $reply['c_name_' . $prizetype], 'sn' => $sn, 'success' => 1, 'prizetype' => $k);
         $this->message($data);
     }
     $this->message();
 }
Exemple #6
0
 public function do_rule()
 {
     global $_GP;
     $xc_zjp = mysqld_select("SELECT * FROM " . table('xc_zjp_reply') . "  LIMIT 1");
     $member = get_member_account(true, intval($xc_zjp['needreg']) == 1);
     $openid = $member['openid'];
     $myuser = mysqld_select("SELECT id,points,count FROM " . table('xc_zjp_user') . " WHERE  open_id = '{$openid}' ");
     include addons_page('rule');
 }