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); }
//付款後導回 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 })); } }
//新版 public static PmchSslRequest3 setPaymentInfo2(ProductModel prod, DataModel data, string orderMid, B2dAccount UserData, Pmgw pmgw, string memUuid) { PmchSslRequest3 pmch = new PmchSslRequest3(); pmch.api_key = "kkdayapi"; pmch.user_oid = "1"; pmch.ver = "1.0.1"; pmch.lang_code = "zh-tw"; pmch.ipaddress = "127.0.0.1"; CallJsonPay2 json = new CallJsonPay2(); json.pmch_oid = pmgw.pmchOid; json.is_3d = "0"; json.pay_currency = data.currency; json.pay_amount = Convert.ToDouble(data.currPriceTotal); json.return_url = Website.Instance.Configuration["payRtnUrl:returnUrl"].ToString() + orderMid; json.cancel_url = Website.Instance.Configuration["payRtnUrl:returnUrl"].ToString() + orderMid; json.user_locale = UserData.LOCALE;// "zh-tw"; json.paymentParam1 = ""; json.paymentParam2 = ""; if (prod.img_list.Count > 0) { json.logo_url = Website.Instance.Configuration["kkUrl:imgUrl"].ToString() + prod.img_list[0].img_kkday_url; } else { json.logo_url = ""; } payment_source_info pay = new payment_source_info(); pay.source_type = "KKDAY"; pay.order_mid = orderMid; json.payment_source_info = pay; credit_card_info credit = new credit_card_info(); credit.card_holder = data.card.cardHolder; credit.card_no = data.card.cardNo.Replace(" ", ""); credit.card_type = data.card.cardType;//"VISA"; credit.card_cvv = data.card.cardCvv; data.card.expiry = data.card.expiry.Replace(" ", "").Replace("/", ""); credit.card_exp = "20" + data.card.expiry.Substring(2, 2) + data.card.expiry.Substring(0, 2);// "202312"; json.credit_card_info = credit; payer_info payer = new payer_info(); payer.first_name = UserData.NAME_LAST; payer.last_name = UserData.NAME_LAST; payer.phone = UserData.TEL; payer.email = UserData.EMAIL; json.payer_info = payer; product_info prodInfo = new product_info(); prodInfo.prod_name = prod.prod_name; prodInfo.prod_oid = prod.prod_no.ToString(); json.product_info = prodInfo; member member = new member(); member.member_uuid = memUuid; member.risk_status = "01"; member.ip = "127.0.0.1"; json.member = member; pmch.json = json; return(pmch);// JsonConvert.SerializeObject(pmch); }
//成立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; OrderDiscountRule rule = new OrderDiscountRule(); if (discRule.isRule == true) { double discAmt = 0; if (confirm.price1Qty > 0) { discAmt = discAmt + Convert.ToDouble((pkg.price1_org - pkg.price1) * confirm.price1Qty); } if (confirm.price2Qty > 0) { discAmt = discAmt + Convert.ToDouble((pkg.price2_org - pkg.price2) * confirm.price2Qty); } if (confirm.price3Qty > 0) { discAmt = discAmt + Convert.ToDouble((pkg.price3_org - pkg.price3) * confirm.price2Qty); } if (confirm.price4Qty > 0) { discAmt = discAmt + Convert.ToDouble((pkg.price4_org - pkg.price4) * confirm.price3Qty); } rule.disc_amt = discAmt; rule.disc_currency = UserData.CURRENCY; rule.disc_name = discRule.disc_name; rule.disc_note = ""; order.order_discount_rule = rule; } else { order.order_discount_rule = rule; } //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()); } }
public static UserAccount UserAuth(string email, string password) { Npgsql.NpgsqlConnection conn = new NpgsqlConnection(Website.Instance.SqlConnectionString); UserAccount _account = null; try { // 連接Posgresql conn.Open(); string sqlStmt = @"SELECT *, name_last || name_first AS Name FROM b2b.b2d_account_kkday WHERE enable=true AND LOWER(email)=LOWER(:email) AND password=:password"; NpgsqlParameter[] sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("email", email), new NpgsqlParameter("password", password) }; var ds = NpgsqlHelper.ExecuteDataset(conn, CommandType.Text, sqlStmt, sqlParams); // 檢查是否為有效KKday使用者 if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; _account = new KKdayAccount() { XID = dr.ToInt64("xid"), UUID = dr.ToStringEx("user_uuid"), EMAIL = dr.ToStringEx("email"), NAME = dr.ToStringEx("name"), NAME_FIRST = dr.ToStringEx("name_first"), NAME_LAST = dr.ToStringEx("name_last"), DEPARTMENT = dr.ToStringEx("department"), ENABLE = dr.ToBoolean("enable"), //GENDER_TITLE = dr.ToStringEx("gender_title"), //JOB_TITLE = dr.ToStringEx("job_title"), STAFF_NO = dr.ToStringEx("staff_no"), ROLES = dr.ToStringEx("roles"), LOCALE = dr.ToStringEx("locale") }; } // 檢查是否為分銷商有效使用者 else { sqlStmt = @"SELECT a.xid, a.user_uuid, a.email, a.name_first, a.name_last, a.name_last || a.name_first AS name, a.department, a.job_title, a.enable, a.gender_title, b.xid as comp_xid, b.comp_name, b.comp_locale AS locale, b.comp_currency AS currency FROM b2b.b2d_account a JOIN b2b.b2d_company b ON a.company_xid=b.xid AND b.status='03' --已核准 WHERE enable=true AND LOWER(email)=LOWER(:email) AND password=:password"; sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("email", email), new NpgsqlParameter("password", password) }; ds = NpgsqlHelper.ExecuteDataset(conn, CommandType.Text, sqlStmt, sqlParams); //已核准分銷商登入 if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; _account = new B2dAccount() { XID = dr.ToInt64("xid"), UUID = dr.ToStringEx("user_uuid"), EMAIL = dr.ToStringEx("email"), NAME = dr.ToStringEx("name"), NAME_FIRST = dr.ToStringEx("name_first"), NAME_LAST = dr.ToStringEx("name_last"), COMPANY_XID = dr.ToInt64("comp_xid"), COMPANY_NAME = dr.ToStringEx("comp_name"), DEPARTMENT = dr.ToStringEx("department"), ENABLE = dr.ToBoolean("enable"), GENDER_TITLE = dr.ToStringEx("gender_title"), JOB_TITLE = dr.ToStringEx("job_title"), CURRENCY = dr.ToStringEx("currency"), LOCALE = dr.ToStringEx("locale") }; } //待審中分銷商登入 else { sqlStmt = @"SELECT a.xid, a.user_uuid, a.email, a.name_first, a.name_last, a.name_last || a.name_first AS name, a.department, a.job_title, a.enable, a.gender_title, b.xid as comp_xid, b.comp_name, b.comp_locale AS locale, b.comp_currency AS currency FROM b2b.b2d_account a JOIN b2b.b2d_company b ON a.company_xid=b.xid AND b.status!='03' --除了已核准外 WHERE enable=false AND LOWER(email)=LOWER(:email) AND password=:password"; sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("email", email), new NpgsqlParameter("password", password) }; ds = NpgsqlHelper.ExecuteDataset(conn, CommandType.Text, sqlStmt, sqlParams); DataRow dr = ds.Tables[0].Rows[0]; _account = new B2dAccount() { XID = dr.ToInt64("xid"), UUID = dr.ToStringEx("user_uuid"), EMAIL = dr.ToStringEx("email"), NAME = dr.ToStringEx("name"), ENABLE = dr.ToBoolean("enable"), }; } } conn.Close(); } catch (Exception ex) { if (conn.State != ConnectionState.Closed) { conn.Close(); } Website.Instance.logger.FatalFormat("{0},{1}", ex.Message, ex.StackTrace); throw ex; } return(_account); }
//付款後導回 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")); }
// [共用]修改分銷商單一帳號資訊 public void UpdateAccount(B2dAccount acct, string upd_user) { AccountDAL.UpdateAccount(acct, upd_user); }
// [共用]修改分銷商單一帳號資訊 public void UpdateAccount(B2dAccount acct, string upd_user) { B2dAccount acc = acct as B2dAccount; ApiAccountDAL.UpdateAccount_Api(acc, upd_user); }