예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dingdanbll"></param>
        /// <param name="jsonDict"></param>
        /// <param name="context"></param>
        private void GetPayUrl(wx_hotel_dingdan dingdanbll, HttpContext context)
        {
            int ddid = MyCommFun.RequestInt("dingdanidnum");

            if (ddid > 0)
            {
                var dingdan = dingdanbll.GetModel(ddid);
                if (dingdan != null)
                {
                    Model.wx_hotels_info hotelInfo = new wx_hotels_info();
                    int wid = 0;
                    if (dingdan.hotelid != null)
                    {
                        hotelInfo = new BLL.wx_hotels_info().GetModel(dingdan.hotelid.Value);
                        if (hotelInfo.wid != null)
                        {
                            wid = hotelInfo.wid.Value;
                        }
                    }
                    //总花费
                    var dateSpan   = dingdan.leaveTime.Value - dingdan.arriveTime.Value;
                    var totalPrice = dingdan.price.Value * dingdan.orderNum.Value * dateSpan.Days;

                    var port   = WebHelper.GetHostPort();
                    var url    = string.Format("{0}/weixin/KNSHotel/hotel_order_paycallback.aspx", port);
                    var entity = new UnifiedOrderEntity
                    {
                        wid          = wid,
                        total_fee    = totalPrice == null ? 0 : (int)totalPrice,
                        out_trade_no = dingdan.OrderNumber,
                        openid       = dingdan.openid,
                        OrderId      = dingdan.id.ToString(),
                        body         = string.Format("订单编号{2} {3}{1}{0}间", dingdan.orderNum, dingdan.roomType
                                                     , dingdan.OrderNumber, hotelInfo.hotelName),
                        PayModuleID = (int)PayModuleEnum.Hotel,
                        PayComplete = url
                    };

                    entity.Extra.Add("dingdanidnum", ddid.ToString());
                    entity.Extra.Add("openid", dingdan.openid);
                    entity.Extra.Add("hotelid", dingdan.hotelid.ToString());
                    entity.Extra.Add("roomid", dingdan.roomid.ToString());

                    var ticket  = EncryptionManager.CreateIV();
                    var payData = EncryptionManager.AESEncrypt(entity.ToJson(), ticket);

                    context.Response.Write(AjaxResult.Success(PayHelper.GetPayUrl(payData, ticket)));
                }
            }
            else
            {
                context.Response.Write(AjaxResult.Error("获取支付状态失败!"));
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string _action   = MyCommFun.QueryString("myact");
            string username  = MyCommFun.QueryString("username");
            string parssword = MyCommFun.QueryString("parssword");
            string id        = MyCommFun.QueryString("id");

            openid = MyCommFun.QueryString("openid");
            string state = MyCommFun.QueryString("state");

            goodsData = QueryString("goodsData");
            shopid    = MyCommFun.RequestInt("shopid");


            BLL.wx_diancai_dianyuan         dianyuanbll = new BLL.wx_diancai_dianyuan();
            BLL.wx_diancai_dingdan_manage   manage      = new BLL.wx_diancai_dingdan_manage();
            Model.wx_diancai_dingdan_manage managemodel = new Model.wx_diancai_dingdan_manage();


            if (_action == "login")
            {
                if (dianyuanbll.Exists(username, parssword))
                {
                    jsonDict.Add("ret", "ok");
                    jsonDict.Add("content", "登录成功!");

                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                }
                else
                {
                    jsonDict.Add("ret", "fail");
                    jsonDict.Add("content", "密码错误!");

                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                }
            }

            else if (_action == "setstatus")
            {
                //id

                if (manage.Updatestatus(id, state))
                {
                    managemodel = manage.GetModel(MyCommFun.Str2Int(id));
                    BLL.wx_diancai_member menbll = new BLL.wx_diancai_member();
                    if (state == "1")
                    {
                        menbll.Update(managemodel.openid);
                    }
                    if (state == "2")
                    {
                        menbll.Updatefail(managemodel.openid);
                    }

                    jsonDict.Add("ret", "ok");
                    jsonDict.Add("content", "提交成功!");
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                }
            }
            else if (_action == "addcaidan")
            {
                var orderProcessResult = this.ProcessOrder();

                if (!orderProcessResult.IsSuccess)
                {
                    this.jsonDict.Add("ret", "err");
                    this.jsonDict.Add("content", orderProcessResult.Message);
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                    return;
                }

                var order = orderProcessResult.BusinessData as Model.wx_diancai_dingdan_manage;

                if (order != null)
                {
                    //this.jsonDict.Add("ret", "ok");
                    //this.jsonDict.Add("content", orderProcessResult.Message);
                    //this.jsonDict.Add("orderid", order.id.ToString());
                    //this.jsonDict.Add("ordercode", order.orderNumber);
                    //this.jsonDict.Add("openid", openid);
                    //this.jsonDict.Add("payamount", order.payAmount.ToString());
                    //this.jsonDict.Add("shopname", new BLL.wx_diancai_shopinfo().GetModel(this.shopid).hotelName);
                    //this.jsonDict.Add("wid", order.wid.ToString());
                    //this.jsonDict.Add("orderNumber", order.orderNumber);
                    //context.Response.Write(MyCommFun.getJsonStr(this.jsonDict));

                    var shopInfo = new BLL.wx_diancai_shopinfo().GetModel(this.shopid);
                    var entity   = new UnifiedOrderEntity
                    {
                        OrderId      = order.id.ToString(),
                        wid          = order.wid,
                        total_fee    = order.payAmount == null ? 0 : (int)order.payAmount,
                        out_trade_no = order.orderNumber,
                        openid       = openid,
                        body         = string.Format("订单编号{0} {1}", order.orderNumber, shopInfo.hotelName),
                        PayModuleID  = (int)PayModuleEnum.Restaurant,
                        PayComplete  = "../restaurant/AfterPay.aspx"
                    };

                    entity.Extra.Add("content", orderProcessResult.Message);
                    entity.Extra.Add("shopname", new BLL.wx_diancai_shopinfo().GetModel(this.shopid).hotelName);
                    entity.Extra.Add("shopid", shopid.ToString());
                    entity.Extra.Add("wid", shopInfo.wid.ToString());

                    var ticket  = EncryptionManager.CreateIV();
                    var payData = EncryptionManager.AESEncrypt(entity.ToJson(), ticket);

                    context.Response.Write(AjaxResult.Success(PayHelper.GetPayUrl(payData, ticket)));
                }

                context.Response.End();
            }
            else if (_action == "productDetail")
            {
                var productId = MyCommFun.QueryString("productId");


                if (!string.IsNullOrEmpty(productId))
                {
                    var    model    = new BLL.wx_diancai_caipin_manage().GetModel(int.Parse(productId));
                    String useRange = string.Empty;
                    if (model.beginDate.HasValue || model.endDate.HasValue)
                    {
                        useRange = string.Format("{0}至{1}",
                                                 model.beginDate.HasValue ? model.beginDate.Value.ToString("yyyy-MM-dd") : string.Empty,
                                                 model.endDate.HasValue ? model.endDate.Value.ToString("yyyy-MM-dd") : string.Empty);
                    }
                    var data = new
                    {
                        shopIntroduction = model.shopIntroduction,
                        detailContent    = model.detailContent,
                        instructions     = model.instructions,
                        chargeback       = model.chargeback,
                        useRange         = useRange
                    };
                    context.Response.Write(AjaxResult.Success(data).ToCamelString());
                }

                context.Response.End();
            }
            else if (_action == "caipinDetail")
            {
                var caipinId    = MyCommFun.RequestInt("caipinId");
                var caipinModel = new BLL.wx_diancai_caipin_manage().GetModel(caipinId);

                String useRange = string.Empty;
                if (caipinModel.beginDate.HasValue || caipinModel.endDate.HasValue)
                {
                    useRange = string.Format("{0}至{1}",
                                             caipinModel.beginDate.HasValue ? caipinModel.beginDate.Value.ToString("yyyy-MM-dd") : string.Empty,
                                             caipinModel.endDate.HasValue ? caipinModel.endDate.Value.ToString("yyyy-MM-dd") : string.Empty);
                }

                String jianjie    = caipinModel.shopIntroduction;
                String tuidanRule = caipinModel.chargeback;
                string pictureUrl = caipinModel.picUrl;

                var result = new
                {
                    Name             = caipinModel.cpName,
                    Url              = MapUrl(pictureUrl),
                    Range            = useRange,
                    Intruduce        = jianjie,
                    Rule             = tuidanRule,
                    suoming          = caipinModel.detailContent,
                    shopIntroduction = caipinModel.shopIntroduction
                };

                context.Response.Write(AjaxResult.Success(result));
                context.Response.End();
            }
        }