public function fetchUserCredit($openid) { load()->model('mc'); $uid = mc_openid2uid($openid); $credits = mc_credit_fetch($uid); return $credits; }
private function getUserInfo($uid = null) { global $_W; load()->model('mc'); if (empty($uid)) { $uid = $_W['member']['uid']; } else { $uid = mc_openid2uid($uid); } $userInfo = array(); $filter = array(); $filter['status'] = 1; $userInfo['coupons'] = activity_coupon_owned($uid, $filter); $userInfo['tokens'] = activity_token_owned($uid, $filter); $userInfo['credits'] = mc_credit_fetch($_W['member']['uid'], '*'); return $userInfo; }
public function doMobilePay() { global $_W, $_GPC; //验证用户登录状态,此处测试不做验证 checkauth(); $params['tid'] = date('YmdH'); $params['user'] = $_W['member']['uid']; $params['fee'] = floatval($_GPC['price']); $params['title'] = '测试支付公众号名称'; $params['ordersn'] = random(5, 1); $params['virtual'] = false; if (checksubmit('submit')) { if ($_GPC['type'] == 'credit') { $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credtis = mc_credit_fetch($_W['member']['uid']); //此处需要验证积分数量 if ($credtis[$setting['creditbehaviors']['currency']] < $params['fee']) { message('抱歉,您帐户的余额不够支付该订单,请充值!', '', 'error'); } } } else { $this->pay($params); } }
$total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('activity_exchange') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime', array(':uniacid' => $_W['uniacid'], ':type' => 5, ':endtime' => TIMESTAMP)); $pindex = max(1, intval($_GPC['page'])); $psize = 10; $lists = pdo_fetchall('SELECT id,title,extra,thumb,type,credittype,endtime,description,credit FROM ' . tablename('activity_exchange') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime ORDER BY endtime ASC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $_W['uniacid'], ':type' => 5, ':endtime' => TIMESTAMP)); foreach ($lists as &$li) { $li['extra'] = iunserializer($li['extra']); } $pager = pagination($total, $pindex, $psize); } if ($do == 'post') { $id = intval($_GPC['id']); $partime = activity_exchange_info($id, $_W['uniacid']); if (empty($partime)) { message('没有指定的礼品兑换.'); } $credit = mc_credit_fetch($_W['member']['uid'], array($partime['credittype'])); if ($credit[$partime['credittype']] < $partime['credit']) { message('您的' . $creditnames[$partime['credittype']] . '数量不够,无法兑换.'); } $ret = activity_module_grant($_W['member']['uid'], $id, 'system', '用户使用' . $partime['credit'] . $creditnames[$partime['credittype']] . '兑换'); if (is_error($ret)) { message($ret['message']); } mc_credit_update($_W['member']['uid'], $partime['credittype'], -1 * $partime['credit'], array($_W['member']['uid'], '礼品兑换:' . $partime['title'] . ' 消耗 ' . $creditnames[$partime['credittype']] . ':' . $partime['credit'])); message("兑换成功,您消费了 {$partime['credit']} {$creditnames[$partime['credittype']]}", url('activity/partimes/mine')); } if ($do == 'mine') { $psize = 10; $pindex = max(1, intval($_GPC['page'])); $condition = ''; if (empty($_GPC['status']) || $_GPC['status'] == 1) {
protected function pay($params = array(), $mine = array()) { global $_W; if (!$this->inMobile) { message('支付功能只能在手机上使用'); } if (empty($_W['member']['uid'])) { checkauth(); } $params['module'] = $this->module['name']; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':module'] = $params['module']; $pars[':tid'] = $params['tid']; if ($params['fee'] <= 0) { $pars['from'] = 'return'; $pars['result'] = 'success'; $pars['type'] = 'alipay'; $pars['tid'] = $params['tid']; $site = WeUtility::createModuleSite($pars[':module']); $method = 'payResult'; if (method_exists($site, $method)) { exit($site->{$method}($pars)); } } $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid'; $log = pdo_fetch($sql, $pars); if (!empty($log) && $log['status'] == '1') { message('这个订单已经支付成功, 不需要重复支付.'); } $setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors')); if (!is_array($setting['payment'])) { message('没有有效的支付方式, 请联系网站管理员.'); } $pay = $setting['payment']; if (!empty($pay['credit']['switch'])) { $credtis = mc_credit_fetch($_W['member']['uid']); } $you = 0; if ($pay['card']['switch'] == 2) { if ($_W['card_permission'] == 1 && !empty($params['module'])) { $cards = pdo_fetchall('SELECT a.id,a.card_id,a.cid,b.type,b.title,b.extra,b.is_display,b.status,b.date_info FROM ' . tablename('coupon_modules') . ' AS a LEFT JOIN ' . tablename('coupon') . ' AS b ON a.cid = b.id WHERE a.acid = :acid AND a.module = :modu AND b.is_display = 1 AND b.status = 3 ORDER BY a.id DESC', array(':acid' => $_W['acid'], ':modu' => $params['module'])); $flag = 0; if (!empty($cards)) { foreach ($cards as $temp) { $temp['date_info'] = iunserializer($temp['date_info']); if ($temp['date_info']['time_type'] == 1) { $starttime = strtotime($temp['date_info']['time_limit_start']); $endtime = strtotime($temp['date_info']['time_limit_end']); if (TIMESTAMP < $starttime || TIMESTAMP > $endtime) { continue; } else { $param = array(':acid' => $_W['acid'], ':openid' => $_W['openid'], ':card_id' => $temp['card_id']); $num = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('coupon_record') . ' WHERE acid = :acid AND openid = :openid AND card_id = :card_id AND status = 1', $param); if ($num <= 0) { continue; } else { $flag = 1; $card = $temp; break; } } } else { $deadline = intval($temp['date_info']['deadline']); $limit = intval($temp['date_info']['limit']); $param = array(':acid' => $_W['acid'], ':openid' => $_W['openid'], ':card_id' => $temp['card_id']); $record = pdo_fetchall('SELECT addtime,id,code FROM ' . tablename('coupon_record') . ' WHERE acid = :acid AND openid = :openid AND card_id = :card_id AND status = 1', $param); if (!empty($record)) { foreach ($record as $li) { $time = strtotime(date('Y-m-d', $li['addtime'])); $starttime = $time + $deadline * 86400; $endtime = $time + $deadline * 86400 + $limit * 86400; if (TIMESTAMP < $starttime || TIMESTAMP > $endtime) { continue; } else { $flag = 1; $card = $temp; break; } } } if ($flag) { break; } } } } if ($flag) { if ($card['type'] == 'discount') { $you = 1; $card['fee'] = sprintf("%.2f", $params['fee'] * ($card['extra'] / 100)); } elseif ($card['type'] == 'cash') { $cash = iunserializer($card['extra']); if ($params['fee'] >= $cash['least_cost']) { $you = 1; $card['fee'] = sprintf("%.2f", $params['fee'] - $cash['reduce_cost']); } } load()->classs('coupon'); $acc = new coupon($_W['acid']); $card_id = $card['card_id']; $time = TIMESTAMP; $randstr = random(8); $sign = array($card_id, $time, $randstr, $acc->account['key']); $signature = $acc->SignatureCard($sign); if (is_error($signature)) { $you = 0; } } } } $we_you = 0; if ($pay['card']['switch'] == 3) { if (!empty($params['module'])) { $cards = pdo_fetchall('SELECT a.id,a.couponid,b.type,b.title,b.discount,b.condition,b.starttime,b.endtime FROM ' . tablename('activity_coupon_modules') . ' AS a LEFT JOIN ' . tablename('activity_coupon') . ' AS b ON a.couponid = b.couponid WHERE a.uniacid = :uniacid AND a.module = :modu AND b.starttime <= :time AND b.endtime >= :time ORDER BY a.id DESC', array(':uniacid' => $_W['uniacid'], ':modu' => $params['module'], ':time' => TIMESTAMP)); if (!empty($cards) && $_W['member']['uid']) { foreach ($cards as $card) { $has = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('activity_coupon_record') . ' WHERE uid = :uid AND uniacid = :aid AND couponid = :cid AND status = 1', array(':uid' => $_W['member']['uid'], ':aid' => $_W['uniacid'], ':cid' => $card['couponid'])); if ($has > 0) { if ($card['type'] == '1') { $we_you = 1; $card['fee'] = sprintf("%.2f", $params['fee'] * $card['discount']); break; } elseif ($card['type'] == '2') { if ($params['fee'] >= $cash['condition']) { $we_you = 1; $card['fee'] = sprintf("%.2f", $params['fee'] - $card['discount']); break; } } } } } } } include $this->template('common/paycenter'); }
public function doMobileRegfans() { global $_GPC, $_W; $rid = intval($_GPC['rid']); $from_user = authcode(base64_decode($_GPC['from_user']), 'DECODE'); $page_from_user = $_GPC['from_user']; $uniacid = $_W['uniacid']; //规则判断 $reply = pdo_fetch("select * FROM " . tablename('stonefish_bigwheel_reply') . " where rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); if ($reply == false) { $this->json_encode(array("success" => 2, "msg" => '规则出错!...')); } if ($reply['isshow'] != 1) { $this->json_encode(array("success" => 2, "msg" => '活动暂停,请稍后...')); } if ($reply['starttime'] > time()) { $this->json_encode(array("success" => 2, "msg" => '活动还没有开始呢,请等待...')); } if ($reply['endtime'] < time()) { $this->json_encode(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!')); } if ($reply['power'] == 2 && intval($_W['fans']['follow']) != 0) { $this->json_encode(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!')); } //规则判断 //查询是活动定义还是商户赠送 $uid = pdo_fetchcolumn("select uid FROM " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid", array(":openid" => $from_user, ":uniacid" => $uniacid)); $profile = mc_fetch($uid, array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position')); if ($reply['opportunity'] == 3) { $doings = pdo_fetch("select * from " . tablename($reply['othermodule'] . '_prizeslist') . " where urlrid = " . $rid . " and prizetype='stonefish_bigwheel' and uniacid='" . $uniacid . "' and from_user='******'"); if (!empty($doings)) { if ($doings['usecount'] >= $doings['prizesnum']) { $this->json_encode(array("success" => 2, "msg" => '抱歉,您的抽奖次数已用完了或没有获得抽奖次数!')); } } else { $this->json_encode(array("success" => 2, "msg" => '抱歉,您的还未获得抽奖资格!')); } } elseif ($reply['opportunity'] == 1) { if (empty($profile['mobile'])) { $this->json_encode(array("success" => 2, "msg" => '您没有注册成为会员,不能参与活动!')); } $doings = pdo_fetch("select * FROM " . tablename('stonefish_branch_doings') . " where rid = " . $rid . " and mobile='" . $profile['mobile'] . "' and uniacid='" . $uniacid . "'"); if (!empty($doings)) { if ($doings['status'] < 2) { $this->json_encode(array("success" => 2, "msg" => '抱歉,您的资格正在审核中!')); } else { if ($doings['awardcount'] == 0) { $this->json_encode(array("success" => 2, "msg" => '抱歉,您的资格已用完了!')); } } } else { $this->json_encode(array("success" => 2, "msg" => '抱歉,您还没有获取资格,不能参与!')); } } elseif ($reply['opportunity'] == 2) { $unisettings = uni_setting($uniacid, array('creditnames')); foreach ($unisettings['creditnames'] as $key => $credits) { if ($reply['credit_type'] == $key) { $creditnames = $credits['title']; break; } } $credit = mc_credit_fetch($uid, array($reply['credit_type'])); $credit_value = intval($credit[$reply['credit_type']] / $reply['credit_value']); if ($credit_value < 1) { $this->json_encode(array("success" => 2, "msg" => '抱歉,您没有' . $creditnames . '兑换参与资格了!')); } } //查询是活动定义还是商户赠送 //判断是否参与过 $fans = pdo_fetch("select * from " . tablename('stonefish_bigwheel_fans') . " where rid = :rid and uniacid = :uniacid and from_user= :from_user", array(':rid' => $rid, ':uniacid' => $uniacid, ':from_user' => $from_user)); if (!empty($fans)) { $this->json_encode(array("success" => 2, "msg" => '已参与过本活动,请勿重复参与!')); } else { $fansdata = array('rid' => $rid, 'uniacid' => $uniacid, 'from_user' => $from_user, 'avatar' => $_GPC['avatar'], 'nickname' => $_GPC['nickname'], 'todaynum' => 1, 'totalnum' => 1, 'awardnum' => 0, 'createtime' => time()); pdo_insert('stonefish_bigwheel_fans', $fansdata); $fans['id'] = pdo_insertid(); //自动读取会员信息存入FANS表中 $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'); foreach ($ziduan as $ziduans) { if ($reply['is' . $ziduans]) { if (!empty($_GPC[$ziduans])) { pdo_update('stonefish_bigwheel_fans', array($ziduans => $_GPC[$ziduans]), array('id' => $fans['id'])); if ($reply['isfans']) { if ($ziduans == 'email') { mc_update($_W['member']['uid'], array('email' => $_GPC['email'])); } else { mc_update($_W['member']['uid'], array($ziduans => $_GPC[$ziduans], 'email' => $profile['email'])); } } } } } //自动读取会员信息存入FANS表中 //增加人数,和浏览次数 pdo_update('stonefish_bigwheel_reply', array('fansnum' => $reply['fansnum'] + 1), array('id' => $reply['id'])); //商家赠送增加使用次数 if ($reply['opportunity'] == 3) { //pdo_update('stonefish_branch_doings', array('usecount' =>0,'usetime' => time()), array('id' => $doings['id'])); pdo_update($reply['othermodule'] . '_prizeslist', array('usecount' => 0), array('id' => $doings['id'])); } elseif ($reply['opportunity'] == 1) { pdo_update('stonefish_branch_doings', array('usecount' => 0, 'usetime' => time()), array('id' => $doings['id'])); $content = '参与活动成功'; $insert = array('uniacid' => $uniacid, 'rid' => $rid, 'module' => 'stonefish_bigwheel', 'mobile' => $doings['mobile'], 'content' => $content, 'prizeid' => 0, 'createtime' => time()); pdo_insert('stonefish_branch_doingslist', $insert); } elseif ($reply['opportunity'] == 2) { mc_credit_update($uid, $reply['credit_type'], -$reply['credit_value'], array($uid, '兑换活动资格 消耗:' . $reply['credit_value'] . '个' . $creditnames)); $credit_now = $credit[$reply['credit_type']] - $reply['credit_value']; } $data = array('success' => 1, 'msg' => '成功参与活动,请邀请好友帮你吧!', 'credit_now' => $credit_now); } //判断是否参与过 $this->json_encode($data); }
protected function pay($params = array()) { global $_W; if (!$this->inMobile) { message('支付功能只能在手机上使用'); } if (empty($_W['member']['uid'])) { checkauth(); } $params['module'] = $this->module['name']; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':module'] = $params['module']; $pars[':tid'] = $params['tid']; if ($params['fee'] <= 0) { $pars['from'] = 'return'; $pars['result'] = 'success'; $pars['type'] = 'alipay'; $pars['tid'] = $params['tid']; $site = WeUtility::createModuleSite($pars[':module']); $method = 'payResult'; if (method_exists($site, $method)) { exit($site->{$method}($pars)); } } $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid'; $log = pdo_fetch($sql, $pars); if (!empty($log) && $log['status'] == '1') { message('这个订单已经支付成功, 不需要重复支付.'); } $setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors')); if (!is_array($setting['payment'])) { message('没有有效的支付方式, 请联系网站管理员.'); } $pay = $setting['payment']; if (!empty($pay['credit']['switch'])) { $credtis = mc_credit_fetch($_W['member']['uid']); } include $this->template('common/paycenter'); }
<?php /** * @FreeGo Team 智慧游 * @url http://www.cninone.com/ */ defined('IN_IA') or exit('Access Denied'); if ($action != 'cash') { checkauth(); } load()->model('activity'); $filter = array(); $coupons = activity_coupon_owned($_W['member']['uid'], $filter); $tokens = activity_token_owned($_W['member']['uid'], $filter); $setting = uni_setting($_W['uniacid'], array('creditnames', 'creditbehaviors', 'uc', 'payment', 'passport')); $behavior = $setting['creditbehaviors']; $creditnames = $setting['creditnames']; $credits = mc_credit_fetch($_W['member']['uid'], '*'); $sql = 'SELECT `status` FROM ' . tablename('mc_card') . " WHERE `uniacid` = :uniacid"; $cardstatus = pdo_fetch($sql, array(':uniacid' => $_W['uniacid']));
function activity_module_card_grant($uid, $couponid, $module = '', $remark = '') { global $_W; $uid = intval($uid); $user = mc_fetch($uid, array('groupid')); $groupid = $user['groupid']; $couponid = intval($couponid); $coupon = pdo_fetch("SELECT * FROM " . tablename('activity_coupon') . " WHERE `couponid` = :couponid LIMIT 1", array(':couponid' => $couponid)); $pcount = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('activity_coupon_record') . " WHERE `uid` = :uid AND `couponid` = :couponid", array(':couponid' => $couponid, ':uid' => $uid)); $coupongroup = pdo_fetchall("SELECT groupid FROM " . tablename('activity_coupon_allocation') . " WHERE `couponid` = :couponid", array(':couponid' => $couponid), 'groupid'); $group = array_keys($coupongroup); $couponmodules = pdo_fetchall("SELECT module FROM " . tablename('activity_coupon_modules') . " WHERE `couponid` = :couponid", array(':couponid' => $couponid), 'module'); $modules = array_keys($couponmodules); if (empty($coupon)) { return error(-1, '未找到指定优惠券'); } elseif (!in_array($module, $modules)) { return error(-1, '该优惠券只能在特定的模块中领取'); } elseif (empty($coupongroup)) { return error(-1, '该优惠券未指定可使用的会员组'); } elseif (!in_array($groupid, $group)) { return error(-1, '您所在的用户组没有领取该优惠券的权限'); } elseif ($coupon['starttime'] > TIMESTAMP) { return error(-1, '优惠券活动尚未开始'); } elseif ($coupon['endtime'] < TIMESTAMP) { return error(-1, '优惠券活动已经结束'); } elseif ($coupon['dosage'] >= $coupon['amount']) { return error(-1, '优惠券已经发放完毕'); } elseif ($pcount >= $coupon['limit']) { return error(-1, '用户领取优惠券数量已经超过限制'); } $creditnames = array(); $unisettings = uni_setting($_W['uniacid'], array('creditnames')); if (!empty($unisettings) && !empty($unisettings['creditnames'])) { foreach ($unisettings['creditnames'] as $key => $credit) { $creditnames[$key] = $credit['title']; } } $credit = mc_credit_fetch($uid, array($coupon['credittype'])); if ($credit[$coupon['credittype']] < $coupon['credit']) { return error(-1, '您的' . $creditnames[$coupon['credittype']] . '数量不够,无法兑换.'); } mc_credit_update($uid, $coupon['credittype'], -1 * $coupon['credit'], array($uid, '优惠券兑换:' . $coupon['title'] . ' 消耗 ' . $creditnames[$coupon['credittype']] . ':' . $coupon['credit'])); $remark = "通过{$module}模块领取优惠券"; $insert = array('couponid' => $couponid, 'uniacid' => $_W['uniacid'], 'uid' => $uid, 'grantmodule' => $module, 'granttime' => TIMESTAMP, 'status' => 1, 'remark' => $remark); pdo_insert('activity_coupon_record', $insert); pdo_update('activity_coupon', array('dosage' => $coupon['dosage'] + 1), array('couponid' => $couponid)); return $coupon; }
public function doMobileget_award() { global $_GPC, $_W; $rid = intval($_GPC['rid']); $fansID = $_W['member']['uid']; $from_user = $_W['fans']['from_user']; $uniacid = $_W['uniacid']; $profile = mc_fetch($fansID, array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position')); if (empty($profile['avatar'])) { $profile['avatar'] = '../addons/stonefish_redenvelope/template/images/avatar.jpg'; } if (empty($profile['nickname'])) { $profile['nickname'] = $_GPC['realname']; } $reply = pdo_fetch("SELECT * FROM " . tablename('stonefish_redenvelope_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); if ($reply == false) { $this->message(array("success" => 2, "msg" => '规则出错!...'), ""); } if ($reply['isshow'] != 1) { //活动已经暂停,请稍后... $this->message(array("success" => 2, "msg" => '活动暂停,请稍后...'), ""); } if ($reply['starttime'] > time()) { $this->message(array("success" => 2, "msg" => '活动还没有开始呢,请等待...'), ""); } if ($reply['endtime'] < time()) { $this->message(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!'), ""); } if (empty($_W['fans'])) { $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), ""); } //先判断有没有资格领取 //判断是否为关注用户 $follow = pdo_fetchcolumn("SELECT follow FROM " . tablename('mc_mapping_fans') . " Where openid=:openid and uniacid=:uniacid ORDER BY `fanid` DESC", array(":openid" => $from_user, ":uniacid" => $uniacid)); if ($follow == 0) { $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), ""); } //判断是否为关注用户 //查询是活动定义还是商户赠送 if ($reply['opportunity'] == 1) { if (empty($profile['mobile'])) { $this->message(array("success" => 2, "msg" => '您没有注册成为会员,不能刮奖!'), ""); } $doings = pdo_fetch("SELECT * FROM " . tablename('stonefish_branch_doings') . " WHERE rid = " . $rid . " and mobile='" . $profile['mobile'] . "' and uniacid='" . $uniacid . "'"); if (!empty($doings)) { if ($doings['status'] < 2) { $this->message(array("success" => 2, "msg" => '抱歉,您的领取红包资格正在审核中!'), ""); } else { if ($doings['awardcount'] == 0) { $this->message(array("success" => 2, "msg" => '抱歉,您的领取红包资格已用完了!'), ""); } } } else { $this->message(array("success" => 2, "msg" => '抱歉,您还没有获取领取红包资格,不能领取!'), ""); } } elseif ($reply['opportunity'] == 2) { load()->model('account'); $unisettings = uni_setting($uniacid, array('creditnames')); foreach ($unisettings['creditnames'] as $key => $credits) { if ($reply['credit_type'] == $key) { $creditnames = $credits['title']; break; } } $credit = mc_credit_fetch($fansID, array($reply['credit_type'])); $credit_times = intval($credit[$reply['credit_type']] / $reply['credit_times']); if ($credit_times < 1) { $this->message(array("success" => 2, "msg" => '抱歉,您没有' . $creditnames . '兑换红包了!'), ""); } } //查询是活动定义还是商户赠送 //是否已关联用户,如果中能中奖一次,判断是否已中奖 $fans = pdo_fetch("SELECT * FROM " . tablename('stonefish_redenvelope_fans') . " WHERE rid = " . $rid . " and fansID=" . $fansID . " and from_user='******'"); if ($fans == false) { $inpoint = mt_rand($reply['inpointstart'] * 100, $reply['inpointend'] * 100) / 100; $inpoint = sprintf("%.2f", $inpoint); $fans = array('rid' => $rid, 'uniacid' => $uniacid, 'fansID' => $fansID, 'from_user' => $from_user, 'inpoint' => $inpoint, 'avatar' => $profile['avatar'], 'nickname' => $profile['nickname'], 'createtime' => time()); pdo_insert('stonefish_redenvelope_fans', $fans); $fans['id'] = pdo_insertid(); //自动读取会员信息存入FANS表中 $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'); load()->model('mc'); foreach ($ziduan as $ziduans) { if ($reply['is' . $ziduans]) { if (!empty($_GPC[$ziduans])) { pdo_update('stonefish_redenvelope_fans', array($ziduans => $_GPC[$ziduans]), array('id' => $fans['id'])); if ($reply['isfans']) { mc_update($fansID, array($ziduans => $_GPC[$ziduans])); } } } } //自动读取会员信息存入FANS表中 //增加人数,和浏览次数 pdo_update('stonefish_redenvelope_reply', array('fansnum' => $reply['fansnum'] + 1, 'viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); //商家赠送增加使用次数 if ($reply['opportunity'] == 1) { pdo_update('stonefish_branch_doings', array('usecount' => 0, 'usetime' => time()), array('id' => $doings['id'])); } elseif ($reply['opportunity'] == 2) { mc_credit_update($fansID, $reply['credit_type'], -$reply['credit_times'], array($fansID, '兑换幸运抢红包活动消耗:' . $reply['credit_times'] . '个' . $creditnames)); $credit_now = $credit[$reply['credit_type']] - $reply['credit_times']; } //开始分配红包咯 if ($inpoint) { //商家赠送添加使用记录 if ($reply['opportunity'] == 1) { $content = '领取红包价值:' . $inpoint; $insert = array('uniacid' => $uniacid, 'rid' => $rid, 'module' => 'stonefish_redenvelope', 'mobile' => $doings['mobile'], 'content' => $content, 'prizeid' => 0, 'createtime' => time()); pdo_insert('stonefish_branch_doingslist', $insert); } //商家赠送添加使用记录 $data = array('msg' => $inpoint, 'success' => 1, 'credit_now' => $credit_now); } } else { $this->message(array("success" => 2, "msg" => '您领取过红包了!'), ""); } $this->message($data); }
public function doMobilePtjpostinfo() { //发布信息内容 global $_W, $_GPC; load()->func('tpl'); load()->model('mc'); load()->func('file'); $uid = mc_openid2uid($_W['openid']); $creditarray = mc_credit_fetch($uid); $credit = $creditarray['credit1']; $ground = $_GPC['ground']; $type = $_GPC['type']; $user = $this->DboperateSearchUser($_W['openid']); if ($_GPC) { $title = $_GPC['title']; $content = $_GPC['description']; $privacy = $_GPC['top'] == 'on' ? 1 : 0; $c_pay = $_GPC['credit']; $phone = $_GPC['default_tel'] != '' ? $_GPC['default_tel'] : $_GPC['new_tel']; if ($_FILES['pic1']['name']) { $pic1 = file_upload($_FILES['pic1'], 'image'); $path1 = tomedia($pic1['path']); } if ($_FILES['pic2']['name']) { $pic2 = file_upload($_FILES['pic2'], 'image'); $path2 = tomedia($pic2['path']); } if ($_FILES['pic3']['name']) { $pic3 = file_upload($_FILES['pic3'], 'image'); $path3 = tomedia($pic3['path']); } //检测状态 if ($title != "" and $content != "" and $phone != "" and $credit >= floatval($c_pay)) { //判断置顶招聘是否已满 if ($privacy and $this->GetPrivacyNum() > 10) { message('置顶招聘已满...请稍后重试!', '', 'warning'); exit; } else { if ($privacy and $credit >= 100) { $value = mc_credit_update(mc_openid2uid($_W['openid']), 'credit1', -100); $this->SendTpl($_W['openid'], $user, 'credit1', $credit - 100); } else { if ($privacy) { message('积分不足,您无权进行此操作,请前往个人中心充值。如有问题,请与管理员联系!'); exit; } } } $jobid = substr(md5(substr(time(), 4, 8)), 4, 9); $t = $this->DboperateInsertGroundInfo($_W['openid'], $jobid, $title, $content, $phone, $privacy, $path1, $path2, $path3, intval($c_pay), $type); if ($t) { $url = murl('entry//ptjindex', array('m' => $this->modulename)); echo "<script>\r\n \t\t\tlocation.href='{$url}';\r\n \t\t\t</script>"; } } else { if ($credit < floatval($c_pay)) { message('积分不足,请前往个人中心充值。如有问题,请与管理员联系!', 'referer'); } } } include $this->template('postinfo'); }
$log .= "会员消费{$money}元,积分赠送比率为:【1:{$card['grant_rate']}】,共赠送【{$num}】积分"; mc_credit_update($uid, 'credit1', $num, array(0, $log, 'system', $clerk['id'], $clerk['store_id'])); $openid = pdo_fetchcolumn('SELECT openid FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uid = :uid', array(':acid' => $_W['acid'], ':uid' => $uid)); if (!empty($openid)) { if ($index == 'credit1') { mc_notice_credit1($openid, $uid, $num, $log); } } } exit('success'); } if ($do == 'credit') { $type = trim($_GPC['type']); $num = floatval($_GPC['num']); $names = array('credit1' => '积分', 'credit2' => '余额'); $credits = mc_credit_fetch($uid); if ($num < 0 && abs($num) > $credits[$type]) { exit("会员账户{$names[$type]}不够"); } $status = mc_credit_update($uid, $type, $num, array(0, trim($_GPC['remark']), 'system', $clerk['id'], $clerk['store_id'])); if (is_error($status)) { exit($status['message']); } if ($type == 'credit1') { mc_group_update($uid); } $openid = pdo_fetchcolumn('SELECT openid FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uid = :uid', array(':acid' => $_W['acid'], ':uid' => $uid)); if (!empty($openid)) { if ($type == 'credit1') { mc_notice_credit1($openid, $uid, $num, '管理员后台操作积分'); }
/** * 签到 */ function doSign($from, $settings) { global $_W; unset($uid, $today_sign, $insert); $uid = getUserIdByOpenId($from); if ($uid <= 0) { return array(false, 'no_login'); } $today_sign = getUserTodaySign($uid, $settings['times']); //今天签到数据 if (!empty($today_sign)) { return array(false, 'over_number'); } //超过签到次数 //list($times, $start_time, $end_time, $credit_type, $credit) $now = time(); if ($now < strtotime($settings['start_time']) || $now > strtotime($settings['end_time'])) { return array(false, 'over_time'); } //不在签到时间 $rank = intval(getTodaySignTotal()) + 1; $times = intval(getUserSignTotal($uid) + 1); $insert = array('uniacid' => $_W['uniacid'], 'uid' => $uid, 'time' => $now, 'sum_times' => $times, 'rank' => $rank); pdo_insert('kim_sign_record', $insert); if (pdo_insertid() > 0) { load()->model('mc'); $log = array(0, '签到获得'); mc_credit_update($uid, $settings['credit_type'], doubleval($settings['credit']), $log); $credit = mc_credit_fetch($uid, array($settings['credit_type'])); } $credits = uni_setting($_W['uniacid'], 'creditnames'); $credit_type = $credits['creditnames'][$settings['credit_type']]; $result = "您今天第 %s 个签到用户\n本次获得 %s 个%s\n您累计拥有 %s 个%s"; $result = sprintf($result, $rank, doubleval($settings['credit']), $credit_type['title'], $credit[$settings['credit_type']], $credit_type['title']); return array(true, $result); }
public function doMobileget_award() { global $_GPC, $_W; $rid = intval($_GPC['rid']); $uniacid = $_W['uniacid']; //开始抽奖咯 $reply = pdo_fetch("select * from " . tablename('stonefish_bigwheel_reply') . " where rid = :rid order by `id` desc", array(':rid' => $rid)); if ($reply == false) { $this->message(array("success" => 2, "msg" => '规则出错!...'), ""); } if ($reply['isshow'] != 1) { //活动已经暂停,请稍后... $this->message(array("success" => 2, "msg" => '活动暂停,请稍后...'), ""); } if ($reply['starttime'] > time()) { $this->message(array("success" => 2, "msg" => '活动还没有开始呢,请等待...'), ""); } if ($reply['endtime'] < time()) { $this->message(array("success" => 2, "msg" => '活动已经结束了,下次再来吧!'), ""); } if (empty($_W['fans'])) { $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), ""); } //先判断有没有资格领取 $fansID = $_W['member']['uid']; $from_user = $_W['fans']['from_user']; //判断是否为关注用户 $follow = pdo_fetchcolumn("select follow from " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid order by `fanid` desc", array(":openid" => $from_user, ":uniacid" => $uniacid)); if ($follow == 0) { $this->message(array("success" => 2, "msg" => '请先关注公共账号再来参与活动!详情请查看规则!'), ""); } //判断是否为关注用户 //是否已关联用户,如果中能中奖一次,判断是否已中奖 $fans = pdo_fetch("select * from " . tablename('stonefish_bigwheel_fans') . " where rid = " . $rid . " and fansID=" . $fansID . " and from_user='******'"); if ($fans == false) { //不存在false的情况,如果是false,则表明是非法 //$this->message(); $fans = array('rid' => $rid, 'uniacid' => $uniacid, 'fansID' => $fansID, 'from_user' => $from_user, 'todaynum' => 0, 'totalnum' => 0, 'awardnum' => 0, 'createtime' => time()); pdo_insert('stonefish_bigwheel_fans', $fans); $fans['id'] = pdo_insertid(); //增加人数,和浏览次数 pdo_update('stonefish_bigwheel_reply', array('fansnum' => $reply['fansnum'] + 1, 'viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); } else { if ($fans['awardnum'] >= $reply['award_times'] && $reply['award_times'] != 0) { $this->message(array("success" => 2, "msg" => '您已中过大奖了,本活动仅限中奖' . $reply['award_times'] . '次,谢谢!'), ""); } //增加浏览次数 pdo_update('stonefish_bigwheel_reply', array('viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); } //获得用户资料 $profile = mc_fetch($_W['member']['uid'], array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position')); //查询是活动定义的次数还是商户赠送次数 if ($reply['opportunity'] == 1) { if (empty($profile['mobile'])) { $this->message(array("success" => 2, "msg" => '您没有注册成为会员,不能抽奖!'), ""); } $doings = pdo_fetch("select * from " . tablename('stonefish_branch_doings') . " where rid = " . $rid . " and mobile='" . $profile['mobile'] . "' and uniacid='" . $uniacid . "'"); if (!empty($doings)) { if ($doings['status'] < 2) { $this->message(array("success" => 2, "msg" => '抱歉,您的抽奖资格正在审核中!'), ""); } else { if ($doings['awardcount'] == 0) { $this->message(array("success" => 2, "msg" => '抱歉,您的抽奖次数已用完了或没有获得抽奖次数!'), ""); } else { $reply['number_times'] = $doings['awardcount']; } } } else { $this->message(array("success" => 2, "msg" => '抱歉,您还没有获取抽奖资格,不能抽奖!'), ""); } } elseif ($reply['opportunity'] == 2) { load()->model('account'); $unisettings = uni_setting($uniacid, array('creditnames')); foreach ($unisettings['creditnames'] as $key => $credits) { if ($reply['credit_type'] == $key) { $creditnames = $credits['title']; break; } } $credit = mc_credit_fetch($fansID, array($reply['credit_type'])); $credit_times = intval($credit[$reply['credit_type']] / $reply['credit_times']); if ($credit_times < 1) { $this->message(array("success" => 2, "msg" => '抱歉,您没有' . $creditnames . '兑换抽奖次数了,不能再抽奖!'), ""); } if ($reply['number_times']) { if ($reply['number_times'] >= $credit_times) { $reply['number_times'] = $credit_times; } } else { $reply['number_times'] = $credit_times; } $reply['number_times'] += $fans['totalnum']; } //查询是活动定义的次数还是商户赠送次数 //查询分享赠送次数 if ($share['sharenum'] > 0) { if ($share['sharetype']) { $sharenum = pdo_fetchcolumn("select count(id) as dd from " . tablename('stonefish_bigwheel_data') . " where uniacid='" . $uniacid . "' and rid= '" . $rid . "' and fromuser='******'"); if ($share['sharenumtype'] == 2 && $reply['number_times'] > 0 && $sharenum > 0) { $reply['number_times'] = $reply['number_times'] + $share['sharenum']; } elseif ($reply['number_times'] > 0) { $reply['number_times'] = $reply['number_times'] + $share['sharenum'] * $sharenum; } } elseif ($fans['sharenum'] > 0 && $reply['number_times'] > 0) { $reply['number_times'] = $reply['number_times'] + $share['sharenum']; } } //查询分享赠送次数 //更新当日次数 $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" => '您超过当日抽奖次数了,不能抽奖了!'), ""); } //所有奖品 $gift = pdo_fetchall("select * from " . tablename('stonefish_bigwheel_prize') . " where rid = :rid and uniacid=:uniacid and turntable=:turntable order by Rand()", array(':rid' => $rid, ':uniacid' => $uniacid, ':turntable' => $reply['turntable'])); //计算礼物中的最小概率 $rate = 1; foreach ($gift as $giftxiao) { if ($giftxiao['probalilty'] < 1 && $giftxiao['probalilty'] > 0 && $giftxiao['prizetotal'] - $giftxiao['prizedraw'] >= 1) { $temp = explode('.', $giftxiao['probalilty']); $temp = pow(10, strlen($temp[1])); $rate = $temp < $rate ? $rate : $temp; } } //计算礼物中的最小概率 $prize_arr = array(); foreach ($gift as $row) { if ($row['prizetotal'] - $row['prizedraw'] >= 1 and floatval($row['prizepro']) > 0) { $item = array('id' => $row['id'], 'prize' => $row['prizetype'], 'v' => $row['prizepro'] * $rate); $prize_arr[] = $item; $isgift = true; } $zprizepro += $row['prizepro']; } //所有奖品 if ($isgift && ($fans['awardnum'] < $reply['award_times'] || $reply['award_times'] == 0)) { $last_time = strtotime(date("Y-m-d", mktime(0, 0, 0))); //当天抽奖次数 pdo_update('stonefish_bigwheel_fans', array('todaynum' => $fans['todaynum'] + 1, 'last_time' => $last_time), array('id' => $fans['id'])); //总抽奖次数 pdo_update('stonefish_bigwheel_fans', array('totalnum' => $fans['totalnum'] + 1), array('id' => $fans['id'])); //商家赠送增加使用次数 if ($reply['opportunity'] == 1) { pdo_update('stonefish_branch_doings', array('usecount' => $doings['usecount'] + 1, 'usetime' => time()), array('id' => $doings['id'])); } elseif ($reply['opportunity'] == 2) { mc_credit_update($fansID, $reply['credit_type'], -$reply['credit_times'], array($fansID, '兑换幸运大转盘活动消耗:' . $reply['credit_times'] . '个' . $creditnames)); $credit_now = $credit[$reply['credit_type']] - $reply['credit_times']; } //传统大转盘增加未中奖奖项 if (!empty($reply['lostDeg']) && $reply['turntable'] == 0 && 100 - $zprizepro > 0) { $item = array('id' => 0, 'prize' => '好可惜!没有中奖', 'v' => (100 - $zprizepro) * $rate); $prize_arr[] = $item; } //开始抽奖咯 foreach ($prize_arr as $key => $val) { $arr[$val['id']] = $val['v']; } $prizetype = $this->get_rand($arr); //根据概率获取奖项id if ($prizetype > 0) { $sn = random(16); $status = 1; $consumetime = ''; //查询奖品排名以及名称和类型 $k = pdo_fetchcolumn("select count(id) from " . tablename('stonefish_bigwheel_prize') . " where uniacid='" . $uniacid . "' and rid= '" . $rid . "' and id<='" . $prizetype . "' order by `id` asc"); $awardinfo = pdo_fetch("select * from " . tablename('stonefish_bigwheel_prize') . " where id='" . $prizetype . "'"); if (!empty($awardinfo['prizepic'])) { $awardinfo['prizepic'] = toimage($awardinfo['prizepic']); } pdo_update('stonefish_bigwheel_prize', array('prizedraw' => $awardinfo['prizedraw'] + 1), array('id' => $prizetype)); if ($awardinfo['credit_type'] != 'physical' && $awardinfo['credit_type'] != 'spaceprize') { $unisetting_s = uni_setting($uniacid, array('creditnames')); foreach ($unisetting_s['creditnames'] as $key => $credit) { if ($awardinfo['credit_type'] == $key) { $credit_names = $credit['title']; break; } } //添加积分到粉丝数据库 mc_credit_update($fansID, $awardinfo['credit_type'], $awardinfo['credit'], array($fansID, '幸运大转盘活动抽中' . $awardinfo['credit'] . '个' . $credit_names)); //添加积分到粉丝数据库 if ($reply['credit_type'] == $awardinfo['credit_type']) { $credit_now += $awardinfo['credit']; } $status = 2; $consumetime = time(); } if ($awardinfo['credit_type'] != 'spaceprize') { //中奖记录保存 $insert = array('uniacid' => $uniacid, 'rid' => $rid, 'fansID' => $fansID, 'from_user' => $from_user, 'name' => $awardinfo['prizetype'], 'description' => $awardinfo['prizename'], 'prizetype' => $prizetype, 'prize' => $k, 'award_sn' => $sn, 'createtime' => time(), 'consumetime' => $consumetime, 'status' => $status); $temp = pdo_insert('stonefish_bigwheel_award', $insert); $branchawardid = pdo_insertid(); //取id商家赠送时保存 //中奖记录保存 //保存中奖人信息到fans中 pdo_update('stonefish_bigwheel_fans', array('awardnum' => $fans['awardnum'] + 1, 'zhongjiang' => 1), array('id' => $fans['id'])); //保存中奖人信息到fans中 } //自动读取会员信息存入FANS表中 $isfansh = 180; $ziduan = array('realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'); foreach ($ziduan as $ziduans) { if ($reply['is' . $ziduans]) { if (!empty($profile[$ziduans]) && empty($fans[$ziduans])) { pdo_update('stonefish_bigwheel_fans', array($ziduans => $profile[$ziduans]), array('id' => $fans['id'])); } else { if (empty($fans[$ziduans])) { ${$ziduans} = true; } } $isfansh += 36; } } if ($realname || $mobile || $qq || $email || $address || $gender || $telephone || $idcard || $company || $occupation || $position) { $isfans = true; $isfansh += 56; } else { $isfansh = 180; } //自动读取会员信息存入FANS表中 //商家赠送添加使用记录 if ($reply['opportunity'] == 1) { $content = '中奖SN:' . $sn . ';' . $awardinfo['prizetype'] . '[' . $awardinfo['prizename'] . ']'; $insert = array('uniacid' => $uniacid, 'rid' => $rid, 'module' => 'stonefish_bigwheel', 'mobile' => $doings['mobile'], 'content' => $content, 'prizeid' => $branchawardid, 'createtime' => time()); pdo_insert('stonefish_branch_doingslist', $insert); } //商家赠送添加使用记录 $data = array('award' => $awardinfo, 'sn' => $sn, 'success' => 1, 'height' => $isfansh, 'credit_now' => $credit_now, 'prizetype' => $k, 'isfans' => $isfans); } if ($awardinfo['credit_type'] == 'spaceprize' || $prizetype <= 0) { //未中奖赠送积分 $creditnames = ""; //是否赠送积分 if ($reply['credit1'] > 0 || $reply['credit2'] > 0) { load()->model('account'); $unisettings = uni_setting($uniacid, array('creditnames')); foreach ($unisettings['creditnames'] as $key => $credit) { if ($reply['credittype'] == $key) { $creditnames = $credit['title']; break; } } $credit = mt_rand($reply['credit1'], $reply['credit2']); if ($reply['credit_type'] == $reply['credittype']) { $credit_now = $credit_now + $credit; } //添加积分到粉丝数据库 load()->model('mc'); mc_credit_update($fansID, $reply['credittype'], $credit, array($fansID, '幸运大转盘活动赠送' . $credit . '个' . $creditnames)); //添加积分到粉丝数据库 } if ($reply['turntable'] == 0) { if (!empty($creditnames)) { $data = array('name' => '幸运送' . $creditnames, 'award' => $creditnames, 'sn' => $credit, 'success' => 1, 'credit_now' => $credit_now, 'prizetype' => 0, 'isfans' => 0); $this->message($data); } else { $data = array('msg' => '抱歉,您没有中奖,好遗憾,下次再来吧!', 'success' => 1, 'height' => 180); $this->message($data); } } elseif ($awardinfo['credit_type'] == 'spaceprize') { $data['isfans'] = 0; $data['height'] = 180; $data['sn'] = $credit . '个' . $creditnames; $data['credit_now'] = $credit_now; } } $this->message($data); } else { //没有奖品或没有资格的提示 $data = array('msg' => '没有奖品了,好遗憾,下次早点来吧!', 'success' => 2, 'height' => 180); $this->message($data); } $this->message(); }
public function doMobileApply() { //这个操作被定义用来呈现 微站个人中心导航 global $_W, $_GPC; load()->model('mc'); $openid = $_W['fans']['from_user']; $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$openid}' LIMIT 1"); $uid = '0'; if ($fans['uid'] != '0') { $uid = $fans['uid']; } else { $uid = mc_update($uid, array('email' => md5($_W['openid']) . '@012wz.com')); if (!empty($fans['fanid']) && !empty($uid)) { pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid'])); } } $minnum = isset($this->module['config']['out_limit']) ? $this->module['config']['out_limit'] : '100.00'; $credit_type = isset($this->module['config']['credit_type']) ? $this->module['config']['credit_type'] : 'credit1'; $yue = mc_credit_fetch($uid); $ff_log = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$uid}'"); $profile = mc_fetch($uid); if (checksubmit('submit')) { if ($_GPC['type'] == '1' && empty($_GPC['alipay'])) { message('参数错误,请返回修改'); } if ($_GPC['type'] == '2' && empty($_GPC['cardid'])) { message('参数错误,请返回修改'); } $remark['1']['user'] = $_GPC['realname']; $remark['1']['time'] = time(); $remark['1']['reason'] = ''; $data = array('uniacid' => $_W['uniacid'], 'uid' => $uid, 'realname' => $_GPC['realname'], 'qq' => $_GPC['qq'], 'type' => intval($_GPC['type']), 'alipay' => $_GPC['alipay'], 'cardid' => $_GPC['cardid'], 'cardfrom' => $_GPC['cardfrom'], 'cardname' => $_GPC['cardname'], 'credit2' => $_GPC['credit2'], 'mobile' => $_GPC['mobile'], 'createtime' => time(), 'status' => '1', 'remark' => iserializer($remark)); pdo_insert('hx_subscribe_apply', $data); mc_credit_update($uid, $credit_type, '-' . $_GPC['mobile'], array('1', '申请提现')); message('提现成功', $this->createMobileUrl('myapply'), 'success'); } include $this->template('apply'); }
function getUserSystemCredit() { load()->model('mc'); $uid = mc_openid2uid($this->getOpenId()); $result = mc_credit_fetch($uid); return $result['credit1']; }
if (!empty($plid)) { $tag = array(); $tag['acid'] = $_W['acid']; $tag['uid'] = $_W['member']['uid']; pdo_update('core_paylog', array('openid' => $_W['openid'], 'tag' => iserializer($tag)), array('plid' => $plid)); } load()->model('payment'); load()->func('communication'); $sl = base64_encode(json_encode($ps)); $auth = sha1($sl . $_W['uniacid'] . $_W['config']['setting']['authkey']); header("location: ../payment/wechat/pay.php?i={$_W['uniacid']}&auth={$auth}&ps={$sl}"); exit; } if ($type == 'credit') { $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credtis = mc_credit_fetch($_W['member']['uid']); if ($credtis[$setting['creditbehaviors']['currency']] < $ps['fee']) { message("余额不足以支付, 需要 {$ps['fee']}, 当前 {$credtis[$setting['creditbehaviors']['currency']]}"); } $fee = floatval($ps['fee']); $result = mc_credit_update($_W['member']['uid'], $setting['creditbehaviors']['currency'], -$fee, array($_W['member']['uid'], '消费' . $setting['creditbehaviors']['currency'] . ':' . $fee)); if (is_error($result)) { message($result['message'], '', 'error'); } $sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid'; $pars = array(); $pars[':plid'] = $ps['tid']; $log = pdo_fetch($sql, $pars); if (!empty($log) && $log['status'] == '0') { $record = array(); $record['status'] = '1';
function mc_require($uid, $fields, $pre = '') { global $_W, $_GPC; if (empty($fields) || !is_array($fields)) { return false; } $flipfields = array_flip($fields); if (in_array('birth', $fields) || in_array('birthyear', $fields) || in_array('birthmonth', $fields) || in_array('birthday', $fields)) { unset($flipfields['birthyear'], $flipfields['birthmonth'], $flipfields['birthday'], $flipfields['birth']); $flipfields['birthyear'] = 'birthyear'; $flipfields['birthmonth'] = 'birthmonth'; $flipfields['birthday'] = 'birthday'; } if (in_array('reside', $fields) || in_array('resideprovince', $fields) || in_array('residecity', $fields) || in_array('residedist', $fields)) { unset($flipfields['residedist'], $flipfields['resideprovince'], $flipfields['residecity'], $flipfields['reside']); $flipfields['resideprovince'] = 'resideprovince'; $flipfields['residecity'] = 'residecity'; $flipfields['residedist'] = 'residedist'; } $fields = array_keys($flipfields); if (!in_array('uniacid', $fields)) { $fields[] = 'uniacid'; } if (!empty($pre)) { $pre .= '<br/>'; } $profile = mc_fetch($uid, $fields); $uniacid = $profile['uniacid']; $sql = 'SELECT `f`.`field`, `f`.`id` AS `fid`, `mf`.* FROM ' . tablename('profile_fields') . " AS `f` LEFT JOIN " . tablename('mc_member_fields') . " AS `mf` ON `f`.`id` = `mf`.`fieldid` WHERE `uniacid` = :uniacid ORDER BY\n\t\t\t`displayorder` DESC"; $system_fields = pdo_fetchall($sql, array(':uniacid' => $_W['uniacid']), 'field'); if (empty($system_fields)) { $sql = 'SELECT `id`, `field`, `title` FROM ' . tablename('profile_fields'); $system_fields = pdo_fetchall($sql, array(), 'field'); } $titles = array(); foreach ($system_fields as $field) { $titles[$field['field']] = $field['title']; } $message = ''; $ks = array(); foreach ($profile as $k => $v) { if (empty($v)) { $ks[] = $k; $message .= $system_fields[$k]['title'] . ', '; } } if (!empty($message)) { $title = '完善资料'; if (checksubmit('submit')) { if (in_array('resideprovince', $fields)) { $_GPC['resideprovince'] = $_GPC['reside']['province']; $_GPC['residecity'] = $_GPC['reside']['city']; $_GPC['residedist'] = $_GPC['reside']['district']; } if (in_array('birthyear', $fields)) { $_GPC['birthyear'] = $_GPC['birth']['year']; $_GPC['birthmonth'] = $_GPC['birth']['month']; $_GPC['birthday'] = $_GPC['birth']['day']; } $record = array_elements($fields, $_GPC); if (isset($record['uniacid'])) { unset($record['uniacid']); } foreach ($record as $field => $value) { if ($field == 'gender') { continue; } if (empty($value)) { message('请填写完整所有资料.', referer(), 'error'); } } $condition = " AND uid != {$uid} "; if (in_array('email', $fields)) { $emailexists = pdo_fetchcolumn("SELECT email FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND email = :email " . $condition, array(':uniacid' => $_W['uniacid'], ':email' => trim($record['email']))); if (!empty($emailexists)) { message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error'); } } if (in_array('mobile', $fields)) { $mobilexists = pdo_fetchcolumn("SELECT mobile FROM " . tablename('mc_members') . " WHERE uniacid = :uniacid AND mobile = :mobile " . $condition, array(':uniacid' => $_W['uniacid'], ':mobile' => trim($record['mobile']))); if (!empty($mobilexists)) { message('抱歉,您填写的手机号已经被使用,请更新。', 'refresh', 'error'); } } mc_update($uid, $record); message('资料完善成功.', 'refresh'); } load()->func('tpl'); load()->model('activity'); $filter = array(); $filter['status'] = 1; $coupons = activity_coupon_owned($_W['member']['uid'], $filter); $tokens = activity_token_owned($_W['member']['uid'], $filter); $setting = uni_setting($_W['uniacid'], array('creditnames', 'creditbehaviors', 'uc')); $behavior = $setting['creditbehaviors']; $creditnames = $setting['creditnames']; $credits = mc_credit_fetch($_W['member']['uid'], '*'); include template('mc/require', TEMPLATE_INCLUDEPATH); exit; } return $profile; }
/** * * @param $openid * 查询积分 */ public function synmembercredit($openid) { global $_W; $fans = pdo_fetch("select uid from " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid limit 1", array(':openid' => $openid, ":uniacid" => $_W['uniacid'])); if (!empty($fans)) { load()->model('mc'); $syscredit = mc_credit_fetch($fans['uid'], $types = array()); return $syscredit; } }
$value['thumb'] = tomedia($value['thumb']); $value['description'] = htmlspecialchars_decode($value['description']); } $_W['page']['title'] = '积分兑换'; $_W['page']['toolbar']['bottom'] = true; $_W['page']['toolbar']['jumps'] = array(array('title' => '礼品兑换', 'url' => url('activity/exchange/display', array('dtype' => 3)), 'active' => true), array('title' => '折扣券兑换', 'url' => url('activity/exchange/display', array('dtype' => 1))), array('title' => '代金券兑换', 'url' => url('activity/exchange/display', array('dtype' => 2))), array('title' => '抽奖机会', 'url' => url('activity/exchange/display', array('dtype' => 5))), array('divider' => true), array('title' => '所有兑换', 'url' => url('activity/exchange/display', array('dtype' => '')))); template('activity/exchange'); } elseif ($do == 'post') { $exid = intval($_GPC['exid']); if (!empty($exid)) { $exchange = activity_exchange_info($exid, $_W['uniacid']); } if (empty($exchange)) { message('没有指定的礼品兑换.'); } $credit = mc_credit_fetch($uid, array($exchange['credittype'])); if ($credit[$exchange['credittype']] < $exchange['credit']) { message($creditnames[$exchange['credittype']] . '数量不够,无法兑换.'); } $extype = intval($exchange['type']); if ($extype == 1) { $ret = activity_coupon_grant($uid, $exchange['extra']['id']); if (is_error($ret)) { message($ret['message']); } } elseif ($extype == 2) { $ret = activity_token_grant($uid, $exchange['extra']['id']); if (is_error($ret)) { message($ret['message']); } } elseif ($extype == 5) {
$dos = array('display', 'post', 'mine', 'use'); $do = in_array($_GPC['do'], $dos) ? $_GPC['do'] : 'display'; if ($do == 'display') { $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('activity_coupon') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime', array(':uniacid' => $_W['uniacid'], ':type' => 2, ':endtime' => TIMESTAMP)); $pindex = max(1, intval($_GPC['page'])); $psize = 10; $lists = pdo_fetchall('SELECT couponid,title,thumb,type,credittype,credit,endtime,description FROM ' . tablename('activity_coupon') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime ORDER BY endtime ASC LIMIT ' . ($pindex - 1) * $psize . ',' . $psize, array(':uniacid' => $_W['uniacid'], ':type' => 2, ':endtime' => TIMESTAMP)); $pager = pagination($total, $pindex, $psize); } if ($do == 'post') { $id = intval($_GPC['id']); $token = activity_token_info($id, $_W['uniacid']); if (empty($token)) { message('没有指定的礼品兑换.'); } $credit = mc_credit_fetch($_W['member']['uid'], array($token['credittype'])); if ($credit[$token['credittype']] < $token['credit']) { message('您的' . $creditnames[$token['credittype']] . '数量不够,无法兑换.'); } $ret = activity_token_grant($_W['member']['uid'], $id, 'system', '用户使用' . $token['credit'] . $creditnames[$token['credittype']] . '兑换'); if (is_error($ret)) { message($ret['message']); } mc_credit_update($_W['member']['uid'], $token['credittype'], -1 * $token['credit'], array($_W['member']['uid'], '礼品兑换:' . $token['title'] . ' 消耗 ' . $creditnames[$token['credittype']] . ':' . $token['credit'])); message("兑换成功,您消费了 {$token['credit']} {$creditnames[$token['credittype']]}", url('activity/token/mine')); } if ($do == 'mine') { $psize = 10; $pindex = max(1, intval($_GPC['page'])); $params = array(':uid' => $_W['member']['uid']); $filter['used'] = '1';
public function doMobilelist() { global $_GPC, $_W; load()->model('mc'); $from_user = $this->getFromUser(); ///28.查询用户的唯一身份ID。$state:参数0默认,参数1微信拉取用户详细信息。 $profile = $this->getProfile(); ///34.获取wwx_fxxt_member表会员信。 $signPackage = $this->getSignPackage(); ///35.转发分享信息、未关注信息、COOKIE等等设置。 $this->OverallSituation($from_user, $profile); ///1.全局统一调用。 $cfg = $this->module['config']; //获取模块设置信息 $title = $cfg['shopname']; //获取商城标题 if (empty($title)) { $title = '商城首页'; } if (!empty($signPackage['dzdtitle'])) { $title = $signPackage['dzdtitle']; } if (!empty($profile['id'])) { $myfansx = pdo_fetch('SELECT member_commission FROM ' . tablename('wwx_fxxt_member_shipgrade') . " WHERE uniacid = :uniacid and displayorder = :displayorder order by member_name desc limit 1", array(':uniacid' => $_W['uniacid'], ':displayorder' => $profile['usergrade'])); if (!empty($myfansx['member_commission'])) { $member_commission = $myfansx['member_commission']; } else { $member_commission = 0; } } //商品查询 $pindex = max(1, intval($_GPC['page'])); $psize = 10; $children = array(); $category = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_category') . " WHERE uniacid = '{$_W['uniacid']}' and enabled=1 ORDER BY parentid ASC, displayorder DESC", array(), 'id'); foreach ($category as $index => $row) { if (!empty($row['parentid'])) { $children[$row['parentid']][$row['id']] = $row; unset($category[$index]); } } $ccolumn = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1'"); $recommandcategory = array(); foreach ($category as &$c) { if ($c['isrecommand'] == 1) { $c['list'] = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' ORDER BY displayorder DESC, sales DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $c['total'] = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}'"); $c['pager'] = pagination($c['total'], $pindex, $psize, $url = '', $context = array('before' => 0, 'after' => 0, 'ajaxcallback' => '')); $recommandcategory[] = $c; } if (!empty($children[$c['id']])) { foreach ($children[$c['id']] as &$child) { if ($child['isrecommand'] == 1) { $child['list'] = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' and ccate='{$child['id']}' ORDER BY displayorder DESC, sales DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $child['total'] = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and isrecommand=1 and deleted=0 AND status = '1' and pcate='{$c['id']}' and ccate='{$child['id']}' "); $child['pager'] = pagination($child['total'], $pindex, $psize, $url = '', $context = array('before' => 0, 'after' => 0, 'ajaxcallback' => '')); $recommandcategory[] = $child; } } unset($child); } } unset($c); $carttotal = $this->getCartTotal(); ///38.查询购物车内的商品数量。 //查询首页幻灯片广告 $advs = pdo_fetchall("select * from " . tablename('wwx_fxxt_adv') . " where enabled=1 and uniacid= '{$_W['uniacid']}' order by displayorder asc"); foreach ($advs as &$adv) { if (substr($adv['link'], 0, 5) != 'http:') { $adv['link'] = $adv['link']; } } unset($adv); //查询所有限时抢购 if (empty($cfg['indexss'])) { $cfg['indexss'] = 0; } $islist = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_goods') . " WHERE uniacid = '{$_W['uniacid']}' and deleted=0 AND status = '1' and istime='1' ORDER BY displayorder DESC, sales DESC limit {$cfg['indexss']}"); foreach ($islist as &$r) { if ($r['istime'] == 1) { $arr = $this->time_tran($r['timeend']); ///56.生成倒计时。 $r['timelaststr'] = $arr[0]; $r['timelast'] = $arr[1]; } } unset($r); //获取自定义单页面代码 $theone = pdo_fetch('SELECT terms FROM ' . tablename('wwx_fxxt_rules') . " WHERE uniacid = :uniacid", array(':uniacid' => $_W['uniacid'])); $fans = mc_credit_fetch($_W['member']['uid'], '*'); //查询会员所有的积分段。 include $this->template('list'); }
function mc_notice_credit1($openid, $uid, $credit1_num, $tip, $url = '', $remark = '谢谢惠顾,点击查看详情') { global $_W; if (!$uid) { $uid = $_W['member']['uid']; } if (!$uid || !$credit1_num || empty($tip)) { return error(-1, '参数错误'); } $acc = mc_notice_init(); if (is_error($acc)) { return error(-1, $acc['message']); } if (!$acc->noticetpl['credit1']['switch']) { return error(-1, '未开启通知'); } $credit = mc_credit_fetch($uid); $time = date('Y-m-d H:i'); if (empty($url)) { $url = murl('mc/bond/credits', array('credittype' => 'credit1'), true, true); } $credit1_num = floatval($credit1_num); $type = '消费'; if ($credit1_num > 0) { $type = '到账'; } $username = $_W['member']['realname']; if (empty($username)) { $username = $_W['member']['nickname']; } if (empty($username)) { $username = $uid; } if ($_W['account']['level'] == 4) { if ($acc->noticetpl['credit1']['type'] == 2) { $data = array('first' => array('value' => "您好,您在{$time}有积分变更", 'color' => '#ff510'), 'account' => array('value' => $username, 'color' => '#ff510'), 'time' => array('value' => $time, 'color' => '#ff510'), 'type' => array('value' => $tip, 'color' => '#ff510'), 'creditChange' => array('value' => $type, 'color' => '#ff510'), 'number' => array('value' => abs($credit1_num) . '积分', 'color' => '#ff510'), 'creditName' => array('value' => '账户积分余额', 'color' => '#ff510'), 'amount' => array('value' => abs($credit['credit1']) . '积分', 'color' => '#ff510'), 'remark' => array('value' => "{$remark}", 'color' => '#ff510')); $status = $acc->sendTplNotice($openid, $acc->noticetpl['credit1'], $data, $url); } else { $content = "您在{$time}有积分{$type},{$type}积分【{$credit1_num}】,变更原因:【{$tip}】,消费后账户积分余额【{$credit['credit1']}】。"; $status = mc_notice_public($openid, '余额消费通知', $_W['account']['name'], $content, $url); } } if ($_W['account']['level'] == 3) { $info = "【{$_W['account']['name']}】积分变更通知\n"; $info .= "您在{$time}有积分{$type},{$type}积分【{$credit1_num}】元,变更原因:【{$tip}】,消费后账户积分余额【{$credit['credit1']}】。\n"; $info .= !empty($remark) ? "备注:{$remark}\n\n" : ''; $custom = array('msgtype' => 'text', 'text' => array('content' => urlencode($info)), 'touser' => $openid); $status = $acc->sendCustomNotice($custom); } return $status; }
<?php $people = pdo_fetch("SELECT * FROM " . tablename('feng_member') . " WHERE uniacid= '{$_W['uniacid']}' AND from_user= '******'fans']['from_user']}'"); if (!$people) { message('请先填写您的资料!', $this->createMobileUrl('prodata'), 'warning'); } load()->model('mc'); $result = mc_credit_fetch($_W['member']['uid']); include $this->template('profile');