Example #1
0
 public function payResult($params)
 {
     load()->model('mc');
     $status = pdo_fetchcolumn("SELECT status FROM " . tablename('mc_credits_recharge') . " WHERE tid = :tid", array(':tid' => $params['tid']));
     if (empty($status)) {
         $fee = $params['fee'];
         $data = array('status' => $params['result'] == 'success' ? 1 : -1);
         if ($params['type'] == 'wechat') {
             $data['transid'] = $params['tag']['transaction_id'];
             $params['user'] = mc_openid2uid($params['user']);
         }
         pdo_update('mc_credits_recharge', $data, array('tid' => $params['tid']));
         if ($params['result'] == 'success' && $params['from'] == 'notify') {
             $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
             $credit = $setting['creditbehaviors']['currency'];
             if (empty($credit)) {
                 message('站点积分行为参数配置错误,请联系服务商', '', 'error');
             } else {
                 $paydata = array('wechat' => '微信', 'alipay' => '支付宝');
                 $record[] = $params['user'];
                 $record[] = '用户通过' . $paydata[$params['type']] . '充值' . $fee;
                 mc_credit_update($params['user'], $credit, $fee, $record);
             }
         }
     }
     if ($params['from'] == 'return') {
         if ($params['result'] == 'success') {
             message('支付成功!', '../../app/' . url('mc/home'), 'success');
         } else {
             message('支付失败!', '../../app/' . url('mc/home'), 'error');
         }
     }
 }
Example #2
0
 public function receive()
 {
     global $_W, $_GPC;
     load()->model('mc');
     load()->func('communication');
     $event = $this->message['event'];
     $openid = $this->message['from'];
     $f_log = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE `uniacid` = '{$_W['uniacid']}' AND `openid` = '{$openid}'");
     if ($f_log['uid'] != 0) {
         pdo_update('hx_subscribe_data', array('uid' => $f_log['uid']), array('openid' => $openid));
         $uid = $f_log['uid'];
     } else {
         $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid']));
         $data = array('uniacid' => $_W['uniacid'], 'email' => md5($openid) . '@qdaygroup.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP);
         $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']);
         pdo_insert('mc_members', $data);
         $uid = pdo_insertid();
         pdo_update('mc_mapping_fans', array('uid' => $uid), array('openid' => $openid));
         pdo_update('hx_subscribe_data', array('uid' => $uid), array('openid' => $openid));
     }
     $credit_type = isset($this->module['config']['credit_type']) ? $this->module['config']['credit_type'] : 'credit1';
     $credit_subscribe = isset($this->module['config']['credit_subscribe']) ? $this->module['config']['credit_subscribe'] : 5;
     $credit_lever_1 = isset($this->module['config']['credit_lever_1']) ? $this->module['config']['credit_lever_1'] : 2;
     $credit_lever_2 = isset($this->module['config']['credit_lever_2']) ? $this->module['config']['credit_lever_2'] : 1;
     if ($event == 'subscribe') {
         $s_log = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `openid`='{$openid}'");
         if (empty($s_log)) {
             //如果没记录
             $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'uid' => $uid, 'from_uid' => '0', 'sn' => time(), 'follow' => '1', 'article_id' => '0', 'shouyi' => $credit_subscribe, 'createtime' => TIMESTAMP);
             pdo_insert('hx_subscribe_data', $insert);
             mc_credit_update($uid, $credit_type, $credit_subscribe, array('1', '关注增加积分'));
         } else {
             //如果有记录
             if ($s_log['follow'] != 1) {
                 //如果记录未关注
                 $insert = array('follow' => '1');
                 pdo_update('hx_subscribe_data', $insert, array('id' => $s_log['id']));
                 mc_credit_update($uid, $credit_type, $credit_subscribe, array('1', '关注增加积分'));
             }
             if (!empty($s_log['from_uid'])) {
                 //如果来源ID不为空
                 $from_user = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$s_log['from_uid']}'");
                 if (!empty($from_user)) {
                     $data = array('shouyi' => $from_user['shouyi'] + $credit_lever_1, 'zjrs' => $from_user['zjrs'] + 1);
                     pdo_update('hx_subscribe_data', $data, array('id' => $from_user['id']));
                     mc_credit_update($s_log['from_uid'], $credit_type, $credit_lever_1, array('1', '推荐一级关注增加积分'));
                     if (!empty($from_user['from_uid'])) {
                         $from_user_2 = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$from_user['from_uid']}'");
                         if (!empty($from_user_2)) {
                             $data2 = array('shouyi' => $from_user_2['shouyi'] + $credit_lever_2, 'jjrs' => $from_user_2['jjrs'] + 1);
                             pdo_update('hx_subscribe_data', $data2, array('id' => $from_user_2['id']));
                             mc_credit_update($from_user['from_uid'], $credit_type, $credit_lever_2, array('1', '推荐二级关注增加积分'));
                         }
                     }
                 }
             }
         }
         //pdo_update('hx_subscribe_data',array('follow'=>1),array('openid'=>$openid));
     }
 }
Example #3
0
 public function updateUserScore($score, $openid, $log = '')
 {
     load()->model('mc');
     $uid = mc_openid2uid($openid);
     $log_arr = array();
     $log_arr[0] = $uid;
     $log_arr[1] = $log == '' ? '未记录' : $log;
     mc_credit_update($uid, 'credit1', $score, $log_arr);
 }
Example #4
0
 public function receive()
 {
     global $_W;
     load()->model('mc');
     $type = $this->message['type'];
     $event = $this->message['event'];
     $openid = $this->message['from'];
     $config = $this->module['config'];
     $acc = WeAccount::create($_W['acid']);
     if ($event == 'subscribe' && $config['sub_num'] != 0 && !empty($config['sub_type'])) {
         $log = pdo_fetch("SELECT id FROM " . tablename('ju_credit_log') . " WHERE uniacid=:uniacid and openid=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
         if (empty($log)) {
             $uid = mc_openid2uid($openid);
             $result = mc_credit_update($uid, $config['sub_type'], $config['sub_num'], array('0' => '1', '1' => '关注平台奖励'));
             if ($result) {
                 $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'subscribetime' => time(), 'unsubscribetime' => 0, 'follow' => 1);
                 pdo_insert('ju_credit_log', $insert);
                 $this->sendText($acc, $this->message['from'], '感谢您的关注,赠送您' . $config['sub_num'] . '!');
             }
         } else {
             pdo_update('ju_credit_log', array('follow' => 1, 'subscribetime' => time()), array('id' => $log['id']));
         }
     } elseif ($event == 'unsubscribe' && $config['unsub_num'] != 0) {
         $log = pdo_fetch("SELECT id FROM " . tablename('ju_credit_log') . " WHERE uniacid=:uniacid and openid=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid));
         $uid = mc_openid2uid($openid);
         if (empty($log)) {
             $result = mc_credit_update($uid, $config['unsub_type'], '-' . $config['unsub_num'], array('0' => '1', '1' => '取消关注平台扣除'));
             if ($result) {
                 $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'subscribetime' => 0, 'unsubscribetime' => time(), 'follow' => 0);
                 pdo_insert('ju_credit_log', $insert);
             }
         } else {
             $result = mc_credit_update($uid, $config['unsub_type'], '-' . $config['unsub_num'], array('0' => '1', '1' => '取消关注平台扣除'));
             pdo_update('ju_credit_log', array('follow' => 0, 'subscribetime' => 0, 'unsubscribetime' => time()), array('id' => $log['id']));
         }
     }
 }
