/// <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);
        }
Example #3
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();
            }
        }