Exemplo n.º 1
0
        internal Meituan_reqlog GetMtOrderCrateLogByMtorder(string mtorderid, string code)
        {
            string sql = @"SELECT top 1  *
  FROM  Meituan_reqlog where   req_type=@req_type and mtorderid=@mtorderid and code=@code order by id desc";
            var    cmd = sqlHelper.PrepareTextSqlCommand(sql);

            cmd.AddParam("@req_type", "/meituan-jk/ordercreate.aspx");
            cmd.AddParam("@mtorderid", mtorderid);
            cmd.AddParam("@code", code);
            using (var reader = cmd.ExecuteReader())
            {
                Meituan_reqlog m = null;
                if (reader.Read())
                {
                    m = new Meituan_reqlog
                    {
                        id           = reader.GetValue <int>("id"),
                        reqstr       = reader.GetValue <string>("reqstr"),
                        subtime      = reader.GetValue <string>("subtime"),
                        respstr      = reader.GetValue <string>("respstr"),
                        resptime     = reader.GetValue <string>("resptime"),
                        code         = reader.GetValue <string>("code"),
                        describe     = reader.GetValue <string>("describe"),
                        req_type     = reader.GetValue <string>("req_type"),
                        sendip       = reader.GetValue <string>("sendip"),
                        mtorderid    = reader.GetValue <string>("mtorderid"),
                        ordernum     = reader.GetValue <string>("ordernum"),
                        issecond_req = reader.GetValue <int>("issecond_req"),
                    };
                }
                return(m);
            }
        }