Example #5
0
 public function doMobileShow()
 {
     global $_W, $_GPC;
     $rid = trim($_GPC['rid']);
     $reply = pdo_fetch("SELECT * FROM " . tablename('bm_qrsign_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
     if (time() > strtotime($reply['endtime'])) {
         if (empty($reply['memo2'])) {
             $msg = '对不起,活动已经于' . $reply['endtime'] . '结束,感谢您的参与!!!';
         } else {
             $msg = $reply['memo2'];
         }
         message($msg, $reply['url2'], 'success');
     }
     if (time() < strtotime($reply['starttime'])) {
         if (empty($reply['memo1'])) {
             $msg = '对不起,活动将于' . $reply['starttime'] . '开始,敬请期待!!!';
         } else {
             $msg = $reply['memo1'];
         }
         message($msg, $reply['url1'], 'success');
     }
     if (empty($_W['fans']['nickname'])) {
         mc_oauth_userinfo();
     }
     if ($reply['pictype'] == 1) {
         if (empty($_W['fans']['follow']) || $_W['fans']['follow'] == 0) {
             header("Location: " . $reply['urlx']);
             exit;
         }
     }
     $op = trim($_GPC['op']);
     $qrmoney = $_GPC['qrmoney'];
     $from_user = $_W['fans']['openid'];
     $qrpicurl = $_W['attachurl'] . $reply['qrcode'];
     if ($op == 'post') {
         if ($qrmoney < 0.01) {
             message('支付金额错误,请重新录入!', $this->createMobileUrl('show', array('rid' => $rid, 'from_user' => $from_user)), 'error');
         }
         $data = array('rid' => $rid, 'dateline' => TIMESTAMP, 'clientOrderId' => TIMESTAMP, 'qrmoney' => $qrmoney, 'status' => 0, 'fromuser' => $from_user, 'username' => $_W['fans']['nickname'], 'avatar' => $_W['fans']['tag']['avatar'], 'credit' => $reply['n']);
         pdo_insert('bm_qrsign_payed', $data);
         $params = array('tid' => $data['clientOrderId'], 'ordersn' => $data['clientOrderId'], 'title' => '扫码支付', 'fee' => $data['qrmoney'], 'user' => $from_user);
         $this->pay($params);
         exit;
     } else {
         if ($op == 'sign') {
             $rec = pdo_fetch("select * from " . tablename('bm_qrsign_record') . " where rid= " . $rid . " and fromuser= '******' order by sign_time desc");
             if (!empty($rec)) {
                 $Date_1 = date("Y-m-d", time());
                 $Date_2 = date("Y-m-d", $rec['sign_time']);
                 $Date_List_a1 = explode("-", $Date_1);
                 $Date_List_a2 = explode("-", $Date_2);
                 $d1 = mktime(0, 0, 0, $Date_List_a1[1], $Date_List_a1[2], $Date_List_a1[0]);
                 $d2 = mktime(0, 0, 0, $Date_List_a2[1], $Date_List_a2[2], $Date_List_a2[0]);
                 $Days = round(($d1 - $d2) / 3600 / 24);
                 if ($Days == 0) {
                     $msg = '感谢您的参与,每个人每天只可以签到一次哦!!!';
                     message($msg, $reply['urly'], 'success');
                 }
             }
             $insert = array('rid' => $rid, 'fromuser' => $from_user, 'username' => $_W['fans']['nickname'], 'avatar' => $_W['fans']['tag']['avatar'], 'sign_time' => $_W['timestamp'], 'credit' => $reply['n']);
             pdo_insert('bm_qrsign_record', $insert);
             $user = fans_search($from_user);
             $sql_member = "SELECT a.uid FROM " . tablename('mc_mapping_fans') . " a inner join " . tablename('mc_members') . " b on a.uid=b.uid WHERE a.openid='{$from_user}'";
             $uid = pdo_fetchcolumn($sql_member);
             mc_credit_update($uid, 'credit1', intval($reply['n']), array(0 => 'system', 1 => '扫码签到送积分'));
             $user = fans_search($from_user);
             $msg = '恭喜签到成功,您已获得奖励积分' . $reply['n'] . '分,您目前的总积分为' . $user['credit1'] . '分!';
             message($msg, $reply['urly'], 'success');
         }
     }
     include $this->template('show');
 }
Example #6
0
 /**
  * author: 微赞科技
  * 兑换
  */
 public function doMobileDH()
 {
     global $_W, $_GPC;
     MonUtil::checkmobile();
     $rid = $_GPC['rid'];
     $egid = $_GPC['egid'];
     $dpassword = $_GPC['dpassword'];
     $record = DBUtil::findById(DBUtil::$TABLE_EGG_RECORD, $rid);
     $res = array();
     if (empty($record)) {
         $res['code'] = 500;
         $res['msg'] = "记录删除或不存在";
         die(json_encode($res));
     }
     $egg = DBUtil::findById(DBUtil::$TABLE_EGG, $egid);
     if ($record['status'] == self::$STATUS_DH) {
         $res['code'] = 500;
         $res['msg'] = "奖品已经兑换过";
         die(json_encode($res));
     }
     if ($egg['dpassword'] == $dpassword) {
         //密码正确
         $prize = DBUtil::findById(DBUtil::$TABLE_EGG_PRIZE, $record['pid']);
         if ($prize['ptype'] == 2) {
             //积分类型
             load()->model('mc');
             $uid = mc_openid2uid($this->getOpenId());
             $result = mc_credit_update($uid, 'credit1', $prize['jf'], array($uid, '砸金蛋手机端兑换积分'));
             if ($result) {
                 DBUtil::updateById(DBUtil::$TABLE_EGG_RECORD, array("status" => self::$STATUS_DH, 'dhtime' => TIMESTAMP), $rid);
                 $res['code'] = 200;
                 die(json_encode($res));
             } else {
                 $res['code'] = 500;
                 $res['msg'] = "兑换失败";
                 die(json_encode($res));
             }
         } else {
             DBUtil::updateById(DBUtil::$TABLE_EGG_RECORD, array("status" => self::$STATUS_DH, 'dhtime' => TIMESTAMP), $rid);
             $res['code'] = 200;
             die(json_encode($res));
         }
     } else {
         $res['code'] = 500;
         $res['msg'] = "密码错误";
         die(json_encode($res));
     }
 }
Example #7
0
 private function sysAddCredit($from_user, $credit_value, $credittype, $tag)
 {
     global $_GPC;
     load()->model('mc');
     $uid = mc_openid2uid($from_user);
     mc_credit_update($uid, 'credit' . $credittype, $credit_value, array($uid, $tag));
 }
Example #8
0
        $is_add = pdo_fetchcolumn($sql, $parm);
        if (empty($is_add)) {
            $creditbehaviors = pdo_fetchcolumn('SELECT creditbehaviors FROM ' . tablename('uni_settings') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid']));
            $creditbehaviors = iunserializer($creditbehaviors) ? iunserializer($creditbehaviors) : array();
            if (empty($creditbehaviors['activity'])) {
                $ret['result'] = 'creditset-miss';
                moduleInit($_GPC['module'], $ret);
            } else {
                $credittype = $creditbehaviors['activity'];
            }
            $data = array('uniacid' => $_W['uniacid'], 'touid' => $uid, 'fromuid' => 0, 'module' => $_GPC['module'], 'sign' => $_GPC['sign'], 'action' => $_GPC['action'], 'credit_value' => intval($return['credit_value']), 'createtime' => TIMESTAMP);
            pdo_insert('mc_handsel', $data);
            $note = empty($_GPC['note']) ? '系统赠送积分' : $_GPC['note'];
            $log = array('uid' => $uid, 'credittype' => $credittype, 'uniacid' => $_W['uniacid'], 'num' => intval($return['credit_value']), 'createtime' => TIMESTAMP, 'operator' => 0, 'remark' => $note);
            $credit_value = intval($return['credit_value']);
            mc_credit_update($uid, $credittype, $credit_value, $log);
            $ret['result'] = 'success';
            moduleInit($_GPC['module'], $ret);
        } else {
            $ret['result'] = 'repeat';
            moduleInit($_GPC['module'], $ret);
        }
    } else {
        $ret['result'] = 'action-miss';
        moduleInit($_GPC['module'], $ret);
    }
} else {
    $ret['result'] = 'uid-miss';
    moduleInit($_GPC['module'], $ret);
}
function moduleInit($name, $params = array())
Example #9
0
    public function doMobileGetAward()
    {
        global $_GPC, $_W;
        if (empty($_W['fans']['from_user']) || empty($_W['member']['uid'])) {
            message('非法访问,请重新发送消息进入砸蛋页面!');
        }
        checkauth();
        $fromuser = $_W['fans']['from_user'];
        $uid = intval($_W['member']['uid']);
        $id = intval($_GPC['id']);
        $sql = 'SELECT `id`, `periodlottery`, `maxlottery`, `default_tips`, `misscredit`, `hitcredit` FROM ' . tablename('egg_reply') . ' WHERE `rid` = :rid';
        $params = array(':rid' => $id);
        $egg = pdo_fetch($sql, $params);
        if (empty($egg)) {
            message('非法访问,请重新发送消息进入砸蛋页面!');
        }
        $result = array('status' => -1, 'message' => '');
        $sql = 'SELECT COUNT(*) FROM ' . tablename('egg_winner') . ' WHERE `rid` = :rid AND `uid` = :uid';
        $params[':uid'] = $uid;
        if (empty($egg['periodlottery'])) {
            $total = pdo_fetchcolumn($sql, $params);
            if ($total >= $egg['maxlottery']) {
                $result['message'] = '您已经超过最大砸蛋次数';
                message($result, '', 'ajax');
            }
        } else {
            $sql .= ' AND `createtime` > :createtime';
            $params[':createtime'] = strtotime(date('Y-m-d')) - 86400 * $egg['periodlottery'];
            $total = pdo_fetchcolumn($sql, $params);
            if ($total >= $egg['maxlottery']) {
                $sql = 'SELECT `createtime` FROM ' . tablename('egg_winner') . ' WHERE `rid` = :rid AND `uid` = :uid
						ORDER BY `createtime` DESC';
                $lastdate = pdo_fetchcolumn($sql, array(':rid' => $id, ':uid' => $uid));
                $result['message'] = '您还未到达可以再次砸蛋的时间。下次可砸时间为' . date('Y-m-d', strtotime(date('Y-m-d', $lastdate)) + $egg['periodlottery'] * 86400);
                message($result, '', 'ajax');
            }
        }
        $sql = 'SELECT * FROM ' . tablename('egg_award') . ' WHERE `rid` = :rid ORDER BY `probalilty`';
        $gifts = pdo_fetchall($sql, array(':rid' => $id));
        $awards = array();
        foreach ($gifts as $key => $gift) {
            if (empty($gift['total']) || empty($gift['probalilty'])) {
                unset($gifts[$key]);
                continue;
            }
            $gifts[$key]['random'] = mt_rand(1, 100 / $gift['probalilty']);
            if (mt_rand(1, 100 / $gift['probalilty']) == mt_rand(1, 100 / $gift['probalilty'])) {
                $awards[] = $gift;
            }
        }
        if (count($awards) > 0) {
            $randid = mt_rand(0, count($awards) - 1);
            $awardid = $awards[$randid];
        }
        $result['message'] = empty($egg['default_tips']) ? '很遗憾,您没能中奖!' : $egg['default_tips'];
        $credit = array('rid' => $id, 'uniacid' => $_W['uniacid'], 'uid' => $uid, 'from_user' => $fromuser, 'isaward' => empty($awardid) ? 0 : 1, 'award' => (empty($awardid) ? '未中' : '中') . '奖奖励积分', 'description' => empty($awardid) ? $egg['misscredit'] : $egg['hitcredit'], 'credit' => empty($awardid) ? $egg['misscredit'] : $egg['hitcredit'], 'createtime' => strtotime(date('Y-m-d H:i:s')), 'status' => 2);
        if (!empty($awardid)) {
            $sql = 'SELECT * FROM ' . tablename('egg_award') . ' WHERE `rid` = :rid AND `id` = :id';
            $params = array(':rid' => $id, ':id' => $awardid['id']);
            $gift = pdo_fetch($sql, $params);
            if ($gift['total'] > 0) {
                $credit['status'] = 0;
                $credit['award'] = $gift['title'];
                if (!empty($gift['inkind'])) {
                    $credit['description'] = $gift['description'];
                    $sql = 'UPDATE ' . tablename('egg_award') . ' SET `total` = `total` - 1 WHERE `rid` = :rid AND `id` = :id';
                    pdo_query($sql, $params);
                } else {
                    $gift['activation_code'] = (array) iunserializer($gift['activation_code']);
                    $code = array_pop($gift['activation_code']);
                    $activation_code = iserializer($gift['activation_code']);
                    $sql = 'UPDATE ' . tablename('egg_award') . " SET `total` = `total` - 1, `activation_code` = '" . $activation_code . "' WHERE `rid` = :rid AND `id` = :id";
                    pdo_query($sql, $params);
                    $credit['description'] = '兑换码:' . $code . '<br /> 兑换地址:' . $gift['activation_url'];
                }
                $result['message'] = '恭喜您,得到“' . $gift['title'] . '”!';
                $result['status'] = 0;
            } else {
                $credit['description'] = $egg['misscredit'];
                $credit['award'] = '未中奖奖励积分';
            }
        }
        !empty($credit['description']) && ($result['message'] .= '<br />' . $credit['award'] . ':' . $credit['description']);
        $credit['aid'] = $gift['id'];
        if (empty($awardid)) {
            $value = intval($egg['misscredit']);
            $uid = mc_openid2uid($fromuser);
            mc_credit_update($uid, 'credit1', $value, array(0, '使用砸蛋模块未中奖,赠送' . $value . '积分'));
        } else {
            $value = intval($egg['hitcredit']);
            $uid = mc_openid2uid($fromuser);
            mc_credit_update($uid, 'credit1', $value, array(0, '使用砸蛋模块中奖,赠送' . $value . '积分'));
        }
        pdo_insert('egg_winner', $credit);
        $result['myaward'] = pdo_fetchall("SELECT award, description FROM " . tablename('egg_winner') . " WHERE uid = '{$uid}' AND award <> '' AND rid = '{$id}' ORDER BY createtime DESC");
        message($result, '', 'ajax');
    }
Example #10
0
 public function payResult($params)
 {
     global $_W;
     load()->model('mc');
     $order = pdo_fetch("SELECT * FROM " . tablename('mc_credits_recharge') . " WHERE tid = :tid", array(':tid' => $params['tid']));
     if (empty($order['status'])) {
         $fee = $params['fee'];
         $total_fee = $fee;
         $data = array('status' => $params['result'] == 'success' ? 1 : -1);
         if ($params['type'] == 'wechat') {
             $data['transid'] = $params['tag']['transaction_id'];
             $params['user'] = mc_openid2uid($params['user']);
         }
         pdo_update('mc_credits_recharge', $data, array('tid' => $params['tid']));
         if ($params['result'] == 'success' && $params['from'] == 'notify') {
             $paydata = array('wechat' => '微信', 'alipay' => '支付宝', 'baifubao' => '百付宝', 'unionpay' => '银联');
             if (empty($order['type']) || $order['type'] == 'credit') {
                 $setting = uni_setting($_W['uniacid'], array('creditbehaviors', 'recharge'));
                 $credit = $setting['creditbehaviors']['currency'];
                 if (empty($credit)) {
                     message('站点积分行为参数配置错误,请联系服务商', '', 'error');
                 } else {
                     $recharge = $setting['recharge'];
                     $add_fee = 0;
                     if (!empty($recharge)) {
                         $back = -1;
                         foreach ($recharge as $k => $li) {
                             if ($li['recharge'] <= $fee) {
                                 $back = $k;
                             }
                         }
                         if (!empty($recharge[$back])) {
                             $add_fee = $recharge[$back]['back'];
                             $total_fee = $add_fee + $fee;
                             $add_str = ",满足 充{$recharge[$back]['recharge']}返{$recharge[$back]['back']},返余额{$recharge[$back]['back']}元,本次操作共增加余额{$total_fee}元";
                         }
                     }
                     $record[] = $params['user'];
                     $record[] = '用户通过' . $paydata[$params['type']] . '充值' . $fee . $add_str;
                     mc_credit_update($order['uid'], $credit, $total_fee, $record);
                     $remark = '用户通过' . $paydata[$params['type']] . '充值' . $fee . $add_str;
                     mc_notice_recharge($order['openid'], $order['uid'], $total_fee, '', $remark);
                 }
             }
             if ($order['type'] == 'card_nums') {
                 $member_card = pdo_get('mc_card_members', array('uniacid' => $order['uniacid'], 'uid' => $order['uid']));
                 $total_num = $member_card['nums'] + $order['tag'];
                 pdo_update('mc_card_members', array('nums' => $total_num), array('uniacid' => $order['uniacid'], 'uid' => $order['uid']));
                 $log = array('uniacid' => $order['uniacid'], 'uid' => $order['uid'], 'type' => 'nums', 'fee' => $params['fee'], 'model' => '1', 'tag' => $order['tag'], 'note' => date('Y-m-d H:i') . "通过{$paydata[$params['type']]}充值{$params['fee']}元,返{$order['tag']}次,总共剩余{$total_num}次", 'addtime' => TIMESTAMP);
                 pdo_insert('mc_card_record', $log);
                 $type = pdo_fetchcolumn('SELECT nums_text FROM ' . tablename('mc_card') . ' WHERE uniacid = :uniacid', array(':uniacid' => $order['uniacid']));
                 $total_num = $member_card['nums'] + $order['tag'];
                 mc_notice_nums_plus($order['openid'], $type, $order['tag'], $total_num);
             }
             if ($order['type'] == 'card_times') {
                 $member_card = pdo_get('mc_card_members', array('uniacid' => $order['uniacid'], 'uid' => $order['uid']));
                 if ($member_card['endtime'] > TIMESTAMP) {
                     $endtime = $member_card['endtime'] + $order['tag'] * 86400;
                 } else {
                     $endtime = strtotime($order['tag'] . 'days');
                 }
                 pdo_update('mc_card_members', array('endtime' => $endtime), array('uniacid' => $order['uniacid'], 'uid' => $order['uid']));
                 $log = array('uniacid' => $order['uniacid'], 'uid' => $order['uid'], 'type' => 'times', 'model' => '1', 'fee' => $params['fee'], 'tag' => $order['tag'], 'note' => date('Y-m-d H:i') . "通过{$paydata[$params['type']]}充值{$params['fee']}元,返{$order['tag']}天,充值后到期时间:" . date('Y-m-d', $endtime), 'addtime' => TIMESTAMP);
                 pdo_insert('mc_card_record', $log);
                 $type = pdo_fetchcolumn('SELECT times_text FROM ' . tablename('mc_card') . ' WHERE uniacid = :uniacid', array(':uniacid' => $order['uniacid']));
                 $endtime = date('Y-m-d', $endtime);
                 mc_notice_times_plus($order['openid'], $member_card['cardsn'], $type, $fee, $order['tag'], $endtime);
             }
         }
     }
     if ($order['type'] == 'credit' || $order['type'] == '') {
         $url = murl('mc/home');
     } else {
         $url = murl('mc/bond/mycard');
     }
     if ($params['from'] == 'return') {
         if ($params['result'] == 'success') {
             message('支付成功!', '../../app/' . $url, 'success');
         } else {
             message('支付失败!', '../../app/' . $url, 'error');
         }
     }
 }
Example #11
0
 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);
 }
    $ret = activity_shipping_grant($uid, $exid);
    if (is_error($ret)) {
        message($ret['message']);
    }
    $member = mc_fetch($uid, array('uid', 'realname', $exchange['credittype'], 'resideprovince', 'residecity', 'residedist', 'address', 'zipcode', 'mobile'));
    if ($member[$exchange['credittype']] < $exchange['credit']) {
        message($creditnames[$exchange['credittype']] . '数量不够,无法兑换.');
    }
    $shipping = array('exid' => $exid, 'uniacid' => $uniacid, 'uid' => $uid, 'realname' => $member['realname'], 'mobile' => $member['mobile'], 'province' => $member['resideprovince'], 'city' => $member['residecity'], 'district' => $member['residedist'], 'address' => $member['address'], 'zipcode' => $member['zipcode']);
    if (checksubmit('submit')) {
        $data = array('uniacid' => $_W['uniacid'], 'exid' => $exid, 'uid' => $uid, 'status' => 0, 'createtime' => time(), 'name' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'province' => $_GPC['reside']['province'], 'city' => $_GPC['reside']['city'], 'district' => $_GPC['reside']['district'], 'address' => $_GPC['address'], 'zipcode' => $_GPC['zipcode']);
        $trade_log = array('uniacid' => $_W['uniacid'], 'uid' => $uid, 'exid' => $exid, 'type' => 3, 'createtime' => time(), 'extra' => iserializer($exchange));
        pdo_insert('activity_exchange_trades', $trade_log);
        pdo_insert('activity_exchange_trades_shipping', $data);
        pdo_update('activity_exchange', array('num' => $exchange['num'] + 1), array('id' => $exchange['id'], 'uniacid' => $_W['uniacid']));
        mc_credit_update($uid, $exchange['credittype'], -1 * $exchange['credit'], array($uid, '礼品兑换:' . $exchange['title'] . ' 消耗 ' . $creditnames[$exchange['credittype']] . ':' . $exchange['credit']));
        message("兑换成功,您消费了 {$exchange['credit']} {$creditnames[$exchange['credittype']]}", url('activity/exchange/mine', array('type' => 3)));
    }
    template('activity/shipping');
} elseif ($do == 'mine') {
    $type = intval($_GPC['type']);
    $type = empty($type) ? 1 : $type;
    $type = in_array($type, array(1, 2, 3, 4, 5)) ? $type : 1;
    $page = intval($_GPC['__input']['page']);
    switch ($type) {
        case 1:
        case 2:
            break;
        case 3:
            $pindex = max(1, $page);
            $psize = 10;
Example #13
0
 public function doMobileCredit()
 {
     global $_W, $_GPC;
     if (!$this->check_mc_follow()) {
         if (empty($_W['account']['subscribeurl'])) {
             $this->msg('error', '请关注本公众平台后再参与活动!');
         }
         $this->msg('redirect', $_W['account']['subscribeurl']);
     }
     checkauth();
     if (empty($_W['member']['mobile'])) {
         //如果未填写手机号码,跳转到会员中心
         $this->msg('uc', '<P>请先完善您的个人资料!</p><P><font color="red">注意</font>:姓名和手机号码必填。</p><P>个人资料是将来兑奖的依据。</p>');
     }
     //用户信息
     $member_info = pdo_fetch("SELECT * FROM " . tablename('mc_members') . " WHERE uid=" . $_W['member']['uid']);
     //活动信息
     $info = pdo_fetch("SELECT l.title as goods_title,l.info,l.price,l.thumb,d.*,r.title as rule_title,r.rule FROM " . tablename('zerobuy_detail') . " d left join " . tablename('zerobuy_list') . " l on d.lid=l.id left join " . tablename('zerobuy_rule') . " r on d.rid=r.id WHERE d.id=" . $_GPC['id']);
     if ($info['status'] == 1) {
         $this->msg('error', '活动还未开始,请耐心等待!');
     }
     if ($info['status'] == 3 || $info['status'] == 4) {
         $this->msg('error', '活动已经结束!');
     }
     $num = floor($member_info['credit1'] / $info['exchange']);
     if ($_GPC['act'] == 'exchange') {
         if ($num < 1) {
             $this->msg('error', '积分不足');
         }
         $msg = $this->make_code($_GPC['id']);
         //更行用户表
         load()->model('mc');
         mc_credit_update($_W['member']['uid'], 'credit1', -$info['exchange'], array($_W['member']['uid'], "参与零元购活动:" . $info['title']));
         $this->msg('success', $msg);
     }
 }
Example #14
0
 public function doMobileGetAward()
 {
     global $_GPC, $_W;
     checkauth();
     $fromuser = $_W['fans']['from_user'];
     $id = intval($_GPC['id']);
     $dqq = pdo_fetch("SELECT id, periodlottery, maxlottery, default_tips, misscredit, hitcredit FROM " . tablename('dqq_reply') . " WHERE rid = '{$id}' LIMIT 1");
     if (empty($dqq)) {
         message('非法访问,请重新发送消息进入打气球页面!4');
     }
     $result = array('status' => -1, 'message' => '');
     if (!empty($dqq['periodlottery'])) {
         $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('dqq_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******'  AND rid = '{$id}'");
         $lastdate = pdo_fetchcolumn("SELECT createtime FROM " . tablename('dqq_winner') . " WHERE from_user = '******'  ORDER BY createtime DESC");
         if ($total >= intval($dqq['maxlottery']) && strtotime(date('Y-m-d')) < strtotime(date('Y-m-d', $lastdate)) + $dqq['periodlottery'] * 86400) {
             $result['message'] = '没箭啦';
             message($result, '', 'ajax');
         }
     } else {
         $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('dqq_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******' ");
         if (!empty($dqq['maxlottery']) && $total >= $dqq['maxlottery']) {
             $result['message'] = '今天没箭了';
             message($result, '', 'ajax');
         }
     }
     $gifts = pdo_fetchall("SELECT id, probalilty FROM " . tablename('dqq_award') . " WHERE rid = '{$id}' ORDER BY probalilty ASC");
     //计算每个礼物的概率
     $probability = 0;
     $rate = 1;
     $award = array();
     foreach ($gifts as $name => $gift) {
         if (empty($gift['probalilty'])) {
             continue;
         }
         if ($gift['probalilty'] < 1) {
             $temp = explode('.', $gift['probalilty']);
             $temp = pow(10, strlen($temp[1]));
             $rate = $temp < $rate ? $rate : $temp;
         }
         $probability = $probability + $gift['probalilty'] * $rate;
         $award[] = array('id' => $gift['id'], 'probalilty' => $probability);
     }
     $all = 100 * $rate;
     if ($probability < $all) {
         $award[] = array('title' => '', 'probalilty' => $all);
     }
     mt_srand((double) microtime() * 1000000);
     $rand = mt_rand(1, $all);
     foreach ($award as $key => $gift) {
         if (isset($award[$key - 1])) {
             if ($rand > $award[$key - 1]['probalilty'] && $rand <= $gift['probalilty']) {
                 $awardid = $gift['id'];
                 break;
             }
         } else {
             if ($rand > 0 && $rand <= $gift['probalilty']) {
                 $awardid = $gift['id'];
                 break;
             }
         }
     }
     $result['message'] = '唉,没中';
     $data = array('rid' => $id, 'from_user' => $fromuser, 'status' => empty($gift['inkind']) ? 1 : 0, 'createtime' => TIMESTAMP);
     $credit = array('rid' => $id, 'award' => (empty($awardid) ? '未中' : '中') . '奖励积分', 'from_user' => $fromuser, 'status' => 3, 'description' => empty($awardid) ? $dqq['misscredit'] : $dqq['hitcredit'], 'createtime' => TIMESTAMP);
     if (!empty($awardid)) {
         $sql = 'SELECT * FROM ' . tablename('dqq_award') . ' WHERE `rid` = :rid AND `id` = :id';
         $params = array(':rid' => $id, ':id' => $awardid);
         $gift = pdo_fetch($sql, $params);
         if ($gift['total'] > 0) {
             $data['award'] = $gift['title'];
             $credit1 = intval($gift['get_jf']);
             load()->model('mc');
             mc_credit_update($_W['member']['uid'], "credit1", $credit1, null);
             $data['description'] = $gift['title'];
             $result['message'] = '' . $data['award'] . '!';
             $result['status'] = 0;
             pdo_update('dqq_award', array('total' => --$gift['total']), array('id' => $gift['id']));
         } else {
             $credit['description'] = $dqq['misscredit'];
             $credit['award'] = '未中奖励积分';
         }
     }
     !empty($credit['description']) && ($result['message'] .= '<br />' . $credit['award'] . ':' . $credit['description']);
     $data['aid'] = $gift['id'];
     if (!empty($credit['description'])) {
         pdo_insert('dqq_winner', $credit);
     }
     pdo_insert('dqq_winner', $data);
     message($result, '', 'ajax');
 }
Example #15
0
 public function setOrderCredit($orderid, $add = true)
 {
     $order = pdo_fetch("SELECT * FROM " . tablename($this->table_order) . " WHERE id=:id LIMIT 1", array(':id' => $orderid));
     if (empty($order)) {
         return false;
     }
     $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename($this->table_order_goods) . " WHERE orderid = :orderid", array(':orderid' => $orderid));
     if (!empty($ordergoods)) {
         $credit = 0.0;
         $sql = 'SELECT `credit` FROM ' . tablename($this->table_goods) . ' WHERE `id` = :id';
         foreach ($ordergoods as $goods) {
             $goodsCredit = pdo_fetchcolumn($sql, array(':id' => $goods['goodsid']));
             $credit += $goodsCredit * floatval($goods['total']);
         }
     }
     //增加积分
     if (!empty($credit)) {
         load()->model('mc');
         load()->func('compat.biz');
         $uid = mc_openid2uid($order['from_user']);
         $fans = fans_search($uid, array("credit1"));
         if (!empty($fans)) {
             $uid = intval($fans['uid']);
             $remark = $add == true ? '微点餐积分奖励 订单ID:' . $orderid : '微点餐积分扣除 订单ID:' . $orderid;
             $log = array();
             $log[0] = $uid;
             $log[1] = $remark;
             mc_credit_update($uid, 'credit1', $credit, $log);
         }
     }
     return true;
 }
Example #16
0
 public function respond()
 {
     global $_W;
     load()->model('mc');
     $openid = $this->message['from'];
     $logs['openid'] = $openid;
     $logs['weid'] = $_W['uniacid'];
     $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']));
         }
     }
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('rule_keyword') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $sqls = "SELECT * FROM " . tablename($this->reply) . " WHERE `rid`=:rid LIMIT 1";
     $rows = pdo_fetch($sqls, array(':rid' => $rid));
     if (empty($rows['id'])) {
         return array();
     }
     if (empty($row['id'])) {
         return array();
     }
     $wd_code = $this->message['scancodeinfo']['scanresult'];
     $wd_qrcode = substr($wd_code, strpos($wd_code, "wd_code=") + 8);
     if ($this->message['event'] == 'scancode_waitmsg') {
         $qrtype = $this->message['scancodeinfo']['scantype'];
         $SecurityCode = $wd_qrcode;
     } else {
         $keywords = $wd_qrcode;
         preg_match('/' . $keywords . '(.*)/', $this->message['content'], $match);
         $SecurityCode = $match[1];
     }
     $logs['code'] = $SecurityCode;
     $sql = "SELECT * FROM " . tablename($this->data) . " WHERE code='{$SecurityCode}' LIMIT 1";
     $member = pdo_fetch($sql);
     $states = 0;
     if (!empty($member)) {
         if ($member['status'] == '0') {
             $states = 0;
         } elseif ($member['num'] >= $rows['tnumber']) {
             $set = pdo_update($this->data, array('status' => '0'), array('id' => $member['id']));
             $states = 0;
         } elseif ($member['stime'] <= TIME()) {
             $logs['status'] = '0';
             $reply = '您查询的防伪码已过期! ';
         } else {
             $data = array('num' => $member['num'] + 1);
             pdo_update($this->data, $data, array('id' => $member['id']));
             $states = 1;
         }
         if ($states == 0) {
             $reply = str_replace('[SecurityCode]', $SecurityCode, $rows['Failure']);
         } else {
             $number = $member['num'] + 1;
             $Factory = $member['factory'];
             $Effedate = date('Y-m-d', $member['stime']);
             $Products = $member['type'];
             $Brand = $member['brand'];
             $Spec = $member['spec'];
             $Weight = $member['weight'];
             $Remarks = $member['remarks'];
             $reply = str_replace('[number]', $number, $rows['Reply']);
             $reply = str_replace('[Factory]', $Factory, $reply);
             $reply = str_replace('[Brand]', $Brand, $reply);
             $reply = str_replace('[Spec]', $Spec, $reply);
             $reply = str_replace('[Weight]', $Weight, $reply);
             $reply = str_replace('[Remarks]', $Remarks, $reply);
             $reply = str_replace('[Effedate]', $Effedate, $reply);
             $reply = str_replace('[Products]', $Products, $reply);
             $reply = str_replace('[SecurityCode]', $SecurityCode, $reply);
             $reply = str_replace('[CreditName]', $member['creditname'], $reply);
             $reply = str_replace('[CreditNum]', $member['creditnum'], $reply);
             if ($member['creditstatus'] == '0') {
                 mc_credit_update($uid, 'credit1', $member['creditnum'], array('1', '防伪码自动增加积分,积分名称:' . $member['creditname']));
                 pdo_update($this->data, array('creditstatus' => '1'), array('id' => $member['id']));
             }
             $logs['status'] = '1';
         }
     } else {
         $logs['status'] = '0';
         $reply = '您查询的防伪码不存在,请核对后重试!';
     }
     $logs['createtime'] = time();
     pdo_insert('super_securitycode_logs', $logs);
     return $this->respText($reply);
 }
Example #17
0
        }
        $status = 0;
    }
}
if ($do == 'manage') {
    load()->model('mc');
    $clerk = pdo_get('activity_coupon_password', array('uniacid' => $_W['uniacid'], 'password' => trim($_GPC['password'])));
    if (empty($clerk)) {
        message('店员密码错误');
    }
    $uid = intval($_GPC['uid']);
    if ($uid) {
        foreach ($creditnames as $index => $creditname) {
            if (($_GPC[$index . '_type'] == 1 || $_GPC[$index . '_type'] == 2) && $_GPC[$index . '_value']) {
                $value = $_GPC[$index . '_type'] == 1 ? $_GPC[$index . '_value'] : -$_GPC[$index . '_value'];
                $return = mc_credit_update($uid, $index, $value, array($_W['uid'], trim($_GPC['remark']), 'system', $clerk['id'], $clerk['store_id']));
                if (is_error($return)) {
                    message($return['message']);
                }
                $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, $value, '管理员后台操作积分');
                    }
                    if ($index == 'credit2') {
                        if ($value > 0) {
                            mc_notice_recharge($openid, $uid, $value, '', "管理员后台操作余额,增加{$value}余额");
                        } else {
                            mc_notice_credit2($openid, $uid, $value, 0, "管理员后台操作余额,减少{$value}余额");
                        }
                    }
Example #18
0
 /**
 * 
 * @param $openid
 * @param $credit
 * 积分同步
 */
 public function synFanscredit($openid, $credit)
 {
     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');
         mc_credit_update($fans['uid'], "credit1", $credit);
     }
 }
Example #19
0
     }
     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';
         pdo_update('core_paylog', $record, array('plid' => $log['plid']));
         if ($log['is_usecard'] == 1 && $log['card_type'] == 1 && !empty($log['encrypt_code']) && $_W['acid']) {
             load()->classs('coupon');
             $acc = new coupon($_W['acid']);
             $codearr['encrypt_code'] = $log['encrypt_code'];
Example #20
0
 public function payResult($params)
 {
     global $_W, $_GPC;
     //$this->checkAuth();
     $weid = $_W['uniacid'];
     $uid = $_W['member']['uid'];
     $openid = $_W['openid'];
     if (empty($openid)) {
         $tsql = "SELECT openid FROM " . tablename('mc_mapping_fans') . " WHERE uid = :uid AND uniacid = :uniacid";
         $tparas = array(':uniacid' => $weid, ':uid' => $uid);
         $topenid = pdo_fetch($tsql, $tparas);
         $openid = $topenid['openid'];
     }
     $cfg = $this->module['config'];
     if (empty($openid)) {
         message('身份失效,请重新进入!');
     } else {
         $res = $this->getusers($weid, $openid);
     }
     $fee = intval($params['fee']);
     $data = array('status' => $params['result'] == 'success' ? 1 : 0);
     $paytype = array('credit' => '1', 'wechat' => '2', 'alipay' => '2', 'delivery' => '3');
     $data['paytype'] = $paytype[$params['type']];
     if ($params['type'] == 'wechat') {
         $data['transid'] = $params['tag']['transaction_id'];
     }
     if ($params['type'] == 'delivery') {
         $data['status'] = 1;
     }
     $data['fee'] = $fee;
     //已经兑换成RMB
     $data['openid'] = $openid;
     $data['time'] = time();
     $data['avatar'] = $res['avatar'];
     $data['weid'] = $weid;
     //也需将订单编号 插入数据库
     $data['tid'] = $params['tid'];
     $addcredit = $fee * $cfg['bilv'];
     if ($params['from'] == 'return') {
         if (!strexists($params['tid'], "||")) {
             pdo_insert('hnpayjifen', $data);
             load()->model('mc');
             mc_credit_update($uid, 'credit1', $addcredit, $log = array());
         } else {
             $data['starttime'] = time();
             $data['endtime'] = time() + 3600 * 720;
             pdo_insert('meepohn_baoyue', $data);
         }
         $setting = uni_setting($_W['uniacid'], array('creditbehaviors'));
         $credit = $setting['creditbehaviors']['currency'];
         if ($params['type'] == $credit) {
             message('支付成功!', $this->createMobileUrl('homecenter'), 'success');
         } else {
             message('支付成功!', '../../app/' . $this->createMobileUrl('homecenter'), 'success');
         }
     }
 }
        foreach ($list as &$li) {
            if (empty($li['email']) || !empty($li['email']) && substr($li['email'], -6) == 'wdlcms.com' && strlen($li['email']) == 39) {
                $li['email'] = '未完善';
            }
        }
        $status = 0;
    }
}
if ($do == 'manage') {
    load()->model('mc');
    $uid = intval($_GPC['uid']);
    if ($uid) {
        foreach ($creditnames as $index => $creditname) {
            if (($_GPC[$index . '_type'] == 1 || $_GPC[$index . '_type'] == 2) && $_GPC[$index . '_value']) {
                $value = $_GPC[$index . '_type'] == 1 ? $_GPC[$index . '_value'] : -$_GPC[$index . '_value'];
                $return = mc_credit_update($uid, $index, $value, array($_W['uid'], trim($_GPC['remark'])));
                if (is_error($return)) {
                    message($return['message']);
                }
            } else {
                continue;
            }
        }
        message('会员积分操作成功', url('mc/creditmanage/display'));
    } else {
        message('未找到指定用户', url('mc/creditmanage/display'), 'error');
    }
}
if ($do == 'modal') {
    if ($_W['isajax']) {
        $uid = intval($_GPC['uid']);
Example #22
0
 public function doWebDeleteprizedata()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $reply = pdo_fetch("select * from " . tablename('stonefish_bigwheel_reply') . " where rid = :rid and uniacid=:uniacid", array(':rid' => $rid, ':uniacid' => $_W['uniacid']));
     $exchange = pdo_fetch("select inventory,tickettype FROM " . tablename("stonefish_bigwheel_exchange") . " where rid = :rid", array(':rid' => $rid));
     if (empty($reply)) {
         echo json_encode(array('errno' => 1, 'error' => '抱歉,传递的参数错误!'));
         exit;
     }
     foreach ($_GPC['idArr'] as $k => $id) {
         $id = intval($id);
         if ($id == 0) {
             continue;
         }
         $fansaward = pdo_fetch("select prizeid,from_user,zhongjiang from " . tablename('stonefish_bigwheel_fansaward') . " where id = :id", array(':id' => $id));
         $from_user = $fansaward['from_user'];
         $fans = pdo_fetch("select * from " . tablename('stonefish_bigwheel_fans') . " where rid = :rid and  uniacid = :uniacid and  from_user = :from_user", array(':rid' => $rid, ':uniacid' => $_W['uniacid'], ':from_user' => $from_user));
         if (empty($fansaward)) {
             echo json_encode(array('errno' => 1, 'error' => '抱歉,选中的中奖数据不存在!'));
             exit;
         }
         $prize = pdo_fetch("select prizetype,prizevalue,prizedraw FROM " . tablename('stonefish_bigwheel_prize') . " where id = :id ORDER BY `id` DESC", array(':id' => $fansaward['prizeid']));
         //修改积分到粉丝数据库
         if ($prize['prizetype'] != 'physical' && $prize['prizetype'] != 'virtual' && $prize['prizetype'] != 'againprize' && $prize['prizetype'] != 'spaceprize') {
             load()->model('mc');
             $uid = pdo_fetchcolumn("select uid FROM " . tablename('mc_mapping_fans') . " where openid=:openid and uniacid=:uniacid", array(":openid" => $from_user, ":uniacid" => $_W['uniacid']));
             $unisetting_s = uni_setting($uniacid, array('creditnames'));
             foreach ($unisetting_s['creditnames'] as $key => $credit) {
                 if ($prize['prizetype'] == $key) {
                     $credit_names = $credit['title'];
                     break;
                 }
             }
             mc_credit_update($uid, $prize['prizetype'], -$prize['prizevalue'], array($_W['uid'], '抽抽卡取消中奖扣除' . $prize['prizevalue'] . '个' . $credit_names));
         }
         //修改积分到粉丝数据库
         if ($exchange['inventory'] == 1) {
             pdo_update('stonefish_bigwheel_prize', array('prizedraw' => $prize['prizedraw'] - 1), array('id' => $fansaward['prizeid']));
         } else {
             if ($fansaward['zhongjiang'] == 2) {
                 pdo_update('stonefish_bigwheel_prize', array('prizedraw' => $prize['prizedraw'] - 1), array('id' => $fansaward['prizeid']));
             }
         }
         //删除粉丝中奖记录
         pdo_update('stonefish_bigwheel_fansaward', array('zhongjiang' => 0, 'zhongjiangtime' => ''), array('id' => $id));
         //再来一次删除记录并减少次数
         if ($prize['prizetype'] == 'againprize') {
             pdo_delete('stonefish_bigwheel_fansaward', array('id' => $id));
             pdo_update('stonefish_bigwheel_fans', array('totalnum' => $fans['totalnum'] - 1, 'todaynum' => $fans['todaynum'] - 1), array('id' => $fans['id']));
         }
         //再来一次删除记录并减少次数
         //删除粉丝中奖记录
         //查询此用户是否还有中奖记录并更新状态
         $yes = pdo_fetch("select * FROM " . tablename('stonefish_bigwheel_fansaward') . " where from_user=:from_user and uniacid=:uniacid and rid=:rid and zhongjiang>=1", array(":from_user" => $from_user, ":uniacid" => $_W['uniacid'], ":rid" => $rid));
         if (empty($yes)) {
             pdo_update('stonefish_bigwheel_fans', array('zhongjiang' => 0), array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'from_user' => $from_user));
         }
         //查询此用户是否还有中奖记录并更新状态
     }
     echo json_encode(array('errno' => 0, 'error' => '选中的中奖数据删除成功!'));
     exit;
 }
