Beispiel #1
0
        public static OrderLst insOrderListTemp(ProductModel prod, PkgDetailModel pkg, confirmPkgInfo confirm, DataModel dataModel, B2dAccount UserData, string priceType, int lstSeqno, int?cusSeqno, int prodQty, DiscountRuleModel discRule)
        {
            OrderLst lstTemp = new OrderLst();

            //lstTemp.lst_seqno = lstSeqno;
            //lstTemp.cus_seqno = cusSeqno;
            lstTemp.prod_no       = prod.prod_no.ToString();
            lstTemp.prod_amt      = Convert.ToDouble(priceType == "price1" ? pkg.price1 : priceType == "price2" ? pkg.price2 : priceType == "price3" ? pkg.price3 : pkg.price4);
            lstTemp.prod_name     = prod.prod_name;
            lstTemp.prod_b2c_amt  = Convert.ToDouble(priceType == "price1" ? pkg.price1_b2c : priceType == "price2" ? pkg.price2_b2c : priceType == "price3" ? pkg.price3_b2c : pkg.price4_b2c);
            lstTemp.prod_currency = UserData.CURRENCY;
            lstTemp.prod_cond1    = priceType;
            lstTemp.prod_cond2    = pkg.unit;
            lstTemp.events        = confirm.pkgEvent;
            lstTemp.pkg_date      = confirm.selDate;
            //lstTemp.discount_xid = 0;
            lstTemp.pkg_no   = pkg.pkg_no;
            lstTemp.pkg_name = pkg.pkg_name;
            lstTemp.prod_qty = prodQty;

            OrderDiscountRule rule = new OrderDiscountRule();

            if (discRule.isRule == true)
            {
                double discAmt = 0;
                if (priceType == "price1")
                {
                    discAmt = pkg.price1_org - pkg.price1;
                }
                if (priceType == "price2")
                {
                    discAmt = pkg.price2_org - pkg.price2;
                }
                if (priceType == "price3")
                {
                    discAmt = Convert.ToDouble(pkg.price3_org - pkg.price3);
                }
                if (priceType == "price4")
                {
                    discAmt = Convert.ToDouble(pkg.price4_org - pkg.price4);
                }

                rule.disc_amt      = discAmt;
                rule.disc_currency = UserData.CURRENCY;
                rule.disc_name     = discRule.disc_name;
                rule.disc_note     = "";
                //rule.lst_seqno = lstSeqno;
                lstTemp.order_discount_rule = rule;
            }
            else
            {
                lstTemp.order_discount_rule = rule;
            }
            return(lstTemp);
        }
Beispiel #2
0
        //組出價格別與年齡->前端js判斷calender用
        public static CusAgeRange getCusAgeRange(confirmPkgInfo confirm, PkgDetailModel pkgsTemp)
        {
            CusAgeRange cus = new CusAgeRange();

            cus.price1Qty = 0;
            cus.price2Qty = 0;
            cus.price3Qty = 0;
            cus.price4Qty = 0;

            if (confirm.price1Qty > 0)
            {
                cus.price1Qty = confirm.price1Qty;

                cus.price1sAge = Convert.ToInt32(pkgsTemp.price1_age_range.Split('~')[0]);
                cus.price1eAge = Convert.ToInt32(pkgsTemp.price1_age_range.Split('~')[1]);
            }
            if (confirm.price2Qty > 0)
            {
                cus.price2Qty = confirm.price2Qty;

                cus.price2sAge = Convert.ToInt32(pkgsTemp.price2_age_range.Split('~')[0]);
                cus.price2eAge = Convert.ToInt32(pkgsTemp.price2_age_range.Split('~')[1]);
            }
            if (confirm.price3Qty > 0)
            {
                cus.price3Qty = confirm.price3Qty;

                cus.price3sAge = Convert.ToInt32(pkgsTemp.price3_age_range.Split('~')[0]);
                cus.price3eAge = Convert.ToInt32(pkgsTemp.price3_age_range.Split('~')[1]);
            }
            if (confirm.price4Qty > 0)
            {
                cus.price4Qty = confirm.price4Qty;

                cus.price4sAge = Convert.ToInt32(pkgsTemp.price4_age_range.Split('~')[0]);
                cus.price4eAge = Convert.ToInt32(pkgsTemp.price4_age_range.Split('~')[1]);
            }

            return(cus);
        }
