Ejemplo n.º 1
0
 public function doMobileEditMember()
 {
     global $_GPC, $_W;
     $sql = "select uid from " . tablename('mc_mapping_fans') . " where openid='{$_GPC['openid']}'";
     $_GPC['uid'] = pdo_fetchcolumn($sql);
     $sql = "select * from " . tablename('fl_dkf_column') . " where weid={$_W['weid']}";
     if (pdo_fetchall($sql)) {
         $sql = "select * from " . tablename('fl_dkf_column') . " where weid={$_W['weid']} and is_show=1 and is_edit=1";
     } else {
         $sql = "select * from " . tablename('fl_dkf_column') . " where weid=0 and is_show=1 and is_edit=1";
     }
     $column = pdo_fetchall($sql);
     foreach ($column as $key => $value) {
         if (isset($_GPC[$value['column_name']])) {
             $data[$value['column_name']] = $_GPC[$value['column_name']];
         }
     }
     pdo_begin();
     pdo_update('mc_members', $data, array("uid" => $_GPC['uid']));
     $sql = "select * from " . tablename('fl_dkf_member_log') . " where uid={$_GPC['uid']} limit 1";
     pdo_fetch($sql);
     $inserArr['create_time'] = time();
     $inserArr['uid'] = $_GPC['uid'];
     $inserArr['kefu_name'] = 'system';
     if (!pdo_fetch($sql)) {
         $sql = "select * from " . tablename('mc_members') . " where uid={$_GPC['uid']} limit 1";
         $old_member = pdo_fetch($sql);
         foreach ($old_member as $key => $value) {
             $inserArr[$key] = $value;
         }
         pdo_insert('fl_dkf_member_log', $inserArr);
     }
     foreach ($data as $key => $value) {
         $inserArr[$key] = $value;
     }
     $inserArr['kefu_name'] = $_SESSION['kefu'];
     pdo_insert('fl_dkf_member_log', $inserArr);
     pdo_commit();
     message('更新资料成功!', $this->createMobileUrl('member'), 'success');
 }
Ejemplo n.º 2
0
if ($verify_result || $verify_result2) {
    //验证成功
    echo "success";
    //请不要修改或删除
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //请在这里加上商户的业务逻辑程序代
    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
    //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表
    //商户订单号
    $out_trade_no = $_GPC['out_trade_no'];
    //支付宝交易号
    $trade_no = $_GPC['trade_no'];
    //交易状态
    $trade_status = $_GPC['trade_status'];
    try {
        pdo_begin();
        $order = pdo_fetch("SELECT * FROM " . tablename("uni_payorder") . " WHERE orderid = :orderid", array(":orderid" => $out_trade_no));
        if (empty($order) || $order["status"] == 1) {
            header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no);
            pdo_rollback();
            return;
        }
        if (pdo_update("uni_payorder", array("status" => 1, "pay_time" => TIMESTAMP, "order_no" => $trade_no), array("orderid" => $out_trade_no)) > 0) {
            if (user_credits_update($order["uid"], $order["credittype"], $order["money"], array(2, "充值"))) {
                pdo_commit();
                header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no);
                return;
            }
            pdo_rollback();
        }
        header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no);
