Beispiel #1
0
        private static void SaveCategory(List <CreateCategoryData> CreateCategoryData, CreateFormulaData CreateFormulaData, SetdbnameResult dbname, int i, string sflg, string isbool, string Categoryid, string iscz)
        {
            var dbnameid = service.Setdbdata_json("", "", Categoryid, CreateFormulaData.data[i], dbname.id, CreateFormulaData.hotelcode, CreateFormulaData.pro_arr);

            if (dbnameid.IndexOf("success") > -1)
            {
                var cateint = int.Parse(Categoryid);
                iticketdb.dbdata_t.Add(new dbdata_t
                {
                    CategoryId = cateint,
                    dbnameid   = int.Parse(dbname.id),
                    hotelcode  = CreateFormulaData.hotelcode,
                    num        = int.Parse(CreateFormulaData.data[i]),
                    oid        = CreateFormulaData.usercode,
                });
                iticketdb.Category_t.Add(new Category_t
                {
                    addtime        = DateTime.Now,
                    BeginString    = "00",
                    bgpic          = "",
                    Categorycode   = CreateCategoryData[i].cate_code,
                    CategoryId     = cateint,
                    CategoryName   = CreateCategoryData[i].cate_name,
                    CategoryNamebm = CreateCategoryData[i].cate_bm,
                    dzpq           = "1",
                    endnum         = int.Parse("00"),
                    EndString      = "00",
                    ExpireDate     = CreateCategoryData[i].cate_start_date.ToString(),
                    ExpireDateend  = (CreateCategoryData[i].cate_start_date + CreateCategoryData[i].cate_end_date).ToString(),
                    flag           = 0,
                    fmoney         = CreateCategoryData[i].cate_price == "" ? decimal.Parse("9999") : decimal.Parse(CreateCategoryData[i].cate_price),
                    fnum           = 0,
                    hotelcode      = CreateFormulaData.hotelcode,
                    HotelId        = CreateFormulaData.hotelcode,
                    isbool         = int.Parse(isbool),//未确定
                    iscz           = int.Parse(iscz),
                    istest         = 0,
                    iswxly         = 0,
                    iszs           = CreateCategoryData[i].iszs == null ? 1 : int.Parse(CreateCategoryData[i].iszs),
                    maxNum         = int.Parse(CreateFormulaData.pro_num == "" ? "999999" : CreateFormulaData.pro_num),
                    moneytype      = 0,
                    pic            = "",
                    rate           = 1,
                    sflag          = int.Parse(sflg),
                    Summary        = CreateCategoryData[i].cate_summary,
                    type           = 0,
                });
                var setcatefw = service.Setcategory_fw_pl_json("", "", Categoryid, CreateFormulaData.hotelcode_fw, CreateFormulaData.pro_arr);
                var rangArr   = CreateFormulaData.hotelcode_fw.Split(',');
                foreach (var item1 in rangArr)
                {
                    if (item1.ToString() != "")
                    {
                        if (!iticketdb.Category_fw_t.Any(x => x.hotelcode == CreateFormulaData.hotelcode && x.CategoryId == cateint))
                        {
                            iticketdb.Category_fw_t.Add(new Category_fw_t
                            {
                                CategoryId   = cateint,
                                hotelcode    = CreateFormulaData.hotelcode,
                                usehotelcode = item1.ToString(),
                                addtime      = DateTime.Now,
                            });
                        }
                    }
                }
                iticketdb.SaveChanges();
            }
        }
