示例#1
0
        /// <summary>
        /// 独立小程序:15天后订单商品自动评论
        /// </summary>
        public void StartPlatChildGoodsCommentServer(int timelength)
        {
            List <PlatChildGoodsCart> entgoodscartlist = PlatChildGoodsCartBLL.SingleModel.GetSuccessDataList(0, timelength);

            if (entgoodscartlist != null && entgoodscartlist.Count > 0)
            {
                string            userids      = string.Join(",", entgoodscartlist.Select(s => s.UserId).Distinct());
                List <C_UserInfo> userinfolist = C_UserInfoBLL.SingleModel.GetListByIds(userids);
                userinfolist = userinfolist == null ? new List <C_UserInfo>() : userinfolist;

                string aids = string.Join(",", entgoodscartlist.Select(s => s.AId).Distinct());
                List <XcxAppAccountRelation> xcxrelationlist = XcxAppAccountRelationBLL.SingleModel.GetListByIds(aids);
                xcxrelationlist = xcxrelationlist == null ? new List <XcxAppAccountRelation>() : xcxrelationlist;

                string goodsids = string.Join(",", entgoodscartlist.Select(s => s.GoodsId).Distinct());
                List <PlatChildGoods> goodslist = PlatChildGoodsBLL.SingleModel.GetListByIds(goodsids);
                goodslist = goodslist == null ? new List <PlatChildGoods>() : goodslist;

                foreach (PlatChildGoodsCart itemcart in entgoodscartlist)
                {
                    C_UserInfo            userinfo    = userinfolist?.FirstOrDefault(f => f.Id == itemcart.UserId);
                    XcxAppAccountRelation xcxrelation = xcxrelationlist?.FirstOrDefault(f => f.Id == itemcart.AId);
                    PlatChildGoods        good        = goodslist?.FirstOrDefault(f => f.Id == itemcart.GoodsId);
                    string imgurl = string.IsNullOrEmpty(itemcart.SpecImg) ? good.Img : itemcart.SpecImg;

                    itemcart.IsCommentting = true;
                    PlatChildGoodsCartBLL.SingleModel.Update(itemcart, "IsCommentting");
                    SingleModel.AddComment(xcxrelation.Id, userinfo, 0, itemcart.GoodsId, itemcart.GoodsName, itemcart.Price, imgurl, itemcart.OrderId, itemcart.SpecInfo);
                }
            }
        }
