public List <BSM_Result> web_batch_purchase(string token, string software_version, purchase_list purchase_order, string otpw, string authority) { List <BSM_Result> results = new List <BSM_Result>(); foreach (BSM_Purchase_Request vp in purchase_order.purchases) { BSM_Result result = _purchase_base.purchase(null, vp.device_id, software_version, vp, null, otpw, authority, null, null); results.Add(result); } return(results); }
public JsonObject check_promo_code(string client_id, string device_id, string promo_code, string pay_type, string package_id) { // promo_code = promo_code.ToUpper(); JsonObject _result = new JsonObject(); BSM_Result _result_bsm = new BSM_Result(); _result_bsm.result_code = "BSM-00000"; _result_bsm.result_message = ""; JsonObject promotion_json = new JsonObject(); List <promotion_info> _promo_infos = _info_base.get_promtion_code(promo_code.ToUpper()); if (_promo_infos == null || _promo_infos.Count <= 0) { _result_bsm.result_code = "BSM-07001"; } else { List <promotion_info> _promo_infos_2 = (from _promo in _promo_infos where _promo.discount_package_id == package_id select _promo).ToList(); if (_promo_infos_2.Count == 0) { _result_bsm.result_code = "BSM-07002"; } else { promotion_info _promo_info = _promo_infos_2[0]; if (_promo_info.status == false) { _result_bsm.result_code = "BSM-07003"; } if (_promo_info.end_date <= DateTime.Now) { _result_bsm.result_code = "BSM-07006"; } if (_promo_info.client_cnt_limit > 0) { List <purchase_info> _purchase_info = _info_base.cache_client_purchase(client_id, false).purchases; int cnt = (from pur in _purchase_info where pur.promo_code == _promo_info.promo_code && pur.promo_code == _promo_info.promo_code select pur).ToList().Count; if (cnt >= _promo_info.client_cnt_limit) { _result_bsm.result_code = "BSM-07004"; } } List <package_info> all_packages = _info_base.get_all_package(); var package_info = _info_base.get_package_info_by_id(client_id, "BUY", 0, device_id, package_id, null); if (package_info["recurrent"].ToString() == "R" && package_info["current_recurrent_status"].ToString() == "R") { _result_bsm.result_code = "BSM-07008"; _result_bsm.result_message = "已使用自動扣款方案,無法使用自動扣款"; } if (_promo_info.nobuy_from != null) { string[] pay_type_list = { "CREDIT", "信用卡", "ATM", "REMIT", "信用卡二次扣款", "GOOGLE", "IOS", "HINET", "GOOGLEPLAY" }; List <purchase_info> _purchase_info = _info_base.cache_client_purchase(client_id, false).purchases; List <purchase_info> l = (from pur in _purchase_info where String.Compare(pur.purchase_date, _promo_info.nobuy_from.Value.ToString("yyyy/MM/dd")) >= 0 && pay_type_list.Contains(pur.pay_type) select pur).ToList(); foreach (var la in l) { foreach (var dtl in la.details) { List <package_info> pks = (from pkg in all_packages where pkg.package_id == dtl.package_id select pkg).ToList(); if (pks != null && pks.Count > 0) { package_info pk = pks[0]; if (pk.catalog_id == _promo_info.discount_package_cat_id1) { _result_bsm.result_code = "BSM-07007"; _result_bsm.result_message = "不符資格,非新會員購買"; } } } } } if (_promo_info.check_client) { List <promotion_clients> lc = new List <promotion_clients>(); lc = _info_base.get_promotion_client(_promo_info.promo_code, client_id); if (lc.Count == 0) { _result_bsm.result_code = "BSM-07005"; } } if (_result_bsm.result_code == "BSM-00000") { promotion_json = (JsonObject)JsonConvert.Import(JsonConvert.ExportToString(_promo_info)); promotion_json.Remove("promo_info"); JsonObject _promo_info_json = new JsonObject(); if (_promo_info.promo_info != "") { _promo_info_json = (JsonObject)JsonConvert.Import(_promo_info.promo_info); } foreach (var a in _promo_info_json) { promotion_json.Add(a.Name, a.Value); } JsonObject _package = this.get_package_info_by_id(null, "LTWEB00", null, null, package_id); if (_package != null) { try { List <JsonObject> _packages_options = (List <JsonObject>)_package["options"]; foreach (JsonObject a in _packages_options) { /* if (Convert.ToDecimal(a["amount"]) > 0) * { * a["enabled"] = false; * } * else * { a["enabled"] = true; } */ a["enabled"] = true; } } catch (InvalidCastException e) { List <JsonObject> _packages_options = new List <JsonObject>(); } catch (NullReferenceException e) { } } // promotion_json.Add("options", _package["options"]); promotion_json.Add("option_title", _package["option_title"]); promotion_json.Add("option_subtitle", _package["option_subtitle"]); } } } _result = (JsonObject)JsonConvert.Import(JsonConvert.ExportToString(_result_bsm)); if (_result_bsm.result_code == "BSM-00000") { foreach (var a in promotion_json) { _result.Add(a.Name, a.Value); } } _result.Remove("purchase"); _result.Remove("purchase_list"); return(_result); }
/// <summary> /// 登錄coupon 號碼 /// </summary> /// <param name="token"></param> /// <param name="Client_Info"></param> /// <param name="Coupon_NO"></param> /// <returns></returns> public BSM_Result register_coupon(string token, BSM_ClientInfo client_info, string coupon_no, string device_id, string sw_version) { BSM_Result _result; BSM_Info.BSM_Info_Service_base BSM_Info_base = new BSM_Info.BSM_Info_Service_base(conn.ConnectionString, MongoDBConnectString, MongoDB_Database); _result = new BSM_Result(); BSM_ClientInfo v_Client_Info = new BSM_ClientInfo(); string coupon_mas_no; if (coupon_no == null || coupon_no == "") { _result.result_code = "BSM-00609"; _result.result_message = "沒有Coupon NO"; _result.client = v_Client_Info; return(_result); } conn.Open(); string sql1 = "begin :M_RESULT := BSM_CLIENT_SERVICE.register_coupon(:M_CLIENT_INFO,:P_COUPON_NO,:P_SRC_NO,:P_SW_VERSION); end; "; TBSM_CLIENT_INFO t_client_info = new TBSM_CLIENT_INFO(); TBSM_RESULT bsm_result = new TBSM_RESULT(); t_client_info.SERIAL_ID = client_info.client_id; t_client_info.OWNER_PHONE = client_info.owner_phone_no; if (device_id != null) { t_client_info.MAC_ADDRESS = device_id; } else { t_client_info.MAC_ADDRESS = client_info.mac_address; } OracleCommand cmd = new OracleCommand(sql1, conn); try { cmd.BindByName = true; OracleParameter param1 = new OracleParameter(); param1.ParameterName = "M_CLIENT_INFO"; param1.OracleDbType = OracleDbType.Object; param1.Direction = ParameterDirection.InputOutput; param1.UdtTypeName = "TBSM_CLIENT_INFO"; param1.Value = t_client_info; cmd.Parameters.Add(param1); OracleParameter param2 = new OracleParameter(); param2.ParameterName = "P_COUPON_NO"; param2.OracleDbType = OracleDbType.Varchar2; param2.Direction = ParameterDirection.InputOutput; param2.Value = coupon_no; cmd.Parameters.Add(param2); OracleParameter param4 = new OracleParameter(); param4.ParameterName = "P_SRC_NO"; param4.OracleDbType = OracleDbType.Varchar2; param4.Direction = ParameterDirection.InputOutput; param4.Size = 64; param4.Value = "12345678"; cmd.Parameters.Add(param4); OracleParameter param3 = new OracleParameter(); param3.ParameterName = "M_RESULT"; param3.OracleDbType = OracleDbType.Object; param3.Direction = ParameterDirection.InputOutput; param3.UdtTypeName = "TBSM_RESULT"; cmd.Parameters.Add(param3); OracleParameter param5 = new OracleParameter(); param5.ParameterName = "P_SW_VERSION"; param5.OracleDbType = OracleDbType.Varchar2; param5.Direction = ParameterDirection.InputOutput; param5.Size = 64; param5.Value = sw_version ?? client_info.sw_version; cmd.Parameters.Add(param5); cmd.ExecuteNonQuery(); bsm_result = (TBSM_RESULT)param3.Value; coupon_mas_no = param4.Value.ToString(); if (bsm_result.RESULT_CODE == "BSM-00000") { _result.purchase_list = BSM_Info_base.get_purchase_info(client_info.client_id, client_info.mac_address, coupon_mas_no); } if (bsm_result.RESULT_CODE != "BSM-00000") { _result.result_code = bsm_result.RESULT_CODE; _result.result_message = bsm_result.RESULT_MESSAGE; _result.client = v_Client_Info; return(_result); } } finally { conn.Close(); cmd.Dispose(); } _result.result_code = bsm_result.RESULT_CODE; _result.result_message = bsm_result.RESULT_MESSAGE; _result.client = v_Client_Info; return(_result); }
public BSM_Result modify_purchase(string token, string software_version, string purchase_id, BSM_Purchase_Request purchase_info) { BSM_Result result = _purchase_base.modify_purchase(purchase_id, purchase_info); return(result); }
public BSM_Result web_batch_purchase(string token, string software_version, BSM_Purchase_Request purchase_info, JsonObject cht_params, string otpw, string authority, string user_agent, string browser_type) { BSM_Result result = _purchase_base.purchase(null, purchase_info.device_id, software_version, purchase_info, cht_params, otpw, authority, user_agent, browser_type); return(result); }