Ejemplo n.º 1
0
        //付款中途停止導回
        //public IActionResult Failure(string id)
        public IActionResult Failure(string id)
        {
            try
            {
                BookingShowProdModel prodShow  = null;
                DataModel            orderData = null;
                Boolean chkSuccess             = true;

                Website.Instance.logger.Debug($",bookingFailure_id:{id}");

                if (id != null)
                {
                    string prodShowStr = RedisHelper.getRedis("b2d:ec:order:final:prodShow:" + id);
                    if (prodShowStr != null)
                    {
                        prodShow = JsonConvert.DeserializeObject <BookingShowProdModel>(prodShowStr);
                    }
                    string orderDataStr = RedisHelper.getRedis("b2d:ec:order:final:orderData:" + id);
                    if (orderDataStr != null)
                    {
                        orderData = JsonConvert.DeserializeObject <DataModel>(orderDataStr);
                    }
                }
                else
                {
                    chkSuccess = false;
                }
                //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));

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

                ViewData["chkSuccess"] = chkSuccess;
                ViewData["prodShow"]   = prodShow;
                ViewData["orderData"]  = orderData;
                ViewData["prodTitle"]  = title;
                return(View("Success"));
            }
            catch (Exception ex)
            {
                ViewData["errMsg"] = ex.Message.ToString();
                Website.Instance.logger.Debug($"Final_Step3_err:{ex.Message.ToString()}");
                //導到錯誤頁
                return(RedirectToAction("Index", "Error", new ErrorViewModel {
                    ErrorType = ErrorType.Order_Fail
                }));
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        //付款後導回
        public IActionResult Step3(string id)
        {
            try
            {
                BookingShowProdModel prodShow  = null;
                DataModel            orderData = null;
                Boolean chkSuccess             = true;

                //B2d分銷商資料
                string jsondata = TempData[id + "forward"] as string;
                if (string.IsNullOrEmpty(jsondata))
                {
                    chkSuccess = false;
                }

                B2dAccount UserData = null;

                if (id != null && jsondata != null && chkSuccess == true)
                {
                    PmchSslResponse2 res = JsonConvert.DeserializeObject <PmchSslResponse2>(jsondata); //新版
                    Website.Instance.logger.Debug($",bookingStep3_id:{id},bookingStep3_jsondata:{jsondata}");
                    if (res.metadata.status != "0000")                                                 //授權失敗,直接跳付款失敗
                    {
                        chkSuccess = false;
                    }
                    else
                    {
                        Boolean chk = ApiHelper.PaymentValid(id, res);
                        if (chk == false)
                        {
                            chkSuccess = false;
                        }
                    }

                    string prodShowStr = RedisHelper.getRedis("b2d:ec:order:final:prodShow:" + id);
                    if (prodShowStr != null)
                    {
                        prodShow = JsonConvert.DeserializeObject <BookingShowProdModel>(prodShowStr);
                    }
                    string orderDataStr = RedisHelper.getRedis("b2d:ec:order:final:orderData:" + id);
                    if (orderDataStr != null)
                    {
                        orderData = JsonConvert.DeserializeObject <DataModel>(orderDataStr);
                    }
                }
                else
                {
                    chkSuccess = false;
                }

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

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

                ViewData["chkSuccess"] = chkSuccess;
                ViewData["prodShow"]   = prodShow;
                ViewData["orderData"]  = orderData;
                ViewData["prodTitle"]  = title;

                return(View("Success"));
            }
            catch (Exception ex)
            {
                ViewData["errMsg"] = ex.Message.ToString();
                Website.Instance.logger.Debug($"Final_Step3_err:{ex.Message.ToString()}");
                //導到錯誤頁
                return(RedirectToAction("Index", "Error", new ErrorViewModel {
                    ErrorType = ErrorType.Order_Fail
                }));
            }
        }
Ejemplo n.º 4
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
                }));
            }
        }