Beispiel #3
0
        //成立b2d 訂單
        public static string insB2dOrder(ProdTitleModel title, ProductModel prod, PkgDetailModel pkg, confirmPkgInfo confirm, DataModel dataModel, B2dAccount UserData, DiscountRuleModel discRule)
        {
            try
            {
                B2dOrderModel order = new B2dOrderModel();

                order.connect_mail  = dataModel.contactEmail;
                order.order_date    = DateTime.Now;
                order.order_type    = "B2D";
                order.order_status  = "NW";
                order.order_amt     = Convert.ToDouble(dataModel.currPriceTotal);
                order.order_b2c_amt = Convert.ToDouble(dataModel.currPriceTotal); //要重算
                order.connect_name  = dataModel.asiaMileMemberLastName + " " + dataModel.contactFirstname;
                order.connect_tel   = dataModel.contactTel;
                order.order_note    = dataModel.note;

                Source source = new Source();
                source.booking_type = "WEB";
                source.company_xid  = UserData.COMPANY_XID;
                source.channel_oid  = UserData.KKDAY_CHANNEL_OID;
                source.connect_tel  = dataModel.contactTel;
                source.connect_mail = dataModel.contactEmail;
                source.connect_name = dataModel.asiaMileMemberLastName + " " + dataModel.contactFirstname;
                source.order_note   = dataModel.note;
                source.client_ip    = "127.0.0.1";
                source.crt_time     = DateTime.Now;

                order.source = source;

                List <OrderCus> cusList = new List <OrderCus>();
                List <OrderLst> lstList = new List <OrderLst>();

                //NORANK 且 (只有一個代表人 或 不要代表人)    ->只塞一筆order_lst
                //NORANK 且要填所有旅客資料->只塞1~*筆order_lst

                //RANK 且 (只有一個代表人 或 不要代表人)    ->只塞1~*筆order_lst
                //RANK 且要填所有旅客資料     ->只塞1~*筆order_lst

                int?cusSeqno = 1;
                int lstSeqno = 1;

                string priceType = "";
                int    ii        = 0;
                //滿足cus
                foreach (CusDataInfo cus in dataModel.travelerData)
                {
                    if (ii < confirm.price1Qty)
                    {
                        priceType = "price1";
                    }
                    else if (ii < (confirm.price1Qty + confirm.price2Qty))
                    {
                        priceType = "price2";
                    }
                    else if (ii < (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty))
                    {
                        priceType = "price3";
                    }
                    else if (ii < (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty))
                    {
                        priceType = "price4";
                    }
                    OrderCus cusTemp = new OrderCus();
                    //cusTemp.cus_seqno = Convert.ToInt32(cusSeqno);
                    cusTemp.cus_type         = priceType;
                    cusTemp.cus_mail         = "";
                    cusTemp.cus_name_e_first = cus.englishName.firstName;
                    cusTemp.cus_name_e_last  = cus.englishName.lastName;
                    cusTemp.cus_sex          = cus.gender;
                    cusTemp.cus_tel          = "";

                    cusList.Add(cusTemp);
                    cusSeqno = cusSeqno + 1;
                    ii       = ii + 1;
                }

                if (dataModel.travelerData.Count == 0)
                {
                    cusSeqno = null;
                }
                else
                {
                    cusSeqno = 1;
                }

                if (dataModel.travelerData.Count == 1)
                {
                    //依priceTeype寫入
                    if (confirm.price1Qty > 0)
                    {
                        lstList.Add(insOrderListTemp(prod, pkg, confirm, dataModel, UserData, "price1", lstSeqno, 1, Convert.ToInt32(confirm.price1Qty), discRule));
                    }
                    lstSeqno = lstSeqno + 1;
                    if (confirm.price2Qty > 0)
                    {
                        lstList.Add(insOrderListTemp(prod, pkg, confirm, dataModel, UserData, "price2", lstSeqno, 1, Convert.ToInt32(confirm.price2Qty), discRule));
                    }
                    lstSeqno = lstSeqno + 1;
                    if (confirm.price3Qty > 0)
                    {
                        lstList.Add(insOrderListTemp(prod, pkg, confirm, dataModel, UserData, "price3", lstSeqno, 1, Convert.ToInt32(confirm.price3Qty), discRule));
                    }
                    lstSeqno = lstSeqno + 1;
                    if (confirm.price4Qty > 0)
                    {
                        lstList.Add(insOrderListTemp(prod, pkg, confirm, dataModel, UserData, "price4", lstSeqno, 1, Convert.ToInt32(confirm.price4Qty), discRule));
                    }
                }
                else
                {
                    //依每一個row寫入
                    for (ii = 0; ii < dataModel.travelerData.Count; ii++)
                    {
                        if (ii < confirm.price1Qty)
                        {
                            priceType = "price1";
                        }
                        else if (ii < (confirm.price1Qty + confirm.price2Qty))
                        {
                            priceType = "price2";
                        }
                        else if (ii < (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty))
                        {
                            priceType = "price3";
                        }
                        else if (ii < (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty))
                        {
                            priceType = "price4";
                        }
                        lstList.Add(insOrderListTemp(prod, pkg, confirm, dataModel, UserData, priceType, lstSeqno, cusSeqno, 1, discRule));
                        lstSeqno = lstSeqno + 1;
                        cusSeqno = cusSeqno + 1;
                    }
                }

                order.order_cus = cusList;
                order.order_lst = lstList;

                Website.Instance.logger.Debug($"bookingStep1_insB2dOrder:{ JsonConvert.SerializeObject(order)}");

                insB2dOrderResult result = ApiHelper.insB2dOrder(order, title);
                if (result.result == "0000")
                {
                    Website.Instance.logger.Debug($"bookingStep1_insB2dOrderResult:{ JsonConvert.SerializeObject(result)}");
                    return(result.order_no);
                }
                else
                {
                    Website.Instance.logger.Debug($"bookingStep1_insB2dOrderResult:{ JsonConvert.SerializeObject(result)}");
                    throw new Exception(result.result_msg);
                }
            }
            catch (Exception ex)
            {
                Website.Instance.logger.Debug($"bookingStep1_insB2dOrderErr:{ JsonConvert.SerializeObject(ex.ToString())}");
                throw new Exception(ex.Message.ToString());
            }
        }