Ejemplo n.º 3
0
 public function edit()
 {
     global $_GPC, $_W;
     $id = $_GPC['id'];
     if (checksubmit('edit')) {
         $prize = $_GPC['prize'];
         $prize_validity = $_GPC['prize_validity'];
         if (empty($prize['prize_name'])) {
             return array(false, '奖品名称为空.', $prize);
         }
         if (intval($prize['prize_possibility']) < 0) {
             return array(false, '奖品概率为空.', $prize);
         }
         if (empty($prize['group_id']) || intval($prize['group_id']) <= 0) {
             return array(false, '所属组为空.', $prize);
         }
         if (empty($prize['description'])) {
             return array(false, '使用详情为空.', $prize);
         }
         if (empty($prize['prize_validity'])) {
             return array(false, '有效期不能为这.', $prize);
         }
         $prize['prize_validity'] = strtotime($prize['prize_validity'] . ' 23:59:59');
         if (intval($prize['id']) > 0) {
             //修改
             $prize['update_time'] = TIMESTAMP;
             unset($prize['prize_code']);
             $prize['update_time'] = TIMESTAMP;
             pdo_update('kim_sign_prizes', $prize, array('id' => $id));
             return array(true, '修改成功.', $prize);
         } else {
             if (empty($prize['prize_code'])) {
                 return array(false, '领奖口令为空.', $prize);
             }
             $prize['create_time'] = TIMESTAMP;
             unset($prize['id']);
             $prize['uniacid'] = $_W['uniacid'];
             $codes = explode("\r\n", $prize['prize_code']);
             if (empty($codes)) {
                 return array(false, '领奖口令为空.', $prize);
             }
             $prize['number'] = count($codes);
             pdo_begin();
             pdo_insert('kim_sign_prizes', $prize);
             $p_id = pdo_insertid();
             if ($p_id > 0) {
                 foreach ($codes as $code) {
                     if (empty($code)) {
                         continue;
                     }
                     $record = array('uid' => 0, 'prize_id' => $p_id, 'code' => $code, 'create_time' => TIMESTAMP, 'status' => 0);
                     pdo_insert('kim_sign_prizes_record', $record);
                     if (pdo_insertid() <= 0) {
                         pdo_rollback();
                         return array(false, '添加失败.');
                     }
                 }
                 pdo_commit();
                 return array(true, '添加成功.', $prize);
             }
             pdo_rollback();
             return array(false, '添加失败.');
         }
     }
     if (intval($id) > 0) {
         $sql = 'SELECT * FROM ' . tablename('kim_sign_prizes') . ' WHERE `uniacid`=:uniacid AND `id`=:id';
         $prize = pdo_fetch($sql, array(':uniacid' => $_W['uniacid'], ':id' => $id));
         $prize['record'] = pdo_fetchall('SELECT * FROM ' . tablename('kim_sign_prizes_record') . ' WHERE `prize_id`=:prize_id', array(':prize_id' => $prize['id']));
         return array(true, '', $prize);
     } else {
         $prize['group_id'] = intval($_GPC['group_id']);
         $prize['prize_validity'] = TIMESTAMP;
     }
     return array(true, '', $prize);
 }