Exemplo n.º 2
0
        private string GetCheckAlive(Meituan_reqlog mlog)
        {
            var response = new MtpApiResponse();

            response.partnerId = agentinfo.mt_partnerId.ConvertTo <int>(0);
            var data = JsonConvert.DeserializeObject <MtpApiRequest>(_requestParam);

            if (data.partnerId == null)
            {
                response.code     = 300;
                response.describe = "Body数据解析失败";
            }
            else
            {
                response.code      = 200;
                response.describe  = "successful";
                response.partnerId = int.Parse(agentinfo.mt_partnerId);
            }

            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 3
0
        //编辑美团日志
        public string EditMTlog_Err(OrderCancelResponse response, Meituan_reqlog mlog, Agent_requestlog reqlog)
        {
            //对历史订单如果有返回300的,美团没有300值进行修改
            if (response.code == 300)
            {
                response.code = 699;
            }
            string json = JsonConvert.SerializeObject(response);

            #region 把处理结果录入数据库
            mlog.respstr  = json;
            mlog.resptime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            mlog.code     = response.code.ToString();
            mlog.describe = response.describe;
            new Meituan_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

            return(json);
        }
Exemplo n.º 4
0
 public int EditReqlog(Meituan_reqlog m)
 {
     using (var helper = new SqlHelper())
     {
         int id = new InternalMeituan_reqlog(helper).EditReqlog(m);
         return(id);
     }
 }
Exemplo n.º 5
0
        private string GetDealNoticeSend(Meituan_reqlog mlog)
        {
            var response = new MtpApiResponse();

            response.partnerId = agentinfo.mt_partnerId.ConvertTo <int>(0);
            try
            {
                var data = JsonConvert.DeserializeObject <MtpDealSendNoticeRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 300;
                    response.describe = "Body数据解析失败";
                }
                else
                {
                    List <MtpDealSendNoticeRequestBody> body = data.body;
                    foreach (MtpDealSendNoticeRequestBody nboy in body)
                    {
                        string partnerDealId      = nboy.partnerDealId;
                        int    status             = nboy.status;
                        int    checkStatus        = nboy.checkStatus;
                        int    msRatioCheckStatus = nboy.msRatioCheckStatus;

                        //产品上线状态:默认未上单
                        int groupbuystatus = 0;
                        if (status == 1)
                        {
                            groupbuystatus = 1;//已上单
                        }
                        //产品上线状态描述
                        string groupbuystatusdesc = EnumUtils.GetName((Meituan_OnlineStatus)status) + ",审核状态:" + EnumUtils.GetName((Meituan_CheckStatus)checkStatus);
                        int    r = new B2b_com_pro_groupbuystocklogData().UpGroupbuystatus(partnerDealId.ConvertTo <int>(0), agentinfo.Id, groupbuystatus, groupbuystatusdesc);

                        response.code      = 200;
                        response.describe  = "successful";
                        response.partnerId = int.Parse(agentinfo.mt_partnerId);
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 300;
                response.describe = "异常错误";
            }
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 6
0
        //编辑日志
        public string EditMTlog_Err(OrderQueryResponse response, Meituan_reqlog mlog)
        {
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 7
0
        ///    拉取库存价格日历
        public string GetPriceList(Meituan_reqlog mlog)
        {
            var response = new PriceResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);
            try
            {
                var data = JsonConvert.DeserializeObject <PriceRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 300;
                    response.describe = "Body数据解析失败";
                }
                else
                {
                    PriceRequestBody body = data.body;

                    //todo 根据请求参数查询产品返回结果
                    string partnerDealId = body.partnerDealId;
                    string startTime     = body.startTime;
                    string endTime       = body.endTime;

                    B2b_com_pro pro = new B2bComProData().GetProById(partnerDealId);
                    if (pro != null)
                    {
                        List <PriceResponseBody> list = new List <PriceResponseBody>();
                        int days = (DateTime.Parse(endTime) - DateTime.Parse(startTime)).Days;
                        //当天不可用
                        if (pro.Iscanuseonsameday == 0)
                        {
                            //当天出票不可用,并且拉取日期是当天,则不返回当天
                            if (startTime == DateTime.Now.ToString("yyyy-MM-dd"))
                            {
                                for (int i = 1; i <= days; i++)
                                {
                                    list.Add(new PriceResponseBody
                                    {
                                        partnerDealId = partnerDealId,
                                        date          = DateTime.Parse(startTime).AddDays(i).ToString("yyyy-MM-dd"),
                                        //暂时美团接口只买票务,其他类型产品先不考虑
                                        marketPrice     = pro.Face_price,
                                        mtPrice         = pro.Advise_price,
                                        settlementPrice = GetSettlementPrice(agentinfo.Id, partnerDealId),
                                        stock           = pro.Ispanicbuy == 0 ? 100000000 : pro.Limitbuytotalnum//库存	无限制 stock = 100000000
                                    });
                                }
                            }
                            else
                            {
                                for (int i = 0; i <= days; i++)
                                {
                                    list.Add(new PriceResponseBody
                                    {
                                        partnerDealId = partnerDealId,
                                        date          = DateTime.Parse(startTime).AddDays(i).ToString("yyyy-MM-dd"),
                                        //暂时美团接口只买票务,其他类型产品先不考虑
                                        marketPrice     = pro.Face_price,
                                        mtPrice         = pro.Advise_price,
                                        settlementPrice = GetSettlementPrice(agentinfo.Id, partnerDealId),
                                        stock           = pro.Ispanicbuy == 0 ? 100000000 : pro.Limitbuytotalnum//库存	无限制 stock = 100000000
                                    });
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i <= days; i++)
                            {
                                list.Add(new PriceResponseBody
                                {
                                    partnerDealId = partnerDealId,
                                    date          = DateTime.Parse(startTime).AddDays(i).ToString("yyyy-MM-dd"),
                                    //暂时美团接口只买票务,其他类型产品先不考虑
                                    marketPrice     = pro.Face_price,
                                    mtPrice         = pro.Advise_price,
                                    settlementPrice = GetSettlementPrice(agentinfo.Id, partnerDealId),
                                    stock           = pro.Ispanicbuy == 0 ? 100000000 : pro.Limitbuytotalnum//库存	无限制 stock = 100000000
                                });
                            }
                        }


                        response.code      = 200;
                        response.describe  = "success";
                        response.partnerId = int.Parse(agentinfo.mt_partnerId);
                        //response.body=new List<PriceResponseBody>

                        response.body = list;
                    }
                    else
                    {
                        response.code     = 300;
                        response.describe = "查询库存价格日历异常.";
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 300;
                response.describe = "异常错误";
            }
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 8
0
        ///     订单退票
        public string Getorderrefund(Meituan_reqlog mlog)
        {
            var response = new OrderCancelResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);
            try
            {
                int organization = agentinfo.Id;
                #region 把分销商发送过来的请求记入数据库日志表2  agent_requestlog
                Agent_requestlog reqlog = new Agent_requestlog()
                {
                    Id                   = 0,
                    Organization         = organization,
                    Encode_requeststr    = "",
                    Decode_requeststr    = _requestParam,
                    Request_time         = DateTime.Now,
                    Encode_returnstr     = "",
                    Decode_returnstr     = "",
                    Return_time          = DateTime.Parse("1970-01-01 00:00:00"),
                    Errmsg               = "",
                    Request_type         = "cancel_order",
                    Req_seq              = "",
                    Ordernum             = "",
                    Is_dealsuc           = 0,
                    Is_second_receivereq = 0,
                    Request_ip           = CommonFunc.GetRealIP()
                };
                int reqlogid = new Agent_requestlogData().Editagent_reqlog(reqlog);
                reqlog.Id = reqlogid;
                #endregion


                var data = JsonConvert.DeserializeObject <OrderCancelRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 699;
                    response.describe = "数据解析失败";
                    return(EditMTlog_Err(response, mlog, reqlog));
                }
                else
                {
                    OrderCancelRequestBody body = data.body;

                    string mtorderid = body.orderId.ToString();
                    string order_num = body.partnerOrderId;
                    int    num       = body.refundQuantity;


                    //日志表2 判断是否是二次发送相同的请求
                    int is_secondreq = new Agent_requestlogData().Is_secondreq(organization.ToString(), mtorderid, reqlog.Request_type);

                    #region 把发送的请求类型,请求流水号,订单号,是否是二次发送相同的请求录入数据库 日志表2
                    reqlog.Req_seq              = mtorderid;
                    reqlog.Ordernum             = order_num;
                    reqlog.Is_second_receivereq = is_secondreq;
                    new Agent_requestlogData().Editagent_reqlog(reqlog);
                    #endregion

                    #region 编辑日志表1
                    mlog.mtorderid    = mtorderid;
                    mlog.ordernum     = order_num;
                    mlog.issecond_req = is_secondreq;
                    new Meituan_reqlogData().EditReqlog(mlog);
                    #endregion

                    if (is_secondreq == 1)
                    {
                        //获取处理成功的请求信息:如果没有则重新操作
                        Agent_requestlog suclog = new Agent_requestlogData().GetAgent_cancelorderlogByReq_seq(organization.ToString(), mtorderid, 1);
                        if (suclog != null)
                        {
                            //return suclog.Decode_returnstr;
                            response = (OrderCancelResponse)JsonConvert.DeserializeObject(suclog.Decode_returnstr, typeof(OrderCancelResponse));

                            reqlog.Is_dealsuc = 1;
                            //reqlog.Ordernum = suclog.Ordernum;

                            mlog.ordernum = suclog.Ordernum;

                            return(EditMTlog_Err(response, mlog, reqlog));
                        }
                        else
                        {
                            return(Cancel_order(reqlog, body, organization.ToString(), mlog));
                        }
                    }
                    else
                    {
                        return(Cancel_order(reqlog, body, organization.ToString(), mlog));
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 699;
                response.describe = "异常错误";

                return(EditMTlog_Err(response, mlog, null));
            }
        }
Exemplo n.º 9
0
        ///     订单支付
        public string Getorderpay(Meituan_reqlog mlog)
        {
            lock (lockobj)
            {
                var response = new OrderPayResponse();
                response.partnerId = int.Parse(agentinfo.mt_partnerId);
                try
                {
                    int organization = agentinfo.Id;
                    #region 把分销商发送过来的请求记入数据库日志表2  agent_requestlog
                    Agent_requestlog reqlog = new Agent_requestlog()
                    {
                        Id                   = 0,
                        Organization         = organization,
                        Encode_requeststr    = "",
                        Decode_requeststr    = _requestParam,
                        Request_time         = DateTime.Now,
                        Encode_returnstr     = "",
                        Decode_returnstr     = "",
                        Return_time          = DateTime.Parse("1970-01-01 00:00:00"),
                        Errmsg               = "",
                        Request_type         = "add_order",
                        Req_seq              = "",
                        Ordernum             = "",
                        Is_dealsuc           = 0,
                        Is_second_receivereq = 0,
                        Request_ip           = CommonFunc.GetRealIP()
                    };
                    int reqlogid = new Agent_requestlogData().Editagent_reqlog(reqlog);
                    reqlog.Id = reqlogid;
                    #endregion


                    var data = JsonConvert.DeserializeObject <OrderPayRequest>(_requestParam);
                    if (data.body == null)
                    {
                        response.code     = 599;
                        response.describe = "Body数据解析失败";
                        return(EditMTlog_Err(response, mlog, reqlog));
                    }
                    else
                    {
                        OrderPayRequestBody body = data.body;

                        string mtorderid = body.orderId.ToString();
                        //如果合作商订单Id不存在,则查询美团订单创建日志
                        if (body.partnerOrderId == "")
                        {
                            Meituan_reqlog mtOrderCrateSucLog = new Meituan_reqlogData().GetMtOrderCrateLogByMtorder(body.orderId.ToString(), "200");
                            body.partnerOrderId = mtOrderCrateSucLog.ordernum;
                        }
                        string order_num = body.partnerOrderId;
                        mlog.mtorderid = body.orderId.ToString();


                        //日志表2 判断是否是二次发送相同的请求
                        int is_secondreq = new Agent_requestlogData().Is_secondreq(organization.ToString(), mtorderid, reqlog.Request_type);

                        #region 把发送的请求类型,请求流水号,订单号,是否是二次发送相同的请求录入数据库 日志表2
                        reqlog.Req_seq              = mtorderid;
                        reqlog.Ordernum             = order_num;
                        reqlog.Is_second_receivereq = is_secondreq;
                        new Agent_requestlogData().Editagent_reqlog(reqlog);
                        #endregion

                        #region 编辑日志表1
                        mlog.mtorderid    = mtorderid;
                        mlog.ordernum     = order_num;
                        mlog.issecond_req = is_secondreq;
                        new Meituan_reqlogData().EditReqlog(mlog);
                        #endregion

                        if (is_secondreq == 1)
                        {
                            //获取处理成功的请求信息:如果没有则重新提单
                            Agent_requestlog suclog = new Agent_requestlogData().GetAgent_addorderlogByReq_seq(organization.ToString(), mtorderid, 1);
                            if (suclog != null)
                            {
                                //return suclog.Decode_returnstr;
                                Meituan_reqlog mtlogg = new Meituan_reqlogData().GetMeituan_Orderpayreqlog(mtorderid, "200");
                                if (mtlogg != null)
                                {
                                    response = (OrderPayResponse)JsonConvert.DeserializeObject(mtlogg.respstr, typeof(OrderPayResponse));

                                    reqlog.Is_dealsuc = 1;
                                    //reqlog.Ordernum = suclog.Ordernum;

                                    mlog.ordernum = suclog.Ordernum;

                                    return(EditMTlog_Err(response, mlog, reqlog));
                                }
                                else
                                {
                                    response.code     = 502;
                                    response.describe = "查询美团支付成功日志失败";
                                    return(EditMTlog_Err(response, mlog, reqlog));
                                }
                            }
                            else
                            {
                                return(pay_order(reqlog, body, organization.ToString(), mlog));
                            }
                        }
                        else
                        {
                            return(pay_order(reqlog, body, organization.ToString(), mlog));
                        }
                    }
                }
                catch (Exception ex)
                {
                    response.code     = 599;
                    response.describe = "异常错误";

                    return(EditMTlog_Err(response, mlog, null));
                }
            }
        }
Exemplo n.º 10
0
        ///     重发电子码
        public string Getorderresend(Meituan_reqlog mlog)
        {
            return("");
            //var response = new VoucherResponse();
            //response.partnerId = int.Parse(agentinfo.mt_partnerId);
            //try
            //{
            //    var data = JsonConvert.DeserializeObject<VoucherRequest>(_requestParam);
            //    if (data.body == null)
            //    {
            //        response.code = 300;
            //        response.describe = "Body数据解析失败";
            //        return EditMTlog_Err(response, mlog);
            //    }
            //    else
            //    {
            //        VoucherRequestBody body = data.body;

            //        string mtorderid = body.bookOrderId;
            //        string ordernum = body.partnerOrderId;

            //        mlog.mtorderid = body.bookOrderId;
            //        mlog.ordernum = body.partnerOrderId;

            //        //根据机构号获得机构(分销商)信息
            //        Agent_company agentcompany = new AgentCompanyData().GetAgentCompanyByName("美团旅游");
            //        if (agentcompany == null)
            //        {
            //            response.code = 300;
            //            response.describe = "不存在 美团旅游 分销账户";
            //            return EditMTlog_Err(response, mlog);
            //        }
            //        int organization = agentcompany.Id;

            //        //判断分销商查询订单是否是 自己发送的接口订单
            //        Agent_requestlog mrequestlogg = new Agent_requestlogData().GetAgent_addorderlogByReq_seq(organization.ToString(), mtorderid);
            //        if (mrequestlogg == null)
            //        {
            //            response.code = 300;
            //            response.describe = "当前查询的订单不存在";
            //            return EditMTlog_Err(response, mlog);
            //        }
            //        if (mrequestlogg.Is_dealsuc == 0)
            //        {
            //            response.code = 300;
            //            response.describe = "当前查询的订单不存在";
            //            return EditMTlog_Err(response, mlog);
            //        }
            //        if (mtorderid.Trim() == "")
            //        {
            //            response.code = 300;
            //            response.describe = "美团订单号 不可为空";
            //            return EditMTlog_Err(response, mlog);
            //        }

            //        string pno = "";

            //        B2b_order morder = new B2bOrderData().GetOrderById(ordernum.ConvertTo<int>(0));
            //        if (morder == null)
            //        {
            //            response.code = 300;
            //            response.describe = "订单查询失败";
            //            return EditMTlog_Err(response, mlog);
            //        }
            //        pno = morder.Pno;

            //        if (morder.Bindingagentorderid > 0)
            //        {
            //            pno = new B2bOrderData().GetPnoByOrderId(morder.Bindingagentorderid);
            //        }

            //        if (pno == "")
            //        {
            //            response.code = 300;
            //            response.describe = "电子码查询失败";
            //            return EditMTlog_Err(response, mlog);
            //        }

            //        var vasmodel = new SendEticketData().SendEticket(ordernum.ConvertTo<int>(0), 2);//重发电子码
            //        if (vasmodel == "OK")
            //        {

            //            response.code = 200;
            //            response.describe = "success";
            //            response.body = new VoucherResponseBody
            //            {
            //                voucherType = (int)Meituan_voucherType.Message,
            //                voucher = pno
            //            };
            //            return EditMTlog_Err(response, mlog);
            //        }
            //        else
            //        {
            //            response.code = 300;
            //            response.describe = "重发电子码失败";
            //            return EditMTlog_Err(response, mlog);
            //        }

            //    }
            //}
            //catch (Exception ex)
            //{
            //    response.code = 300;
            //    response.describe = "查询产品异常";

            //    return EditMTlog_Err(response, mlog);
            //}
        }
Exemplo n.º 11
0
        ///     产品订单创建
        public string Getordercreate(Meituan_reqlog mlog)
        {
            lock (lockobj)
            {
                var response = new OrderCreateResponse();
                response.partnerId = int.Parse(agentinfo.mt_partnerId);
                try
                {
                    var data = JsonConvert.DeserializeObject <OrderCreateRequest>(_requestParam);
                    if (data.body == null)
                    {
                        response.code     = 499;
                        response.describe = "Body数据解析失败";
                        return(EditMTlog_Order(response, mlog));
                    }
                    else
                    {
                        OrderCreateRequestBody body = data.body;

                        string product_num = body.partnerDealId;
                        string num         = body.quantity.ToString();
                        mlog.mtorderid = body.orderId.ToString();

                        //todo 根据请求参数查询产品返回结果
                        B2b_com_pro pro = new B2bComProData().GetProById(product_num);
                        #region 产品信息
                        if (pro != null)
                        {
                            #region 分销授权信息判断
                            Agent_company agentwarrantinfo = AgentCompanyData.GetAgentWarrant(agentinfo.Id, pro.Com_id);

                            if (agentwarrantinfo != null)
                            {
                                int warrantid     = agentwarrantinfo.Warrantid;
                                int Warrant_type  = agentwarrantinfo.Warrant_type;//支付类型分销 1出票扣款 2验码扣款
                                int Warrant_level = agentwarrantinfo.Warrant_level;
                                if (agentwarrantinfo.Warrant_state == 0)
                                {
                                    response.code     = 499;
                                    response.describe = "商户尚未授权此分销";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            else
                            {
                                response.code     = 499;
                                response.describe = "分销还没有得到商户授权";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region 暂时对外接口只支持票务产品
                            if (pro.Server_type != 1)
                            {
                                response.code     = 499;
                                response.describe = "暂时对外接口只支持票务产品,其他产品请到分销后台提单";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region 价格(建议价)效验,保证美团抓到的是最新价格
                            string advice_price = body.unitPrice.ToString("f0");
                            if (pro.Advise_price.ToString("f0") != advice_price)
                            {
                                response.code     = 410;
                                response.describe = "价格(建议价)效验失败,请重新拉取价格库存日历";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region 价格(分销价)效验,保证美团抓到的是最新的结算价
                            if (agentwarrantinfo.Warrant_level == 1)
                            {
                                if (body.buyPrice.ToString("f0") != pro.Agent1_price.ToString("f0"))
                                {
                                    response.code     = 410;
                                    response.describe = "价格(分销价)效验失败,请重新拉取价格库存日历";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            if (agentwarrantinfo.Warrant_level == 2)
                            {
                                if (body.buyPrice.ToString("f0") != pro.Agent2_price.ToString("f0"))
                                {
                                    response.code     = 410;
                                    response.describe = "价格(分销价)效验失败,请重新拉取价格库存日历";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            if (agentwarrantinfo.Warrant_level == 3)
                            {
                                if (body.buyPrice.ToString("f0") != pro.Agent3_price.ToString("f0"))
                                {
                                    response.code     = 410;
                                    response.describe = "价格(分销价)效验失败,请重新拉取价格库存日历";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            #endregion

                            #region 多规格产品编码格式验证
                            int speciid = 0;
                            //判断产品编号是否符合多规格产品特点:例如 2503-1
                            if (product_num.IndexOf("-") > -1)
                            {
                                speciid = product_num.Substring(product_num.IndexOf("-") + 1).ConvertTo <int>(0);
                                if (speciid == 0)
                                {
                                    response.code     = 410;
                                    response.describe = "多规格产品编码格式有误";
                                    return(EditMTlog_Order(response, mlog));
                                }
                                product_num = product_num.Substring(0, product_num.IndexOf("-"));
                            }
                            #endregion

                            #region 产品编码格式有误
                            if (product_num.ConvertTo <int>(0) == 0)
                            {
                                response.code     = 410;
                                response.describe = "产品编码格式有误";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region  购买数量格式有误
                            if (num.ConvertTo <int>(0) == 0)
                            {
                                response.code     = 410;
                                response.describe = "购买数量格式有误";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region  产品限购则需要判断 限购数量 是否足够
                            if (pro.Ispanicbuy != 0)
                            {
                                //最多可购买数量
                                int zuiduo_canbuynum = pro.Limitbuytotalnum;
                                if (int.Parse(num) > zuiduo_canbuynum)
                                {
                                    response.code     = 420;
                                    response.describe = "产品库存不足";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            #endregion

                            #region 产品已暂停
                            if (pro.Pro_state == 0)
                            {
                                response.code     = 421;
                                response.describe = "产品已暂停";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region 产品已过期
                            if (pro.Pro_end < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")))
                            {
                                response.code     = 421;
                                response.describe = "产品已过期";
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion

                            #region   产品是否需要预约:需要预约则最晚预约时间是 游玩前一天的18点
                            if (pro.isneedbespeak == 1)
                            {
                                if (body.travelDate != "")
                                {
                                    DateTime visitdate = DateTime.Parse(body.travelDate);
                                    DateTime bookdate  = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));

                                    //必须提前一天预约
                                    if (bookdate >= visitdate)
                                    {
                                        response.code     = 422;
                                        response.describe = "产品需要提前一天预约";
                                        return(EditMTlog_Order(response, mlog));
                                    }
                                }
                            }
                            #endregion

                            #region  是否有使用限制
                            if (pro.Iscanuseonsameday == 0)//1:当天出票可用 ;2:2小时内出票不可用;0:当天出票不可用
                            {
                                if (body.travelDate != "")
                                {
                                    DateTime visitdate = DateTime.Parse(body.travelDate);//游玩日期:2012-12-12 格式要求:yyyy-MM-dd

                                    DateTime bookdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                                    if (bookdate >= visitdate)
                                    {
                                        response.code     = 422;
                                        response.describe = "预定日期至少在游玩日期之前一天";
                                        return(EditMTlog_Order(response, mlog));
                                    }
                                }
                            }
                            #endregion



                            Meituan_reqlog mtOrderCrateSucLog = new Meituan_reqlogData().GetMtOrderCrateLogByMtorder(body.orderId.ToString(), "200");
                            #region 美团订单成功创建过
                            if (mtOrderCrateSucLog != null)
                            {
                                response.code      = 200;
                                response.describe  = "订单创建成功";
                                response.partnerId = int.Parse(agentinfo.mt_partnerId);
                                response.body      = new OrderCreateResponseBody
                                {
                                    partnerOrderId = mtOrderCrateSucLog.ordernum
                                };

                                mlog.ordernum = mtOrderCrateSucLog.ordernum;
                                return(EditMTlog_Order(response, mlog));
                            }
                            #endregion
                            #region 美团订单没有成功创建过
                            else
                            {
                                int    isInterfaceSub = 1;   //是否是电子票接口提交的订单:0.否;1.是
                                string ordertype      = "1"; //1.出票2.充值
                                int    orderid        = 0;

                                string             real_name   = "";
                                string             mobile      = "";
                                string             use_date    = body.travelDate;
                                List <BaseVisitor> visitorlist = body.visitors;
                                if (visitorlist.Count > 0)
                                {
                                    foreach (BaseVisitor info in visitorlist)
                                    {
                                        if (info != null)
                                        {
                                            real_name = info.name;
                                            mobile    = info.mobile;
                                            break;
                                        }
                                    }
                                }
                                //创建一笔未支付订单
                                string      rdata   = OrderJsonData.CreateNopayOrder(agentinfo.Id, product_num, ordertype, num, real_name, mobile, use_date, isInterfaceSub, out orderid, speciid);
                                XmlDocument retdoc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + rdata + "}");
                                XmlElement  retroot = retdoc.DocumentElement;
                                string      rtype   = retroot.SelectSingleNode("type").InnerText;
                                string      rmsg    = retroot.SelectSingleNode("msg").InnerText;
                                if (rtype == "100")//创建订单成功
                                {
                                    //针对美团因为创建未支付订单 是单写的,所以同时创建一笔wl订单
                                    #region 万龙接口订单
                                    if (pro.Source_type == 3 && pro.Serviceid == 4)
                                    {
                                        try
                                        {
                                            B2b_company commanage = B2bCompanyData.GetAllComMsg(pro.Com_id);
                                            WlGetProInfoDealRequestData wldata = new WlGetProInfoDealRequestData(commanage.B2bcompanyinfo.wl_PartnerId, commanage.B2bcompanyinfo.wl_userkey);

                                            WlDealResponseBody WlDealinfo = wldata.SelectonegetWlProDealData(pro.Service_proid, pro.Com_id);
                                            if (WlDealinfo == null)
                                            {
                                                response.code     = 499;
                                                response.describe = "订单创建失败1";
                                                return(EditMTlog_Order(response, mlog));
                                            }
                                            double toal     = WlDealinfo.marketPrice * int.Parse(num);
                                            string tavedate = "";


                                            var createwlorder = wldata.wlOrderCreateRequest_json(int.Parse(commanage.B2bcompanyinfo.wl_PartnerId), real_name, mobile, orderid.ToString(), product_num.ToString(), WlDealinfo.proID, WlDealinfo.settlementPrice, WlDealinfo.marketPrice, toal, int.Parse(num), tavedate);//

                                            var wlcreate = wldata.wlOrderCreateRequest_data(createwlorder, pro.Com_id);
                                            if (wlcreate.IsSuccess == true)
                                            {
                                                //wl订单创建成功
                                            }
                                            else
                                            {
                                                //return JsonConvert.SerializeObject(new { type = 1, msg = "wl接口创建订单失败1" });
                                                response.code     = 499;
                                                response.describe = "订单创建失败1";
                                                return(EditMTlog_Order(response, mlog));
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            response.code     = 499;
                                            response.describe = "订单创建失败" + ex.Message;
                                            return(EditMTlog_Order(response, mlog));
                                        }
                                    }
                                    #endregion


                                    response.code      = 200;
                                    response.describe  = "订单创建成功";
                                    response.partnerId = int.Parse(agentinfo.mt_partnerId);
                                    response.body      = new OrderCreateResponseBody
                                    {
                                        partnerOrderId = orderid.ToString()
                                    };

                                    mlog.ordernum = orderid.ToString();
                                    return(EditMTlog_Order(response, mlog));
                                }
                                else
                                {
                                    response.code     = 499;
                                    response.describe = "订单创建失败";
                                    return(EditMTlog_Order(response, mlog));
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            response.code     = 421;
                            response.describe = "产品不存在";
                            return(EditMTlog_Order(response, mlog));
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    response.code     = 499;
                    response.describe = "异常错误" + ex;

                    return(EditMTlog_Order(response, mlog));
                }
            }
        }
Exemplo n.º 12
0
        private string pay_order(Agent_requestlog reqlog, OrderPayRequestBody body, string organization, Meituan_reqlog mlog)
        {
            var response = new OrderPayResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);

            string mtorderid      = body.orderId.ToString();
            string partnerOrderId = body.partnerOrderId;
            ////如果合作商订单Id不存在,则查询美团订单创建日志
            //if(partnerOrderId=="")
            //{
            //    Meituan_reqlog mtOrderCrateSucLog = new Meituan_reqlogData().GetMtOrderCrateLogByMtorder(body.orderId.ToString(), "200");
            //    partnerOrderId = mtOrderCrateSucLog.ordernum;
            //}

            string      data    = OrderJsonData.agentorder_shoudongchuli(partnerOrderId.ConvertTo <int>(0));
            XmlDocument retdoc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + data + "}");
            XmlElement  retroot = retdoc.DocumentElement;
            string      type    = retroot.SelectSingleNode("type").InnerText;
            string      msg     = retroot.SelectSingleNode("msg").InnerText;

            if (type == "100")//创建订单成功
            {
                string pno = retroot.SelectSingleNode("pno").InnerText;

                response.code     = 200;
                response.describe = "success";
                response.body     = new OrderPayResponseBody
                {
                    orderId          = body.orderId,
                    partnerOrderId   = partnerOrderId,
                    voucherType      = (int)Meituan_voucherType.multiuse,
                    asyReturnVoucher = false,
                    vouchers         = new string[] { pno },
                    voucherPics      = new string[] {}
                };


                reqlog.Is_dealsuc = 1;
                reqlog.Ordernum   = partnerOrderId;

                mlog.ordernum = partnerOrderId;

                return(EditMTlog_Err(response, mlog, reqlog));
            }
            else//创建订单失败
            {
                if (msg == "预付款不足")
                {
                    response.code     = 501;
                    response.describe = msg;
                }
                else
                {
                    response.code     = 599;
                    response.describe = "支付订单失败:" + msg;
                }
                return(EditMTlog_Err(response, mlog, reqlog));
            }
        }
Exemplo n.º 13
0
        ///     抓POI信息
        public string GetPoiList(Meituan_reqlog mlog)
        {
            var response = new PoiResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);
            try
            {
                var data = JsonConvert.DeserializeObject <PoiRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 300;
                    response.describe = "Body数据解析失败";
                }
                else
                {
                    PoiRequestBody body = data.body;

                    //todo 根据请求参数查询产品返回结果
                    if (body.method.Equals("multi", StringComparison.OrdinalIgnoreCase))
                    {
                        #region 获取列表
                        int totalcount = 0;
                        List <PoiResponseBody> list = new PoiResponseData().GetPoiResponseBody(out totalcount, body.method, body.partnerPoiId, agentinfo);
                        if (list.Count > 0)
                        {
                            response.code      = 200;
                            response.describe  = "success";
                            response.partnerId = int.Parse(agentinfo.mt_partnerId);
                            response.totalSize = totalcount;
                            response.body      = list;
                        }
                        else
                        {
                            response.code     = 300;
                            response.describe = "获取poi失败";
                        }
                        #endregion
                    }
                    else if (body.method.Equals("page", StringComparison.OrdinalIgnoreCase))
                    {
                        int pageindex = body.currentPage, pagesize = body.pageSize;
                        if (pageindex <= 0)
                        {
                            pageindex = 1;
                        }
                        if (pagesize <= 0 || pagesize > 20)
                        {
                            pagesize = 20;
                        }

                        #region 获取列表
                        int totalcount = 0;
                        List <PoiResponseBody> list = new PoiResponseData().GetPoiResponseBody(out totalcount, body.method, body.partnerPoiId, agentinfo, pageindex, pagesize);
                        if (list.Count > 0)
                        {
                            response.code      = 200;
                            response.describe  = "success";
                            response.partnerId = int.Parse(agentinfo.mt_partnerId);
                            response.totalSize = totalcount;
                            response.body      = list;
                        }
                        else
                        {
                            response.code     = 300;
                            response.describe = "获取poi失败";
                        }
                        #endregion
                    }
                    else
                    {
                        response.code     = 300;
                        response.describe = "拉取方式出错";
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 300;
                response.describe = "异常错误";
            }
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 14
0
        private string Cancel_order(Agent_requestlog reqlog, OrderCancelRequestBody body, string organization, Meituan_reqlog mlog)
        {
            var response = new OrderCancelResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);

            string mtorderid = body.orderId.ToString();
            string order_num = body.partnerOrderId;
            string num       = body.refundQuantity.ToString();

            mlog.mtorderid = mtorderid;
            mlog.ordernum  = order_num;

            #region 条件判断
            if (order_num.ConvertTo <int>(0) == 0)
            {
                response.code     = 699;
                response.describe = "订单号格式有误";
                return(EditMTlog_Err(response, mlog, reqlog));
            }

            if (num.ConvertTo <int>(0) == 0)
            {
                response.code     = 606;
                response.describe = "退票张数格式有误";
                return(EditMTlog_Err(response, mlog, reqlog));
            }
            //判断订单是否是当前分销的订单
            bool isselforder = new Agent_requestlogData().Getisselforder(organization, order_num);
            if (isselforder == false)
            {
                response.code     = 699;
                response.describe = "订单并非此分销的订单";
                return(EditMTlog_Err(response, mlog, reqlog));
            }
            #endregion
            B2b_order morder = new B2bOrderData().GetOrderById(order_num.ConvertTo <int>(0));
            if (morder != null)
            {
                if (morder.Pro_id > 0)
                {
                    B2b_com_pro pro = new B2bComProData().GetProById(morder.Pro_id.ToString());
                    if (pro == null)
                    {
                        response.code     = 607;
                        response.describe = "产品不存在";
                        return(EditMTlog_Err(response, mlog, reqlog));
                    }
                    else
                    {
                        if (pro.Source_type == 2)//产品来源:1.系统自动生成2.倒码产品
                        {
                            response.code     = 607;
                            response.describe = "倒码产品不支持接口退票";
                            return(EditMTlog_Err(response, mlog, reqlog));
                        }
                        else
                        {
                            //得到订单的验证方式:0(一码多验);1(一码一验),
                            #region 一码多验 退票 按订单号退票,或者外部接口订单
                            if (morder.yanzheng_method == 0 || pro.Source_type == 3)
                            {
                                string      data    = OrderJsonData.QuitOrder(pro.Com_id, order_num.ConvertTo <int>(0), pro.Id, num.ConvertTo <int>(0), "分销外部接口退票");
                                XmlDocument retdoc  = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + data + "}");
                                XmlElement  retroot = retdoc.DocumentElement;
                                string      type    = retroot.SelectSingleNode("type").InnerText;
                                string      msg     = retroot.SelectSingleNode("msg").InnerText;

                                if (type == "100")//取消订单成功
                                {
                                    response.code     = 200;
                                    response.describe = "success";
                                    response.body     = new OrderCancelResponseBody
                                    {
                                        orderId        = body.orderId,
                                        refundId       = body.refundId,
                                        partnerOrderId = body.partnerOrderId,
                                        requestTime    = reqlog.Request_time.ToString("yyyy-MM-dd HH:mm:ss"),
                                        responseTime   = reqlog.Return_time.ToString("yyyy-MM-dd HH:mm:ss")
                                    };


                                    reqlog.Ordernum   = order_num;
                                    reqlog.Is_dealsuc = 1;


                                    return(EditMTlog_Err(response, mlog, reqlog));
                                }
                                else//取消订单失败
                                {
                                    response.code     = 606;
                                    response.describe = msg;
                                    return(EditMTlog_Err(response, mlog, reqlog));
                                }
                            }
                            #endregion
                            #region 一码一验 ,或非接口产品
                            else
                            {
                                response.code     = 604;
                                response.describe = "订单验码方式不支持";
                                return(EditMTlog_Err(response, mlog, reqlog));
                            }
                            #endregion
                        }
                    }
                }
                else
                {
                    response.code     = 699;
                    response.describe = "订单中产品不存在";
                    return(EditMTlog_Err(response, mlog, reqlog));
                }
            }
            else
            {
                response.code     = 699;
                response.describe = "订单不存在";
                return(EditMTlog_Err(response, mlog, reqlog));
            }
        }
Exemplo n.º 15
0
        ///     产品查询
        public string Getorderquery(Meituan_reqlog mlog)
        {
            var response = new OrderQueryResponse();

            response.partnerId = int.Parse(agentinfo.mt_partnerId);
            try
            {
                var data = JsonConvert.DeserializeObject <OrderQueryRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 399;
                    response.describe = "Body数据解析失败";
                    return(EditMTlog_Err(response, mlog));
                }
                else
                {
                    OrderQueryRequestBody body = data.body;

                    string mtorderid = body.orderId.ToString();
                    //如果合作商订单Id不存在,则查询美团订单创建日志
                    if (body.partnerOrderId == "")
                    {
                        Meituan_reqlog mtOrderCrateSucLog = new Meituan_reqlogData().GetMtOrderCrateLogByMtorder(body.orderId.ToString(), "200");
                        body.partnerOrderId = mtOrderCrateSucLog.ordernum;
                    }
                    string ordernum = body.partnerOrderId;

                    mlog.mtorderid = mtorderid;
                    mlog.ordernum  = ordernum;


                    int organization = agentinfo.Id;

                    //判断分销商查询订单是否是 自己发送的接口订单
                    Agent_requestlog mrequestlogg = new Agent_requestlogData().GetAgent_addorderlogByReq_seq(organization.ToString(), mtorderid);
                    if (mrequestlogg == null)
                    {
                        response.code     = 301;
                        response.describe = "当前查询的订单不存在";
                        return(EditMTlog_Err(response, mlog));
                    }
                    if (mrequestlogg.Is_dealsuc == 0)
                    {
                        response.code     = 301;
                        response.describe = "当前查询的订单不存在";
                        return(EditMTlog_Err(response, mlog));
                    }
                    if (mtorderid.Trim() == "")
                    {
                        response.code     = 301;
                        response.describe = "美团订单号 不可为空";
                        return(EditMTlog_Err(response, mlog));
                    }

                    B2b_order morder = new B2bOrderData().GetOrderByAgentRequestReqSeq(mtorderid);
                    if (morder != null)
                    {
                        if (morder.Pro_id > 0)
                        {
                            B2b_com_pro pro = new B2bComProData().GetProById(morder.Pro_id.ToString());
                            if (pro == null)
                            {
                                response.code     = 399;
                                response.describe = "产品不存在";
                                return(EditMTlog_Err(response, mlog));
                            }
                            else
                            {
                                #region 主要用途 判断是否是商家自己产品,如果为外来接口产品,暂时不售卖
                                //判断产品码来源 (4分销倒过来的产品 1系统自动生成产品  2倒码产品 判断分销是否是 自己发码;3外来接口产品暂时不售卖)
                                int prosourtype = pro.Source_type;
                                //if (prosourtype == 3)//外来接口产品,暂时只有阳光接口产品(需要手机号)
                                //{
                                //    //暂时只售卖商家自己产品,主要是产品有效期 需要另外通过外部接口获取,过于麻烦
                                //    response.code = 301;
                                //    response.describe = "暂时只可查询商家自己产品";
                                //    return EditMTlog_Err(response, mlog);

                                //}
                                if (prosourtype == 4)                                                              //分销导入产品;
                                {
                                    int old_proid = new B2bComProData().GetOldproidById(morder.Pro_id.ToString()); //绑定产品的原始编号
                                    if (old_proid == 0)
                                    {
                                        response.code     = 399;
                                        response.describe = "分销导入产品的原始产品编号没有查到";
                                        return(EditMTlog_Err(response, mlog));
                                    }
                                    else
                                    {
                                        prosourtype = new B2bComProData().GetProSource_typeById(old_proid.ToString());
                                        //if (prosourtype == 3)
                                        //{
                                        //    //暂时只售卖商家自己产品,主要是产品有效期 需要另外通过外部接口获取,过于麻烦
                                        //    response.code = 300;
                                        //    response.describe = "暂时只可查询商家自己产品";
                                        //    return EditMTlog_Err(response, mlog);

                                        //}
                                    }
                                }
                                #endregion

                                #region 产品有效期
                                //经过以上赋值prosourtype,只可能2个值:1系统自动生成码产品;2倒码产品
                                DateTime pro_start = pro.Pro_start;
                                DateTime pro_end   = pro.Pro_end;
                                if (prosourtype == 2) //倒码产品
                                {
                                }
                                if (prosourtype == 1) //系统自动生成码产品
                                {
                                    #region 产品有效期判定(微信模板--门票订单预订成功通知 中也有用到)
                                    string provalidatemethod = pro.ProValidateMethod;
                                    int    appointdate       = pro.Appointdata;
                                    int    iscanuseonsameday = pro.Iscanuseonsameday;

                                    //DateTime pro_end = modelcompro.Pro_end;
                                    if (provalidatemethod == "2")//按指定有效期
                                    {
                                        if (appointdate == (int)ProAppointdata.NotAppoint)
                                        {
                                        }
                                        else if (appointdate == (int)ProAppointdata.OneWeek)
                                        {
                                            pro_end = DateTime.Now.AddDays(7);
                                        }
                                        else if (appointdate == (int)ProAppointdata.OneMonth)
                                        {
                                            pro_end = DateTime.Now.AddMonths(1);
                                        }
                                        else if (appointdate == (int)ProAppointdata.ThreeMonth)
                                        {
                                            pro_end = DateTime.Now.AddMonths(3);
                                        }
                                        else if (appointdate == (int)ProAppointdata.SixMonth)
                                        {
                                            pro_end = DateTime.Now.AddMonths(6);
                                        }
                                        else if (appointdate == (int)ProAppointdata.OneYear)
                                        {
                                            pro_end = DateTime.Now.AddYears(1);
                                        }

                                        //如果指定有效期大于产品有效期,则按产品有效期
                                        if (pro_end > pro.Pro_end)
                                        {
                                            pro_end = pro.Pro_end;
                                        }
                                    }
                                    else //按产品有效期
                                    {
                                        pro_end = pro.Pro_end;
                                    }

                                    //DateTime pro_start = modelcompro.Pro_start;
                                    DateTime nowday = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                                    if (iscanuseonsameday == 1) //当天可用
                                    {
                                        if (nowday < pro_start) //当天日期小于产品起始日期
                                        {
                                            pro_start = pro.Pro_start;
                                        }
                                        else
                                        {
                                            pro_start = nowday;
                                        }
                                    }
                                    else //当天不可用
                                    {
                                        if (nowday < pro_start)//当天日期小于产品起始日期
                                        {
                                            pro_start = pro.Pro_start;
                                        }
                                        else
                                        {
                                            pro_start = nowday.AddDays(1);
                                        }
                                    }
                                    #endregion
                                }
                                #endregion

                                #region  购买数量   可使用数量  使用数量 退票数量 出票时间 电子票号(列表)

                                string all_pno     = ""; //全部电子码
                                string keyong_pno  = ""; //可用电子码
                                string add_time    = morder.U_subdate.ToString("yyyy-MM-dd HH:mm:ss");
                                int    buy_num     = 0;
                                int    keyong_num  = 0;
                                int    consume_num = 0;
                                int    tuipiao_num = morder.Cancelnum;

                                if (prosourtype == 1)//系统自动生成码产品
                                {
                                    int noworderid = morder.Id;
                                    //判断是否含有绑定订单
                                    if (morder.Bindingagentorderid > 0)
                                    {
                                        noworderid = morder.Bindingagentorderid;
                                    }

                                    //根据订单号得到电子票信息
                                    List <B2b_eticket> meticketlist = new B2bEticketData().GetEticketListByOrderid(noworderid);
                                    if (meticketlist == null)
                                    {
                                        response.code     = 302;
                                        response.describe = "根据订单号查询电子票信息失败";
                                        return(EditMTlog_Err(response, mlog));
                                    }
                                    else
                                    {
                                        if (meticketlist.Count == 0)
                                        {
                                            response.code     = 302;
                                            response.describe = "根据订单号查询电子票信息失败";
                                            return(EditMTlog_Err(response, mlog));
                                        }
                                        else
                                        {
                                            foreach (B2b_eticket meticket in meticketlist)
                                            {
                                                if (meticket != null)
                                                {
                                                    buy_num     += meticket.Pnum;
                                                    keyong_num  += meticket.Use_pnum;
                                                    consume_num += meticket.Pnum - meticket.Use_pnum;
                                                    all_pno     += meticket.Pno + ",";
                                                    if (meticket.Use_pnum > 0)
                                                    {
                                                        keyong_pno += meticket.Pno + ",";
                                                    }
                                                }
                                            }
                                            if (all_pno.Length > 0)
                                            {
                                                all_pno = all_pno.Substring(0, all_pno.Length - 1);
                                            }
                                            if (keyong_pno.Length > 0)
                                            {
                                                keyong_pno = keyong_pno.Substring(0, keyong_pno.Length - 1);
                                            }
                                        }
                                    }
                                }
                                else if (prosourtype == 3)
                                {
                                    if (pro.Serviceid == 4)
                                    { //如果是接口产品
                                        B2b_company commanage = B2bCompanyData.GetAllComMsg(pro.Com_id);
                                        WlGetProInfoDealRequestData wldata = new WlGetProInfoDealRequestData(commanage.B2bcompanyinfo.wl_PartnerId, commanage.B2bcompanyinfo.wl_userkey);
                                        var wlorderinfo = wldata.SearchWlOrderData(pro.Com_id, 0, "", morder.Id);
                                        if (wlorderinfo != null)
                                        {
                                            all_pno     = wlorderinfo.vouchers;
                                            buy_num     = wlorderinfo.quantity;
                                            keyong_num  = wlorderinfo.quantity - wlorderinfo.usedQuantity;
                                            consume_num = wlorderinfo.usedQuantity;;
                                        }
                                    }
                                }


                                else //倒码产品
                                {
                                }
                                #endregion

                                #region 实名制类型 真是姓名 状态
                                string real_name_type = pro.Realnametype.ToString();
                                string real_name      = morder.U_name;
                                string statusdesc     = EnumUtils.GetName((OrderStatus)morder.Order_state);
                                #endregion


                                #region 手机号 根据订单号得到 分销商发送接口请求记录
                                string           mobile      = "";
                                Agent_requestlog mrequestlog = new Agent_requestlogData().GetAgent_addorderlogByOrderId(morder.Id.ToString(), 1);
                                if (mrequestlog == null)
                                {
                                    response.code     = 399;
                                    response.describe = "根据订单号获得分销商接口发送请求记录失败";
                                    return(EditMTlog_Err(response, mlog));
                                }
                                #endregion


                                int orderstate = morder.Order_state;
                                //
                                int mt_orderstatus = (int)Meituan_orderStatus.CreateFail;
                                if (orderstate == (int)OrderStatus.HasSendCode)
                                {
                                    mt_orderstatus = (int)Meituan_orderStatus.CreateSuc;
                                }
                                else if (orderstate == (int)OrderStatus.HasUsed)
                                {
                                    mt_orderstatus = (int)Meituan_orderStatus.PaySuc;
                                }
                                else
                                {
                                    if (orderstate == (int)PayStatus.HasPay)
                                    {
                                        mt_orderstatus = (int)Meituan_orderStatus.PaySuc;
                                    }
                                    if (orderstate == (int)PayStatus.NotPay)
                                    {
                                        mt_orderstatus = (int)Meituan_orderStatus.PayFailed;
                                    }
                                    if (orderstate == (int)PayStatus.WaitPay)
                                    {
                                        mt_orderstatus = (int)Meituan_orderStatus.Paying;
                                    }
                                }


                                response.code     = 200;
                                response.describe = "success";


                                /************现在只有一单一码的情况************
                                 * required	凭证状态	见映射表<凭证码状态>
                                 *  0	未使用
                                 * 1	已使用
                                 * 2	已退款
                                 * 3	已废弃 对应的门票还未消费,但是此凭证码作废了
                                 * ************************/
                                List <Voucher> voucherlist = new List <Voucher>();

                                //电子票未使用
                                if (keyong_num == buy_num)
                                {
                                    Voucher vou = new Voucher
                                    {
                                        voucher            = all_pno,
                                        voucherPics        = "",
                                        voucherInvalidTime = morder.U_subdate.ToString("yyyy-MM-dd HH:mm:ss"),
                                        quantity           = keyong_num,
                                        status             = 0
                                    };
                                    voucherlist.Add(vou);
                                }
                                else
                                {
                                    //电子票已使用
                                    if (tuipiao_num == 0)
                                    {
                                        string yanzhengtime = morder.U_subdate.ToString("yyyy-MM-dd HH:mm:ss");
                                        //得到电子票最近的一条验证成功日志
                                        B2b_eticket_log lastyanzhengsuclog = new B2bEticketLogData().GetlastyanzhengsuclogByPno(all_pno);
                                        if (lastyanzhengsuclog != null)
                                        {
                                            yanzhengtime = lastyanzhengsuclog.Actiondate.ToString("yyyy-MM-dd HH:mm:ss");
                                        }
                                        Voucher vou = new Voucher
                                        {
                                            voucher            = all_pno,
                                            voucherPics        = "",
                                            voucherInvalidTime = morder.U_subdate.ToString("yyyy-MM-dd HH:mm:ss"),
                                            quantity           = consume_num,
                                            status             = 1
                                        };
                                        voucherlist.Add(vou);
                                    }
                                    else
                                    {
                                        //电子票退票
                                        if (tuipiao_num != buy_num)
                                        {
                                            Voucher vou = new Voucher
                                            {
                                                voucher            = all_pno,
                                                voucherPics        = "",
                                                voucherInvalidTime = morder.Backtickettime.ToString("yyyy-MM-dd HH:mm:ss"),
                                                quantity           = keyong_num,
                                                status             = 2
                                            };
                                            voucherlist.Add(vou);
                                        }
                                        //电子票废弃
                                        else
                                        {
                                            Voucher vou = new Voucher
                                            {
                                                voucher            = all_pno,
                                                voucherPics        = "",
                                                voucherInvalidTime = morder.Backtickettime.ToString("yyyy-MM-dd HH:mm:ss"),
                                                quantity           = keyong_num,
                                                status             = 3
                                            };
                                            voucherlist.Add(vou);
                                        }
                                    }
                                }



                                response.body = new OrderQueryResponseBody
                                {
                                    orderId          = body.orderId,
                                    partnerOrderId   = body.partnerOrderId,
                                    orderStatus      = mt_orderstatus,
                                    orderQuantity    = morder.U_num,
                                    usedQuantity     = (consume_num - morder.Cancelnum),
                                    refundedQuantity = morder.Cancelnum,
                                    voucherType      = 2,
                                    voucherList      = voucherlist
                                };

                                return(EditMTlog_Err(response, mlog));
                            }
                        }
                        else
                        {
                            response.code     = 301;
                            response.describe = "订单中产品不存在";

                            return(EditMTlog_Err(response, mlog));
                        }
                    }
                    else
                    {
                        response.code     = 301;
                        response.describe = "订单不存在";

                        return(EditMTlog_Err(response, mlog));
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 399;
                response.describe = "异常错误";

                return(EditMTlog_Err(response, mlog));
            }
        }
Exemplo n.º 16
0
        private string GetBalance(Meituan_reqlog mlog)
        {
            var response = new MtpBalanceResponse();

            response.partnerId = agentinfo.mt_partnerId.ConvertTo <int>(0);
            var data = JsonConvert.DeserializeObject <MtpBalanceRequest>(_requestParam);

            if (data.partnerId == 0)
            {
                response.code     = 300;
                response.describe = "Body数据解析失败";
            }
            else
            {
                MtpBalanceRequestBody body = data.body;
                //因为我们系统没有给单个产品授权过额度,所以接收的请求body中产品id不用处理

                //得到分销的授权信息
                List <Agent_warrant> warrantinfolist = new AgentCompanyData().GetAgentWarrantList(agentinfo.Id, "1");
                if (warrantinfolist.Count == 1)
                {
                    //预付款账户余额	单位为分, 非预付款商家, 此值返回-1不要传0
                    int prepaidAccountBalance = -1;
                    //授信账户余额	    单位为分, 无授信账户, 此值返回-1不要传0
                    int creditAccountBalance = -1;
                    foreach (Agent_warrant rinfo in warrantinfolist)
                    {
                        prepaidAccountBalance = int.Parse(rinfo.Imprest.ToString("f0")) == 0 ? -1 : int.Parse(rinfo.Imprest.ToString("f0"));

                        creditAccountBalance = int.Parse(rinfo.Credit.ToString("f0")) == 0 ? -1 : int.Parse(rinfo.Credit.ToString("f0"));
                    }


                    List <MtpBalanceResponseBody> blist = new List <MtpBalanceResponseBody>();
                    if (data.body.partnerDealIds.Length > 0)
                    {
                        foreach (string dealid in data.body.partnerDealIds)
                        {
                            if (dealid != "")
                            {
                                blist.Add(new MtpBalanceResponseBody
                                {
                                    prepaidAccountBalance = prepaidAccountBalance,
                                    creditAccountBalance  = creditAccountBalance,
                                    partnerDealId         = dealid
                                });
                            }
                        }
                    }
                    else
                    {
                        blist.Add(new MtpBalanceResponseBody
                        {
                            prepaidAccountBalance = prepaidAccountBalance,
                            creditAccountBalance  = creditAccountBalance,
                            partnerDealId         = ""
                        });
                    }


                    response.code      = 200;
                    response.describe  = "successful";
                    response.partnerId = int.Parse(agentinfo.mt_partnerId);
                    response.body      = blist;
                }
                else
                {
                    response.code     = 300;
                    response.describe = "分销授权信息有误";
                }
            }

            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 17
0
        ///     抓产品
        public string GetProductList(Meituan_reqlog mlog)
        {
            var response = new DealResponse();

            response.partnerId = agentinfo.mt_partnerId.ConvertTo <int>(0);
            try
            {
                var data = JsonConvert.DeserializeObject <DealRequest>(_requestParam);
                if (data.body == null)
                {
                    response.code     = 300;
                    response.describe = "Body数据解析失败";
                }
                else
                {
                    DealRequestBody body = data.body;

                    //todo 根据请求参数查询产品返回结果
                    if (body.method.Equals("multi", StringComparison.OrdinalIgnoreCase))
                    {
                        #region 获取产品列表
                        int totalcount = 0;
                        List <DealResponseBody> list = new DealResponseData().GetDealResponseBody(out totalcount, agentinfo, body.method, body.partnerDealIds);
                        foreach (DealResponseBody rbody in list)
                        {
                            B2b_com_project pro_project = new B2b_com_projectData().GetProject(rbody.partnerPoiId.ConvertTo <int>(0));
                            if (pro_project != null)
                            {
                                List <ServicePhone> servicePhonelist = new List <ServicePhone>();
                                servicePhonelist.Add(new ServicePhone
                                {
                                    phone     = pro_project.Mobile.Split(' ')[0],
                                    startHour = "08",
                                    startMin  = "00",
                                    endHour   = "17",
                                    endMin    = "00"
                                });
                                //服务电话
                                rbody.servicePhones = servicePhonelist;

                                //入园地址
                                rbody.getInAddresses = new string[] { pro_project.Address };
                            }
                            //结算价
                            Agent_warrant warrant = new Agent_companyData().GetAgentWarrantInfo(agentinfo.Id, rbody.partnerDealId.ConvertTo <int>(0));
                            if (warrant != null)
                            {
                                rbody.settlementPrice = new B2bComProData().GetAgentPrice(rbody.partnerDealId.ConvertTo <int>(0), warrant.Warrant_level);
                            }

                            /*******************************
                             * 产品图片(最多5张)=产品主图片+产品子图片(前4张)
                             * ******************************/
                            List <DealImageInfo> imgs = rbody.dealImageInfos;
                            int        topnum         = 4;
                            List <int> childimgarr    = new B2bComProData().GetProChildImgArr(rbody.partnerDealId.ConvertTo <int>(0), topnum);
                            if (childimgarr.Count > 0)
                            {
                                foreach (int iimg in childimgarr)
                                {
                                    imgs.Add(new DealImageInfo
                                    {
                                        imageName  = "",
                                        imageUrl   = iimg.ToString(),
                                        frontImage = false
                                    });
                                }
                            }

                            foreach (DealImageInfo iinfo in imgs)
                            {
                                var iimgurl = FileSerivce.GetImgUrl(iinfo.imageUrl.ConvertTo <int>(0));
                                iinfo.imageUrl = iimgurl;
                            }
                            rbody.dealImageInfos = imgs;
                        }

                        if (list.Count > 0)
                        {
                            response.code      = 200;
                            response.describe  = "success";
                            response.partnerId = int.Parse(agentinfo.mt_partnerId);
                            response.totalSize = totalcount;
                            response.body      = list;
                        }
                        else
                        {
                            response.code     = 300;
                            response.describe = "获取deal失败";
                        }

                        #endregion
                    }
                    else if (body.method.Equals("page", StringComparison.OrdinalIgnoreCase))
                    {
                        int pageindex = body.currentPage, pagesize = body.pageSize;
                        if (pageindex <= 0)
                        {
                            pageindex = 1;
                        }
                        if (pagesize <= 0 || pagesize > 20)
                        {
                            pagesize = 20;
                        }
                        #region 获取产品列表
                        int totalcount = 0;
                        List <DealResponseBody> list = new DealResponseData().GetDealResponseBody(out totalcount, agentinfo, body.method, body.partnerDealIds, pageindex, pagesize);
                        foreach (DealResponseBody rbody in list)
                        {
                            B2b_com_project pro_project = new B2b_com_projectData().GetProject(rbody.partnerPoiId.ConvertTo <int>(0));
                            if (pro_project != null)
                            {
                                List <ServicePhone> servicePhonelist = new List <ServicePhone>();
                                servicePhonelist.Add(new ServicePhone
                                {
                                    phone     = pro_project.Mobile.Split(' ')[0],
                                    startHour = "08",
                                    startMin  = "00",
                                    endHour   = "17",
                                    endMin    = "00"
                                });
                                //服务电话
                                rbody.servicePhones = servicePhonelist;

                                //入园地址
                                rbody.getInAddresses = new string[] { pro_project.Address };
                            }
                            //结算价
                            Agent_warrant warrant = new Agent_companyData().GetAgentWarrantInfo(agentinfo.Id, rbody.partnerDealId.ConvertTo <int>(0));
                            if (warrant != null)
                            {
                                rbody.settlementPrice = new B2bComProData().GetAgentPrice(rbody.partnerDealId.ConvertTo <int>(0), warrant.Warrant_level);
                            }

                            /*******************************
                             * 产品图片(最多5张)=产品主图片+产品子图片(前4张)
                             * ******************************/
                            List <DealImageInfo> imgs = rbody.dealImageInfos;
                            int        topnum         = 4;
                            List <int> childimgarr    = new B2bComProData().GetProChildImgArr(rbody.partnerDealId.ConvertTo <int>(0), topnum);
                            if (childimgarr.Count > 0)
                            {
                                foreach (int iimg in childimgarr)
                                {
                                    imgs.Add(new DealImageInfo
                                    {
                                        imageName  = "",
                                        imageUrl   = iimg.ToString(),
                                        frontImage = false
                                    });
                                }
                            }

                            foreach (DealImageInfo iinfo in imgs)
                            {
                                var iimgurl = FileSerivce.GetImgUrl(iinfo.imageUrl.ConvertTo <int>(0));
                                iinfo.imageUrl = iimgurl;
                            }
                            rbody.dealImageInfos = imgs;
                        }

                        if (list.Count > 0)
                        {
                            response.code      = 200;
                            response.describe  = "success";
                            response.partnerId = int.Parse(agentinfo.mt_partnerId);
                            response.totalSize = totalcount;
                            //response.body = new List<DealResponseBody>();
                            response.body = list;
                        }
                        else
                        {
                            response.code     = 300;
                            response.describe = "获取deal为空";
                        }

                        #endregion
                    }
                    else
                    {
                        response.code     = 300;
                        response.describe = "拉取方式(method:" + body.method + ")出错";
                    }
                }
            }
            catch (Exception ex)
            {
                response.code     = 300;
                response.describe = "异常错误";
            }
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 18
0
        private string GetDealNoticeSend(Meituan_reqlog mlog)
        {
            var response = new MtpApiResponse();

            response.partnerId = agentinfo.mt_partnerId.ConvertTo <int>(0);
            try
            {
                var data = JsonConvert.DeserializeObject <MtpOrderRefundedMessageRequest>(_requestParam.Replace("operator", "operator1"));
                if (data.body == null)
                {
                    response.code     = 300;
                    response.describe = "Body数据解析失败";
                }
                else
                {
                    MtpOrderRefundedMessageRequestBody body = data.body;

                    /*
                     * 把电子票作废,数量清零
                     * 1.根据美团订单号得到系统订单号
                     * 2.根据系统订单号得到电子票
                     * 3.把电子票作废
                     */
                    int sysOrderid = new Meituan_reqlogData().GetSysorderidByMtorderid(body.orderId.ToString());
                    if (sysOrderid == 0)
                    {
                        //把这次操作计入日志文档中
                        LogHelper.RecordSelfLog("Error", "美团重要错误记录", "1--美团订单号:" + body.orderId + ",系统订单号:" + body.partnerOrderId + ",退款流水号:" + body.refundSerialNo + ",凭证码:" + String.Join(",", body.voucherList) + ",单张门票退款金额:" + body.refundPrice + ",已退款消息类型:" + body.refundMessageType + ",退款原因:" + body.reason + ",退款时间:" + body.refundTime + ",退款份数:" + body.count);
                    }
                    else
                    {
                        string pno = new SendEticketData().HuoQuEticketPno(sysOrderid);
                        if (pno == "")
                        {
                            //把这次操作计入日志文档中
                            LogHelper.RecordSelfLog("Error", "美团重要错误记录", "2--美团订单号:" + body.orderId + ",系统订单号:" + body.partnerOrderId + ",退款流水号:" + body.refundSerialNo + ",凭证码:" + String.Join(",", body.voucherList) + ",单张门票退款金额:" + body.refundPrice + ",已退款消息类型:" + body.refundMessageType + ",退款原因:" + body.reason + ",退款时间:" + body.refundTime + ",退款份数:" + body.count);
                        }
                        else
                        {
                            try
                            {
                                string[] pnoarr = pno.Split(',');
                                for (var i = 0; i < pnoarr.Length; i++)
                                {
                                    if (pnoarr[i] != "")
                                    {
                                        //清空电子票数量
                                        int r = new B2bEticketData().ClearPnoNum(pnoarr[i]);
                                    }
                                }
                            }
                            catch { }

                            //把这次操作计入日志文档中
                            LogHelper.RecordSelfLog("Error", "美团重要错误记录", "3--美团订单号:" + body.orderId + ",系统订单号:" + body.partnerOrderId + ",退款流水号:" + body.refundSerialNo + ",凭证码:" + String.Join(",", body.voucherList) + ",单张门票退款金额:" + body.refundPrice + ",已退款消息类型:" + body.refundMessageType + ",退款原因:" + body.reason + ",退款时间:" + body.refundTime + ",退款份数:" + body.count);
                        }
                    }
                }
                response.code      = 200;
                response.describe  = "successful";
                response.partnerId = int.Parse(agentinfo.mt_partnerId);
            }
            catch (Exception ex)
            {
                response.code     = 300;
                response.describe = "异常错误";
            }
            string json = JsonConvert.SerializeObject(response);

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

            return(json);
        }
Exemplo n.º 19
0
        public ReturnResult ProductChangedNotify(DealChangeNotice requestData, int agentcompanyid)
        {
            //测试地址
            //string url = "http://lvyou.meituan.com/rhone-doc/lv/deal/change/notice";
            ////正式地址
            //string url = "http://lvyou.meituan.com/rhone/lv/deal/change/notice";
            string url = "http://lvyou.meituan.com/rhone/mtp/api/deal/change/notice";

            #region  记入日志表
            string         reqip = CommonFunc.GetRealIP();
            Meituan_reqlog mlog  = new Meituan_reqlog
            {
                id                  = 0,
                reqstr              = JsonConvert.SerializeObject(requestData),
                subtime             = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                respstr             = "",
                resptime            = "",
                code                = "",
                describe            = "",
                req_type            = "",
                sendip              = reqip,
                stockagentcompanyid = agentcompanyid
            };
            int logid = new Meituan_reqlogData().EditReqlog(mlog);
            mlog.id = logid;
            #endregion

            ReturnResult result = new ReturnResult
            {
                IsSuccess = false,
            };
            try
            {
                var responseStr = DoRequest(url, JsonConvert.SerializeObject(requestData));
                if (string.IsNullOrEmpty(responseStr))
                {
                    result.Message = "返回数据为空";
                }
                else
                {
                    PushResponseBody responseBody = (PushResponseBody)JsonConvert.DeserializeObject(responseStr, typeof(PushResponseBody));
                    if (responseBody.code == "200" && responseBody.describe == "success")
                    {
                        result.IsSuccess = true;
                        result.Message   = JsonConvert.SerializeObject(responseBody);
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message   = responseBody.describe;
                    }

                    //记录在日志表
                    mlog.code     = responseBody.code;
                    mlog.describe = responseBody.describe;
                }
            }
            catch (Exception ex)
            {
                result.Message = "异常" + ex.Message;
            }

            #region  记录在日志表
            mlog.req_type = "/rhone/lv/deal/change/notice";
            mlog.respstr  = result.Message;
            mlog.resptime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            new Meituan_reqlogData().EditReqlog(mlog);
            #endregion

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


            string date          = System.Web.HttpContext.Current.Request.Headers.Get("Date");
            string PartnerId     = System.Web.HttpContext.Current.Request.Headers.Get("PartnerId");
            string Authorization = System.Web.HttpContext.Current.Request.Headers.Get("Authorization");
            string requestMethod = System.Web.HttpContext.Current.Request.HttpMethod;
            string URI           = System.Web.HttpContext.Current.Request.CurrentExecutionFilePath;
            //authorization 形式: "MWS" + " " + client + ":" + sign;
            string mtSign = Authorization.Substring(Authorization.IndexOf(":") + 1);

            mlog.req_type = URI;

            agentinfo = new AgentCompanyData().GetAgentCompanyByMeituanPartnerId(PartnerId);
            #region 验证是否已经配置美团合作商信息
            if (agentinfo == null)
            {
                var response = new PoiResponse();
                response.partnerId = int.Parse(PartnerId);
                response.code      = 300;
                response.describe  = "分销尚未配置美团合作商信息(合作商PartnerId:" + PartnerId + ")";

                string json = JsonConvert.SerializeObject(response);

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

                LogHelper.RecordSelfLog("Error", "meituan", response.describe);

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

            mlog.stockagentcompanyid = agentinfo.Id;

            #region 签名验证
            string beforeSign = requestMethod + " " + URI + "\n" + date;
            string afterSign  = new MeiTuanInter(agentinfo.mt_partnerId, agentinfo.mt_secret, agentinfo.mt_client).GetSign(beforeSign);
            //判断签名是否正确
            if (afterSign != mtSign)
            {
                var response = new PoiResponse();
                response.partnerId = int.Parse(PartnerId);
                response.code      = 300;
                response.describe  = "签名验证失败";

                string json = JsonConvert.SerializeObject(response);

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

                LogHelper.RecordSelfLog("Error", "meituan", "拉取产品 签名错误 mtSign-" + mtSign + "  meSign-" + afterSign);

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

            string actionResult = GetPoiList(mlog);

            Response.Write(actionResult);
        }
Exemplo n.º 21
0
        internal int EditReqlog(Meituan_reqlog m)
        {
            if (m.id == 0)
            {
                string sql = @"INSERT INTO  [Meituan_reqlog]
                           ([reqstr]
                           ,[subtime]
                           ,[respstr]
                           ,[resptime]
                           ,[code]
                           ,[describe]
                           ,[req_type]
                           ,[sendip]
                           ,mtorderid
                           ,ordernum
                           ,issecond_req,stockagentcompanyid)
                     VALUES
                           (@reqstr 
                           ,@subtime 
                           ,@respstr 
                           ,@resptime 
                           ,@code
                           ,@describe 
                           ,@req_type 
                           ,@sendip
                           ,@mtorderid
                           ,@ordernum
                           ,@issecond_req,@stockagentcompanyid);select @@identity;";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@reqstr", m.reqstr);
                cmd.AddParam("@subtime", m.subtime);
                cmd.AddParam("@respstr", m.respstr);
                cmd.AddParam("@resptime", m.resptime);
                cmd.AddParam("@code", m.code);
                cmd.AddParam("@describe", m.describe);
                cmd.AddParam("@req_type", m.req_type);
                cmd.AddParam("@sendip", m.sendip);

                if (m.mtorderid == null)
                {
                    m.mtorderid = "";
                }
                cmd.AddParam("@mtorderid", m.mtorderid);
                if (m.ordernum == null)
                {
                    m.ordernum = "";
                }
                cmd.AddParam("@ordernum", m.ordernum);
                if (m.issecond_req == null)
                {
                    m.issecond_req = 0;
                }
                cmd.AddParam("@issecond_req", m.issecond_req);
                if (m.stockagentcompanyid == null)
                {
                    m.stockagentcompanyid = 0;
                }
                cmd.AddParam("@stockagentcompanyid", m.stockagentcompanyid);

                object o = cmd.ExecuteScalar();
                return(o == null ? 0 : int.Parse(o.ToString()));
            }
            else
            {
                string sql = @"UPDATE  [Meituan_reqlog]
                               SET [reqstr] = @reqstr 
                                  ,[subtime] = @subtime 
                                  ,[respstr] = @respstr 
                                  ,[resptime] = @resptime 
                                  ,[code] = @code 
                                  ,[describe] = @describe 
                                  ,[req_type] = @req_type 
                                  ,[sendip] = @sendip 
                                  ,mtorderid=@mtorderid
                                  ,ordernum=@ordernum
                                  ,issecond_req=@issecond_req
                                  ,stockagentcompanyid=@stockagentcompanyid
                             WHERE id=@id";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@id", m.id);
                cmd.AddParam("@reqstr", m.reqstr);
                cmd.AddParam("@subtime", m.subtime);

                if (m.respstr == null)
                {
                    m.respstr = "";
                }
                cmd.AddParam("@respstr", m.respstr);
                cmd.AddParam("@resptime", m.resptime);
                cmd.AddParam("@code", m.code);
                cmd.AddParam("@describe", m.describe);
                cmd.AddParam("@req_type", m.req_type);
                cmd.AddParam("@sendip", m.sendip);
                if (m.mtorderid == null)
                {
                    m.mtorderid = "";
                }
                cmd.AddParam("@mtorderid", m.mtorderid);
                if (m.ordernum == null)
                {
                    m.ordernum = "";
                }
                cmd.AddParam("@ordernum", m.ordernum);
                if (m.issecond_req == null)
                {
                    m.issecond_req = 0;
                }
                cmd.AddParam("@issecond_req", m.issecond_req);
                if (m.stockagentcompanyid == null)
                {
                    m.stockagentcompanyid = 0;
                }
                cmd.AddParam("@stockagentcompanyid", m.stockagentcompanyid);

                cmd.ExecuteNonQuery();
                return(m.id);
            }
        }