Beispiel #4
0
        //組出booking 頁右邊顯示的內容
        public static BookingShowProdModel setBookingShowProd(ProductModel prod, PkgDetailModel pkg, confirmPkgInfo confirm, string currency, PkgEventsModel pkgEvent, ProdTitleModel prodTitle)
        {
            BookingShowProdModel prodShow = new BookingShowProdModel();

            prodShow.prodOid   = prod.prod_no.ToString();
            prodShow.prodName  = prod.prod_name;
            prodShow.currency  = currency;
            prodShow.sDate     = DateTimeTool.yyyy_mm_dd(confirm.selDate);
            prodShow.price1Qty = confirm.price1Qty;
            prodShow.price2Qty = confirm.price2Qty;
            prodShow.price3Qty = confirm.price3Qty;
            prodShow.price4Qty = confirm.price4Qty;
            prodShow.price1    = pkg.price1;
            prodShow.price2    = pkg.price2;
            prodShow.price3    = pkg.price3;
            prodShow.price4    = pkg.price4;
            prodShow.eventOid  = confirm.pkgEvent;
            if (prod.img_list.Count > 0)
            {
                prodShow.photoUrl = Website.Instance.Configuration["kkUrl:imgUrl"].ToString() + prod.img_list[0].img_kkday_url;
            }

            prodShow.isRank      = pkg.is_unit_pirce == "RANK" ? true : false;
            prodShow.pkgOid      = pkg.pkg_no;
            prodShow.pkgName     = pkg.pkg_name;
            prodShow.totoalPrice = (prodShow.price1Qty * prodShow.price1) + (prodShow.price2Qty * prodShow.price2) +
                                   (prodShow.price3Qty * prodShow.price3) + (prodShow.price4Qty * prodShow.price4);

            prodShow.unitText = pkg.unit_txt;

            if (pkgEvent != null)
            {
                var eTemp = pkgEvent.events.Where(x => x.day.Equals(confirm.selDate));


                foreach (Event e in eTemp)
                {
                    string[] times = e.event_times.Split(",");

                    foreach (string s in times)
                    {
                        string id = s.Split("_")[0];
                        if (id.Equals(confirm.pkgEvent))
                        {
                            prodShow.eventTime = s.Split("_")[1];
                            break;
                        }
                    }
                }
            }

            //設定回覆確試時間
            if (prod.confirm_order_time == 0)
            {
                prodShow.confirm_order_time = prodTitle.common_imm_confirm;
            }
            else
            {
                prodShow.confirm_order_time = prodTitle.booking_step3_check_confirm_hour.Replace("%d", prod.confirm_order_time.ToString());
            }

            return(prodShow);
        }
Beispiel #5
0
        public static DataModel setDefaultBookingInfo(string guid, DataModel data, ProductModel prod, PkgDetailModel pkg, confirmPkgInfo confirm, B2dAccount UserData, Pmgw pmgw)
        {
            string memUuid = "051794b8-db2a-4fe7-939f-31ab1ee2c719";

            data.productOid       = confirm.prodOid;
            data.packageOid       = confirm.pkgOid;
            data.contactFirstname = UserData.NAME_FIRST;
            data.contactLastname  = UserData.NAME_LAST;
            data.contactEmail     = UserData.EMAIL;
            data.telCountryCd     = UserData.TEL_AREA;
            data.contactTel       = UserData.TEL;
            data.contactCountryCd = UserData.COUNRTY_CODE;
            data.lstGoDt          = confirm.selDate;
            if (confirm.pkgEvent != null)
            {
                data.eventOid = confirm.pkgEvent;
            }

            data.price1Qty = confirm.price1Qty;
            data.price2Qty = confirm.price2Qty == null ? 0 : confirm.price2Qty;
            data.price3Qty = confirm.price3Qty == null ? 0 : confirm.price3Qty;
            data.price4Qty = confirm.price4Qty == null ? 0 : confirm.price4Qty;
            data.payMethod = pmgw.acctdocReceiveMethod;// "ONLINE_CITI";這個地方接pmch要改
            data.hasRank   = pkg.is_unit_pirce == "RANK" ? "Y" : "N";
            //data.productUrlOid =
            data.productName = prod.prod_name;
            string[] citys = new string[prod.countries[0].cities.Count];

            int i = 0;

            foreach (City c in prod.countries[0].cities)
            {
                citys[i] = c.id;
                i++;
            }

            data.productCity         = citys;
            data.productCountry      = prod.countries[0].id;
            data.productMainCat      = prod.prod_type;
            data.productOrderHandler = prod.prod_hander;
            data.payPmchOid          = "1";
            data.currency            = UserData.CURRENCY;
            //先接直客價!!
            data.currPriceTotal    = ((pkg.price1_b2c * confirm.price1Qty) + (pkg.price2_b2c * confirm.price2Qty) + (pkg.price3_b2c * confirm.price3Qty) + (pkg.price4_b2c * confirm.price4Qty));// 263;// (pkg.price1 * confirm.price1Qty) +(pkg.price2 * confirm.price2Qty) +(pkg.price3 * confirm.price3Qty) + (pkg.price4 * confirm.price4Qty);
            data.crtDevice         = "Macintosh";
            data.crtBrowser        = "Safari";
            data.crtBrowserVersion = "12.0";
            data.memberUuid        = memUuid;
            data.deviceId          = guid;
            data.tokenKey          = MD5Tool.GetMD5(memUuid + guid + Website.Instance.Configuration["kkdayKey:memuuidToken"].ToString());// "897af29c45ed180451c2e6bfa81333b6";
            data.riskStatus        = "01";

            data.multipricePlatform     = "01";
            data.sourceCode             = "WEB";
            data.sourceParam1           = "";
            data.allowedCardNumberArray = new string[] { };

            //senddata
            data.modules.sendData.moduleData.receiverTel.telCountryCode = UserData.TEL_AREA;
            data.modules.sendData.moduleData.receiverTel.telNumber      = UserData.TEL;

            //contact
            data.modules.contactData.moduleData.contactTel.telCountryCode = UserData.TEL_AREA;

            //rendCar 寫在 js

            return(data);
        }
