Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)

        {
            int totalCount = 0;
            var sourceData = bllMall.GetProductList(context, out totalCount);
            var list       = from p in sourceData
                             select new
            {
                product_id    = p.PID,
                title         = p.PName,
                quote_price   = p.PreviousPrice,
                price         = p.Price,
                category_id   = p.CategoryId,
                category_name = bllMall.GetWXMallCategoryName(p.CategoryId),
                img_url       = bllMall.GetImgUrl(p.RecommendImg),
                is_onsale     = (!string.IsNullOrEmpty(p.IsOnSale) && p.IsOnSale == "1") ? 1 : 0,
                pv            = p.PV,
                tags          = p.Tags,
                sale_count    = p.SaleCount,
            };

            apiResp.status = true;
            apiResp.msg    = "ok";
            apiResp.result = new
            {
                totalcount = totalCount,
                list       = list,//列表
            };
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string List(HttpContext context)
        {
            int totalCount = 0;
            var sourceData = bllMall.GetPromotionProductList(context, out totalCount);
            var list       = from p in sourceData
                             select new
            {
                product_id                = p.PID,
                category_id               = p.CategoryId,
                product_title             = p.PName,
                price                     = p.Price,
                promotion_price           = p.PromotionPrice,
                img_url                   = bllMall.GetImgUrl(p.RecommendImg),
                is_onsale                 = (!string.IsNullOrEmpty(p.IsOnSale) && p.IsOnSale == "1") ? 1 : 0,
                promotion_start_timestamp = p.PromotionStartTime,
                promotion_stop_timestamp  = p.PromotionStopTime,
                sale_count                = bllMall.GetProductSaleCount(int.Parse(p.PID)),
                promotion_count           = p.PromotionStock,
                totalcount                = bllMall.GetProductTotalStock(int.Parse(p.PID))
            };

            return(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                totalcount = totalCount,
                list = list
            }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 顶部菜单
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Top(HttpContext context)
        {
            var sourceData = bllMall.GetList <BLLJIMP.Model.Navigation>(string.Format(" WebsiteOwner='{0}' And NavigationLinkType='top' order by Sort DESC,AutoID ASC", bllMall.WebsiteOwner));
            var rootData   = sourceData.Where(p => p.ParentId == 0);
            List <NavigationModel> list = new List <NavigationModel>();

            foreach (var item in rootData)
            {
                var model = new NavigationModel();
                model.navigation_id      = item.AutoID;
                model.navigation_name    = item.NavigationName;
                model.navigation_link    = item.NavigationLink;
                model.navigation_img_url = bllMall.GetImgUrl(item.NavigationImage);
                list.Add(GetTree(model, sourceData, model.navigation_id));
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(list));
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string          orderId   = context.Request["order_id"];
            WXMallOrderInfo orderInfo = bllMall.GetOrderInfo(orderId);

            if (orderInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号不存在";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (orderInfo.OrderType != 1)
            {
                resp.errcode = 1;
                resp.errmsg  = "不是礼品订单";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (orderInfo.PaymentStatus == 0)
            {
                resp.errcode = 1;
                resp.errmsg  = "礼品订单未付款";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            if (!string.IsNullOrEmpty(orderInfo.ParentOrderId))
            {
                //resp.errcode =1;
                //resp.errmsg = "不是父订单";
                //context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                //return;
                orderInfo = bllMall.GetOrderInfo(orderInfo.ParentOrderId);
            }

            WXMallOrderDetailsInfo orderDetail = bllMall.GetOrderDetail(orderInfo.OrderID).First();
            WXMallProductInfo      productInfo = bllMall.GetProduct(orderDetail.PID);
            ProductSku             skuInfo     = bllMall.GetProductSku((int)orderDetail.SkuId);

            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                errcode         = 0,
                errmsg          = "ok",
                order_id        = orderInfo.OrderID,
                product_name    = productInfo.PName,
                product_img_url = bllMall.GetImgUrl(productInfo.RecommendImg),
                product_count   = orderDetail.TotalCount,
                //product_properties = bllMall.GetProductProperties(skuInfo.SkuId),
                product_properties = "",
                is_get_gift        = IsGetGift(orderInfo.OrderID),
                receiver_list      = GetReceiverList(orderInfo.OrderID),
                send_user_info     = GiftOrderUserInfo(orderInfo.OrderUserID)
            }));
        }
Exemplo n.º 5
0
        /// <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
            }));
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            int totalCount = 0;
            var sourceData = bllMall.GetProductList(context, out totalCount);
            var list       = from p in sourceData
                             select new
            {
                product_id       = p.PID,
                product_sn       = p.ProductCode,
                title            = p.PName,
                quote_price      = p.PreviousPrice,
                price            = p.Price,
                category_id      = p.CategoryId,
                category_name    = bllMall.GetWXMallCategoryName(p.CategoryId),
                img_url          = bllMall.GetImgUrl(p.RecommendImg),
                is_onsale        = (!string.IsNullOrEmpty(p.IsOnSale) && p.IsOnSale == "1") ? 1 : 0,
                pv               = p.PV,
                tags             = p.Tags,
                sale_count       = p.SaleCount,
                create_time      = p.InsertDate.ToString(),
                last_update_time = p.LastUpdate == null ? "" : ((DateTime)p.LastUpdate).ToString("yyyy-MM-dd HH:mm:ss"),
                stock            = bllMall.GetProductTotalStock(int.Parse(p.PID))
                                   //skus = from s in bllMall.GetProductSkuList(int.Parse(p.PID))
                                   //       select new
                                   //       {
                                   //           sku_id = s.SkuId,
                                   //           properties = bllMall.GetProductProperties(s.SkuId),
                                   //           price = bllMall.GetSkuPrice(s),
                                   //           count = bllMall.IsPromotionTime(s) ? p.PromotionStock : p.Stock
                                   //       }
            };

            resp.status = true;
            resp.msg    = "ok";
            resp.result = new
            {
                totalcount = totalCount,
                list       = list,//列表
            };
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 递归获取子节点
        /// </summary>
        /// <param name="model"></param>
        /// <param name="list"></param>
        /// <param name="parentID"></param>
        /// <returns></returns>
        private CategoryModel GetTree(CategoryModel model, IList <BLLJIMP.Model.WXMallCategory> list, int?parentID = 0)
        {
            var query = list.Where(m => m.PreID == parentID);

            if (query.Any())
            {
                if (model.children == null)
                {
                    model.children = new List <CategoryModel>();
                }
                foreach (var item in query)
                {
                    CategoryModel child = new CategoryModel()
                    {
                        category_id      = item.AutoID,
                        category_name    = item.CategoryName,
                        category_img_url = bllMall.GetImgUrl(item.CategoryImg)
                    };
                    model.children.Add(child);
                    this.GetTree(child, list, item.AutoID);
                }
            }
            return(model);
        }
Exemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            /// <summary>
            /// 卡券BLL
            /// </summary>
            BLLJIMP.BLLCardCoupon bllCardCoupon = new BLLJIMP.BLLCardCoupon();
            /// <summary>
            /// 商城BLL
            /// </summary>
            BLLJIMP.BLLMall bllMall = new BLLJIMP.BLLMall();
            /// <summary>
            /// 用户BLL
            /// </summary>
            BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser();
            /// <summary>
            /// 微信BLL
            /// </summary>
            BLLJIMP.BLLWeixin bllWeixin = new BLLJIMP.BLLWeixin();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLStoredValueCard bllStoredValue = new BLLJIMP.BLLStoredValueCard();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLWeixinCard bllWeixinCard = new BLLJIMP.BLLWeixinCard();

            string cardCouponId   = context.Request["cardcoupon_id"];    //主卡券ID
            string myCardCouponId = context.Request["my_cardcoupon_id"]; //我的卡券ID

            if (string.IsNullOrEmpty(cardCouponId))
            {
                resp.status = false;
                resp.msg    = "cardcoupon_id 参数必传";
                context.Response.Write(JsonConvert.SerializeObject(resp));
                return;
            }
            CardCoupons cardCoupon = bllCardCoupon.GetCardCouponByWXCardId(cardCouponId);

            if (cardCoupon == null)
            {
                cardCoupon = bllCardCoupon.GetCardCoupon(int.Parse(cardCouponId));
                if (cardCoupon == null)
                {
                    resp.status = false;
                    resp.msg    = "cardcoupon_id 不存在";
                    context.Response.Write(JsonConvert.SerializeObject(resp));
                    return;
                }
            }
            cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon);

            MainCardModel model = new MainCardModel();

            model.cardcoupon_id      = cardCoupon.CardId;
            model.cardcoupon_name    = cardCoupon.Name;
            model.cardcoupon_type    = ConvertCardCouponType(cardCoupon.CardCouponType);
            model.valid_from         = cardCoupon.ValidFrom.ToString();
            model.valid_to           = cardCoupon.ValidTo.ToString();
            model.img_url            = bllMall.GetImgUrl(cardCoupon.Logo);
            model.discount           = string.IsNullOrEmpty(cardCoupon.Ex1) ? 0 : double.Parse(cardCoupon.Ex1);
            model.product_id         = string.IsNullOrEmpty(cardCoupon.Ex2) ? 0 : double.Parse(cardCoupon.Ex2);
            model.deductible_amount  = string.IsNullOrEmpty(cardCoupon.Ex3) ? 0 : double.Parse(cardCoupon.Ex3);
            model.freefreight_amount = string.IsNullOrEmpty(cardCoupon.Ex4) ? 0 : double.Parse(cardCoupon.Ex4);
            model.buckle_amount      = string.IsNullOrEmpty(cardCoupon.Ex5) ? 0 : double.Parse(cardCoupon.Ex5);
            model.buckle_sub_amount  = string.IsNullOrEmpty(cardCoupon.Ex6) ? 0 : double.Parse(cardCoupon.Ex6);
            model.max_count          = cardCoupon.MaxCount;
            model.send_count         = cardCoupon.SendCount;
            model.un_send_count      = cardCoupon.UnSendCount;
            //model.is_recivece = bllCardCoupon.IsReciveCoupon(cardCoupon.CardId, CurrentUserInfo.UserID);
            model.valid_to_timestamp  = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
            model.limit_type          = cardCoupon.Ex7;
            model.product_tags        = cardCoupon.Ex8;
            model.user_get_limit_type = cardCoupon.GetLimitType;
            model.is_can_use_shop     = cardCoupon.IsCanUseShop;
            model.is_can_use_groupbuy = cardCoupon.IsCanUseGroupbuy;
            model.expire_time_type    = cardCoupon.ExpireTimeType;
            model.expire_day          = cardCoupon.ExpireDay;
            model.weixin_card_id      = cardCoupon.WeixinCardId == null ? "" : cardCoupon.WeixinCardId;
            if (!string.IsNullOrEmpty(myCardCouponId))
            {
                MyCardCoupons myCardCoupon = bllCardCoupon.GetMyCardCoupon(int.Parse(myCardCouponId));
                if (myCardCoupon != null)
                {
                    UserInfo fromUserInfo = bllUser.GetUserInfo(myCardCoupon.UserId);

                    if (fromUserInfo != null)
                    {
                        model.from_user_info = new UserInfoModel();
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }

                    if (!string.IsNullOrEmpty(myCardCoupon.ToUserId))
                    {
                        model.is_donation = true;
                    }
                }
            }

            resp.status = true;
            resp.result = model;

            context.Response.Write(JsonConvert.SerializeObject(resp));
        }
