public ActionResult SendValidCodeFJXX(string mobile, string type, bool isNewRegister = false, string guess = "")
        {
            string IP = (Request.ServerVariables["HTTP_VIA"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString() : Request.ServerVariables["REMOTE_ADDR"].ToString();

            if (Session[CAPTCHAS_TEXT] == null || string.IsNullOrEmpty(guess) || guess.ToLower() != Session[CAPTCHAS_TEXT].ToString().ToLower())
            {
                SysLogService.SaveSysLog("AliDaYu", IP, string.Format("SessionID:{0},手机号码:{1},验证码:{2}", Session.SessionID, mobile, guess), "发送短信验证码,图片验证码输入错误");
                return(Json(new { msg = "图片验证码输入错误", success = false }));
            }
            mobile = mobile.Trim();
            if (mobile.IsNullOrTrimEmpty())
            {
                return(Json(new { msg = "手机不能为空", success = false }));
            }
            if (new Regex(@"^1[3|5|7|8|4|][0-9]{9}$").IsMatch(mobile) == false)
            {
                return(Json(new { msg = "手机格式不正确", success = false }));
            }

            var pcsv       = new PhoneCodeService();
            var codeRecord = pcsv.GetPhoneCodeByMobile(mobile);

            if (codeRecord != null && (DateTime.Now - codeRecord.SendTime).TotalMinutes < 1)
            {
                return(Json(new { msg = "短信已发送,发送时间为:" + codeRecord.SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ",一分钟后重发", success = false }));
            }

            var code   = new Random().Next(100000, 999999);
            var isUsed = pcsv.IsPhoneUsed(mobile);

            if (isUsed || isNewRegister)
            { //当情况为注册过的改密码 或 新注册时
                pcsv.CreatePhoneCode(mobile, code.ToString(), "UnKnown");
                //var data = new FCake.Bll.Services.MsgTemplateService().GetMsgTempByCategory(type);
                //var result = EChiHelper.SendSMSResult(mobile, string.Format(data, code), FormatType.MobileCheckCode);
                var sendErrorMsg = string.Empty;


                SysLogService.SaveSysLog("AliDaYu", IP, string.Format("SessionID:{0},手机号码:{1},模板ID:{2}", Session.SessionID, mobile, DaYuConfig.SMSCodeCommonTemplate), "调用阿里大鱼发送手机验证码接口");

                var result = DaYuSMSHelper.SendSMSCode(mobile, code.ToString(), out sendErrorMsg);

                if (result)
                {
                    return(Json(new { msg = "短信发送成功,一小时内有效", success = true }));
                }
                else
                {
                    SysLogService.SaveAliSMSErrorLog(sendErrorMsg, mobile, DaYuConfig.SMSCodeCommonTemplate);
                }
            }
            else
            {
                return(Json(new { msg = "该手机号未绑定账户,请确认您的手机号", success = false }));
            }
            return(Json(new { msg = "短信发送失败", success = false }));
        }
        /// <summary>
        /// 配送开始短信通知
        /// </summary>
        /// <param name="orderNo"></param>
        /// <param name="msgContent"></param>
        /// <returns></returns>
        public OpResult SendBeginMessage(string orderNo, string msgTemplateId)
        {
            OpResult result = new OpResult();

            result.Successed = false;
            var order = context.Orders.Where(p => p.No.Equals(orderNo) && p.IsDeleted != 1).SingleOrDefault();

            if (order != null)
            {
                var customer = context.Customers.Where(p => p.Id.Equals(order.CustomerId) && p.IsDeleted != 1).SingleOrDefault();
                if (customer != null)
                {
                    bool rt = false;
                    if (customer.Mobile.IsNullOrTrimEmpty() == false)
                    {
                        //rt = EChiHelper.SendSMSResult(customer.Mobile, msgContent);
                        var sendSMSErrorMsg = string.Empty;
                        rt = DaYuSMSHelper.SendNotifySMS(customer.Mobile, msgTemplateId, out sendSMSErrorMsg);
                        if (!rt)
                        {
                            SysLogService.SaveAliSMSErrorLog(sendSMSErrorMsg, customer.Mobile, msgTemplateId);
                        }
                    }
                    else
                    {
                        result.Message = orderNo + "未留手机号";
                    }

                    if (rt)
                    {
                        result.Successed = true;
                    }
                    else
                    {
                        result.Message = "发送失败";
                    }
                }
                else
                {
                    result.Message = orderNo + ":查不到客户";
                }
            }
            else
            {
                result.Message = orderNo + ":查不到订单";
            }
            return(result);
        }
        /// <summary>
        /// 批量开始某段时间的配送
        /// </summary>
        /// <param name="minDate">时间段起点(默认今日开始)</param>
        /// <param name="maxDate">时间段终点(默认今日结束)</param>
        /// <returns></returns>
        public bool BegioSection(DateTime?minDate, DateTime?maxDate, string userID, bool isSMS)
        {
            var mtsv = new MsgTemplateService();

            if (minDate == null)
            {
                minDate = DateTime.Today;
            }
            if (maxDate == null)
            {
                maxDate = DateTime.Today.AddDays(1);
            }

            var dis = context.Distribution.Include("Order").Include("Order.Customers").Where(d => d.Status == StatusDistribution.DistributionPending && d.RequiredTime >= minDate && d.RequiredTime < maxDate && d.IsDeleted != 1).ToList();

            if (dis != null && dis.Count > 0)
            {
                foreach (var record in dis)
                {
                    record.Status       = StatusDistribution.Distributing;
                    record.BeginTime    = DateTime.Now;
                    record.ModifiedBy   = userID;
                    record.ModifiedOn   = DateTime.Now;
                    record.Order.Status = OrderStatus.Delivery;

                    if (isSMS)
                    {
                        try
                        {
                            //EChiHelper.SendSMS(record.Order.Customers.Mobile, string.Format(mtsv.GetMsgTempByCategory("Distribution"), record.OrderNo));
                            var sendSMSErrorMsg = string.Empty;
                            var sendResult      = DaYuSMSHelper.SendNotifySMS(record.Order.Customers.Mobile, DaYuConfig.BeginDeliveryTemplate, out sendSMSErrorMsg);
                            if (!sendResult)
                            {
                                SysLogService.SaveAliSMSErrorLog(sendSMSErrorMsg, record.Order.Customers.Mobile, DaYuConfig.BeginDeliveryTemplate);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                //todo:怎么没有修改状态代码? bug
                return(context.SaveChanges() > 0);
            }
            return(false);
        }
Exemple #4
0
        /// <summary>
        /// 完成支付
        /// </summary>
        /// <param name="orderNo">订单号</param>
        /// <param name="tradeNo">交易单号</param>
        /// <param name="feeType">交易方式</param>
        /// <param name="isReviewPass">是否默认通过审核 如果为false则待审核</param>
        /// <returns></returns>
        public void FinishOrder(string orderNo, string tradeNo, FeeType feeType, bool isReviewPass = true)
        {
            //取出订单
            var order = GetOrderByOrderNo(orderNo);

            if (order != null && order.TradeStatus == TradeStatus.NotPay)
            {
                //插入订单历史
                OrderHist oh = new OrderHist();
                oh.CopyProperty(order);
                oh.Id        = FCake.Core.Common.DataHelper.GetSystemID();
                oh.CreatedOn = DateTime.Now;
                oh.CreatedBy = order.CreatedBy;
                DAL.Entities <OrderHist>().Add(oh);
                //oh.OrderId = order.Id;
                //oh.No = order.No;
                //oh
                //变更支付状态
                //改order 状态  订单状态、支付状态,插入状态,支付状态
                //todo: 更改订单状态 逻辑?
                order.Status      = OrderStatus.HadPaid;
                order.TradeNo     = tradeNo;
                order.ActualPay   = order.TotalPrice - (order.CouponPay + order.GiftCardPay + order.IntegralPay);
                order.TradeStatus = TradeStatus.HadPaid;
                if (isReviewPass)
                {
                    if (order.ReviewStatus != ReviewStatus.ReviewPass && order.ReviewStatus != ReviewStatus.ReviewReject && order.ReviewStatus != ReviewStatus.Canceled)
                    {
                        order.ReviewStatus = ReviewStatus.ReviewPending;//付了款的订单还是要审核
                    }
                }
                else
                {
                    order.ReviewStatus = ReviewStatus.ReviewOnLineNoPay;
                }

                //order.ReviewStatus = (isReviewPass ? ReviewStatus.ReviewPending : ReviewStatus.ReviewOnLineNoPay);//付了款的订单还是要审核

                //发送短信给客户
                if (order.ReceiverMobile != "" && order.ReceiverMobile != null)
                {
                    var customer = (new CustomersService()).GetById(order.CustomerId);
                    if (customer != null)
                    {
                        try
                        {
                            //EChiHelper.SendSMS(customer.Mobile, new FCake.Bll.Services.MsgTemplateService().GetMsgTempByCategory("Pass"), FormatType.BuySuccess);
                            var sendSMSErrorMsg = string.Empty;
                            var sendResult      = DaYuSMSHelper.SendNotifySMS(customer.Mobile, DaYuConfig.OrderApproveTemplate, out sendSMSErrorMsg);
                            if (!sendResult)
                            {
                                SysLogService.SaveAliSMSErrorLog(sendSMSErrorMsg, customer.Mobile, DaYuConfig.OrderApproveTemplate);
                            }
                        }
                        catch { }
                    }
                    //EChiHelper.SendSMS(order.ReceiverMobile, FormatType.BuySuccess, new FCake.Bll.Services.MsgTemplateService().GetMsgTempByCategory("Pass"));
                }
                //提交
                DAL.Commit();
            }
        }