Beispiel #6
0
        // GET: /<controller>/
        public IActionResult Index(string guid)
        {
            try
            {
                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1");

                //取挖字
                Dictionary <string, string> uikey = CommonRepostory.getuiKey(RedisHelper, UserData.LOCALE);// RedisHelper.getuiKey(fakeContact.lang);
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(JsonConvert.SerializeObject(uikey));

                if (guid == null)
                {
                    throw new Exception(title.common_data_error);
                }

                confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(RedisHelper.getRedis("bid:ec:confirm:" + guid));
                if (confirm == null)
                {
                    throw new Exception(title.common_data_error);
                }

                //從 api取
                ProductModuleModel module = ProductRepostory.getProdModule(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, confirm.pkgOid, title);
                ProductModel       prod   = ProductRepostory.getProdDtl(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, title);
                PackageModel       pkgs   = ProductRepostory.getProdPkg(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, title);

                if (prod.result != "0000")
                {
                    Website.Instance.logger.Debug($"booking_index_getProdDtl_err:prodOid->{confirm.prodOid} ,msg-> {prod.result_msg}");
                    throw new Exception(title.result_code_9990);
                }
                if (pkgs.result != "0000")
                {
                    Website.Instance.logger.Debug($"booking_index_getProdPkg_err:prodOid->{confirm.prodOid},pkgOid ->{confirm.pkgOid} ,msg-> {prod.result_msg}");
                    throw new Exception(title.result_code_9990);
                }

                string         flightInfoType = "";
                string         sendInfoType   = "";
                PkgDetailModel pkg            = null;
                PkgEventsModel pkgEvent       = null;
                CusAgeRange    cusAgeRange    = null;
                string         isEvent        = "N";
                string         isHl           = "N";
                var            pkgsTemp       = pkgs.pkgs.Where(x => x.pkg_no == confirm.pkgOid).ToList();
                if (pkgsTemp.Count() > 0)
                {
                    foreach (PkgDetailModel p in pkgsTemp)
                    {
                        pkg            = p;
                        flightInfoType = p.module_setting.flight_info_type.value;
                        sendInfoType   = p.module_setting.send_info_type.value;
                        cusAgeRange    = BookingRepostory.getCusAgeRange(confirm, p);

                        isEvent = p.is_event;
                        isHl    = p.is_hl;
                    }
                }
                else
                {
                    //丟錯誤頁
                    Website.Instance.logger.Debug($"booking_index_err:商編->{confirm.prodOid}即有pkgs找不到對應的pkgoid->{ confirm.pkgOid}");
                    throw new Exception(title.common_data_error);
                }

                //如果有event 但沒有傳 event id ,就error
                if (isEvent == "Y" && string.IsNullOrEmpty(confirm.pkgEvent))
                {
                    throw new Exception(title.common_data_error);
                }

                if (isEvent == "Y")
                {
                    pkgEvent = ApiHelper.getPkgEvent(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, confirm.pkgOid, title);
                }

                //pmgw
                PmchLstResponse pmchRes = ApiHelper.getPaymentListRes(prod.countries, prod.prod_no.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"),
                                                                      DateTimeTool.yyyyMMdd2DateTime(confirm.selDate).ToString("yyyy-MM-dd"), DateTimeTool.yyyyMMdd2DateTime(confirm.selDate).ToString("yyyy-MM-dd"), UserData.COUNRTY_CODE, UserData.LOCALE,
                                                                      prod.prod_type, ip, prod.prod_hander, UserData.CURRENCY, title);

                Pmgw pmgw = null;
                if (UserData.CURRENCY == "TWD")
                {
                    pmgw = pmchRes.pmchlist.Where(x => x.acctdocReceiveMethod == "ONLINE_CITI" && x.pmchCode == "B2D_CITI_TWD").FirstOrDefault();
                }
                else
                {
                    pmgw = pmchRes.pmchlist.Where(x => x.acctdocReceiveMethod == "ONLINE_HK_ADYEN").FirstOrDefault();
                }
                //必須要設定人數
                //var cusData = BookingRepostory.getCusDdate();
                int totalCus = 0;
                if (module.module_cust_data != null)
                {
                    if (module.module_cust_data.is_require == true)
                    {
                        totalCus = (module.module_cust_data.cus_type == "01") ? 1 : Convert.ToInt32(confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty);
                    }
                }

                //滿足國家
                List <Country> country    = prod.countries;
                string         nationName = "";
                if (country.Count > 0)
                {
                    nationName = country[0].name;
                }

                //將dataModel原型 以json str 帶到前台的hidden
                DataModel dm = DataSettingRepostory.getDefaultDataModel(totalCus, guid);
                dm.guidNo = guid;
                String dataModelStr = JsonConvert.SerializeObject(dm);
                //dm.travelerData[0].meal.mealType
                ViewData["dataModelStr"] = dataModelStr;

                VenueInfo venue = module.module_venue_info;
                if (venue == null)
                {
                    venue = new VenueInfo(); venue.is_require = false;
                }
                RentCar rentCar = module.module_rent_car;
                if (rentCar == null)
                {
                    rentCar = new RentCar(); rentCar.is_require = false;
                }
                ViewData["confirmPkgInfo"] = confirm;
                ViewData["contactInfo"]    = UserData;
                ViewData["cusData"]        = module.module_cust_data;
                ViewData["guide"]          = module.module_guide_lang_list;
                ViewData["wifi"]           = module.module_sim_wifi;
                ViewData["exchange"]       = module.module_exchange_location_list;
                ViewData["flightInfo"]     = module.module_flight_info;
                ViewData["venue"]          = venue;                                    // module.module_venue_info;
                ViewData["useDate"]        = DateTimeTool.yyyy_mm_dd(confirm.selDate); //DateTimeTool.yyyy_mm_dd();
                ViewData["rentCar"]        = rentCar;                                  // module.module_rent_car;
                ViewData["carPsgr"]        = module.module_car_pasgr;                  //車輛資料
                ViewData["sendData"]       = module.module_send_data;
                ViewData["contactData"]    = module.module_contact_data;
                ViewData["nationName"]     = nationName;

                ViewData["guid"]           = guid;
                ViewData["prodTitle"]      = title;
                ViewData["totalCus"]       = totalCus;
                ViewData["mainCat"]        = prod.prod_type;
                ViewData["flightInfoType"] = flightInfoType;
                ViewData["sendInfoType"]   = sendInfoType;
                ViewData["CutOfDay"]       = prod.before_order_day;
                ViewData["cusAgeRange"]    = cusAgeRange;
                BookingShowProdModel show = BookingRepostory.setBookingShowProd(prod, pkg, confirm, UserData.CURRENCY, pkgEvent, title);
                ViewData["prodShow"] = show;

                ViewData["isEvent"]       = isEvent;                                                                                                                                                                            //
                ViewData["isHl"]          = isHl;                                                                                                                                                                               //如果是N就不用做
                ViewData["pkgCanUseDate"] = (isHl == "Y" && isEvent == "Y") ? BookingRepostory.getPkgEventDate(pkgEvent, confirm.pkgOid, (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty)) : ""; //要把這個套餐可以用的日期全抓出來
                ViewData["pmgw"]          = pmgw;

                //放到session
                TempData["prod_" + guid]          = JsonConvert.SerializeObject(prod);
                TempData["pkgEvent_" + guid]      = (isHl == "Y" && isEvent == "Y") ? JsonConvert.SerializeObject(pkgEvent) : "";
                TempData["module_" + guid]        = JsonConvert.SerializeObject(module);
                TempData["confirm_" + guid]       = JsonConvert.SerializeObject(confirm);
                TempData["ProdTitleKeep_" + guid] = JsonConvert.SerializeObject(title);
                TempData["pkg_" + guid]           = JsonConvert.SerializeObject(pkg);
                TempData["pkgsDiscRule_" + guid]  = JsonConvert.SerializeObject(pkgs.discount_rule);
                TempData["prodShow_" + guid]      = JsonConvert.SerializeObject(show);
                TempData["pmgw_" + guid]          = JsonConvert.SerializeObject(pmgw);

                return(View());
            }
            catch (Exception ex)
            {
                ViewData["errMsg"] = ex.Message.ToString();
                Website.Instance.logger.Debug($"booking_index_err:{ex.Message.ToString()}");
                //導到錯誤頁
                return(RedirectToAction("Index", "Error", new ErrorViewModel {
                    ErrorType = ErrorType.Invalid_Common
                }));
            }
        }
