Exemple #1
0
        /// <summary>
        /// 分销商列表信息
        /// </summary>
        /// <param name="manaDTO"></param>
        /// <returns></returns>
        public ManageDTO ManageInfoExt(ManageVM manaDTO)
        {
            ManageDTO result = new ManageDTO();

            if (manaDTO == null)
            {
                return(result);
            }

            if (manaDTO.Ynos == 1 && manaDTO.ParentId != Guid.Empty)
            {
                var parent = Distributor.ObjectSet().FirstOrDefault(c => c.Id == manaDTO.ParentId);
                if (parent != null)
                {
                    var tuple = CBCSV.GetUserNameAndCode(parent.UserId);
                    result.ParentName = tuple.Item1;
                    result.ParentCode = tuple.Item2;
                }
            }
            var resultData = DSSBP.Instance.ManageInfo(manaDTO);

            if (resultData != null && resultData.Data != null)
            {
                result.Count   = resultData.Data.Count;
                result.Manager = resultData.Data.Manager;
            }

            LogHelper.Info(
                string.Format("DistributeBP.ManageInfoExt(AppId='{0}',ParentId='{1}'),返回:Count={2},Manager.Count={3}。",
                              manaDTO.AppId, manaDTO.ParentId, result.Count, result.Manager.Count));

            return(result);
        }
Exemple #2
0
 /// <summary>
 /// 定时更新无效用户信息
 /// </summary>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdataYJEmployeeInfoExt()
 {
     try
     {
         ContextSession contextSession = ContextFactory.CurrentThreadContext;
         //取出表中多有的无效员工
         var InvalidYJEmployeeList = YJEmployee.ObjectSet().Where(p => p.UserId == Guid.Empty && p.IsDel == 0).ToList();
         foreach (var item in InvalidYJEmployeeList)
         {
             Guid UserId = CBCSV.GetUserIdByAccount(item.UserAccount);
             if (UserId != Guid.Empty)
             {
                 item.UserId      = UserId;
                 item.ModifiedOn  = DateTime.Now;
                 item.EntityState = EntityState.Modified;
                 contextSession.SaveObject(item);
             }
         }
         contextSession.SaveChanges();
     }
     catch (Exception ex)
     {
         LogHelper.Error("YJEmployeeBP.UpdataYJEmployeeInfoExt 异常", ex);
         return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
             isSuccess = false, Message = "更新失败"
         });
     }
     return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
         isSuccess = true, Message = "更新成功"
     });
 }
Exemple #3
0
 /// <summary>
 /// 编辑员工
 /// </summary>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateYJEmployeeExt(Jinher.AMP.BTP.Deploy.YJEmployeeDTO input)
 {
     try
     {
         Guid UserId = CBCSV.GetUserIdByAccount(input.UserAccount);
         //if (UserId == Guid.Empty || UserId == null)
         //{
         //    return new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO { isSuccess = false, Message = "该用户不是易捷用户!" };
         //}
         var UserInfo = YJEmployee.ObjectSet().FirstOrDefault(p => p.Id != input.Id & p.AppId == input.AppId & p.UserAccount == input.UserAccount & p.IsDel != 1);
         if (UserInfo != null)
         {
             return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
                 isSuccess = false, Message = "该用户已存在!"
             });
         }
         ContextSession contextSession = ContextFactory.CurrentThreadContext;
         var            YJEmp          = YJEmployee.ObjectSet().FirstOrDefault(_ => _.Id == input.Id);
         YJEmp.UserId      = UserId;
         YJEmp.UserCode    = input.UserCode;
         YJEmp.UserAccount = input.UserAccount;
         YJEmp.UserName    = input.UserName;
         YJEmp.IdentityNum = input.IdentityNum;
         YJEmp.Phone       = input.Phone;
         YJEmp.Area        = input.Area;
         YJEmp.StationCode = input.StationCode;
         YJEmp.StationName = input.StationName;
         YJEmp.ModifiedId  = ContextDTO.LoginUserID;
         YJEmp.ModifiedOn  = DateTime.Now;
         YJEmp.IsManager   = input.IsManager;
         if (YJEmp.IsManager == 1)
         {
             YJEmp.Department = input.Department;
             YJEmp.Station    = input.Station;
         }
         else
         {
             YJEmp.Department = "";
             YJEmp.Station    = "";
         }
         YJEmp.EntityState = EntityState.Modified;
         contextSession.SaveObject(YJEmp);
         contextSession.SaveChanges();
     }
     catch (Exception ex)
     {
         LogHelper.Error("YJEmployeeBP.UpdateYJEmployeeExt 异常", ex);
         return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
             isSuccess = false, Message = ex.Message
         });
     }
     LogHelper.Info("员工修改日志" + JsonHelper.JsonSerializer(input) + "修改人" + ContextDTO.LoginUserID + "修改时间" + DateTime.Now);
     return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
         isSuccess = true, Message = "修改成功"
     });
 }
