Пример #1
0
        private bool CreateOrderOfHparty(OrderParams param, int order_id)
        {
            try
            {
                int good_id=Convert.ToInt32(param.goodid);
                int price_id=Convert.ToInt32(param.priceid);

                var hpartyModel = entity.hp_hparty.First(o => o.goodid ==good_id);
                var priceModel = entity.hp_hpprice.First(o => o.id == price_id);
                Model.hp_hpartyorderinfo model = new Model.hp_hpartyorderinfo();
                model.goodid = hpartyModel.goodid;
                model.orderid = order_id;
                model.price = Convert.ToDouble(priceModel.price);
                #region 根据分类选择场次价格

                model.begintime = priceModel.begintime;
                model.endtime = priceModel.endtime;

                #endregion
                model.name = param.name;
                model.tel = param.tel;
                model.num = Convert.ToInt32(param.num);
                model.mark = param.mark;
                model.create_time = DateTime.Now;
                entity.hp_hpartyorderinfo.Add(model);
                entity.SaveChanges();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
Пример #2
0
 /// <summary>
 /// 下订单的入口
 /// </summary>
 /// <param name="param">参数集合</param>
 /// <returns></returns>
 public string CreateOrder(OrderParams param)
 {
     string jsonstr = "";
     Model.hp_order model = new Model.hp_order();
     try
     {
         model.goodid = Convert.ToInt32(param.goodid);
         var goodModel = entity.hp_goodinfo.First(o => o.id == model.goodid);
         model.classid = Convert.ToInt32(goodModel.classid);
         model.countid = Convert.ToInt32(param.countid);
         model.create_time = DateTime.Now;
         model.ordernum = SetOrderNum(model.create_time, model.classid.ToString());
         entity.hp_order.Add(model);
         entity.SaveChanges();
         //jsonstr = ReturnJson.toJson("100","总表创建成功",-1);
         #region 根据分类去不同的表存储订单信息
         if (model.classid == StringHelper.轰趴管)
         {
             if (!CreateOrderOfHparty(param, model.id))
             {
                 entity.hp_order.Remove(model);
                 return ReturnJson.toJson("101", "hparty创建失败", -1);
             }
             else
             {
                 //OrderInfo info = GetResultFromHparty(model);
                 string result = InitAliParams(model);
                 return ReturnJson.toJson("100", "下单成功", result);
             }
         }
         else if (model.classid == StringHelper.活动)
         {
             if (!CreateOrderOfCampaign(param, model.id))
             {
                 entity.hp_order.Remove(model);
                 return ReturnJson.toJson("101", "campaign创建失败", -1);
             }
             else
             {
                 //OrderInfo info = GetResultFromCampaign(model);
                 string result = InitAliParams(model);
                 return ReturnJson.toJson("100", "下单成功", result);
             }
         }
         #endregion
     }
     catch (Exception e)
     {
         //entity.DeleteObject(model);
         //entity.SaveChanges();
         jsonstr = ReturnJson.toJson("101", "order创建失败", -1);
     }
     return jsonstr;
 }
Пример #3
0
    private OrderParams initParam()
    {
        OrderParams param = new OrderParams();

        param.goodid=Request.Form["id"];
        param.countid = Request.Form["countid"];
        //param.goodclassid = Request.Form["classid"];
        //param.begintime = Request.Form["begintime"];
        //param.endtime = Request.Form["endtime"];
        //param.price = Request.Form["price"];
        //param.name = Request.Form["name"];
        param.tel = Request.Form["tel"];
        //param.num = Request.Form["num"];
        //param.mark = Request.Form["mark"];
        param.priceid=Request.Form["priceid"];
        param.choicedate = Request.Form["choicedate"];
        return param;
    }
Пример #4
0
 private bool CreateOrderOfCampaign(OrderParams param, int order_id)
 {
     try
     { 
         int good_id=Convert.ToInt32(param.goodid);
         int price_id = Convert.ToInt32(param.priceid);
         var campaignModel=entity.hp_campaign.First(o=>o.goodid==good_id);
         Model.hp_campaignorderinfo model = new Model.hp_campaignorderinfo();
         model.orderid = order_id;
         model.hostdate = campaignModel.hostdate;
         model.begintime = campaignModel.begintime;
         model.endtime = campaignModel.endtime;
         model.tel = param.tel;
         model.price = campaignModel.price;
         entity.hp_campaignorderinfo.Add(model);
         entity.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
    
 }