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}余额"); } } } } else { continue; } } message('会员积分操作成功', url('mc/creditmanage/display')); } else {
$id = intval($_GPC['id']); $coupon = activity_coupon_info($id, $_W['uniacid']); if (empty($coupon)) { message(error(-1, '没有指定的礼品兑换'), '', 'ajax'); } $credit = mc_credit_fetch($_W['member']['uid'], array($coupon['credittype'])); if ($credit[$coupon['credittype']] < $coupon['credit']) { message(error(-1, "您的 {$creditnames[$token['credittype']]} 数量不够,无法兑换."), '', 'ajax'); } $ret = activity_coupon_grant($_W['member']['uid'], $id, '', '用户使用' . $coupon['credit'] . $creditnames[$coupon['credittype']] . '兑换'); if (is_error($ret)) { message($ret, '', 'ajax'); } mc_credit_update($_W['member']['uid'], $coupon['credittype'], -1 * $coupon['credit'], array($_W['member']['uid'], '礼品兑换:' . $coupon['title'] . ' 消耗 ' . $creditnames[$coupon['credittype']] . ':' . $coupon['credit'])); if ($coupon['credittype'] == 'credit1') { mc_notice_credit1($_W['openid'], $_W['member']['uid'], -1 * $coupon['credit'], '兑换折扣券消耗积分'); } else { mc_notice_credit2($_W['openid'], $_W['member']['uid'], -1 * $coupon['credit'], 0, '线上消费,兑换折扣券'); } message(error(0, "兑换成功,您消费了 {$token['credit']} {$creditnames[$token['credittype']]}"), '', 'ajax'); } 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; }
$id = intval($_GPC['id']); $goods = activity_exchange_info($id, $_W['uniacid']); if (empty($goods)) { message(error(-1, '没有指定的礼品兑换'), '', 'ajax'); } $credit = mc_credit_fetch($_W['member']['uid'], array($goods['credittype'])); if ($credit[$goods['credittype']] < $goods['credit']) { message(error(-1, "您的 {$creditnames[$token['credittype']]} 数量不够,无法兑换."), '', 'ajax'); } $ret = activity_goods_grant($_W['member']['uid'], $id, 'system', '用户使用' . $goods['credit'] . $creditnames[$goods['credittype']] . '兑换'); if (is_error($ret)) { message($ret, '', 'ajax'); } mc_credit_update($_W['member']['uid'], $goods['credittype'], -1 * $goods['credit'], array($_W['member']['uid'], '礼品兑换:' . $goods['title'] . ' 消耗 ' . $creditnames[$goods['credittype']] . ':' . $goods['credit'])); if ($goods['credittype'] == 'credit1') { mc_notice_credit1($_W['openid'], $_W['member']['uid'], -1 * $goods['credit'], '兑换礼品消耗积分'); } else { mc_notice_credit2($_W['openid'], $_W['member']['uid'], -1 * $goods['credit'], 0, '线上消费,兑换礼品'); } message(error($ret, "兑换成功,您消费了 {$goods['credit']} {$creditnames[$goods['credittype']]},现在去完善订单信息"), '', 'ajax'); } if ($do == 'deliver') { load()->func('tpl'); $tid = intval($_GPC['tid']); $ship = pdo_fetch('SELECT * FROM ' . tablename('activity_exchange_trades_shipping') . ' WHERE uid = :uid AND tid = :tid', array(':uid' => $_W['member']['uid'], ':tid' => $tid)); if (empty($ship)) { message('没有找到该兑换的收货人信息', '', 'error'); } $member = mc_fetch($_W['member']['uid'], array('uid', 'realname', 'resideprovince', 'residecity', 'residedist', 'address', 'zipcode', 'mobile')); $ship['name'] = !empty($ship['name']) ? $ship['name'] : $member['realname']; $ship['province'] = !empty($ship['province']) ? $ship['province'] : $member['resideprovince'];
$names = array('credit1' => '积分', 'credit2' => '余额'); $credits = mc_credit_fetch($uid); if ($num < 0 && abs($num) > $credits[$type]) { exit("会员账户{$names[$type]}不够"); } $status = mc_credit_update($uid, $type, $num, array(0, trim($_GPC['remark']), 'system', $clerk['id'], $clerk['store_id'])); if (is_error($status)) { exit($status['message']); } if ($type == 'credit1') { mc_group_update($uid); } $openid = pdo_fetchcolumn('SELECT openid FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uid = :uid', array(':acid' => $_W['acid'], ':uid' => $uid)); if (!empty($openid)) { if ($type == 'credit1') { mc_notice_credit1($openid, $uid, $num, '管理员后台操作积分'); } if ($type == 'credit2') { if ($num > 0) { mc_notice_recharge($openid, $uid, $num, '', "管理员后台操作余额,增加{$value}余额"); } else { mc_notice_credit2($openid, $uid, $num, 0, '', '', "管理员后台操作余额,减少{$value}余额"); } } } exit('success'); } if ($do == 'card') { load()->model('card'); $card = card_setting(); if (empty($card)) {
$pager = pagination($total, $pindex, $psize); } if ($do == 'share') { if (!$_W['isajax']) { exit; } $set = card_credit_set(); if ($set['share']['times'] > 0 && $set['share']['num'] > 0) { $total = intval(pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_handsel') . ' WHERE uniacid = :uniacid AND touid = :touid AND module = :module AND action = :action AND createtime >= :createtime', array(':uniacid' => $_W['uniacid'], ':touid' => $_W['member']['uid'], ':module' => 'card', ':action' => 'share', ':createtime' => strtotime(date('Y-m-d'))))); if ($total < $set['share']['times']) { $data = array('uniacid' => $_W['uniacid'], 'touid' => $_W['member']['uid'], 'module' => 'card', 'action' => 'share', 'createtime' => TIMESTAMP, 'credit_value' => intval($set['share']['num'])); pdo_insert('mc_handsel', $data); if ($set['share']['num'] > 0) { $log = "用户分享会员卡的每日推荐页面,赠送【{$set['share']['num']}】积分"; mc_credit_update($_W['member']['uid'], 'credit1', $set['share']['num'], array(0, $log, 'card')); $status = mc_notice_credit1($_W['openid'], $_W['member']['uid'], $set['share']['num'], $log); if (is_error($status)) { exit($log); } } } else { exit("每天只会赠送{$set['share']['times']}次积分,明天再来吧"); } } else { exit('商家没有开始积分赠送'); } exit; } if ($do == 'notice') { $title = '系统消息-会员卡'; if ($_W['isajax']) {
$id = intval($_GPC['id']); $token = activity_token_info($id, $_W['uniacid']); if (empty($token)) { message(error(-1, '没有指定的礼品兑换'), '', 'ajax'); } $credit = mc_credit_fetch($_W['member']['uid'], array($token['credittype'])); if ($credit[$token['credittype']] < $token['credit']) { message(error(-1, "您的 {$creditnames[$token['credittype']]} 数量不够,无法兑换."), '', 'ajax'); } $ret = activity_token_grant($_W['member']['uid'], $id, '', '用户使用' . $token['credit'] . $creditnames[$token['credittype']] . '兑换'); if (is_error($ret)) { message($ret, '', 'ajax'); } mc_credit_update($_W['member']['uid'], $token['credittype'], -1 * $token['credit'], array($_W['member']['uid'], '礼品兑换:' . $token['title'] . ' 消耗 ' . $creditnames[$token['credittype']] . ':' . $token['credit'])); if ($token['credittype'] == 'credit1') { mc_notice_credit1($_W['openid'], $_W['member']['uid'], -1 * $token['credit'], '兑换代金券消耗积分'); } else { mc_notice_credit2($_W['openid'], $_W['member']['uid'], -1 * $token['credit'], 0, '线上消费,兑换代金券'); } message(error(0, "兑换成功,您消费了 {$token['credit']} {$creditnames[$token['credittype']]}"), '', 'ajax'); } 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; }