コード例 #1
0
        /// <summary>
        /// 获取众销统计信息
        /// </summary>
        /// <param name="search">查询类</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneySumDTO GetShareOrderMoneySumInfoExt(Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneySumSearchDTO search)
        {
            if (search == null || search.UseId == Guid.Empty || search.AppId == Guid.Empty)
            {
                return(null);
            }
            Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneySumDTO result = new ShareOrderMoneySumDTO();

            //售中待收益
            var orderStates = new List <int>()
            {
                1, 2, 8, 9, 10, 12, 13, 14
            };
            //售后待收益
            var orderAfterStates = new List <int>()
            {
                3, 5, 10, 12, 13
            };

            //佣金总数(已收益佣金)
            var sumInfo = (from orderShare in OrderShare.ObjectSet()
                           join order in CommodityOrder.ObjectSet()
                           on orderShare.OrderId equals order.Id
                           join dataS in CommodityOrderService.ObjectSet()
                           on orderShare.OrderId equals dataS.Id
                           into tempS
                           from orderService in tempS.DefaultIfEmpty()
                           where
                           orderShare.PayeeId == search.UseId && orderShare.PayeeType == search.PayeeType && orderShare.Commission > 0 &&
                           order.EsAppId == search.AppId && order.State == 3 && orderService.State == 15
                           select orderShare.Commission).ToList().Sum();

            //待收益佣金总数
            var sumUnPayInfo = (from orderShare in OrderShare.ObjectSet()
                                join order in CommodityOrder.ObjectSet()
                                on orderShare.OrderId equals order.Id
                                join dataS in CommodityOrderService.ObjectSet()
                                on orderShare.OrderId equals dataS.Id
                                into tempS
                                from orderService in tempS.DefaultIfEmpty()
                                where
                                orderShare.PayeeId == search.UseId && orderShare.PayeeType == search.PayeeType && orderShare.Commission > 0 &&
                                order.EsAppId == search.AppId && (orderStates.Contains(order.State) ||
                                                                  order.State == 3 && orderService.State != null && orderAfterStates.Contains(orderService.State))
                                select orderShare.Commission).ToList().Sum();

            result.CommissionAmount = sumInfo;
            result.CommmissionUnPay = sumUnPayInfo;

            return(result);
        }