Ejemplo n.º 5
0
        //付款後導回
        public IActionResult Step3(string id, string jsondata)
        {
            B2dAccount           UserData  = null;
            BookingShowProdModel prodShow  = null;
            DataModel            orderData = null;
            Boolean chkSuccess             = true;

            if (id != null && jsondata != null)
            {
                ////回傳的連結有訂編 (記log)
                ////透過訂編將redis 的資料抓回送出去的資料
                ////取b2dredis 內的paymentDtl
                ////string payDtlStr = RedisHelper.getProdInfotoRedis("b2d:ec:payDtl:" + id);
                ////PaymentDtl payDtl = JsonConvert.DeserializeObject<PaymentDtl>(payDtlStr);

                ////從kkday redis 取出
                ////組出token res:pmgwTransNo, res:pmgwMethod ,res:pmch_resp ceil res:payAmount order_mid
                ////md5($pmgw_trans_no.$pmgw_method.$trans_curr_cd.$trans_amt.$pmch_ref_no.$key);
                ////PmchSslResponse res = JsonConvert.DeserializeObject<PmchSslResponse>(jsondata); //舊版
                PmchSslResponse2 res = JsonConvert.DeserializeObject <PmchSslResponse2>(jsondata); //新版
                //string transNo = GibberishAES.OpenSSLDecrypt(res.data.pmgw_trans_no, "pmgw@%#@trans*no");
                ////CallJsonPay req = JsonConvert.DeserializeObject<CallJsonPay>(RedisHelper.getProdInfotoRedis("b2d:ec:pmchSslRequest:" + id)); //using KKday.Web.B2D.EC.AppCode;
                //CallJsonPay2 req = JsonConvert.DeserializeObject<CallJsonPay2>(RedisHelper.getProdInfotoRedis("b2d:ec:pmchSslRequest:" + id)); //using KKday.Web.B2D.EC.AppCode;

                //string token = Website.Instance.Configuration["kkdayKey:pmgwValidToken"].ToString();
                //string pmgwMethod = res.data.pmgw_method;

                //string payCurrency = res.data.pay_currency;
                //string payAmount = Math.Ceiling(res.data.pay_amount).ToString();
                //string pmgwValidToken = MD5Tool.GetMD5(transNo + pmgwMethod + payCurrency + payAmount + id + token);

                //KKapiHelper helper = new KKapiHelper();
                //必須要再呼叫一次要讓FA 知道這個授權是kkday做的!而不是robot
                //string isSuccess = helper.PaymentValid(transNo, pmgwValidToken);

                //如果ok就upd

                //helper.PayUpdSuccessUpdOrder(id, transNo, payDtl, req, res, fakeContact);//舊版
                //helper.PayUpdSuccessUpdOrder2(id, transNo, payDtl, req, res, fakeContact); //新版

                Website.Instance.logger.Debug($",bookingStep3_id:{id},bookingStep3_jsondata:{jsondata}");

                if (res.metadata.status != "0000") //授權失敗,直接跳付款失敗
                {
                    chkSuccess = false;
                }
                else
                {
                    Boolean chk = ApiHelper.PaymentValid(id, jsondata);
                    if (chk == false)
                    {
                        chkSuccess = false;
                    }
                }

                string prodShowStr = RedisHelper.getRedis("b2d:ec:order:final:prodShow:" + id);
                if (prodShowStr != null)
                {
                    prodShow = JsonConvert.DeserializeObject <BookingShowProdModel>(prodShowStr);
                }
                string orderDataStr = RedisHelper.getRedis("b2d:ec:order:final:orderData:" + id);
                if (orderDataStr != null)
                {
                    orderData = JsonConvert.DeserializeObject <DataModel>(orderDataStr);
                }
            }
            else
            {
                chkSuccess = false;
            }

            //取挖字
            //B2d分銷商資料
            var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();

            UserData = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

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

            ViewData["chkSuccess"] = chkSuccess;
            ViewData["prodShow"]   = prodShow;
            ViewData["orderData"]  = orderData;
            ViewData["prodTitle"]  = title;

            return(View("Success"));
        }