Exemplo n.º 9
0
Arquivo: Get.ashx.cs Projeto: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string orderId = context.Request["order_id"];

            if (string.IsNullOrEmpty(orderId))
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "order_id 必传";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                return;
            }
            WXMallOrderInfo orderInfo = bllMall.GetOrderInfo(orderId);

            if (orderInfo == null)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "订单号不存在";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                return;
            }
            if (orderInfo.OrderType != 2)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "不是拼团订单";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                return;
            }
            if (!string.IsNullOrEmpty(orderInfo.GroupBuyParentOrderId))
            {
                orderInfo = bllMall.GetOrderInfo(orderInfo.GroupBuyParentOrderId);
            }
            if (orderInfo.PaymentStatus == 0)
            {
                apiResp.code = (int)APIErrCode.OperateFail;
                apiResp.msg  = "团长订单未付款";
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
                return;
            }
            WXMallOrderDetailsInfo orderDetail = bllMall.GetOrderDetail(orderInfo.OrderID).First();
            WXMallProductInfo      productInfo = bllMall.GetProduct(orderDetail.PID);
            ProductSku             skuInfo     = bllMall.GetProductSku((int)orderDetail.SkuId);
            decimal kk = Math.Round((decimal)productInfo.Price * (decimal)(orderInfo.MemberDiscount / 10), 2);

            apiResp.result =
                new
            {
                order_id           = orderInfo.OrderID,
                product_id         = productInfo.PID,
                product_name       = productInfo.PName,
                summary            = productInfo.Summary,
                priduct_price      = productInfo.Price,
                product_price      = productInfo.Price,
                product_img_url    = bllMall.GetImgUrl(productInfo.RecommendImg),
                product_properties = bllMall.GetProductProperties(skuInfo.SkuId),
                product_desc       = productInfo.PDescription,
                is_join            = IsJoin(orderInfo),
                people_list        = GetPeopleList(orderInfo),
                head_discount      = orderInfo.HeadDiscount,
                head_price         = Math.Round((decimal)productInfo.Price * (decimal)(orderInfo.HeadDiscount / 10), 2),
                member_discount    = orderInfo.MemberDiscount,
                member_price       = Math.Round((decimal)productInfo.Price * (decimal)(orderInfo.MemberDiscount / 10), 2),
                people_count       = orderInfo.PeopleCount,
                pay_people_count   = GetPayPeopleCount(orderInfo),
                expire_day         = orderInfo.ExpireDay,
                is_head            = IsHead(orderInfo),
                group_buy_status   = GetGroupBuyStatus(orderInfo),
                end_time           = bllMall.GetTimeStamp(((DateTime)orderInfo.PayTime).AddDays(orderInfo.ExpireDay)),
                pay_order_id       = GetNeedPayOrderId(orderInfo),
                score           = productInfo.Score,
                is_cashpay_only = productInfo.IsCashPayOnly,
                is_no_express   = productInfo.IsNoExpress,
                sku_id          = skuInfo.SkuId,
                ex10            = orderInfo.Ex10
            };
            apiResp.status = true;
            apiResp.msg    = "ok";
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp));
        }
