Exemple #1
0
        //编辑日志
        public string EditLvmamalog_Order(backRefund response, Lvmama_reqlog mlog, Agent_requestlog reqlog)
        {
            string json = JsonConvert.SerializeObject(response);

            #region 把处理结果录入数据库
            mlog.respstr  = json;
            mlog.resptime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            mlog.code     = response.status;
            mlog.describe = response.msg;
            new lvmama_reqlogData().EditReqlog(mlog);
            #endregion

            #region  把处理结果录入分销接口通用日志表
            if (reqlog != null)
            {
                reqlog.Errmsg           = json;
                reqlog.Decode_returnstr = json;
                reqlog.Encode_returnstr = "";
                reqlog.Return_time      = DateTime.Now;

                new Agent_requestlogData().Editagent_reqlog(reqlog);
            }
            #endregion


            if (agentinfo != null)
            {
                var lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);


                //初始的时候没有sign值,等组合后下面生成加密文件
                var discardcodecalljson = lvmamadata.discardcodecall_json(reqlog.Req_seq, agentinfo.Lvmama_uid, agentinfo.Lvmama_password, response.status, "", response.msg);


                #region 签名验证
                string Md5Sign   = lvmamadata.discardcall_codemd5(discardcodecalljson);
                string afterSign = lvmamadata.lumamasign(Md5Sign, agentinfo.Lvmama_Apikey);
                #endregion

                discardcodecalljson.sign = afterSign;

                //异步通知
                AsyncsendsmsEventHandler mydelegate = new AsyncsendsmsEventHandler(AsyncSendSms);
                mydelegate.BeginInvoke(discardcodecalljson, agentinfo, new AsyncCallback(CompletedSendSms), null);
            }


            return(json);
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 记入日志表LVmama_reqlog
            string        reqip = CommonFunc.GetRealIP();
            Lvmama_reqlog mlog  = new Lvmama_reqlog
            {
                id                  = 0,
                reqstr              = _requestParam,
                subtime             = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                respstr             = "",
                resptime            = "",
                code                = "",
                describe            = "",
                req_type            = "sms_resend",
                sendip              = reqip,
                stockagentcompanyid = 0
            };
            int logid = new lvmama_reqlogData().EditReqlog(mlog);
            mlog.id = logid;
            #endregion

            var data = JsonConvert.DeserializeObject <sms_resendmodel>(_requestParam);
            if (data == null)
            {
                return;
            }
            try
            {
                uid      = data.uid;
                password = data.password;


                string timestamp = data.timestamp;
                string sign      = data.sign;
                string extId     = data.extId;


                agentinfo = new AgentCompanyData().GetAgentCompanyByLvmamaPartnerId(uid);

                LVMAMA_Data lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);


                #region 验证是否已经配置驴妈妈合作商信息
                if (agentinfo == null)
                {
                    var response = new apply_codeRefund();
                    response.uid     = uid;
                    response.orderId = "0";
                    response.status  = "2";
                    response.msg     = "分销尚未配置驴妈妈商信息(uid:" + uid + ")";

                    string json = JsonConvert.SerializeObject(response);

                    //把处理结果录入日志
                    mlog.respstr  = "";
                    mlog.resptime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    mlog.code     = response.status;
                    mlog.describe = response.msg;
                    new lvmama_reqlogData().EditReqlog(mlog);
                    LogHelper.RecordSelfLog("Error", "lvmama", response.msg);
                    Response.Write(json);
                    return;
                }
                #endregion


                mlog.stockagentcompanyid = agentinfo.Id;
                mlog.ordernum            = extId;


                #region 签名验证
                string Md5Sign   = lvmamadata.sms_resend_codemd5(data);
                string afterSign = lvmamadata.lumamasign(Md5Sign, agentinfo.Lvmama_Apikey);

                //判断签名是否正确
                if (afterSign != sign)
                {
                    var response = new apply_codeRefund();
                    response.uid     = uid;
                    response.orderId = extId;
                    response.status  = "2";
                    response.msg     = "签名认证失败";

                    string json = JsonConvert.SerializeObject(response);

                    //把处理结果录入日志
                    mlog.respstr  = "";
                    mlog.resptime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    mlog.code     = response.status;
                    mlog.describe = response.msg;
                    new lvmama_reqlogData().EditReqlog(mlog);

                    LogHelper.RecordSelfLog("Error", "lvmama", "签名错误 lvmamamSign-" + sign + "  meSign-" + afterSign);

                    Response.Write(json);
                    return;
                }
                #endregion

                string actionResult = Smsresend(mlog, agentinfo);

                Response.Write(actionResult);
            }
            catch (Exception ex)
            {
                // Response.Write(ex);
            }
        }
Exemple #3
0
      public static void AsyncSendSms(asynnoticecallback asynnoticecalljson, Agent_company agentinfo)
      {
          var lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);

          var asynnoticecall = lvmamadata.asyConsumeNotify(asynnoticecalljson, agentinfo.Id);
      }
