public static void WriteTextLog(DateTime time, string str1) { string path = AppDomain.CurrentDomain.BaseDirectory + @"合同\Log\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileFullPath = path + MyCommFun.RequestParam("pickname") + "护理合同" + time.ToString("yyyy-MM-dd") + ".txt"; string str = str1; StreamWriter sw; if (!File.Exists(fileFullPath)) { sw = File.CreateText(fileFullPath); } else { sw = File.AppendText(fileFullPath); } sw.WriteLine(str.ToString()); sw.Close(); }
public void ProcessRequest(HttpContext context) { string type = MyCommFun.RequestParam("type"); if (type == "list") { int pagesize = MyCommFun.RequestInt("pagesize"); int pageindex = MyCommFun.RequestInt("pageindex"); string str = MyCommFun.RequestParam("str"); if (pageindex == 1) { context.Response.ContentType = "text/json"; context.Response.Write(GetJsonByDataset(GetList(str))); } else { context.Response.ContentType = "text/json"; context.Response.Write(null); } } else if (type == "tell") { string strwhere = MyCommFun.RequestParam("strwh"); context.Response.ContentType = "text/json"; context.Response.Write(GetJsonByDataset(Get_tell(strwhere))); } else if (type == "back") { string stt = MyCommFun.RequestParam("stt"); context.Response.ContentType = "text/json"; context.Response.Write(GetJsonByDataset(GetList(stt))); } }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (errInitTemplates != "") { Response.Write(errInitTemplates); return; } //1获得模版基本信息 BLL.wx_module_templates tBll = new BLL.wx_module_templates(); templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid); if (templateFileName == null || templateFileName.Trim() == "") { errInitTemplates = "不存在该帐号或者该帐号尚未设置模版!"; Response.Write(errInitTemplates); Response.End(); return; } serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/so.html"; ShopTemplateMgr template = new ShopTemplateMgr("/shop/templates/" + templateFileName, serverPath, wid); template.tType = TemplateType.Channel; template.openid = MyCommFun.RequestOpenid(); template.soStr = MyCommFun.RequestParam("sostr"); template.OutPutHtml(wid); }
/// <summary> /// 写入日志到文本文件 /// </summary> /// <param name="action">动作</param> /// <param name="strMessage">日志内容</param> /// <param name="time">时间</param> public static void WriteTextLog(DateTime time) { string path = AppDomain.CurrentDomain.BaseDirectory + @"合同\Log\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileFullPath = path + MyCommFun.RequestParam("pickname") + "护理合同" + time.ToString("yyyy-MM-dd") + ".txt"; StringBuilder str = new StringBuilder(); str.Append(" 甲方:甘肃维盛科技劳务服务有限公司 "); str.AppendLine("\n"); str.Append(" 乙方:微信用户:" + MyCommFun.RequestParam("pickname") + " "); str.AppendLine(); str.Append(" 一、甲方从 " + DateTime.Now.ToString() + " 时开始向乙方提供医院陪护人员,护理地点为:医院。甲方给乙方陪护伤病人员。"); str.AppendLine("\n"); str.Append(" 二、感谢你的反馈、吃药、翻身、勤换衣物、协助病人大小便、保证卫生良好,即时找护士、大夫反应情况,以便为病人早日康复创造良好条件。"); str.AppendLine("\n"); str.Append(" 三、医院陪护人员夜间班和白班分别为10个小时,夜间班护理费为人民币 元钱。白天班护理费为人民币 元钱,全日班24小时值班陪护,全日班护理费为每班(24小时)人民币 元钱,乙方给护理人员提供夜间不离岗休息条件,乙方管吃管住。 "); str.AppendLine(); str.Append(" 四、乙方应先付款,付款后甲方才指派陪护员工上岗。乙方只能对甲方结算费用,陪护员工资由甲方支付。乙方不得与陪护人员私自建立陪护服务关系,不得私自将费用结算给甲方所提供的陪护员工。 "); str.AppendLine(); str.Append(" 五、甲方应加强对所提供陪护员工的管理,保证服务质量。乙方有权对甲方所提供的陪护员工提出以下要求:在乙方处工作值班时微笑,热情主动,勤快,不准随便远离值班岗位,值班间中午不准喝酒,不准长时间看书报。乙方有权对陪护员工监督、批评、纠正。 "); str.AppendLine(); str.Append(" 六、甲乙双方在合作中,如乙方对甲方所提供陪护员的工作不满意,乙方可通知甲方更换陪护人员,定价不变。所提供的陪护员只要在乙方处工作服务,本合同一直有效。 "); str.AppendLine(); str.Append(" 七、乙方应自己管好自己的财物,不得借给员工钱物。否则对员工的债务,甲方不承担清偿责任;乙方如发生被骗、窃的后果,乙方应即时向公安部门报案处理,甲方只负责协助乙方及执法部门处理此案,甲方不负任何经济赔偿责任。乙方不得以此为由拒付甲方的陪护费。 "); str.AppendLine(); str.Append(" 八、乙方应提供一至两个有不亲友的家庭住址、身份证复印件及联系电话给甲方及甲方的陪护员,以便乙方被陪护的亲属由特殊情况时能及时通知。 "); str.AppendLine(); str.Append("--------------------------------------------------------------"); str.AppendLine(); StreamWriter sw; if (!File.Exists(fileFullPath)) { sw = File.CreateText(fileFullPath); } else { sw = File.AppendText(fileFullPath); } sw.WriteLine(str.ToString()); sw.Close(); }
protected void Page_Load(object sender, EventArgs e) { id = MyCommFun.RequestParam("id"); quest = MyCommFun.RequestParam("quest"); create = MyCommFun.RequestParam("creadate"); load = MyCommFun.RequestParam("load"); openid = MyCommFun.RequestParam("openid"); }
public void ProcessRequest(HttpContext context) { int number = MyCommFun.RequestInt("number"); int page = MyCommFun.RequestInt("page"); string where = MyCommFun.RequestParam("where"); string open_id = MyCommFun.RequestParam("open_idss"); string action = MyCommFun.RequestParam("action"); string mmm = "Hg_number asc"; int recordCount = 0; int ord = MyCommFun.RequestInt("orderid"); string order_123 = MyCommFun.RequestParam("order_123"); string pic_name = MyCommFun.RequestParam("pickname"); if (action == "no_order") { context.Response.ContentType = "text/json"; context.Response.Write(MyCommFun.GetJsonByDataset(No_order(open_id, where))); } else if (action == "delete_order") { Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict = new Dictionary <string, string>(); BLL.HG.Hg_list order = new BLL.HG.Hg_list(); order.DeleteList(ord); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "删除成功!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else if (action == "pay_update") { Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict = new Dictionary <string, string>(); BLL.HG.Hg_list order = new BLL.HG.Hg_list(); order.update("已支付", order_123); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "更新成功!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else if (action == "File") { Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict = new Dictionary <string, string>(); BLL.HG.Hg_list order = new BLL.HG.Hg_list(); WriteTextLog(DateTime.Now); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "更新成功!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else { context.Response.Write(MyCommFun.GetJsonByDataset(Hgdata(8, page))); } }
public string OrderQuery() { int orderId = MyCommFun.RequestInt("orderid"); int wid = MyCommFun.RequestInt("wid"); string code = MyCommFun.RequestParam("code"); string state = MyCommFun.RequestParam("state"); BLL.wx_payment_wxpay wxPayBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = wxPayBll.GetModelByWid(wid); BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); BLL.orders otBll = new BLL.orders(); Model.orders orderEntity = otBll.GetModel(orderId, wid); litout_trade_no = orderEntity.order_no; string nonceStr = TenPayV3Util.GetNoncestr(); RequestHandler packageReqHandler = new RequestHandler(null); //设置package订单参数 packageReqHandler.SetParameter("appid", paymentInfo.appId); //公众账号ID packageReqHandler.SetParameter("mch_id", paymentInfo.partnerId); //商户号 packageReqHandler.SetParameter("transaction_id", ""); //填入微信订单号 packageReqHandler.SetParameter("out_trade_no", litout_trade_no); //填入商家订单号 packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串 string sign = packageReqHandler.CreateMd5Sign("key", paymentInfo.paySignKey); packageReqHandler.SetParameter("sign", sign); //签名 string data = packageReqHandler.ParseXML(); var result = TenPayV3.OrderQuery(data); var res = XDocument.Parse(result); openid = res.Element("xml").Element("sign").Value; string transaction_id = res.Element("xml").Element("sign").Value; openids = res.Element("xml").Element("openid").Value; bank_type = res.Element("xml").Element("bank_type").Value; if (bank_type == "CNY") { bank_type = "钱包零钱"; } if (bank_type == "CFT") { bank_type = "银行卡"; } total_fee = res.Element("xml").Element("total_fee").Value; time_end = res.Element("xml").Element("time_end").Value; out_trade_no = res.Element("xml").Element("out_trade_no").Value; transaction_id = res.Element("xml").Element("transaction_id").Value; result_code = res.Element("xml").Element("result_code").Value; return(openid); }
public void ProcessRequest(HttpContext context) { string channel_name = MyCommFun.RequestParam("channel_name"); int pagesize = MyCommFun.RequestInt("page"); string orderby1 = "id asc"; int pageindex = MyCommFun.RequestInt("index"); int recordCount = 0; context.Response.ContentType = "text/json"; context.Response.Write(MyCommFun.GetJsonByDataset(GetList(channel_name, category_id, pagesize, pageindex, "wid=" + wid, orderby1, out recordCount))); }
public void GetHongNao() { int wid = MyCommFun.RequestInt("wid"); int aid = MyCommFun.RequestInt("aid"); string openid = MyCommFun.RequestParam("openid"); if (openid == "" && openid == null) { jsonDict.Add("re", "error"); jsonDict.Add("remsg", "参数错误!"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } Model.wx_hb_base hb = new Model.wx_hb_base(); BLL.wx_hb_base hbbll = new BLL.wx_hb_base(); hb = hbbll.GetModel(aid); Random ran = new Random(); int RandKey = ran.Next(int.Parse(hb.pricemin.ToString()), int.Parse(hb.pricemax.ToString())); string nonceStr = ""; string paySign = ""; // NormalRedPackResult normalReturn = new NormalRedPackResult(); // normalReturn = RedPayApi.SendNormalRedPack(hb.appID, hb.paynum, hb.paypass, hb.payZSadd, openid, hb.payname, hb.payreIP, RandKey, hb.zftxt, hb.title, hb.depict, out nonceStr, out paySign); // if (normalReturn.return_msg == "发送成功") // { Model.wx_hb_userinfo hbuserM = new Model.wx_hb_userinfo(); DAL.wx_hb_userinfo hbuserDAL = new DAL.wx_hb_userinfo(); hbuserM.aid = aid; hbuserM.openid = openid; hbuserM.price = RandKey; hbuserM.addtime = DateTime.Now; hbuserDAL.Add(hbuserM); // } jsonDict.Add("re", "ok"); // jsonDict.Add("remsg", normalReturn.return_msg); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; }
// string pass = MyCommFun.RequestParam("pass_1"); public void ProcessRequest(HttpContext context) { string action = MyCommFun.RequestParam("action"); int user = MyCommFun.RequestInt("Hg_number"); string order = MyCommFun.RequestParam("order_number"); string text = MyCommFun.RequestParam("text"); if (action == "Suc_pay") { context.Response.ContentType = "text/json"; context.Response.Write(MyCommFun.GetJsonByDataset(Get_pay(user))); } else if (action == "all_suc") { context.Response.ContentType = "text/json"; context.Response.Write(MyCommFun.GetJsonByDataset(Get_all(user))); } else if (action == "upload_start") { if (Update_start(text, order) == true) { context.Response.ContentType = "text/json"; Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict = new Dictionary <string, string>(); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "更新成功!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } else { context.Response.ContentType = "text/json"; Dictionary <string, string> jsonDict = new Dictionary <string, string>(); jsonDict = new Dictionary <string, string>(); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "fail!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart(); string _action = MyCommFun.QueryString("myact"); string openid = MyCommFun.RequestOpenid(); //得到微信用户的openid Dictionary <string, string> jsonDict = new Dictionary <string, string>(); if (_action == "addCart") { #region 添加购物车 try { int wid = MyCommFun.RequestInt("wid"); int productId = MyCommFun.RequestInt("productid"); string skuId = MyCommFun.QueryString("mid"); string skuInfo = MyCommFun.QueryString("attr"); int productNum = MyCommFun.RequestInt("bc"); decimal totalPrice = (decimal)MyCommFun.RequestFloat("totprice", 0); Model.wx_shop_cart cart = new Model.wx_shop_cart(); IList <Model.wx_shop_cart> cartList = cartBll.GetModelList("productId=" + productId + " and openid='" + openid + "' and skuId='" + skuId + "'"); int getCartCount = cartBll.GetRecordCount("wid=" + wid + " and openid='" + openid + "'"); bool isAdd = true; if (cartList != null && cartList.Count > 0) { isAdd = false; cart = cartList[0]; } if (isAdd) { cart.createDate = DateTime.Now; cart.openid = openid; cart.productId = productId; cart.productNum = productNum; cart.skuId = skuId; cart.skuInfo = skuInfo; cart.totPrice = totalPrice * productNum; cart.wid = wid; int ret = cartBll.Add(cart); if (ret > 0) { jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "添加购物车成功!"); jsonDict.Add("cartcount", (getCartCount + 1).ToString()); } else { jsonDict.Add("errCode", "true"); jsonDict.Add("recontent", "添加购物车失败!"); jsonDict.Add("cartcount", getCartCount.ToString()); } } else { cart.openid = openid; cart.productNum += productNum; cart.skuId = skuId; cart.skuInfo = skuInfo; cart.totPrice += totalPrice * productNum; cart.wid = wid; bool ret = cartBll.Update(cart); if (ret) { jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "更新购物车成功!"); jsonDict.Add("cartcount", getCartCount.ToString()); } else { jsonDict.Add("errCode", "true"); jsonDict.Add("recontent", "更新购物车失败!"); jsonDict.Add("cartcount", getCartCount.ToString()); } } } catch (Exception ex) { jsonDict.Add("errCode", "true"); jsonDict.Add("recontent", "添加购物车失败!"); } finally { context.Response.Write(MyCommFun.getJsonStr(jsonDict)); } #endregion } else if (_action == "pcount") { #region 购物车商品数量 jsonDict = new Dictionary <string, string>(); int wid = MyCommFun.RequestInt("wid"); int count = cartBll.GetRecordCount("wid=" + wid + " and openid='" + openid + "'"); jsonDict.Add("data", count.ToString()); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "remove") { #region 移除购物车商品 jsonDict = new Dictionary <string, string>(); int cartId = MyCommFun.RequestInt("id"); cartBll.Delete(cartId); jsonDict.Add("errCode", "false"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "modifyNum") { #region 修改购物车商品数量 jsonDict = new Dictionary <string, string>(); int cartId = MyCommFun.RequestInt("ic"); int newNum = MyCommFun.RequestInt("bc"); cartBll.UpdateNum(cartId, newNum); jsonDict.Add("errCode", "false"); jsonDict.Add("recontent", "更新成功!"); context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } else if (_action == "getCity") { #region 择省份,改变城市列表 int privice = MyCommFun.RequestInt("pvid"); BLL.pre_common_district areaBll = new BLL.pre_common_district(); IList <Model.pre_common_district> disList = areaBll.GetModelList("upid=" + privice + " and level=2"); Model.pre_common_district dis; StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":["); for (int i = 0; i < disList.Count; i++) { dis = new Model.pre_common_district(); if (i != disList.Count - 1) { jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},"); } else { jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}"); } } jsonStr.Append("]}"); context.Response.Write(jsonStr); #endregion } else if (_action == "getArea") { #region 择城市,改变区域列表 int ctid = MyCommFun.RequestInt("ctid"); BLL.pre_common_district areaBll = new BLL.pre_common_district(); IList <Model.pre_common_district> disList = areaBll.GetModelList("upid=" + ctid + " and level=3"); Model.pre_common_district dis; StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":["); for (int i = 0; i < disList.Count; i++) { dis = new Model.pre_common_district(); if (i != disList.Count - 1) { jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},"); } else { jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}"); } } jsonStr.Append("]}"); context.Response.Write(jsonStr); #endregion } else if (_action == "order_save") { #region 保存订单信息 //获得传参信息 int wid = MyCommFun.RequestInt("wid"); int payment_id = MyCommFun.RequestInt("pc"); //支付方式:1货到付款;3微支付 int express_id = MyCommFun.RequestInt("mtype"); //物流方式 // string orderStrList = MyCommFun.QueryString("orderStrList"); //检查物流方式 if (express_id == 0) { context.Response.Write("{\"errCode\":3, \"msg\":\"对不起,请选择配送方式!\"}"); return; } BLL.wx_shop_user_addr uAddrBll = new BLL.wx_shop_user_addr(); IList <Model.wx_shop_user_addr> uaddrList = uAddrBll.GetOpenidAddrName(openid, wid); if (uaddrList == null || uaddrList.Count <= 0 || uaddrList[0].id <= 0) { context.Response.Write("{\"errCode\":3, \"msg\":\"收货地址不存在,无法结算!\"}"); return; } //检查购物车商品 IList <Model.cartProduct> cartList = cartBll.GetCartList(openid, wid); if (cartList == null) { context.Response.Write("{\"errCode\":3, \"msg\":\"对不起,购物车为空,无法结算!\"}"); return; } //统计购物车 decimal payable_amount = cartList.Sum(c => c.totPrice); //物流费用 BLL.express expressBll = new BLL.express(); Model.express expModel = expressBll.GetModel(express_id); //支付方式 BLL.payment pbll = new BLL.payment(); Model.payment payModel = pbll.GetModelBypTypeId(payment_id); //保存订单======================================================================= Model.orders model = new Model.orders(); model.order_no = "b" + Utils.GetOrderNumber(); //订单号B开头为商品订单 model.wid = wid; model.openid = openid; model.modelName = "微商城"; model.modelCode = "shop"; model.modelActionName = ""; model.modelActionId = 0; model.user_id = 0; model.user_name = ""; model.payment_id = payment_id; model.express_id = express_id; model.accept_name = uaddrList[0].contractPerson; model.post_code = ""; model.telphone = uaddrList[0].tel; model.mobile = uaddrList[0].tel; model.area = uaddrList[0].province; model.city = uaddrList[0].city; model.district = uaddrList[0].area; model.address = uaddrList[0].province + " " + uaddrList[0].city + " " + uaddrList[0].area + " " + uaddrList[0].addrDetail; model.message = ""; model.payable_amount = payable_amount; //应付商品总金额 model.real_amount = payable_amount; //实际商品总金额, model.status = 1; model.express_status = 1; model.express_fee = expModel.express_fee; //物流费用 if (payment_id == 1) { //货到付款,需要确认订单 model.payment_status = 0; //标记未付款 } else { //先款后货 model.payment_status = 1; //标记未付款 } bool quicklyFH = false; //如果是先款后货的话 if (payment_id == 3) { if (payModel.poundage_type == 1) //百分比 { model.payment_fee = model.real_amount * payModel.poundage_amount / 100; } else //固定金额 { model.payment_fee = payModel.poundage_amount; } BLL.wx_payment_wxpay wxBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay wxpay = wxBll.GetModelByWid(wid); quicklyFH = wxpay.quicklyFH; } if (quicklyFH) { model.express_status = 0; } //订单总金额=实付商品金额+运费+支付手续费 model.order_amount = model.real_amount + model.express_fee + model.payment_fee; //购物积分,可为负数 model.point = 0; model.add_time = DateTime.Now; //商品详细列表 List <Model.order_goods> gls = new List <Model.order_goods>(); foreach (Model.cartProduct item in cartList) { gls.Add(new Model.order_goods { goods_id = item.productId, goods_title = item.productName, goods_price = item.totPrice, real_price = item.totPrice, quantity = item.productNum, point = 0 }); } model.order_goods = gls; int result = new BLL.orders().Add(model); if (result < 1) { context.Response.Write("{\"errCode\":3, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}"); return; } //清空购物车 cartBll.RemoveCartInfo(wid, openid); //提交成功,返回URL order_no context.Response.Write("{\"errCode\":true, \"payType\":\"" + payment_id + "\", \"order_no\":\"" + model.order_no + "\",\"orderid\":\"" + result + "\",\"wid\":\"" + wid + "\",\"openid\":\"" + openid + "\",\"payable_amount\":\"" + payable_amount + "\", \"msg\":\"恭喜您,订单已成功提交!\"}"); return; #endregion } else if (_action == "order_canel") { #region //取消订单 int orderid = MyCommFun.RequestInt("order_id"); BLL.orders oBll = new BLL.orders(); oBll.UpdateField(orderid, "status=4"); context.Response.Write("{\"errCode\":true, \"msg\":\"订单已取消!\"}"); #endregion } else if (_action == "fukuan") { #region //在线支付 int orderid = MyCommFun.RequestInt("order_id"); BLL.orders oBll = new BLL.orders(); Model.orders order = oBll.GetModel(orderid); oBll.UpdateField(orderid, "express_status=1,payment_status=2 , status=2"); context.Response.Write("{\"errCode\":true, \"msg\":\"付款成功!\"}"); #endregion } else if (_action == "shouhuo") { #region //确认收货 int orderid = MyCommFun.RequestInt("order_id"); BLL.orders oBll = new BLL.orders(); Model.orders order = oBll.GetModel(orderid); //if (order.payment_id == 1) //{ //货到付款 // oBll.UpdateField(orderid, "express_status=2,payment_status=2 , status=3"); // } // else //{ //在线支付 oBll.UpdateField(orderid, "express_status=2,payment_status=2 , status=6"); // } context.Response.Write("{\"errCode\":true, \"msg\":\"交易完成!\"}"); #endregion } else if (_action == "so") { #region //产品搜索,主要字段名称,分类,简介 int wid = MyCommFun.RequestInt("wid"); string pagesizeStr = MyCommFun.RequestParam("pagesize"); string orderby = " id desc"; int currPage = MyCommFun.RequestInt("currPage");; //当前页面 int recordCount = 0; //总记录数 int totPage = 1; //总页数 int pageSize = MyCommFun.Str2Int(pagesizeStr); //每页的记录数 if (pageSize <= 0) { pageSize = 10; } if (MyCommFun.RequestInt("page") > 0) { currPage = 1; } string key = MyCommFun.RequestParam("key"); DataSet productlist = new DataSet(); DAL.wx_shop_product artDal = new DAL.wx_shop_product(); productlist = artDal.SoGetList(wid, key, pageSize, currPage, "upselling=1", orderby, out recordCount); if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0) { DataRow dr; for (int i = 0; i < productlist.Tables[0].Rows.Count; i++) { dr = productlist.Tables[0].Rows[i]; dr["p_count"] = recordCount; if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0) { dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid); } else { dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&pid=" + dr["id"].ToString(), openid); } productlist.AcceptChanges(); } context.Response.Write(MyCommFun.GetJsonByDataset(productlist)); } #endregion } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart(); string _action = MyCommFun.QueryString("myact"); string openid = MyCommFun.RequestOpenid(); //得到微信用户的openid Dictionary <string, string> jsonDict = new Dictionary <string, string>(); if (_action == "LoadProduct") { #region 择排序,改变商品列表 string sortColumn = MyCommFun.RequestParam("sortColumn"); int wid = MyCommFun.RequestInt("wid"); int id = MyCommFun.RequestInt("cid"); string name = MyCommFun.RequestParam("name"); string flog = MyCommFun.RequestParam("flog"); string gd = MyCommFun.RequestParam("gd"); DataSet ds = null; BLL.wx_shop_product proBll = new BLL.wx_shop_product(); StringBuilder jsonStr = new StringBuilder(); if (id != 0) { if (sortColumn == "priceDesc") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " order by marketPrice desc "); } if (sortColumn == "priceDesc" && flog == "true") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and productName like " + "'%" + name + "%'" + "order by marketPrice desc "); } if (sortColumn == "priceAsc") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " order by marketPrice asc "); } if (sortColumn == "priceAsc" && flog == "true") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and productName like " + "'%" + name + "%'" + "order by marketPrice asc "); } if (sortColumn == "newDesc") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and latest=" + 1 + " order by latest desc "); } if (sortColumn == "newDesc" && flog == "true") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and latest=" + 1 + " and productName like " + "'%" + name + "%'" + "order by latest desc "); } if (sortColumn == "saleDesc") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and hotsale=" + 1 + " order by hotsale desc "); } if (sortColumn == "saleDesc" && flog == "true") { ds = proBll.GetList(wid, 20, "categoryId=" + id + " and hotsale=" + 1 + " and productName like " + "'%" + name + "%'" + "order by hotsale desc "); } } else { if (sortColumn == "priceDesc") { ds = proBll.GetList(wid, 20, "1=1 order by marketPrice desc "); } if (sortColumn == "priceDesc" && flog == "true") { ds = proBll.GetList(wid, 20, " productName like " + "'%" + name + "%'" + "order by marketPrice desc "); } if (sortColumn == "priceAsc") { ds = proBll.GetList(wid, 20, " 1=1 order by marketPrice asc "); } if (sortColumn == "priceAsc" && flog == "true") { ds = proBll.GetList(wid, 27, " productName like " + "'%" + name + "%'" + "order by marketPrice asc "); } if (sortColumn == "newDesc") { ds = proBll.GetList(wid, 20, " latest=" + 1 + " order by latest desc "); } if (sortColumn == "newDesc" && flog == "true") { ds = proBll.GetList(wid, 20, " latest=" + 1 + "productName like " + "'%" + name + "%'" + "order by latest desc "); } if (sortColumn == "saleDesc") { ds = proBll.GetList(wid, 20, "hotsale=" + 1 + " order by hotsale desc "); } if (sortColumn == "saleDesc" && flog == "true") { ds = proBll.GetList(wid, 20, "hotsale=" + 1 + " and productName like " + "'%" + name + "%'" + "order by hotsale desc "); } } if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { if (id != 0) { if (gd == "") { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"lists_items\"> <p class=\"pic\"> <a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"> <img src=\"" + d["productpic"] + "\"></a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><span><font>¥" + d["marketPrice"] + "</font></span><strong>" + d["productName"] + "</strong></br>" + d["sku"] + "</a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a class=\"activemsg\" href=\"\"></a></p><p class=\"list_tex\" ><span class=\"txt_blue\">库存" + d["stock"] + "</span></p> </div>"); } jsonStr.Append("<div class=\"details_more\" style=\"float:left; width:100%;\"><A href=\"javascript:void(0);\" id=\"gengduo\" onclick=\"gengduo()\"><span>查看更多</span><br />可能产生较多流量<br /> </A>"); } else { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"list_msg list_with_img\" style=\"margin-top:10px;font-size:12px;\"> <a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><img style=\"top:16px;\" src=\"" + d["productpic"] + "\">"); jsonStr.Append("<p class=\"list_tex\">" + d["productName"] + "<span class=\"txt_red\" style=\"font-size:12px;\">¥" + d["marketPrice"] + "</span></p><p class=\"list_tex\">" + d["sku"] + "</p><p class=\"list_tex\">158人评价,98%好评"); jsonStr.Append("<span class=\"txt_blue\" style=\"font-size:12px;\">库存" + d["stock"] + "</span></p></a></div>"); } } } else { if (gd == "") { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"lists_items\"> <p class=\"pic\"> <a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"> <img src=\"" + d["productpic"] + "\"></a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><span><font>¥" + d["marketPrice"] + "</font></span><strong>" + d["productName"] + "</strong></br>" + d["sku"] + "</a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a class=\"activemsg\" href=\"\"></a></p><p class=\"list_tex\" ><span class=\"txt_blue\">库存" + d["stock"] + "</span></p> </div>"); } jsonStr.Append("<div class=\"details_more\" style=\"float:left; width:100%;\"><A href=\"javascript:void(0);\" id=\"gengduo\" onclick=\"gengduo()\"><span>查看更多</span><br />可能产生较多流量<br /> </A>"); } else { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"list_msg list_with_img\" style=\"margin-top:10px;font-size:12px;\"> <a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><img style=\"top:16px;\" src=\"" + d["productpic"] + "\">"); jsonStr.Append("<p class=\"list_tex\">" + d["productName"] + "<span class=\"txt_red\" style=\"font-size:12px;\">¥" + d["marketPrice"] + "</span></p><p class=\"list_tex\">" + d["sku"] + "</p><p class=\"list_tex\">158人评价,98%好评"); jsonStr.Append("<span class=\"txt_blue\" style=\"font-size:12px;\">库存" + d["stock"] + "</span></p></a></div>"); } } } } context.Response.Write(jsonStr); #endregion } else if (_action == "sousuo") { #region 择商品名称,改变商品列表 string name = MyCommFun.RequestParam("name"); int wid = MyCommFun.RequestInt("wid"); DataSet ds = null; BLL.wx_shop_product proBll = new BLL.wx_shop_product(); StringBuilder jsonStr = new StringBuilder(); ds = proBll.GetList(wid, 20, " productName like " + "'%" + name + "%'" + ""); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"lists_items\"> <p class=\"pic\"> <a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"> <img src=\"" + d["productpic"] + "\"></a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><span><font>¥" + d["marketPrice"] + "</font></span><strong>" + d["productName"] + "</strong></br>" + d["sku"] + "</a> </p>"); jsonStr.Append("<p class=\"list_tex\"><a class=\"activemsg\" href=\"\"></a></p><p class=\"list_tex\" ><span class=\"txt_blue\">库存" + d["stock"] + "</span>1534人评价,96%好评</p> </div>"); } jsonStr.Append("<div class=\"details_more\" style=\"float:left; width:100%;\"><A href=\"javascript:void(0);\" id=\"gengduo\" onclick=\"gengduo()\"><span>查看更多</span><br />可能产生较多流量<br /> </A>"); } context.Response.Write(jsonStr); #endregion } else if (_action == "gengduo") { #region 查看更多 int wid = MyCommFun.RequestInt("wid"); int id = MyCommFun.RequestInt("cid"); DataSet ds = null; BLL.wx_shop_product proBll = new BLL.wx_shop_product(); StringBuilder jsonStr = new StringBuilder(); if (id != 0) { ds = proBll.GetList(wid, -1, "categoryId=" + id + " and p.hotsale=" + 1 + " order by p.hotsale desc "); } else { ds = proBll.GetList(wid, -1, "p.hotsale=" + 1 + " order by p.hotsale desc "); } if (ds != null && ds.Tables[0] != null) { foreach (DataRow d in ds.Tables[0].Rows) { jsonStr.Append("<div class=\"list_msg list_with_img\" style=\"margin-top:10px;font-size:12px;\"><a href=\"/shop/detail.aspx?wid=" + wid + "&pid=" + d["id"] + "&openid=" + openid + "\"><img style=\"top:16px;\" src=\"" + d["productpic"] + "\">"); jsonStr.Append("<p class=\"list_tex\">" + d["productName"] + "<span class=\"txt_red\" style=\"font-size:12px;\">¥" + d["marketPrice"] + "</span></p><p class=\"list_tex\">" + d["sku"] + "</p><p class=\"list_tex\">158人评价,98%好评"); jsonStr.Append("<span class=\"txt_blue\" style=\"font-size:12px;\">库存" + d["stock"] + "</span></p></a></div>"); } } context.Response.Write(jsonStr); #endregion } else if (_action == "checkid") { #region 是否存在该商品 jsonDict = new Dictionary <string, string>(); int wid = MyCommFun.RequestInt("wid"); int id = MyCommFun.RequestInt("id"); BLL.wx_shop_product proBll = new BLL.wx_shop_product(); DataSet ds = null; ds = proBll.GetList("wid=" + wid + " and id=" + id + ""); BLL.wx_shop_sku skuBll = new BLL.wx_shop_sku(); Model.wx_shop_sku skuModel = skuBll.GetModel(id); if (ds != null && ds.Tables[0].Rows.Count > 0) { jsonDict.Add("data", ds.Tables[0].Rows[0]["stock"].ToString()); } context.Response.Write(MyCommFun.getJsonStr(jsonDict)); #endregion } }
public string Apply_refund() { int orderId = MyCommFun.RequestInt("orderid"); int wid = MyCommFun.RequestInt("wid"); string code = MyCommFun.RequestParam("code"); string state = MyCommFun.RequestParam("state"); BLL.wx_payment_wxpay wxPayBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = wxPayBll.GetModelByWid(wid); BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); BLL.orders otBll = new BLL.orders(); Model.orders orderEntity = otBll.GetModel(orderId, wid); litout_trade_no = orderEntity.order_no; amount = orderEntity.order_amount.ToString(); string nonceStr = TenPayV3Util.GetNoncestr(); RequestHandler packageReqHandler = new RequestHandler(null); //设置package订单参数 packageReqHandler.SetParameter("appid", paymentInfo.appId); //公众账号ID packageReqHandler.SetParameter("mch_id", paymentInfo.partnerId); //商户号 packageReqHandler.SetParameter("out_trade_no", orderEntity.order_no); //填入商家订单号 packageReqHandler.SetParameter("out_refund_no", orderEntity.order_no); //填入退款订单号 packageReqHandler.SetParameter("total_fee", amount); //填入总金额 packageReqHandler.SetParameter("refund_fee", amount); //填入退款金额 packageReqHandler.SetParameter("op_user_id", paymentInfo.partnerId); //操作员Id,默认就是商户号 packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串 string sign = packageReqHandler.CreateMd5Sign("key", paymentInfo.paySignKey); packageReqHandler.SetParameter("sign", sign); //签名 //退款需要post的数据 string data = packageReqHandler.ParseXML(); //退款接口地址 string url = "https://api.mch.weixin.qq.com/secapi/pay/refund"; //本地或者服务器的证书位置(证书在微信支付申请成功发来的通知邮件中) string cert = MyCommFun.GetRootPath() + paymentInfo.CertInfoPath; //私钥(在安装证书时设置) string password = paymentInfo.partnerPwd; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); //调用证书 X509Certificate2 cer = new X509Certificate2(cert, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet); #region 发起post请求 HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(url); webrequest.ClientCertificates.Add(cer); webrequest.Method = "post"; byte[] postdatabyte = Encoding.UTF8.GetBytes(data); webrequest.ContentLength = postdatabyte.Length; Stream stream; stream = webrequest.GetRequestStream(); stream.Write(postdatabyte, 0, postdatabyte.Length); stream.Close(); HttpWebResponse httpWebResponse = (HttpWebResponse)webrequest.GetResponse(); StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()); string responseContent = streamReader.ReadToEnd(); #endregion var res = XDocument.Parse(responseContent); string openid = res.Element("xml").Element("out_refund_no").Value; return(openid); }
protected void Page_Load(object sender, EventArgs e) { int orderId = MyCommFun.RequestInt("orderid"); int wid = MyCommFun.RequestInt("wid"); getwid = wid; getorderId = orderId; string code = MyCommFun.RequestParam("code"); string state = MyCommFun.RequestParam("state"); BLL.wx_payment_wxpay wxPayBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = wxPayBll.GetModelByWid(wid); BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); BLL.orders otBll = new BLL.orders(); Model.orders orderEntity = otBll.GetModel(orderId, wid); litout_trade_no = orderEntity.order_no; litMoney = Decimal.ToInt32(orderEntity.order_amount); litDate = orderEntity.add_time.ToString(); if (string.IsNullOrEmpty(code)) { Response.Write("您拒绝了授权!"); return; } if (!state.Contains("|")) { //这里的state其实是会暴露给客户端的,验证能力很弱,这里只是演示一下 //实际上可以存任何想传递的数据,比如用户ID,并且需要结合例如下面的Session["OAuthAccessToken"]进行验证 Response.Write("验证失败!请从正规途径进入!1001"); return; } ////获取产品信息 //var stateData = state.Split('|'); //int productId = 0; //if (int.TryParse(stateData[0], out productId)) //{ // int hc = 0; // if (int.TryParse(stateData[1], out hc)) // { // var products = ProductModel.GetFakeProductList(); // product = products.FirstOrDefault(z => z.Id == productId); // if (product == null || product.GetHashCode() != hc) // { // return Content("商品信息不存在,或非法进入!1002"); // } // ViewData["product"] = product; // } //} //通过,用code换取access_token var openIdResult = OAuthApi.GetAccessToken(PayV3Config.Mch_appId, PayV3Config.Mch_Secret, code); if (openIdResult.errcode != ReturnCode.请求成功) { Response.Write("错误:" + openIdResult.errmsg); return; } string timeStamp = ""; string nonceStr = ""; string paySign = ""; string sp_billno = Request["order_no"]; //当前时间 yyyyMMdd string date = DateTime.Now.ToString("yyyyMMdd"); if (null == sp_billno) { //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一 sp_billno = DateTime.Now.ToString("HHmmss") + TenPayV3Util.BuildRandomStr(28); } else { sp_billno = Request["order_no"].ToString(); } //创建支付应答对象 Senparc.Weixin.MP.TenPayLibV3.RequestHandler packageReqHandler = new Senparc.Weixin.MP.TenPayLibV3.RequestHandler(null); //初始化 packageReqHandler.Init(); timeStamp = TenPayV3Util.GetTimestamp(); nonceStr = TenPayV3Util.GetNoncestr(); //设置package订单参数 // packageReqHandler.SetParameter("appid", paymentInfo.appId); //公众账号ID /// packageReqHandler.SetParameter("mch_id", paymentInfo.partnerId); //商户号 packageReqHandler.SetParameter("appid", PayV3Config.Mch_appId); //公众账号ID packageReqHandler.SetParameter("mch_id", PayV3Config.Mch_mchid); //商户号 //// packageReqHandler.SetParameter("sub_appid", paymentInfo.appId); //子商户公众账号ID packageReqHandler.SetParameter("sub_mch_id", paymentInfo.partnerId); //子商户号mch_id /// packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串 packageReqHandler.SetParameter("body", orderId.ToString()); //商品信息 packageReqHandler.SetParameter("out_trade_no", litout_trade_no); //商家订单号 packageReqHandler.SetParameter("total_fee", (litMoney * 100).ToString()); //product == null ? "100" : (product.Price * 100).ToString()商品金额,以分为单位(money * 100).ToString() packageReqHandler.SetParameter("spbill_create_ip", Request.UserHostAddress); //用户的公网ip,不是商户服务器IP packageReqHandler.SetParameter("notify_url", MyCommFun.getWebSite() + "/api/wxpay/notify_url.aspx?wid=" + wid + "|" + orderId); //接收财付通通知的URL packageReqHandler.SetParameter("trade_type", TenPayV3Type.JSAPI.ToString()); //交易类型 packageReqHandler.SetParameter("openid", openIdResult.openid); //用户的openId // string sign = packageReqHandler.CreateMd5Sign("key", paymentInfo.paySignKey); string sign = packageReqHandler.CreateMd5Sign("key", PayV3Config.Mch_Key); packageReqHandler.SetParameter("sign", sign); //签名 string data = packageReqHandler.ParseXML(); var result = TenPayV3.Unifiedorder(data); var res = XDocument.Parse(result); string prepayId = res.Element("xml").Element("prepay_id").Value; //设置支付参数 Senparc.Weixin.MP.TenPayLibV3.RequestHandler paySignReqHandler = new Senparc.Weixin.MP.TenPayLibV3.RequestHandler(null); paySignReqHandler.SetParameter("appId", PayV3Config.Mch_appId); paySignReqHandler.SetParameter("timeStamp", timeStamp); paySignReqHandler.SetParameter("nonceStr", nonceStr); paySignReqHandler.SetParameter("package", string.Format("prepay_id={0}", prepayId)); paySignReqHandler.SetParameter("signType", "MD5"); paySign = paySignReqHandler.CreateMd5Sign("key", PayV3Config.Mch_Key); payaddid = PayV3Config.Mch_appId; paytimeStamp = timeStamp; paynonceStr = nonceStr; paypackageValue = string.Format("prepay_id={0}", prepayId); paypaySign = paySign; }