Esempio n. 1
0
        /// <summary>
        /// 浏览过的店铺(20个)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="appId"></param>
        /// <returns></returns>
        public List <AppIdNameIconDTO> GetBrowseAppInfoExt(Guid userId, Guid appId)
        {
            try
            {
                //获取浏览记录商品ID
                string sql = "select CommodityId from UserBrowseList where appid='" + appId + "' and UserId='" + userId + "' order by InsertDate desc";

                DataTable   UserBrowseList = Jinher.AMP.BTP.Common.SQLHelper.ExecuteDataset(SQLHelper.UserBrowse, CommandType.Text, sql, null).Tables[0];
                List <Guid> ids            = (from DataRow item in UserBrowseList.Rows select Guid.Parse(item["CommodityId"].ToString())).ToList();

                //获取app下的APP
                //Jinher.AMP.ZPH.ISV.Facade.AppPavilionFacade apppa=new AppPavilionFacade();
                //ReturnInfo<List<Jinher.AMP.ZPH.Deploy.CustomDTO.PavilionAppListCDTO>> list= apppa.GetPavilionApp(new Jinher.AMP.ZPH.Deploy.CustomDTO.QueryPavilionAppParam(){Id = appId,pageIndex = 1,pageSize =100,srcAppId = appId})
                //获取店铺ID
                var info = from comm in BE.Commodity.ObjectSet()
                           join id in ids on comm.Id equals id
                           where ids.Contains(comm.Id)
                           select comm.AppId;
                LogHelper.Info(string.Format("获取浏览过的店铺id:count:{0}", info.ToList().Count));
                //获取浏览过的店铺信息
                List <AppIdNameIconDTO> listapp = APPSV.GetAppListByIds(info.ToList()).Distinct().Take(20).ToList();
                LogHelper.Info(string.Format("获取浏览过的店铺信息:count:{0}", listapp.Count));
                return(listapp);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("AppSetSV.GetBrowseAppInfoExt异常:userId:{0},appId:{1}", userId, appId), ex);
                throw;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 根据用户ID查询收藏店铺数量
 /// <para>Service Url: http://devbtp.sv.iuoooo.com/Jinher.AMP.BTP.SV.SetCollectionSV.svc/GetCollectionAppsCount
 /// </para>
 /// </summary>
 /// <param name="search"></param>
 /// <returns></returns>
 public int GetCollectionAppsCountExt(Jinher.AMP.BTP.Deploy.CustomDTO.SetCollectionSearchDTO search)
 {
     if (search == null || search.UserId == Guid.Empty || search.ChannelId == Guid.Empty)
     {
         LogHelper.Debug(string.Format("SetCollectionSV.GetCollectionAppsCountExt,获取收藏店铺数量参数不全,search:{0},", JsonHelper.JsonSerializer(search)));
         return(0);
     }
     try
     {
         var appIds =
             SetCollection.ObjectSet()
             .Where(c => c.ColType == 2 && c.UserId == search.UserId && c.ChannelId == search.ChannelId).OrderByDescending(c => c.SubTime)
             .Select(c => c.ColKey)
             .ToList();
         if (appIds.Any())
         {
             var applist = APPSV.GetAppListByIds(appIds);
             if (applist != null && applist.Any())
             {
                 return(applist.Count);
             }
         }
         LogHelper.Debug(string.Format("SetCollectionSV.GetCollectionAppsCountExt,获取收藏店铺数量位未查到appids,search:{0},", JsonHelper.JsonSerializer(search)));
         return(0);
     }
     catch (Exception ex)
     {
         LogHelper.Error(string.Format("SetCollectionSV.GetCollectionAppsCountExt,获取收藏店铺数量异常,search:{0},", JsonHelper.JsonSerializer(search)), ex);
         return(0);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 查询商品 非电商馆
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public ResultDTO <List <ComdtyList4SelCDTO> > SearchCommodity2Ext(ComdtySearch4SelCDTO search)
        {
            string appName    = APPSV.GetAppName(search.AppId ?? Guid.Empty);
            var    comdtyList = from c in Commodity.ObjectSet()
                                where c.IsDel == false && c.State == 0 && c.AppId == search.AppId && c.CommodityType == 0
                                orderby c.Name
                                select new ComdtyList4SelCDTO
            {
                Id      = c.Id,
                Name    = c.Name,
                Pic     = c.PicturesPath,
                Price   = c.Price,
                AppId   = c.AppId,
                Stock   = c.Stock,
                AppName = appName
            };

            if (!string.IsNullOrEmpty(search.CommodityName))
            {
                comdtyList = comdtyList.Where(o => o.Name.Contains(search.CommodityName));
            }

            List <ComdtyList4SelCDTO> comdtyList4SelCdtos = new List <ComdtyList4SelCDTO>();

            foreach (var comdty in comdtyList)
            {
                //获取加入的分类名称
                var temp1 = (from scc in CommodityCategory.ObjectSet()
                             join sc in Category.ObjectSet() on scc.CategoryId equals sc.Id
                             where scc.CommodityId == comdty.Id && scc.IsDel == false && scc.AppId == comdty.AppId
                             orderby scc.MaxSort
                             select sc);
                var cnames = "";
                foreach (var category in temp1)
                {
                    cnames += category.Name + "<br>";
                }
                comdty.CommodityCategory = cnames;

                comdtyList4SelCdtos.Add(comdty);
            }

            ResultDTO <List <ComdtyList4SelCDTO> > retInfo = new ResultDTO <List <ComdtyList4SelCDTO> >
            {
                ResultCode = comdtyList4SelCdtos.Count(),
                Data       = comdtyList4SelCdtos.Skip((search.PageIndex - 1) * search.PageSize)
                             .Take(search.PageSize)
                             .ToList()
            };

            return(retInfo);
        }
Esempio n. 4
0
        /// <summary>
        /// 获取特定app下载所需数据
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        public ResultDTO <AppDownloadDTO> GetAppDownLoadInfoExt(Guid appId)
        {
            ResultDTO <AppDownloadDTO> result = new ResultDTO <AppDownloadDTO>()
            {
            };
            AppDownloadDTO data = new AppDownloadDTO();

            data.AppId = appId;
            data.Icon  = APPSV.GetAppIcon(appId);
            data.PromotionDownGuide = BACSV.GetPromotionDownGuide(appId);
            result.Data             = data;
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 判断商品是否填写备注编码(第三方电商商品skuid)
        /// </summary>
        /// <param name="commodityList"></param>
        /// <param name="commodityStockList"></param>
        /// <returns>未设置备注编码的商品名称集合</returns>
        public static List <string> CheckJDCodeExists(Guid appId, List <CommodityDTO> commodityList, List <BTP.Deploy.CommodityStockDTO> commodityStockList)
        {
            if (commodityList == null && commodityList.Count == 0)
            {
                return(new List <string>());
            }
            var type = GetAppThirdECommerceType(appId);

            if (!IsThirdECommerce(type))
            {
                return(new List <string>());
            }
            var commodityIdList = new List <Guid>();

            commodityList.ForEach(p =>
            {
                if (commodityStockList != null && commodityStockList.Count > 0 && commodityStockList.Any(x => x.CommodityId == p.Id))
                {
                    commodityIdList.AddRange(commodityStockList.Where(x => x.CommodityId == p.Id && string.IsNullOrEmpty(x.JDCode)).Select(x => x.CommodityId).ToList());
                }
                else
                {
                    if (string.IsNullOrEmpty(p.JDCode))
                    {
                        commodityIdList.Add(p.Id);
                    }
                }
            });
            if (commodityIdList.Count > 0)
            {
                var commodityNameList = new List <string>();
                if (IsWangYiYanXuan(appId))
                {
                    var appName = APPSV.GetAppName(appId);
                    commodityNameList = commodityList.Where(p => commodityIdList.Contains(p.Id)).Select(p => p.Name).ToList();
                    var commodityNames = string.Join("、", commodityNameList);
                    YXOrderHelper.SaveErrorLog(new YXOrderErrorLogDTO
                    {
                        Content        = string.Format("{0}App中{1}等商品的备注编码不存在,请尽快补充填写~", appName, commodityNames),
                        AppId          = appId,
                        OrderId        = Guid.Empty,
                        OrderCode      = string.Empty,
                        AppName        = appName,
                        CommodityNames = commodityNames,
                        Json           = string.Empty
                    });
                }
                return(commodityNameList);
            }
            return(new List <string>());
        }
Esempio n. 6
0
        /// <summary>
        /// 获取渠道默认佣金比例
        /// </summary>
        /// <param name="appId">AppId</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.AppExtensionDTO GetDefaulChannelAccountExt(Guid appId)
        {
            if (appId == Guid.Empty)
            {
                return(null);
            }
            var model = AppExtension.ObjectSet().Where(c => c.Id == appId).FirstOrDefault();

            if (model == null)
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                var            appName        = APPSV.GetAppName(appId);
                model                     = new AppExtension();
                model.Id                  = appId;
                model.AppName             = appName;
                model.SubTime             = DateTime.Now;
                model.ModifiedOn          = DateTime.Now;
                model.IsShowSearchMenu    = false;
                model.IsShowAddCart       = false;
                model.IsDividendAll       = null;
                model.SharePercent        = 0;
                model.DistributeL1Percent = null;
                model.DistributeL2Percent = null;
                model.DistributeL3Percent = null;
                model.IsCashForScore      = false;
                model.ChannelSharePercent = null;
                model.EntityState         = EntityState.Added;
                contextSession.SaveObject(model);
                contextSession.SaveChanges();
            }
            Jinher.AMP.BTP.Deploy.CustomDTO.AppExtensionDTO result = new Jinher.AMP.BTP.Deploy.CustomDTO.AppExtensionDTO()
            {
                Id                       = model.Id,
                AppName                  = model.AppName,
                SubTime                  = model.SubTime,
                ModifiedOn               = model.ModifiedOn,
                IsShowSearchMenu         = model.IsShowSearchMenu,
                IsShowAddCart            = model.IsShowAddCart,
                IsDividendAll            = model.IsDividendAll,
                SharePercent             = model.SharePercent,
                DistributeL1Percent      = model.DistributeL1Percent,
                DistributeL2Percent      = model.DistributeL2Percent,
                DistributeL3Percent      = model.DistributeL3Percent,
                IsCashForScore           = model.IsCashForScore,
                ChannelDistributePercent = model.ChannelSharePercent
            };
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 设置发票类型
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SetInvoiceCategoryExt(Jinher.AMP.BTP.Deploy.CustomDTO.AppExtensionDTO model)
        {
            if (model == null || model.Id == Guid.Empty)
            {
                return(new ResultDTO <AppExtensionDTO>()
                {
                    ResultCode = 1, Message = "参数不能为空"
                });
            }
            var            appExt         = AppExtension.ObjectSet().Where(t => t.Id == model.Id).FirstOrDefault();
            ContextSession contextSession = ContextFactory.CurrentThreadContext;

            if (appExt == null)
            {
                var appName = APPSV.GetAppName(model.Id);
                appExt                     = AppExtension.CreateAppExtension();
                appExt.Id                  = model.Id;
                appExt.AppName             = appName;
                appExt.SubTime             = DateTime.Now;
                appExt.ModifiedOn          = DateTime.Now;
                appExt.IsShowSearchMenu    = false;
                appExt.IsShowAddCart       = false;
                appExt.IsDividendAll       = null;
                appExt.SharePercent        = 0;
                appExt.DistributeL1Percent = null;
                appExt.DistributeL2Percent = null;
                appExt.DistributeL3Percent = null;
                appExt.IsCashForScore      = false;

                appExt.EntityState = System.Data.EntityState.Added;
                contextSession.SaveObject(appExt);
            }
            appExt.InvoiceDefault = model.InvoiceDefault;
            appExt.InvoiceValues  = model.InvoiceValues;
            appExt.ModifiedOn     = DateTime.Now;

            appExt.EntityState = EntityState.Modified;
            contextSession.SaveChanges();

            return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO()
            {
                ResultCode = 0, Message = "Success"
            });
        }
Esempio n. 8
0
        /// <summary>
        /// 根据用户ID查询收藏商品
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.AppSetAppDTO> GetCollectionAppsExt(SetCollectionSearchDTO search)
        {
            DateTime            now    = DateTime.Now;
            List <AppSetAppDTO> result = new List <AppSetAppDTO>();

            if (search == null || search.UserId == Guid.Empty || search.ChannelId == Guid.Empty || search.PageIndex < 1 || search.PageSize < 1)
            {
                return(result);
            }
            try
            {
                var appIds =
                    SetCollection.ObjectSet()
                    .Where(c => c.ColType == 2 && c.UserId == search.UserId && c.ChannelId == search.ChannelId).OrderByDescending(c => c.SubTime)
                    .Select(c => c.ColKey).Skip((search.PageIndex - 1) * search.PageSize)
                    .Take(search.PageSize)
                    .ToList();
                if (appIds.Any())
                {
                    var applist = APPSV.GetAppListByIds(appIds);
                    if (applist != null && applist.Any())
                    {
                        foreach (var appIdNameIconDTO in applist)
                        {
                            result.Add(new AppSetAppDTO
                            {
                                AppId       = appIdNameIconDTO.AppId,
                                AppIcon     = appIdNameIconDTO.AppIcon,
                                AppName     = appIdNameIconDTO.AppName,
                                AppCreateOn = appIdNameIconDTO.CreateDate > DateTime.MinValue ? appIdNameIconDTO.CreateDate : new DateTime(1970, 1, 1)
                            });
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("SetCollectionSV.GetCollectionAppsExt,获取收藏商品列表查询错误search:{0},", JsonHelper.JsonSerializer(search)), ex);
                return(new List <AppSetAppDTO>());
            }
        }
Esempio n. 9
0
        private string getQrCodeName(SpreadInfo spreadInfo)
        {
            string result = string.Empty;

            if (spreadInfo == null)
            {
                return(result);
            }
            List <Guid> appIds = new List <Guid>();

            if (spreadInfo.SpreadAppId != Guid.Empty)
            {
                appIds.Add(spreadInfo.SpreadAppId);
            }
            if (spreadInfo.HotshopId != Guid.Empty)
            {
                appIds.Add(spreadInfo.HotshopId);
            }
            var appDict = APPSV.GetAppNameListByIds(appIds);

            return(SpreadSV.Instance.BuildQrCodeName(spreadInfo, appDict));
        }
Esempio n. 10
0
        /// <summary>
        /// 查询一级代理指定APP的旺铺列表
        /// </summary>
        /// <param name="iwId">组织ID</param>
        /// <param name="appId">应用ID</param>
        /// <returns></returns>
        public ResultDTO <List <SpreadAppDTO> > GetLv1SpreadHotshopsExt(Guid iwId, Guid appId)
        {
            var data   = new List <SpreadAppDTO>();
            var appIds = SpreadInfo.ObjectSet().
                         Where(s => s.IsDel != 1 && s.SpreadType == 5 && s.IWId == iwId && s.SpreadAppId == appId).
                         Select(s => s.HotshopId).ToList();

            if (appIds.Count > 0)
            {
                var appDict = APPSV.GetAppNameListByIds(appIds);
                foreach (var item in appIds)
                {
                    data.Add(new SpreadAppDTO {
                        Id = item, Name = appDict.ContainsKey(item) ? appDict[item] : null
                    });
                }
            }
            return(new ResultDTO <List <SpreadAppDTO> >
            {
                isSuccess = true,
                Message = "success",
                Data = data
            });
        }
Esempio n. 11
0
        /// <summary>
        /// 添加众筹
        /// </summary>
        /// <param name="crowdfundingDTO">众筹实体</param>
        public ResultDTO AddCrowdfundingExt(Jinher.AMP.BTP.Deploy.CrowdfundingDTO crowdfundingDTO)
        {
            if (crowdfundingDTO == null)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "入参不能为空"
                }
            }
            ;
            if (crowdfundingDTO.AppId == Guid.Empty)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "请正确填写应用"
                }
            }
            ;

            var dividendPercent = crowdfundingDTO.DividendPercent * crowdfundingDTO.ShareCount;

            if (dividendPercent > CustomConfig.CrowdfundingConfig.MaxDividend)
            {
                return new ResultDTO {
                           ResultCode = 2, Message = "您的订单成交额已不足抵扣分红,请重新设置!"
                }
            }
            ;

            if (crowdfundingDTO.StartTime < DateTime.Now)
            {
                return(new ResultDTO {
                    ResultCode = 2, Message = "众筹开始时间必须大于当前时间!"
                });
            }

            string message = "Success";

            try
            {
                var tmp = Crowdfunding.ObjectSet().FirstOrDefault(c => c.AppId == crowdfundingDTO.AppId);
                if (tmp != null)
                {
                    return new ResultDTO {
                               ResultCode = 3, Message = "该应用已经参加众筹活动,不能重复添加"
                    }
                }
                ;

                Dictionary <Guid, string> list = APPSV.GetAppNameListByIds(new List <Guid> {
                    crowdfundingDTO.AppId
                });

                if (list == null || !list.Any() || !list.ContainsKey(crowdfundingDTO.AppId) || list[crowdfundingDTO.AppId] != crowdfundingDTO.AppName.Trim())
                {
                    return new ResultDTO {
                               ResultCode = 2, Message = "应用Id与名称不符"
                    }
                }
                ;

                ContextSession contextSession = ContextFactory.CurrentThreadContext;

                //保存众筹
                Crowdfunding entity = Crowdfunding.CreateCrowdfunding();
                entity.AppName         = crowdfundingDTO.AppName;
                entity.AppId           = crowdfundingDTO.AppId;
                entity.PerShareMoney   = crowdfundingDTO.PerShareMoney;
                entity.DividendPercent = crowdfundingDTO.DividendPercent;
                entity.ShareCount      = crowdfundingDTO.ShareCount;
                entity.StartTime       = crowdfundingDTO.StartTime;
                entity.State           = 0;
                entity.Slogan          = crowdfundingDTO.Slogan;
                entity.Description     = crowdfundingDTO.Description;
                contextSession.SaveObject(entity);

                //保存众筹计数表
                CrowdfundingCount cnt = CrowdfundingCount.CreateCrowdfundingCount();
                cnt.AppId          = entity.AppId;
                cnt.CrowdfundingId = entity.Id;
                cnt.ShareCount     = entity.ShareCount;
                contextSession.SaveObject(cnt);

                contextSession.SaveChanges();
                if (dividendPercent > CustomConfig.CrowdfundingConfig.WarnDividend)
                {
                    message = string.Format("您的分红支出已超{0:P0},请注意收支平衡!", CustomConfig.CrowdfundingConfig.WarnDividend);
                }

                CrowdfundingMessageDTO Message = new CrowdfundingMessageDTO();
                Message.Now       = DateTime.Now;
                Message.StartTime = entity.StartTime;
                Message.State     = -1;
                AddMessage addMessage = new AddMessage();
                addMessage.SendMessage(entity.Id, entity.AppId, entity.StartTime, Message);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("添加众筹服务异常。crowdfundingDTO:{0}", crowdfundingDTO), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
            return(new ResultDTO {
                ResultCode = 0, Message = message
            });
        }
Esempio n. 12
0
        /// <summary>
        /// 担保交易(金币)支付,生成结算单
        /// </summary>
        public static SettleAccounts CreateSettleAccount(ContextSession contextSession, CommodityOrder commodityOrder, MallApply mall)
        {
            if (!CheckPayType(commodityOrder))
            {
                return(null);
            }
            if (mall == null)
            {
                LogHelper.Info("生成结算项失败,商城中未找到该APP,订单ID:" + commodityOrder.Id);
                return(null);
            }
            var sad = CreateSettleAccountDetails(contextSession, commodityOrder, mall);

            if (sad == null)
            {
                return(null);
            }
            LogHelper.Info("担保交易(金币)支付,生成结算单,OrderId:" + commodityOrder.Id);
            // 结算单
            SettleAccounts sa = new SettleAccounts();

            sad.SAId      = sa.Id = Guid.NewGuid();
            sa.UserId     = Guid.Empty; // 系统生成结算单,UserId为空
            sa.AmountDate = sa.ModifiedOn = sa.SubTime = DateTime.Now;
            sa.AppId      = commodityOrder.AppId;
            sa.AppName    = APPSV.GetAppName(sa.AppId);
            sa.EsAppId    = commodityOrder.EsAppId.Value;
            sa.SellerType = mall.Type;
            var pInfo = ZPHSV.Instance.GetAppPavilionInfo(new Jinher.AMP.ZPH.Deploy.CustomDTO.QueryAppPavilionParam {
                id = sa.EsAppId
            });

            if (string.IsNullOrEmpty(pInfo.pavilionName))
            {
                sa.EsAppName = "未找到";
                LogHelper.Error("OrderSV.CreateSettleAccount 生成结算单异常:未能从 ZPHSV.Instance.GetAppPavilionInfo 获取到场管名称。OrderId:" + commodityOrder.Id);
            }
            sa.EsAppName                 = pInfo.pavilionName;
            sa.OrderAmount               = sad.OrderAmount;
            sa.OrderRealAmount           = sad.OrderRealAmount;
            sa.CouponAmount              = sad.OrderCouponAmount;
            sa.RefundAmount              = sad.OrderRefundAmount;
            sa.PromotionCommissionAmount = sad.OrderPromotionCommissionAmount;
            sa.PromotionAmount           = sad.PromotionAmount;
            sa.SellerAmount              = sad.SellerAmount;
            sa.OrderYJBAmount            = sad.OrderYJBAmount;
            sa.IsAmount     = true;
            sa.SettleStatue = true;
            Random rd = new Random();

            sa.Code = DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(9999).ToString("D4");
            if (sad.IsMallCoupon)
            {
                // 当商城佣金小于商城优惠券金额时,则商城不分佣金,表示当前订单结算异常,结算结果为:结算异常;
                if (sad.PromotionAmount < sad.OrderCouponAmount)
                {
                    sa.PromotionAmount = 0;
                    sa.SellerAmount   += sa.PromotionAmount;
                    sa.SettleStatue    = false;
                }
            }
            else
            {
                // 当商家的结算金额小于0时,则先结算推广佣金,而后结算商城佣金,表示当前订单结算异常,结算结果为:结算异常;
                if (sa.SellerAmount < 0)
                {
                    sa.SettleStatue = false;
                }
            }
            sa.State = new Deploy.SettleAccountsVO()
            {
                Value = 3
            };
            sa.EntityState = EntityState.Added;
            sad.IsSettled  = true;
            sad.SAId       = sa.Id;

            contextSession.SaveObject(sa);
            return(sa);
        }
Esempio n. 13
0
        /// <summary>
        /// 我的拼团订单列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupOrderListDTO> GetDiyGroupListExt(Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupSearchDTO search)
        {
            List <Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupOrderListDTO> resultlist = new List <DiyGroupOrderListDTO>();

            if (search == null)
            {
                return(resultlist);
            }
            search.PageIndex = search.PageIndex == 0 ? 1 : search.PageIndex;
            search.PageSize  = search.PageSize == 0 ? 20 : search.PageSize;

            var diyList = (from diy in DiyGroup.ObjectSet()
                           join pro in PromotionItems.ObjectSet() on diy.PromotionId equals pro.PromotionId
                           join p in Promotion.ObjectSet() on pro.PromotionId equals p.Id
                           join diyo in DiyGroupOrder.ObjectSet() on diy.Id equals diyo.DiyGroupId
                           join com in CommodityOrder.ObjectSet() on diyo.OrderId equals com.Id
                           where diy.EsAppId == search.EsAppId && com.UserId == search.UserId && diyo.State == 1 && diy.State != 0
                           orderby diyo.SubTime descending
                           select new DiyGroupOrderListDTO
            {
                Price = com.RealPrice,
                DiyGroupPrice = pro.DiscountPrice,
                SubTime = diyo.SubTime,
                DiyGroupState = diy.State,
                GroupMinVolume = p.GroupMinVolume ?? -1,
                JoinNumber = diy.JoinNumber,
                DiyGroupId = diy.Id,
                EsAppId = diy.EsAppId,
                OrderId = diyo.OrderId,
                DiyOrderSubTime = diyo.SubTime,
                ModifiedOn = diyo.ModifiedOn,
                EndTime = p.EndTime
            }).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();

            var diyorderIds = diyList.Select(n => n.OrderId).ToList();

            if (diyList.Any())
            {
                var diyorderList = (from ord in OrderItem.ObjectSet()
                                    where diyorderIds.Contains(ord.CommodityOrderId)
                                    select new DiyGroupManageMM
                {
                    Pic = ord.PicturesPath,
                    Name = ord.Name,
                    DiyNumber = ord.Number,
                    DiyGroupOrderId = ord.CommodityOrderId,
                    attributes = ord.CommodityAttributes
                }).ToList();
                Dictionary <Guid, List <DiyGroupManageMM> > csdtoList = diyorderList.GroupBy(c => c.DiyGroupOrderId, (key, group) =>
                                                                                             new { DiyGroupOrderId = key, CommodityList = group })
                                                                        .ToDictionary(c => c.DiyGroupOrderId, c => c.CommodityList.ToList());
                var listAppIds = (from co in diyList select co.EsAppId).Distinct().ToList();
                Dictionary <Guid, string> dictAppName = APPSV.GetAppNameListByIds(listAppIds);

                foreach (var diyGroupOrder in diyList)
                {
                    if (csdtoList.ContainsKey(diyGroupOrder.OrderId))
                    {
                        var commodityDtoList = csdtoList[diyGroupOrder.OrderId];
                        diyGroupOrder.OrderDataList = commodityDtoList;
                    }
                    if (dictAppName != null && dictAppName.Count > 0 && dictAppName.ContainsKey(diyGroupOrder.EsAppId))
                    {
                        var appNameDto = dictAppName[diyGroupOrder.EsAppId];
                        diyGroupOrder.AppName = appNameDto;
                    }
                    resultlist.Add(diyGroupOrder);
                }
            }
            return(resultlist);
        }
Esempio n. 14
0
        /// <summary>
        /// 保存一个京东订单
        /// </summary>
        /// <param name="item">一个订单</param>
        /// <param name="comList">订单项对应的商品</param>
        private ResultDTO SaveOneJdOrder(OrderSDTO item, List <Commodity> comList)
        {
            ResultDTO <List <CommoditySummaryDTO> > result = new ResultDTO <List <CommoditySummaryDTO> >();

            if (item == null)
            {
                result.ResultCode = (int)ReturnCodeEnum.ParamEmpty;
                result.Message    = ReturnCodeEnum.ParamEmpty.GetDescription();
                return(result);
            }
            if (item.ShoppingCartItemSDTO == null || !item.ShoppingCartItemSDTO.Any() ||
                comList == null || !comList.Any())
            {
                result.ResultCode = (int)ReturnCodeEnum.ParamEmpty;
                result.Message    = ReturnCodeEnum.ParamEmpty.GetDescription();
                return(result);
            }
            //易捷北京所有的AppId
            string Appids = CustomConfig.AppIds;

            LogHelper.Info(string.Format("Appids{0}", Appids));
            List <string> Appidlist = null;

            if (!string.IsNullOrEmpty(Appids))
            {
                Appidlist = Appids.Split(new char[] { ',' }).ToList();
            }

            if (!Appidlist.Contains(comList[0].AppId.ToString().ToUpper()))
            {
                //todo 返回非京东app.
                result.ResultCode = (int)ReturnCodeEnum.NotJdShop;
                result.Message    = ReturnCodeEnum.NotJdShop.GetDescription();
                return(result);
            }
            LogHelper.Info(string.Format("Appidlist的数量{0}", Appidlist.Count()));

            string orderPriceSnap = null;
            string sku            = null;

            //订单项里的商品都是同一店铺的,店铺名称相同。
            string appName = APPSV.GetAppName(comList[0].AppId);

            List <CommoditySummaryDTO> errorCommodities = new List <CommoditySummaryDTO>();

            orderPriceSnap = null;
            sku            = null;

            ContextSession contextSession = ContextFactory.CurrentThreadContext;

            var scis = item.ShoppingCartItemSDTO;

            foreach (var _item in scis)
            {
                Commodity commodity = comList.FirstOrDefault(_ => _.Id == _item.Id);

                LogHelper.Info(string.Format("京东日志:商品Id:{0},JDCode:{1},AppId:{2}", commodity.Id, commodity.JDCode, commodity.AppId));

                //京东店铺的商品没有JDCode,返回错误。
                if (string.IsNullOrWhiteSpace(commodity.JDCode))
                {
                    #region

                    Jdlogs model = new Jdlogs();
                    model.Id         = Guid.NewGuid();
                    model.Content    = (appName + "App中" + commodity.Name + "商品的备注编码不存在,请尽快补充填写~");
                    model.Remark     = string.Empty;
                    model.AppId      = commodity.AppId;
                    model.ModifiedOn = DateTime.Now;
                    model.SubTime    = DateTime.Now;
                    model.Isdisable  = false;

                    model.EntityState = EntityState.Added;
                    contextSession.SaveObject(model);


                    bool falg = EmailHelper.SendEmail("京东错误日志", model.Content, "*****@*****.**");

                    var errorCommodity = new CommoditySummaryDTO();
                    errorCommodity.Id             = commodity.Id;
                    errorCommodity.Name           = commodity.Name;
                    errorCommodity.PicturesPath   = commodity.PicturesPath;
                    errorCommodity.Price          = _item.Price;
                    errorCommodity.Sku            = _item.SizeAndColorId;
                    errorCommodity.ShopCartItemId = _item.ShopCartItemId;
                    errorCommodities.Add(errorCommodity);

                    result.ResultCode = (int)ReturnCodeEnum.CommoditySold;
                    result.Message    = ReturnCodeEnum.CommoditySold.GetDescription();
                    result.Data       = errorCommodities;
                    return(result);

                    #endregion
                }

                orderPriceSnap += "{'price':" + commodity.CostPrice + ",'skuId':" + commodity.JDCode + "},";
                sku            += "{'skuId':" + commodity.JDCode + ", 'num':" + _item.CommodityNumber + ",'bNeedAnnex':true, 'bNeedGift':false},";
                LogHelper.Info(string.Format("京东日志2:{0}:{1}", orderPriceSnap, sku));
            }

            LogHelper.Info(string.Format("京东日志3:{0}:{1}", orderPriceSnap, sku));
            if (string.IsNullOrEmpty(orderPriceSnap) || string.IsNullOrEmpty(sku))
            {
                //没有商品要去京东下单。
                result.ResultCode = (int)ReturnCodeEnum.NoCommodityNeedJdOrder;
                result.Message    = ReturnCodeEnum.NoCommodityNeedJdOrder.GetDescription();
                return(result);
            }

            orderPriceSnap = orderPriceSnap.Remove(orderPriceSnap.Length - 1, 1);
            sku            = sku.Remove(sku.Length - 1, 1);
            orderPriceSnap = "[" + orderPriceSnap + "]";
            sku            = "[" + sku + "]";
            string thirdOrder = Guid.NewGuid().ToString();
            if (string.IsNullOrEmpty(item.StreetCode))
            {
                item.StreetCode = "0";
            }
            //获取京东编号
            ResultDTO jdResult = JdHelper.GetJDOrderNew(thirdOrder, orderPriceSnap, sku, item.ReceiptUserName, item.ReceiptAddress, item.ReceiptPhone, "*****@*****.**", item.ProvinceCode, item.CityCode, item.DistrictCode, item.StreetCode);
            LogHelper.Info(string.Format("京东日志4:{0}:{1}", orderPriceSnap, sku));

            //正常下单,保存订单项关系。
            if (jdResult.ResultCode == 0)
            {
                #region 京东下单情况

                JdOrderItem jdorderitemdto = new JdOrderItem()
                {
                    Id = Guid.NewGuid(),
                    //todo jdporderId????
                    //JdPorderId = jdporderId,
                    TempId           = Guid.Parse(thirdOrder),
                    JdOrderId        = Guid.Empty.ToString(),
                    MainOrderId      = Guid.Empty.ToString(),
                    CommodityOrderId = Guid.Empty.ToString(),
                    State            = Convert.ToInt32(JdEnum.YZ),
                    StateContent     = new EnumHelper().GetDescription(JdEnum.YZ),
                    SubTime          = DateTime.Now,
                    ModifiedOn       = DateTime.Now
                };

                //todo SaveJdOrderItem(jdorderitemdto);

                JdJournal jdjournaldto = new JdJournal()
                {
                    Id = Guid.NewGuid(),
                    //todo jdporderId
                    //JdPorderId = jdporderId,
                    TempId           = Guid.Parse(thirdOrder),
                    JdOrderId        = Guid.Empty.ToString(),
                    MainOrderId      = Guid.Empty.ToString(),
                    CommodityOrderId = Guid.Empty.ToString(),
                    Name             = "京东统一下单接口",
                    Details          = "初始状态为" + Convert.ToInt32(JdEnum.YZ),
                    SubTime          = DateTime.Now
                };

                //todo SaveJdJournal(jdjournaldto);

                #endregion
            }
            else
            {
                #region 记录京东日志

                int    resultCode = jdResult.ResultCode;
                string jdlog      = jdResult.Message;
                if (resultCode == 3017) //账户异常情况特殊
                {
                    #region

                    EmailHelper.SendEmail("京东错误日志", "您的京东账户余额不足,请充值!", "*****@*****.**");

                    Jinher.AMP.BTP.Deploy.JdlogsDTO model = new Jinher.AMP.BTP.Deploy.JdlogsDTO();
                    model.Id         = Guid.NewGuid();
                    model.Content    = "您的京东账户余额不足,请充值!";
                    model.Remark     = string.Empty;
                    model.AppId      = Guid.Empty;
                    model.ModifiedOn = DateTime.Now;
                    model.SubTime    = DateTime.Now;
                    model.Isdisable  = false;
                    //SaveJdlogs(model);

                    foreach (var itemlog in scis)
                    {
                        var errorCommodity = new CommoditySummaryDTO();
                        errorCommodity.Id             = itemlog.Id;
                        errorCommodity.Name           = itemlog.Name;
                        errorCommodity.PicturesPath   = itemlog.Pic;
                        errorCommodity.Price          = itemlog.Price;
                        errorCommodity.Sku            = itemlog.SizeAndColorId;
                        errorCommodity.ShopCartItemId = itemlog.ShopCartItemId;
                        errorCommodities.Add(errorCommodity);
                    }

                    #endregion
                }
                else
                {
                    #region

                    if (!string.IsNullOrEmpty(jdResult.Message))
                    {
                        string num     = null;
                        var    matches = Regex.Matches(jdResult.Message, @"(\d+)");
                        int    count   = 0;
                        foreach (Match match in matches)
                        {
                            if (count == 0)
                            {
                                num = match.Value;
                            }
                            count++;
                        }
                        foreach (var itemlog in scis)
                        {
                            Commodity commodity = comList.FirstOrDefault(_ => _.Id == itemlog.Id);
                            if (commodity.JDCode != num.ToString())
                            {
                                continue;
                            }

                            var errorCommodity = new CommoditySummaryDTO();
                            errorCommodity.Id             = commodity.Id;
                            errorCommodity.Name           = commodity.Name;
                            errorCommodity.PicturesPath   = commodity.PicturesPath;
                            errorCommodity.Price          = itemlog.Price;
                            errorCommodity.Sku            = itemlog.SizeAndColorId;
                            errorCommodity.ShopCartItemId = itemlog.ShopCartItemId;
                            errorCommodities.Add(errorCommodity);

                            string content = null;
                            content += (APPSV.GetAppName(commodity.AppId) + "App中" + itemlog.Name) + "商品[" + commodity.JDCode + "]";
                            if (resultCode == 2004)
                            {
                                content += "京东商品池中不存在";
                            }
                            else if (resultCode == 3019)
                            {
                                string str = jdlog;
                                if (!string.IsNullOrEmpty(str))
                                {
                                    content += "价格错误,";
                                    int      num1       = str.IndexOf('[');
                                    int      num2       = str.IndexOf(']');
                                    string   strjdprice = str.Substring(num1 + 1, (num2 - num1 - 1));
                                    string[] arr        = strjdprice.Split(new char[] { '=' });
                                    content += "京东价" + arr[1] + "元," + "易捷价" + commodity.CostPrice + "元";
                                }
                            }
                            else if (resultCode == 3008)
                            {
                                content += "已售馨";
                            }
                            else
                            {
                                content += "异常信息:" + jdlog;
                            }

                            EmailHelper.SendEmail("京东错误日志", content, "*****@*****.**");

                            Jinher.AMP.BTP.Deploy.JdlogsDTO model = new Jinher.AMP.BTP.Deploy.JdlogsDTO();
                            model.Id         = Guid.NewGuid();
                            model.Content    = content;
                            model.Remark     = string.Empty;
                            model.AppId      = itemlog.AppId;
                            model.ModifiedOn = DateTime.Now;
                            model.SubTime    = DateTime.Now;
                            model.Isdisable  = false;
                            //SaveJdlogs(model);
                        }
                    }

                    #endregion
                }

                #endregion

                #region 获取京东订单单号失败的情况

                //////京东确认取消订单
                ////bool flag = JdHelper.OrderCancel(jdorderid.JdporderId);
                ////if (flag == true)
                ////{
                ////    List<string> jdorder = new List<string>();
                ////    jdorder.Add(jdorderid.JdporderId);
                ////    //删除京东对应订单
                ////    var res = jdorderitemfacade.DeleteJdOrderItem(jdorder);
                ////    if (res.isSuccess == true)
                ////    {
                ////        JdJournal jdjournaldto = new JdJournal()
                ////        {
                ////            Id = Guid.NewGuid(),
                ////            JdPorderId = jdporderId,
                ////            TempId = Guid.Parse(thirdOrder),
                ////            JdOrderId = Guid.Empty.ToString(),
                ////            MainOrderId = Guid.Empty.ToString(),
                ////            CommodityOrderId = Guid.Empty.ToString(),
                ////            Name = "京东确认取消订单",
                ////            Details = "删除JdOrderItem表中相应的内容",
                ////            SubTime = DateTime.Now
                ////        };
                ////        //SaveJdJournal(jdjournaldto);
                ////    }
                ////}


                #endregion

                //LogHelper.Error("商品已售馨,请选择其他商品,Jdlogs:" + jdlog + " resultCode:" + resultCode);
                //return Json(new OrderResultDTO { ResultCode = 2, Message = "商品已售馨,请选择其他商品", ErrorCommodities = errorCommodities }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
Esempio n. 15
0
        /// <summary>
        /// 获取商品信息变更信息
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> GetCommodityChangeList(Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO Search)
        {
            try
            {
                var query = CommodityChange.ObjectSet().Where(p => Search.Appids.Contains(p.AppId)).AsQueryable();
                #region  查询条件
                //根据供应商
                if (Search.AppidsList.Count > 0)
                {
                    query = query.Where(p => Search.AppidsList.Contains(p.AppId));
                }
                //商铺名称
                if (Search.AppId != Guid.Empty)
                {
                    query = query.Where(p => p.AppId == Search.AppId);
                }
                //商品名称
                if (!string.IsNullOrEmpty(Search.Name))
                {
                    query = query.Where(p => Search.Name.Contains(p.Name) || p.Name.Contains(Search.Name));
                }
                //备注编码
                if (!string.IsNullOrEmpty(Search.JDCode))
                {
                    query = query.Where(p => p.JDCode == Search.JDCode);
                }
                //商品条形码
                if (!string.IsNullOrEmpty(Search.Barcode))
                {
                    query = query.Where(p => p.Barcode == Search.Barcode);
                }
                //发布人
                if (Search.SubId != Guid.Empty)
                {
                    query = query.Where(p => p.SubId == Search.SubId);
                }
                if (!string.IsNullOrEmpty(Search.SubStarTime))
                {
                    var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    StartTime = DateTime.Parse(Search.SubStarTime);
                    query     = query.Where(p => p.SubOn >= StartTime);
                }
                if (!string.IsNullOrEmpty(Search.SubEndTime))
                {
                    var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    EndTime = DateTime.Parse(Search.SubEndTime).AddDays(1);
                    query   = query.Where(p => p.SubOn <= EndTime);
                }
                if (Search.ModifiedId != Guid.Empty)
                {
                    query = query.Where(p => p.ModifiedId == Search.ModifiedId);
                }
                if (!string.IsNullOrEmpty(Search.ModStarTime))
                {
                    var StartTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    StartTime = DateTime.Parse(Search.ModStarTime);
                    query     = query.Where(p => p.ModifiedOn >= StartTime);
                }
                if (!string.IsNullOrEmpty(Search.ModEndTime))
                {
                    var EndTime = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
                    EndTime = DateTime.Parse(Search.ModEndTime).AddDays(1);
                    query   = query.Where(p => p.ModifiedOn <= EndTime);
                }
                if (Search.State != -1)
                {
                    if (Search.State == 3)
                    {   //已删除的数据
                        query = query.Where(p => p.IsDel == true);
                    }
                    else
                    {
                        query = query.Where(p => p.State == Search.State && p.IsDel == false);
                    }
                }
                #endregion
                List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO> result = (from n in query
                                                                                    select new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityChangeDTO
                {
                    Id = n.Id,
                    CommodityId = n.CommodityId,
                    AppId = n.AppId,
                    Barcode = n.Barcode,
                    Type = n.Type,
                    YJCouponActivityId = n.YJCouponActivityId,
                    YJCouponType = n.YJCouponType,
                    No_Code = n.No_Code,
                    JDCode = n.JDCode,                                                                        //备注编码
                    Name = n.Name,
                    MarketPrice = n.MarketPrice,
                    Price = n.Price,
                    CostPrice = n.CostPrice,
                    TaxClassCode = n.TaxClassCode,
                    InputRax = n.InputRax,
                    TaxRate = n.TaxRate,
                    ComAttribute = n.ComAttribute,
                    Unit = n.Unit,
                    SubId = n.SubId,
                    SubOn = n.SubOn,
                    ModifiedId = n.ModifiedId,
                    ModifiedOn = n.ModifiedOn,
                    State = n.State,
                    IsDel = n.IsDel
                }).OrderByDescending(p => p.ModifiedOn).ToList();
                if (result.Count() > 0)
                {
                    if (result.Count() > 0)
                    {
                        //获取商铺名称
                        List <Guid> appIds = (from it in result select it.AppId).Distinct().ToList();
                        Dictionary <Guid, string> listApps = APPSV.GetAppNameListByIds(appIds); //获取商铺名称

                        //获取供应商名称
                        var SupplierList = Supplier.ObjectSet().Where(p => appIds.Contains(p.AppId)).Select(s => new { s.AppId, s.SupplierName }).Distinct().ToList();

                        //获取提交人名称
                        List <Guid> SubId    = (from n in query where n.SubId != null select n.SubId).Distinct().ToList();
                        List <Guid> ModId    = (from n in query where n.ModifiedId != null select n.ModifiedId).Distinct().ToList();
                        List <Guid> userid   = SubId.Union(ModId).Distinct().ToList();
                        var         Userinfo = CBCSV.GetUserNameAndCodes(userid);

                        foreach (var item in result)
                        {
                            //获取提交人名称
                            var NameAndCodes = Userinfo[item.SubId];
                            item.SubName = NameAndCodes.Item1;
                            item.SubCode = NameAndCodes.Item2;
                            //获取供应商名称
                            var SupplierName = SupplierList.Where(p => p.AppId == item.AppId).Select(s => s.SupplierName).FirstOrDefault();
                            if (!string.IsNullOrEmpty(SupplierName))
                            {
                                item.SupplierName = SupplierName;
                            }
                            //获取商铺名称
                            if (listApps.ContainsKey(item.AppId))
                            {
                                var listAppName = listApps[item.AppId];
                                if (!String.IsNullOrEmpty(listAppName))
                                {
                                    item.AppName = listAppName;
                                }
                            }
                            //获取修改人名称
                            if (item.ModifiedId != new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9") && item.ModifiedId != null)
                            {
                                Guid MId = item.ModifiedId ?? new Guid("00000000-0000-0000-0000-000000000000");
                                NameAndCodes      = Userinfo[MId];
                                item.ModifiedName = NameAndCodes.Item1;
                                item.ModifiedCode = NameAndCodes.Item2;
                            }
                            else if (item.ModifiedId == new Guid("72EF9DC4-2615-4649-92A9-9A4C71D1AFF9"))
                            {
                                item.ModifiedName = "系统自动";
                                item.ModifiedCode = "京东同步";
                            }
                            else
                            {
                                item.ModifiedName = "";
                                item.ModifiedCode = "";
                            }
                            //格式化状态
                            if (!item.IsDel)
                            {
                                if (item.State == 0)
                                {
                                    item.StateName = "在售中";
                                }
                                else
                                {
                                    item.StateName = "已下架";
                                }
                            }
                            else
                            {
                                item.StateName = "已删除";
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Jinher.JAP.Common.Loging.LogHelper.Error(string.Format("根据搜索条件获取变动商品表异常。"), ex);
                return(null);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 获取商品列表(平台获取平台商品、店铺获取店铺商品)
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO GetCommodityListV2Ext(CommodityListSearchDTO search)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO comdtyListResultCDTO = new Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO();
            try
            {
                if (search == null || search.PageSize <= 0 || search.PageIndex <= 0)
                {
                    comdtyListResultCDTO.isSuccess   = false;
                    comdtyListResultCDTO.Code        = 1;
                    comdtyListResultCDTO.Message     = "参数不能为空";
                    comdtyListResultCDTO.realCount   = 0;
                    comdtyListResultCDTO.comdtyList  = null;
                    comdtyListResultCDTO.appInfoList = null;
                    return(comdtyListResultCDTO);
                }
                if (!search.AppId.HasValue || search.AppId == Guid.Empty)
                {
                    comdtyListResultCDTO.isSuccess   = false;
                    comdtyListResultCDTO.Code        = 1;
                    comdtyListResultCDTO.Message     = "参数不能为空";
                    comdtyListResultCDTO.realCount   = 0;
                    comdtyListResultCDTO.comdtyList  = null;
                    comdtyListResultCDTO.appInfoList = null;
                    return(comdtyListResultCDTO);
                }

                DateTime now = DateTime.Now;

                var appId = search.AppId.Value;

                IQueryable <Commodity> ocommodityList;
                //用于存储临加入真实价格后的Commodity信息
                IQueryable <TempCommodity> tempOcommodityList;
                //根据是否平台区分
                bool isPavilion = Jinher.AMP.BTP.TPS.ZPHSV.Instance.IsAppPavilion(search.AppId.Value);
                if (isPavilion)
                {
                    tempOcommodityList = (from cs in CommodityCategory.ObjectSet()
                                          join cate in Category.ObjectSet() on cs.CategoryId equals cate.Id
                                          join c in Commodity.ObjectSet() on cs.CommodityId equals c.Id
                                          join pro in
                                          (
                                              from query in TodayPromotion.ObjectSet()
                                              where
                                              (query.PromotionType != 3 &&
                                               (query.StartTime <= now || query.PresellStartTime <= now) &&
                                               query.EndTime > now)
                                              select query
                                          ) on c.Id equals pro.CommodityId
                                          into todayPros
                                          from promotion in todayPros.DefaultIfEmpty()
                                          where cs.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0 && !cate.IsDel
                                          orderby c.Salesvolume descending, c.SubTime descending
                                          select new TempCommodity
                    {
                        Com = c,
                        newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10)
                    });
                }
                else
                {
                    tempOcommodityList = (from c in Commodity.ObjectSet()
                                          join pro in
                                          (
                                              from query in TodayPromotion.ObjectSet()
                                              where (query.PromotionType != 3 && (query.StartTime <= now || query.PresellStartTime <= now) && query.EndTime > now)
                                              select query
                                          ) on c.Id equals pro.CommodityId
                                          into todayPros
                                          from promotion in todayPros.DefaultIfEmpty()

                                          where c.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0
                                          select new TempCommodity
                    {
                        Com = c,
                        newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10)
                    });
                }

                if (search.MinPrice.HasValue && search.MinPrice != 0)
                {
                    tempOcommodityList = tempOcommodityList.Where(c => c.newPrice >= search.MinPrice);
                }
                if (search.MaxPrice.HasValue && search.MaxPrice != 0)
                {
                    tempOcommodityList = tempOcommodityList.Where(c => c.newPrice <= search.MaxPrice);
                }

                ocommodityList = tempOcommodityList.Select(c => c.Com).Distinct();


                if (search.IsHasStock)
                {
                    ocommodityList = ocommodityList.Where(c => c.Stock > 0);
                }

                if (!ProvinceCityHelper.IsTheWholeCountry(search.areaCode))
                {
                    var province = ProvinceCityHelper.GetProvinceByAreaCode(search.areaCode);
                    var city     = ProvinceCityHelper.GetCityByAreaCode(search.areaCode);
                    if (province != null && city != null)
                    {
                        if (province.AreaCode == city.AreaCode)
                        {
                            ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode));
                        }
                        else
                        {
                            ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode) || c.SaleAreas.Contains(city.AreaCode));
                        }
                    }
                }
                var commoditiesQuery         = from c in ocommodityList select c;
                List <Commodity> commodities = null;
                List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO> commodityList = null;

                comdtyListResultCDTO.realCount = commoditiesQuery.Count();
                if (isPavilion)
                {
                    commodities = (from c in commoditiesQuery
                                   orderby c.Salesvolume descending, c.SubTime descending
                                   select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();
                }
                else
                {
                    commodities = (from c in commoditiesQuery
                                   orderby c.SortValue
                                   select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();
                }

                //commodities = commoditiesQuery.Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();


                if (!commodities.Any())
                {
                    return(comdtyListResultCDTO);
                }

                commodityList = commodities.Select(c => new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO
                {
                    Id               = c.Id,
                    Pic              = c.PicturesPath,
                    Price            = c.Price,
                    State            = c.State,
                    Stock            = c.Stock,
                    Name             = c.Name,
                    MarketPrice      = c.MarketPrice,
                    AppId            = c.AppId,
                    IsEnableSelfTake = c.IsEnableSelfTake,
                    ComAttribute     = c.ComAttribute,
                    ComAttrType      = (c.ComAttribute == "[]" || c.ComAttribute == null) ? 1 : 3
                }).ToList();

                var appList = commodities.Select(c => c.AppId).Distinct().ToList();

                #region 众筹
                if (CustomConfig.CrowdfundingFlag)
                {
                    var crowdFundingApps = Crowdfunding.ObjectSet().Where(c => c.StartTime < now && c.State == 0 && appList.Contains(c.AppId)).Select(c => c.AppId).ToList();
                    if (crowdFundingApps.Any())
                    {
                        for (int i = 0; i < commodityList.Count; i++)
                        {
                            if (crowdFundingApps.Any(c => c == commodityList[i].AppId))
                            {
                                commodityList[i].IsActiveCrowdfunding = true;
                            }
                        }
                    }
                }
                #endregion

                var commodityIds = commodityList.Select(c => c.Id).Distinct().ToList();
                var comStockList = CommodityStock.ObjectSet()
                                   .Where(c => commodityIds.Contains(c.CommodityId))
                                   .Select(
                    c =>
                    new Deploy.CommodityStockDTO
                {
                    Id          = c.Id,
                    CommodityId = c.CommodityId,
                    Price       = c.Price,
                    MarketPrice = c.MarketPrice
                })
                                   .ToList();
                var todayPromotions = TodayPromotion.GetCurrentPromotionsWithPresell(commodityIds);

                foreach (var commodity in commodityList)
                {
                    commodity.IsMultAttribute = Commodity.CheckComMultAttribute(commodity.ComAttribute);
                    List <Deploy.CommodityStockDTO> comStocks = comStockList.Where(c => c.CommodityId == commodity.Id).ToList();

                    var todayPromotion = todayPromotions.FirstOrDefault(c => c.CommodityId == commodity.Id && c.PromotionType != 3);

                    if (todayPromotion != null)
                    {
                        commodity.LimitBuyEach         = todayPromotion.LimitBuyEach ?? -1;
                        commodity.LimitBuyTotal        = todayPromotion.LimitBuyTotal ?? -1;
                        commodity.SurplusLimitBuyTotal = todayPromotion.SurplusLimitBuyTotal ?? 0;
                        commodity.PromotionType        = todayPromotion.PromotionType;
                        if (todayPromotion.DiscountPrice > -1)
                        {
                            commodity.DiscountPrice = Convert.ToDecimal(todayPromotion.DiscountPrice);
                            commodity.Intensity     = 10;
                        }
                        else
                        {
                            commodity.DiscountPrice = -1;
                            commodity.Intensity     = todayPromotion.Intensity;
                        }
                    }
                    else
                    {
                        commodity.DiscountPrice        = -1;
                        commodity.Intensity            = 10;
                        commodity.LimitBuyEach         = -1;
                        commodity.LimitBuyTotal        = -1;
                        commodity.SurplusLimitBuyTotal = -1;
                        commodity.PromotionType        = 9999;
                    }
                    buildShowPrice(commodity, comStocks, todayPromotion);
                }

                try
                {
                    var apps = APPSV.GetAppListByIds(appList);
                    if (apps != null && apps.Any())
                    {
                        comdtyListResultCDTO.appInfoList = new List <ComdtyAppInfoCDTO>();
                        foreach (var appInfo in apps)
                        {
                            comdtyListResultCDTO.appInfoList.Add(new ComdtyAppInfoCDTO
                            {
                                appId   = appInfo.AppId,
                                appName = appInfo.AppName,
                                icon    = appInfo.AppIcon
                            });
                        }

                        foreach (var commodityListCdto in commodityList)
                        {
                            var appInfo = apps.FirstOrDefault(c => c.AppId == commodityListCdto.AppId);
                            if (appInfo != null)
                            {
                                commodityListCdto.AppName = appInfo.AppName;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("AppSetSV.GetCommodityListExt,获取app名称错误。appId:{0}", appId), ex);
                }

                comdtyListResultCDTO.comdtyList = commodityList;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("商品列表查询错误,CommoditySV.GetCommodityListV2Ext。search:{0}", JsonHelper.JsonSerializer(search)), ex);
                comdtyListResultCDTO.isSuccess   = false;
                comdtyListResultCDTO.Code        = -1;
                comdtyListResultCDTO.Message     = "Error";
                comdtyListResultCDTO.realCount   = 0;
                comdtyListResultCDTO.comdtyList  = null;
                comdtyListResultCDTO.appInfoList = null;
                return(comdtyListResultCDTO);
            }
            comdtyListResultCDTO.isSuccess = true;
            comdtyListResultCDTO.Code      = 0;
            comdtyListResultCDTO.Message   = "Success";
            return(comdtyListResultCDTO);
        }
Esempio n. 17
0
        public ResultDTO <ListResult <SpreadInfoShowDTO> > GetSpreadInfoListExt(SpreadSearchDTO search)
        {
            if (search == null)
            {
                return new ResultDTO <ListResult <SpreadInfoShowDTO> > {
                           ResultCode = 1, Message = "参数为空"
                }
            }
            ;
            if (search.PageIndex == 0)
            {
                search.PageIndex = 1;
            }
            if (search.PageSize == 0)
            {
                search.PageSize = 20;
            }
            var query = SpreadInfo.ObjectSet().Where(c => c.IsDel != 1);

            if (search.SpreadType.HasValue)
            {
                query = query.Where(c => c.SpreadType == search.SpreadType.Value);
            }
            if (!string.IsNullOrEmpty(search.UserCode))
            {
                query = query.Where(c => c.UserCode.Contains(search.UserCode));
            }
            if (search.SpreadAppId.HasValue && search.SpreadAppId != Guid.Empty)
            {
                query = query.Where(c => c.SpreadAppId == search.SpreadAppId.Value);
            }
            if (search.IWId.HasValue)
            {
                query = query.Where(c => c.IWId == search.IWId.Value);
            }
            ListResult <SpreadInfoShowDTO> data = new ListResult <SpreadInfoShowDTO> {
                List = new List <SpreadInfoShowDTO>()
            };

            data.Count = query.Count();
            data.List  = query.OrderByDescending(c => c.SubTime).Skip((search.PageIndex - 1) * search.PageSize).
                         Take(search.PageSize).Select(c => new SpreadInfoShowDTO
            {
                Id                 = c.Id,
                SpreadId           = c.SpreadId,
                Account            = c.UserCode,
                Name               = c.Name,
                SpreadType         = c.SpreadType,
                SpreadAppId        = c.SpreadAppId,
                HotshopId          = c.HotshopId,
                QrCodeUrl          = c.QrCodeUrl,
                SpreadDesc         = c.SpreadDesc,
                SpreadUrl          = c.SpreadUrl,
                SubTime            = c.SubTime,
                IsDel              = c.IsDel,
                HotshopName        = "",
                IsBindWeChatQrCode = false,
                SpreadAppName      = "",
                SpreadTypeDesc     = "",
                IWCode             = c.IWCode,
                SubSpreadCount     = c.SubSpreadCount,
                DividendPercent    = c.DividendPercent
            }).ToList();
            if (data.List.Any())
            {
                var spreadTypes        = data.List.Select(c => c.SpreadType).Distinct().ToList();
                var spreadCategoryList = SpreadCategory.ObjectSet()
                                         .Where(c => spreadTypes.Contains(c.SpreadType))
                                         .Select(m => new SpreadCategoryDTO {
                    SpreadType = m.SpreadType, CategoryDesc = m.CategoryDesc
                }).ToList();

                var ids       = data.List.Select(c => c.Id).ToList();
                var bindedIds = WeChatQRCode.ObjectSet().Where(c => ids.Contains(c.SpreadInfoId)).Select(m => m.SpreadInfoId).ToList();


                var appIds = data.List.Select(c => c.SpreadAppId).Distinct().ToList();
                appIds.AddRange(data.List.Select(c => c.HotshopId));
                appIds = appIds.Distinct().ToList();
                var appDict = APPSV.GetAppNameListByIds(appIds);
                foreach (var spreadInfoShowDTO in data.List)
                {
                    if (appDict.ContainsKey(spreadInfoShowDTO.SpreadAppId))
                    {
                        spreadInfoShowDTO.SpreadAppName = appDict[spreadInfoShowDTO.SpreadAppId];
                    }
                    if (appDict.ContainsKey(spreadInfoShowDTO.HotshopId))
                    {
                        spreadInfoShowDTO.HotshopName = appDict[spreadInfoShowDTO.HotshopId];
                    }
                    var spreadTypeDto = spreadCategoryList.FirstOrDefault(c => c.SpreadType == spreadInfoShowDTO.SpreadType);
                    if (spreadTypeDto != null)
                    {
                        spreadInfoShowDTO.SpreadTypeDesc = spreadTypeDto.CategoryDesc;
                    }
                    if (bindedIds.Contains(spreadInfoShowDTO.Id))
                    {
                        spreadInfoShowDTO.IsBindWeChatQrCode = true;
                    }
                }
            }

            return(new ResultDTO <ListResult <SpreadInfoShowDTO> >
            {
                isSuccess = true,
                Message = "success",
                Data = data
            });
        }