Example #23
0
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;
}
Example #24
0
 public function setOrderCredit($orderid, $add = true)
 {
     global $_W;
     $order = pdo_fetch("SELECT * FROM " . tablename('shopping_order') . " WHERE id = :id limit 1", array(':id' => $orderid));
     if (empty($order)) {
         return false;
     }
     $sql = 'SELECT `goodsid`, `total` FROM ' . tablename('shopping_order_goods') . ' WHERE `orderid` = :orderid';
     $orderGoods = pdo_fetchall($sql, array(':orderid' => $orderid));
     if (!empty($orderGoods)) {
         $credit = 0.0;
         $sql = 'SELECT `credit` FROM ' . tablename('shopping_goods') . ' WHERE `id` = :id';
         foreach ($orderGoods as $goods) {
             $goodsCredit = pdo_fetchcolumn($sql, array(':id' => $goods['goodsid']));
             $credit += $goodsCredit * floatval($goods['total']);
         }
     }
     //增加积分
     if (!empty($credit)) {
         load()->model('mc');
         load()->func('compat.biz');
         $uid = mc_openid2uid($order['from_user']);
         $fans = fans_search($uid, array("credit1"));
         if (!empty($fans)) {
             if (!empty($add)) {
                 mc_credit_update($_W['member']['uid'], 'credit1', $credit, array('0' => $_W['member']['uid'], '购买商品赠送'));
             } else {
                 mc_credit_update($_W['member']['uid'], 'credit1', 0 - $credit, array('0' => $_W['member']['uid'], '微商城操作'));
             }
         }
     }
 }
