/// <summary> /// 该方法帮助开发者在订单生成之后掉用微信支付接口生成预支付订单,如果当前下单场景为公众号支付则返回一段用于发起支付的js代码,如果当前场景为PC端则返回一个用于发起支付的二维码图片URL /// </summary> /// <param name="order">设置需要支付的订单信息</param> /// <param name="notifyURL">设置发起支付之后微信服务端返回支付结果的回调地址</param> /// <param name="tradeType">设置支付类型,请参考Jumpcity.API.WeiXin.Pay.PayTradeType枚举类</param> /// <returns>如果当前下单场景为公众号支付则返回一段用于发起支付的js代码,如果当前场景为PC端则返回一个用于发起支付的二维码图片URL</returns> public static string UnifiedOrderPay(WMOrders order, string notifyURL, string tradeType) { string text = string.Empty; if (order != null && !General.IsNullable(notifyURL)) { List<WMOrderGoods> goodList = WMOrderGoods.GetList(order.Id); UnifiedOrder.SubmitParameters submit = new UnifiedOrder.SubmitParameters(WxConfig.GetSystemPayParameters()); if (!General.IsNullable(goodList)) { foreach (WMOrderGoods good in goodList) submit.Detail += string.Format("{0} X {1}\n\r", good.GoodName, good.Count); } submit.Body = "添依网 - 购物清单"; submit.OutTradeId = order.Id; submit.TotalPrice = (int)(order.OrderTotalPrice * 100); submit.NotifyURL = notifyURL; if (tradeType == PayTradeType.JSAPI && !General.IsNullable(order.OpenId)) submit.OpenId = order.OpenId; else submit.ProductId = order.Id; UnifiedOrder un_order = new UnifiedOrder(submit); if (tradeType == PayTradeType.JSAPI) text = un_order.PublicPlaceOrder(); else text = un_order.ScanCodePlaceOrder(); } return text; }
public void Test_Add_Get() { //Add user WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //Add Order WMOrders order = new WMOrders() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, PayId = 621 }; Assert.IsTrue(order.Add()); Assert.AreEqual("小李", order.Contact); }
public void Test_Add_Get() { //Add user WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //Add address WMOrders order = new WMOrders() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, PayId = 621 }; Assert.IsTrue(order.Add()); Assert.AreEqual("小李", order.Contact); //添加category WMGoodCategories cateToAdd = new WMGoodCategories(); cateToAdd.ParentId = "root"; cateToAdd.Name = "珠宝"; bool isCateAdded = cateToAdd.Add(); Assert.IsTrue(isCateAdded); //添加good WMGoods goodToAdd = new WMGoods(); goodToAdd.CategoryId = cateToAdd.Id; goodToAdd.Name = "砖石项链"; goodToAdd.Unit = "件"; goodToAdd.OriginalPrice = 10000; goodToAdd.StatusId = 501; bool isGoodAdded = goodToAdd.Add(); Assert.IsTrue(isGoodAdded); WMOrderGoods orderGood = new WMOrderGoods() { Count = 2, GoodId = goodToAdd.Id, OrderId = order.Id, Price = 100, }; Assert.IsTrue(orderGood.Add()); int pageCount; List<WMOrderGoods> orderGoodsGetted = WMOrderGoods.GetList(out pageCount, order.Id); Assert.AreEqual(1, orderGoodsGetted.Count); Assert.AreEqual("砖石项链", orderGoodsGetted[0].GoodName); Assert.AreEqual(2, orderGoodsGetted[0].Count); }
public static WMOrders Get(string orderId) { WMOrders order = null; if (!General.IsNullable(orderId)) { using (WMContext context = new WMContext()) { order = ( from o in context.Orders join u in context.Users on o.UserId equals u.Id join p in context.Options on o.PayId equals p.Id join s in context.Options on o.StatusId equals s.Id join pv in context.Regions on o.ProvinceId equals pv.Id join city in context.Regions on o.CityId equals city.Id join area in context.Regions on o.AreaId equals area.Id where o.Id.Equals(orderId) select new WMOrders { Id = o.Id, UserId = o.UserId, NickName = u.NickName, ProvinceId = o.ProvinceId, ProvinceName = pv.Name, CityId = o.CityId, CityName = city.Name, AreaId = o.AreaId, AreaName = area.Name, Contact = o.Contact, Address = o.Address, Phone = o.Phone, ZipCode = o.ZipCode, PayId = o.PayId, PayName = p.Name, Paid = o.Paid, Freight = o.Freight, Message = o.Message, StatusId = o.StatusId, StatusName = s.Name, AddDate = o.AddDate } ).FirstOrDefault(); } } return(order); }
protected void btnGoToPay_Click(object sender, EventArgs e) { WMUserReceipts receipt = WMUserReceipts.Get(hiddenReceiptId.Value); if (receipt == null) { Helper.ExecScript("alert('收货地址错误,请修正');"); return; } WMOrders order = new WMOrders { UserId = Helper.User.Id, Address = receipt.Address, Contact = receipt.Contact, Phone = receipt.Phone, ZipCode = receipt.ZipCode, ProvinceId = receipt.ProvinceId, CityId = receipt.CityId, AreaId = receipt.AreaId, PayId = radioPayMethod.SelectedValue.ToInt32(), Message = OrderMessage.Text }; if (order.Add()) { int pageCount; List<WMShopCars> cars = WMShopCars.GetList(out pageCount, Helper.User.Id); foreach (var car in cars) { new WMOrderGoods() { Count = car.Count, GoodId = car.GoodId, OrderId = order.Id, Price = car.Price, }.Add(); } WMShopCars.Clear(Helper.User.Id); Response.Redirect("/pay/pay.aspx?orderId=" + order.Id); } else { Helper.ExecScript("alert('生成订单错误')"); } }
public void Test_Add_Get() { //Add user WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //Add Order WMOrders order = new WMOrders() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, PayId = 621 }; Assert.IsTrue(order.Add()); //AddBonus WMUserBonus bonus = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 101, }; Assert.IsTrue(bonus.Add()); int pageCount; DateTime firstDayInMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); List<WMUserBonus> bonusesGetted = WMUserBonus.GetList( out pageCount, firstDayInMonth, null, userToAdd.Id); Assert.IsNotNull(bonusesGetted); Assert.AreEqual(1, bonusesGetted.Count); Assert.AreEqual(101, bonusesGetted[0].BonusSum); }
private void BindOrder() { Order = new WMOrders(); OrderExpress = new WMOrderExpress(); OrderId = Request.GetString("Id"); if (!General.IsNullable(OrderId)) { WMOrders tempOrder = WMOrders.Get(OrderId); if (tempOrder!= null) { Order = tempOrder; WMOrderExpress tempOrderExpress = WMOrderExpress.Get(Order.ExpressId); if(tempOrderExpress != null) { OrderExpress = tempOrderExpress; } BindOrderGoods(); } } }
public void Test_AddAllDatas() { bool isAdded = false; //express WMOrderExpress express = new WMOrderExpress() { Name = "顺丰", URL = "www.shufen.com" }; Assert.IsTrue(express.Add()); //Admins WMAdministrators adminToAdd = new WMAdministrators(); adminToAdd.RoleId = 302; adminToAdd.UserName = "******"; adminToAdd.Password = "******"; adminToAdd.Add(); //Users WMUsers userToAdd = new WMUsers(); userToAdd.Id = General.UniqueString(userToAdd.Id); userToAdd.RoleId = 101; userToAdd.UserName = "******"; userToAdd.Password = "******"; userToAdd.NickName = "nick"; userToAdd.Mobile = "13512341234"; Assert.IsTrue(userToAdd.Add()); //Categories //珠宝 WMGoodCategories cate_0 = new WMGoodCategories(); cate_0.ParentId = "root"; cate_0.Name = "珠宝"; isAdded = cate_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_0_0 = new WMGoodCategories(); cate_0_0.ParentId = cate_0.Id; cate_0_0.Name = "项链"; isAdded = cate_0_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_0_1 = new WMGoodCategories(); cate_0_1.ParentId = cate_0.Id; cate_0_1.Name = "手镯"; isAdded = cate_0_1.Add(); Assert.IsTrue(isAdded); //服装 WMGoodCategories cate_1 = new WMGoodCategories(); cate_1.ParentId = "root"; cate_1.Name = "服装"; isAdded = cate_1.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_1_0 = new WMGoodCategories(); cate_1_0.ParentId = cate_1.Id; cate_1_0.Name = "衬衫"; isAdded = cate_1_0.Add(); Assert.IsTrue(isAdded); WMGoodCategories cate_1_1 = new WMGoodCategories(); cate_1_1.ParentId = cate_1.Id; cate_1_1.Name = "T恤"; isAdded = cate_1_1.Add(); Assert.IsTrue(isAdded); //添加good WMGoods goodToAdd = new WMGoods(); goodToAdd.CategoryId = cate_0.Id; goodToAdd.Name = "砖石项链"; goodToAdd.Unit = "件"; goodToAdd.OriginalPrice = 10000; goodToAdd.StatusId = 501; bool isGoodAdded = goodToAdd.Add(); Assert.IsTrue(isGoodAdded); WMGoods good2ToAdd = new WMGoods(); good2ToAdd.CategoryId = cate_0_0.Id; good2ToAdd.Name = "黄金项链"; good2ToAdd.Unit = "件"; good2ToAdd.OriginalPrice = 10000; good2ToAdd.StatusId = 501; good2ToAdd.Add(); WMGoods good3ToAdd = new WMGoods(); good3ToAdd.CategoryId = cate_0_0.Id; good3ToAdd.Name = "红宝石项链"; good3ToAdd.Unit = "件"; good3ToAdd.OriginalPrice = 10000; good3ToAdd.StatusId = 501; good3ToAdd.Add(); WMGoods good4ToAdd = new WMGoods(); good4ToAdd.CategoryId = cate_0_0.Id; good4ToAdd.Name = "蓝宝石项链"; good4ToAdd.Unit = "件"; good4ToAdd.OriginalPrice = 10000; good4ToAdd.StatusId = 501; good4ToAdd.Add(); WMGoods good5ToAdd = new WMGoods(); good5ToAdd.CategoryId = cate_0_0.Id; good5ToAdd.Name = "绿宝石项链"; good5ToAdd.Unit = "件"; good5ToAdd.OriginalPrice = 10000; good5ToAdd.StatusId = 501; good5ToAdd.Add(); WMGoods good6ToAdd = new WMGoods(); good6ToAdd.CategoryId = cate_0_0.Id; good6ToAdd.Name = "黄宝石项链"; good6ToAdd.Unit = "件"; good6ToAdd.OriginalPrice = 10000; good6ToAdd.StatusId = 501; good6ToAdd.Add(); WMGoods good7ToAdd = new WMGoods(); good7ToAdd.CategoryId = cate_0_0.Id; good7ToAdd.Name = "珍珠项链"; good7ToAdd.Unit = "件"; good7ToAdd.OriginalPrice = 10000; good7ToAdd.StatusId = 501; good7ToAdd.Add(); WMGoods good8ToAdd = new WMGoods(); good8ToAdd.CategoryId = cate_0_0.Id; good8ToAdd.Name = "石头项链"; good8ToAdd.Unit = "件"; good8ToAdd.OriginalPrice = 10000; good8ToAdd.StatusId = 501; good8ToAdd.Add(); WMGoods good9ToAdd = new WMGoods(); good9ToAdd.CategoryId = cate_0_0.Id; good9ToAdd.Name = "水泥项链"; good9ToAdd.Unit = "件"; good9ToAdd.OriginalPrice = 10000; good9ToAdd.StatusId = 501; good9ToAdd.Add(); WMGoods good10ToAdd = new WMGoods(); good10ToAdd.CategoryId = cate_0_0.Id; good10ToAdd.Name = "1项链"; good10ToAdd.Unit = "件"; good10ToAdd.OriginalPrice = 10000; good10ToAdd.StatusId = 501; good10ToAdd.Add(); WMGoods good11ToAdd = new WMGoods(); good11ToAdd.CategoryId = cate_0_0.Id; good11ToAdd.Name = "2项链"; good11ToAdd.Unit = "件"; good11ToAdd.OriginalPrice = 10000; good11ToAdd.StatusId = 501; good11ToAdd.Add(); WMGoods good12ToAdd = new WMGoods(); good12ToAdd.CategoryId = cate_0_0.Id; good12ToAdd.Name = "3项链"; good12ToAdd.Unit = "件"; good12ToAdd.OriginalPrice = 10000; good12ToAdd.StatusId = 501; good12ToAdd.Add(); WMGoods good13ToAdd = new WMGoods(); good13ToAdd.CategoryId = cate_0_0.Id; good13ToAdd.Name = "4项链"; good13ToAdd.Unit = "件"; good13ToAdd.OriginalPrice = 10000; good13ToAdd.StatusId = 501; good13ToAdd.Add(); WMGoods good14ToAdd = new WMGoods(); good14ToAdd.CategoryId = cate_0_0.Id; good14ToAdd.Name = "5项链"; good14ToAdd.Unit = "件"; good14ToAdd.OriginalPrice = 10000; good14ToAdd.StatusId = 501; good14ToAdd.Add(); WMGoods good15ToAdd = new WMGoods(); good15ToAdd.CategoryId = cate_0_0.Id; good15ToAdd.Name = "6项链"; good15ToAdd.Unit = "件"; good15ToAdd.OriginalPrice = 10000; good15ToAdd.StatusId = 501; good15ToAdd.Add(); WMGoods good16ToAdd = new WMGoods(); good16ToAdd.CategoryId = cate_0_0.Id; good16ToAdd.Name = "7项链"; good16ToAdd.Unit = "件"; good16ToAdd.OriginalPrice = 10000; good16ToAdd.StatusId = 501; good16ToAdd.Add(); WMGoods good17ToAdd = new WMGoods(); good17ToAdd.CategoryId = cate_0_0.Id; good17ToAdd.Name = "8项链"; good17ToAdd.Unit = "件"; good17ToAdd.OriginalPrice = 10000; good17ToAdd.StatusId = 501; good17ToAdd.Add(); //添加brand WMGoodBrands brand1 = new WMGoodBrands(); brand1.Name = "卡地亚"; Assert.IsTrue(brand1.Add()); WMGoodBrands brand2 = new WMGoodBrands(); brand2.Name = "爱马仕"; Assert.IsTrue(brand2.Add()); //Car WMShopCars car = new WMShopCars() { GoodId = goodToAdd.Id, UserId = userToAdd.Id, Price = 100, Count = 2, }; Assert.IsTrue(car.Add()); WMShopCars car2 = new WMShopCars() { GoodId = good2ToAdd.Id, UserId = userToAdd.Id, Price = 500, Count = 3, }; Assert.IsTrue(car2.Add()); WMOrders order = new WMOrders() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, PayId = 621, ExpressId = express.Id }; Assert.IsTrue(order.Add()); WMOrderGoods orderGood = new WMOrderGoods() { Count = 2, GoodId = goodToAdd.Id, OrderId = order.Id, Price = 100, }; Assert.IsTrue(orderGood.Add()); //Add address WMUserReceipts receipt = new WMUserReceipts() { UserId = userToAdd.Id, Address = "上海哪儿哪儿哪儿", Contact = "小李", Phone = "13512341235", ZipCode = "240101", ProvinceId = 110000, CityId = 110100, AreaId = 110101, }; Assert.IsTrue(receipt.Add()); //用户收藏 WMUserSets userSet = new WMUserSets() { TypeId = 401, UserId = userToAdd.Id, GoodId = goodToAdd.Id, }; Assert.IsTrue(userSet.Add()); //用户积分 WMUserIntegrals intergral = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral.Add()); WMUserIntegrals intergral2 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral2.Add()); WMUserIntegrals intergral3 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral3.Add()); WMUserIntegrals intergral4 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral4.Add()); WMUserIntegrals intergral5 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral5.Add()); WMUserIntegrals intergral6 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral6.Add()); WMUserIntegrals intergral7 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral7.Add()); WMUserIntegrals intergral8 = new WMUserIntegrals() { UserId = userToAdd.Id, Integral = 100, SourceId = 451 }; Assert.IsTrue(intergral8.Add()); //用户返利 WMUserBonus bonus = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 101, }; Assert.IsTrue(bonus.Add()); WMUserBonus bonus2 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus2.Add()); WMUserBonus bonus3 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus3.Add()); WMUserBonus bonus4 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus4.Add()); WMUserBonus bonus5 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus5.Add()); WMUserBonus bonus6 = new WMUserBonus() { UserId = userToAdd.Id, OrderId = order.Id, BonusSum = 102, //AddDate = DateTime.Parse("2014-9-9") }; Assert.IsTrue(bonus6.Add()); }