Ejemplo n.º 4
0
function buy_package($user, $package_id, $total = 1)
{
    if (empty($user) || empty($user["uid"])) {
        return error(-1, "用户不存在");
    }
    if ($total <= 0) {
        return error(-1, "购买数必须大于1");
    }
    if (empty($user["credit2"]) || doubleval($user["credit2"]) < 0) {
        return error(-1, "用户余额为0无法购买套餐.");
    }
    $group = kim_get_uni_group($package_id);
    if (empty($group)) {
        return error(-1, "模块不存在.");
    }
    $price = doubleval($group["price"]);
    if (intval($user['groupid']) > 0) {
        list($price, $discount) = check_price($price, intval($user['groupid']));
    }
    if (doubleval($user["credit2"]) < $price * $total) {
        return error(-1, "用户余额不足.");
    }
    $st = get_settings();
    $day = 30;
    if (intval($st[package_day]) > 0) {
        $day = intval($st[package_day]);
    }
    $package_price = $price * $total;
    $package_time = $total * $day * 24 * 60 * 60;
    load()->model("account");
    $account = uni_fetch();
    if (empty($account)) {
        return error(-1, "公众号不存在.");
    }
    $settings = uni_setting($account["uniacid"], array('groupdata'));
    $groupData = $settings['groupdata'] ? $settings['groupdata'] : array("endtime" => TIMESTAMP);
    $package_endTime = $package_time;
    if ($groupData["endtime"] - TIMESTAMP > 0) {
        $package_endTime = $groupData["endtime"] - TIMESTAMP + $package_time;
    }
    $old_package = kim_get_uni_group($account["groupid"]);
    try {
        pdo_begin();
        $endtime = date("Y-m-d", TIMESTAMP + $package_endTime);
        load()->model('user');
        $record = array();
        $record['uid'] = $user["uid"];
        $record['endtime'] = $endtime;
        user_update($record);
        $order_record = array("uniacid" => $account["uniacid"], "uid" => $user["uid"], "package" => $package_id, "buy_time" => TIMESTAMP, "expiration_time" => TIMESTAMP + $package_endTime);
        pdo_insert("users_packages", $order_record);
        $record_id = pdo_insertid();
        if ($record_id <= 0) {
            throw new Exception("保存记录失败");
        }
        //VIP时间同步
        $groupData["endtime"] = $groupData["endtime"] < TIMESTAMP ? TIMESTAMP : $groupData["endtime"];
        $old_over_time = date("Y-m-d", $groupData["endtime"]);
        $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
        $log = array(0, sprintf("自动续费: %s 套餐续费,续费前:%s 到期; 续费后:%s 到期", $group["name"], $old_over_time, $new_over_time));
        if (intval($account["groupid"]) != intval($package_id)) {
            $surplus_price = $old_package["price"] * round(($groupData["endtime"] - TIMESTAMP) / 86400);
            $surplus_price = $surplus_price / $day;
            $surplus_time = round($surplus_price / $group["price"]) * $day;
            $package_endTime = $surplus_time * 24 * 60 * 60 + $package_time;
            $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
            $log_text = sprintf("套餐变更: &lt;p&gt;A、原套餐: %s , %s 到期&lt;/p&gt;&lt;p&gt;B、变更后: %s , %s 到期.&lt;/p&gt;", $old_package["name"], $old_over_time, $group["name"], $new_over_time);
            $log = array(0, $log_text);
            if (pdo_update('uni_account', array('groupid' => $package_id), array('uniacid' => $account["uniacid"])) <= 0) {
                throw new Exception("更新套餐失败.");
            }
        }
        $new_groupdata = array('groupdata' => iserializer(array('isexpire' => 1, 'endtime' => TIMESTAMP + $package_endTime, 'oldgroupid' => $old_package['id'], 'is_auto' => 1)));
        if (pdo_update('uni_settings', $new_groupdata, array('uniacid' => $account["uniacid"])) <= 0) {
            throw new Exception("更新套餐失败!");
        }
        $result = user_credits_update($user["uid"], "credit2", -$package_price, $log);
        if (is_error($result)) {
            throw new Exception($result["message"]);
        }
        $_W['account']['groupid'] = $account["uniacid"];
        load()->model('module');
        module_build_privileges();
        pdo_update("users_packages", array("record_id" => $record_id, "status" => 1), array("id" => $record_id));
        pdo_commit();
        return true;
    } catch (Exception $e) {
        pdo_rollback();
        return error(-1, $e->getMessage());
    }
    return error(-1, "错误操作.");
}
Ejemplo n.º 5
0
 /**
  * 链接起来两个人
  */
 public function doMobileCall()
 {
     global $_W, $_GPC;
     $this->prepare_web_config();
     $uniacid = $_W['uniaccount']['uniacid'];
     $openid = $_W['openid'];
     try {
         $this->check_follow();
     } catch (Exception $e) {
         return $this->return_json($e->getCode(), $e->getMessage(), null);
     }
     try {
         //超时会抛出异常 当不存在也会抛出异常
         $relation = $this->fetch_relation_openid();
         if (!empty($this->web_config['pipei_success_me'])) {
             $this->send_text_message($openid, $this->web_config['pipei_success_me']);
         }
         $to = $this->fetch_user_info_by_openid($relation['relation_openid']);
         $over_time = ceil(($relation['expire_time'] - $relation['update_time']) / 60);
         $to['over_minute'] = $over_time;
         return $this->return_json(200, '匹配成功,请关闭此页面,发送消息给公众平台即可与对方聊天', $to);
     } catch (Exception $e) {
         $relation_user = null;
         try {
             $relation_user = $this->fetch_one_relation();
         } catch (Exception $e) {
             $this->log($e->getMessage());
             return $this->return_json($e->getCode(), $e->getMessage(), null);
         }
         $to = $this->fetch_user_info_by_openid($relation_user['openid']);
         try {
             pdo_begin();
             $relation = $this->create_relation($relation_user['openid']);
             // 提醒对方用户,已经被匹配了
             $this->send_text_message($to['openid'], $this->web_config['pipei_success']);
             //将双方的状态改为忙碌
             $this->check_buzy_status($openid);
             $this->check_buzy_status($to['openid']);
             if (!empty($this->web_config['pipei_success_me'])) {
                 $this->send_text_message($openid, $this->web_config['pipei_success_me']);
             }
             pdo_commit();
             $to['over_minute'] = $this->web_config['chat_limit_minute'];
             return $this->return_json(200, '匹配成功,请关闭此页面,发送消息给公众平台即可与对方聊天', $to);
         } catch (Exception $e) {
             $this->log('匹配失败,对方已经被别人匹配到');
             pdo_rollback();
             return $this->return_json($e->getCode(), $e->getMessage(), null);
         }
     }
 }