Exemple #4
0
 /// <summary>
 /// 新建员工
 /// </summary>
 public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO AddYJEmployeeExt(Jinher.AMP.BTP.Deploy.YJEmployeeDTO input)
 {
     try
     {
         Guid UserId = CBCSV.GetUserIdByAccount(input.UserAccount);
         //if (UserId == Guid.Empty || UserId == null)
         //{
         //    return new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO { isSuccess = false, Message = "该用户不是易捷用户!" };
         //}
         var UserInfo = YJEmployee.ObjectSet().FirstOrDefault(p => (p.UserAccount == input.UserAccount || p.IdentityNum == input.IdentityNum) && p.AppId == p.AppId && p.IsDel == 0);
         if (UserInfo != null)
         {
             return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
                 isSuccess = false, Message = "该用户已存在!"
             });
         }
         ContextSession contextSession = ContextFactory.CurrentThreadContext;
         YJEmployee     YJEmp          = YJEmployee.CreateYJEmployee();
         YJEmp.UserId      = UserId;
         YJEmp.UserCode    = input.UserCode;
         YJEmp.UserAccount = input.UserAccount;
         YJEmp.UserName    = input.UserName;
         YJEmp.IdentityNum = input.IdentityNum;
         YJEmp.Phone       = input.Phone;
         YJEmp.Area        = input.Area;
         YJEmp.StationCode = input.StationCode;
         YJEmp.StationName = input.StationName;
         YJEmp.IsDel       = 0;
         YJEmp.SubId       = ContextDTO.LoginUserID;
         YJEmp.SubOn       = DateTime.Now;
         YJEmp.AppId       = input.AppId;
         YJEmp.IsManager   = input.IsManager;
         if (YJEmp.IsManager == 1)
         {
             YJEmp.Department = input.Department;
             YJEmp.Station    = input.Station;
         }
         else
         {
             YJEmp.Department = "";
             YJEmp.Station    = "";
         }
         contextSession.SaveObject(YJEmp);
         contextSession.SaveChanges();
     }
     catch (Exception ex)
     {
         LogHelper.Error("YJEmployeeBP.AddYJEmployeeExt 异常", ex);
         return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
             isSuccess = false, Message = ex.Message
         });
     }
     return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO {
         isSuccess = true, Message = "添加成功"
     });
 }