Beispiel #2
0
        public static JsonReturn CreateFormula(CreateFormulaData data)
        {
            JsonReturn jsonResult = new JsonReturn();

            if (data != null)
            {
                try
                {
                    //var sflg = GetSflag(data.type);
                    if (data.arr != null && data.arr.Count > 0)
                    {
                        var pro_num = TicketApi.GetProNum(data.type, data.pro_num);

                        //调用webservice接口定义产品包,返回产品包id
                        //TODO:   Formulacode, fmoney,fnum, 字段没有
                        var formulaid = service.SetFormula_json("", "", data.pro_name, data.summary, "00", data.price, pro_num, data.hotelcode, data.pro_arr);
                        if (formulaid != "")
                        {
                            var formulaint = int.Parse(formulaid);
                            //本地关系型数据库存储产品信息
                            var formula = new Formula_t
                            {
                                fmoney         = decimal.Parse(data.price),
                                Formulacode    = "",
                                FormulaId      = int.Parse(formulaid),
                                FormulaName    = data.pro_name,
                                FormulaSummary = data.summary,
                                hotelcode      = data.hotelcode,
                                //maxnum=int.Parse( data.pro_num),
                                flag = 0,
                            };
                            iticketdb.Formula_t.Add(formula);
                            iticketdb.SaveChanges();

                            //TODO:redis缓存记录产品信息
                            var setformulafw = service.SetFormula_fw_pl_json("", "", formulaid, data.hotelcode_fw, data.hotelcode, data.pro_arr);
                            var rangArr      = data.pro_arr.Split(',');
                            foreach (var item1 in rangArr)
                            {
                                if (!iticketdb.Formula_fw_t.Any(x => x.hotelcode == data.hotelcode && x.FormulaId == formulaint))
                                {
                                    iticketdb.Formula_fw_t.Add(new Formula_fw_t
                                    {
                                        FormulaId    = formulaint,
                                        hotelcode    = data.hotelcode,
                                        usehotelcode = item1.ToString(),
                                    });
                                }
                            }
                            iticketdb.SaveChanges();
                            //TODO:打包产品
                            var dbstr = service.Setdbname_json("", "", data.pro_name, formulaid, data.hotelcode, data.pro_arr).Replace("(", "").Replace(")", "");
                            if (dbstr != null)
                            {
                                var dbobj = JsonConvert.DeserializeObject <List <SetdbnameResult> >(dbstr)[0];
                                if (dbobj.returncode == "success")
                                {
                                    iticketdb.dbname_t.Add(new dbname_t
                                    {
                                        dbname    = data.pro_name,
                                        formulaid = formulaid,
                                        hotelcode = data.hotelcode,
                                    });
                                    iticketdb.SaveChanges();
                                    if (CreateCategory(data.arr, data, dbobj))
                                    {
                                        jsonResult.code = ApiCode.成功;
                                        jsonResult.msg  = "成功";
                                    }
                                    else
                                    {
                                        jsonResult.code = ApiCode.子券定义失败;
                                        jsonResult.msg  = "子券定义失败";
                                    }
                                }
                            }
                        }
                        else
                        {
                            jsonResult.code = ApiCode.产品定义失败;
                            jsonResult.msg  = "产品定义失败";
                        }
                    }
                    else
                    {
                        jsonResult.code = ApiCode.参数不全;
                        jsonResult.msg  = "接口调用失败";
                    }
                }
                catch (Exception ex)
                {
                    jsonResult.code = ApiCode.接口调用失败;
                    jsonResult.msg  = ex.ToString();
                }
            }
            return(jsonResult);
        }
Beispiel #3
0
        public static bool CreateCategory(List <CreateCategoryData> CreateCategoryData, CreateFormulaData CreateFormulaData, SetdbnameResult dbname)
        {
            var isSet = true;

            try
            {
                for (int i = 0; i < CreateCategoryData.Count; i++)
                {
                    if (CreateCategoryData[i].cate_name != null)
                    {
                        var sflg = TicketApi.GetSflag(CreateFormulaData.type, CreateCategoryData[i].cate_xz, CreateCategoryData[i].cate_type);
                        var iscz = TicketApi.GetIscz(sflg);
                        if (sflg == "4" || sflg == "5")
                        {
                            var isbool     = TicketApi.GetIsBool(sflg, CreateCategoryData[i].isbool);
                            var Categoryid = service.Setcategory_cz_json
                                                 ("", "", CreateCategoryData[i].cate_name, CreateCategoryData[i].cate_code, CreateCategoryData[i].cate_summary, CreateFormulaData.hotelcode, "", "00", "00", "0", CreateCategoryData[i].cate_type, sflg, CreateCategoryData[i].cate_start_date.ToString(), (CreateCategoryData[i].cate_start_date + CreateCategoryData[i].cate_end_date).ToString(), "00", "1", isbool, "0", "1", CreateCategoryData[i].cate_bm, CreateCategoryData[i].cate_price, "0", CreateCategoryData[i].iszs, iscz, "", CreateFormulaData.pro_arr);
                            if (Categoryid != "")
                            {
                                SaveCategory(CreateCategoryData, CreateFormulaData, dbname, i, sflg, isbool, Categoryid, iscz);
                            }
                            else
                            {
                                isSet = false;
                            }
                        }
                        else
                        {
                            var isbool     = TicketApi.GetIsBool(sflg, CreateCategoryData[i].isbool);
                            var Categoryid = service.Setcategory_json("", "", CreateCategoryData[i].cate_name, CreateCategoryData[i].cate_code, CreateCategoryData[i].cate_summary, CreateFormulaData.hotelcode, "", "00", "00", "0", CreateCategoryData[i].cate_type, sflg, CreateCategoryData[i].cate_start_date.ToString(), (CreateCategoryData[i].cate_start_date + CreateCategoryData[i].cate_end_date).ToString(), "00", "1", isbool, "0", "1", CreateCategoryData[i].cate_bm, CreateCategoryData[i].cate_price == "" ? "9999" : CreateCategoryData[i].cate_price, "0", CreateCategoryData[i].iszs, iscz, CreateFormulaData.pro_arr);
                            if (Categoryid != "")
                            {
                                SaveCategory(CreateCategoryData, CreateFormulaData, dbname, i, sflg, isbool, Categoryid, iscz);
                            }
                            else
                            {
                                isSet = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isSet = false;
            }
            return(isSet);
        }