Exemplo n.º 10
0
        /// <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"]) : 20;

            pageSize = int.MaxValue;
            string cardcouponStatus    = context.Request["cardcoupon_status"];
            string isCanUse            = context.Request["is_can_use"];            //可以正常使用的标识
            string amount              = context.Request["amount"];                //订单金额
            string isNotShowStoreValue = context.Request["is_notshow_storevalue"]; //是否不显示储值卡
            // string skuIds = context.Request["sku_ids"];
            bool               isSuccess  = false;
            string             msg        = "";
            string             couponName = "";
            int                totalCount = 0;
            List <MyCardModel> list       = new List <MyCardModel>();

            #region 优惠券
            var sourceData = bllCardCoupon.GetMyCardCoupons(currentUserInfo.UserID, pageIndex, pageSize, out totalCount, cardcouponStatus);

            foreach (var item in sourceData)
            {
                BLLJIMP.Model.CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(item.CardId);
                cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon, item);
                MyCardModel model = new MyCardModel();
                model.cardcoupon_id      = item.AutoId;
                model.cardcoupon_number  = item.CardCouponNumber;
                model.main_cardcoupon_id = item.CardId;

                model.cardcoupon_name      = cardCoupon.Name;
                model.cardcoupon_type      = ConvertCardCouponType(cardCoupon.CardCouponType);
                model.valid_from           = cardCoupon.ValidFrom.ToString();
                model.valid_to             = cardCoupon.ValidTo.ToString();
                model.img_url              = bllMall.GetImgUrl(cardCoupon.Logo);
                model.cardcoupon_status    = item.Status;
                model.cardcoupon_gettime   = bllCardCoupon.GetTimeStamp(item.InsertDate);
                model.product_id           = cardCoupon.Ex2;
                model.valid_from_timestamp = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidFrom);
                model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                model.discount             = cardCoupon.Ex1;
                model.deductible_amount    = cardCoupon.Ex3;
                model.freefreight_amount   = cardCoupon.Ex4;
                model.buckle_amount        = cardCoupon.Ex5;
                model.buckle_sub_amount    = cardCoupon.Ex6;
                model.limit_type           = cardCoupon.Ex7;
                model.product_tags         = cardCoupon.Ex8;
                model.hexiao_channel       = item.HexiaoChannel;
                model.is_can_use_shop      = cardCoupon.IsCanUseShop;
                model.is_can_use_groupbuy  = cardCoupon.IsCanUseGroupbuy;

                if (model.cardcoupon_type == 4)//满减券直接转成现金券
                {
                    model.buckle_amount     = "";
                    model.buckle_sub_amount = "";
                    model.cardcoupon_type   = 1;
                    model.deductible_amount = cardCoupon.Ex6;
                }

                #region 转赠信息
                model.is_can_give = bllCardCoupon.IsCanGiveCoupon(item, out msg);
                if (!string.IsNullOrEmpty(item.FromUserId))//赠送人信息
                {
                    model.from_user_info = new UserInfoModel();
                    UserInfo fromUserInfo = bllUser.GetUserInfo(item.FromUserId);
                    if (fromUserInfo != null)
                    {
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }
                }
                if (!string.IsNullOrEmpty(item.ToUserId))//被赠送人信息
                {
                    model.to_user_info = new UserInfoModel();
                    UserInfo toUserInfo = bllUser.GetUserInfo(item.ToUserId);
                    if (toUserInfo != null)
                    {
                        model.to_user_info.head_img_url = bllUser.GetUserDispalyAvatar(toUserInfo);
                        model.to_user_info.nick_name    = bllUser.GetUserDispalyName(toUserInfo);
                    }
                }
                #endregion

                if (isCanUse == "1")//可以使用
                {
                    if (model.cardcoupon_status == 0)
                    {
                        if (cardCoupon.ValidFrom != null && cardCoupon.ValidTo != null)
                        {
                            DateTime dtNow = DateTime.Now;
                            if (dtNow >= (DateTime)(cardCoupon.ValidFrom) && (dtNow <= (DateTime)(cardCoupon.ValidTo)))
                            {
                                list.Add(model);
                                //if (!string.IsNullOrEmpty(amount))
                                //{
                                //    if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), CurrentUserInfo.UserID, out isSuccess, out msg, out couponName) > 0)
                                //    {
                                //        list.Add(model);
                                //    }
                                //}
                                //else
                                //{
                                //    list.Add(model);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(amount))
                    {
                        if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), currentUserInfo.UserID, out isSuccess, out msg, out couponName) > 0)
                        {
                            list.Add(model);
                        }
                    }
                    else
                    {
                        list.Add(model);
                    }
                }
            }
            #endregion



            #region 储值卡转换成现金券
            if (string.IsNullOrEmpty(isNotShowStoreValue))
            {
                var storeValueCardList = bllStoredValue.GetCanUseStoredValueCardList(currentUserInfo.UserID);
                foreach (var item in storeValueCardList)
                {
                    try
                    {
                        BLLJIMP.Model.StoredValueCard cardCoupon = bllStoredValue.Get <StoredValueCard>(string.Format(" AutoId={0}", item.CardId));
                        MyCardModel model = new MyCardModel();
                        model.cardcoupon_id      = item.AutoId;
                        model.main_cardcoupon_id = item.CardId;
                        model.cardcoupon_name    = string.Format("{0}(储值卡余额{1}元)", cardCoupon.Name, bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId));
                        model.valid_from         = DateTime.Now.ToString();
                        model.valid_to           = cardCoupon.ValidTo.ToString();
                        // model.img_url = bllMall.GetImgUrl(cardCoupon.Logo);
                        model.cardcoupon_status = 0;
                        //model.cardcoupon_gettime = bllCardCoupon.GetTimeStamp(item.InsertDate);
                        //model.product_id = cardCoupon.Ex2;
                        model.valid_from_timestamp = bllCardCoupon.GetTimeStamp(DateTime.Now);
                        model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                        model.discount             = "";
                        //model.deductible_amount = cardCoupon.Ex3;
                        model.freefreight_amount = "";
                        model.buckle_amount      = "";
                        model.buckle_sub_amount  = "";
                        model.limit_type         = "";
                        model.product_tags       = "";
                        //model.hexiao_channel = item.HexiaoChannel;
                        model.is_can_use_shop     = 1;
                        model.is_can_use_groupbuy = 1;
                        model.product_id          = "";
                        model.buckle_amount       = "";
                        model.buckle_sub_amount   = "";
                        model.cardcoupon_type     = 1;
                        model.deductible_amount   = (item.Amount - bllStoredValue.GetUseRecordList(item.AutoId, item.UserId).Sum(p => p.UseAmount)).ToString();
                        model.is_store_card       = 1;
                        list.Add(model);
                        totalCount++;
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                #endregion

                #region 海澜处理

                if (bllCardCoupon.WebsiteOwner.Contains("hailan"))
                {
                    Open.HongWareSDK.Client client = new Open.HongWareSDK.Client(bllCardCoupon.WebsiteOwner);
                    Open.HongWareSDK.Entity.YimaVerifyCard yimaCard = new Open.HongWareSDK.Entity.YimaVerifyCard();
                    yimaCard.pos_seq = DateTime.Now.ToString("yyyyMMddHHmmss");

                    List <string> cardCodes = new List <string>();
                    client.YimaCardVerify(yimaCard, out cardCodes, out msg);
                    if (cardCodes.Count > 0)
                    {
                        foreach (var item in list)
                        {
                            if (cardCodes.Contains(item.yima_cardcode))
                            {
                                list.Remove(item);
                            }
                        }
                    }
                    else
                    {
                        list = new List <MyCardModel>();//无卡券可用
                    }
                }
                #endregion
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(new
            {
                totalcount = list.Count,
                list = list
            }));
        }
