Пример #1
0
    void queryWalletAmount()
    {
        JToken result = new JObject();

        Model.Member.Define memberDefine = new Model.Member.Define();

        int memberId;

        int agentId;

        string agentId_s = (req["agentId"] ?? "").ToString();

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentId);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentId);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (req["externalId"] ?? "").ToString();

        var checkExternalIdExit = memberDefine.CheckMemberExternalIdExist(externalId_s, agentId);

        if (checkExternalIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "externalId不存在";
            result["errorCode"] = ApiErrorCodes.NotFindUsername;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        memberId = memberDefine.GetMemberId(externalId_s, agentId);

        decimal walletAmount = memberDefine.GetMemberWalletAmount(memberId);

        result["result"]       = "success";
        result["msg"]          = "查詢完成";
        result["walletAmount"] = walletAmount;
        result["errorcode"]    = 0;

        Response.Write(JsonConvert.SerializeObject(result));
    }
Пример #2
0
    void ForwardGame()
    {
        JToken result = new JObject();

        Model.Member.Define memberDefine = new Model.Member.Define();

        int    memberId;
        string guid;

        int agentId;

        string agentId_s = (req["agentId"] ?? "").ToString();

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentId);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentId);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (req["externalId"] ?? "").ToString();

        var checkExternalIdExit = memberDefine.CheckMemberExternalIdExist(externalId_s, agentId);

        if (checkExternalIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "externalId不存在";
            result["errorCode"] = ApiErrorCodes.NotFindUsername;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        memberId = memberDefine.GetMemberId(externalId_s, agentId);

        guid = Guid.NewGuid().ToString("N");

        Model.Member.Edit edit = new Model.Member.Edit();
        Model.Member.Edit.ForwardGameStruct fg = new Model.Member.Edit.ForwardGameStruct();

        fg.MemberId = memberId;
        fg.Guid     = guid;

        edit.ForwardGameStructHandle(fg);

        JToken jtk = new JObject();

        jtk["agentId"]    = agentId;
        jtk["externalId"] = externalId_s;
        jtk["guid"]       = guid;

        string str = JsonConvert.SerializeObject(jtk);

        byte[] bt = Encoding.UTF8.GetBytes(str);

        string webaddr = Convert.ToBase64String(bt);

        result["result"]     = "success";
        result["errorCode"]  = 0;
        result["agentId"]    = agentId;
        result["externalId"] = externalId_s;
        result["url"]        = "http://192.168.1.131:82/lottery/externalLogin?post=" + webaddr;

        Response.Write(JsonConvert.SerializeObject(result));
    }
