Ejemplo n.º 1
0
        private bool IsAllowSend(string tenantCode, string mobile) 
        {
            SMSQueryVehicleSettingService service = new SMSQueryVehicleSettingService();
            DateTime? lastSendTime = service.GetLastSendTime(tenantCode, mobile);
            if (lastSendTime.HasValue)
            {
                DateTime lastTime = lastSendTime.Value;
                int iLastSend = Convert.ToInt32(lastTime.ToString("yyyyMMdd"));

                DateTime dtNow = DateTime.Now;
                int iNow = Convert.ToInt32(dtNow.ToString("yyyyMMdd"));

                if (iLastSend != iNow)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else 
            {
                return true;
            }
        }
Ejemplo n.º 2
0
        public void Send(string tenantCode, string content, string mobile) 
        {
            AccountServcie service = new AccountServcie();
            decimal balance = service.GetBalance(tenantCode);

            if (balance >= StaticValues.SMSFee)
            {
                //发送查车短信
                SMSSender.Send(content, mobile);

                //更新租户账户
                service.DecreaseBalance(tenantCode, StaticValues.SMSFee);

                //记录消费明细
                AccountDetailService detailService = new AccountDetailService();
                detailService.AddDetail(tenantCode, StaticValues.SMSFee, Enum.ConsumeType.SMSQuery);
            }
            else 
            {
                if (IsAllowSend(tenantCode, mobile)) 
                {
                    SMSSender.Send(StaticValues.ContentOfBalanceIsLessThan, mobile);

                    //更新最后发送短信时间
                    SMSQueryVehicleSettingService settingService = new SMSQueryVehicleSettingService();
                    settingService.UpdateLastSendTime(tenantCode, mobile);
                }
            }
        }