public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         $order_id = intval($_REQUEST['id']);
         $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where order_status = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . " and id = " . $order_id);
         if (!$order_info) {
             $root['info'] = '无效的订单';
         } else {
             $money = $order_info['credit_pay'];
             $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_order where id = " . $order_id . " and user_id = " . intval($GLOBALS['user_info']['id']) . " and order_status = 0");
             if ($GLOBALS['db']->affected_rows() > 0) {
                 if ($money > 0) {
                     require_once APP_ROOT_PATH . "system/libs/user.php";
                     modify_account(array("money" => $money), intval($GLOBALS['user_info']['id']), "删除" . $order_info['deal_name'] . "项目支付,退回支付款。");
                 }
             }
             $root['response_code'] = 1;
             $root['info'] = '删除成功';
         }
     } else {
         $root['response_code'] = 0;
         $root['show_err'] = "未登录";
         $root['user_login_status'] = 0;
     }
     output($root);
 }
 public function cash_save()
 {
     $data['integral'] = intval($_REQUEST['integral']);
     $data['user_id'] = $GLOBALS['user_info']['id'];
     require APP_ROOT_PATH . 'system/libs/user.php';
     $userinfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "user WHERE id='" . $GLOBALS['user_info']['id'] . "' ");
     if ($userinfo['vip_id'] == 0) {
         showErr("您还不是VIP会员,不可兑换积分!", 0);
     }
     if ($data['integral'] == 0 || $data['integral'] == "") {
         showErr("请输入正确的兑换积分!", 0);
     }
     if ($data['integral'] > $userinfo['score']) {
         showErr("该积分超过了用户积分", 0);
     } else {
         if ($data['integral'] % 1000 != 0) {
             showErr("该积分不是1000的倍数积分", 0);
         } else {
             $vininfo = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "vip_setting WHERE vip_id='" . $userinfo['vip_id'] . "' ");
             $excmoney = $data['integral'] * $vininfo['coefficient'] / 100;
             modify_account(array('money' => $excmoney, 'nmc_amount' => $excmoney, 'score' => -$data['integral']), $GLOBALS['user_info']['id'], '积分兑现', 22);
         }
     }
     $data['vip_id'] = $userinfo['vip_id'];
     $data['exchange_date'] = to_date(TIME_UTC, "Y-m-d");
     $data['cash'] = $excmoney;
     $GLOBALS['db']->autoExecute(DB_PREFIX . "score_exchange_record", $data, "INSERT");
     if ($GLOBALS['db']->affected_rows()) {
         showSuccess("兑现成功", 0);
     } else {
         showErr("兑现失败", 0);
     }
 }
Пример #3
0
/**
 * 付款单的支付
 * @param unknown_type $payment_notice_id
 * 当超额付款时在此进行退款处理
 */
function payment_paid($payment_notice_id, $outer_notice_sn = '')
{
    $payment_notice_id = intval($payment_notice_id);
    $now = TIME_UTC;
    $GLOBALS['db']->query("update " . DB_PREFIX . "payment_notice set pay_time = " . $now . ", pay_date = '" . to_date($now, 'Y-m-d') . "',outer_notice_sn = '" . $outer_notice_sn . "',is_paid = 1 where id = " . $payment_notice_id . " and is_paid = 0");
    $rs = $GLOBALS['db']->affected_rows();
    if ($rs) {
        $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
        $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_notice['payment_id']);
        $GLOBALS['db']->query("update " . DB_PREFIX . "payment set total_amount = total_amount + " . $payment_notice['money'] . " where class_name = '" . $payment_info['class_name'] . "'");
        if (intval($payment_notice['order_id']) == 0) {
            //充值
            require_once APP_ROOT_PATH . "system/libs/user.php";
            if ($payment_info['online_pay'] == 0) {
                $msg = '线下充值';
                // sprintf($GLOBALS['lang']['PAYMENT_INCHARGE'],$payment_notice['notice_sn']);
            } else {
                $msg = '在线充值';
                // sprintf($GLOBALS['lang']['PAYMENT_INCHARGE'],$payment_notice['notice_sn']);
            }
            $fee_amount = $payment_notice['fee_amount'];
            $money = $payment_notice['money'];
            modify_account(array('money' => $money - $fee_amount, 'fee_amount' => $fee_amount, 'score' => 0), $payment_notice['user_id'], $msg, 1);
            //在此处开始生成付款的短信及邮件
            send_payment_sms($payment_notice_id);
            send_payment_mail($payment_notice_id);
        }
    }
    return $rs;
}
Пример #4
0
/**
 * 付款单的支付
 * @param unknown_type $payment_notice_id
 * 当超额付款时在此进行退款处理
 */
function payment_paid($payment_notice_id, $outer_notice_sn = '')
{
    $payment_notice_id = intval($payment_notice_id);
    $now = TIME_UTC;
    $GLOBALS['db']->query("update " . DB_PREFIX . "payment_notice set pay_time = " . $now . ", pay_date = " . to_date($now, 'Y-m-d') . ",outer_notice_sn = '" . $outer_notice_sn . "',is_paid = 1 where id = " . $payment_notice_id . " and is_paid = 0");
    $rs = $GLOBALS['db']->affected_rows();
    if ($rs) {
        $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
        $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $payment_notice['payment_id']);
        $GLOBALS['db']->query("update " . DB_PREFIX . "payment set total_amount = total_amount + " . $payment_notice['money'] . " where class_name = '" . $payment_info['class_name'] . "'");
        //if (intval($payment_notice['order_id']) == 0){
        //充值
        require_once APP_ROOT_PATH . "system/libs/user.php";
        $msg = sprintf($GLOBALS['lang']['PAYMENT_INCHARGE'], $payment_notice['notice_sn']);
        modify_account(array('money' => $payment_notice['money'], 'score' => 0), $payment_notice['user_id'], $msg, 1);
        // 充值奖励
        if ($payment_notice['money'] > intval(app_conf("USER_RECHARGE_LIMIT_MONEY"))) {
            $award = $payment_notice['money'] * floatval(app_conf("USER_RECHARGE_PERCENT")) * 0.01;
            modify_account(array('money' => $award, 'score' => 0), $payment_notice['user_id'], "充值奖励", 1);
        }
        //在此处开始生成付款的短信及邮件
        send_payment_sms($payment_notice_id);
        send_payment_mail($payment_notice_id);
        //}
    }
    return $rs;
}
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     $page = intval($GLOBALS['request']['page']);
     $dltid = intval($GLOBALS['request']['dltid']);
     $status = intval($GLOBALS['request']['status']);
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     if ($user_id > 0) {
         require APP_ROOT_PATH . 'app/Lib/uc_func.php';
         require APP_ROOT_PATH . 'system/libs/user.php';
         $root['user_login_status'] = 1;
         $root['response_code'] = 1;
         $nmc_amount = $GLOBALS['db']->getOne("SELECT nmc_amount FROM " . DB_PREFIX . "user where id = " . intval($GLOBALS['user_info']['id']));
         if ($status == 0) {
             $GLOBALS['db']->query("UPDATE " . DB_PREFIX . "user_carry SET status=4 where id=" . $dltid . " and status=0  and user_id = " . intval($GLOBALS['user_info']['id']));
             if ($GLOBALS['db']->affected_rows()) {
                 $data = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "user_carry where id=" . $dltid . " and status=4 and user_id = " . intval($GLOBALS['user_info']['id']));
                 modify_account(array('money' => $data['money'], 'lock_money' => -$data['money']), $data['user_id'], "撤销提现,提现金额", 8);
                 modify_account(array('money' => $data['fee'], 'lock_money' => -$data['fee']), $data['user_id'], "撤销提现,提现手续费", 9);
                 $root['show_err'] = "撤销操作成功";
             } else {
                 $root['show_err'] = "撤销操作失败";
             }
             output($root);
         } elseif ($status == 4) {
             $data = $GLOBALS['db']->getRow("SELECT user_id,money,fee FROM " . DB_PREFIX . "user_carry where id=" . $dltid . " and status=4 and user_id = " . intval($GLOBALS['user_info']['id']));
             if ((double) $data['money'] + (double) $data['fee'] + (double) $GLOBALS['user_info']['nmc_amount'] > (double) $GLOBALS['user_info']['money']) {
                 $root['show_err'] = "继续申请提现失败,金额不足";
             }
             $sql = "UPDATE " . DB_PREFIX . "user_carry SET status=0 where id=" . $dltid . " and (money + fee + {$nmc_amount}) <= " . (double) $GLOBALS['user_info']['money'] . " and status=4 and user_id = " . intval($GLOBALS['user_info']['id']) . "  ";
             $root['sql'] = $sql;
             $GLOBALS['db']->query($sql);
             if ($GLOBALS['db']->affected_rows()) {
                 modify_account(array('money' => -$data['money'], 'lock_money' => $data['money']), $data['user_id'], "提现申请", 8);
                 modify_account(array('money' => -$data['fee'], 'lock_money' => $data['fee']), $data['user_id'], "提现手续费", 9);
                 $root['show_err'] = "继续申请提现成功";
             } else {
                 $root['show_err'] = "继续申请提现失败";
             }
             output($root);
         } else {
             $root['show_err'] = "操作失败";
             output($root);
         }
     } else {
         $root['response_code'] = 0;
         $root['show_err'] = "未登录";
         $root['user_login_status'] = 0;
     }
     $root['program_title'] = "提现操作";
     output($root);
 }
Пример #6
0
 public function get_payment_code($payment_notice_id)
 {
     $rs = payment_paid($payment_notice_id);
     if ($rs) {
         $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
         $order_sn = $GLOBALS['db']->getOne("select order_sn from " . DB_PREFIX . "deal_order where id = " . $payment_notice['order_id']);
         require_once APP_ROOT_PATH . "system/model/user.php";
         $msg = sprintf('%s订单付款,付款单号%s', $order_sn, $payment_notice['notice_sn']);
         modify_account(array('money' => "-" . $payment_notice['money'], 'score' => 0), $payment_notice['user_id'], $msg);
     }
 }
Пример #7
0
 public function index()
 {
     require_once APP_ROOT_PATH . "system/libs/user.php";
     //print_r($email);echo"<br />";print_r($pwd);exit;
     //检查用户,用户密码
     $user_return = $GLOBALS['user_info'];
     $user = $user_return;
     $user_id = intval($user['id']);
     //print_r($user_id);exit;
     $uname = strim($GLOBALS['request']['uname']);
     if ($user_id == 0) {
         $root['status'] = 0;
         $root['info'] = "请先登录";
         $root['user_login_status'] = 0;
         //用户登陆状态:1:成功登陆;0:未成功登陆
         output($root);
     } else {
         $ecvtype_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "ecv_type where uname= '" . $uname . "'");
         if (!$ecvtype_info) {
             $root['status'] = 0;
             $root['info'] = "代金券不存在";
             output($root);
         }
         $id = intval($ecvtype_info['id']);
         $is_use = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "ecv where ecv_type_id=" . $id . " and user_id=" . $user_id);
         if ($is_use > 0) {
             $root['status'] = 0;
             $root['info'] = "您已经领取过了";
             output($root);
         }
         if ($ecvtype_info['end_time'] > 0 && $ecvtype_info['end_time'] < get_gmtime()) {
             $root['status'] = 0;
             $root['info'] = "代金券已过期";
             output($root);
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "ecv set user_id = " . $user_id . " where user_id = 0 and ecv_type_id = " . $id . " limit 1");
         if ($GLOBALS['db']->affected_rows() > 0) {
             $root['status'] = 1;
             $root['info'] = "您已成功领取红包" . round($ecvtype_info['money'], 2) . "元";
             $root['id'] = $id;
             modify_account(array('money' => round($ecvtype_info['money'], 2)), $user_id, "成功领取红包" . round($ecvtype_info['money'], 2) . "元");
         } else {
             $root['status'] = 0;
             $root['info'] = "剩余数量不足";
             output($root);
         }
     }
     output($root);
 }
 public function delete_order()
 {
     $id = intval($_REQUEST['id']);
     $total_score = intval($_REQUEST['total_score']);
     $count_sql = "SELECT count(*) from " . DB_PREFIX . "goods_order where id=" . $id . " and order_status =0  and user_id=" . $GLOBALS['user_info']['id'];
     $order_count = $GLOBALS['db']->getOne($count_sql);
     if (!$order_count) {
         showErr('订单取消失败', 0, url("index", "uc_goods_order"));
     }
     require_once APP_ROOT_PATH . "system/libs/user.php";
     modify_account(array('score' => $total_score), $GLOBALS['user_info']['id'], "用户取消订单积分返还", 22);
     $GLOBALS['db']->query("update " . DB_PREFIX . "goods_order set order_status = 3 where id = " . $id);
     if ($GLOBALS['db']->affected_rows() == 0) {
         showErr('订单取消失败', 0, url("index", "uc_goods_order"));
     } else {
         showSuccess('订单取消成功', 0, url("index", "uc_goods_order"));
     }
 }
 public function edit_dsffreezer()
 {
     $id = intval($_REQUEST['id']);
     $now = get_gmtime();
     $dsffreezer = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "money_freeze where id = " . $id);
     $deal_name = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $dsffreezer['deal_id']);
     $user_xinxi = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $dsffreezer['platformUserNo']);
     $log_info = $user_xinxi['name'];
     $GLOBALS['db']->query("update " . DB_PREFIX . "money_freeze set status=2,create_time ={$now} where id=" . $id);
     require_once APP_ROOT_PATH . "system/libs/user.php";
     if ($GLOBALS['db']->affected_rows()) {
         modify_account(array('money' => $dsffreezer['amount']), $dsffreezer['platformUserNo'], '冻结资金解冻-冻结号码:' . $id);
     }
     syn_mortgate($dsffreezer['platformUserNo']);
     //$GLOBALS['db']->query("update ".DB_PREFIX."user set money=$money,score=$score,point=$point where id=".$dsffreezer['platformUserNo']);
     //save_log($log_info.L("INSERT_SUCCESS"),1);
     $this->success(L("INSERT_SUCCESS"));
 }