コード例 #2
0
ファイル: SignSV.cs プロジェクト: GSIL-Monitor/BTP
        /// <summary>
        /// 售后完成渠道打积分
        /// </summary>
        /// <param name="contextSession"></param>
        /// <param name="commodityOrder"></param>
        /// <param name="commodityOrderService"></param>
        /// <returns></returns>
        public static bool ChannelShareSaleGiveScore(ContextSession contextSession, CommodityOrder commodityOrder, CommodityOrderService commodityOrderService)
        {
            if (!commodityOrder.EsAppId.HasValue)
            {
                return(true);
            }
            //使用了积分
            if (commodityOrder.ChannelShareMoney > 0)
            {
                //取商货众销的收款人
                var shareModel = OrderShare.ObjectSet().FirstOrDefault(t => t.OrderId == commodityOrder.Id && t.PayeeType == 12);

                //没有收款人
                if (shareModel == null || shareModel.PayeeId == Guid.Empty)
                {
                    LogHelper.Error(string.Format("售后完成渠道打积,找不到收款人。OrderId:{0}", commodityOrder.Id));
                    return(false);
                }
                //获取当时的积分比例
                CostScoreInfoDTO scoreCostDto;
                if (new ScoreSV().GetScoreCost(commodityOrder.EsAppId.Value, out scoreCostDto, commodityOrder.SubTime))
                {
                    int  srore             = (int)(commodityOrder.ChannelShareMoney * scoreCostDto.Cost);
                    bool refundScoreResult = Instance.GiveScoreBtpShare(shareModel.PayeeId, commodityOrder.EsAppId.Value, srore, commodityOrder.Id, commodityOrder.Code, ScoringType.BtpChannelBrokerage, commodityOrder.ChannelShareMoney, scoreCostDto.Cost, scoreCostDto.ScoreType);
                    if (!refundScoreResult)
                    {
                        LogHelper.Error(string.Format("售后完成渠道打积分失败。UserId:{0},AppId:{1},srore:{2},OrderId:{3}", shareModel.PayeeId, commodityOrder.AppId, srore, commodityOrder.Id));
                        ErrorCommodityOrder errorOrder = new ErrorCommodityOrder
                        {
                            Id           = Guid.NewGuid(),
                            ErrorOrderId = commodityOrder.Id,
                            ResourceType = 6,
                            Source       = 3,
                            State        = 0,
                            AppId        = commodityOrder.EsAppId.Value,
                            UserId       = shareModel.PayeeId,
                            OrderCode    = commodityOrder.Code,
                            CouponId     = Guid.Empty,
                            Score        = srore,
                            SubTime      = DateTime.Now,
                            ModifiedOn   = DateTime.Now,
                            ScoreType    = (int)scoreCostDto.ScoreType,
                            EntityState  = System.Data.EntityState.Added
                        };
                        contextSession.SaveObject(errorOrder);
                    }
                    return(refundScoreResult);
                }
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// 获取众销入账信息
        /// </summary>
        /// <param name="search">查询类</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneyResultDTO GetShareOrderMoneyInfoExt(Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneySearchDTO search)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.ShareOrderMoneyResultDTO result = new ShareOrderMoneyResultDTO();

            if (search == null || search.UseId == Guid.Empty || search.AppId == Guid.Empty || search.PageIndex < 1 || search.PageSize < 1)
            {
                return(result);
            }

            //售中待收益
            var orderStates = new List <int>()
            {
                1, 2, 8, 9, 10, 12, 13, 14
            };
            //售后待收益
            var orderAfterStates = new List <int>()
            {
                3, 5, 10, 12, 13
            };

            //已收益
            if (search.SearchType == 1)
            {
                var query = from orderShare in OrderShare.ObjectSet()
                            join order in CommodityOrder.ObjectSet()
                            on orderShare.OrderId equals order.Id
                            join dataS in CommodityOrderService.ObjectSet()
                            on orderShare.OrderId equals dataS.Id
                            into tempS
                            from orderService in tempS.DefaultIfEmpty()
                            where
                            orderShare.PayeeId == search.UseId && orderShare.PayeeType == search.PayeeType && orderShare.Commission > 0 &&
                            order.EsAppId == search.AppId && order.State == 3 && orderService.State == 15
                            select new ShareOrderMoneyDTO
                {
                    SortTime = orderService.EndTime.Value,
                    Money    = orderShare.Commission,
                    State    = 0,
                    SrcType  = order.SrcType
                };
                result.Count = query.Count();



                result.ShareOrderMoneyList = query.OrderByDescending(n => n.SortTime).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();
            }
            //待收益
            else if (search.SearchType == 2)
            {
                var query = from orderShare in OrderShare.ObjectSet()
                            join order in CommodityOrder.ObjectSet()
                            on orderShare.OrderId equals order.Id
                            join dataS in CommodityOrderService.ObjectSet()
                            on orderShare.OrderId equals dataS.Id
                            into tempS
                            from orderService in tempS.DefaultIfEmpty()
                            where
                            orderShare.PayeeId == search.UseId && orderShare.PayeeType == search.PayeeType && orderShare.Commission > 0 &&
                            order.EsAppId == search.AppId && (orderStates.Contains(order.State) ||
                                                              order.State == 3 && orderService.State != null &&
                                                              orderAfterStates.Contains(orderService.State))
                            select new ShareOrderMoneyDTO
                {
                    SortTime = order.PaymentTime.Value,
                    Money    = orderShare.Commission,
                    State    = 1,
                    SrcType  = order.SrcType
                };
                result.Count = query.Count();
                result.ShareOrderMoneyList =
                    query.OrderByDescending(n => n.SortTime)
                    .Skip((search.PageIndex - 1) * search.PageSize)
                    .Take(search.PageSize)
                    .ToList();
            }
            else
            {
            }

            return(result);
        }
コード例 #4
0
ファイル: SignSV.cs プロジェクト: GSIL-Monitor/BTP
        /// <summary>
        /// 售后完成三级分销打积分
        /// </summary>
        /// <param name="contextSession"></param>
        /// <param name="commodityOrder"></param>
        /// <param name="commodityOrderService"></param>
        /// <returns></returns>
        public static bool DistributeSaleGiveScore(ContextSession contextSession, CommodityOrder commodityOrder, CommodityOrderService commodityOrderService)
        {
            if (!commodityOrder.EsAppId.HasValue)
            {
                return(true);
            }
            List <int> payeeTypeList = new List <int>()
            {
                9, 10, 11
            };
            //取得三级分销应分的积分记录
            var osQuery =
                OrderShare.ObjectSet()
                .Where(
                    t =>
                    t.OrderId == commodityOrder.Id && t.Commission > 0 && payeeTypeList.Contains(t.PayeeType))
                .ToList();

            //使用了积分
            if (osQuery.Any())
            {
                //获取当时的积分比例
                CostScoreInfoDTO scoreCostDto;
                if (new ScoreSV().GetScoreCost(commodityOrder.EsAppId.Value, out scoreCostDto, commodityOrder.SubTime))
                {
                    bool isAllSuccess = true;
                    foreach (var orderShare in osQuery)
                    {
                        int  srore             = (int)(orderShare.Commission * scoreCostDto.Cost);
                        bool refundScoreResult = SignSV.Instance.GiveScoreBtpShare(orderShare.PayeeId, commodityOrder.AppId, srore, commodityOrder.Id, commodityOrder.Code, Jinher.AMP.Sign.Deploy.Enum.ScoringType.BtpDistributeSale, orderShare.Commission, scoreCostDto.Cost, scoreCostDto.ScoreType);
                        if (!refundScoreResult)
                        {
                            isAllSuccess = false;
                            LogHelper.Error(string.Format("售售后完成三级分销打积分失败。UserId:{0},AppId:{1},srore:{2},OrderId:{3}", orderShare.PayeeId, commodityOrder.AppId, srore, commodityOrder.Id));
                            ErrorCommodityOrder errorOrder = new ErrorCommodityOrder();
                            errorOrder.Id           = Guid.NewGuid();
                            errorOrder.ErrorOrderId = commodityOrder.Id;
                            if (orderShare.PayeeType == 9)
                            {
                                errorOrder.ResourceType = 2;
                            }
                            else if (orderShare.PayeeType == 10)
                            {
                                errorOrder.ResourceType = 3;
                            }
                            else if (orderShare.PayeeType == 11)
                            {
                                errorOrder.ResourceType = 4;
                            }
                            errorOrder.Source      = 3;
                            errorOrder.State       = 0;
                            errorOrder.AppId       = commodityOrder.AppId;
                            errorOrder.UserId      = orderShare.PayeeId;
                            errorOrder.OrderCode   = commodityOrder.Code;
                            errorOrder.CouponId    = Guid.Empty;
                            errorOrder.Score       = srore;
                            errorOrder.SubTime     = DateTime.Now;
                            errorOrder.ModifiedOn  = DateTime.Now;
                            errorOrder.ScoreType   = (int)scoreCostDto.ScoreType;
                            errorOrder.EntityState = System.Data.EntityState.Added;
                            contextSession.SaveObject(errorOrder);
                        }
                    }

                    return(isAllSuccess);
                }
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// 获取分销商佣金入账信息
        /// </summary>
        /// <param name="distributeMoneySearch"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.DistributorMoneyResultDTO GetDistributorMoneyInfoExt(Jinher.AMP.BTP.Deploy.CustomDTO.DistributeMoneySearch distributeMoneySearch)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.DistributorMoneyResultDTO result = new DistributorMoneyResultDTO();

            if (distributeMoneySearch == null || distributeMoneySearch.DistributorId == Guid.Empty || distributeMoneySearch.PageIndex < 0 || distributeMoneySearch.PageSize < 1)
            {
                return(result);
            }
            var payeeType = new List <int>()
            {
                9, 10, 11
            };
            var orderStates = new List <int>()
            {
                1, 2, 8, 9, 10, 12, 13, 14
            };
            var orderAfterStates = new List <int>()
            {
                3, 5, 10, 12, 13
            };

            var distributorId = distributeMoneySearch.DistributorId.ToString();

            //佣金累计 查已收益佣金
            if (distributeMoneySearch.SearchType == 1)
            {
                var query = from os in OrderShare.ObjectSet()
                            join orderService in CommodityOrderService.ObjectSet()
                            on os.OrderId equals orderService.Id
                            where
                            payeeType.Contains(os.PayeeType) &&
                            os.ShareKey == distributorId && os.Commission > 0 &&
                            orderService.State == 15
                            select new DistributorMoneyDTO
                {
                    DistributorId = distributeMoneySearch.DistributorId,
                    SortTime      = orderService.EndTime.Value,
                    Money         = os.Commission,
                    State         = 0
                };
                result.Count = query.Count();
                result.DistributorMoneyList = query.OrderByDescending(n => n.SortTime).Skip((distributeMoneySearch.PageIndex - 1) * distributeMoneySearch.PageSize).Take(distributeMoneySearch.PageSize).ToList();
            }
            //待收益
            else if (distributeMoneySearch.SearchType == 2)
            {
                var query = from os in OrderShare.ObjectSet()
                            join order in CommodityOrder.ObjectSet()
                            on os.OrderId equals order.Id
                            join dataS in CommodityOrderService.ObjectSet()
                            on os.OrderId equals dataS.Id
                            into tempS
                            from orderService in tempS.DefaultIfEmpty()
                            where
                            payeeType.Contains(os.PayeeType) &&
                            os.ShareKey == distributorId && os.Commission > 0 &&
                            (orderStates.Contains(order.State) ||
                             (order.State == 3 && orderService.State != null && orderAfterStates.Contains(orderService.State)))
                            select new DistributorMoneyDTO
                {
                    DistributorId = distributeMoneySearch.DistributorId,
                    SortTime      = order.PaymentTime.Value,
                    Money         = os.Commission,
                    State         = 1
                };
                result.Count = query.Count();
                result.DistributorMoneyList = query.OrderByDescending(n => n.SortTime).Skip((distributeMoneySearch.PageIndex - 1) * distributeMoneySearch.PageSize).Take(distributeMoneySearch.PageSize).ToList();
            }
            else
            {
                //
            }
            return(result);
        }
コード例 #6
0
        /// <summary>
        /// 查询分销统计信息
        /// </summary>
        /// <param name="search">查询类</param>
        /// <returns>结果</returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.DistributorProfitsResultDTO GetDistributorProfitsExt(Jinher.AMP.BTP.Deploy.CustomDTO.DistributorProfitsSearchDTO search)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.DistributorProfitsResultDTO result = new Deploy.CustomDTO.DistributorProfitsResultDTO();

            if (search == null)
            {
                return(result);
            }
            //查询等级。0:本人;1:一级;2:二级
            if (search.SearchType == 0)
            {
                var getResult = DSSBP.Instance.GetDistributorProfits(search);
                if (getResult != null && getResult.ResultCode == 200 && getResult.Data != null)
                {
                    result = getResult.Data;
                }
                if (result.DistributorProfitsInfoList == null || !result.DistributorProfitsInfoList.Any())
                {
                    result.DistributorProfitsInfoList = new List <DistributorProfitsInfoDTO>();
                    result.DistributorProfitsInfoList.Add(new DistributorProfitsInfoDTO());
                }
                //待收益佣金、已收益佣金改为btp实时计算
                //本人只返回一条数据,这里只处理第一条数据
                result.DistributorProfitsInfoList.First().CommmissionUnPay =
                    (from orderShare in OrderShare.ObjectSet()
                     join order in CommodityOrder.ObjectSet() on orderShare.OrderId equals order.Id
                     join os in CommodityOrderService.ObjectSet() on orderShare.OrderId equals os.Id into tmp
                     from orderService in tmp.DefaultIfEmpty()
                     where new[] { 9, 10, 11 }.Contains(orderShare.PayeeType)
                     &&
                     (
                         new[] { 1, 2, 8, 9, 10, 12, 13, 14 }.Contains(order.State)
                         ||
                         (
                             order.State == 3 && new[] { 3, 5, 10, 12, 13 }.Contains(orderService.State)
                         )
                     )
                     &&
                     orderShare.PayeeId == search.UserId
                     &&
                     order.AppId == search.AppId
                     select orderShare.Commission).ToList().Sum();

                result.DistributorProfitsInfoList.First().CommissionAmount =
                    (from orderShare in OrderShare.ObjectSet()
                     join order in CommodityOrder.ObjectSet() on orderShare.OrderId equals order.Id
                     join os in CommodityOrderService.ObjectSet() on orderShare.OrderId equals os.Id into tmp
                     from orderService in tmp.DefaultIfEmpty()
                     where new[] { 9, 10, 11 }.Contains(orderShare.PayeeType) && order.State == 3
                     &&
                     (
                         orderService.Id == null
                         ||
                         orderService.State == 15
                     )
                     &&
                     orderShare.PayeeId == search.UserId
                     &&
                     order.AppId == search.AppId
                     select orderShare.Commission).ToList().Sum();
            }
            else if (search.SearchType == 1)
            {
                var getResult = DSSBP.Instance.GetDistributorList(search);
                if (getResult != null && getResult.ResultCode == 200 && getResult.Data != null)
                {
                    result = getResult.Data;
                }
            }
            else if (search.SearchType == 2)
            {
                var getResult = DSSBP.Instance.GetDistributorList(search);
                if (getResult != null && getResult.ResultCode == 200 && getResult.Data != null)
                {
                    result = getResult.Data;
                }
            }

            return(result);
        }