Example #1
0
    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 {
        message('未找到指定用户', url('mc/creditmanage/display'), 'error');
    }
}
if ($do == 'modal') {
Example #2
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');
         }
     }
 }