Exemplo n.º 11
0
        public void ProcessRequest(HttpContext context)
        {
            /// <summary>
            /// 卡券BLL
            /// </summary>
            BLLJIMP.BLLCardCoupon bllCardCoupon = new BLLJIMP.BLLCardCoupon();
            /// <summary>
            /// 商城BLL
            /// </summary>
            BLLJIMP.BLLMall bllMall = new BLLJIMP.BLLMall();
            /// <summary>
            /// 用户BLL
            /// </summary>
            BLLJIMP.BLLUser bllUser = new BLLJIMP.BLLUser();
            /// <summary>
            /// 微信BLL
            /// </summary>
            BLLJIMP.BLLWeixin bllWeixin = new BLLJIMP.BLLWeixin();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLStoredValueCard bllStoredValue = new BLLJIMP.BLLStoredValueCard();
            /// <summary>
            ///
            /// </summary>
            BLLJIMP.BLLWeixinCard bllWeixinCard = new BLLJIMP.BLLWeixinCard();


            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"]) : 20;

            pageSize = int.MaxValue;
            string cardcouponStatus    = context.Request["cardcoupon_status"];
            string isCanUse            = "0";                                      // context.Request["is_can_use"];//可以正常使用的标识
            string amount              = context.Request["amount"];                //订单金额
            string isNotShowStoreValue = context.Request["is_notshow_storevalue"]; //是否不显示储值卡

            string openId = context.Request["open_id"];

            bool   isSuccess  = false;
            string msg        = "";
            string couponName = "";
            int    totalCount = 0;

            var currUser = bllUser.GetUserInfoByOpenId(openId);

            if (currUser == null)
            {
                resp.status = false;
                resp.msg    = "openid找不到用户";
                context.Response.Write(JsonConvert.SerializeObject(resp));
                return;
            }

            List <MyCardModel> list = new List <MyCardModel>();

            #region 优惠券
            var sourceData = bllCardCoupon.GetMyCardCoupons(currUser.UserID, pageIndex, pageSize, out totalCount, cardcouponStatus);
            foreach (var item in sourceData)
            {
                BLLJIMP.Model.CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(item.CardId);
                cardCoupon = bllCardCoupon.ConvertExpireTime(cardCoupon, item);
                MyCardModel model = new MyCardModel();
                model.cardcoupon_id        = item.AutoId;
                model.main_cardcoupon_id   = item.CardId;
                model.cardcoupon_name      = cardCoupon.Name;
                model.cardcoupon_type      = ConvertCardCouponType(cardCoupon.CardCouponType);
                model.valid_from           = cardCoupon.ValidFrom.ToString();
                model.valid_to             = cardCoupon.ValidTo.ToString();
                model.img_url              = bllMall.GetImgUrl(cardCoupon.Logo);
                model.cardcoupon_status    = item.Status;
                model.cardcoupon_gettime   = bllCardCoupon.GetTimeStamp(item.InsertDate);
                model.product_id           = cardCoupon.Ex2;
                model.valid_from_timestamp = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidFrom);
                model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                model.discount             = cardCoupon.Ex1;
                model.deductible_amount    = cardCoupon.Ex3;
                model.freefreight_amount   = cardCoupon.Ex4;
                model.buckle_amount        = cardCoupon.Ex5;
                model.buckle_sub_amount    = cardCoupon.Ex6;
                model.limit_type           = cardCoupon.Ex7;
                model.product_tags         = cardCoupon.Ex8;
                model.hexiao_channel       = item.HexiaoChannel;
                model.is_can_use_shop      = cardCoupon.IsCanUseShop;
                model.is_can_use_groupbuy  = cardCoupon.IsCanUseGroupbuy;
                model.weixin_card_id       = cardCoupon.WeixinCardId;

                if (model.cardcoupon_type == 4)//满减券直接转成现金券
                {
                    model.buckle_amount     = "";
                    model.buckle_sub_amount = "";
                    model.cardcoupon_type   = 1;
                    model.deductible_amount = cardCoupon.Ex6;
                }

                #region 转赠信息
                model.is_can_give = bllCardCoupon.IsCanGiveCoupon(item, out msg);
                if (!string.IsNullOrEmpty(item.FromUserId))//赠送人信息
                {
                    model.from_user_info = new UserInfoModel();
                    UserInfo fromUserInfo = bllUser.GetUserInfo(item.FromUserId);
                    if (fromUserInfo != null)
                    {
                        model.from_user_info.head_img_url = bllUser.GetUserDispalyAvatar(fromUserInfo);
                        model.from_user_info.nick_name    = bllUser.GetUserDispalyName(fromUserInfo);
                    }
                }
                if (!string.IsNullOrEmpty(item.ToUserId))//被赠送人信息
                {
                    model.to_user_info = new UserInfoModel();
                    UserInfo toUserInfo = bllUser.GetUserInfo(item.ToUserId);
                    if (toUserInfo != null)
                    {
                        model.to_user_info.head_img_url = bllUser.GetUserDispalyAvatar(toUserInfo);
                        model.to_user_info.nick_name    = bllUser.GetUserDispalyName(toUserInfo);
                    }
                }
                #endregion

                if (isCanUse == "1")//可以使用
                {
                    if (model.cardcoupon_status == 0)
                    {
                        if (cardCoupon.ValidFrom != null && cardCoupon.ValidTo != null)
                        {
                            DateTime dtNow = DateTime.Now;
                            if (dtNow >= (DateTime)(cardCoupon.ValidFrom) && (dtNow <= (DateTime)(cardCoupon.ValidTo)))
                            {
                                list.Add(model);
                                //if (!string.IsNullOrEmpty(amount))
                                //{
                                //    if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), currUser.UserID, out isSuccess, out msg, out couponName) > 0)
                                //    {
                                //        list.Add(model);
                                //    }
                                //}
                                //else
                                //{
                                //    list.Add(model);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(amount))
                    {
                        if (bllMall.CalcDiscountAmount(item.AutoId.ToString(), decimal.Parse(amount), currUser.UserID, out isSuccess, out msg, out couponName) > 0)
                        {
                            list.Add(model);
                        }
                    }
                    else
                    {
                        list.Add(model);
                    }
                }
            }
            #endregion

            #region 储值卡转换成现金券
            if (string.IsNullOrEmpty(isNotShowStoreValue))
            {
                var storeValueCardList = bllStoredValue.GetCanUseStoredValueCardList(currUser.UserID);
                foreach (var item in storeValueCardList)
                {
                    try
                    {
                        BLLJIMP.Model.StoredValueCard cardCoupon = bllStoredValue.Get <StoredValueCard>(string.Format(" AutoId={0}", item.CardId));
                        MyCardModel model = new MyCardModel();
                        model.cardcoupon_id      = item.AutoId;
                        model.main_cardcoupon_id = item.CardId;
                        model.cardcoupon_name    = string.Format("{0}(储值卡余额{1}元)", cardCoupon.Name, bllMall.GetStoreValueCardCanUseAmount(item.AutoId.ToString(), item.UserId));
                        model.valid_from         = DateTime.Now.ToString();
                        model.valid_to           = cardCoupon.ValidTo.ToString();
                        // model.img_url = bllMall.GetImgUrl(cardCoupon.Logo);
                        model.cardcoupon_status = 0;
                        //model.cardcoupon_gettime = bllCardCoupon.GetTimeStamp(item.InsertDate);
                        //model.product_id = cardCoupon.Ex2;
                        model.valid_from_timestamp = bllCardCoupon.GetTimeStamp(DateTime.Now);
                        model.valid_to_timestamp   = bllCardCoupon.GetTimeStamp((DateTime)cardCoupon.ValidTo);
                        model.discount             = "";
                        //model.deductible_amount = cardCoupon.Ex3;
                        model.freefreight_amount = "";
                        model.buckle_amount      = "";
                        model.buckle_sub_amount  = "";
                        model.limit_type         = "";
                        model.product_tags       = "";
                        //model.hexiao_channel = item.HexiaoChannel;
                        model.is_can_use_shop     = 1;
                        model.is_can_use_groupbuy = 1;
                        model.product_id          = "";
                        model.buckle_amount       = "";
                        model.buckle_sub_amount   = "";
                        model.cardcoupon_type     = 1;
                        model.deductible_amount   = (item.Amount - bllStoredValue.GetUseRecordList(item.AutoId, item.UserId).Sum(p => p.UseAmount)).ToString();
                        model.is_store_card       = 1;
                        list.Add(model);
                        totalCount++;
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                #endregion
            }

            resp.status = true;

            resp.result = new
            {
                totalcount = list.Count,
                list       = list
            };

            context.Response.Write(JsonConvert.SerializeObject(resp));
        }
Exemplo n.º 12
0
Arquivo: Get.ashx.cs Projeto: uvbs/mmp
        public void ProcessRequest(HttpContext context)
        {
            string productId = context.Request["product_id"];
            string productSn = context.Request["product_sn"];
            string storeId   = context.Request["store_id"];

            if (string.IsNullOrEmpty(productId) && string.IsNullOrEmpty(productSn))
            {
                resp.msg  = "product_id product_sn不能同时为空";
                resp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            var productInfo = bllMall.GetProduct(productId);

            if (productInfo == null)
            {
                productInfo = bllMall.GetProductByProductCode(productSn);
            }

            if (productInfo == null)
            {
                resp.msg  = "商品不存在";
                resp.code = (int)BLLJIMP.Enums.APIErrCode.IsNotFound;
                context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
                return;
            }
            var productSkuList = bllMall.GetProductSkuList(int.Parse(productInfo.PID), true, storeId);//源SKU
            var skus           = from p in productSkuList
                                 select new
            {
                sku_id     = p.SkuId,
                properties = bllMall.GetProductProperties(p.SkuId),
                price      = bllMall.GetSkuPrice(p),
                count      = bllMall.IsPromotionTime(p) ? p.PromotionStock : p.Stock
            };

            resp.result = new
            {
                product_id       = productInfo.PID,
                product_sn       = productInfo.ProductCode,
                title            = productInfo.PName,
                quote_price      = productInfo.PreviousPrice,
                price            = productInfo.Price,
                category_id      = productInfo.CategoryId,
                category_name    = bllMall.GetWXMallCategoryName(productInfo.CategoryId),
                img_url          = bllMall.GetImgUrl(productInfo.RecommendImg),
                is_onsale        = (!string.IsNullOrEmpty(productInfo.IsOnSale) && productInfo.IsOnSale == "1") ? 1 : 0,
                pv               = productInfo.PV,
                sale_count       = productInfo.SaleCount,
                create_time      = productInfo.InsertDate.ToString(),
                last_update_time = productInfo.LastUpdate == null ? "" :((DateTime)productInfo.LastUpdate).ToString("yyyy-MM-dd HH:mm:ss"),
                stock            = bllMall.GetProductTotalStock(int.Parse(productInfo.PID)),
                tags             = productInfo.Tags,
                skus             = skus,
                product_desc     = productInfo.PDescription
            };
            resp.status = true;
            resp.msg    = "ok";
            context.Response.Write(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }