Пример #1
0
 /// <summary>
 /// 同意销售员申请
 /// </summary>
 /// <param name="memberIds"></param>
 /// <param name="remark"></param>
 public static void AgreeDistributor(IEnumerable <long> memberIds, string remark)
 {
     _iDistributionService.AgreeDistributor(memberIds, remark);
     //发送短信通知
     Task.Factory.StartNew(() =>
     {
         foreach (var item in memberIds)
         {
             var uobj = MemberApplication.GetMember(item);
             MessageApplication.SendMessageOnDistributorAuditSuccess(item, uobj.UserName);
         }
     });
 }
Пример #2
0
        /// <summary>
        /// 发送短信,根据搜索条件
        /// </summary>
        /// <param name="query"></param>
        /// <param name="couponIds"></param>
        public static void SendMsg(MemberPowerQuery query, string sendCon, string labelinfos = "会员分组")
        {
            var messagePlugin = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.SMS");
            int result        = 0;

            //循环执行发送
            for (int i = 0; i < int.MaxValue; i++)
            {
                query.PageNo   = i + 1;
                query.PageSize = 1000;
                var members = MemberApplication.GetPurchasingPowerMember(query);

                string[]      dests  = members.Models.Select(e => e.CellPhone).ToArray();
                List <string> phones = new List <string>();
                foreach (var dest in dests)
                {
                    if (messagePlugin.Biz.CheckDestination(dest))
                    {
                        phones.Add(dest);
                        result++;
                    }
                }

                messagePlugin.Biz.SendMessages(phones.ToArray(), sendCon);

                if (members.Models.Count == 0)
                {
                    break;
                }
            }

            //记录发送历史
            if (result > 0)
            {
                var sendRecord = new Himall.Model.SendMessageRecordInfo
                {
                    ContentType = Himall.CommonModel.WXMsgType.wxcard,
                    MessageType = Himall.CommonModel.MsgType.Coupon,
                    SendContent = "",
                    SendState   = 1,
                    SendTime    = DateTime.Now,
                    ToUserLabel = labelinfos                     //"会员分组"
                };
                WXMsgTemplateApplication.AddSendRecord(sendRecord);
            }
            else
            {
                throw new HimallException("此标签下无符发送的会员;");
            }
        }
Пример #3
0
        /// <summary>
        /// 申请成为销售员
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="shopLogo"></param>
        /// <param name="shopName"></param>
        /// <returns></returns>
        public static DistributorInfo ApplyDistributor(long memberId, string shopLogo, string shopName)
        {
            DistributorInfo result = _iDistributionService.GetDistributor(memberId);
            bool            isadd  = false;

            if (result == null)
            {
                result = new DistributorInfo();
                isadd  = true;
                result.ProductCount     = 0;
                result.OrderCount       = 0;
                result.SettlementAmount = 0;
            }
            result.MemberId           = memberId;
            result.ShopLogo           = shopLogo;
            result.IsShowShopLogo     = true;
            result.ShopName           = shopName;
            result.ApplyTime          = DateTime.Now;
            result.DistributionStatus = (int)DistributorStatus.UnAudit;
            if (!SiteSettingApplication.SiteSettings.DistributorNeedAudit)
            {
                result.DistributionStatus = (int)DistributorStatus.Audited;
            }
            var gradeId = GetDistributorGrades().OrderByDescending(d => d.Quota).FirstOrDefault(d => d.Quota <= result.SettlementAmount)?.Id;

            result.GradeId = gradeId ?? 0;

            if (isadd)
            {
                _iDistributionService.AddDistributor(result);
            }
            else
            {
                _iDistributionService.UpdateDistributor(result);
            }
            var uobj = MemberApplication.GetMember(result.MemberId);

            //发送短信通知
            Task.Factory.StartNew(() =>
            {
                MessageApplication.SendMessageOnDistributorApply(result.MemberId, uobj.UserName);
                if (result.DistributionStatus == (int)DistributorStatus.Audited)
                {
                    MessageApplication.SendMessageOnDistributorAuditSuccess(result.MemberId, uobj.UserName);
                }
            });
            return(result);
        }
        public static ObsoletePageModel <WeiActivityWinModel> GetActivityWin(string text, long id, int pageIndex, int pageSize)
        {
            ObsoletePageModel <WeiActivityWinInfo> weiInfo = _iWeiActivityWinService.Get(text, id, pageIndex, pageSize);

            var datas = weiInfo.Models.ToList().Select(m => new WeiActivityWinModel()
            {
                userName  = MemberApplication.GetMember(m.UserId).UserName,
                awardName = m.AwardName,
                addDate   = m.AddDate
            }).ToList();

            ObsoletePageModel <WeiActivityWinModel> t = new ObsoletePageModel <WeiActivityWinModel>();

            t.Models = datas.AsQueryable();
            t.Total  = weiInfo.Total;
            return(t);
        }