Пример #10
0
 public function refund()
 {
     $id = intval($_REQUEST['id']);
     $order_info = M("DealOrder")->getById($id);
     if ($order_info) {
         if ($order_info['is_refund'] == 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set is_refund = 1 where id = " . $id . " and is_refund = 0");
             if ($GLOBALS['db']->affected_rows() > 0) {
                 require_once APP_ROOT_PATH . "system/libs/user.php";
                 modify_account(array("money" => $order_info['total_price']), $order_info['user_id'], $order_info['deal_name'] . "退款");
             }
             $this->success("成功退款到会员余额");
         } else {
             $this->error("已经退款");
         }
     } else {
         $this->error("没有该项目的支持");
     }
 }
 public function confirm()
 {
     $id = intval($_REQUEST['id']);
     $refund_data = M("UserRefund")->getById($id);
     if ($refund_data) {
         if ($refund_data['is_pay'] == 1) {
             $this->error("已经提现过");
         }
         $refund_user = M("User")->where("id=" . $refund_data['user_id'] . " and is_effect = 1")->find();
         if ($refund_user['money'] < $refund_data['money']) {
             $this->error("会员余额不足,不能提现");
         }
         $reply = strim($_REQUEST['reply']);
         require_once APP_ROOT_PATH . "system/libs/user.php";
         modify_account(array("money" => "-" . $refund_data['money']), $refund_data['user_id'], "管理员确认提现:" . $reply);
         $refund_data['reply'] = $reply;
         $refund_data['is_pay'] = 1;
         $refund_data['pay_time'] = get_gmtime();
         M("UserRefund")->save($refund_data);
         $this->success("提现确认成功");
     } else {
         $this->error("没有提现数据");
     }
 }
Пример #12
0
 public function doexchange()
 {
     if ($this->allow_exchange) {
         $user_pwd = md5(addslashes(trim($_REQUEST['password'])));
         $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($GLOBALS['user_info']['id']));
         if ($user_info['user_pwd'] == "") {
             //判断是否为初次整合
             //载入会员整合
             $integrate_code = trim(app_conf("INTEGRATE_CODE"));
             if ($integrate_code != '') {
                 $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php";
                 if (file_exists($integrate_file)) {
                     require_once $integrate_file;
                     $integrate_class = $integrate_code . "_integrate";
                     $integrate_obj = new $integrate_class();
                 }
             }
             if ($integrate_obj) {
                 $result = $integrate_obj->login($user_info['user_name'], $user_pwd);
                 if ($result['status']) {
                     $GLOBALS['db']->query("update " . DB_PREFIX . "user set user_pwd = '" . $user_pwd . "' where id = " . $user_info['id']);
                     $user_info['user_pwd'] = $user_pwd;
                 }
             }
         }
         if ($user_info['user_pwd'] == $user_pwd) {
             $cfg = $this->creditsettings[addslashes(trim($_REQUEST['key']))];
             if ($cfg) {
                 $amount = floor($_REQUEST['amountdesc']);
                 $use_amount = floor($amount * $cfg['ratio']);
                 //消耗的本系统积分
                 $field = $this->credits_CFG[$cfg['creditsrc']]['field'];
                 if ($user_info[$field] < $use_amount) {
                     $data = array("status" => false, "message" => $cfg['srctitle'] . "不足,不能兑换");
                     ajax_return($data);
                 }
                 include_once APP_ROOT_PATH . 'uc_client/client.php';
                 $res = call_user_func_array("uc_credit_exchange_request", array($user_info['integrate_id'], $cfg['creditsrc'], $cfg['creditdesc'], $cfg['appiddesc'], $amount));
                 if ($res) {
                     //兑换成功
                     $use_amount = 0 - $use_amount;
                     $credit_data = array($field => $use_amount);
                     require_once APP_ROOT_PATH . "system/libs/user.php";
                     modify_account($credit_data, $user_info['id'], "ucenter兑换支出");
                     $data = array("status" => true, "message" => "兑换成功");
                     ajax_return($data);
                 } else {
                     $data = array("status" => false, "message" => "兑换失败");
                     ajax_return($data);
                 }
             } else {
                 $data = array("status" => false, "message" => "非法的兑换请求");
                 ajax_return($data);
             }
         } else {
             $data = array("status" => false, "message" => "登录密码不正确");
             ajax_return($data);
         }
     } else {
         $data = array("status" => false, "message" => "未开启兑换功能");
         ajax_return($data);
     }
 }
