protected void Page_Load(object sender, EventArgs e) { string OrderId = null; OrderId = Request["oid"]; if (string.IsNullOrEmpty(OrderId)) { Response.End(); } if (bllMall.IsLogin) { OrderInfo = bllMall.GetScoreOrderInfo(OrderId); if (OrderInfo == null) { Response.End(); } if (!OrderInfo.OrderUserID.Equals(bllMall.GetCurrUserID())) { Response.End(); } if (!OrderInfo.WebsiteOwner.Equals(bllMall.WebsiteOwner)) { Response.End(); } } else { Response.Redirect("/App/Cation/Wap/Login.aspx?redirecturl=/App/Cation/Wap/Mall/MyCenter.aspx"); } }
/// <summary> /// 查询 /// </summary> /// <param name="context"></param> /// <returns></returns> private string List(HttpContext context) { string promotionActivityId = context.Request["promotion_activity_id"]; //限时特卖活动ID int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; //页码 int pageSize = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10; //页数 pageSize = 1000; BLLJIMP.Model.PromotionActivity promotionActivity = new BLLJIMP.Model.PromotionActivity(); if (!string.IsNullOrEmpty(promotionActivityId)) { promotionActivity = bllMall.Get <BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", promotionActivityId)); } int totalCount = 0; var sourceData = bllMall.GetPromotionProductList(context, out totalCount); //using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"D:\WXOpenOAuthDevLog.txt", true, System.Text.Encoding.GetEncoding("gb2312"))) //{ // sw.WriteLine(string.Format("{0}\t{1}", DateTime.Now.ToString(), ZentCloud.Common.JSONHelper.ObjectToJson(sourceData))); //} var list = from p in sourceData select new { product_id = p.PID, category_id = p.CategoryId, title = p.PName, quote_price = p.PreviousPrice, price = bllMall.GetShowPrice(p), promotion_price = bllMall.GetMinPrommotionPrice(int.Parse(p.PID)), img_url = bllMall.GetImgUrl(p.RecommendImg), is_onsale = (!string.IsNullOrEmpty(p.IsOnSale) && p.IsOnSale == "1") ? 1 : 0, totalcount = bllMall.GetProductTotalStockPromotion(int.Parse(p.PID)), tags = p.Tags, promotion_count = bllMall.GetProductTotalPromotionSaleStock(int.Parse(p.PID)), //start_time = bllMall.Get<BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", p.PromotionActivityId)).StartTime, //stop_time = bllMall.Get<BLLJIMP.Model.PromotionActivity>(string.Format(" ActivityId={0}", p.PromotionActivityId)).StopTime, start_time = promotionActivity.StartTime, stop_time = promotionActivity.StopTime, is_sms_remind = IsRemind(p.PromotionActivityId.ToString(), bllMall.GetCurrUserID()), is_collect = IsCollectProduct(int.Parse(p.PID)), promotion_activity_id = p.PromotionActivityId }; list = list.Where(p => p.promotion_count > 0).ToList(); totalCount = list.Count(); // list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize); return(ZentCloud.Common.JSONHelper.ObjectToJson(new { start_time = promotionActivity.StartTime, stop_time = promotionActivity.StopTime, totalcount = totalCount, list = list })); }
/// <summary> /// 查询 /// </summary> /// <param name="context"></param> /// <returns></returns> private string List(HttpContext context) { int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1; int pageSize = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10; int totalCount = bllMall.GetCount <BLLJIMP.Model.PromotionActivity>(string.Format(" WebsiteOwner='{0}'", bllMall.WebsiteOwner)); var sourceData = bllMall.GetLit <BLLJIMP.Model.PromotionActivity>(pageSize, pageIndex, string.Format(" WebsiteOwner='{0}'", bllMall.WebsiteOwner), " Sort DESC,ActivityId ASC"); var list = from p in sourceData select new { promotion_activity_id = p.ActivityId, promotion_activity_name = p.ActivityName, promotion_activity_summary = p.ActivitySummary, promotion_activity_image = p.ActivityImage, promotion_activity_start_time = p.StartTime, promotion_activity_stop_time = p.StopTime, is_sms_remind = IsRemind(p.ActivityId.ToString(), bllMall.GetCurrUserID()) }; return(ZentCloud.Common.JSONHelper.ObjectToJson(new { totalcount = totalCount, list = list })); }
protected void Page_Load(object sender, EventArgs e) { if (bllMall.IsLogin) { orderList = bllMall.GetList <WXMallOrderInfo>(string.Format("OrderUserID='{0}' And WebsiteOwner='{1}' Order By InsertDate DESC", bllMall.GetCurrUserID(), bllMall.WebsiteOwner)); } else { Response.Redirect(string.Format("/App/Cation/Wap/Login.aspx?redirecturl={0}", Request.FilePath)); } }
/// <summary> /// 获取订单金额可以获得的积分V2 /// </summary> /// <param name="context"></param> /// <returns></returns> private string ScoreGetRateV2(HttpContext context) { ScoreConfig scoreConfig = bllScore.GetScoreConfig(); if (scoreConfig != null) { string data = context.Request["data"]; decimal productFee = 0; //商品总价格 不包含邮费 OrderRequestModel orderRequestModel; //订单模型 try { orderRequestModel = ZentCloud.Common.JSONHelper.JsonToModel <OrderRequestModel>(data); } catch (Exception ex) { resp.errcode = 1; resp.errmsg = "JSON格式错误,请检查。错误信息:" + ex.Message; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } #region 格式检查 if (orderRequestModel.skus == null) { resp.errcode = 1; resp.errmsg = "参数skus 不能为空"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //相关检查 #endregion #region 商品检查 订单详情生成 ///订单详情 List <WXMallOrderDetailsInfo> detailList = new List <WXMallOrderDetailsInfo>();//订单详情 orderRequestModel.skus = orderRequestModel.skus.Distinct().ToList(); foreach (var sku in orderRequestModel.skus) { //先检查库存 ProductSku productSku = bllMall.GetProductSku(sku.sku_id); if (productSku == null) { resp.errcode = 1; resp.errmsg = "SKU不存在,请检查"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } WXMallProductInfo productInfo = bllMall.GetProduct(productSku.ProductId.ToString()); if (productInfo.IsOnSale == "0") { resp.errcode = 1; resp.errmsg = string.Format("{0}已下架", productInfo.PName); return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } WXMallOrderDetailsInfo detailModel = new WXMallOrderDetailsInfo(); detailModel.PID = productInfo.PID; detailModel.TotalCount = sku.count; detailModel.OrderPrice = bllMall.GetSkuPrice(productSku); detailModel.ProductName = productInfo.PName; detailModel.SkuId = productSku.SkuId; detailModel.SkuShowProp = bllMall.GetProductShowProperties(productSku.SkuId); detailList.Add(detailModel); } #endregion productFee = detailList.Sum(p => p.OrderPrice * p.TotalCount).Value;//商品费用 //物流费用旧的 // orderInfo.Transport_Fee = bllMall.CalcFreight(orderRequestModel.skus.Sum(p => p.count)); #region 运费计算 FreightModel freightModel = new FreightModel(); freightModel.receiver_province_code = orderRequestModel.receiver_province_code; freightModel.receiver_city_code = orderRequestModel.receiver_city_code; freightModel.receiver_dist_code = orderRequestModel.receiver_dist_code; freightModel.skus = orderRequestModel.skus; decimal freight = 0; string freightMsg = ""; if (!bllMall.CalcFreight(freightModel, out freight, out freightMsg)) { resp.errcode = 1; resp.errmsg = freightMsg; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } WXMallOrderInfo orderInfo = new WXMallOrderInfo();//订单信息 orderInfo.Transport_Fee = freight; #endregion #region 优惠券计算 decimal discountAmount = 0;//优惠金额 bool canUseCardCoupon = false; string msg = ""; if (orderRequestModel.cardcoupon_id > 0)//有优惠券 { discountAmount = bllMall.CalcDiscountAmount(orderRequestModel.cardcoupon_id.ToString(), data, bllMall.GetCurrUserID(), out canUseCardCoupon, out msg); if (!canUseCardCoupon) { resp.errcode = 1; resp.errmsg = msg; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } //优惠券计算 #endregion //积分计算 decimal scoreExchangeAmount = 0;///积分抵扣的金额 if (orderRequestModel.use_score > 0) { scoreExchangeAmount = Math.Round(orderRequestModel.use_score / (scoreConfig.ExchangeScore / scoreConfig.ExchangeAmount), 2); } //计算 orderInfo.Product_Fee = productFee; orderInfo.TotalAmount = orderInfo.Product_Fee + orderInfo.Transport_Fee; orderInfo.TotalAmount -= discountAmount; //折扣金额 orderInfo.PayableAmount = orderInfo.TotalAmount - freight; orderInfo.TotalAmount -= scoreExchangeAmount; //积分抵现金 return(ZentCloud.Common.JSONHelper.ObjectToJson(new { errcode = 0, errmsg = orderInfo.PayableAmount })); } else { return(ZentCloud.Common.JSONHelper.ObjectToJson(new { errcode = 1, errmsg = "尚未配置订单获取积分比例" })); } }