protected override CommandResult <Hashtable> OnExecute(object commandParameter) { var param = commandParameter as SaveAddressParameter; var result = new CommandResult <Hashtable>(); using (CoreContext context = new CoreContext()) { var acc = context.MemberInfo.Where(m => m.AccountId == param.MemberAccount).Select(m => m.ZlOpenId).FirstOrDefault(); param.MemberAccount = acc; var res = ZlanAPICaller.ExecuteShop("Member.SaveAddress", param); if (res["ErrorCode"].Value <string>() == "0000" && res["Result"]["Data"] != null) { result.Data = res["Result"]["Data"].ToObject <Hashtable>(); result.ErrorCode = res["ErrorCode"].Value <int>(); result.ErrorMessage = res["ErrorMsg"].Value <string>(); } else { result.ErrorCode = -1; result.ErrorMessage = "创建地址失败,请刷新页面重试"; } } return(result); }
protected override CommandResult <IList <ParamKeyValuePair> > OnExecute(object commandParameter) { var param = commandParameter as LoadAddressParameter; var result = new CommandResult <IList <ParamKeyValuePair> >(); var res = ZlanAPICaller.ExecuteShop("Pub.LoadAddress", param); result.ErrorCode = res["ErrorCode"].Value <int>(); result.ErrorMessage = res["ErrorMsg"].Value <string>(); if (res["Result"]["List"] != null) { result.Data = res["Result"]["List"].ToObject <IList <ParamKeyValuePair> >(); } return(result); }
protected override CommandResult <List <AddressData> > OnExecute(object commandParameter) { var param = commandParameter as LoadAddressListParameter; var result = new CommandResult <List <AddressData> >(); using (CoreContext context = new CoreContext()) { var acc = context.MemberInfo.Where(m => m.AccountId == param.MemberAccount).Select(m => m.ZlOpenId).FirstOrDefault(); param.MemberAccount = acc; var res = ZlanAPICaller.ExecuteShop("Member.LoadAddressList", param); result.ErrorCode = res["ErrorCode"].Value <int>(); result.ErrorMessage = res["ErrorMsg"].Value <string>(); if (res["Result"]["List"] != null) { result.Data = res["Result"]["List"].ToObject <List <AddressData> >(); } } return(result); }
protected override CommandResult <string> OnExecute(object commandParameter) { var param = commandParameter as CreateShopOrderParameter; var result = new CommandResult <string>(); using (CoreContext context = new CoreContext()) { //if (DateTime.Now == DateTime.Parse("2018-10-31 23:30:00")) { var acc = param.ZlOpenId; //移除购物车 var RemoveProductRes = ZlanAPICaller.ExecuteShop("Member.RemoveProduct", $"{{ 'MemberAccount': '{acc}','SkuCodeList':['{param.ProductSkuNo}'] }}"); if (RemoveProductRes["ErrorCode"].Value <string>() == "0000") { //加入购物车 var SelectProductRes = ZlanAPICaller.ExecuteShop("Member.SelectProduct", $"{{ 'ProductList':[{{ 'Increment': 0, 'Counter': 1, 'ProductSkuCode':'{param.ProductSkuNo}', 'Remark': ''}}], 'MemberAccount': '{acc}' }}"); if (SelectProductRes["ErrorCode"].Value <string>() == "0000") { //确认结算产品 var ConfirmSelectProductRes = ZlanAPICaller.ExecuteShop("Member.ConfirmSelectProduct", $"{{ 'MemberAccount': '{acc}','SkuCodeList':['{param.ProductSkuNo}'] }}"); //生成订单 if (ConfirmSelectProductRes["ErrorCode"].Value <string>() == "0000") { var CouponTicket = new Dictionary <string, IList <string> >(); CouponTicket["Coupon"] = new List <string>(); CouponTicket["RedPackage"] = new List <string>(); var orderParam = new { MemberAccount = acc, param.AddressId, PaymentId = 3, Kind = "shop", CouponTicket, UseSpecialDiscount = 0, VCartDiscount = 0, Score = 0, ActId = param.Id }; LogUtil.Log("Pin.CreateShopOrder_CreateOrderRes", param.ProductSkuNo, JsonConvert.SerializeObject(orderParam)); var CreateOrderRes = ZlanAPICaller.ExecuteShop("Member.CreateOrder", orderParam); if (CreateOrderRes["ErrorCode"].Value <string>() == "0000") { result.Data = CreateOrderRes["Result"]["PaymentNo"].Value <string>();// context.Database.ExecuteSqlCommand($"update pin_order set order_no={CreateOrderRes["Result"]["PaymentNo"].Value<string>()},status=1 where recid={param.Id}"); //book.Status = 1; //book.ShopOrderNo = CreateOrderRes["Result"]["PaymentNo"].Value<string>(); //book.CouponTicket = res.Data; //context.SaveChanges(); } else { result.ErrorCode = -1; result.ErrorMessage = CreateOrderRes["ErrorMsg"].Value <string>(); LogUtil.Log("Pin.CreateShopOrder_CreateOrderRes", param.ProductSkuNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = ConfirmSelectProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("Pin.CreateShopOrder_ConfirmSelectProductRes", param.ProductSkuNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = SelectProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("Pin.CreateShopOrder_SelectProductRes", param.ProductSkuNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = RemoveProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("CreateShopOrder_RemoveProductRes", param.ProductSkuNo, result.ErrorMessage); } } } return(result); }
protected override CommandResult <int> OnExecute(object commandParameter) { // var param = commandParameter as CreateShopOrderParameter; var result = new CommandResult <int>(); using (CoreContext context = new CoreContext()) { //if (DateTime.Now == DateTime.Parse("2018-10-31 23:30:00")) { var bookList = context.BookInfo.FromSql(@"select b.* from book_info b left join pay_order p on p.order_no=b.order_no where p.`STATUS`=1 and b.`STATUS` !=1 ").ToList(); foreach (var book in bookList) { var acc = context.MemberInfo.Where(m => m.AccountId == book.MemberAccount).Select(m => m.ZlOpenId).FirstOrDefault(); var couponticket = book.CouponTicket; if (string.IsNullOrEmpty(couponticket)) { int?couponId = context.BookInfo.Where(b => b.OrderNo == book.OrderNo && b.MemberAccount == book.MemberAccount).Select(b => b.CouponId).FirstOrDefault(); var url = ConfigurationUtil.GetSection("CouponUrl").Value as string; //领取抵扣优惠券 var res = ZlanAPICaller.Call <CommandResult <string> >(url, new { MemberAccount = acc, RuleId = couponId }); if (res.ErrorCode == 0) { context.Database.ExecuteSqlCommand($"update book_info set coupon_ticket={res.Data} where order_no={book.OrderNo}"); couponticket = res.Data; } else { result.ErrorCode = res.ErrorCode; result.ErrorMessage = res.ErrorMessage; LogUtil.Log("CreateShopOrder_TakeCoupon", book.OrderNo, res.ErrorMessage); } } { //移除购物车 var RemoveProductRes = ZlanAPICaller.ExecuteShop("Member.RemoveProduct", $"{{ 'MemberAccount': '{acc}','SkuCodeList':['{book.ProductSkuNo}'] }}"); if (RemoveProductRes["ErrorCode"].Value <string>() == "0000") { //加入购物车 var SelectProductRes = ZlanAPICaller.ExecuteShop("Member.SelectProduct", $"{{ 'ProductList':[{{ 'Increment': 0, 'Counter': 1, 'ProductSkuCode':'{book.ProductSkuNo}', 'Remark': ''}}], 'MemberAccount': '{acc}' }}"); if (SelectProductRes["ErrorCode"].Value <string>() == "0000") { //确认结算产品 var ConfirmSelectProductRes = ZlanAPICaller.ExecuteShop("Member.ConfirmSelectProduct", $"{{ 'MemberAccount': '{acc}','SkuCodeList':['{book.ProductSkuNo}'] }}"); //生成订单 if (ConfirmSelectProductRes["ErrorCode"].Value <string>() == "0000") { var CouponTicket = new Dictionary <string, IList <string> >(); CouponTicket["Coupon"] = new List <string>() { couponticket }; CouponTicket["RedPackage"] = new List <string>(); var orderParam = new { MemberAccount = acc, book.AddressId, PaymentId = 3, Kind = "shop", CouponTicket, UseSpecialDiscount = 0, VCartDiscount = 0, Score = 0 }; LogUtil.Log("CreateShopOrder_CreateOrderRes", book.OrderNo, JsonConvert.SerializeObject(orderParam)); var CreateOrderRes = ZlanAPICaller.ExecuteShop("Member.CreateOrder", orderParam); if (CreateOrderRes["ErrorCode"].Value <string>() == "0000") { result.Data += context.Database.ExecuteSqlCommand($"update book_info set Status=1,Shop_Order_No={CreateOrderRes["Result"]["PaymentNo"].Value<string>()} where order_no={book.OrderNo}"); //book.Status = 1; //book.ShopOrderNo = CreateOrderRes["Result"]["PaymentNo"].Value<string>(); //book.CouponTicket = res.Data; //context.SaveChanges(); } else { result.ErrorCode = -1; result.ErrorMessage = CreateOrderRes["ErrorMsg"].Value <string>(); LogUtil.Log("CreateShopOrder_CreateOrderRes", book.OrderNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = ConfirmSelectProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("CreateShopOrder_ConfirmSelectProductRes", book.OrderNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = SelectProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("CreateShopOrder_SelectProductRes", book.OrderNo, result.ErrorMessage); } } else { result.ErrorCode = -1; result.ErrorMessage = RemoveProductRes["ErrorMsg"].Value <string>(); LogUtil.Log("CreateShopOrder_RemoveProductRes", book.OrderNo, result.ErrorMessage); } } } } } return(result); }