Пример #13
0
function deal_redempte($redempte_id, $status, $earn_money, $fee = 0, $organiser_fee = 0, $pay_type = 0, $web_type = 0)
{
    require_once APP_ROOT_PATH . 'system/libs/user.php';
    $info = array('status' => 1, 'info' => '');
    $licai = array();
    if ($web_type == 1 || $web_type == 2) {
        $redempte = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "licai_redempte where id={$redempte_id}");
        if ($redempte['status'] == 0) {
            if ($status == 1) {
                //审核通过
                if (true) {
                    //最终的金额
                    $money = $redempte['money'] + $organiser_fee + $earn_money;
                    $order = $GLOBALS['db']->getRow("select dorder.money,dorder.site_buy_fee,dorder.redempte_money,dorder.user_id as consumer_id,d.user_id as organiser_id,d.name as licai_name,d.id as licai_id,d.service_fee_rate from " . DB_PREFIX . "licai_order as dorder left join " . DB_PREFIX . "licai as d on dorder.licai_id=d.id  where dorder.id=" . $redempte['order_id']);
                    if ($redempte['money'] > $order['money'] - $order['redempte_money']) {
                        $info['status'] = 0;
                        $info['info'] = '您赎回的金额超过了您购买的金额(您的购买金额是' . $order['money'] . ',已赎回' . $order['redempte_money'] . ")";
                        return $info;
                    }
                    /*if($order['service_fee_rate']>0){
                    			$organiser_fee=$redempte['money']*$order['service_fee_rate'];
                    		}else{
                    			$organiser_fee=0;
                    		}*/
                    //$money=$redempte['money']+$organiser_fee+$earn_money;
                    $licai['url'] = url("licai#deal", array("id" => $order['licai_id']));
                    $licai['name'] = $order['licai_name'];
                    //对发起人进行扣款操作,有冻结金额mortgage_money 先用冻结金额,没有再用余额money,如果余额也不够,就生成垫付单
                    if ($order['consumer_id'] && $order['organiser_id']) {
                        //$organiser_user=$GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id=".$order['organiser_id']);
                        require_once APP_ROOT_PATH . 'system/libs/user.php';
                        $organiser_user = get_user_info("*", "id = " . $order['organiser_id']);
                        if ($organiser_user['money'] >= $money) {
                            //modify_account(array('money'=>'-'.$money,'ben_money'=>'-'.$redempte['money'],'earn_money'=>'-'.$earn_money,'organiser_fee'=>'-'.$organiser_fee),$order['organiser_id'],"发放用户要赎回的理财产品“<a href=\"".$licai['url']."\">".$licai['name']."</a>”",39);
                            //赎回本金
                            modify_account(array('money' => '-' . $redempte['money']), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 39);
                            //收益
                            modify_account(array('money' => '-' . $earn_money), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 40);
                            //平台手续费
                            modify_account(array('money' => '-' . $organiser_fee), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 45);
                            //if(!$re){
                            /*	$info['status']=0;
                            				$info['info']='资金修改错误';
                            				return $info;
                            			*/
                            //}
                        } elseif ($organiser_user['mortgage_money'] >= $money) {
                            //赎回本金
                            modify_account(array('money' => '-' . $redempte['money']), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 39);
                            //赎回手续费
                            modify_account(array('money' => '-' . $earn_money), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 40);
                            //赎回平台手续费
                            modify_account(array('money' => '-' . $organiser_fee), $order['organiser_id'], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 45);
                            //if(!$re){
                            /*	$info['status']=0;
                            			$info['info']='资金修改错误';
                            			return $info;*/
                            //}
                        } elseif ($organiser_user['money'] + $organiser_user['mortgage_money'] >= $money) {
                            $ye_money = $money - $organiser_user['mortgage_money'];
                            //赎回本金
                            modify_account(array('money' => '-' . $redempte['money']), $order["organiser_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 39);
                            //赎回收益
                            modify_account(array('money' => '-' . $earn_money), $order["organiser_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 40);
                            //平台手续费
                            modify_account(array('money' => '-' . $organiser_fee), $order["organiser_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 45);
                            //if(!$re){
                            /*	$info['status']=0;
                            			$info['info']='资金修改错误';
                            			return $info;*/
                            //}
                        } else {
                            if ($pay_type == 1) {
                                //生成垫付单
                                $re = $GLOBALS['db']->getRow("select * from  " . DB_PREFIX . "licai_advance where  redempte_id=" . $redempte_id);
                                if ($re) {
                                    $info['status'] = 0;
                                    $info['info'] = '发起人已经生成垫付单';
                                    return $info;
                                } else {
                                    $advance['redempte_id'] = $redempte_id;
                                    $advance['user_id'] = $organiser_user['id'];
                                    $advance['user_name'] = $organiser_user['user_name'];
                                    $advance['money'] = $redempte['money'];
                                    $advance['earn_money'] = $earn_money;
                                    $advance['fee'] = $fee;
                                    $advance['organiser_fee'] = $organiser_fee;
                                    $advance['real_money'] = $organiser_user['money'] + $organiser_user['mortgage_money'];
                                    $advance['advance_money'] = $redempte['money'] + $advance['earn_money'] + $advance['organiser_fee'] - $advance['real_money'];
                                    $advance['status'] = 1;
                                    $advance['type'] = $redempte['type'];
                                    $advance['create_date'] = to_date(NOW_TIME);
                                    $advance['update_date'] = to_date(NOW_TIME);
                                    $re = $GLOBALS['db']->autoExecute(DB_PREFIX . "licai_advance", $advance);
                                    if (!$re) {
                                        $info['status'] = 0;
                                        $info['info'] = '发起人生成垫付单错误';
                                        return $info;
                                    } else {
                                        //赎回本金
                                        modify_account(array('money' => '-' . $redempte['money']), $advance["user_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 39);
                                        //赎回收益
                                        modify_account(array('money' => '-' . $earn_money), $advance["user_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 40);
                                        //赎回平台手续费
                                        modify_account(array('money' => '-' . $organiser_fee), $advance["user_id"], "发放用户要赎回的理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 45);
                                    }
                                }
                            } else {
                                $info['status'] = 2;
                                if ($web_type == 1) {
                                    $info['info'] = '用户账户资金不足,是否要帮用户垫付';
                                } elseif ($web_type == 2) {
                                    $info['info'] = '您的账户资金不足,请充值';
                                }
                                return $info;
                            }
                        }
                        //修改赎回状态
                        $re = $GLOBALS['db']->query("update  " . DB_PREFIX . "licai_redempte set status={$status},earn_money=" . $earn_money . ",fee=" . $fee . ",update_date = '" . to_date(NOW_TIME, "Y-m-d H:i:s") . "' where id={$redempte_id}  ");
                        //修改订单状态
                        if ($redempte['money'] < $order['money'] - $order["site_buy_fee"] - $order['redempte_money']) {
                            //部分赎回
                            $set = " ,status=2 ";
                        } else {
                            //全部赎回
                            $set = " ,status=3 ";
                            $over = 1;
                        }
                        $re = $GLOBALS['db']->query("update  " . DB_PREFIX . "licai_order set redempte_money=redempte_money+" . $redempte['money'] . $set . " ,status_time = '" . to_date(NOW_TIME, "Y-m-d H:i:s") . "' where id=" . $redempte['order_id']);
                        //为投资人 进行金额的增加
                        $comuse_money = $redempte['money'] + $earn_money - $fee;
                        //赎回本金
                        modify_account(array('money' => $redempte['money']), $order['consumer_id'], "赎回理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 39);
                        //赎回收益
                        modify_account(array('money' => $earn_money), $order['consumer_id'], "赎回理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 40);
                        //赎回手续费
                        modify_account(array('money' => '-' . $fee), $order['consumer_id'], "赎回理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 41);
                        if ($over == 1) {
                            $GLOBALS["db"]->query("update  " . DB_PREFIX . "licai_redempte set status=2,update_date = '" . to_date(NOW_TIME, "Y-m-d H:i:s") . "' where order_id = " . $redempte['order_id'] . " and status = 0 and user_id =" . $order["consumer_id"]);
                        }
                        /* if(!$re){
                         			$info['status']=0;
                        			$info['info']='用户收款错误';
                        			return $info;
                         		 }*/
                    } else {
                        $info['status'] = 0;
                        $info['info'] = '操作失败,请重新提交';
                        return $info;
                    }
                } else {
                    $info['status'] = 0;
                    $info['info'] = '操作失败,请重新撤销';
                    return $info;
                }
            } elseif ($status == 2) {
                //审核不通过
                $re = $GLOBALS['db']->query("update  " . DB_PREFIX . "licai_redempte set status={$status} where id={$redempte_id}  ");
                if ($re) {
                    $info['info'] = '操作成功';
                    return $info;
                } else {
                    $info['status'] = 0;
                    $info['info'] = '操作失败,请重新撤销';
                    return $info;
                }
            }
        }
    } elseif ($web_type == 0) {
        $user_id = $GLOBALS['user_info']['id'];
        if (!$user_id) {
            $info['status'] = 0;
            $info['info'] = '请登录';
            return $info;
        }
        if ($status == 3) {
            $redempte = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "licai_redempte where id={$redempte_id}");
            if ($redempte['user_id'] == $user_id) {
                $re = $GLOBALS['db']->query("update  " . DB_PREFIX . "licai_redempte set status={$status} where id={$redempte_id} and user_id={$user_id} ");
                if ($re) {
                    $info['info'] = '操作成功';
                    return $info;
                } else {
                    $info['status'] = 0;
                    $info['info'] = '操作失败,请重新撤销';
                    return $info;
                }
            } else {
                $info['status'] = 0;
                $info['info'] = '您没有权限撤销';
                return $info;
            }
        }
    }
    return $info;
}
Пример #14
0
 public function index()
 {
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     $root = array();
     if ($user_id > 0) {
         $order_id = intval($GLOBALS['request']['order_id']);
         $credit = doubleval($_REQUEST['credit']);
         $payment_id = intval($_REQUEST['payment']);
         $memo = strim($_REQUEST['memo']);
         $root['user_login_status'] = 1;
         $root['show_pay_btn'] = 0;
         //0:不显示,支付按钮; 1:显示支付按钮
         $order = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where user_id = {$user_id} and id = " . $order_id);
         if (empty($order)) {
             //	$root['order_status'] = 1;
             $root['pay_info'] = '订单不存在.';
             $root['show_pay_btn'] = 0;
             output($root);
         }
         if ($order['order_status'] == 2) {
             $root['order_status'] = 1;
             $root['pay_code'] = '';
             $root['order_id'] = $order_id;
             $root['order_sn'] = $order['order_sn'];
             $root['response_code'] = 1;
             $root['pay_info'] = '订单已支付成功.';
             $root['show_pay_btn'] = 0;
             output($root);
         }
         if ($payment_id == 0) {
             $payment_id = intval($order['payment_id']);
         }
         $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id= " . $order['deal_id']);
         if ($credit > 0) {
             $sql = $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set credit_pay = credit_pay + " . $credit . " where id = " . $order_id);
             require_once APP_ROOT_PATH . "system/libs/user.php";
             modify_account(array("money" => "-" . $credit), intval($user_id), "支持" . $deal_info['name'] . "项目支付");
         }
         $result = pay_order($order_id);
         if ($order['credit_pay'] = $order['total_price']) {
             $root['response_code'] = 1;
             $root['info'] = "余额全部支付";
         }
         if ($order['credit_pay'] < $order['total_price'] && $order['credit_pay'] > 0) {
             $root['response_code'] = 2;
             $root['info'] = "余额部分支付";
         }
         if ($order['credit_pay'] = 0) {
             $root['response_code'] = 3;
             $root['info'] = "余额未支付";
         }
         if ($result['status'] == 0) {
             $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id=" . $payment_id);
             $pay_code = strtolower($payment_info['class_name']);
             /*online_pay 支付方式:1:在线支付;0:线下支付;2:手机wap;3:手机sdk */
             $online_pay = intval($payment_info['online_pay']);
             $root['online_pay'] = $online_pay;
             if ($online_pay != 2) {
                 $root['response_code'] = 0;
                 $root['pay_info'] = '手机版本不支付,无法在手机上支付.' . $pay_code;
                 $root['show_pay_btn'] = 0;
                 output($root);
             }
             if ($online_pay = 2) {
                 $money = $result['money'];
                 $payment_notice['create_time'] = NOW_TIME;
                 $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
                 $payment_notice['payment_id'] = $payment_id;
                 $payment_notice['money'] = $money;
                 //	$payment_notice['bank_id'] = strim($_REQUEST['bank_id']);
                 $payment_notice['order_id'] = $order_id;
                 $payment_notice['memo'] = $memo;
                 $payment_notice['deal_id'] = $deal_info['id'];
                 $payment_notice['deal_item_id'] = $order['deal_item_id'];
                 $payment_notice['deal_name'] = $deal_info['name'];
                 do {
                     $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999);
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                     $notice_id = $GLOBALS['db']->insert_id();
                 } while ($notice_id == 0);
             }
             //创建了支付单号,通过支付接口创建支付数据
             require_once APP_ROOT_PATH . "system/payment/" . $payment_info['class_name'] . "_payment.php";
             $payment_class = $payment_info['class_name'] . "_payment";
             $payment_object = new $payment_class();
             $pay = $payment_object->get_payment_code($notice_id);
             $root['is_wap'] = intval($pay['is_wap']);
             $root['pay_money_format'] = $pay['total_fee_format'];
             $root['pay_money'] = $pay['total_fee'];
             $root['pay_info'] = $pay['body'];
             $root['pay_wap'] = $pay['notify_url'];
             if ($root['pay_money'] > 0) {
                 $root['show_pay_btn'] = 1;
             }
         }
         output($root);
     } else {
         $root['response_code'] = 0;
         $root['user_login_status'] = 0;
         $root['show_err'] = "未登录";
         output($root);
     }
 }
Пример #15
0
 /**
  * 退款执行流:
  * 1. 退还金额至会员账户
  * 2. 更新商家账户
  * 3. 更新订单及订单关联表的相关状态
  * 3. 更新平台报表
  * 4. 更新订单缓存
  * 5. 为订单重新分片
  */
 public function do_refund()
 {
     $order_item_id = intval($_REQUEST['order_item_id']);
     $coupon_id = intval($_REQUEST['coupon_id']);
     $price = floatval($_REQUEST['price']);
     $balance_price = floatval($_REQUEST['balance_price']);
     $content = strim($_REQUEST['content']);
     if ($price < 0 || $balance_price < 0) {
         $this->error("金额出错", 1);
     }
     if ($order_item_id) {
         $oi = $order_item_id;
         $data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order_item where id = " . $order_item_id);
         if ($data['refund_status'] == 2) {
             $this->error("已退款", 1);
         }
         if ($data) {
             $order_id = $data['order_id'];
             $supplier_id = $data['supplier_id'];
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set refund_status = 2,is_arrival = 0 where id = " . $order_item_id);
         $refund_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item where (refund_status = 1 or is_arrival = 2) and order_id = " . $order_id);
         $coupon_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where refund_status = 1 and order_id = " . $order_id);
         if ($refund_item_count == 0 && $coupon_item_count == 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_amount = refund_amount + " . $price . ",refund_money = refund_money + " . $price . ",refund_status = 2,after_sale = 1,is_refuse_delivery=0 where id = " . $order_id);
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_amount = refund_amount + " . $price . ",refund_money = refund_money + " . $price . ",is_refuse_delivery=0 where id = " . $order_id);
         }
     } elseif ($coupon_id) {
         $data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_coupon where id = " . $coupon_id);
         if ($data['refund_status'] == 2) {
             $this->error("已退款", 1);
         }
         if ($data) {
             $oi = $data['order_deal_id'];
             $order_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order_item where id = " . $data['order_deal_id']);
             $data['name'] = $order_item['name'];
             $order_id = $data['order_id'];
             $supplier_id = $data['supplier_id'];
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set refund_status = 2 where id = " . $coupon_id);
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set refund_status = 2 where id = " . $data['order_deal_id']);
         $refund_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item where (refund_status = 1 or is_arrival = 2) and order_id = " . $order_id);
         $coupon_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where refund_status = 1 and order_id = " . $order_id);
         if ($refund_item_count == 0 && $coupon_item_count == 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_amount = refund_amount + " . $price . ",refund_money = refund_money + " . $price . ",refund_status = 2,after_sale = 1 where id = " . $order_id);
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_amount = refund_amount + " . $price . ",refund_money = refund_money + " . $price . " where id = " . $order_id);
         }
     }
     $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id);
     if ($price > 0) {
         require_once APP_ROOT_PATH . "system/model/user.php";
         modify_account(array("money" => $price), $order_info['user_id'], $data['name'] . "退款成功");
         modify_statements($price, 6, $data['name'] . "用户退款");
     }
     if ($balance_price > 0) {
         require_once APP_ROOT_PATH . "system/model/supplier.php";
         modify_supplier_account("-" . $balance_price, $supplier_id, 1, $data['name'] . "用户退款");
         //冻结资金减少
         modify_supplier_account($balance_price, $supplier_id, 4, $data['name'] . "用户退款");
         //退款增加
         modify_statements($balance_price, 7, $data['name'] . "用户退款");
     }
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     order_log($data['name'] . "退款成功 " . format_price($price) . " " . $content, $order_id);
     auto_over_status($order_id);
     update_order_cache($order_id);
     distribute_order($order_id);
     send_msg($order_info['user_id'], $data['name'] . "退款成功 " . format_price($price) . " " . $content, "orderitem", $oi);
     $this->success("退款成功", 1);
 }
Пример #16
0
 public function batch_refund()
 {
     $page = intval($_REQUEST['page']);
     $page = $page <= 0 ? 1 : $page;
     $page_size = 100;
     $deal_id = intval($_REQUEST['id']);
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $deal_info = M("Deal")->where("id=" . $deal_id . " and is_delete = 0 and is_effect = 1 and is_success = 0 and end_time <>0 and end_time <" . get_gmtime())->find();
     if (!$deal_info) {
         $this->error("该项目不能批量退款");
     } else {
         require_once APP_ROOT_PATH . "system/libs/user.php";
         $refund_order_list = M("DealOrder")->where("deal_id=" . $deal_id . " and is_refund = 0 and order_status = 3")->limit($limit)->findAll();
         foreach ($refund_order_list as $k => $v) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set is_refund = 1 where id = " . $v['id']);
             if ($GLOBALS['db']->affected_rows() > 0) {
                 modify_account(array("money" => $v['online_pay'] + $v['credit_pay']), $v['user_id'], $v['deal_name'] . "退款");
                 //退回积分
                 if ($v['score'] > 0) {
                     $log_info = $v['deal_name'] . "退款,退回" . $v['score'] . "积分";
                     modify_account(array("score" => $v['score']), $v['user_id'], $log_info);
                 }
                 //扣掉购买时送的积分和信用值
                 $sp_multiple = unserialize($v['sp_multiple']);
                 if ($v['score_multiple'] > 0) {
                     $score = intval($v['total_price'] * $sp_multiple['score_multiple']);
                     $log_info = $v['deal_name'] . "退款,扣掉" . $score . "积分";
                     modify_account(array("score" => "-" . $score), $v['user_id'], $log_info);
                 }
                 if ($sp_multiple['point_multiple'] > 0) {
                     $point = intval($v['total_price'] * $sp_multiple['point_multiple']);
                     $log_info = $v['deal_name'] . "退款,扣掉" . $point . "信用值";
                     modify_account(array("point" => "-" . $point), $v['user_id'], $log_info);
                 }
             }
         }
         //同步商品记录
         syn_deal($deal_info['id']);
         $deal_item_list = M("DealItem")->where("deal_id=" . intval($deal_info['id']))->findAll();
         foreach ($deal_item_list as $k => $v) {
             $deal_item['support_count'] = intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order where deal_id = " . $v['deal_id'] . " and order_status=3 and is_refund=0 and deal_item_id=" . intval($v['id'])));
             $deal_item['support_amount'] = floatval($GLOBALS['db']->getOne("select sum(deal_price) from " . DB_PREFIX . "deal_order where deal_id = " . $v['deal_id'] . " and order_status=3 and is_refund=0 and deal_item_id=" . intval($v['id'])));
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_item", $deal_item, $mode = 'UPDATE', "id=" . intval($v['id']), $querymode = 'SILENT');
         }
         $remain = M("DealOrder")->where("deal_id=" . $deal_id . " and is_refund = 0 and order_status = 3")->count();
         if ($remain == 0) {
             $jump_url = u("Deal/online_index");
             $this->assign("jumpUrl", $jump_url);
             M("Deal")->where("id=" . $deal_info['id'])->setField("deal_extra_cache", "");
             M("DealLog")->where("deal_id=" . $deal_info['id'])->setField("deal_info_cache", "");
             $this->success("批量退款成功");
         } else {
             $jump_url = u("Deal/batch_refund", array("id" => $deal_id, "page" => $page + 1));
             $this->assign("jumpUrl", $jump_url);
             $this->success("批量退款中,请勿刷新页面,剩余" . $remain . "条订单未退款");
         }
     }
 }
 public function go_order_pay()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $id = intval($_REQUEST['order_id']);
     $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']) . " and order_status = 0");
     if (!$order_info) {
         showErr("项目支持已支付", 0, get_gopreview());
     } else {
         $credit = doubleval($_REQUEST['credit']);
         $payment_id = intval($_REQUEST['payment']);
         if ($credit > 0) {
             $max_pay = $order_info['total_price'] - $order_info['credit_pay'];
             $max_credit = $max_pay < $GLOBALS['user_info']['money'] ? $max_pay : $GLOBALS['user_info']['money'];
             $credit = $credit > $max_credit ? $max_credit : $credit;
             if ($credit > 0) {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set credit_pay = credit_pay + " . $credit . " where id = " . $order_info['id']);
                 //追加使用余额支付
                 require_once APP_ROOT_PATH . "system/libs/user.php";
                 modify_account(array("money" => "-" . $credit), intval($GLOBALS['user_info']['id']), "支持" . $order_info['deal_name'] . "项目支付");
             }
         }
         $result = pay_order($order_info['id']);
         if ($result['status'] == 0) {
             $money = $result['money'];
             $payment_notice['create_time'] = NOW_TIME;
             $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
             $payment_notice['payment_id'] = $payment_id;
             $payment_notice['money'] = $money;
             $payment_notice['bank_id'] = strim($_REQUEST['bank_id']);
             $payment_notice['order_id'] = $order_info['id'];
             $payment_notice['memo'] = $order_info['support_memo'];
             $payment_notice['deal_id'] = $order_info['deal_id'];
             $payment_notice['deal_item_id'] = $order_info['deal_item_id'];
             $payment_notice['deal_name'] = $order_info['deal_name'];
             do {
                 $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                 $notice_id = $GLOBALS['db']->insert_id();
             } while ($notice_id == 0);
             app_redirect(url("cart#jump", array("id" => $notice_id)));
         } else {
             app_redirect(url("account#view_order", array("id" => $order_info['id'])));
         }
     }
 }
Пример #18
0
 public function update()
 {
     $data = M(MODULE_NAME)->create();
     $data['status'] = strim(intval($_REQUEST['status']));
     $data['bad_msg'] = strim($_REQUEST['msg']);
     $data['note'] = strim($_REQUEST['note']);
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if ($list > 0) {
         $sdata['op_time'] = TIME_UTC;
         $sdata['id'] = $data['id'];
         M(MODULE_NAME)->save($sdata);
         //成功提示
         $vo = M(MODULE_NAME)->where("id=" . $data['id'])->find();
         $user_id = $vo['user_id'];
         $user_info = M("User")->where("id=" . $user_id)->find();
         require_once APP_ROOT_PATH . "/system/libs/user.php";
         if ($data['status'] == 1) {
             //$content = "您于".to_date($vo['create_time'],"Y年m月d日 H:i:s")."提交的".format_price($vo['money'])."信用额度申请成功,请查看您的申请记录。";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 21;
             $sh_notice['time'] = to_date($vo['create_time'], "Y年m月d日 H:i:s");
             //申请时间
             $sh_notice['quota'] = format_price($vo['money']);
             //申请额度
             $GLOBALS['tmpl']->assign("sh_notice", $sh_notice);
             $tmpl_sz_failed_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_INS_QUORA_SUCCESS'", false);
             $sh_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_sz_failed_content['content']);
             $msg_data['content'] = $sh_content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 21;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
             //更改用户额度
             if ($vo['money'] > $user_info['quota']) {
                 modify_account(array("quota" => $vo['money'] - $user_info['quota']), $user_info['id'], "申请额度", 13);
             }
             //短信通知
             if (app_conf("SMS_ON") == 1) {
                 $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_QUOTA_SUCCESS_SMS'", false);
                 $tmpl_content = $tmpl['content'];
                 $notice['user_name'] = $user_info["user_name"];
                 $notice['quota_money'] = $vo['money'];
                 $notice['site_name'] = app_conf("SHOP_TITLE");
                 $GLOBALS['tmpl']->assign("notice", $notice);
                 $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                 $msg_data['dest'] = $user_info['mobile'];
                 $msg_data['send_type'] = 0;
                 $msg_data['title'] = "额度申请成功短信提醒";
                 $msg_data['content'] = addslashes($msg);
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = TIME_UTC;
                 $msg_data['user_id'] = $user_info['id'];
                 $msg_data['is_html'] = $tmpl['is_html'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 //插入
             }
         } else {
             //驳回
             //$content = "您于".to_date($vo['create_time'],"Y年m月d日 H:i:s")."提交的".format_price($vo['money'])."信用额度申请申请被我们驳回,驳回原因\"".$data['bad_msg']."\"";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 22;
             $sh_notice['time'] = to_date($vo['create_time'], "Y年m月d日 H:i:s");
             //申请时间
             $sh_notice['quota'] = format_price($vo['money']);
             //申请额度
             $sh_notice['msg'] = $data['bad_msg'];
             //驳回原因
             $GLOBALS['tmpl']->assign("sh_notice", $sh_notice);
             $tmpl_sz_failed_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_INS_QUORA_FAILED'", false);
             $sh_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_sz_failed_content['content']);
             $msg_data['content'] = $sh_content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 22;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
             //短信通知
             if (app_conf("SMS_ON") == 1) {
                 $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_QUOTA_FAILED_SMS'", false);
                 $tmpl_content = $tmpl['content'];
                 $notice['user_name'] = $user_info["user_name"];
                 $notice['quota_money'] = $vo['money'];
                 $notice['msg'] = $data['bad_msg'];
                 $notice['site_name'] = app_conf("SHOP_TITLE");
                 $GLOBALS['tmpl']->assign("notice", $notice);
                 $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                 $msg_data['dest'] = $user_info['mobile'];
                 $msg_data['send_type'] = 0;
                 $msg_data['title'] = "额度申请失败";
                 $msg_data['content'] = addslashes($msg);
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = TIME_UTC;
                 $msg_data['user_id'] = $user_info['id'];
                 $msg_data['is_html'] = $tmpl['is_html'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 //插入
             }
         }
         save_log("编号为" . $data['id'] . "的信用额度申请" . L("UPDATE_SUCCESS"), 1);
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         $DBerr = M()->getDbError();
         save_log("编号为" . $data['id'] . "的信用额度申请" . L("UPDATE_FAILED") . $DBerr, 0);
         $this->error(L("UPDATE_FAILED") . $DBerr, 0);
     }
 }
 public function update()
 {
     $data = M(MODULE_NAME)->create();
     $point = 0;
     if ($data['status']) {
         $point = intval($_REQUEST['point']);
     }
     $this->assign("jumpUrl", "javascript:history.back(-1);");
     if ($data['status'] == 1) {
         if (!check_empty($data['name'])) {
             $this->error(L("DEAL_NAME_EMPTY_TIP"));
         }
         if (!check_empty($data['sub_name'])) {
             $this->error(L("DEAL_SUB_NAME_EMPTY_TIP"));
         }
         if ($data['cate_id'] == 0) {
             $this->error(L("DEAL_CATE_EMPTY_TIP"));
         }
     }
     if ($point > 0) {
         $msg = "授信额度申请成功,增加信用额度" . $point;
         require_once APP_ROOT_PATH . "system/libs/user.php";
         modify_account(array('point' => $point), $data['user_id'], $msg, 8);
     }
     $user_info = M("User")->getById($data['user_id']);
     $old_imgdata_str = unserialize($user_info['view_info']);
     $data['view_info'] = array();
     foreach ($_REQUEST['key'] as $k => $v) {
         if (isset($old_imgdata_str[$v])) {
             $data['view_info'][$v] = $old_imgdata_str[$v];
         }
     }
     $data['view_info'] = serialize($data['view_info']);
     $data['citys'] = serialize($_REQUEST['city_id']);
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if ($list > 0) {
         $sdata['update_time'] = TIME_UTC;
         $sdata['id'] = $data['id'];
         M(MODULE_NAME)->save($sdata);
         //成功提示
         $vo = M(MODULE_NAME)->where("id=" . $data['id'])->find();
         $user_id = $vo['user_id'];
         $user_info = M("User")->where("id=" . $user_id)->find();
         require_once APP_ROOT_PATH . "/system/libs/user.php";
         if ($data['status'] == 1) {
             //$content = "您于".to_date($vo['create_time'],"Y年m月d日 H:i:s")."提交的".format_price($vo['borrow_amount'])."授信额度申请成功,请查看您的申请记录。";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 21;
             $sh_notice['point'] = "并增加信用积分" . $point;
             $sh_notice['time'] = to_date($vo['create_time'], "Y年m月d日 H:i:s");
             //提交时间
             $sh_notice['quota'] = format_price($vo['borrow_amount']);
             //授信额度
             $GLOBALS['tmpl']->assign("sh_notice", $sh_notice);
             $tmpl_sz_failed_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_INS_SXQUORA_SUCCESS_SMS'", false);
             $sh_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_sz_failed_content['content']);
             $msg_data['content'] = $sh_content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 22;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
             //短信通知
             if (app_conf("SMS_ON") == 1) {
                 $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_QUOTA_SUCCESS_SMS'", false);
                 $tmpl_content = $tmpl['content'];
                 $notice['user_name'] = $user_info["user_name"];
                 $notice['quota_money'] = $vo['money'];
                 $notice['site_name'] = app_conf("SHOP_TITLE");
                 $GLOBALS['tmpl']->assign("notice", $notice);
                 $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                 $msg_data['dest'] = $user_info['mobile'];
                 $msg_data['send_type'] = 0;
                 $msg_data['title'] = "额度申请成功短信提醒";
                 $msg_data['content'] = addslashes($msg);
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = TIME_UTC;
                 $msg_data['user_id'] = $user_info['id'];
                 $msg_data['is_html'] = $tmpl['is_html'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 //插入
             }
         } else {
             //驳回
             //$content = "您于".to_date($vo['create_time'],"Y年m月d日 H:i:s")."提交的".format_price($vo['money'])."授信额度申请申请被我们驳回,驳回原因\"".$data['bad_msg']."\"";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 22;
             $sh_notice['time'] = to_date($vo['create_time'], "Y年m月d日 H:i:s");
             //提交时间
             $sh_notice['quota'] = format_price($vo['money']);
             //授信额度
             $sh_notice['msg'] = $data['bad_msg'];
             //驳回原因
             $GLOBALS['tmpl']->assign("sh_notice", $sh_notice);
             $tmpl_sz_failed_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_INS_SXQUORA_FAILED_SMS'", false);
             $sh_content = $GLOBALS['tmpl']->fetch("str:" . $tmpl_sz_failed_content['content']);
             $msg_data['content'] = $sh_content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 22;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
             //短信通知
             if (app_conf("SMS_ON") == 1) {
                 $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_QUOTA_FAILED_SMS'", false);
                 $tmpl_content = $tmpl['content'];
                 $notice['user_name'] = $user_info["user_name"];
                 $notice['quota_money'] = $vo['borrow_amount'];
                 $notice['msg'] = $data['bad_msg'];
                 $notice['site_name'] = app_conf("SHOP_TITLE");
                 $GLOBALS['tmpl']->assign("notice", $notice);
                 $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                 $msg_data['dest'] = $user_info['mobile'];
                 $msg_data['send_type'] = 0;
                 $msg_data['title'] = "授信额度申请失败";
                 $msg_data['content'] = addslashes($msg);
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = TIME_UTC;
                 $msg_data['user_id'] = $user_info['id'];
                 $msg_data['is_html'] = $tmpl['is_html'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 //插入
             }
         }
         save_log("编号为" . $data['id'] . "的授信额度申请" . L("UPDATE_SUCCESS"), 1);
         $this->assign("jumpUrl", u(MODULE_NAME . "/index", array("status" => $data['status'])));
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         $DBerr = M()->getDbError();
         save_log("编号为" . $data['id'] . "的授信额度申请" . L("UPDATE_FAILED") . $DBerr, 0);
         $this->error(L("UPDATE_FAILED") . $DBerr, 0);
     }
 }
Пример #20
0
 public function create_user()
 {
     $s_api_user_info = es_session::get("api_user_info");
     $user_data['user_name'] = $s_api_user_info['name'];
     $user_data['user_pwd'] = md5(rand(100000, 999999));
     $user_data['create_time'] = TIME_UTC;
     $user_data['update_time'] = TIME_UTC;
     $user_data['login_ip'] = get_client_ip();
     $user_data['group_id'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_group order by score asc limit 1");
     $user_data['is_effect'] = 1;
     $user_data['alipay_id'] = $s_api_user_info['id'];
     $count = 0;
     do {
         if ($count > 0) {
             $user_data['user_name'] = $user_data['user_name'] . $count;
         }
         if (intval($user_data['alipay_id']) > 0) {
             $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user_data, "INSERT", '', 'SILENT');
         }
         $rs = $GLOBALS['db']->insert_id();
         $count++;
     } while (intval($rs) == 0 && intval($user_data['alipay_id']) > 0);
     $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . intval($rs));
     if ($rs > 0) {
         $user_id = $rs;
         $register_money = doubleval(app_conf("USER_REGISTER_MONEY"));
         $register_score = intval(app_conf("USER_REGISTER_SCORE"));
         $register_point = intval(app_conf("USER_REGISTER_POINT"));
         $register_lock_money = intval(app_conf("USER_LOCK_MONEY"));
         if ($register_money > 0 || $register_score > 0 || $register_point > 0 || $register_lock_money > 0) {
             $user_get['score'] = $register_score;
             $user_get['money'] = $register_money;
             $user_get['point'] = $register_point;
             $user_get['reg_lock_money'] = $register_lock_money;
             require_once APP_ROOT_PATH . "system/libs/user.php";
             modify_account($user_get, intval($user_id), "在" . to_date(TIME_UTC) . "注册成功");
         }
     }
     es_session::set("user_info", $user_info);
     es_session::delete("api_user_info");
 }
Пример #21
0
/**
 * 生成会员数据
 * @param $user_data  提交[post或get]的会员数据
 * @param $mode  处理的方式,注册或保存
 * 返回:data中返回出错的字段信息,包括field_name, 可能存在的field_show_name 以及 error 错误常量
 * 不会更新保存的字段为:score,money,verify,pid
 */
function save_user($user_data, $mode = 'INSERT')
{
    //开始数据验证
    $res = array('status' => 1, 'info' => '', 'data' => '');
    //用于返回的数据
    if ($mode == "INSERT" || isset($user_data['user_name'])) {
        if (trim($user_data['user_name']) == '') {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!preg_match("/^[\\x{4e00}-\\x{9fa5}_\\-]*[0-9a-zA-Z_\\-]*[\\x{201c}\\x{201d}\\x{3001}\\x{uff1a}\\x{300a}\\x{300b\\x{ff0c}\\x{ff1b}\\x{3002}_\\-]*\$/u", $user_data['user_name']) || is_numeric($user_data['user_name'])) {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where user_name = '" . trim($user_data['user_name']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'user_name';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
    }
    if ($mode == "INSERT" && (intval(app_conf('REGISTER_TYPE')) == 0 || intval(app_conf('REGISTER_TYPE')) == 2) || isset($user_data['email'])) {
        if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where email = '" . trim($user_data['email']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'email';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (trim($user_data['email']) == '') {
            $field_item['field_name'] = 'email';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!check_email(trim($user_data['email']))) {
            $field_item['field_name'] = 'email';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        $user['emailpassed'] = intval($user_data['emailpassed']);
    }
    if ($mode == "INSERT" && (intval(app_conf('REGISTER_TYPE')) == 0 || intval(app_conf('REGISTER_TYPE')) == 1) || isset($user_data['mobile'])) {
        if (trim($user_data['mobile']) == '') {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if (!check_mobile(trim($user_data['mobile']))) {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($user_data['mobile'] != '' && $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where mobile = '" . trim($user_data['mobile']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'mobile';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        $user['mobilepassed'] = intval($user_data['mobilepassed']);
    }
    if (isset($user_data['idno']) && strim($user_data['idno']) != "") {
        if (getIDCardInfo($user_data['idno']) == 0) {
            $field_item['field_name'] = 'idno';
            $field_item['error'] = FORMAT_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
        if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where idno = '" . trim($user_data['idno']) . "' and id <> " . intval($user_data['id'])) > 0) {
            $field_item['field_name'] = 'idno';
            $field_item['error'] = EXIST_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
    }
    //验证扩展字段
    if (isset($user_data['user_pwd'])) {
        $user_field = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_field");
        foreach ($user_field as $field_item) {
            if ($field_item['is_must'] == 1 && trim($user_data[$field_item['field_name']]) == '') {
                $field_item['error'] = EMPTY_ERROR;
                $res['status'] = 0;
                $res['data'] = $field_item;
                return $res;
            }
        }
    }
    //验证结束开始插入数据
    if ($mode == "INSERT" || $user_data['user_name']) {
        $user['user_name'] = $user_data['user_name'];
    }
    $user['update_time'] = TIME_UTC;
    if (isset($user_data['pid'])) {
        $user['pid'] = $user_data['pid'];
    }
    if (isset($user_data['referral_rate'])) {
        $user['referral_rate'] = $user_data['referral_rate'];
    }
    if (isset($user_data['real_name'])) {
        $user['real_name'] = $user_data['real_name'];
    }
    if (isset($user_data['idno'])) {
        $user['idno'] = $user_data['idno'];
    }
    if (isset($user_data['graduation'])) {
        $user['graduation'] = $user_data['graduation'];
    }
    if (isset($user_data['graduatedyear'])) {
        $user['graduatedyear'] = intval($user_data['graduatedyear']);
    }
    if (isset($user_data['university'])) {
        $user['university'] = $user_data['university'];
    }
    if (isset($user_data['marriage'])) {
        $user['marriage'] = $user_data['marriage'];
    }
    if (isset($user_data['haschild'])) {
        $user['haschild'] = intval($user_data['haschild']);
    }
    if (isset($user_data['hashouse'])) {
        $user['hashouse'] = intval($user_data['hashouse']);
    }
    if (isset($user_data['houseloan'])) {
        $user['houseloan'] = intval($user_data['houseloan']);
    }
    if (isset($user_data['hascar'])) {
        $user['hascar'] = intval($user_data['hascar']);
    }
    if (isset($user_data['carloan'])) {
        $user['carloan'] = intval($user_data['carloan']);
    }
    if (isset($user_data['address'])) {
        $user['address'] = $user_data['address'];
    }
    if (isset($user_data['phone'])) {
        $user['phone'] = $user_data['phone'];
    }
    if (isset($user_data['n_province_id'])) {
        $user['n_province_id'] = intval($user_data['n_province_id']);
    }
    if (isset($user_data['n_city_id'])) {
        $user['n_city_id'] = intval($user_data['n_city_id']);
    }
    if (isset($user_data['province_id'])) {
        $user['province_id'] = intval($user_data['province_id']);
    }
    if (isset($user_data['city_id'])) {
        $user['city_id'] = intval($user_data['city_id']);
    }
    if (isset($user_data['sex'])) {
        $user['sex'] = intval($user_data['sex']);
    }
    if (isset($user_data['byear'])) {
        $user['byear'] = intval($user_data['byear']);
    }
    if (isset($user_data['bmonth'])) {
        $user['bmonth'] = intval($user_data['bmonth']);
    }
    if (isset($user_data['bday'])) {
        $user['bday'] = intval($user_data['bday']);
    }
    if (isset($user_data['referer_memo'])) {
        $user['referer_memo'] = $user_data['referer_memo'];
    }
    //自动获取会员分组
    if (intval($user_data['group_id']) != 0) {
        $user['group_id'] = $user_data['group_id'];
    } else {
        if ($mode == 'INSERT') {
            //获取默认会员组, 即升级积分最小的会员组
            $user['group_id'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_group order by score asc limit 1");
        }
    }
    //会员状态
    if (intval($user_data['is_effect']) != 0) {
        $user['is_effect'] = $user_data['is_effect'];
    } else {
        if ($mode == 'INSERT') {
            if (intval(app_conf("USER_VERIFY")) == 4) {
                $user['is_effect'] = 0;
            } elseif (app_conf("USER_VERIFY") == 3) {
                $user['is_effect'] = 1;
            }
        }
    }
    if ($mode == "INSERT" || isset($user_data['email'])) {
        $user['email'] = $user_data['email'];
    }
    if ($mode == "INSERT" || isset($user_data['mobile'])) {
        $user['mobile'] = $user_data['mobile'];
    }
    if ($mode == "INSERT" || isset($user_data['user_type'])) {
        $user['user_type'] = intval($user_data['user_type']);
    }
    if ($mode == 'INSERT') {
        $user['create_time'] = TIME_UTC;
        $user['code'] = '';
        //默认不使用code, 该值用于其他系统导入时的初次认证
    } else {
        $user['code'] = $GLOBALS['db']->getOne("select code from " . DB_PREFIX . "user where id =" . $user_data['id']);
    }
    if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
        $user['user_pwd'] = md5($user_data['user_pwd'] . $user['code']);
    }
    $user['old_user_name'] = $user_data['old_user_name'];
    $user['old_email'] = $user_data['old_email'];
    $user['old_password'] = $user_data['old_password'];
    $user['new_password'] = $user_data['user_pwd'];
    $date_time = to_date(TIME_UTC);
    //载入会员整合
    $integrate_code = trim(app_conf("INTEGRATE_CODE"));
    if ($integrate_code != '') {
        $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php";
        if (file_exists($integrate_file)) {
            require_once $integrate_file;
            $integrate_class = $integrate_code . "_integrate";
            $integrate_obj = new $integrate_class();
        }
    }
    //同步整合
    if ($integrate_obj) {
        if ($mode == 'INSERT') {
            $res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            $user['integrate_id'] = intval($res['data']);
        } else {
            $add_res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            if (intval($add_res['status']) && $integrate_code != "Cn273") {
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . intval($add_res['data']) . " where id = " . intval($user_data['id']));
            } else {
                if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
                    $status = $integrate_obj->edit_user($user, $user_data['user_pwd']);
                    if ($status <= 0) {
                        //修改密码失败
                        $res['status'] = 0;
                    }
                }
            }
        }
        if (intval($res['status']) == 0) {
            return $res;
        }
    }
    if ($mode == 'INSERT') {
        $user['register_ip'] = get_client_ip();
        $s_api_user_info = es_session::get("api_user_info");
        $user[$s_api_user_info['field']] = $s_api_user_info['id'];
        es_session::delete("api_user_info");
        $where = '';
    } else {
        unset($user['pid']);
        $where = "id=" . intval($user_data['id']);
    }
    if ($GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user, $mode, $where)) {
        if ($mode == 'INSERT') {
            $user_id = $GLOBALS['db']->insert_id();
            $register_money = doubleval(app_conf("USER_REGISTER_MONEY"));
            $register_score = intval(app_conf("USER_REGISTER_SCORE"));
            $register_point = intval(app_conf("USER_REGISTER_POINT"));
            $register_lock_money = intval(app_conf("USER_LOCK_MONEY"));
            if ($register_money > 0 || $register_score > 0 || $register_point > 0 || $register_lock_money > 0) {
                $user_get['score'] = $register_score;
                $user_get['money'] = $register_money;
                $user_get['point'] = $register_point;
                $user_get['lock_money'] = $register_lock_money;
                modify_account($user_get, intval($user_id), "在" . $date_time . "注册成功", 18);
            }
        } else {
            $user_id = $user_data['id'];
        }
    }
    $res['data'] = $user_id;
    //开始更新处理扩展字段
    if ($mode == 'INSERT') {
        foreach ($user_field as $field_item) {
            $extend = array();
            $extend['user_id'] = $user_id;
            $extend['field_id'] = $field_item['id'];
            $extend['value'] = $user_data[$field_item['field_name']];
            $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode);
        }
    } else {
        foreach ($user_field as $field_item) {
            $extend = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_extend where user_id=" . $user_id . " and field_id =" . $field_item['id']);
            if ($extend) {
                $extend['value'] = $user_data[$field_item['field_name']];
                $where = 'id=' . $extend['id'];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode, $where);
            } else {
                $extend = array();
                $extend['user_id'] = $user_id;
                $extend['field_id'] = $field_item['id'];
                $extend['value'] = $user_data[$field_item['field_name']];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, "INSERT");
            }
        }
    }
    return $res;
}
Пример #22
0
/**
 * 弃用
 * 为某个团购券退款
 * 团购券退款总额
 * 返回: 0:退款失败 1:成功 2全单退款
 */
function refund_coupon($coupon_id)
{
    return;
    $coupon_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_coupon where id = " . $coupon_id . " and refund_status = 1");
    if (!$coupon_data) {
        return 0;
    }
    $return = 1;
    $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $coupon_data['order_id']);
    if ($coupon_data['coupon_price'] <= $order_info['pay_amount'] - $order_info['payment_fee'] - $order_info['delivery_fee'] - $order_info['refund_amound']) {
        $refund_price = $coupon_data['coupon_price'];
    } else {
        $refund_price = $order_info['pay_amount'] - $order_info['refund_amound'] - $order_info['payment_fee'];
        //不退支付手续费;
        $return = 2;
    }
    $refund_price -= $coupon_data['coupon_money'];
    //返现的钱也退
    $refund_score = 0 - $coupon_data['coupon_score'];
    //处理返利
    if ($order_info['pay_status'] == 2) {
        //判断商品是否返利商品
        $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id=" . intval($coupon_data['deal_id']));
        if ($deal_info['is_referral'] == 1) {
            $res = return_referrals($order_info['id']);
            if ($res) {
                save_log("ID:" . $order_info['id'] . l("REFERRALS_PAY_SUCCESS"), 1);
            } else {
                save_log("ID:" . $order_info['id'] . l("REFERRALS_PAY_FAILED"), 0);
            }
        }
    }
    $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set refund_status = 2,is_valid = 2 where id = " . $coupon_data['id']);
    $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_amount = refund_amount+" . $refund_price . ",refund_status = 2,after_sale = 1 where id = " . $order_info['id']);
    $GLOBALS['db']->query("update " . DB_PREFIX . "deal set buy_count=buy_count-1 where id=" . intval($coupon_data['deal_id']));
    $affect_deal = $GLOBALS['db']->getRow("select buy_count from " . DB_PREFIX . "deal where id= " . intval($coupon_data['deal_id']));
    if ($affect_deal['buy_count'] == 0) {
        $sql_1 = "update " . DB_PREFIX . "deal set buy_status = 0 where id= " . intval($coupon_data['deal_id']);
    } else {
        $sql_1 = "update " . DB_PREFIX . "deal set buy_status = 1 where id= " . intval($coupon_data['deal_id']);
    }
    $GLOBALS['db']->query($sql_1);
    $data = array("money" => $refund_price, "score" => $refund_score);
    require_once APP_ROOT_PATH . "system/model/user.php";
    modify_account($data, $order_info['user_id'], "来自" . $order_info['order_sn'] . "中团购券" . $coupon_data['sn'] . "的退款 ");
    order_log("团购券" . $coupon_data['sn'] . "已退款" . format_price($refund_price), $order_info['id']);
    return $return;
}
Пример #23
0
 public function do_invest_failure()
 {
     $retrun = array('status' => 0, 'info' => "操作失败");
     $deal_id = intval($_REQUEST['id']);
     $user_info = es_session::get("user_info");
     if ($user_info) {
         $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id=" . $deal_id . " and user_id=" . intval($user_info['id']) . " and  end_time<" . NOW_TIME . " and is_success=1 and invest_status=0 and type=1");
         if ($deal_info) {
             //有相应项目
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal set invest_status=2,is_success=0 where id=" . $deal_id . " and user_id=" . intval($user_info['id']) . " and  end_time<" . NOW_TIME . " and is_success=1 and invest_status=0  and type=1");
             if ($GLOBALS['db']->affected_rows()) {
                 $order_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order where deal_id=" . $deal_id . " and is_refund=0 and order_status = 3");
                 foreach ($order_list as $k => $v) {
                     $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set is_refund = 1 where id = " . $v['id']);
                     if ($GLOBALS['db']->affected_rows() > 0) {
                         modify_account(array("money" => $v['online_pay'] + $v['credit_pay']), $v['user_id'], $v['deal_name'] . "退款");
                         //退回积分
                         if ($v['score'] > 0) {
                             $log_info = $v['deal_name'] . "退款,退回" . $v['score'] . "积分";
                             modify_account(array("score" => $v['score']), $v['user_id'], $log_info);
                         }
                         //扣掉购买时送的积分和信用值
                         $sp_multiple = unserialize($v['sp_multiple']);
                         if ($v['score_multiple'] > 0) {
                             $score = intval($v['total_price'] * $sp_multiple['score_multiple']);
                             $log_info = $v['deal_name'] . "退款,扣掉" . $score . "积分";
                             modify_account(array("score" => "-" . $score), $v['user_id'], $log_info);
                         }
                         if ($sp_multiple['point_multiple'] > 0) {
                             $point = intval($v['total_price'] * $sp_multiple['point_multiple']);
                             $log_info = $v['deal_name'] . "退款,扣掉" . $point . "信用值";
                             modify_account(array("point" => "-" . $point), $v['user_id'], $log_info);
                         }
                     }
                 }
                 $retrun['status'] = 1;
                 $retrun['info'] = "操作成功";
             }
         }
         //end有相应项目
     } else {
         $retrun['info'] = "请先登录";
     }
     ajax_return($retrun);
 }
function HandleCommand($socket, $cmd)
{
    global $TBS;
    global $pagetitle;
    global $result;
    $pagetitle = $cmd . " result";
    $username = !empty($_POST['username']) ? $_POST['username'] : null;
    $password = !empty($_POST['password']) ? $_POST['password'] : null;
    $confirmation = !empty($_POST['cmd_optn']) ? $_POST['cmd_optn'] : null;
    switch ($cmd) {
        case 'Add':
        case 'Update':
            if (modify_account($socket, $username, $password, 0, false)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Ban':
            if (modify_account($socket, $username, "(hidden)", 0, true)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Unban':
            if (modify_account($socket, $username, "(hidden)", 0, false)) {
                $result = $cmd . " succeed.";
            } else {
                $result = $cmd . " failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'AccessLevel':
            $access_level = intval($_POST['accesslevel']);
            if (modify_account($socket, $username, "(hidden)", $access_level, false)) {
                $result = "Set access level succeed.";
            } else {
                $result = "Set access level failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Disconnect':
            session_destroy();
            $result = "You have been disconnected.";
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Save':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = world_save($socket);
                $result = $cmd . " command sent.";
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Shutdown':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Restart':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, false);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveShutdown':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, false, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'SaveRestart':
            // Antony's enrichment.
            if ($confirmation == "yes") {
                $result = shutdown($socket, true, true);
                if ($result) {
                    $result = $cmd . " command sent.";
                } else {
                    $result = $cmd . " command failed.";
                }
            } else {
                $result = $cmd . " command canceled.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
        case 'Broadcast':
            // Antony's enrichment.
            $message = $_POST['message'];
            $hue = (int) $_POST['hue'];
            $result = world_broadcast($socket, $message, $hue);
            if (!$result) {
                $result = $cmd . " command failed.";
            }
            $TBS->LoadTemplate('tpl/cmdresult.htm');
            break;
    }
}
 public function go_pay()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $consignee_id = intval($_REQUEST['consignee_id']);
     $credit = doubleval($_REQUEST['credit']);
     $memo = strim($_REQUEST['memo']);
     $payment_id = intval($_REQUEST['payment']);
     $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $id);
     if (!$deal_item) {
         app_redirect(url("index"));
     } elseif ($deal_item['support_count'] >= $deal_item['limit_user'] && $deal_item['limit_user'] != 0) {
         app_redirect(url("deal#show", array("id" => $deal_item['deal_id'])));
     }
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $deal_item['deal_id']);
     if (!$deal_info) {
         app_redirect(url("index"));
     } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) {
         app_redirect(url("deal#show", array("id" => $deal_item['deal_id'])));
     }
     if (intval($consignee_id) == 0 && $deal_item['is_delivery'] == 1) {
         showErr("请选择配送方式", 0, get_gopreview());
     }
     $order_info['deal_id'] = $deal_info['id'];
     $order_info['deal_item_id'] = $deal_item['id'];
     $order_info['user_id'] = intval($GLOBALS['user_info']['id']);
     $order_info['user_name'] = $GLOBALS['user_info']['user_name'];
     $order_info['total_price'] = $deal_item['price'] + $deal_item['delivery_fee'];
     $order_info['delivery_fee'] = $deal_item['delivery_fee'];
     $order_info['deal_price'] = $deal_item['price'];
     $order_info['support_memo'] = $memo;
     $order_info['payment_id'] = $payment_id;
     $order_info['bank_id'] = strim($_REQUEST['bank_id']);
     $max_credit = $order_info['total_price'] < $GLOBALS['user_info']['money'] ? $order_info['total_price'] : $GLOBALS['user_info']['money'];
     $credit = $credit > $max_credit ? $max_credit : $credit;
     $order_info['credit_pay'] = $credit;
     $order_info['online_pay'] = 0;
     $order_info['deal_name'] = $deal_info['name'];
     $order_info['order_status'] = 0;
     $order_info['create_time'] = NOW_TIME;
     if ($consignee_id > 0) {
         $consignee_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id = " . $consignee_id . " and user_id = " . intval($GLOBALS['user_info']['id']));
         if (!$consignee_info && $deal_item['is_delivery'] == 1) {
             showErr("请选择配送方式", 0, get_gopreview());
         }
         $order_info['consignee'] = $consignee_info['consignee'];
         $order_info['zip'] = $consignee_info['zip'];
         $order_info['address'] = $consignee_info['address'];
         $order_info['province'] = $consignee_info['province'];
         $order_info['city'] = $consignee_info['city'];
         $order_info['mobile'] = $consignee_info['mobile'];
     }
     $order_info['is_success'] = $deal_info['is_success'];
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info);
     $order_id = $GLOBALS['db']->insert_id();
     if ($order_id > 0) {
         if ($order_info['credit_pay'] > 0) {
             require_once APP_ROOT_PATH . "system/libs/user.php";
             modify_account(array("money" => "-" . $order_info['credit_pay']), intval($GLOBALS['user_info']['id']), "支持" . $deal_info['name'] . "项目支付");
         }
         $result = pay_order($order_id);
         if ($result['status'] == 0) {
             $money = $result['money'];
             $payment_notice['create_time'] = NOW_TIME;
             $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']);
             $payment_notice['payment_id'] = $payment_id;
             $payment_notice['money'] = $money;
             $payment_notice['bank_id'] = strim($_REQUEST['bank_id']);
             $payment_notice['order_id'] = $order_id;
             $payment_notice['memo'] = $memo;
             $payment_notice['deal_id'] = $deal_info['id'];
             $payment_notice['deal_item_id'] = $deal_item['id'];
             $payment_notice['deal_name'] = $deal_info['name'];
             do {
                 $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                 $notice_id = $GLOBALS['db']->insert_id();
             } while ($notice_id == 0);
             app_redirect(url("cart#jump", array("id" => $notice_id)));
         } elseif ($result['status'] == 1 || $result['status'] == 2) {
             app_redirect(url("account#credit"));
         } else {
             app_redirect(url("account"));
         }
     } else {
         showErr("下单失败", 0, get_gopreview());
     }
 }
 public function update()
 {
     B('FilterString');
     $data = M(MODULE_NAME)->create();
     switch ($data['status']) {
         case 0:
             $action = 'wait';
             break;
         case 1:
             $action = 'success';
             break;
         case 2:
             $action = 'failed';
             break;
         case 3:
             $action = 'waitpay';
             break;
         case 4:
             $action = 'reback';
             break;
         default:
             $action = 'index';
             break;
     }
     // 更新数据
     $list = M(MODULE_NAME)->save($data);
     if ($list > 0) {
         $sdata['update_time'] = TIME_UTC;
         $sdata['id'] = $data['id'];
         M(MODULE_NAME)->save($sdata);
         //成功提示
         $vo = M(MODULE_NAME)->where("id=" . $data['id'])->find();
         $user_id = $vo['user_id'];
         $user_info = M("User")->where("id=" . $user_id)->find();
         require_once APP_ROOT_PATH . "/system/libs/user.php";
         if ($data['status'] == 1) {
             //提现
             modify_account(array("lock_money" => -$vo['money']), $vo['user_id'], "提现成功", 8);
             modify_account(array("lock_money" => -$vo['fee']), $vo['user_id'], "提现成功", 9);
             $content = "您于" . to_date($vo['create_time'], "Y年m月d日 H:i:s") . "提交的" . format_price($vo['money']) . "提现申请汇款成功,请查看您的资金记录。";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 6;
             $msg_data['content'] = $content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 6;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
             //短信通知
             if (app_conf("SMS_ON") == 1) {
                 $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_CARYY_SUCCESS_SMS'");
                 $tmpl_content = $tmpl['content'];
                 $notice['user_name'] = $user_info["user_name"];
                 $notice['carry_money'] = $vo['money'];
                 $notice['site_name'] = app_conf("SHOP_TITLE");
                 $GLOBALS['tmpl']->assign("notice", $notice);
                 $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                 $msg_data['dest'] = $user_info['mobile'];
                 $msg_data['send_type'] = 0;
                 $msg_data['title'] = "提现成功短信提醒";
                 $msg_data['content'] = addslashes($msg);
                 $msg_data['send_time'] = 0;
                 $msg_data['is_send'] = 0;
                 $msg_data['create_time'] = TIME_UTC;
                 $msg_data['user_id'] = $user_info['id'];
                 $msg_data['is_html'] = $tmpl['is_html'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                 //插入
             }
         } elseif ($data['status'] == 2) {
             //驳回
             modify_account(array("money" => $vo['money'], "lock_money" => -$vo['money']), $vo['user_id'], "提现失败", 8);
             modify_account(array("money" => $vo['fee'], "lock_money" => -$vo['fee']), $vo['user_id'], "提现失败", 9);
             $content = "您于" . to_date($vo['create_time'], "Y年m月d日 H:i:s") . "提交的" . format_price($vo['money']) . "提现申请被我们驳回,驳回原因\"" . $data['msg'] . "\"";
             $group_arr = array(0, $user_id);
             sort($group_arr);
             $group_arr[] = 7;
             $msg_data['content'] = $content;
             $msg_data['to_user_id'] = $user_id;
             $msg_data['create_time'] = TIME_UTC;
             $msg_data['type'] = 0;
             $msg_data['group_key'] = implode("_", $group_arr);
             $msg_data['is_notice'] = 7;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
             $id = $GLOBALS['db']->insert_id();
             $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
         }
         save_log("编号为" . $data['id'] . "的提现申请" . L("UPDATE_SUCCESS"), 1);
         //开始验证有效性
         $this->assign("jumpUrl", u(MODULE_NAME . "/" . $action));
         parent::success(L("UPDATE_SUCCESS"));
     } else {
         //错误提示
         $DBerr = M()->getDbError();
         save_log("编号为" . $data['id'] . "的提现申请" . L("UPDATE_FAILED") . $DBerr, 0);
         $this->error(L("UPDATE_FAILED") . $DBerr, 0);
     }
 }
Пример #27
0
 public function use_youhui()
 {
     $s_account_info = es_session::get("account_info");
     if (intval($s_account_info['id']) == 0) {
         $result['status'] = 0;
         $result['info'] = $GLOBALS['lang']['SUPPLIER_LOGIN_FIRST'];
     } else {
         $now = get_gmtime();
         $sn = htmlspecialchars(addslashes(trim($_REQUEST['youhui_sn'])));
         $total_fee = intval(htmlspecialchars(addslashes(trim($_REQUEST['total_fee']))));
         $youhui_log = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui_log where youhui_sn = '" . $sn . "'");
         if ($youhui_log) {
             $sql = "select y.* from " . DB_PREFIX . "youhui as y left join " . DB_PREFIX . "youhui_location_link as l on l.youhui_id = y.id where l.youhui_id = " . $youhui_log['youhui_id'] . " and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")";
             $youhui_info = $GLOBALS['db']->getRow($sql);
             if (!$youhui_info) {
                 $result['status'] = 0;
                 $result['info'] = $GLOBALS['lang']['NO_AUTH'];
                 ajax_return($result);
             }
             if ($youhui_log['confirm_id'] > 0 && $youhui_log['confirm_time'] > 0) {
                 $result['status'] = 0;
                 $result['info'] = sprintf($GLOBALS['lang']['YOUHUI_HAS_USED'], to_date($youhui_log['confirm_time']));
             } else {
                 $youhui_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where id = " . $youhui_log['youhui_id']);
                 if ($youhui_data) {
                     if ($youhui_data['begin_time'] > 0 && $youhui_data['begin_time'] > $now) {
                         $result['status'] = 0;
                         $result['info'] = sprintf($GLOBALS['lang']['YOUHUI_NOT_BEGIN'], to_date($youhui_data['begin_time']));
                     } elseif ($youhui_data['end_time'] > 0 && $youhui_data['end_time'] < $now) {
                         $result['status'] = 0;
                         $result['info'] = sprintf($GLOBALS['lang']['YOUHUI_HAS_END'], to_date($youhui_data['end_time']));
                     } else {
                         $youhui_log['confirm_id'] = $s_account_info['id'];
                         $youhui_log['confirm_time'] = $now;
                         $youhui_log['total_fee'] = $total_fee;
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_log", $youhui_log, $mode = 'UPDATE', $where = 'id=' . $youhui_log['id'], $querymode = 'SILENT');
                         //更新优惠总金额
                         $youhui_content['total_fee'] = $youhui_data['total_fee'] + $total_fee;
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui", $youhui_content, $mode = 'UPDATE', $where = 'id=' . $youhui_data['id'], $querymode = 'SILENT');
                         require_once APP_ROOT_PATH . "system/libs/user.php";
                         $data = array("money" => $youhui_data['return_money'], "score" => $youhui_data['return_score'], "point" => $youhui_data['return_point']);
                         modify_account($data, $youhui_log['user_id'], $youhui_data['name'] . "已验证消费");
                         $result['status'] = 1;
                         $youhui_log['youhui_data'] = $youhui_data;
                         $result['data'] = $youhui_log;
                     }
                 } else {
                     $result['status'] = 0;
                     $result['info'] = $GLOBALS['lang']['YOUHUI_INVALID'];
                 }
             }
         } else {
             $result['status'] = 0;
             $result['info'] = $GLOBALS['lang']['YOUHUI_SN_INVALID'];
         }
         ajax_return($result);
     }
 }
Пример #28
0
/**
 * 生成会员数据
 * @param $user_data  提交[post或get]的会员数据
 * @param $mode  处理的方式,注册或保存
 * 返回:data中返回出错的字段信息,包括field_name, 可能存在的field_show_name 以及 error 错误常量
 * 不会更新保存的字段为:score,money,verify,pid
 */
function save_user($user_data, $mode = 'INSERT')
{
    //开始数据验证
    $res = array('status' => 1, 'info' => '', 'data' => '');
    //用于返回的数据
    if (trim($user_data['user_name']) == '') {
        $field_item['field_name'] = 'user_name';
        $field_item['error'] = EMPTY_ERROR;
        $res['status'] = 0;
        $res['data'] = $field_item;
        return $res;
    }
    if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where user_name = '" . trim($user_data['user_name']) . "' and id <> " . intval($user_data['id'])) > 0) {
        $field_item['field_name'] = 'user_name';
        $field_item['error'] = EXIST_ERROR;
        $res['status'] = 0;
        $res['data'] = $field_item;
        return $res;
    }
    /**
    		if($GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where email = '".trim($user_data['email'])."' and id <> ".intval($user_data['id']))>0)
    		{
    			$field_item['field_name'] = 'email';
    			$field_item['error']	=	EXIST_ERROR;
    			$res['status'] = 0;
    			$res['data'] = $field_item;
    			return $res;
    		}
    		if(trim($user_data['email'])=='')
    		{
    			$field_item['field_name'] = 'email';
    			$field_item['error']	=	EMPTY_ERROR;
    			$res['status'] = 0;
    			$res['data'] = $field_item;
    			return $res;
    		}
    		if(!check_email(trim($user_data['email'])))
    		{
    			$field_item['field_name'] = 'email';
    			$field_item['error']	=	FORMAT_ERROR;
    			$res['status'] = 0;
    			$res['data'] = $field_item;
    			return $res;
    		}
            **/
    if (intval(app_conf("MOBILE_MUST")) == 1 && trim($user_data['mobile']) == '') {
        $field_item['field_name'] = 'mobile';
        $field_item['error'] = EMPTY_ERROR;
        $res['status'] = 0;
        $res['data'] = $field_item;
        return $res;
    }
    if (!check_mobile(trim($user_data['mobile']))) {
        $field_item['field_name'] = 'mobile';
        $field_item['error'] = FORMAT_ERROR;
        $res['status'] = 0;
        $res['data'] = $field_item;
        return $res;
    }
    //		if($user_data['mobile']!=''&&$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."user where mobile = '".trim($user_data['mobile'])."' and id <> ".intval($user_data['id']))>0)
    //		{
    //			$field_item['field_name'] = 'mobile';
    //			$field_item['error']	=	EXIST_ERROR;
    //			$res['status'] = 0;
    //			$res['data'] = $field_item;
    //			return $res;
    //		}
    //验证扩展字段
    $user_field = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_field");
    foreach ($user_field as $field_item) {
        if ($field_item['is_must'] == 1 && trim($user_data[$field_item['field_name']]) == '') {
            $field_item['error'] = EMPTY_ERROR;
            $res['status'] = 0;
            $res['data'] = $field_item;
            return $res;
        }
    }
    //验证结束开始插入数据
    $user['user_name'] = $user_data['user_name'];
    $user['create_time'] = get_gmtime();
    $user['update_time'] = get_gmtime();
    $user['pid'] = $user_data['pid'];
    if (isset($user_data['province_id'])) {
        $user['province_id'] = intval($user_data['province_id']);
    }
    if (isset($user_data['city_id'])) {
        $user['city_id'] = intval($user_data['city_id']);
    }
    if (isset($user_data['sex'])) {
        $user['sex'] = intval($user_data['sex']);
    }
    $user['my_intro'] = addslashes(trim($user_data['my_intro']));
    if (isset($user_data['byear'])) {
        $user['byear'] = intval($user_data['byear']);
    }
    if (isset($user_data['bmonth'])) {
        $user['bmonth'] = intval($user_data['bmonth']);
    }
    if (isset($user_data['bday'])) {
        $user['bday'] = intval($user_data['bday']);
    }
    if (isset($user_data['is_merchant'])) {
        $user['is_merchant'] = intval($user_data['is_merchant']);
        $user['merchant_name'] = $user_data['merchant_name'];
    }
    if (isset($user_data['is_daren'])) {
        $user['is_daren'] = intval($user_data['is_daren']);
        $user['daren_title'] = $user_data['daren_title'];
    }
    //自动获取会员分组
    if (intval($user_data['group_id']) != 0) {
        $user['group_id'] = $user_data['group_id'];
    } else {
        if ($mode == 'INSERT') {
            //获取默认会员组, 即升级积分最小的会员组
            $user['group_id'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user_group order by score asc limit 1");
        }
    }
    //会员状态
    if (intval($user_data['is_effect']) != 0) {
        $user['is_effect'] = $user_data['is_effect'];
    } else {
        if ($mode == 'INSERT') {
            $user['is_effect'] = app_conf("USER_VERIFY");
        }
    }
    //		$user['email'] = $user_data['email'];
    $user['mobile'] = $user_data['mobile'];
    if ($mode == 'INSERT') {
        $user['code'] = '';
        //默认不使用code, 该值用于其他系统导入时的初次认证
    } else {
        $user['code'] = $GLOBALS['db']->getOne("select code from " . DB_PREFIX . "user where id =" . $user_data['id']);
    }
    if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
        $user['user_pwd'] = md5($user_data['user_pwd'] . $user['code']);
    }
    //载入会员整合
    $integrate_code = trim(app_conf("INTEGRATE_CODE"));
    if ($integrate_code != '') {
        $integrate_file = APP_ROOT_PATH . "system/integrate/" . $integrate_code . "_integrate.php";
        if (file_exists($integrate_file)) {
            require_once $integrate_file;
            $integrate_class = $integrate_code . "_integrate";
            $integrate_obj = new $integrate_class();
        }
    }
    //同步整合
    if ($integrate_obj) {
        if ($mode == 'INSERT') {
            $res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            $user['integrate_id'] = intval($res['data']);
        } else {
            $add_res = $integrate_obj->add_user($user_data['user_name'], $user_data['user_pwd'], $user_data['email']);
            if (intval($add_res['status'])) {
                $GLOBALS['db']->query("update " . DB_PREFIX . "user set integrate_id = " . intval($add_res['data']) . " where id = " . intval($user_data['id']));
            } else {
                if (isset($user_data['user_pwd']) && $user_data['user_pwd'] != '') {
                    $status = $integrate_obj->edit_user($user, $user_data['user_pwd']);
                    if ($status <= 0) {
                        //修改密码失败
                        $res['status'] = 0;
                    }
                }
            }
        }
        if (intval($res['status']) == 0) {
            return $res;
        }
    }
    if ($mode == 'INSERT') {
        $s_api_user_info = es_session::get("api_user_info");
        $user[$s_api_user_info['field']] = $s_api_user_info['id'];
        es_session::delete("api_user_info");
        $where = '';
    } else {
        unset($user['pid']);
        $where = "id=" . intval($user_data['id']);
    }
    if ($GLOBALS['db']->autoExecute(DB_PREFIX . "user", $user, $mode, $where)) {
        if ($mode == 'INSERT') {
            $user_id = $GLOBALS['db']->insert_id();
            $register_money = doubleval(app_conf("USER_REGISTER_MONEY"));
            $register_score = intval(app_conf("USER_REGISTER_SCORE"));
            $register_point = intval(app_conf("USER_REGISTER_POINT"));
            if ($register_money > 0 || $register_score > 0 || $register_point > 0) {
                $user_get['score'] = $register_score;
                $user_get['money'] = $register_money;
                $user_get['point'] = $register_point;
                modify_account($user_get, intval($user_id), "在" . to_date(get_gmtime()) . "注册成功");
            }
        } else {
            $user_id = $user_data['id'];
        }
    }
    $res['data'] = $user_id;
    //开始更新处理扩展字段
    if ($mode == 'INSERT') {
        foreach ($user_field as $field_item) {
            $extend = array();
            $extend['user_id'] = $user_id;
            $extend['field_id'] = $field_item['id'];
            $extend['value'] = $user_data[$field_item['field_name']];
            $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode);
        }
    } else {
        foreach ($user_field as $field_item) {
            $extend = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_extend where user_id=" . $user_id . " and field_id =" . $field_item['id']);
            if ($extend) {
                $extend['value'] = $user_data[$field_item['field_name']];
                $where = 'id=' . $extend['id'];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, $mode, $where);
            } else {
                $extend = array();
                $extend['user_id'] = $user_id;
                $extend['field_id'] = $field_item['id'];
                $extend['value'] = $user_data[$field_item['field_name']];
                $GLOBALS['db']->autoExecute(DB_PREFIX . "user_extend", $extend, "INSERT");
            }
        }
    }
    return $res;
}
Пример #29
0
 public function update_hand_quota()
 {
     $user_name = strim($_REQUEST['user_name']);
     $quota = floatval($_REQUEST['quota']);
     $msg = strim($_REQUEST['msg']);
     $user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where user_name = '" . $user_name . "'");
     if ($user_id > 0) {
         $msg = trim($msg) == '' ? l("ADMIN_MODIFY_ACCOUNT") : trim($msg);
         modify_account(array('quota' => $quota), $user_id, $msg, 13);
         save_log(l("ADMIN_MODIFY_ACCOUNT"), 1);
         $this->success(L("UPDATE_SUCCESS"));
     } else {
         $this->error(L("用户不存在,或用户名输入错误"));
     }
 }
 public function modify_passed()
 {
     $id = intval($_REQUEST['id']);
     if ($id == 0) {
         echo "认证信息不存在";
         exit;
     }
     $credit = D("UserCreditFile")->where("id=" . $id)->find();
     if ($credit == 0) {
         echo "认证信息不存在";
         exit;
     }
     $ispassed = intval($_REQUEST["passed"]);
     $field_array = array("credit_identificationscanning" => "idcardpassed", "credit_contact" => "workpassed", "credit_credit" => "creditpassed", "credit_incomeduty" => "incomepassed", "credit_house" => "housepassed", "credit_car" => "carpassed", "credit_marriage" => "marrypassed", "credit_titles" => "skillpassed", "credit_videoauth" => "videopassed", "credit_mobilereceipt" => "mobiletruepassed", "credit_residence" => "residencepassed", "credit_seal" => "sealpassed");
     $credit_type = load_auto_cache("credit_type");
     $typeinfo = $credit_type['list'][$credit['type']];
     if ($field_array[$credit['type']]) {
         $data[$field_array[$credit['type']]] = $ispassed;
         if ($ispassed == 1) {
             $data[$field_array[$credit['type']] . '_time'] = TIME_UTC;
         } else {
             $data[$field_array[$credit['type']] . '_time'] = 0;
         }
         M('User')->where('id=' . $credit['user_id'])->save($data);
     }
     $u_info = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "user WHERE id=" . $credit['user_id']);
     if ($ispassed > 0) {
         require_once APP_ROOT_PATH . "/system/libs/user.php";
         if ($ispassed == 1) {
             modify_account(array('point' => $typeinfo['point']), $credit['user_id'], $typeinfo['type_name'], 8);
         }
         $content = "您好,您于 " . to_date($credit['create_time'], "Y年m月d日") . " ";
         if ($ispassed == 1) {
             $content .= "在" . app_conf('SHOP_TITLE') . "提交的" . $typeinfo['type_name'] . "信息已经成功通过审核。";
             $user_current_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where id = " . intval($u_info['level_id']));
             $user_level = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_level where point <=" . intval($u_info['point']) . " order by point desc");
             if ($user_current_level['point'] < $user_level['point']) {
                 $u_info['level_id'] = intval($user_level['id']);
                 $GLOBALS['db']->query("update " . DB_PREFIX . "user set level_id = " . $u_info['level_id'] . " where id = " . $u_info['id']);
                 $pm_title = "您已经成为" . $user_level['name'] . "";
                 $pm_content = "恭喜您,您已经成为" . $user_level['name'] . "。";
                 require_once APP_ROOT_PATH . "/app/Lib/common.php";
                 send_user_msg($pm_title, $pm_content, 0, $u_info['id'], TIME_UTC, 0, true, true);
                 $user_current_level['name'] = $user_level['name'];
             }
             $content .= "<br>您目前的信用分数为" . $u_info['point'] . "分(" . $user_current_level['name'] . "级),信用额度为" . $u_info['quota'];
         } else {
             $content .= "在" . app_conf('SHOP_TITLE') . "提交的" . $typeinfo['type_name'] . "信息未能通过审核。";
             $content .= "未能通过的原因是“ " . $_REQUEST['msg'] . " ”";
         }
         $group_arr = array(0, $credit['user_id']);
         sort($group_arr);
         $group_arr[] = intval($ispassed + 1);
         $msg_data['content'] = $content;
         $msg_data['to_user_id'] = $credit['user_id'];
         $msg_data['create_time'] = TIME_UTC;
         $msg_data['type'] = 0;
         $msg_data['group_key'] = implode("_", $group_arr);
         $msg_data['is_notice'] = intval($ispassed + 1);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "msg_box", $msg_data);
         $id = $GLOBALS['db']->insert_id();
         $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set group_key = '" . $msg_data['group_key'] . "_" . $id . "' where id = " . $id);
         $credit_data['status'] = 1;
         $credit_data['passed'] = $ispassed;
         $credit_data['passed_time'] = TIME_UTC;
         $credit_data['msg'] = $_REQUEST['msg'];
         $credit_data['checked'] = intval($_REQUEST['checked']);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "user_credit_file", $credit_data, "UPDATE", "id = " . $credit['id']);
         save_log(l("ADMIN_MODIFY_CREDIT") . ":" . $u_info['user_name'] . " " . $typeinfo['type_name'], 1);
     }
     $this->success(L("UPDATE_SUCCESS"));
 }