示例#2
0
        public ActionResult GetGoodInfo()
        {
            int pid    = Context.GetRequestInt("pid", 0);
            int userId = Context.GetRequestInt("userId", 0);

            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";

            if (pid == 0)
            {
                returnObj.Msg = "请选择产品";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatChildGoods goodModel = PlatChildGoodsBLL.SingleModel.GetModel(pid);

            if (goodModel == null || goodModel.State == 0)
            {
                returnObj.Msg = "产品不存在或已删除";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            PlatStore platStore = PlatStoreBLL.SingleModel.GetModelByAId(goodModel.AId);

            if (platStore == null)
            {
                returnObj.Msg = "店铺不存在";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            if (!string.IsNullOrEmpty(goodModel.Plabels))
            {
                //goodModel.plabelstr = DAL.Base.SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"SELECT group_concat(name order by sort desc) from entgoodlabel where id in ({goodModel.plabels})").ToString();
                goodModel.PlabelStr      = PlatChildGoodsLabelBLL.SingleModel.GetEntGoodsLabelStr(goodModel.Plabels);
                goodModel.PlabelStr_Arry = goodModel.PlabelStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            }

            #region 会员折扣显示
            //获取会员信息
            VipRelation vipInfo   = VipRelationBLL.SingleModel.GetModelByUserid(userId);
            VipLevel    levelinfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null;

            List <PlatChildGoods> list = new List <PlatChildGoods>();
            list.Add(goodModel);
            //  _miniappVipLevelBll.GetVipDiscount(ref list, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel = list.FirstOrDefault();

            #endregion 会员折扣显示

            //#region 会员打折
            List <PlatChildGoodsCart> carlist = new List <PlatChildGoodsCart>()
            {
                new PlatChildGoodsCart()
                {
                    GoodsId = goodModel.Id
                }
            };
            carlist.ForEach(g => g.OriginalPrice = g.Price);
            VipLevelBLL.SingleModel.GetVipDiscount(ref carlist, vipInfo, levelinfo, userId, "Discount", "Price");
            goodModel.Discount = carlist[0].Discount;
            //#endregion 会员打折

            if (!string.IsNullOrEmpty(goodModel.Img))
            {
                goodModel.Img = goodModel.Img.Replace("http://vzan-img.oss-cn-hangzhou.aliyuncs.com", "https://i.vzan.cc/");
            }

            List <GoodsSpecDetail> listGoodsSpecDetail = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GoodsSpecDetail> >(goodModel.SpecDetail);
            listGoodsSpecDetail.ForEach(x =>
            {
                if (x.Discount == 100)
                {
                    x.DiscountPrice = x.Price;
                }
            });

            goodModel.SpecDetail = JsonConvert.SerializeObject(listGoodsSpecDetail);
            goodModel.storeModel = new StoreModel()
            {
                StoreId = platStore.Id,
                Name    = platStore.Name,
                Img     = platStore.StoreHeaderImg,
                Loction = platStore.Location,
                Lng     = platStore.Lng,
                Lat     = platStore.Lat
            };

            PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId);
            if (platMyCard != null)
            {
                goodModel.storeOwner = new StoreOwner()
                {
                    UserId = platMyCard.UserId,
                    Name   = platMyCard.Name,
                    Avatar = platMyCard.ImgUrl
                };

                PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(platMyCard.AId, platMyCard.UserId);
                if (userCash != null)
                {
                    goodModel.storeOwner.IsOpenDistribution = userCash.IsOpenDistribution;
                }
            }

            returnObj.isok    = true;
            returnObj.dataObj = goodModel;
            returnObj.Msg     = "获取成功";
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        /// <summary>
        /// 添加商品至购物车
        /// </summary>
        /// <returns></returns>
        public ActionResult AddGoodsCarData()
        {
            returnObj = new Return_Msg_APP();
            string attrSpacStr = Context.GetRequest("attrspacstr", "");
            //商品规格(格式):规格1:属性1 规格2:属性2 如:(颜色:白色 尺码:M)
            string specInfo = Context.GetRequest("specinfo", "");
            string specImg  = Context.GetRequest("specimg", "");
            int    goodId   = Context.GetRequestInt("goodid", 0);
            int    userId   = Context.GetRequestInt("userid", 0);
            int    qty      = Context.GetRequestInt("qty", 0);
            //立即购买,1:立即购买,0:添加到购物车
            int gotoBuy = Context.GetRequestInt("gotobuy", 2);

            if (qty <= 0)
            {
                returnObj.Msg = "数量必须大于0";
                return(Json(returnObj));
            }

            PlatChildGoods good = PlatChildGoodsBLL.SingleModel.GetModel(goodId);

            if (good == null)
            {
                returnObj.Msg = "未找到该商品";
                return(Json(returnObj));
            }
            PlatStore store = PlatStoreBLL.SingleModel.GetModelByAId(good.AId);

            if (store == null)
            {
                returnObj.Msg = "店铺已关闭";
                return(Json(returnObj));
            }
            if (!string.IsNullOrWhiteSpace(attrSpacStr))
            {
                //log4net.LogHelper.WriteInfo(this.GetType(),$"{JsonConvert.SerializeObject(good.GASDetailList)},{attrSpacStr}");
                if (!good.GASDetailList.Any(x => x.Id.Equals(attrSpacStr)))
                {
                    returnObj.Msg = "商品已过期";
                    return(Json(returnObj));
                }
            }
            if (!(good.State == 1 && good.Tag == 1))
            {
                returnObj.Msg = "无法添加失效商品";
                return(Json(returnObj));
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                returnObj.Msg = "用户不存在";
                return(Json(returnObj));
            }

            PlatChildGoodsCart car = PlatChildGoodsCartBLL.SingleModel.GetModelBySpec(userInfo.Id, goodId, attrSpacStr, 0);
            //商品价格
            int price = Convert.ToInt32(good.Price * 100);

            price = Convert.ToInt32(!string.IsNullOrWhiteSpace(attrSpacStr) ? good.GASDetailList.First(x => x.Id.Equals(attrSpacStr)).Price * 100 : good.Price * 100);

            if (car == null || gotoBuy == 1)
            {
                car = new PlatChildGoodsCart
                {
                    //FoodId = store.Id,
                    StoreId   = store.Id,
                    GoodsName = good.Name,
                    GoodsId   = good.Id,
                    SpecIds   = attrSpacStr,
                    Count     = qty,
                    Price     = price,
                    SpecInfo  = specInfo,
                    SpecImg   = specImg,//规格图片
                    UserId    = userInfo.Id,
                    AddTime   = DateTime.Now,
                    State     = 0,
                    GoToBuy   = gotoBuy,
                    AId       = good.AId,
                };

                //加入购物车
                int id = Convert.ToInt32(PlatChildGoodsCartBLL.SingleModel.Add(car));
                if (id > 0)
                {
                    int cartcount = PlatChildGoodsCartBLL.SingleModel.GetCartGoodsCountByUserId(userInfo.Id);
                    returnObj.Msg     = "成功";
                    returnObj.dataObj = new { id = id, count = cartcount };
                    returnObj.isok    = true;
                    return(Json(returnObj));
                }
            }
            else
            {
                car.Count += qty;
                if (PlatChildGoodsCartBLL.SingleModel.Update(car, "Count"))
                {
                    int cartcount = PlatChildGoodsCartBLL.SingleModel.GetCartGoodsCountByUserId(userInfo.Id);
                    returnObj.dataObj = new { id = car.Id, count = cartcount };
                    returnObj.Msg     = "成功";
                    returnObj.isok    = true;
                    return(Json(returnObj));
                }
            }

            returnObj.Msg = "失败";
            return(Json(returnObj));
        }
示例#4
0
        /// <summary>
        /// 从购物车 删除商品
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="openid"></param>
        /// <param name="goodsCarId"></param>
        /// <param name="function">0为更新,-1为删除</param>
        /// <returns></returns>
        public ActionResult UpdateOrDeleteGoodsCarData()
        {
            returnObj = new Return_Msg_APP();
            string cartStr = Context.GetRequest("cartstr", "");
            int    userId  = Context.GetRequestInt("userid", 0);
            int    type    = Context.GetRequestInt("type", 0);

            if (string.IsNullOrEmpty(cartStr))
            {
                returnObj.Msg = "数据不能为空";
                return(Json(returnObj));
            }
            List <PlatChildGoodsCart> goodsCarModel = JsonConvert.DeserializeObject <List <PlatChildGoodsCart> >(cartStr);

            if (userId <= 0)
            {
                returnObj.Msg = "userid不能为空";
                return(Json(returnObj));
            }
            C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userInfo == null)
            {
                returnObj.Msg = "找不到用户";
                return(Json(returnObj));
            }
            if (goodsCarModel == null || goodsCarModel.Count <= 0)
            {
                returnObj.Msg = "找不到购物车数据";
                return(Json(returnObj));
            }

            string column = "";

            foreach (PlatChildGoodsCart item in goodsCarModel)
            {
                column = "State";
                if (type == -1)
                {
                    item.State = -1;
                }
                else if (type == 0)//根据传入参数更新购物车内容
                {
                    //价格因更改规格随之改变
                    PlatChildGoods carGoods = PlatChildGoodsBLL.SingleModel.GetModel(item.GoodsId);
                    if (carGoods == null)
                    {
                        item.State = 2;
                    }
                    else
                    {
                        column += ",Count";
                        if (!string.IsNullOrWhiteSpace(carGoods.SpecDetail))
                        {
                            float?price = carGoods.GASDetailList.Where(x => x.Id.Equals(item.SpecIds))?.FirstOrDefault()?.Price;
                            if (price != null)
                            {
                                column    += ",Price";
                                item.Price = Convert.ToInt32(price * 100);
                            }
                        }
                    }
                }

                bool success = PlatChildGoodsCartBLL.SingleModel.Update(item, column);
                if (!success)
                {
                    returnObj.Msg = "失败";
                    return(Json(returnObj));
                }
            }
            returnObj.Msg  = "操作成功";
            returnObj.isok = true;
            return(Json(returnObj));
        }
示例#5
0
        /// <summary>
        /// 查询购物车
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="openid"></param>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public ActionResult GetGoodsCarList()
        {
            returnObj = new Return_Msg_APP();
            int pageSize  = Context.GetRequestInt("pageSize", 6);
            int pageIndex = Context.GetRequestInt("pageIndex", 1);
            int userId    = Context.GetRequestInt("userid", 0);

            try
            {
                C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId);
                if (userInfo == null)
                {
                    returnObj.Msg = "用户不存在";
                    return(Json(returnObj));
                }

                XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(userInfo.appId);
                if (xcxrelation == null)
                {
                    returnObj.Msg = "未绑定小程序或模板已过期";
                    return(Json(returnObj));
                }

                List <PlatChildGoodsCart> carList = PlatChildGoodsCartBLL.SingleModel.GetListByUserId(xcxrelation.Id, userInfo.Id, pageSize, pageIndex);

                if (carList == null || carList.Count <= 0)
                {
                    returnObj.Msg = "购物车为空";
                    return(Json(returnObj));
                }

                //获取会员信息
                VipRelation vipInfo   = VipRelationBLL.SingleModel.GetModelByUserid(userInfo.Id);
                VipLevel    levelInfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null;

                //#region 会员打折
                carList.ForEach(g => g.OriginalPrice = g.Price);
                VipLevelBLL.SingleModel.GetVipDiscount(ref carList, vipInfo, levelInfo, userInfo.Id, "Discount", "Price");
                //#endregion 会员打折

                //获取商品详细资料
                List <PlatChildGoods> goods = new List <PlatChildGoods>();
                goods = PlatChildGoodsBLL.SingleModel.GetList($" Id in ({string.Join(",", carList.Select(x => x.GoodsId))}) ");

                if (goods == null || goods.Count <= 0)
                {
                    returnObj.Msg     = "商品已过期";
                    returnObj.dataObj = carList;
                    return(Json(returnObj));
                }

                PlatChildGoods curGood = new PlatChildGoods();
                carList.ForEach(c =>
                {
                    curGood = goods.FirstOrDefault(g => g.Id == c.GoodsId);
                    if (curGood != null && curGood.Id > 0)
                    {
                        //多规格处理
                        if (curGood.GASDetailList != null && curGood.GASDetailList.Count > 0)
                        {
                            List <GoodsSpecDetail> detaillist = curGood.GASDetailList.ToList();
                            detaillist?.ForEach(g =>
                            {
                                g.OriginalPrice     = g.Price;
                                g.Discount          = c.Discount;
                                float discountPrice = g.Price * (c.Discount * 0.01F);
                                g.DiscountPrice     = discountPrice < 0.01 ? 0.01F : discountPrice;
                            });
                            curGood.SpecDetail = JsonConvert.SerializeObject(detaillist);
                        }
                        curGood.Description = string.Empty;
                        c.GoodsInfo         = curGood;
                    }
                });

                returnObj.dataObj = new { carlist = carList, count = carList.Sum(s => s.Count) };
                returnObj.isok    = true;
                return(Json(returnObj));
            }
            catch (Exception ex)
            {
                returnObj.dataObj = ex;
                return(Json(returnObj));
            }
        }
示例#6
0
        /// <summary>
        /// 获取商品名称
        /// </summary>
        /// <param name="xcxtemplatetype">模板类型</param>
        /// <param name="goodstype">商品类型</param>
        /// <param name="goodsid">商品ID(拼团entgoods表ID,团购groups表ID,普通商品entgoods表ID,砍价bargain表ID)</param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public string GetGoodsName(int xcxtemplatetype, int goodstype, int goodsid, ref string msg)
        {
            string goodsname = "";

            switch (xcxtemplatetype)
            {
            case (int)TmpType.小程序专业模板:
                switch (goodstype)
                {
                case (int)EntGoodsType.团购商品:
                    Groups groups = GroupsBLL.SingleModel.GetModel(goodsid);
                    if (groups == null)
                    {
                        msg = "找不到商品数据";
                    }
                    else
                    {
                        goodsname = groups.GroupName;
                    }
                    break;

                case (int)EntGoodsType.拼团产品:
                    EntGoods entgroupgoods = EntGoodsBLL.SingleModel.GetModel(goodsid);
                    if (entgroupgoods == null)
                    {
                        msg = "找不到商品数据";
                    }
                    else
                    {
                        goodsname = entgroupgoods.name;
                    }
                    break;

                case (int)EntGoodsType.普通产品:
                    EntGoods entgoods = EntGoodsBLL.SingleModel.GetModel(goodsid);
                    if (entgoods == null)
                    {
                        msg = "找不到商品数据";
                    }
                    else
                    {
                        goodsname = entgoods.name;
                    }
                    break;

                case (int)EntGoodsType.价产品:
                    Bargain bargain = BargainBLL.SingleModel.GetModel(goodsid);
                    if (bargain == null)
                    {
                        msg = "找不到商品数据";
                    }
                    else
                    {
                        goodsname = bargain.BName;
                    }
                    break;
                }
                break;

            case (int)TmpType.小未平台子模版:
                PlatChildGoods platchildgoods = PlatChildGoodsBLL.SingleModel.GetModel(goodsid);
                if (platchildgoods == null)
                {
                    msg = "找不到商品数据";
                }
                else
                {
                    goodsname = platchildgoods.Name;
                }
                break;
            }

            return(goodsname);
        }