Exemple #5
0
        /// <summary>
        /// 售中退款时,回退用户易捷币和易捷抵用券
        /// </summary>
        public static ResultDTO OrderRefund(ContextSession contextSession, CommodityOrder commodityOrder, OrderRefund orderRefund, decimal commodityPrice, Guid useryjcouponid)
        {
            if (commodityOrder.EsAppId != Jinher.AMP.YJB.Deploy.CustomDTO.YJBConsts.YJAppId)
            {
                return(ResultDTO.Successed);
            }

            //var result = YJBSV.RefundAllOrderJournal(commodityOrder.Id);
            //if (!result.IsSuccess)
            //{
            //    LogHelper.Error("售中退款时,回退用户易捷币失败,订单ID:" + commodityOrder.Id + ",错误内容:" + result.Message);
            //    LogOrderErrorInfo(contextSession, commodityOrder, "售中退款时,回退用回退用户易捷币失败户易捷币");
            //}
            //return result;
            #region 记录抵用券退款明细表
            var orderitemorder = (from i in OrderItem.ObjectSet()
                                  where commodityOrder.Id == i.CommodityOrderId
                                  select i).ToList();
            var user = CBCSV.GetUserNameAndCode(commodityOrder.UserId);
            foreach (var item in orderitemorder)
            {
                CouponRefundDetail couponRefundDetailDTO = new CouponRefundDetail();
                couponRefundDetailDTO.Id                   = Guid.NewGuid();
                couponRefundDetailDTO.SubTime              = DateTime.Now;
                couponRefundDetailDTO.ModifiedOn           = DateTime.Now;
                couponRefundDetailDTO.RefundTime           = DateTime.Now;
                couponRefundDetailDTO.ReceiveAccount       = user != null ? user.Item2 : "";
                couponRefundDetailDTO.ReceiveName          = user != null ? user.Item1 : "";
                couponRefundDetailDTO.CommodityCouponMoney = commodityPrice;
                couponRefundDetailDTO.FreightCouponMoney   = 0;
                couponRefundDetailDTO.CommodityRefundMoney = orderRefund.RefundMoney;
                couponRefundDetailDTO.FreightRefundMoney   = orderRefund.RefundFreightPrice;
                couponRefundDetailDTO.RefundTotalMoney     = commodityPrice + orderRefund.RefundMoney + orderRefund.RefundFreightPrice;
                couponRefundDetailDTO.ShopName             = commodityOrder.AppName;
                couponRefundDetailDTO.OrderNo              = commodityOrder.Code;
                couponRefundDetailDTO.CommoidtyName        = item.Name;
                couponRefundDetailDTO.ReceivePhone         = commodityOrder.ReceiptPhone;
                couponRefundDetailDTO.ConsigneeName        = commodityOrder.ReceiptUserName;
                couponRefundDetailDTO.Remark               = "";
                couponRefundDetailDTO.EntityState          = System.Data.EntityState.Added;

                contextSession.SaveObject(couponRefundDetailDTO);
            }
            contextSession.SaveChanges();
            #endregion
            var mobile = user != null ? user.Item2 : "";
            var result = YJBSV.RefundOrderJournal(commodityOrder.Id, orderRefund.RefundYJBMoney, commodityPrice, mobile, commodityOrder.UserId, useryjcouponid);
            if (!result.IsSuccess)
            {
                LogHelper.Error("售中退款时,回退用户易捷币失败,订单ID:" + commodityOrder.Id + ",错误内容:" + result.Message);
                LogOrderErrorInfo(contextSession, commodityOrder, "售中退款时,回退用回退用户易捷币失败户易捷币");
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 保存推广信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SaveSpreadInfoExt(Jinher.AMP.BTP.Deploy.CustomDTO.SpreadSaveDTO dto)
        {
            if (dto == null || dto.SpreadAppId == Guid.Empty || dto.HotshopId == Guid.Empty)
            {
                return new ResultDTO {
                           ResultCode = 1, Message = "参数为空"
                }
            }
            ;

            Guid userId = Guid.Empty;
            Guid iwId   = Guid.Empty;

            // 一级代理
            if (dto.SpreadType == 5)
            {
                if (dto.SubSpreadCount < 0 || dto.SubSpreadCount > 999)
                {
                    return(new ResultDTO {
                        ResultCode = 1, Message = "子代理数量仅允许输入0~999"
                    });
                }
                if (dto.IWCode == null)
                {
                    return new ResultDTO {
                               ResultCode = 1, Message = "参数为空"
                    }
                }
                ;

                iwId = EBCSV.GetOrgIdByIwCode(dto.IWCode);
                if (iwId == Guid.Empty)
                {
                    return new ResultDTO {
                               ResultCode = 2, Message = "该组织不存在"
                    }
                }
                ;
                // 同一个推广主或推广组织,同一个推广App,同一个旺铺仅能生成一个推广码;已存在则提示:已存在相同的推广码;
                var spreadInfoCount = SpreadInfo.ObjectSet().Count(c => c.IsDel != 1 && c.SpreadType == 5 && c.IWId == iwId && c.SpreadAppId == dto.SpreadAppId && c.HotshopId == dto.HotshopId);
                if (spreadInfoCount > 0)
                {
                    return(new ResultDTO {
                        ResultCode = 2, Message = "已存在相同的推广码"
                    });
                }
            }
            // 二级代理
            else if (dto.SpreadType == 6)
            {
                if (dto.UserCode == null || dto.IWId == Guid.Empty || string.IsNullOrEmpty(dto.IWCode))
                {
                    return new ResultDTO {
                               ResultCode = 1, Message = "参数为空"
                    }
                }
                ;
                iwId   = dto.IWId;
                userId = CBCSV.GetUserIdByAccount(dto.UserCode);
                if (userId == Guid.Empty)
                {
                    return new ResultDTO {
                               ResultCode = 2, Message = "该用户未注册"
                    }
                }
                ;

                // 同一个推广主,同一个推广App,同一个旺铺仅能生成一个推广码;已存在则提示:已存在相同的推广码;
                var spreadUserCount = SpreadInfo.ObjectSet().Count(c => c.IsDel != 1 && c.SpreadType == 6 && c.SpreadId == userId && c.SpreadAppId == dto.SpreadAppId && c.HotshopId == dto.HotshopId);
                if (spreadUserCount > 0)
                {
                    return(new ResultDTO {
                        ResultCode = 2, Message = "已存在相同的推广码"
                    });
                }

                // 查询一级代理
                var lv1Spread = SpreadInfo.ObjectSet().FirstOrDefault(s => s.IsDel != 1 && s.SpreadType == 5 && s.IWId == iwId && s.SpreadAppId == dto.SpreadAppId && s.HotshopId == dto.HotshopId);
                if (lv1Spread == null)
                {
                    return(new ResultDTO {
                        ResultCode = 2, Message = "未创建一级代理"
                    });
                }
                // 同一组织、同一个推广App,同一个旺铺的子代理数量限制
                var lv2SpreadCount = SpreadInfo.ObjectSet().Count(c => c.IsDel != 1 && c.SpreadType == 6 && c.IWId == iwId && c.SpreadAppId == dto.SpreadAppId && c.HotshopId == dto.HotshopId);
                if (lv2SpreadCount >= lv1Spread.SubSpreadCount)
                {
                    return(new ResultDTO {
                        ResultCode = 2, Message = "生成的推广码已经达到限制数量"
                    });
                }
            }
            else
            {
                if (dto.UserCode == null)
                {
                    return new ResultDTO {
                               ResultCode = 1, Message = "参数为空"
                    }
                }
                ;
                userId = CBCSV.GetUserIdByAccount(dto.UserCode);
                if (userId == Guid.Empty)
                {
                    return new ResultDTO {
                               ResultCode = 2, Message = "该用户未注册"
                    }
                }
                ;
            }

            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                Guid           spreadCode     = Guid.NewGuid();
                string         spreadUrl      = getSpreadUrl(dto.SpreadAppId, dto.HotshopId, spreadCode);
                var            qrCodeUrl      = BaseAppToolsSV.GenerateQrCode(spreadUrl, dto.QrCodeFileImg);
                if (string.IsNullOrEmpty(qrCodeUrl))
                {
                    return(new ResultDTO {
                        ResultCode = 2, Message = "生成二维码失败"
                    });
                }
                SpreadInfo spreadInfo = new SpreadInfo
                {
                    Id              = Guid.NewGuid(),
                    SpreadId        = userId,
                    SpreadUrl       = ShortUrlSV.Instance.GenShortUrl(spreadUrl),
                    SpreadCode      = spreadCode,
                    SpreadDesc      = dto.SpreadDesc,
                    SpreadType      = dto.SpreadType,
                    QrCodeUrl       = qrCodeUrl,
                    SpreadAppId     = dto.SpreadAppId,
                    HotshopId       = dto.HotshopId,
                    UserCode        = dto.UserCode,
                    Name            = dto.Name ?? "",
                    IWId            = iwId,
                    IWCode          = dto.IWCode,
                    SubSpreadCount  = dto.SubSpreadCount,
                    DividendPercent = dto.DividendPercent,
                    EntityState     = EntityState.Added
                };
                contextSession.SaveObject(spreadInfo);

                updateRalationUserSpread(contextSession, spreadInfo);

                contextSession.SaveChanges();

                return(new ResultDTO {
                    isSuccess = true, ResultCode = 0, Message = "Success"
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("SpreadInfoBP.SaveSpreadInfoExt异常,dto={0}", JsonHelper.JsonSerializer(dto)), ex);
                return(new ResultDTO {
                    ResultCode = 1, Message = "Error"
                });
            }
        }
Exemple #7
0
        /// <summary>
        /// 获取拼团详情
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupDetailDTO> GetDiyGroupDetailExt(Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupDetailSearchDTO search)
        {
            ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.DiyGroupDetailDTO> result = new ResultDTO <DiyGroupDetailDTO>();

            if (search == null || search.DiyGoupId == Guid.Empty)
            {
                result.ResultCode = 1;
                result.Message    = "参数错误";
                return(result);
            }
            var query = (from dg in DiyGroup.ObjectSet()
                         join c in Commodity.ObjectSet() on dg.CommodityId equals c.Id
                         join p in Promotion.ObjectSet() on dg.PromotionId equals p.Id
                         where dg.Id == search.DiyGoupId
                         select new
            {
                DiyGroup = dg,
                Commodity = c,
                Promotion = p
            }).FirstOrDefault();

            if (query == null || query.Commodity == null || query.DiyGroup == null || query.Promotion == null)
            {
                result.ResultCode = 2;
                result.Message    = "没有获取到相应的拼团详情";
                return(result);
            }
            var commodity     = query.Commodity;
            var diyGroup      = query.DiyGroup;
            var promotion     = query.Promotion;
            var promotionItem = PromotionItems.ObjectSet().Where(t => t.PromotionId == diyGroup.PromotionId).FirstOrDefault();

            if (promotionItem == null)
            {
                result.ResultCode = 2;
                result.Message    = "没有获取到相应的拼团详情";
                return(result);
            }
            var productDetailPicture = ProductDetailsPicture.ObjectSet().Where(n => n.CommodityId == commodity.Id).OrderBy(n => n.Sort).Select(c => c.PicturesPath).FirstOrDefault();

            result.Data = new DiyGroupDetailDTO()
            {
                Id                 = diyGroup.Id,
                Name               = diyGroup.Name,
                Code               = diyGroup.Code,
                SubTime            = diyGroup.SubTime,
                SubId              = diyGroup.SubId,
                AppId              = diyGroup.AppId,
                CommodityId        = diyGroup.CommodityId,
                PromotionId        = diyGroup.PromotionId,
                ModifiedOn         = diyGroup.ModifiedOn,
                ExpireTime         = diyGroup.ExpireTime,
                State              = diyGroup.State,
                JoinNumber         = diyGroup.JoinNumber,
                SuccessProcessorId = diyGroup.SuccessProcessorId,
                SuccessTime        = diyGroup.SuccessTime,
                FailProcessorId    = diyGroup.FailProcessorId,
                FailTime           = diyGroup.FailTime,
                EsAppId            = diyGroup.EsAppId,
                //commodity
                PicturesPath         = commodity.PicturesPath,
                CommodityName        = commodity.Name,
                ProductDetailPicture = productDetailPicture,
                //promotion
                StartTime      = promotion.StartTime,
                EndTime        = promotion.EndTime,
                GroupMinVolume = promotion.GroupMinVolume ?? -1,
                ExpireSecond   = promotion.ExpireSecond ?? -1,
                Description    = promotion.Description,
                OutsideId      = promotion.OutsideId.Value,
                //promotionitem
                LimitBuyEach         = promotionItem.LimitBuyEach ?? -1,
                LimitBuyTotal        = promotionItem.LimitBuyTotal ?? -1,
                DiscountPrice        = promotionItem.DiscountPrice,
                SurplusLimitBuyTotal = promotionItem.SurplusLimitBuyTotal ?? -1
            };
            result.Data.DiyGroupOrderList = new List <DiyGroupOrderDetailDTO>();
            var diyGroupOrder = (from dgOrder in DiyGroupOrder.ObjectSet()
                                 join co in CommodityOrder.ObjectSet() on dgOrder.OrderId equals co.Id
                                 where dgOrder.DiyGroupId == search.DiyGoupId && (dgOrder.Role == 0 || dgOrder.Role == 1 && dgOrder.State == 1)
                                 orderby dgOrder.SubTime ascending
                                 select new DiyGroupOrderDetailDTO
            {
                Id = dgOrder.Id,
                SubTime = dgOrder.SubTime,
                SubId = dgOrder.SubId,
                AppId = dgOrder.AppId,
                OrderId = dgOrder.OrderId,
                OrderCode = dgOrder.OrderCode,
                Role = dgOrder.Role,
                DiyGroupId = dgOrder.DiyGroupId,
                SubCode = dgOrder.SubCode,
                ModifiedOn = dgOrder.ModifiedOn,
                DiyGroupPrice = (decimal)co.RealPrice
            }).ToList();

            result.Data.DiyGroupOrderList.AddRange(diyGroupOrder);

            //提取用户信息
            var userIdList   = result.Data.DiyGroupOrderList.Select(t => t.SubId).ToList();
            var userInfolist = CBCSV.Instance.GetUserInfoWithAccountList(userIdList);

            if (userInfolist != null && userInfolist.Count > 0)
            {
                foreach (var item in result.Data.DiyGroupOrderList)
                {
                    var tmpUserInfo = userInfolist.Where(t => t.UserId == item.SubId).FirstOrDefault();
                    if (tmpUserInfo != null)
                    {
                        item.UserCode    = CBCSV.EncodeUserCode(tmpUserInfo.Account);
                        item.UserPicture = tmpUserInfo.HeadIcon;
                    }
                }
            }

            //var diyHeadOrder = diyGroupOrder.Where(t => t.Role == 0).FirstOrDefault();
            //if (diyHeadOrder != null && diyHeadOrder.State == 0)
            //{
            //    result.Data.JoinNumber = result.Data.JoinNumber + 1;
            //}

            //系统当前时间,倒计时用
            result.Data.DateTimeNow = DateTime.Now;
            return(result);
        }
Exemple #8
0
        /// <summary>
        /// 导入员工信息
        /// </summary>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.YJEmployee.YJEmployeeSearchDTO> ImportYJEmployeeListExt(System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.YJEmployeeDTO> YJEmpList, System.Guid AppId)
        {
            try
            {
                ContextSession      contextSession = ContextFactory.CurrentThreadContext;
                YJEmployeeSearchDTO YJEmpl         = new YJEmployeeSearchDTO();
                var YJEmpListNoRepeat = YJEmpList.GroupBy(P => P.UserAccount).Select(P => P.FirstOrDefault()).ToList();
                var IcardList         = YJEmpList.Select(s => s.IdentityNum).ToList();                 //身份证号

                List <string> UserAccountList = YJEmpListNoRepeat.Select(S => S.UserAccount).ToList(); //用户账号
                //验证重复账号
                var ExistIcardDate = YJEmployee.ObjectSet().Where(p => IcardList.Contains(p.IdentityNum) && p.IsDel == 0 && p.AppId == AppId).Select(s => s.IdentityNum).ToList();
                var ExistDate      = YJEmployee.ObjectSet().Where(p => UserAccountList.Contains(p.UserAccount) && p.IsDel == 0 && p.AppId == AppId).ToList();
                var RepeatData     = ExistDate.Select(s => s.UserAccount).ToList();
                YJEmpl.RepeatData      = YJEmpListNoRepeat.Where(p => RepeatData.Contains(p.UserAccount)).ToList();
                YJEmpl.RepeatIcardData = YJEmpList.Where(p => ExistIcardDate.Contains(p.IdentityNum)).ToList();
                if (YJEmpl.RepeatIcardData.Any())
                {
                    return(new ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.YJEmployee.YJEmployeeSearchDTO> {
                        Data = YJEmpl, ResultCode = 1, isSuccess = false, Message = "数据库中已存在,请核对后再导入~"
                    });
                }
                //取出无效数据
                List <string> Invalid = new List <string>();
                foreach (var item in YJEmpListNoRepeat)
                {
                    Guid UserId = CBCSV.GetUserIdByAccount(item.UserAccount);
                    item.UserId = UserId;
                    if (UserId == Guid.Empty || UserId == null)
                    {
                        Invalid.Add(item.UserAccount);
                    }
                }
                YJEmpl.InvalidData = YJEmpListNoRepeat.Where(p => Invalid.Contains(p.UserAccount)).Select(s => s.UserAccount).ToList();
                foreach (var item in YJEmpListNoRepeat)
                {
                    var ExistEmpolyee = ExistDate.FirstOrDefault(p => p.UserAccount == item.UserAccount);
                    if (ExistEmpolyee == null)
                    {
                        YJEmployee YJEmp = YJEmployee.CreateYJEmployee();
                        YJEmp.UserId      = item.UserId;
                        YJEmp.UserCode    = item.UserCode;
                        YJEmp.UserAccount = item.UserAccount;
                        YJEmp.UserName    = item.UserName;
                        YJEmp.IdentityNum = item.IdentityNum;
                        YJEmp.Phone       = item.Phone;
                        YJEmp.Area        = item.Area;
                        YJEmp.StationCode = item.StationCode;
                        YJEmp.StationName = item.StationName;
                        YJEmp.IsDel       = 0;
                        YJEmp.SubId       = ContextDTO.LoginUserID;
                        YJEmp.SubOn       = DateTime.Now;
                        YJEmp.AppId       = item.AppId;
                        YJEmp.IsManager   = item.IsManager;
                        YJEmp.Department  = item.Department;
                        YJEmp.Station     = item.Station;
                        contextSession.SaveObject(YJEmp);
                    }
                    else
                    {
                        ExistEmpolyee.UserId      = item.UserId;
                        ExistEmpolyee.UserCode    = item.UserCode;
                        ExistEmpolyee.UserAccount = item.UserAccount;
                        ExistEmpolyee.UserName    = item.UserName;
                        ExistEmpolyee.IdentityNum = item.IdentityNum;
                        ExistEmpolyee.Phone       = item.Phone;
                        ExistEmpolyee.Area        = item.Area;
                        ExistEmpolyee.StationCode = item.StationCode;
                        ExistEmpolyee.StationName = item.StationName;
                        ExistEmpolyee.IsDel       = 0;
                        ExistEmpolyee.SubId       = ContextDTO.LoginUserID;
                        ExistEmpolyee.SubOn       = DateTime.Now;
                        ExistEmpolyee.AppId       = item.AppId;
                        ExistEmpolyee.IsManager   = item.IsManager;
                        ExistEmpolyee.Department  = item.Department;
                        ExistEmpolyee.Station     = item.Station;
                        ExistEmpolyee.EntityState = EntityState.Modified;
                        contextSession.SaveObject(ExistEmpolyee);
                    }
                }
                contextSession.SaveChanges();
                return(new ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.YJEmployee.YJEmployeeSearchDTO> {
                    Data = YJEmpl, ResultCode = 0, isSuccess = true, Message = "导入成功"
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error("YJEmployeeBP.AddYJEmployeeExt 异常", ex);
                return(new ResultDTO <Jinher.AMP.BTP.Deploy.CustomDTO.YJEmployee.YJEmployeeSearchDTO> {
                    isSuccess = false, ResultCode = 2, Message = ex.Message
                });
            }
        }
Exemple #9
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);
            }
        }