Example #25
0
}
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';
    $type = 1;
    if ($_GPC['type'] == 'used') {
        $filter['used'] = '2';
        $type = 2;
    }
    $total = pdo_fetchall('SELECT COUNT(*) FROM ' . tablename('activity_coupon_record') . ' WHERE uid = :uid AND status = :status GROUP BY couponid', array(':uid' => $_W['member']['uid'], ':status' => $type));
    $coupon = activity_token_owned($_W['member']['uid'], $filter, $pindex, $psize);
    if (!empty($coupon['data'])) {
Example #26
0
             pdo_insert('nsign_prize', $prize);
             $unsetrecord = array('continue_sign_days' => $user_newcontinue_sign_days, 'first_sign_days' => $user_newfirst_sign_days, 'total_sign_num' => $user_newtotal_sign_num);
             pdo_update('nsign_record', $unsetrecord, array('uid' => $uid));
         }
         $tip4 = $credit . '个积分';
         $tip = '签到成功,获得' . $tip1 . $tip2 . $tip3 . $tip4;
     } else {
         $status = 0;
         $tip = '签到失败';
     }
 }
 if (0 < $today_usersigned_num && $today_usersigned_num < $times) {
     $insert = array('rid' => $rid, 'uid' => $uid, 'username' => $profile['realname'], 'today_rank' => $today_user_rank, 'sign_time' => $now, 'credit' => $credit);
     pdo_insert('nsign_record', $insert);
     //$givecredit['credit1'] = $credit + $profile['credit1'];
     mc_credit_update($uid, 'credit1', $credit);
     $total_sign_num = $user_allsign_num + 1;
     $maxtotal_sign_num = $user_maxallsign_num + 1;
     $update = array('last_sign_time' => $now, 'continue_sign_days' => $user_continue_sign_days, 'maxcontinue_sign_days' => $user_maxcontinue_sign_days, 'total_sign_num' => $total_sign_num, 'maxtotal_sign_num' => $maxtotal_sign_num, 'first_sign_days' => $user_first_sign_days, 'maxfirst_sign_days' => $user_maxfirst_sign_days);
     pdo_update('nsign_record', $update, array('uid' => $uid));
     $user_newsign_info = pdo_fetch("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid ORDER BY sign_time DESC LIMIT 1 ", array(':uid' => $uid));
     $user_newcontinue_sign_days = $user_newsign_info['continue_sign_days'];
     $user_newfirst_sign_days = $user_newsign_info['first_sign_days'];
     $user_newtotal_sign_num = $user_newsign_info['total_sign_num'];
     if ($user_newsign_info['id']) {
         $status = 1;
         if ($user_newtotal_sign_num == $tsignnum) {
             $tip = '获得累计签到奖励';
             $user_newtotal_sign_num = 0;
             $type = '累计签到奖';
         } else {
Example #27
0
function mc_handsel($touid, $fromuid, $handsel, $uniacid = '')
{
    global $_W;
    $touid = intval($touid);
    $fromuid = intval($fromuid);
    if (empty($uniacid)) {
        $uniacid = $_W['uniacid'];
    }
    $touid_exist = mc_fetch($touid, array('uniacid'));
    if (empty($touid_exist)) {
        return error(-1, '赠送积分用户不存在');
    }
    if (empty($handsel['module'])) {
        return error(-1, '没有填写模块名称');
    }
    if (empty($handsel['sign'])) {
        return error(-1, '没有填写赠送积分对象信息');
    }
    if (empty($handsel['action'])) {
        return error(-1, '没有填写赠送积分动作');
    }
    $credit_value = intval($handsel['credit_value']);
    $sql = 'SELECT id FROM ' . tablename('mc_handsel') . ' WHERE uniacid = :uniacid AND touid = :touid AND fromuid = :fromuid AND module = :module AND sign = :sign AND action = :action';
    $parm = array(':uniacid' => $uniacid, ':touid' => $touid, ':fromuid' => $fromuid, ':module' => $handsel['module'], ':sign' => $handsel['sign'], ':action' => $handsel['action']);
    $handsel_exists = pdo_fetch($sql, $parm);
    if (!empty($handsel_exists)) {
        return error(-1, '已经赠送过积分,每个用户只能赠送一次');
    }
    $creditbehaviors = pdo_fetchcolumn('SELECT creditbehaviors FROM ' . tablename('uni_settings') . ' WHERE uniacid = :uniacid', array(':uniacid' => $uniacid));
    $creditbehaviors = iunserializer($creditbehaviors) ? iunserializer($creditbehaviors) : array();
    if (empty($creditbehaviors['activity'])) {
        return error(-1, '公众号没有配置积分行为参数');
    } else {
        $credittype = $creditbehaviors['activity'];
    }
    $data = array('uniacid' => $uniacid, 'touid' => $touid, 'fromuid' => $fromuid, 'module' => $handsel['module'], 'sign' => $handsel['sign'], 'action' => $handsel['action'], 'credit_value' => $credit_value, 'createtime' => TIMESTAMP);
    pdo_insert('mc_handsel', $data);
    $log = array($fromuid, $handsel['credit_log']);
    mc_credit_update($touid, $credittype, $credit_value, $log);
    return true;
}
Example #28
0
             if ($discount_credit < 0) {
                 $discount_credit = 0;
             }
         }
     }
     if ($member['credit2'] < $discount_credit) {
         message('余额不足', referer(), 'error');
     }
     if ($card_setting['grant_rate'] > 0) {
         $credit1 = $discount_credit * $card_setting['grant_rate'];
         $log_credit1 = array($member['uid'], "使用会员卡消费【{$discount_credit}】元,消费返积分比率:【1:{$card_setting['grant_rate']}】,共赠送积分{$credit1}", 'card', $clerk['id']);
         mc_credit_update($member['uid'], 'credit1', $credit1, $log_credit1);
         $discount_str .= ",消费返积分比率:【1:{$card_setting['grant_rate']}】,共赠送积分{$credit1}";
     }
     $log_credit2 = array($member['uid'], "使用会员卡消费【{$credit}】元 {$discount_str},消费门店:{$store_str}", 'card', $clerk['id']);
     mc_credit_update($member['uid'], 'credit2', -$discount_credit, $log_credit2);
     mc_notice_credit2($card_member['openid'], $member['uid'], -$discount_credit, $credit1, $store_str);
     message("消费成功,共扣除余额{$discount_credit}元,赠送{$credit1}积分", url('clerk/check'), 'success');
 }
 if ($card_setting['discount_type'] != 0 && !empty($card_setting['discount'])) {
     $discount = $card_setting['discount'];
     if (!empty($discount[$member['groupid']])) {
         $tips = "该会员所在的会员组: {$_W['account']['groups'][$member['groupid']]['title']} ,可享受满 {$discount[$member['groupid']]['condition']} ";
         if ($card_setting['discount_type'] == 2) {
             $tips .= "打 {$discount[$member['groupid']]['discount']} 折";
         } else {
             $tips .= "减 {$discount[$member['groupid']]['discount']} 元";
         }
         $mine_discount = $discount[$member['groupid']];
     }
 }
