Ejemplo n.º 1
0
 /// <summary>
 /// 指定用户发送微信消息
 /// </summary>
 /// <param name="userIds"></param>
 /// <param name="msgtype"></param>
 /// <param name="mediaid"></param>
 /// <param name="msgcontent"></param>
 public static void SendWeiMessageByUserIds(long[] userIds, string msgtype, string mediaid = "", string msgcontent = "")
 {
     Himall.CommonModel.WXMsgType type;
     if (Enum.TryParse <Himall.CommonModel.WXMsgType>(msgtype, out type))
     {
         var openIds = _iMemberService.GetOpenIdByUserIds(userIds);
         if (openIds.Count() != userIds.Length && openIds.Count() < 2)
         {
             throw new HimallException("有用户未关注公众号,发送失败!");
         }
         var set    = SiteSettingApplication.GetSiteSettings();
         var result = WXMsgTemplateApplication.SendWXMsg(openIds, 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);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///分页获取待结算预约单列表
        /// </summary>
        /// <param name="orderId">预约单ID</param>
        /// <param name="shopId">诊所ID</param>
        /// <param name="StartTime">预约单完成时间</param>
        /// <param name="EndTime">预约单完成时间</param>
        ///<param name="pageNo">当前页</param>
        ///<param name="pageSize">每页显示记录数</param>
        /// <returns></returns>
        public static QueryPageModel <PendingSettlementOrders> GetPendingSettlementOrders(PendingSettlementOrderQuery query)
        {
            QueryPageModel <PendingSettlementOrders> orders = new QueryPageModel <PendingSettlementOrders>();
            var model = _iBillingService.GetPendingSettlementOrders(query);

            orders.Total = model.Total;
            Mapper.CreateMap <PendingSettlementOrdersInfo, PendingSettlementOrders>();
            orders.Models = Mapper.Map <List <PendingSettlementOrdersInfo>, List <PendingSettlementOrders> >(model.Models);
            var settlementCycle        = SiteSettingApplication.GetSiteSettings().WeekSettlement;
            var end                    = _iBillingService.GetLastSettlementTime();
            var CurrentSettlementCycle = GetDateBilingTime(settlementCycle, end, DateTime.Now); //节省一次查询

            foreach (var m in orders.Models)
            {
                m.DistributorCommission = m.DistributorCommission - m.DistributorCommissionReturn;
                m.PlatCommission        = m.PlatCommission - m.PlatCommissionReturn;
                if (m.OrderFinshTime < CurrentSettlementCycle.StartTime) //如果预约单完成时间不在当前结算周期之内
                {
                    var cycle = GetDateBilingTime(settlementCycle, end, m.OrderFinshTime);
                    m.SettlementCycle = "此预约单为" + cycle.StartTime.ToString("yyyy-MM-dd HH:mm:ss") + "至" + cycle.EndTime.ToString("yyyy-MM-dd HH:mm:ss") + "周期内预约单";
                }
            }

            return(orders);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据日期获取当前结算周期
        /// </summary>
        /// <returns></returns>
        public static SettlementCycle GetCurrentBilingTime()
        {
            var settlementCycle = SiteSettingApplication.GetSiteSettings().WeekSettlement;
            var end             = _iBillingService.GetLastSettlementTime();

            return(GetDateBilingTime(settlementCycle, end, DateTime.Now));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取微信分享参数
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static WeiXinShareArgs GetWeiXinShareArgs(string url)
        {
            var siteSettings = SiteSettingApplication.GetSiteSettings();

            if (string.IsNullOrWhiteSpace(siteSettings.WeixinAppId) || string.IsNullOrWhiteSpace(siteSettings.WeixinAppSecret))
            {
                return(null);
            }
            return(_wxApiService.GetWeiXinShareArgs(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, url));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 诊所创建支付
        /// </summary>
        /// <param name="shopId">诊所ID</param>
        /// <param name="balance">支付金额</param>
        /// <param name="webRoot">站点URL</param>
        /// <returns></returns>
        public static ChargePayModel PaymentList(long shopId, decimal balance, string webRoot)
        {
            ChargeDetailShopInfo model = new ChargeDetailShopInfo()
            {
                ChargeAmount = balance,
                ChargeStatus = Himall.Model.ChargeDetailInfo.ChargeDetailStatus.WaitPay,
                CreateTime   = DateTime.Now,
                ShopId       = shopId
            };
            long orderIds = MemberCapitalApplication.AddChargeDetailShop(model);

            ChargePayModel viewmodel = new ChargePayModel();

            //获取同步返回地址
            string returnUrl = webRoot + "/SellerAdmin/Pay/CapitalChargeReturn/{0}";

            //获取异步通知地址
            string payNotify = webRoot + "/SellerAdmin/Pay/CapitalChargeNotify/{0}";

            var payments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(item => item.Biz.SupportPlatforms.Contains(PlatformType.PC));

            const string RELATEIVE_PATH = "/Plugins/Payment/";

            var models = payments.Select(item =>
            {
                string requestUrl = string.Empty;
                try
                {
                    requestUrl = item.Biz.GetRequestUrl(string.Format(returnUrl, EncodePaymentId(item.PluginInfo.PluginId)), string.Format(payNotify, EncodePaymentId(item.PluginInfo.PluginId)), orderIds.ToString(), model.ChargeAmount, "预付款充值");
                }
                catch (Exception ex)
                {
                    Core.Log.Error("支付页面加载支付插件出错", ex);
                }
                return(new PaymentModel()
                {
                    Logo = RELATEIVE_PATH + item.PluginInfo.ClassFullName.Split(',')[1] + "/" + item.Biz.Logo,
                    RequestUrl = requestUrl,
                    UrlType = item.Biz.RequestUrlType,
                    Id = item.PluginInfo.PluginId
                });
            });

            models                  = models.Where(item => !string.IsNullOrEmpty(item.RequestUrl) && item.Id != "Himall.Plugin.Payment.WeiXinPay" && item.Id != "Himall.Plugin.Payment.WeiXinPay_Native");//只选择正常加载的插件
            viewmodel.OrderIds      = orderIds.ToString();
            viewmodel.TotalAmount   = model.ChargeAmount;
            viewmodel.Step          = 1;
            viewmodel.UnpaidTimeout = SiteSettingApplication.GetSiteSettings().UnpaidTimeout;
            viewmodel.models        = models.ToList();
            return(viewmodel);
        }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 根据会员ID发送短信
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="sendCon"></param>
        public static void SendMsgByUserIds(long[] userIds, string sendCon)
        {
            var messagePlugin = PluginsManagement.GetPlugin <IMessagePlugin>("Himall.Plugin.Message.SMS");

            var members = _iMemberService.GetMembers(userIds);

            string[]      dests  = members.Select(e => e.CellPhone).ToArray();
            List <string> phones = new List <string>();

            foreach (var dest in dests)
            {
                if (messagePlugin.Biz.CheckDestination(dest))
                {
                    phones.Add(dest);
                }
            }
            if (phones.Count == 0)
            {
                throw new HimallException("可发送的对象未空!");
            }
            var siteName = SiteSettingApplication.GetSiteSettings().SiteName;

            sendCon = sendCon + "【" + siteName + "】";
            //【TODO使用队列】
            foreach (var phone in phones)
            {
                messagePlugin.Biz.SendTestMessage(phone, sendCon);
            }

            var sendRecord = new Himall.Model.SendMessageRecordInfo
            {
                ContentType = Himall.CommonModel.WXMsgType.text,
                MessageType = Himall.CommonModel.MsgType.SMS,
                SendContent = sendCon == null ? "" : sendCon,
                SendState   = 1,
                SendTime    = DateTime.Now,
                ToUserLabel = "会员分组"
            };

            WXMsgTemplateApplication.AddSendRecord(sendRecord);
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
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);
            }
        }