Esempio n. 1
0
        /// <summary>
        /// 拒收后自动申请退款
        /// </summary>
        /// <param name="orderId"></param>
        private void ApplyRefund(Guid orderId)
        {
            var order = new ISV.Facade.CommodityOrderFacade().GetOrderItems(orderId, Guid.Empty, Guid.Empty);

            if (order == null)
            {
                LogHelper.Error("进销存-拒收后自动申请退款,未获取到订单信息,入参:" + orderId);
                return;
            }
            var refundMoney = order.Price + (order.YJBPrice ?? 0) + order.ScorePrice + order.YJCouponPrice;
            var result      = new CommodityOrderSV().SubmitOrderRefundExt(new SubmitOrderRefundDTO
            {
                commodityorderId = orderId,
                Id                = orderId,
                RefundDesc        = "用户已拒收",
                RefundExpOrderNo  = string.Empty,
                RefundMoney       = refundMoney,
                RefundCouponPirce = order.YJCouponPrice,
                State             = 2,
                RefundReason      = "用户已拒收",
                RefundType        = 0,
                OrderRefundImgs   = string.Empty
            });

            if (result.ResultCode != 0)
            {
                LogHelper.Error("进销存-拒收后自动申请退款失败:" + result.Message + ",入参:" + orderId);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 妥投后自动确认收货
        /// </summary>
        /// <param name="orderId"></param>
        private void ConfirmOrder(Guid orderId)
        {
            var order = CommodityOrder.ObjectSet().FirstOrDefault(p => p.Id == orderId);

            if (order == null)
            {
                LogHelper.Error("进销存-妥投后自动确认收货:未找到订单,入参:" + orderId);
                return;
            }
            var result = new CommodityOrderSV().UpdateCommodityOrderExt(3, orderId, order.SubId, order.AppId, order.Payment, string.Empty, string.Empty);

            if (result.ResultCode != 0)
            {
                LogHelper.Error("进销存-妥投后自动确认收货失败:" + result.Message + ",入参:" + orderId);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取正品会“我的”,各栏目数量
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserInfoCountDTO GetUserInfoCountExt(Guid userId, Guid esAppId)
        {
            try
            {
                UserInfoCountDTO result = new UserInfoCountDTO()
                {
                    UserId = userId, EsAppId = esAppId
                };

                #region 订单
                CommodityOrderSV commodityOrderSV = new CommodityOrderSV();

                var orderCount = commodityOrderSV.GetOrderCountExt(userId, esAppId);
                if (orderCount != null)
                {
                    result.OrderTotalState0   = orderCount.OrderTotalState0;
                    result.OrderTotalState1   = orderCount.OrderTotalState1;
                    result.OrderTotalState2   = orderCount.OrderTotalState2;
                    result.OrderTotalState3   = orderCount.OrderTotalState3;
                    result.OrderTotalStateTui = orderCount.OrderTotalStateTui;
                }
                #endregion

                #region 收藏


                result.ColCommodityCnt = (from com in Commodity.ObjectSet()
                                          join col in SetCollection.ObjectSet() on com.Id equals col.ColKey
                                          where col.UserId == userId && col.ColType == 1 && com.State == 0 && !com.IsDel && com.CommodityType == 0 && col.ChannelId == esAppId
                                          select com.Id).Count();

                result.ColAppCnt = SetCollection.ObjectSet().Count(c => c.UserId == userId && c.ColType == 2 && c.ChannelId == esAppId);
                #endregion

                #region 预约

                try
                {
                    result.ForespeakCnt = Jinher.AMP.BTP.TPS.ZPHSV.Instance.GetMyPresellComdtyNum(userId, esAppId);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("AppSetSV.GetUserInfoCountExt。获取我的预约数量异常。 userId:{0}", userId), ex);
                }
                #endregion

                #region 金币
                result.Gold = FSPSV.Instance.GetBalance(userId);
                #endregion

                #region 浏览记录

                try
                {
                    string sql = "select count(distinct CommodityId) from UserBrowseList where appid='" + esAppId.ToString() + "' and UserId='" + userId.ToString() + "'";

                    int BrowseCount = Convert.ToInt32(Jinher.AMP.BTP.Common.SQLHelper.ExecuteScalar(SQLHelper.UserBrowse, CommandType.Text, sql, null).ToString());
                    result.BrowseCount = BrowseCount;
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("AppSetSV.GetUserInfoCountExt。获取浏览记录失败。 userId:{0},esAppId:{1}", userId, esAppId), ex);
                    result.BrowseCount = 0;
                    throw;
                }

                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("AppSetSV.GetUserInfoCountExt异常:userId:{0}", userId), ex);
                return(new UserInfoCountDTO {
                    UserId = userId, BrowseCount = -1
                });
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 佣金结算
        /// </summary>
        public void SettleCommossionExt()
        {
            try
            {
                ContextSession contextSession = ContextFactory.CurrentThreadContext;
                bool           isContinue     = true;
                int            pageSize       = 100;
                while (true)
                {
                    int shareFacadeErrCnt = 0;
                    var shares            = (from data in ShareDividend.ObjectSet()
                                             join order in CommodityOrder.ObjectSet() on data.CommodityOrderId equals order.Id
                                             join data1 in OrderShareMess.ObjectSet() on data.CommodityOrderId equals data1.OrderId into oshares
                                             from oshare in oshares.DefaultIfEmpty()
                                             join commodity in Commodity.ObjectSet() on order.SrcTagId equals commodity.Id into coms
                                             from com in coms.DefaultIfEmpty()
                                             where data.State == 0 && data.SharerMoney > 0
                                             select new
                    {
                        ShareDividend = data,
                        OrderSrcType = order.SrcType,
                        OrderSrcTagId = order.SrcTagId,
                        OrderCode = order.Code,
                        ShareId = oshare.ShareId,
                        CommodityName = com.Name,
                        OrderSrcAppId = order.SrcAppId,
                        ShareType = data.ShareType,
                        OrderId = order.Id
                    }).Take(pageSize).ToList();
                    if (!shares.Any())
                    {
                        break;
                    }

                    var shareOrderIds = shares.Where(x => x.OrderSrcType == 33).Select(x => x.OrderSrcTagId).ToList();

                    Dictionary <Guid, string> shareOrderCodes = CommodityOrder.ObjectSet()
                                                                .Where(x => shareOrderIds.Contains(x.Id))
                                                                .Select(x => new
                    {
                        Code = x.Code,
                        Id   = x.Id
                    }).ToDictionary(x => x.Id, y => y.Code);

                    for (int i = 0; i < shares.Count; i++)
                    {
                        var    share       = shares[i];
                        Guid   userId      = Guid.Empty;
                        int    roleType    = 1;
                        string description = null;
                        long   money       = share.ShareDividend.SharerMoney;
                        if (share.ShareType == 1) //应用主分成
                        {
                            try
                            {
                                if (share.OrderSrcAppId.HasValue && share.OrderSrcAppId != Guid.Empty)
                                {
                                    var result = APPSV.Instance.GetAppLevelInfo(share.OrderSrcAppId.Value.ToString());
                                    if (result == null)
                                    {
                                        continue;
                                    }
                                    var appScore = result.LevelScore;
                                    if (result.OwnerId == Guid.Empty || appScore < CustomConfig.ShareOwner.AppMinCalcScore)
                                    {
                                        share.ShareDividend.State       = 1;
                                        share.ShareDividend.EntityState = EntityState.Modified;
                                        continue;
                                    }

                                    if (result.OwnerTypeId == (int)App.Deploy.Enum.AppOwnerTypeEnum.Org)
                                    {
                                        roleType = 2;
                                    }
                                    userId = result.OwnerId;

                                    //发送消息
                                    if (result.OwnerTypeId == (int)App.Deploy.Enum.AppOwnerTypeEnum.Org)
                                    {
                                        List <Guid> OrgUserIds = Jinher.AMP.BTP.TPS.EBCSV.Instance.GetUserIdsByOrgIdAndCode(result.OwnerId, "ReceiveRed");

                                        CommodityOrderSV.SendMessageToPayment(OrgUserIds, "affirm", share.ShareDividend.SharerMoney.ToString(CultureInfo.InvariantCulture), null, 0);
                                    }
                                    else if (result.OwnerTypeId == (int)App.Deploy.Enum.AppOwnerTypeEnum.Personal)
                                    {
                                        List <Guid> userIds = new List <Guid> {
                                            result.OwnerId
                                        };
                                        CommodityOrderSV.SendMessageToPayment(userIds, "affirm", share.ShareDividend.SharerMoney.ToString(CultureInfo.InvariantCulture), null, 0);
                                    }
                                }
                                description = string.Format("正品o2o 商品销售分红获得金币{0}个", money);
                            }
                            catch (Exception ex)
                            {
                                LogHelper.Error("佣金结算服务异常:获取应用信息异常。", ex);
                                continue;
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(share.ShareId) || share.ShareId.ToLower() == "null" || share.ShareId.ToLower() == "undefined")
                            {
                                share.ShareDividend.State       = 1;
                                share.ShareDividend.EntityState = EntityState.Modified;
                                continue;
                            }
                            Jinher.AMP.SNS.Deploy.CustomDTO.ReturnInfoDTO <Guid> shareServiceResult = new SNS.Deploy.CustomDTO.ReturnInfoDTO <Guid>();

                            try
                            {
                                shareServiceResult = Jinher.AMP.BTP.TPS.SNSSV.Instance.GetShareUserId(share.ShareId);
                            }
                            catch (Exception ex)
                            {
                                shareFacadeErrCnt++;
                                LogHelper.Error(string.Format("佣金结算服务异常。调用服务:\"根据分享Id获取分享人Id\" 错误,分享Id={0}", share.ShareId), ex);
                                if (i > 5 && i == shareFacadeErrCnt - 1)
                                {
                                    isContinue = false;
                                    break;
                                }
                                continue;
                            }

                            if (shareServiceResult.Code != "0")
                            {
                                LogHelper.Error(string.Format("佣金结算服务异常。调用服务:\"根据分享Id获取分享人Id\" 不成功,分享Id={0},返回结果={1}", share.ShareId, JsonHelper.JsonSerializer(shareServiceResult)));
                                shareFacadeErrCnt++;
                                //调用服务都为异常,停止本次操作
                                if (i > 5 && i == shareFacadeErrCnt - 1)
                                {
                                    isContinue = false;
                                    break;
                                }
                                continue;
                            }
                            userId = shareServiceResult.Content;
                            switch (share.OrderSrcType)
                            {
                            case 33:
                                //description = string.Format("分享{0}商品获得金币{1}个", share.CommodityName, money);

                                if (share.OrderSrcTagId.HasValue && shareOrderCodes.ContainsKey(share.OrderSrcTagId.Value))
                                {
                                    description = string.Format("分享{0}订单获得金币{1}个", shareOrderCodes[share.OrderSrcTagId.Value], money);
                                }
                                else
                                {
                                    description = string.Format("分享订单获得金币{0}个", money);
                                }
                                break;

                            case 34:
                                //description = string.Format("分享{0}订单获得金币{1}个", share.OrderCode, money);
                                description = string.Format("分享{0}商品获得金币{1}个", share.CommodityName, money);
                                break;
                            }
                        }


                        ShareDividendDetail model = new ShareDividendDetail
                        {
                            Id              = Guid.NewGuid(),
                            UserId          = userId,
                            Money           = money,
                            SettlementDate  = share.ShareDividend.SettlementDate,
                            AppId           = share.ShareDividend.AppId,
                            RoleType        = roleType,
                            ShareDivedendId = share.ShareDividend.Id,
                            Description     = description
                        };
                        model.EntityState = EntityState.Added;
                        contextSession.SaveObject(model);

                        share.ShareDividend.State       = 1;
                        share.ShareDividend.EntityState = EntityState.Modified;
                    }
                    if (!isContinue)
                    {
                        break;
                    }
                    contextSession.SaveChanges();
                    LogHelper.Info(string.Format("佣金结算Job处理了ShareDividend表{0}条记录", shares.Count));
                    if (shares.Count < pageSize)
                    {
                        isContinue = false;
                        break;
                    }
                }

                LogHelper.Info("佣金结算Job处理成功");
            }
            catch (Exception ex)
            {
                LogHelper.Error("佣金结算服务异常。 ", ex);
            }
        }