Пример #3
0
    void createMember()
    {
        JToken result = new JObject();

        Model.Member.Define memberDefine = new Model.Member.Define();

        int    agentId;
        string externalId;

        int agentLevelId;

        string agentId_s = (req["agentId"] ?? "").ToString();

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentId);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentId);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        agentLevelId = memberDefine.GetMemberLevelId(agentId);

        if (agentLevelId != 7)
        {
            result["result"]    = "fail";
            result["msg"]       = "levelId 錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (req["externalId"] ?? "").ToString();

        var chkExternalIdFmt = memberDefine.UsernameValidate(externalId_s);

        if (chkExternalIdFmt == 1)
        {
            result["result"] = "fail";
            result["msg"]    = "externalId長度必須為4~10";
            result["column"] = "externalId";
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }
        else if (chkExternalIdFmt == 2)
        {
            result["result"] = "fail";
            result["msg"]    = "externalId字元須為英數";
            result["column"] = "externalId";
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var checkExternalIdExist = memberDefine.CheckMemberExternalIdExist(externalId_s, agentId);

        if (checkExternalIdExist == true)
        {
            result["result"]    = "fail";
            result["msg"]       = "externalId重複";
            result["errorcode"] = ApiErrorCodes.UsernameExist;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        externalId = externalId_s;

        Model.Member.Add add            = new Model.Member.Add();
        Model.Member.Add.MemberStruct s = new Model.Member.Add.MemberStruct();
        s.ExternalId = externalId;
        s.AgentId    = agentId;

        add.MemberStructHandle(s);

        result["result"]    = "success";
        result["msg"]       = "新增完成";
        result["errorcode"] = 0;

        Response.Write(JsonConvert.SerializeObject(result));
    }
Пример #4
0
    void oneTimeLinkLogin()
    {
        JToken result = new JObject();

        Model.Member.Define memberDefine = new Model.Member.Define();

        byte[] decbuff = Convert.FromBase64String(Request["post"]);
        var    o       = System.Text.Encoding.UTF8.GetString(decbuff);
        var    json    = JsonConvert.DeserializeObject <JObject>(o);

        int    memberId;
        string ip = glbf.GetClientIP();

        int    agentId;
        string memberGuid;

        string agentId_s = (json["agentId"] ?? "").ToString();

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentId);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentId);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (json["externalId"] ?? "").ToString();

        var checkExternalIdExit = memberDefine.CheckMemberExternalIdExist(externalId_s, agentId);

        if (checkExternalIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "externalId不存在";
            result["errorCode"] = ApiErrorCodes.NotFindUsername;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        memberId   = memberDefine.GetMemberId(externalId_s, agentId);
        memberGuid = memberDefine.GetMemberGuid(memberId);

        string guid_s = (json["guid"] ?? "").ToString();

        if (guid_s != memberGuid)
        {
            result["result"]    = "fail";
            result["msg"]       = "guid錯誤";
            result["errorcode"] = ApiErrorCodes.NotFindUsername;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        Model.Member.Edit memberEdit          = new Model.Member.Edit();
        Model.Member.Edit.MemberLoginStruct s = new Model.Member.Edit.MemberLoginStruct();

        s.MemberId = memberId;
        s.LoginIP  = ip;

        memberEdit.MemberLoginStructHandle(s);


        result["result"] = "success";
        result["msg"]    = "登入成功";

        Response.Redirect("./index");
    }
Пример #5
0
    void depositWalletAmount()
    {
        JToken result = new JObject();

        Model.Member.Define memberDefine = new Model.Member.Define();

        int     memberId;
        decimal memberWalletAmount;

        string  transferType;
        decimal walletDiff;

        int agentId;

        string transferType_s = (req["transferType"] ?? "").ToString();
        string walletAmount_s = (req["walletAmount"] ?? "").ToString();

        string agentId_s = (req["agentId"] ?? "").ToString();

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentId);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentId);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (req["externalId"] ?? "").ToString();

        var checkExternalIdExit = memberDefine.CheckMemberExternalIdExist(externalId_s, agentId);

        if (checkExternalIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "externalId不存在";
            result["errorCode"] = ApiErrorCodes.NotFindUsername;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        memberId           = memberDefine.GetMemberId(externalId_s, agentId);
        memberWalletAmount = memberDefine.GetMemberWalletAmount(memberId);

        bool conversionWalletAmount = decimal.TryParse(walletAmount_s, out walletDiff);

        if (conversionWalletAmount == false)
        {
            result["result"] = "fail";
            result["msg"]    = "金額格式錯誤";
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        bool checkTransferType = Model.Member.Define.TransactionTypesLangMap.ContainsKey(transferType_s);

        if (checkTransferType == false)
        {
            result["result"] = "fail";
            result["msg"]    = "交易型態錯誤";
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }
        transferType = transferType_s;

        if (transferType == Model.Member.Define.TransactionType.Debits)
        {
            if (walletDiff > memberWalletAmount)
            {
                result["result"] = "fail";
                result["msg"]    = "餘額不足";
                Response.Write(JsonConvert.SerializeObject(result));
                return;
            }

            memberWalletAmount -= walletDiff;
        }
        else if (transferType == Model.Member.Define.TransactionType.Deposit)
        {
            memberWalletAmount += walletDiff;
        }

        Model.Member.Edit.BalanceTransferStruct m = new Model.Member.Edit.BalanceTransferStruct();
        Model.Member.Edit edit = new Model.Member.Edit();

        m.MemberId     = memberId;
        m.WalletAmount = memberWalletAmount;

        edit.BalanceTransferStructHandle(m);

        result["result"] = "success";
        result["msg"]    = "交易成功,交易金額為:" + walletDiff.ToString() + ",目前餘額為:" + memberWalletAmount.ToString();

        Response.Write(JsonConvert.SerializeObject(result));
    }
Пример #6
0
    void GetMemberBetForm()
    {
        JToken result = new JObject();

        Model.Member.Define  memberDefine  = new Model.Member.Define();
        Model.BetForm.Define betFormDefine = new Model.BetForm.Define();

        int      agentLevelId;
        int?     l7     = null;
        int?     l1     = null;
        string   status = null;
        DateTime beginDateTime;
        DateTime endDateTime;

        string agentId_s = (req["agentId"] ?? "").ToString();
        int    agentIdTemp;

        var chkAgentIdFmt = int.TryParse(agentId_s, out agentIdTemp);

        if (chkAgentIdFmt == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號格式錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var chkAgentIdExit = memberDefine.CheckMemberIdExist(agentIdTemp);

        if (chkAgentIdExit == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "代理帳號不存在";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        l7           = agentIdTemp;
        agentLevelId = memberDefine.GetMemberLevelId(agentIdTemp);

        if (agentLevelId != 7)
        {
            result["result"]    = "fail";
            result["msg"]       = "levelId 錯誤";
            result["errorCode"] = ApiErrorCodes.AgentIdExistFalse;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        string externalId_s = (req["externalId"] ?? "").ToString();

        if (externalId_s != "")
        {
            var checkExternalIdExit = memberDefine.CheckMemberExternalIdExist(externalId_s, agentIdTemp);
            if (checkExternalIdExit == false)
            {
                result["result"]    = "fail";
                result["msg"]       = "externalId不存在";
                result["errorCode"] = ApiErrorCodes.NotFindUsername;
                Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            l1 = memberDefine.GetMemberId(externalId_s, agentIdTemp);
        }

        string status_s = (req["status"] ?? "").ToString();//找狀態

        if (status_s != "")
        {
            var chkStatusExist = Model.BetForm.Define.BetFormStatusLangMap.ContainsKey(status_s);
            if (chkStatusExist == false)
            {
                result["result"]    = "fail";
                result["msg"]       = "status不存在";
                result["errorCode"] = ApiErrorCodes.UsernameFormatError;
                Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            status = status_s;
        }

        string beginDateTime_s = (req["beginDateTime"] ?? "").ToString();
        string endDateTime_s   = (req["endDateTime"] ?? "").ToString();

        if (beginDateTime_s == "" || endDateTime_s == "")
        {
            result["result"]    = "fail";
            result["msg"]       = "日期必須輸入";
            result["errorCode"] = ApiErrorCodes.DateNull;

            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var s = DateTime.TryParse(beginDateTime_s, out beginDateTime);

        if (s == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "beginDateTime格式錯誤";
            result["errorCode"] = ApiErrorCodes.DateTimeError;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var e = DateTime.TryParse(endDateTime_s, out endDateTime);

        if (e == false)
        {
            result["result"]    = "fail";
            result["msg"]       = "endDateTime格式錯誤";
            result["errorCode"] = ApiErrorCodes.DateTimeError;
            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        var i = new TimeSpan(endDateTime.Ticks - beginDateTime.Ticks).TotalMinutes;

        if (i > 30000)
        {
            result["result"]    = "fail";
            result["msg"]       = "日期區間間隔必須小於30分鐘";
            result["errorCode"] = ApiErrorCodes.DateTimeInterval30;

            Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        Model.BetForm.List list = new Model.BetForm.List();
        Model.BetForm.List.BetFormDetailStruct br = new Model.BetForm.List.BetFormDetailStruct();

        br.L7            = l7;
        br.L1            = l1;
        br.Status        = status;
        br.BeginDateTime = beginDateTime;
        br.EndDateTime   = endDateTime;

        var brList = list.BetFormDetailStructHandle(br);

        result["result"]    = 0;
        result["errorCode"] = 0;
        result["msg"]       = "";
        result["list"]      = brList;

        Response.Write(JsonConvert.SerializeObject(result));
    }