public Boolean SaveStore(Store_Info storeinfo) { if (string.IsNullOrEmpty(storeinfo.Store_Info_ID.ToString())) // New Record { using (UtilitySaleDBContext dbContext = new UtilitySaleDBContext()) { dbContext.Store_Info.Add(storeinfo); dbContext.SaveChanges(); return(true); } } else // Update Record { using (UtilitySaleDBContext dbContext = new UtilitySaleDBContext()) { Store_Info info = dbContext.Store_Info.Where(x => x.Store_Info_ID == storeinfo.Store_Info_ID).FirstOrDefault(); info.Store_Name = storeinfo.Store_Name; info.Is_Active = storeinfo.Is_Active; info.Updated_On = DateTime.Now; info.Updated_By = "User"; dbContext.SaveChanges(); return(true); } } }
public void BindData() { UtilityData utilitydata = new UtilityData(); Store_Info store_info = utilitydata.GetStoreInfoByStoreInfoID(Convert.ToInt32(Request.QueryString["StoreInfoID"])); txtStoreName.Text = store_info.Store_Name; if (store_info.Is_Active == true) { chkIsActive.Checked = true; } else { chkIsActive.Checked = false; } }
public IActionResult Unifiedorder(UnidiedorderData udata) { using (_dbContext) { var response = ResponseModelFactory.CreateResultInstance; var stu = _dbContext.StudentBill.FirstOrDefault(x => x.StudentBillUuid == udata.BillGuid); if (stu == null) { response.SetFailed("未查找到对应缴费信息"); return(Ok(response)); } if (stu.OrderMoney >= stu.AmountPayable) { response.SetFailed("已缴费"); return(Ok(response)); } //时间戳 string timeStamp = TenPayV3Util.GetTimestamp(); //随机字符串 string nonceStr = TenPayV3Util.GetNoncestr(); string appid = "wx0bf342f51437ca67"; //获取学校绑定商户信息 var school = _dbContext.School.FirstOrDefault(x => x.SchoolUuid == udata.Guid); if (school == null) { response.SetFailed("未查找到对应学校"); return(Ok(response)); } if (school.Yard == null || school.Secretkey == null) { response.SetFailed("未查找到对应学校商户信息"); return(Ok(response)); } //商户号 string mch_id = school.Yard; //"1600884893"; //商户支付秘钥 string partnerKey = AES.AesDecrypt(school.Secretkey, HaiKan3.Utils.AES.Key); //"ew6QCdWiDfcif902EbC07dh0icTuM5le"; //签名 string sign = ""; string sign_type = "MD5"; //商品描述 string body = udata.Body; //商户订单号 string out_trade_no = ""; //标价金额(单位:分) int total_fee = udata.Totalfee; //终端IP //string spbill_create_ip = "183.158.56.51"; //Request.HttpContext.Connection.RemoteIpAddress.ToString(); string spbill_create_ip = Request.HttpContext.Connection.RemoteIpAddress.ToString(); _logger.LogInformation("ip:" + spbill_create_ip); //通知地址 string notify_url = "http://msz-b.jiulong.yoruan.com/test/PayCallBack"; //string notify_url = "http://msz-b.jiulong.yoruan.com/api/v1/student/StudentBill/PayCallBack"; //交易类型 string trade_type = "JSAPI"; //预支付id string prepayId = ""; //微信调用支付的签名 string paySign = ""; //用户openid string openid = udata.Openid; Store_Info info = new Store_Info() { address = "xxxxxx", area_code = "330185", id = "MSZzf" + appid, name = "码上知支付商城", }; TenPayV3UnifiedorderRequestData_SceneInfo sceneInfo = new TenPayV3UnifiedorderRequestData_SceneInfo(false); sceneInfo.store_info = info; //生成订单号 out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmss") + TenPayV3Util.BuildRandomStr(14); _logger.LogInformation("订单号:" + out_trade_no); TenPayV3UnifiedorderRequestData requestData = new TenPayV3UnifiedorderRequestData(appid, mch_id, body, out_trade_no, total_fee, spbill_create_ip, notify_url, Senparc.Weixin.TenPay.TenPayV3Type.JSAPI, openid, partnerKey, nonceStr, null, DateTime.Now, DateTime.Now.AddHours(2), null, null, "CNY", null, null, false, sceneInfo, null); var urlFormat = ReurnPayApiUrl("https://api.mch.weixin.qq.com/{0}pay/unifiedorder"); var data = requestData.PackageRequestHandler.ParseXML();//获取XML _logger.LogInformation("xml:" + data); var str = PostXmlMethod.PostXmla(urlFormat, data); _logger.LogInformation("postxml:" + str); DataSet ds = new DataSet(); StringReader stream = new StringReader(str); //读取字符串为数据量 XmlTextReader reader = new XmlTextReader(stream); //对XML的数据流的只进只读访问 ds.ReadXml(reader); //把数据读入DataSet if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["return_code"].ToString() == "SUCCESS") { _logger.LogInformation("成功"); _logger.LogInformation("timeStamp:" + timeStamp + "; nonceStr:" + nonceStr + "; prepayId:" + ds.Tables[0].Rows[0]["prepay_id"].ToString() + "; paySign:" + ds.Tables[0].Rows[0]["sign"].ToString() + "; partnerKey:" + partnerKey); response.SetData(new { appid = ds.Tables[0].Rows[0]["appid"].ToString(), timeStamp, nonceStr, prepayId = ds.Tables[0].Rows[0]["prepay_id"].ToString(), sign_type, paySign = ds.Tables[0].Rows[0]["sign"].ToString(), sjcode = Electroniccode.getString(32), key = partnerKey, outtradeno = out_trade_no }); BillState bill = new BillState() { BillUuid = Guid.NewGuid(), BillNum = out_trade_no, Appid = appid, MchId = mch_id, Money = total_fee, Key = partnerKey, SbillUuid = udata.BillGuid, }; _logger.LogInformation("订单记录:" + JsonConvert.SerializeObject(bill)); _dbContext.BillState.Add(bill); _dbContext.SaveChanges(); return(Ok(response)); } else { response.SetFailed(ds.Tables[0].Rows[0]["return_msg"].ToString()); _logger.LogInformation("异常"); _logger.LogInformation(ds.Tables[0].Rows[0]["return_msg"].ToString()); return(Ok(response)); } } else { response.SetFailed("订单信息为空"); return(Ok(response)); } } }