Esempio n. 1
0
        /// <summary>
        /// 订单操作时候,发送通知(Email,Message)的操作
        /// </summary>
        protected string OrderOperateSendEmail(OrderInfo order, OrderOperate orderOperate)
        {
            string result        = string.Empty;
            string key           = string.Empty;
            int    isSendNotice  = (int)BoolType.False;
            int    isSendEmail   = (int)BoolType.False;
            int    isSendMessage = (int)BoolType.False;

            switch (orderOperate)
            {
            case OrderOperate.Pay:
                isSendNotice  = ShopConfig.ReadConfigInfo().PayOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().PayOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().PayOrderMsg;
                key           = "PayOrder";
                break;

            case OrderOperate.Cancle:
                isSendNotice  = ShopConfig.ReadConfigInfo().CancleOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().CancleOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().CancleOrderMsg;
                key           = "CancleOrder";
                break;

            case OrderOperate.Check:
                isSendNotice  = ShopConfig.ReadConfigInfo().CheckOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().CheckOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().CheckOrderMsg;
                key           = "CheckOrder";
                break;

            case OrderOperate.Send:
                isSendNotice  = ShopConfig.ReadConfigInfo().SendOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().SendOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().SendOrderMsg;
                key           = "SendOrder";
                break;

            case OrderOperate.Received:
                isSendNotice  = ShopConfig.ReadConfigInfo().ReceivedOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ReceivedOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ReceivedOrderMsg;
                key           = "ReceivedOrder";
                break;

            case OrderOperate.Change:
                isSendNotice  = ShopConfig.ReadConfigInfo().ChangeOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ChangeOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ChangeOrderMsg;
                key           = "ChangeOrder";
                break;

            case OrderOperate.Return:
                isSendNotice  = ShopConfig.ReadConfigInfo().ReturnOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().ReturnOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().ReturnOrderMsg;
                key           = "ReturnOrder";
                break;

            case OrderOperate.Back:
                isSendNotice  = ShopConfig.ReadConfigInfo().BackOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().BackOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().BackOrderMsg;
                key           = "BackOrder";
                break;

            case OrderOperate.Refund:
                isSendNotice  = ShopConfig.ReadConfigInfo().RefundOrder;
                isSendEmail   = ShopConfig.ReadConfigInfo().RefundOrderEmail;
                isSendMessage = ShopConfig.ReadConfigInfo().RefundOrderMsg;
                key           = "RefundOrder";
                break;

            default:
                break;
            }
            if (isSendNotice == (int)BoolType.True && key != string.Empty)
            {
                if (isSendEmail == (int)BoolType.True)
                {//发邮件
                    try
                    {
                        EmailContentInfo    emailContent    = EmailContentHelper.ReadSystemEmailContent(key);
                        EmailSendRecordInfo emailSendRecord = new EmailSendRecordInfo();
                        emailSendRecord.Title     = emailContent.EmailTitle;
                        emailSendRecord.Content   = emailContent.EmailContent.Replace("$UserName$", order.UserName).Replace("$OrderNumber$", order.OrderNumber).Replace("$PayName$", order.PayName).Replace("$ShippingName$", ShippingBLL.Read(order.ShippingId).Name).Replace("$ShippingNumber$", order.ShippingNumber).Replace("$ShippingDate$", order.ShippingDate.ToString("yyyy-MM-dd"));
                        emailSendRecord.IsSystem  = (int)BoolType.True;
                        emailSendRecord.EmailList = order.Email;
                        emailSendRecord.IsStatisticsOpendEmail = (int)BoolType.False;
                        emailSendRecord.SendStatus             = (int)SendStatus.No;
                        emailSendRecord.AddDate  = RequestHelper.DateNow;
                        emailSendRecord.SendDate = RequestHelper.DateNow;
                        emailSendRecord.ID       = EmailSendRecordBLL.AddEmailSendRecord(emailSendRecord);
                        EmailSendRecordBLL.SendEmail(emailSendRecord);
                        result = "通知邮件已发送。";
                    }
                    catch {
                        result = "未发送通知邮件。";
                    }
                }
                if (isSendMessage == (int)BoolType.True)
                {//发短信
                    result += "未发送通知短信。";
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 按纽提交结束
        /// </summary>
        protected void ButtonEnd(OrderInfo order, string note, OrderOperate orderOperate, int startOrderStatus)
        {
            OrderBLL.AdminUpdateOrderAddAction(order, note, (int)orderOperate, startOrderStatus);

            string result = OrderOperateSendEmail(order, orderOperate);

            if (orderOperate == OrderOperate.Pay)
            {
                #region 拼团订单付款:团长付款--开团+增加参团记录;成员付款--增加参团记录
                if (order.IsActivity == (int)OrderKind.GroupBuy)
                {
                    var orderDetail = OrderDetailBLL.ReadList(order.Id).FirstOrDefault() ?? new OrderDetailInfo();
                    if (orderDetail.Id > 0)
                    {
                        var product = ProductBLL.Read(orderDetail.ProductId);
                        //团长付款
                        if (order.FavorableActivityId <= 0)
                        {
                            //开团
                            int groupId = GroupBuyBLL.Add(new GroupBuyInfo
                            {
                                Leader    = order.UserId,
                                ProductId = product.Id,
                                StartTime = DateTime.Now,
                                EndTime   = DateTime.Now.AddDays(ShopConfig.ReadConfigInfo().GroupBuyDays),
                                Quantity  = product.GroupQuantity,
                                //团购订单支付成功之后计数加1
                                SignCount = 1
                            });
                            //订单绑定团购Id
                            Dictionary <string, object> dict = new Dictionary <string, object>();
                            dict.Add("[FavorableActivityId]", groupId);
                            OrderBLL.UpdatePart("[Order]", dict, order.Id);
                            //增加参团记录
                            GroupSignBLL.Add(new GroupSignInfo
                            {
                                GroupId  = groupId,
                                UserId   = order.UserId,
                                OrderId  = order.Id,
                                SignTime = DateTime.Now
                            });
                        }
                        else//参团者付款
                        {
                            //增加参团记录
                            GroupSignBLL.Add(new GroupSignInfo
                            {
                                GroupId  = order.FavorableActivityId,
                                UserId   = order.UserId,
                                OrderId  = order.Id,
                                SignTime = DateTime.Now
                            });
                            //开团表signcount加1
                            GroupBuyBLL.PlusSignCount(order.FavorableActivityId);
                        }
                    }
                }
                #endregion
                #region 自提订单 生成提货码
                //避免重复数据,一个订单对应一个提货码,提货码没有有效期,使用过后失效
                if (order.SelfPick == 1 && PickUpCodeBLL.ReadByOrderId(order.Id).Id <= 0)
                {
                    PickUpCodeInfo pkCode = new PickUpCodeInfo();
                    pkCode.OrderId  = order.Id;
                    pkCode.Status   = 0;
                    pkCode.PickCode = PickUpCodeBLL.CreatePickUpCode();
                    int pickCodeId = PickUpCodeBLL.Add(pkCode);
                    //if (pickCodeId <= 0)
                    //{
                    //    return Json(new { flag = false, msg = "生成提货码失败" });
                    //}
                }
                #endregion
                //付款操作时触发sianalr
                ScriptHelper.Alert("订单" + ShopLanguage.ReadLanguage("OperateOK") + "。" + result, RequestHelper.RawUrl.IndexOf("?") >= 0 ? RequestHelper.RawUrl + "&paysuccess=1" : RequestHelper.RawUrl + "?paysuccess=1");
            }
            else
            {
                ScriptHelper.Alert("订单" + ShopLanguage.ReadLanguage("OperateOK") + "。" + result, RequestHelper.RawUrl);
            }
        }