Example #29
0
 public function doMobileCheckprize()
 {
     global $_W, $_GPC;
     if (empty($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) != "xmlhttprequest") {
         exit('非法访问');
     }
     load()->model('activity');
     $id = $_GPC['id'];
     $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE id = :id", array(':id' => $id));
     if (!empty($reply)) {
         if (empty($_W['fans']['from_user'])) {
             //防止错误提交的数据
             $errorCode = 10999;
         } else {
             $from_user = $_W['fans']['from_user'];
             $fans = pdo_fetch("SELECT fanid,uid FROM " . tablename('mc_mapping_fans') . " WHERE `openid`='{$from_user}' LIMIT 1");
             $uid = '0';
             if ($fans['uid'] != '0') {
                 $uid = $fans['uid'];
             } else {
                 $uid = mc_update($uid, array('email' => md5($from_user) . '@wdlcms.com'));
                 if (!empty($fans['fanid']) && !empty($uid)) {
                     pdo_update('mc_mapping_fans', array('uid' => $uid), array('fanid' => $fans['fanid']));
                 }
             }
             $profile = mc_fetch($uid);
             $awardnum = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename($this->table_award) . " WHERE reply_id = '{$id}' AND uid = '{$uid}'");
             $awardfans = pdo_fetch("SELECT * FROM " . tablename($this->table_fans) . " WHERE reply_id = '{$id}' AND uid = '{$uid}'");
             $t = mktime(0, 0, 0, date("m", time()), date("d", time()), date("y", time()));
             if (empty($awardfans)) {
                 $data1 = array('reply_id' => $id, 'from_user' => $from_user, 'uid' => $uid, 'todaynum' => '0', 'totalnum' => '0', 'awardnum' => '0', 'last_time' => time(), 'createtime' => time());
                 pdo_insert($this->table_fans, $data1);
             } elseif ($awardfans['last_time'] < $t) {
                 $data2 = array('todaynum' => '0', 'last_time' => time());
                 pdo_update($this->table_fans, $data2, array('id' => $awardfans['id']));
             }
             if (time() <= $reply['starttime'] || time() >= $reply['endtime'] || $reply['status'] == 0) {
                 $errorCode = 1;
             } elseif ($reply['status'] == 2) {
                 $errorCode = 1;
             } elseif ($reply['groupid'] != 0 && $reply['groupid'] != $profile['groupid']) {
                 $errorCode = 1;
             } elseif ($reply['need_num'] > $profile[$reply['need_type']]) {
                 $errorCode = 1;
             } elseif ($awardnum >= $reply['awardnum']) {
                 $errorCode = 1;
             } elseif ($awardfans['totalnum'] >= $reply['playnum']) {
                 $errorCode = 1;
             } elseif ($awardfans['todaynum'] >= $reply['dayplaynum']) {
                 $errorCode = 1;
             } else {
                 mc_credit_update($uid, $reply['need_type'], '-' . $reply['need_num'], array('1', '幸运大抽奖 消耗 ' . $this->getcreditname($reply['need_type']) . ':' . $reply['need_num']));
                 $data3 = array('todaynum' => $awardfans['todaynum'] + 1, 'totalnum' => $awardfans['totalnum'] + 1, 'last_time' => time());
                 pdo_update($this->table_fans, $data3, array('id' => $awardfans['id']));
                 /*中奖部分代码开始*/
                 $rate = $reply['rate'];
                 $prizes = iunserializer($reply['prizes']);
                 $p_num = $prizes['p1_num'] + $prizes['p2_num'] + $prizes['p3_num'] + $prizes['p4_num'];
                 empty($p_num) && ($p_num = 1);
                 $arr['p1'] = round(100 * $rate * $prizes['p1_num'] / $p_num);
                 $arr['p2'] = round(100 * $rate * $prizes['p2_num'] / $p_num);
                 $arr['p3'] = round(100 * $rate * $prizes['p3_num'] / $p_num);
                 $arr['p4'] = round(100 * $rate * $prizes['p4_num'] / $p_num);
                 $arr['p5'] = 10000 - $arr['p1'] - $arr['p2'] - $arr['p3'] - $arr['p4'];
                 if ($awardnum >= $p_num) {
                     $result = 'p5';
                 } else {
                     $result = $this->get_rand($arr);
                     //返回结果为键值p1,p2,p3,p4
                 }
                 /*中奖部分代码结束*/
                 if ($result == 'p5') {
                     if ($reply['give_num'] != 0) {
                         mc_credit_update($uid, $reply['give_type'], $reply['give_num'], array('1', '幸运大抽奖 未中奖赠送 ' . $this->getcreditname($reply['give_type']) . ':' . $reply['give_num']));
                     }
                 } else {
                     if ($reply['give_num'] != 0 && $reply['onlynone'] != 1) {
                         $give_point = $reply['give_num'];
                         $give_name = $this->getcreditname($reply['give_type']);
                         mc_credit_update($uid, $reply['give_type'], $reply['give_num'], array('1', '幸运大抽奖 未中奖赠送 ' . $this->getcreditname($reply['give_type']) . ':' . $reply['give_num']));
                     }
                     $errorCode = 0;
                     if ($result == 'p1') {
                         if ($prizes['p1_type'] != 2 && $prizes['p1_type'] != 3 && $prizes['p1_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p1_score'];
                             $point_name = $this->getcreditname($prizes['p1_type']);
                             mc_credit_update($uid, $prizes['p1_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p1_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p1_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p1_type']) . ':' . $point, 'prizetype' => $prizes['p1_type'], 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p1_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p1_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p1_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p1_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p1_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p1_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '1', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '1', 'detail_url' => $detail_url);
                     } elseif ($result == 'p2') {
                         if ($prizes['p2_type'] != 2 && $prizes['p2_type'] != 3 && $prizes['p2_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p2_score'];
                             $point_name = $this->getcreditname($prizes['p2_type']);
                             mc_credit_update($uid, $prizes['p2_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p2_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p2_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p2_type']) . ':' . $point, 'prizetype' => $prizes['p2_type'], 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p2_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p2_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p2_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p2_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p2_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p2_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '2', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '2', 'detail_url' => $detail_url);
                     } elseif ($result == 'p3') {
                         if ($prizes['p3_type'] != 2 && $prizes['p3_type'] != 3 && $prizes['p3_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p3_score'];
                             $point_name = $this->getcreditname($prizes['p3_type']);
                             mc_credit_update($uid, $prizes['p3_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p3_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p3_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p3_type']) . ':' . $point, 'prizetype' => $prizes['p3_type'], 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p3_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p3_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p3_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p3_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p3_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p3_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '3', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => $remsg, 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '3', 'detail_url' => $detail_url);
                     } elseif ($result == 'p4') {
                         if ($prizes['p4_type'] != 2 && $prizes['p4_type'] != 3 && $prizes['p4_type'] != 4) {
                             //积分类奖品
                             $point = $prizes['p4_score'];
                             $point_name = $this->getcreditname($prizes['p4_type']);
                             mc_credit_update($uid, $prizes['p4_type'], $point, array('1', '幸运大抽奖 中奖获得 ' . $this->getcreditname($prizes['p4_type']) . ':' . $point));
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=mc&a=bond&do=credits&credittype=' . $prizes['p4_type'];
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => $this->getcreditname($prizes['p4_type']) . ':' . $point, 'prizetype' => $prizes['p4_type'], 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                         } elseif ($prizes['p4_type'] == 2) {
                             //非积分类奖品:折扣券
                             $point = 0;
                             $couponid = $prizes['p4_score'];
                             $coupon = activity_coupon_info($couponid, $_W['uniacid']);
                             $ret = activity_coupon_grant($uid, $couponid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'];
                                 mc_credit_update($uid, $coupon['credittype'], $coupon['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($coupon['credittype']) . ':' . $coupon['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=coupon&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $coupon['title'], 'prizetype' => 'coupon', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '折扣券';
                             $type = '折扣券';
                             $value = 1;
                         } elseif ($prizes['p4_type'] == 3) {
                             //非积分类奖品:代金券
                             $point = 0;
                             $tokenid = $prizes['p4_score'];
                             $token = activity_token_info($tokenid, $_W['uniacid']);
                             $ret = activity_token_grant($uid, $tokenid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($token['credittype']) . ':' . $token['credit'];
                                 mc_credit_update($uid, $token['credittype'], $token['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($token['credittype']) . ':' . $token['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=token&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $token['title'], 'prizetype' => 'token', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '代金券';
                             $type = '代金券';
                             $value = 1;
                         } elseif ($prizes['p4_type'] == 4) {
                             //非积分类奖品:真实物品
                             $point = 0;
                             $goodsid = $prizes['p4_score'];
                             $goods = activity_exchange_info($goodsid, $_W['uniacid']);
                             $ret = activity_goods_grant($uid, $goodsid, 'hx_lottery', '幸运大转盘中奖获得');
                             if (is_error($ret)) {
                                 //领取错误做等值处理
                                 $remsg = ' 由于' . $ret['message'] . ' 奖品转换为等值' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'];
                                 mc_credit_update($uid, $goods['credittype'], $goods['credit'], array('1', '幸运大抽奖 等价 ' . $this->getcreditname($goods['credittype']) . ':' . $goods['credit'] . '原因:' . $ret['message']));
                             }
                             $detail_url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=activity&a=goods&do=mine';
                             $awarddata = array('reply_id' => $id, 'uid' => $uid, 'name' => '折扣券:' . $goods['title'], 'prizetype' => 'goods', 'level' => '4', 'createtime' => time(), 'consumetime' => time(), 'status' => 1);
                             $title = '真实物品券';
                             $type = '真实物品券';
                             $value = 1;
                         }
                         $award = array('title' => $title, 'value' => $value, 'type' => $type, 'remsg' => !empty($remsg) ? $remsg : ' ', 'point' => $point, 'point_name' => $point_name, 'give_point' => $give_point, 'give_name' => $give_name, 'level' => '4', 'detail_url' => $detail_url);
                     }
                     pdo_insert($this->table_award, $awarddata);
                     pdo_update($this->table_fans, array('awardnum' => $awardfans['awardnum'] + 1), array('id' => $awardfans['id']));
                 }
             }
         }
     }
     $data['code'] = $errorCode;
     $data['msg'] = $errorMsg;
     $data['data'] = $award;
     echo json_encode($data);
 }
Example #30
0
 public function setOrderCredit($orderid, $add = true)
 {
     $order = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_order') . " WHERE id=:id LIMIT 1", array(':id' => $orderid));
     if (empty($order)) {
         return false;
     }
     $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename($this->modulename . '_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid');
     if (!empty($ordergoods)) {
         $goods = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . '_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')");
     }
     //增加积分
     if (!empty($goods)) {
         $credits = 0;
         foreach ($goods as $g) {
             $credits += $g['credit'] * $g['total'];
         }
         load()->model('mc');
         load()->func('compat.biz');
         $uid = mc_openid2uid($order['from_user']);
         $fans = fans_search($uid, array("credit1"));
         if (!empty($fans)) {
             //                if ($add) {
             //                    $new_credit = $credits + $fans['credit1'];
             //                } else {
             //                    $new_credit = $fans['credit1'] - $credits;
             //                    if ($new_credit <= 0) {
             //                        $new_credit = 0;
             //                    }
             //                }
             $uid = intval($fans['uid']);
             $remark = $add == true ? '微点餐积分奖励 订单ID:' . $orderid : '微点餐积分扣除 订单ID:' . $orderid;
             $log = array();
             $log[0] = $uid;
             $log[1] = $remark;
             mc_credit_update($uid, 'credit1', $credits, $log);
             //pdo_update('mc_members', array("credit1" => $new_credit), array('uid' => $uid));
         }
     }
     return true;
 }