Beispiel #7
0
        public IActionResult bookingStep1([FromBody] DataModel data)
        {
            try
            {
                string memUuid = Website.Instance.Configuration["kkdayKey:uuid"];

                string    userAgent = Request.Headers["User-Agent"].ToString();
                UserAgent ua        = new UserAgent(userAgent);

                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1");
                data = BookingRepostory.setCardEncrypt(data);
                //log時把卡號移除
                DataModel dataTemp = data.Clone();
                dataTemp.card = null;
                Website.Instance.logger.Debug($"bookingStep1_inputdata:{ JsonConvert.SerializeObject(dataTemp)}");

                string prodStr = TempData["prod_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(prodStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModel prod = JsonConvert.DeserializeObject <ProductModel>(prodStr);

                string moduleStr = TempData["module_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModuleModel module = JsonConvert.DeserializeObject <ProductModuleModel>(moduleStr);

                string pkgStr = TempData["pkg_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pkgStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                PkgDetailModel pkg = JsonConvert.DeserializeObject <PkgDetailModel>(pkgStr);

                string pkgConfirmStr = TempData["confirm_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(pkgConfirmStr);

                string titleStr = TempData["ProdTitleKeep_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(titleStr);

                string discRuleStr = TempData["pkgsDiscRule_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(discRuleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                DiscountRuleModel rule = JsonConvert.DeserializeObject <DiscountRuleModel>(discRuleStr);

                string pmgwStr = TempData["pmgw_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pmgwStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                Pmgw pmgw = JsonConvert.DeserializeObject <Pmgw>(pmgwStr);

                string showStr = TempData["prodShow_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(showStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                //BookingShowProdModel show = JsonConvert.DeserializeObject<BookingShowProdModel>(showStr);

                TempData.Keep();
                data = BookingRepostory.setDefaultBookingInfo(memUuid, ua, data, prod, pkg, confirm, UserData, pmgw);

                //排除餐食
                data = BookingRepostory.exculdeFood(prod, data, module);

                data.company_xid = UserData.COMPANY_XID.ToString();
                data.channel_oid = UserData.KKDAY_CHANNEL_OID;
                data.locale      = UserData.LOCALE;
                data.ip          = ip;
                JObject order = ApiHelper.orderNew(data, title);

                string       orderMid = "";
                string       orderOid = "";
                returnStatus status   = new returnStatus();

                Website.Instance.logger.Debug($"bookingStep1_ordernewresponse:" + JsonConvert.SerializeObject(order));//要改
                //要先判斷是不是result='0000'
                if (order["result"].ToString() == "0000")
                {
                    orderMid = order["order_mid"].ToString();
                    orderOid = order["order_oid"].ToString();
                    //upd B2bOrder
                    //BookingRepostory.updB2dOrder(UserData.COMPANY_XID, orderOid, orderMid, b2bOrder, title);

                    status.pmchSslRequest = BookingRepostory.setPaymentInfo2(prod, data, orderMid, UserData, pmgw, memUuid, ip);
                    status.status         = "OK";
                    status.url            = Website.Instance.Configuration["kkUrl:pmchUrl"].ToString() + pmgw.pmchPayURL; //pmchUrl

                    //要把BookingShowProdModel 帶到訂購final頁
                    RedisHelper.SetRedis(showStr, "b2d:ec:order:final:prodShow:" + orderMid, 60);
                    RedisHelper.SetRedis(JsonConvert.SerializeObject(data), "b2d:ec:order:final:orderData:" + orderMid, 60);

                    //要存redis 付款主要資訊,最後訂單 upd時要使用,可和下面整合存一個就
                    BookingRepostory.setPayDtltoRedis(data, orderMid, UserData.UUID, RedisHelper);

                    //要存redis 因為付款後要從這個redis內容再進行payment驗證,可和上面整合存一個就好
                    //CallJsonPay rdsJson = (CallJsonPay)status.pmchSslRequest.json;
                    CallJsonPay2 rdsJson     = (CallJsonPay2)status.pmchSslRequest.json;
                    string       callPmchReq = JsonConvert.SerializeObject(status.pmchSslRequest.json);
                    RedisHelper.SetRedis(callPmchReq, "b2d:ec:pmchSslRequest:" + orderMid, 60);
                }
                else
                {
                    status.status = "Error";
                    status.msgErr = order["content"]["result"].ToString() + order["content"]["msg"].ToString();//要改
                }

                return(Json(status));
                //v1/channel/citi/auth
                //https://pmch.sit.kkday.com/citi/payment/auth
                //https://payment.kkday.com/v1/channel/adyen/auth
            }
            catch (Exception ex)
            {
                Website.Instance.logger.Debug($"bookingStep1_err_ordernew失敗:{ex.Message.ToString()}");
                ViewData["errMsg"] = ex.Message.ToString();
                Website.Instance.logger.Debug($"booking_index_err:{ex.Message.ToString()}");

                //導到錯誤頁
                return(RedirectToAction("Index", "Error", new ErrorViewModel {
                    ErrorType = ErrorType.Order_Fail, ErrorMessage = ex.Message.ToString()
                }));
            }
        }
Beispiel #8
0
        public IActionResult bookingStep1([FromBody] DataModel data)
        {
            try
            {
                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1");
                data = BookingRepostory.setCardEncrypt(data);
                //log時把卡號移除
                DataModel dataTemp = data.Clone();
                dataTemp.card = null;
                Website.Instance.logger.Debug($"bookingStep1_inputdata:{ JsonConvert.SerializeObject(dataTemp)}");

                ApiSetting api = new ApiSetting();
                api.apiKey    = "kkdayapi";
                api.userOid   = "1";
                api.ver       = "1.0.1";
                api.locale    = UserData.LOCALE;
                api.currency  = UserData.CURRENCY;
                api.ipaddress = ip;

                string prodStr = TempData["prod_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(prodStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModel prod = JsonConvert.DeserializeObject <ProductModel>(prodStr);

                string moduleStr = TempData["module_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModuleModel module = JsonConvert.DeserializeObject <ProductModuleModel>(moduleStr);

                string pkgStr = TempData["pkg_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pkgStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                PkgDetailModel pkg = JsonConvert.DeserializeObject <PkgDetailModel>(pkgStr);

                string pkgConfirmStr = TempData["confirm_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(pkgConfirmStr);

                string titleStr = TempData["ProdTitleKeep_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(titleStr);

                string discRuleStr = TempData["pkgsDiscRule_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(discRuleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                DiscountRuleModel rule = JsonConvert.DeserializeObject <DiscountRuleModel>(discRuleStr);

                string pmgwStr = TempData["pmgw_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pmgwStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                Pmgw pmgw = JsonConvert.DeserializeObject <Pmgw>(pmgwStr);

                string showStr = TempData["prodShow_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(showStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                //BookingShowProdModel show = JsonConvert.DeserializeObject<BookingShowProdModel>(showStr);

                TempData.Keep();

                //排除餐食
                data = BookingRepostory.exculdeFood(prod, data, module);

                string b2bOrder = BookingRepostory.insB2dOrder(title, prod, pkg, confirm, data, UserData, rule);

                //轉 ordermodel
                //OrderRepostory res = new OrderRepostory();
                //OrderModel ord = res.setOrderModel(data,pmgw,title);
                //api.json = ord;
                //string orderModelStr = JsonConvert.SerializeObject(api);
                //Website.Instance.logger.Debug($"bookingStep1_ordernewdata:{ JsonConvert.SerializeObject(orderModelStr)}");

                //KKapiHelper kk = new KKapiHelper();
                //JObject order =kk.crtOrder(api);
                JObject order = ApiHelper.orderNew(data, title);

                string       orderMid = "";
                string       orderOid = "";
                returnStatus status   = new returnStatus();

                Website.Instance.logger.Debug($"bookingStep1_ordernewresponse:" + JsonConvert.SerializeObject(order));//要改
                //要先判斷是不是result='0000'
                if (order["content"]["result"].ToString() == "0000")
                {
                    string memUuid = "051794b8-db2a-4fe7-939f-31ab1ee2c719";
                    orderMid = order["content"]["orderMid"].ToString();
                    orderOid = order["content"]["orderOid"].ToString();
                    status.pmchSslRequest = BookingRepostory.setPaymentInfo2(prod, data, orderMid, UserData, pmgw, memUuid);
                    status.status         = "OK";
                    status.url            = Website.Instance.Configuration["kkUrl:pmchUrl"].ToString() + pmgw.pmchPayURL; //pmchUrl

                    //要把BookingShowProdModel 帶到訂購final頁
                    RedisHelper.SetRedis(showStr, "b2d:ec:order:final:prodShow:" + orderMid, 60);
                    RedisHelper.SetRedis(JsonConvert.SerializeObject(data), "b2d:ec:order:final:orderData:" + orderMid, 60);

                    //要存redis 付款主要資訊,最後訂單 upd時要使用,可和下面整合存一個就
                    BookingRepostory.setPayDtltoRedis(data, orderMid, memUuid, RedisHelper);

                    //要存redis 因為付款後要從這個redis內容再進行payment驗證,可和上面整合存一個就好
                    //CallJsonPay rdsJson = (CallJsonPay)status.pmchSslRequest.json;
                    CallJsonPay2 rdsJson     = (CallJsonPay2)status.pmchSslRequest.json;
                    string       callPmchReq = JsonConvert.SerializeObject(status.pmchSslRequest.json);
                    RedisHelper.SetRedis(callPmchReq, "b2d:ec:pmchSslRequest:" + orderMid, 60);
                }
                else
                {
                    status.status = "Error";
                    status.msgErr = order["content"]["result"].ToString() + order["content"]["msg"].ToString();//要改
                }

                return(Json(status));
                //v1/channel/citi/auth
                //https://pmch.sit.kkday.com/citi/payment/auth
                //https://payment.kkday.com/v1/channel/adyen/auth
            }
            catch (Exception ex)
            {
                //error
                Website.Instance.logger.Debug($"bookingStep1_err_ordernew失敗:{ex.Message.ToString()}");
                returnStatus status = new returnStatus();
                status.status = "Error";
                status.msgErr = ex.Message.ToString();

                return(Json(status));
            }
        }
Beispiel #9
0
        /// <summary>
        /// Gets the package lst.
        /// </summary>
        /// <returns>The package lst.</returns>
        /// <param name="rq">Rq.</param>
        //取得套餐列表
        public static PackageModel GetPkgLst(QueryProductModel rq)
        {
            PackageModel          pkg    = new PackageModel();
            List <PkgDetailModel> pkgLst = new List <PkgDetailModel>();

            DataModel.Discount.DiscountRuleModel disc = null;
            PkgPriceModel pkg_price = new PkgPriceModel();

            try {
                //商品黑名單過濾
                //抓商品是否為黑名單
                bool isBlack = DiscountRepository.GetProdBlackWhite(rq.prod_no);

                if (isBlack)
                {
                    pkg.result     = "10";
                    pkg.result_msg = $"Bad Request:Product-{rq.prod_no} is not available";
                    return(pkg);
                }


                JObject obj     = PackageProxy.getPkgLst(rq);
                JObject objProd = ProdProxy.getProd(rq);

                if (obj["content"]["result"].ToString() != "0000")
                {
                    pkg.result     = obj["content"]["result"].ToString();
                    pkg.result_msg = $"kkday package api response msg is not correct! {obj["content"]["msg"].ToString()}";
                    throw new Exception($"kkday package api response msg is not correct! {obj["content"]["msg"].ToString()}");
                }

                if (objProd["content"]["result"].ToString() != "0000")
                {
                    pkg.result     = obj["content"]["result"].ToString();
                    pkg.result_msg = $"kkday product api response msg is not correct! {objProd["content"]["msg"].ToString()}";
                    throw new Exception($"kkday product api response msg is not correct! {objProd["content"]["msg"].ToString()}");
                }

                #region --1.取回傳資料是否成功的訊息、一般資訊--

                pkg.result         = obj["content"]["result"].ToString();
                pkg.result_msg     = obj["content"]["msg"].ToString();
                pkg.cost_calc_type = obj["content"]["costCalcMethod"].ToString();

                #endregion

                #region --2.從傑森物件取『套餐列表』--
                JArray jPkglst = (JArray)obj["content"]["packageList"];

                pkg_price.pkgs     = new List <pkgs>(); // 初始化陣列
                pkg_price.currency = rq.current_currency;

                for (int i = 0; i < jPkglst.Count; i++)
                {
                    var model       = new PkgDetailModel();
                    var price_model = new pkgs(); // pkg_price 用

                    model.pkg_no        = jPkglst[i]["productPkg"]["pkgOid"].ToString();
                    model.pkg_name      = jPkglst[i]["productPkg"]["pkgName"].ToString();
                    model.online_s_date = jPkglst[i]["productPkg"]["begValidDt"].ToString();
                    model.online_e_date = jPkglst[i]["productPkg"]["endValidDt"].ToString();
                    model.weekDays      = jPkglst[i]["productPkg"]["weekDays"].ToString();

                    model.is_unit_pirce = jPkglst[i]["productPkg"]["priceType"].ToString();

                    model.price1             = DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price1"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price1_org         = (double?)jPkglst[i]["productPkg"]["price1Org"] ?? 0;
                    model.price1_org_net     = (double?)jPkglst[i]["productPkg"]["price1NetOrg"] ?? 0;
                    model.price1_profit_rate = (double?)jPkglst[i]["productPkg"]["price1GrossRate"] ?? 0;
                    model.price1_comm_rate   = (double?)jPkglst[i]["productPkg"]["price1CommRate"] ?? 0;
                    model.price1_age_range   = jPkglst[i]["productPkg"]["price1BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price1EndOld"].ToString();
                    model.price1_b2c = (double?)jPkglst[i]["productPkg"]["price1Sale"] ?? 0;
                    // model.price1_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price1_list = (double)jPkglst[i]["productPkg"][""];

                    model.price2             = (double?)jPkglst[i]["productPkg"]["price2"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price2"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price2_org         = (double?)jPkglst[i]["productPkg"]["price2Org"] ?? 0;
                    model.price2_org_net     = (double?)jPkglst[i]["productPkg"]["price2NetOrg"] ?? 0;
                    model.price2_profit_rate = (double?)jPkglst[i]["productPkg"]["price2GrossRate"] ?? 0;
                    model.price2_comm_rate   = (double?)jPkglst[i]["productPkg"]["price2CommRate"] ?? 0;
                    model.price2_age_range   = jPkglst[i]["productPkg"]["price2BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price2EndOld"].ToString();
                    model.price2_b2c = (double?)jPkglst[i]["productPkg"]["price2Sale"] ?? 0;
                    // model.price2_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price2_list = (double)jPkglst[i]["productPkg"][""];

                    model.price3             = (double?)jPkglst[i]["productPkg"]["price3"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price3"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price3_org         = (double?)jPkglst[i]["productPkg"]["price3Org"] ?? 0;
                    model.price3_org_net     = (double?)jPkglst[i]["productPkg"]["price3NetOrg"] ?? 0;
                    model.price3_profit_rate = (double?)jPkglst[i]["productPkg"]["price3GrossRate"] ?? 0;
                    model.price3_comm_rate   = (double?)jPkglst[i]["productPkg"]["price3CommRate"] ?? 0;
                    model.price3_age_range   = jPkglst[i]["productPkg"]["price3BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price3EndOld"].ToString();
                    model.price3_b2c = (double?)jPkglst[i]["productPkg"]["price3Sale"] ?? 0;
                    // model.price3_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price3_list = (double)jPkglst[i]["productPkg"][""];

                    model.price4             = (double?)jPkglst[i]["productPkg"]["price4"] == null ? 0 : DiscountRepository.GetCompanyDiscPrice(Int64.Parse(rq.company_xid), (double)jPkglst[i]["productPkg"]["price4"], rq.prod_no, objProd["content"]["product"]["mainCat"].ToString(), ref disc);//分銷價
                    model.price4_org         = (double?)jPkglst[i]["productPkg"]["price4Org"] ?? 0;
                    model.price4_org_net     = (double?)jPkglst[i]["productPkg"]["price4NetOrg"] ?? 0;
                    model.price4_profit_rate = (double?)jPkglst[i]["productPkg"]["price4GrossRate"] ?? 0;
                    model.price4_comm_rate   = (double?)jPkglst[i]["productPkg"]["price4CommRate"] ?? 0;
                    model.price4_age_range   = jPkglst[i]["productPkg"]["price4BegOld"].ToString() + "~" +
                                               jPkglst[i]["productPkg"]["price4EndOld"].ToString();
                    model.price4_b2c = (double?)jPkglst[i]["productPkg"]["price4Sale"] ?? 0;
                    // model.price4_net = (double)jPkglst[i]["productPkg"][""];
                    //  model.price4_list = (double)jPkglst[i]["productPkg"][""];

                    model.status = jPkglst[i]["productPkg"]["status"].ToString();
                    model.norank_min_book_qty = (int)jPkglst[i]["productPkg"]["minOrderNum"];
                    model.norank_max_book_qty = (int)jPkglst[i]["productPkg"]["maxOrderNum"];
                    model.rank_min_book_qty   = (int)jPkglst[i]["productPkg"]["minOrderQty"];
                    model.min_orverage_qty    = (int)jPkglst[i]["productPkg"]["minOrderAdultQty"];
                    model.isMultiple          = jPkglst[i]["productPkg"]["isMultiple"].ToString();
                    model.book_qty            = jPkglst[i]["productPkg"]["orderQty"].ToString();
                    model.unit = jPkglst[i]["productPkg"]["unit"].ToString();

                    model.unit_txt    = jPkglst[i]["productPkg"]["unitTxt"].ToString();
                    model.unit_qty    = (int)jPkglst[i]["productPkg"]["unitQty"];
                    model.pickupTp    = jPkglst[i]["productPkg"]["pickupTp"].ToString();
                    model.pickupTpTxt = jPkglst[i]["productPkg"]["pickupTpTxt"].ToString();
                    model.is_hl       = jPkglst[i]["productPkg"]["isBackUp"].ToString();
                    model.is_event    = jPkglst[i]["productPkg"]["hasEvent"].ToString();

                    var d = jPkglst[i]["productPkg"]["pkgDesc"];
                    if (d.FirstOrDefault() != null)
                    {
                        //取各套餐內的各個敘述
                        List <DescItem> desc = (d["descItems"][0]["content"])
                                               .Select(x => new DescItem {
                            id   = (string)x["id"],
                            desc = (string)x["desc"]
                        }).ToList();
                        model.desc_items = desc;
                    }

                    //組moduleSetting
                    var moduleSet = jPkglst[i]["productPkg"]["moduleSetting"];

                    if (moduleSet.FirstOrDefault() != null)
                    {
                        FlightInfoType fit = new FlightInfoType()
                        {
                            value =
                                moduleSet["flightInfoType"]["value"].ToString()
                        };

                        SendInfoType sit = new SendInfoType()
                        {
                            value =
                                moduleSet["sendInfoType"]["value"].ToString(),
                            country_code =
                                moduleSet["sendInfoType"]["countryCode"].ToString()
                        };

                        VoucherValidInfo vi = new VoucherValidInfo();

                        if (moduleSet["voucherValidInfo"] != null && moduleSet["voucherValidInfo"].Any())
                        {
                            vi.valid_period_type =
                                moduleSet["voucherValidInfo"]["validPeriodType"].ToString();

                            vi.before_specific_date =
                                moduleSet["voucherValidInfo"]["beforeSpecificDate"].ToString();

                            if (moduleSet["voucherValidInfo"]["afterOrderDate"] != null && moduleSet["voucherValidInfo"]["afterOrderDate"].Any())
                            {
                                AfterOrderDate aod = new AfterOrderDate()
                                {
                                    qty  = (int?)moduleSet["voucherValidInfo"]["afterOrderDate"]["qty"],
                                    unit = moduleSet["voucherValidInfo"]["afterOrderDate"]["unit"].ToString()
                                };

                                vi.after_order_date = aod;
                            }
                        }

                        ModuleSetting ms = new ModuleSetting()
                        {
                            flight_info_type   = fit,
                            send_info_type     = sit,
                            voucher_valid_info = vi
                        };

                        model.module_setting = ms;
                    }

                    pkgLst.Add(model);


                    price_model.pkg_no     = model.pkg_no;
                    price_model.price1     = model.price1;
                    price_model.price1_b2c = model.price1_b2c;
                    price_model.price2     = model.price2;
                    price_model.price2_b2c = model.price2_b2c;
                    price_model.price3     = model.price3;
                    price_model.price3_b2c = model.price3_b2c;
                    price_model.price4     = model.price4;
                    price_model.price4_b2c = model.price4_b2c;
                    pkg_price.pkgs.Add(price_model);
                }

                pkg.pkgs          = pkgLst;
                pkg.discount_rule = disc;
                pkg.guid          = Guid.NewGuid().ToString();
                rds.SetProdInfotoRedis(JsonConvert.SerializeObject(pkg_price), "b2d:pkgsPrice:" + pkg.guid, 1440); // 將 pkg_price 存入redis

                //依套餐取回『可售日期』
                pkg.sale_dates = (PkgSaleDateModel)GetPkgSaleDate(rq);;

                #endregion
            } catch (Exception ex) {
                pkg.result     = "10001";
                pkg.result_msg = $"Package ERROR :{ex.Message},{ex.StackTrace}";
                Website.Instance.logger.FatalFormat($"Package ERROR :{ex.Message},{ex.StackTrace}");
            }

            return(pkg);
        }