Exemple #4
0
        public static void AsyncSend(string updateurl, string pno, int confirmnum, string confirmtime, int agentcomid, int comidd1, int validateticketlogid, int aorderid)
        {
            Agent_asyncsendlog log = new Agent_asyncsendlog
            {
                Id                = 0,
                Pno               = pno,
                Num               = confirmnum,
                Sendtime          = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                Confirmtime       = DateTime.Parse(confirmtime),
                Issendsuc         = 0,//0失败;1成功
                Agentupdatestatus = (int)AgentUpdateStatus.Fail,
                Agentcomid        = agentcomid,
                Comid             = comidd1,
                Remark            = "",
                Issecondsend      = 0,
                Platform_req_seq  = (1000000000 + agentcomid).ToString() + DateTime.Now.ToString("yyyyMMddhhssmm") + CommonFunc.CreateNum(6),//请求流水号
                Request_content   = "",
                Response_content  = "",
                b2b_etcket_logid  = validateticketlogid
            };
            int inslog = new Agent_asyncsendlogData().EditLog(log);

            log.Id = inslog;
            try
            {
                //获得分销商信息
                Agent_company agentinfo = new AgentCompanyData().GetAgentCompany(agentcomid);
                if (agentinfo != null)
                {
                    string agent_updateurl = agentinfo.Agent_updateurl;

                    #region 糯米分销
                    if (agentinfo.Agent_type == (int)AgentCompanyType.NuoMi)//糯米分销
                    {
                        string re = new GetUrlData().HttpPost(updateurl, "");

                        XmlDocument doc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + re + "}");
                        XmlElement  root = doc.DocumentElement;
                        string      info = root.SelectSingleNode("info").InnerText;

                        //只要返回了数据,则是发送成功
                        log.Id               = inslog;
                        log.Issendsuc        = 1;
                        log.Request_content  = updateurl;
                        log.Response_content = re;

                        if (info == "success")
                        {
                            string errCode = root.SelectSingleNode("res/errCode").InnerText;//分销商更新结果
                            if (errCode == "0")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        else
                        {
                            log.Remark            = info;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                        }
                    }
                    #endregion
                    #region 驴妈妈
                    else if (agentinfo.Agent_type == (int)AgentCompanyType.Lvmama)
                    {
                        /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/


                        Lvmama_reqlog LvmamaOrderCrateSucLog = new lvmama_reqlogData().GetLvmama_OrderpayreqlogBySelforderid(aorderid, "0");


                        if (LvmamaOrderCrateSucLog == null)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }

                        B2b_order morder = new B2bOrderData().GetOrderById(aorderid);
                        if (morder == null)
                        {
                            log.Remark            = "根据订单号查询订单失败.";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }

                        string state = "1";
                        if (morder.U_num > confirmnum)
                        {
                            state = "2";
                        }
                        else if (confirmnum == morder.U_num)
                        {
                            state = "3";
                        }
                        else
                        {
                            state = "1";
                        }



                        var lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);
                        //初始的时候没有sign值,等组合后下面生成加密文件
                        var hexiaojson = lvmamadata.usedticketscallback_json(LvmamaOrderCrateSucLog.mtorderid, agentinfo.Lvmama_uid, agentinfo.Lvmama_password, state, "", DateTime.Now.ToString("yyyyMMddHHmmss"), confirmnum.ToString());

                        #region 签名验证
                        string Md5Sign   = lvmamadata.usedticketscallbackmd5(hexiaojson);
                        string afterSign = lvmamadata.lumamasign(Md5Sign, agentinfo.Lvmama_Apikey);
                        #endregion
                        hexiaojson.sign = afterSign;

                        var asynnoticecall = lvmamadata.useConsumeNotify(hexiaojson, agentinfo.Id);
                        return;
                    }
                    #endregion
                    #region 一般分销
                    else //一般分销
                    {
                        #region 如果是美团分销,则向美团发送验证通知
                        Agent_company mtagentcompany = new AgentCompanyData().GetAgentCompany(agentinfo.Id);
                        if (mtagentcompany != null)
                        {
                            if (mtagentcompany.mt_partnerId != "")
                            {
                                B2b_order      ordermodel  = new B2bOrderData().GetOrderById(aorderid);
                                Meituan_reqlog meituanlogg = new Meituan_reqlogData().GetMt_OrderpayreqlogBySelforderid(ordermodel.Id, "200");
                                if (meituanlogg == null)
                                {
                                    LogHelper.RecordSelfLog("Erro", "meituan", "美团验证通知发送失败:查询美团支付成功订单失败");
                                }
                                else
                                {
                                    #region  订单电子票使用情况
                                    string all_pno     = ""; //全部电子码
                                    string keyong_pno  = ""; //可用电子码
                                    int    buy_num     = 0;
                                    int    keyong_num  = 0;
                                    int    consume_num = 0;
                                    int    tuipiao_num = ordermodel.Cancelnum;
                                    #endregion


                                    string meituancontent = "{" +
                                                            "\"partnerId\": " + mtagentcompany.mt_partnerId + "," +
                                                            "\"body\": " +
                                                            "{" +
                                                            "\"orderId\": " + meituanlogg.mtorderid + "," +
                                                            "\"partnerOrderId\": \"" + aorderid + "\"," +
                                                            "\"quantity\": " + ordermodel.U_num + "," +
                                                            "\"usedQuantity\": " + confirmnum + "," +
                                                            "\"refundedQuantity\": " + tuipiao_num + "," +
                                                            "\"voucherList\": " +
                                                            "[{" +
                                                            "\"voucher\":\"" + pno + "\"," +
                                                            "\"voucherPics\":\"\"," +
                                                            "\"voucherInvalidTime\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"," +
                                                            "\"quantity\":" + confirmnum + "," +
                                                            "\"status\":1" + //4.10 凭证码状态:0	未使用;1	已使用;2	已退款;3	已废弃 对应的门票还未消费,但是此凭证码作废了
                                                            "}]" +
                                                            "}" +
                                                            "}";


                                    OrderConsumeNotice mrequest = (OrderConsumeNotice)JsonConvert.DeserializeObject(meituancontent, typeof(OrderConsumeNotice));

                                    ETS2.PM.Service.Meituan.Data.ReturnResult r = new MeiTuanInter(mtagentcompany.mt_partnerId, mtagentcompany.mt_secret, mtagentcompany.mt_client).ConsumeNotify(mrequest, mtagentcompany.Id);
                                }
                            }
                        }
                        #endregion


                        /*根据订单号得到分销商订单请求记录(当前需要得到原订单请求流水号)*/
                        List <Agent_requestlog> listagent_rlog = new Agent_requestlogData().GetAgent_requestlogByOrdernum(aorderid.ToString(), "add_order", "1");
                        if (listagent_rlog == null)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }
                        if (listagent_rlog.Count == 0)
                        {
                            log.Remark            = "根据订单号得到分销商订单请求记录失败.";//单引号替换为'',双引号不用处理;
                            log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                            new Agent_asyncsendlogData().EditLog(log);
                            return;
                        }


                        /*验证通知发送内容*/
                        string sbuilder = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                        "<business_trans>" +
                                                        "<request_type>sync_order</request_type>" +  //<!--验证同步-->
                                                        "<req_seq>{0}</req_seq>" +                   //<!--原订单请求流水号-->
                                                        "<platform_req_seq>{1}</platform_req_seq>" + //<!--平台请求流水号-->
                                                        "<order>" +                                  //<!--订单信息-->
                                                        "<code>{5}</code>" +                         //<!-- 验证电子码 y-->
                                                        "<order_num>{2}</order_num>" +               //<!-- 订单号 y-->
                                                        "<num>{3}</num>" +                           //<!-- 使用张数 -->
                                                        "<use_time>{4}</use_time>" +                 //<!--  使用时间  -->
                                                        "</order>" +
                                                        "</business_trans>", listagent_rlog[0].Req_seq, log.Platform_req_seq, aorderid, confirmnum, CommonFunc.ConvertDateTimeInt(DateTime.Parse(confirmtime)), pno);

                        #region 分销通知发送方式post
                        if (agentinfo.inter_sendmethod.ToLower() == "post")
                        {
                            string re = "";
                            if (agentcomid == 6490)
                            {
                                re = new GetUrlData().HttpPost(updateurl, sbuilder);

                                updateurl += "?xml=" + sbuilder;//只为记录
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                                re         = new GetUrlData().HttpPost(updateurl, "");
                            }


                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                        #region 分销通知发送方式get
                        else
                        {
                            if (updateurl.IndexOf('?') > -1)
                            {
                                updateurl += "&xml=" + sbuilder;
                            }
                            else
                            {
                                updateurl += "?xml=" + sbuilder;
                            }

                            string re = new GetUrlData().HttpGet(updateurl);
                            //只要返回了数据,则是发送成功
                            log.Id               = inslog;
                            log.Issendsuc        = 1;
                            log.Request_content  = updateurl;
                            log.Response_content = re;

                            log.Remark = re.Replace("'", "''");//单引号替换为'',双引号不用处理;
                            if (re.Length >= 7)
                            {
                                re = re.Substring(0, 7);
                            }
                            if (re == "success")
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Suc;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                            else
                            {
                                log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                                new Agent_asyncsendlogData().EditLog(log);
                            }
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    log.Remark            = "分销商获取失败";
                    log.Agentupdatestatus = (int)AgentUpdateStatus.Fail;
                    new Agent_asyncsendlogData().EditLog(log);
                }
            }
            catch (Exception e)
            {
                log.Id     = inslog;
                log.Remark = e.Message.Replace("'", "''");//单引号替换为'',双引号不用处理
                new Agent_asyncsendlogData().EditLog(log);
            }
        }
Exemple #5
0
        public static void AsyncSendSms(discardcodecallbackmodel discardcodecalljson, Agent_company agentinfo)
        {
            var lvmamadata = new LVMAMA_Data(agentinfo.Lvmama_uid, agentinfo.Lvmama_password, agentinfo.Lvmama_Apikey);

            var asynnoticecall = lvmamadata.discardcodecallbacksend(discardcodecalljson, agentinfo.Id);
        }