Пример #5
0
        /// <summary>
        /// 指定用户发送微信消息
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="msgtype"></param>
        /// <param name="mediaid"></param>
        /// <param name="msgcontent"></param>
        public static void SendWeiMessage(MemberPowerQuery query, string msgtype, string mediaid = "", string msgcontent = "")
        {
            Himall.CommonModel.WXMsgType type;
            if (Enum.TryParse <Himall.CommonModel.WXMsgType>(msgtype, out type))
            {
                List <string> allopenIds = new List <string>();
                //循环执行发送
                for (int i = 0; i < int.MaxValue; i++)
                {
                    query.PageNo   = i + 1;
                    query.PageSize = 1000;
                    var members = MemberApplication.GetPurchasingPowerMember(query);
                    var userIds = members.Models.Select(p => p.Id).ToArray();
                    var openIds = _iMemberService.GetOpenIdByUserIds(userIds);
                    foreach (var item in openIds)
                    {
                        allopenIds.Add(item);
                    }
                    if (members.Models.Count == 0)
                    {
                        break;
                    }
                }

                var set    = SiteSettingApplication.GetSiteSettings();
                var result = WXMsgTemplateApplication.SendWXMsg(allopenIds, type, msgcontent, mediaid, set.WeixinAppId, set.WeixinAppSecret);
                if (result.errCode == "0" || result.errMsg.Contains("success"))
                {
                    SendMessageRecordInfo sendRecord = new SendMessageRecordInfo()
                    {
                        ContentType = type,
                        MessageType = MsgType.WeiXin,
                        SendContent = msgcontent,
                        SendTime    = DateTime.Now,
                        ToUserLabel = "会员分组",
                        SendState   = 1
                    };
                    WXMsgTemplateApplication.AddSendRecord(sendRecord);
                }
                else
                {
                    throw new HimallException(result.errCode);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 查询某个会员标签列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static QueryPageModel <LabelModel> GetMemberLabelList(long userId)
        {
            var membLabels = MemberApplication.GetMemberLabels(userId);
            var pageModel  = new QueryPageModel <LabelModel>();

            if (membLabels.Count() > 0)
            {
                var ids            = membLabels.Select(e => e.LabelId);
                var labelPageModel = _iMemberLabelService.GetMemberLabelList(new LabelQuery()
                {
                    LabelIds = ids
                });
                pageModel.Models = labelPageModel.Models.Select(e => new LabelModel {
                    LabelName = e.LabelName, Id = e.Id
                }).ToList();
                pageModel.Total = labelPageModel.Total;
            }
            return(pageModel);
        }
Пример #7
0
        /// <summary>
        /// 验证码验证,认证管理员
        /// </summary>
        /// <param name="pluginId">信息类别</param>
        /// <param name="code">验证码</param>
        /// <param name="destination">联系号码</param>
        /// <param name="userId">会员ID</param>
        /// <returns></returns>
        public static int CheckShopCode(string pluginId, string code, string destination, long userId)
        {
            var member    = MemberApplication.GetMembers(userId);
            int result    = 0;
            var cache     = CacheKeyCollection.MemberPluginCheck(member.UserName, pluginId + destination);
            var cacheCode = Core.Cache.Get <string>(cache);

            if (cacheCode != null && cacheCode == code)
            {
                if (MessageApplication.GetMemberContactsInfo(pluginId, destination, Entities.MemberContactInfo.UserTypes.General) != null)
                {
                    result = -1;
                }
                else
                {
                    if (pluginId.ToLower().Contains("email"))
                    {
                        member.Email = destination;
                    }
                    else if (pluginId.ToLower().Contains("sms"))
                    {
                        member.CellPhone = destination;
                    }

                    MemberApplication.UpdateMember(member);

                    MessageApplication.UpdateMemberContacts(new Entities.MemberContactInfo()
                    {
                        Contact         = destination,
                        ServiceProvider = pluginId,
                        UserId          = userId,
                        UserType        = Entities.MemberContactInfo.UserTypes.General
                    });

                    Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(member.UserName, pluginId));
                    Core.Cache.Remove(CacheKeyCollection.Member(userId));//移除用户缓存
                    Core.Cache.Remove("Rebind" + userId);
                    result = 1;
                }
            }
            return(result);
        }
Пример #8
0
        /// <summary>
        /// 支付提现
        /// </summary>
        public static void PaymentWithdraw(long withdrawId)
        {
            var model = Service.GetWithdraw(withdrawId);

            try
            {
                switch (model.WithdrawType)
                {
                case DistributionWithdrawType.Alipay:
                    var result = Payment(DistributionWithdrawType.Alipay, model.WithdrawAccount, model.Amount, $"(单号 {withdrawId})", model.Id.ToString(), model.WithdrawName);
                    Service.SuccessWithdraw(withdrawId, result.TradNo.ToString());
                    break;

                case DistributionWithdrawType.Capital:
                    var no = MemberCapitalApplication.BrokerageTransfer(model.MemberId, model.Amount, $"(单号 {withdrawId})", model.Id.ToString());
                    Service.SuccessWithdraw(withdrawId, no.ToString());
                    break;

                case DistributionWithdrawType.WeChat:
                    var resultWechat = Payment(DistributionWithdrawType.WeChat, model.WithdrawAccount, model.Amount, $"(单号 {withdrawId})", model.Id.ToString());
                    Service.SuccessWithdraw(withdrawId, resultWechat.TradNo.ToString());
                    break;
                }
            }
            catch (Exception ex)
            {
                //支付失败(回滚提现状态)
                Service.FailWithdraw(withdrawId, ex.Message);
                throw ex;
            }
            //发送消息
            var member  = MemberApplication.GetMember(model.MemberId);
            var message = new MessageWithDrawInfo();

            message.UserName  = member != null ? member.UserName : "";
            message.Amount    = model.Amount;
            message.ApplyType = model.WithdrawType.GetHashCode();
            message.ApplyTime = model.ApplyTime;
            message.Remark    = model.Remark;
            message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;
            Task.Factory.StartNew(() => ServiceProvider.Instance <IMessageService> .Create.SendMessageOnDistributionMemberWithDrawSuccess(model.MemberId, message));
        }
Пример #9
0
        /// <summary>
        /// 根据查询条件分页获取会员信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static QueryPageModel <DTO.Members> GetMemberList(MemberQuery query)
        {
            if (query.GradeId.HasValue)
            {
                var expenditureRange = MemberApplication.GetMemberGradeRange(query.GradeId.Value);
                query.MinIntegral = expenditureRange.MinIntegral;
                query.MaxIntegral = expenditureRange.MaxIntegral;
            }
            var list    = _iMemberService.GetMembers(query);
            var members = Mapper.Map <QueryPageModel <DTO.Members> >(list);
            var grades  = MemberGradeApplication.GetMemberGradeList();

            foreach (var m in members.Models)
            {
                var memberIntegral = MemberIntegralApplication.GetMemberIntegral(m.Id);
                m.GradeName = MemberGradeApplication.GetMemberGradeByIntegral(grades, memberIntegral.HistoryIntegrals).GradeName;
                if (memberIntegral != null)
                {
                    m.AvailableIntegral = memberIntegral.AvailableIntegrals;
                    m.HistoryIntegral   = memberIntegral.HistoryIntegrals;
                }
            }
            return(members);
        }
Пример #10
0
        /// <summary>
        /// 发送优惠券,根据搜索条件
        /// </summary>
        /// <param name="query"></param>
        /// <param name="couponIds"></param>
        public static void SendCoupon(MemberPowerQuery query, IEnumerable <long> couponIds, string labelinfos = "")
        {
            var     siteName = SiteSettingApplication.GetSiteSettings().SiteName;
            decimal price    = 0;
            string  result   = "";

            //会员领取优惠券记录ID
            //   List<long> memberCouponIds = new List<long>();
            // dictResult = new Dictionary<string, int>();

            query.PageSize = 500;
            query.PageNo   = 1;

            var pageMode = MemberApplication.GetPurchasingPowerMember(query);

            if (pageMode.Total > 0)
            {
                var mUserMember = new List <MemberPurchasingPower>();
                while (pageMode.Models.Count() > 0)//循环批量获取用户信息
                {
                    //   string[] dests = pageMode.Models.Select(e => e.).ToArray();
                    foreach (var item in pageMode.Models)
                    {
                        mUserMember.Add(item);
                    }
                    query.PageNo += 1;
                    pageMode      = MemberApplication.GetPurchasingPowerMember(query);
                }


                var model = _iCouponService.GetCouponInfo(couponIds.ToArray());//获取所选优惠券集合

                //查询优惠券领取状况
                var mCouponRecord = _iCouponService.GetCouponRecordTotal(couponIds.ToArray());

                List <SendmessagerecordCouponInfo> lsendInfo = new List <SendmessagerecordCouponInfo>();
                //验证优惠券是否充足
                foreach (var item in model)
                {
                    price += item.Price;
                    lsendInfo.Add(new SendmessagerecordCouponInfo()
                    {
                        CouponId = item.Id
                    });
                    if ((item.Num - item.Himall_CouponRecord.Count()) < mUserMember.Count)
                    {
                        result = item.CouponName + "优惠券的数量不足,无法赠送";
                        break;
                    }
                }
                if (result == "")
                {
                    //发送优惠券
                    bool alTotal = false;
                    for (int i = 0; i < mUserMember.Count; i++)
                    {
                        bool suTotal = false;//会员发送优惠券成功数
                        foreach (var item in model)
                        {
                            //判断会员领取限制,是否可领取此优惠券
                            bool isf = true;
                            if (item.PerMax > 0)
                            {
                                int total = mCouponRecord.Where(p => p.UserId == mUserMember[i].Id && p.CouponId == item.Id).ToList().Count;
                                if (item.PerMax <= total)
                                {
                                    isf = false;
                                }
                            }

                            if (isf)
                            {
                                suTotal = true;
                                alTotal = true;

                                CouponRecordInfo info = new CouponRecordInfo();
                                info.UserId   = mUserMember[i].Id;
                                info.UserName = mUserMember[i].UserName;
                                info.ShopId   = item.ShopId;
                                info.CouponId = item.Id;
                                _iCouponService.AddCouponRecord(info);
                            }
                        }

                        if (suTotal)
                        {
                            MessageCouponInfo info = new MessageCouponInfo();
                            info.Money    = price;
                            info.SiteName = siteName;
                            info.UserName = mUserMember[i].UserName;
                            MessageApplication.SendMessageOnCouponSuccess(mUserMember[i].Id, info);
                        }
                    }

                    Log.Debug("sendCoupon:" + alTotal);
                    //查看成功发送会员数
                    if (alTotal)
                    {
                        //记录发送历史
                        var sendRecord = new Himall.Model.SendMessageRecordInfo
                        {
                            ContentType = WXMsgType.wxcard,
                            MessageType = MsgType.Coupon,
                            SendContent = "",
                            SendState   = 1,
                            SendTime    = DateTime.Now,
                            ToUserLabel = labelinfos == null ? "" : labelinfos,
                            Himall_SendmessagerecordCoupon = lsendInfo
                        };
                        WXMsgTemplateApplication.AddSendRecord(sendRecord);
                    }
                    else
                    {
                        result = "此标签下无符合领取此优惠券的会员";
                    }
                }
            }
            else
            {
                result = "该标签下无任何会员";
            }


            if (!string.IsNullOrWhiteSpace(result))
            {
                throw new HimallException(result);
            }
        }
Пример #11
0
        /// <summary>
        /// 发送优惠券,根据会员ID
        /// </summary>
        /// <param name="userIds">发送对象</param>
        /// <param name="couponIds">优惠券名称</param>
        public static void SendCouponByUserIds(IEnumerable <long> userIds, IEnumerable <long> couponIds)
        {
            var     model         = _iCouponService.GetCouponInfo(couponIds.ToArray());
            var     siteName      = SiteSettingApplication.GetSiteSettings().SiteName;
            var     mCouponRecord = _iCouponService.GetCouponRecordTotal(couponIds.ToArray());
            var     mUserMember   = MemberApplication.GetMembers(userIds);
            decimal price         = 0;
            string  result        = "";
            List <SendmessagerecordCouponInfo> lsendInfo = new List <SendmessagerecordCouponInfo>();

            //验证优惠券是否充足
            foreach (var item in model)
            {
                price += item.Price;
                lsendInfo.Add(new SendmessagerecordCouponInfo()
                {
                    CouponId = item.Id
                });
                if ((item.Num - item.Himall_CouponRecord.Count()) < mUserMember.Count)
                {
                    result = item.CouponName + "优惠券的数量不足,无法赠送";
                    break;
                }
            }
            if (result == "")
            {
                //发送优惠券
                bool alTotal = false;
                for (int i = 0; i < mUserMember.Count; i++)
                {
                    bool suTotal = false;//会员发送优惠券成功数
                    foreach (var item in model)
                    {
                        //判断会员领取限制,是否可领取此优惠券
                        bool isf = true;
                        if (item.PerMax > 0)
                        {
                            int total = mCouponRecord.Where(p => p.UserId == mUserMember[i].Id && p.CouponId == item.Id).ToList().Count;
                            if (item.PerMax <= total)
                            {
                                isf = false;
                            }
                        }

                        if (isf)
                        {
                            suTotal = true;
                            alTotal = true;

                            CouponRecordInfo info = new CouponRecordInfo();
                            info.UserId   = mUserMember[i].Id;
                            info.UserName = mUserMember[i].UserName;
                            info.ShopId   = item.ShopId;
                            info.CouponId = item.Id;
                            _iCouponService.AddCouponRecord(info);
                        }
                    }

                    if (suTotal)
                    {
                        MessageCouponInfo info = new MessageCouponInfo();
                        info.Money    = price;
                        info.SiteName = siteName;
                        info.UserName = mUserMember[i].UserName;
                        MessageApplication.SendMessageOnCouponSuccess(mUserMember[i].Id, info);
                    }
                }

                Log.Debug("sendCoupon:" + alTotal);
                //查看成功发送会员数
                if (alTotal)
                {
                    //记录发送历史
                    var sendRecord = new Himall.Model.SendMessageRecordInfo
                    {
                        ContentType = WXMsgType.wxcard,
                        MessageType = MsgType.Coupon,
                        SendContent = "",
                        SendState   = 1,
                        SendTime    = DateTime.Now,
                        ToUserLabel = "",
                        Himall_SendmessagerecordCoupon = lsendInfo
                    };
                    WXMsgTemplateApplication.AddSendRecord(sendRecord);
                }
                else
                {
                    result = "无符合领取此优惠券的会员";
                }
            }
            else
            {
                result = "该标签下无任何会员";
            }
            if (!string.IsNullOrWhiteSpace(result))
            {
                throw new HimallException(result);
            }
        }
Пример #12
0
        /// <summary>
        /// 发送优惠券
        /// </summary>
        /// <param name="labelids">发送标签</param>
        /// <param name="labelinfos">标签名称</param>
        /// <param name="couponIds">优惠券名称</param>
        /// <returns>-1:优惠券不足;-2:请选择发送的优惠券;-3:标签中用户数为0</returns>
        public static string SendCouponMsg(string labelids, string labelinfos, string couponIds, string url)
        {
            var    messageEmali = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.Email");
            var    messageSMS   = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.SMS");
            string result       = "";

            if (!couponIds.TrimEnd(',').Equals(""))
            {
                //取出标签对应的会员信息
                long[] lids = string.IsNullOrWhiteSpace(labelids) ? null : labelids.Split(',').Select(s => long.Parse(s)).ToArray();
                int    pageNo = 1, pageSize = 100;
                var    pageMode = MemberApplication.GetMembers(new MemberQuery
                {
                    LabelId  = lids,
                    PageNo   = pageNo,
                    PageSize = pageSize
                });
                if (pageMode.Total > 0)
                {
                    List <UserMemberInfo> mUserMember = new List <UserMemberInfo>();
                    while (pageMode.Models.Count() > 0)//循环批量获取用户信息
                    {
                        string[] dests = pageMode.Models.Select(e => e.Email).ToArray();
                        foreach (var item in pageMode.Models)
                        {
                            mUserMember.Add(item);
                        }
                        pageNo  += 1;
                        pageMode = MemberApplication.GetMembers(new MemberQuery
                        {
                            LabelId  = lids,
                            PageNo   = pageNo,
                            PageSize = pageSize
                        });
                    }

                    string[] arrStr       = couponIds.TrimEnd(',').Split(',');
                    long[]   arrcouponIds = arrStr.Select(a => long.Parse(a)).ToArray();

                    var model = _iCouponService.GetCouponInfo(arrcouponIds);//获取所选优惠券集合

                    //查询优惠券领取状况
                    var mCouponRecord = _iCouponService.GetCouponRecordTotal(arrcouponIds);

                    decimal price = 0;
                    List <SendmessagerecordCouponInfo>   lsendInfo = new List <SendmessagerecordCouponInfo>();
                    List <SendmessagerecordCouponSNInfo> lsendSN   = new List <SendmessagerecordCouponSNInfo>();
                    //验证优惠券是否充足
                    foreach (var item in model)
                    {
                        price += item.Price;
                        lsendInfo.Add(new SendmessagerecordCouponInfo()
                        {
                            CouponId = item.Id
                        });
                        if ((item.Num - item.Himall_CouponRecord.Count()) < mUserMember.Count)
                        {
                            result = item.CouponName + "优惠券的数量不足,无法赠送";
                            break;
                        }
                    }
                    var siteName = ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName;

                    if (result == "")
                    {
                        //发送优惠券
                        bool alTotal = false;
                        for (int i = 0; i < mUserMember.Count; i++)
                        {
                            bool suTotal = false;//会员发送优惠券成功数
                            foreach (var item in model)
                            {
                                //判断会员领取限制,是否可领取此优惠券
                                bool isf = true;
                                if (item.PerMax > 0)
                                {
                                    int total = mCouponRecord.Where(p => p.UserId == mUserMember[i].Id && p.CouponId == item.Id).ToList().Count;
                                    if (item.PerMax <= total)
                                    {
                                        isf = false;
                                    }
                                }

                                if (isf)
                                {
                                    suTotal = true;
                                    alTotal = true;

                                    CouponRecordInfo info = new CouponRecordInfo();
                                    info.UserId   = mUserMember[i].Id;
                                    info.UserName = mUserMember[i].UserName;
                                    info.ShopId   = item.ShopId;
                                    info.CouponId = item.Id;
                                    var couponRecord = _iCouponService.AddCouponRecord(info);
                                    lsendSN.Add(new SendmessagerecordCouponSNInfo()
                                    {
                                        CouponSN = couponRecord.CounponSN
                                    });
                                }
                            }

                            if (suTotal)
                            {
                                MessageCouponInfo info = new MessageCouponInfo();
                                info.Money    = price;
                                info.SiteName = siteName;
                                info.UserName = mUserMember[i].UserName;
                                MessageApplication.SendMessageOnCouponSuccess(mUserMember[i].Id, info);
                            }
                        }

                        Log.Debug("sendCoupon:" + alTotal);
                        //查看成功发送会员数
                        if (alTotal)
                        {
                            //记录发送历史
                            var sendRecord = new Himall.Model.SendMessageRecordInfo
                            {
                                ContentType = WXMsgType.wxcard,
                                MessageType = MsgType.Coupon,
                                SendContent = "",
                                SendState   = 1,
                                SendTime    = DateTime.Now,
                                ToUserLabel = labelinfos == null ? "" : labelinfos,
                                Himall_SendmessagerecordCoupon = lsendInfo
                            };
                            var record = WXMsgTemplateApplication.AddSendRecordItem(sendRecord);
                            foreach (var item in lsendSN)
                            {
                                item.MessageId = record.Id;
                            }
                            _iCouponService.AddSendmessagerecordCouponSN(lsendSN);
                        }
                        else
                        {
                            result = "此标签下无符合领取此优惠券的会员";
                        }
                    }
                }
                else
                {
                    result = "该标签下无任何会员";
                }
            }
            else
            {
                result = "请选择发送的优惠券";
            }
            return(result);
        }
Пример #13
0
 public static void WinnerSubmit(WeiActivityWinModel winModel)
 {
     Entities.WeiActivityInfoInfo model = _iActivityInfoService.GetActivityModel(winModel.activityId);
     //添加中奖信息记录
     Entities.WeiActivityWinInfoInfo activityWinInfo = new Entities.WeiActivityWinInfoInfo();
     activityWinInfo.ActivityId = winModel.activityId;
     activityWinInfo.AddDate    = DateTime.Now;
     activityWinInfo.UserId     = winModel.userId;
     activityWinInfo.IsWin      = winModel.isWin;
     //消耗积分
     if (winModel.integrals > 0)
     {
         var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
         Himall.Entities.MemberIntegralRecordInfo info = new Himall.Entities.MemberIntegralRecordInfo();
         info.UserName   = MemberApplication.GetMember(activityWinInfo.UserId).UserName;
         info.MemberId   = activityWinInfo.UserId;
         info.RecordDate = DateTime.Now;
         info.ReMark     = ((WeiActivityType)model.ActivityType).ToDescription() + "消耗";
         info.TypeId     = Entities.MemberIntegralInfo.IntegralType.WeiActivity;
         var memberIntegral = factoryService.Create(Himall.Entities.MemberIntegralInfo.IntegralType.WeiActivity, -winModel.integrals);
         MemberIntegralApplication.AddMemberIntegral(info, memberIntegral);
     }
     if (activityWinInfo.IsWin)
     {
         if (winModel.awardType == WeiActivityAwardType.Integral)//积分
         {
             activityWinInfo.AwardName = winModel.awardName + " 积分";
             //新增积分记录
             var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create;
             Entities.MemberIntegralRecordInfo info = new Entities.MemberIntegralRecordInfo();
             info.UserName   = MemberApplication.GetMember(activityWinInfo.UserId).UserName;
             info.MemberId   = activityWinInfo.UserId;
             info.RecordDate = DateTime.Now;
             info.ReMark     = ((WeiActivityType)model.ActivityType).ToDescription() + "中奖";
             info.TypeId     = Himall.Entities.MemberIntegralInfo.IntegralType.WeiActivity;
             var memberIntegral = factoryService.Create(Entities.MemberIntegralInfo.IntegralType.WeiActivity, Convert.ToInt32(winModel.awardName));//winModel.integrals为消耗积分 此处不是用户总积分
             MemberIntegralApplication.AddMemberIntegral(info, memberIntegral);
         }
         else if (winModel.awardType == WeiActivityAwardType.Bonus)//红包
         {
             activityWinInfo.AwardName = winModel.awardName;
             BonusApplication.SetShareByUserId(winModel.bonusId, false, winModel.userId);//添加红包记录
             BonusApplication.IncrReceiveCount(winModel.bonusId);
         }
         else
         {
             activityWinInfo.AwardName = winModel.awardName;
             //添加优惠券记录
             Entities.CouponRecordInfo recordInfo = new Entities.CouponRecordInfo();
             recordInfo.UserId   = winModel.userId;
             recordInfo.UserName = MemberApplication.GetMember(winModel.userId).UserName;
             recordInfo.ShopId   = CouponApplication.GetCouponInfo(winModel.couponId).ShopId;
             recordInfo.CouponId = winModel.couponId;
             CouponApplication.AddCouponRecord(recordInfo);
         }
     }
     else
     {
         activityWinInfo.AwardName = winModel.awardName;
     }
     activityWinInfo.AwardId = winModel.awardId;
     _iWeiActivityWinService.AddWinner(activityWinInfo);
 }
Пример #14
0
        public static List <CartItem> GetCartItems(long memberId)
        {
            var cart = GetShoppingCart(memberId);
            //会员折扣
            var discount = MemberApplication.GetMemberDiscount(memberId);

            var skuIds   = cart.Items.Select(p => p.SkuId).ToList();
            var skus     = GetService <IProductService>().GetSKUs(skuIds);
            var products = GetService <IProductService>().GetProducts(skus.Select(p => p.ProductId).ToList());
            var shops    = GetService <IShopService>().GetShops(products.Select(p => p.ShopId).ToList());
            var types    = TypeApplication.GetTypes();
            //限时购活动
            var limitProducts = LimitTimeApplication.GetPriceByProducrIds(products.Select(p => p.Id).ToList());
            //阶梯价商品
            var allLadders = GetService <IProductLadderPriceService>().GetLadderPricesByProductIds(products.Where(p => p.IsOpenLadder).Select(p => p.Id).ToList());

            var result = new List <CartItem>();

            foreach (var item in cart.Items)
            {
                var sku     = skus.FirstOrDefault(p => p.Id == item.SkuId);
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                if (product == null)
                {
                    continue;                 //忽略异常数据
                }
                var shop = shops.FirstOrDefault(p => p.Id == product.ShopId);
                var type = types.FirstOrDefault(p => p.Id == product.TypeId);
                if (sku == null || shop == null)
                {
                    continue;                             //忽略异常数据
                }
                #region 价格覆盖
                var minMach = 0;
                //阶梯价格
                if (product.IsOpenLadder)
                {
                    var ladders  = allLadders.Where(p => p.ProductId == item.ProductId).ToList();
                    var quantity = cart.Items.Where(c => c.ProductId == item.ProductId && c.ShopBranchId == 0).ToList().Sum(c => c.Quantity);
                    sku.SalePrice = ProductManagerApplication.GetProductLadderPrice(ladders, quantity);
                    minMach       = ladders.Min(p => p.MinBath);
                }

                var price = -1M;//其他价格
                //限时购价格
                var limit = limitProducts.FirstOrDefault(p => p.ProductId == item.ProductId);
                if (limit != null)
                {
                    price = limit.MinPrice;
                }
                //会员折扣
                if (price < 0 && shop.IsSelf)
                {
                    price = sku.SalePrice * discount;
                }

                if (price >= 0)
                {
                    sku.SalePrice = price;
                }
                #endregion

                //填充SKU别名
                ProductManagerApplication.FillSkuAlias(sku, product, type);
                //是否限时购
                var isLimit = limit != null;



                result.Add(new CartItem
                {
                    ItemId     = item.Id,
                    Quantity   = item.Quantity,
                    AddTime    = item.AddTime,
                    Product    = product,
                    Shop       = shop,
                    Sku        = sku,
                    ShowStatus = isLimit ? 1 : ProductManagerApplication.GetProductShowStatus(product, sku.Map <DTO.SKU>(), 1),
                    LimitId    = isLimit?limit.Id:0, //参与限时购活动ID
                    IsLimit    = isLimit,            //是否参加限时购
                    MinMach    = minMach,
                });
            }
            return(result);
        }
Пример #15
0
        /// <summary>
        /// 提现申请
        /// </summary>
        /// <param name="apply"></param>
        public static void ApplyWithdraw(DistributionApplyWithdraw apply)
        {
            if (!MemberApplication.VerificationPayPwd(apply.MemberId, apply.Password))
            {
                throw new HimallException("交易密码错误");
            }

            if (apply.Amount > SiteSettingApplication.SiteSettings.DistributorWithdrawMaxLimit)
            {
                throw new HimallException("超过最大提现额限");
            }

            if (apply.Amount < SiteSettingApplication.SiteSettings.DistributorWithdrawMinLimit)
            {
                throw new HimallException("小于最低提现额限");
            }

            var distributor = Service.GetDistributor(apply.MemberId);

            if (apply.Amount > distributor.Balance)
            {
                throw new HimallException("超过最多提现金额");
            }

            var settings = SiteSettingApplication.SiteSettings;

            if (apply.Type == DistributionWithdrawType.Alipay)
            {
                if (!settings.DistributorWithdrawTypes.ToLower().Contains("alipay"))
                {
                    throw new HimallException("暂不支持支付宝提现");
                }
                if (string.IsNullOrEmpty(apply.WithdrawAccount))
                {
                    throw new HimallException("支付宝账户不可为空");
                }
                if (string.IsNullOrEmpty(apply.WithdrawName))
                {
                    throw new HimallException("真实姓名不可为空");
                }
            }
            else if (apply.Type == DistributionWithdrawType.WeChat)
            {
                if (!settings.DistributorWithdrawTypes.ToLower().Contains("wechat"))
                {
                    throw new HimallException("暂不支持微信提现");
                }
                if (string.IsNullOrEmpty(apply.WithdrawAccount))
                {
                    throw new HimallException("尚未绑定微信,请先绑定微信账户");
                }
            }

            var info = new DistributionWithdrawInfo
            {
                Amount          = apply.Amount,
                WithdrawType    = apply.Type,
                MemberId        = apply.MemberId,
                WithdrawAccount = apply.WithdrawAccount,
                WithdrawName    = apply.WithdrawName
            };

            Service.ApplyWithdraw(info);

            //发送消息
            var member  = MemberApplication.GetMember(apply.MemberId);
            var message = new MessageWithDrawInfo();

            message.UserName  = member != null ? member.UserName : "";
            message.Amount    = info.Amount;
            message.ApplyType = info.WithdrawType.GetHashCode();
            message.ApplyTime = info.ApplyTime;
            message.Remark    = info.Remark;
            message.SiteName  = SiteSettingApplication.SiteSettings.SiteName;
            Task.Factory.StartNew(() => MessageApplication.SendMessageOnDistributionMemberWithDrawApply(apply.MemberId, message));

            //预付款提现,自动审核
            if (info.WithdrawType == DistributionWithdrawType.Capital)
            {
                AuditingWithdraw(info.Id, "System", "预存款提现,自动审核");
            }
        }