示例#1
0
 public void SendMessageOnOrderCreate(long userId, MessageOrderInfo info)
 {
     foreach (Plugin <IMessagePlugin> list in PluginsManagement.GetPlugins <IMessagePlugin>().ToList <Plugin <IMessagePlugin> >())
     {
         if (list.Biz.GetStatus(MessageTypeEnum.OrderCreated) != StatusEnum.Open)
         {
             continue;
         }
         string destination = GetDestination(userId, list.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General);
         if (!list.Biz.CheckDestination(destination))
         {
             throw new HimallException(string.Concat(list.Biz.ShortName, "错误"));
         }
         string str = list.Biz.SendMessageOnOrderCreate(destination, info);
         if (!list.Biz.EnableLog)
         {
             continue;
         }
         DbSet <MessageLog> messageLog  = context.MessageLog;
         MessageLog         messageLog1 = new MessageLog()
         {
             SendTime       = new DateTime?(DateTime.Now),
             ShopId         = new long?(info.ShopId),
             MessageContent = str,
             TypeId         = "短信"
         };
         messageLog.Add(messageLog1);
         context.SaveChanges();
     }
 }
示例#2
0
        public string SendMessageOnOrderPay(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.OrderPay.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#Total#", info.TotalMoney.ToString("F2"));

            SendMessage(destination, info.SiteName + "订单支付成功", text);
            return(text);
        }
示例#3
0
        public string SendMessageOnOrderShipping(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str = messageContentConfig.OrderShipping.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#shippingCompany#", info.ShippingCompany).Replace("#shippingNumber", info.ShippingNumber);

            SendMessage(destination, string.Concat(info.SiteName, "订单(", info.OrderId, ")已发货"), str, false);
            return(str);
        }
示例#4
0
        //public string SendMessageOnRefundDeliver(string destination, MessageOrderInfo info)
        //{
        //    var config = EmailCore.GetMessageContentConfig();
        //    var text = config.RefundDeliver.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#RefundMoney#", info.RefundMoney.ToString("F2"));
        //    SendMessage(destination, info.SiteName + "订单(" + info.OrderId + ")售后发货提醒已处理", text);
        //    return text;
        //}

        public string SendMessageOnOrderShipping(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.OrderShipping.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#shippingCompany#", info.ShippingCompany).Replace("#shippingNumber#", info.ShippingNumber);

            SendMessage(destination, info.SiteName + "订单(" + info.OrderId + ")已发货", text);
            return(text);
        }
示例#5
0
        public string SendMessageOnOrderCreate(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = SMSCore.GetMessageContentConfig();
            string         str = messageContentConfig.OrderCreated.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);

            SendMessage(destination, str, "0");
            return(str);
        }
示例#6
0
        public string SendMessageOnSelfTakeOrderPay(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.SelfTakeOrderPay.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName).Replace("#pickupCode#", info.PickupCode);

            SendMessage(destination, info.SiteName + "自提订单支付成功", text);
            return(text);
        }
示例#7
0
        //public string SendMessageGetBrokerage(string destination, GetBrokerageInfo info)
        //{
        //    var config = EmailCore.GetMessageContentConfig();
        //    var text = config.GetBrokerage.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName).Replace("#Money#", info.Money.ToString("F2")).Replace("#GetDate#", info.GetDate);
        //    SendMessage(destination, info.SiteName + "获得一笔佣金", text);
        //    return text;
        //}

        public string SendMessageOnOrderRefund(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.OrderRefundSuccess.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#RefundMoney#", info.RefundMoney.ToString("F2"));

            SendMessage(destination, info.SiteName + "订单(" + info.OrderId + ")退款已处理", text);
            return(text);
        }
示例#8
0
        //public string SendMessageOnFindPassWord(string destination, MessageUserInfo info)
        //{
        //    var config = EmailCore.GetMessageContentConfig();
        //    var text = config.FindPassWord.Replace("#userName#", info.UserName).Replace("#checkCode#", info.CheckCode).Replace("#siteName#", info.SiteName);
        //    SendMessage(destination, info.SiteName + "找回密码验证", text);
        //    return text;
        //}

        public string SendMessageOnOrderCreate(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.OrderCreated.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);

            SendMessage(destination, info.SiteName + "订单创建成功", text);
            return(text);
        }
示例#9
0
        public string SendMessageOnOrderShipping(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = SMSCore.GetMessageContentConfig();
            string         str = messageContentConfig.OrderShipping.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#shippingCompany#", info.ShippingCompany).Replace("#shippingNumber", info.ShippingNumber);

            SendMessage(destination, str, "0");
            return(str);
        }
示例#10
0
        public string SendMessageOnFightGroupFailed(string destination, MessageOrderInfo info)
        {
            var config = SMSCore.GetMessageContentConfig();
            var text   = config.FightGroupFailed.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, text, "2");
            return(text);
        }
示例#11
0
        public string SendMessageOnAlreadyVerification(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.AlreadyVerification.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName).Replace("#orderId#", info.OrderId);

            SendMessage(destination, info.SiteName + "核销成功", text);
            return(text);
        }
示例#12
0
        public string SendMessageOnOrderRefundApply(string destination, MessageOrderInfo info)
        {
            var config = SMSCore.GetMessageContentConfig();
            var text   = config.OrderRefundApply.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, text, "2");
            return(text);
        }
示例#13
0
        public string SendMessageOnOrderCreate(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str = messageContentConfig.OrderCreated.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);

            SendMessage(destination, string.Concat(info.SiteName, "订单创建成功"), str, false);
            return(str);
        }
示例#14
0
        public string SendMessageOnRefundDeliver(string destination, MessageOrderInfo info)
        {
            var config = SMSCore.GetMessageContentConfig();
            var text   = config.RefundDeliver.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName).Replace("#RefundMoney#", info.RefundMoney.ToString("F2"));

            SendMessage(destination, text);
            return(text);
        }
示例#15
0
        public string SendMessageOnFightGroupSuccess(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.FightGroupSuccess.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, info.SiteName + "拼团成功", text);
            return(text);
        }
示例#16
0
        public string SendMessageOnOrderReturnFail(string destination, MessageOrderInfo info)
        {
            var config = EmailCore.GetMessageContentConfig();
            var text   = config.OrderReturnFail.Replace("#userName#", info.UserName).Replace("#siteName#", info.SiteName);

            SendMessage(destination, info.SiteName + "退货失败", text);
            return(text);
        }
示例#17
0
        public string SendMessageOnOrderRefund(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str         = messageContentConfig.OrderRefund.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);
            decimal        refundMoney = info.RefundMoney;
            string         str1        = str.Replace("#RefundMoney#", refundMoney.ToString("F2"));

            SendMessage(destination, string.Concat(info.SiteName, "订单(", info.OrderId, ")退款已处理"), str1, false);
            return(str1);
        }
示例#18
0
        public string SendMessageOnOrderPay(string destination, MessageOrderInfo info)
        {
            MessageContent messageContentConfig = EmailCore.GetMessageContentConfig();
            string         str        = messageContentConfig.OrderPay.Replace("#userName#", info.UserName).Replace("#orderId#", info.OrderId).Replace("#siteName#", info.SiteName);
            decimal        totalMoney = info.TotalMoney;
            string         str1       = str.Replace("#Total#", totalMoney.ToString("F2"));

            SendMessage(destination, string.Concat(info.SiteName, "订单支付成功"), str1, false);
            return(str1);
        }
示例#19
0
        /// <summary>
        /// 诊所有新预约单
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="info"></param>
        public void SendMessageOnShopHasNewOrder(long shopId, MessageOrderInfo info)
        {
            #region 发送模板消息
            //诊所收信息
            var shopinfo = Context.ManagerInfo.FirstOrDefault(d => d.ShopId == shopId);
            if (shopinfo != null)
            {
                var sellerinfo = Context.UserMemberInfo.FirstOrDefault(d => d.UserName == shopinfo.UserName);
                if (sellerinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();

#if DEBUG
                    Core.Log.Info("[模板消息]诊所新预约单用户编号:" + sellerinfo.Id.ToString());
#endif
                    msgdata                = new WX_MsgTemplateSendDataModel();
                    msgdata.first.value    = "您的诊所有新的预约单生成。";
                    msgdata.first.color    = "#000000";
                    msgdata.keyword1.value = info.ShopName;
                    msgdata.keyword1.color = "#000000";
                    msgdata.keyword2.value = info.ProductName.ToString() + "等...";
                    msgdata.keyword2.color = "#000000";
                    msgdata.keyword3.value = info.OrderTime.ToString();
                    msgdata.keyword3.color = "#000000";
                    msgdata.keyword4.value = info.TotalMoney.ToString();
                    msgdata.keyword4.color = "#FF0000";
                    msgdata.keyword5.value = "已付款(" + info.PaymentType + ")";
                    msgdata.keyword5.color = "#000000";
                    msgdata.remark.value   = "感谢您的使用,祝您生意兴荣。";
                    msgdata.remark.color   = "#000000";

#if DEBUG
                    Core.Log.Info("[模板消息]诊所新预约单开始前:" + sellerinfo.Id.ToString() + "_" + info.OrderId.ToString());
#endif
                    var _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    _iwxtser.SendMessageByTemplate(MessageTypeEnum.ShopHaveNewOrder, sellerinfo.Id, msgdata);
                }
            }
            #endregion
        }
示例#20
0
        /// <summary>
        /// 售后发货信息提醒
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="info"></param>
        /// <param name="refundid"></param>
        public void SendMessageOnRefundDeliver(long userId, MessageOrderInfo info, long refundid = 0)
        {
            var message = PluginsManagement.GetPlugins <IMessagePlugin>().ToList();

#if DEBUG
            Core.Log.Info("[发送消息]数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(info) + "[售后发货]");
#endif
            foreach (var msg in message)
            {
                if (msg.Biz.GetStatus(MessageTypeEnum.RefundDeliver) == StatusEnum.Open)
                {
                    string destination = GetDestination(userId, msg.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General);
                    if (!msg.Biz.CheckDestination(destination))
                    {
#if DEBUG
                        Core.Log.Info("[发送消息]失败:" + msg.PluginInfo.PluginId + "未发送," + destination + "格式检测未通过[售后发货]");
#endif
                        throw new HimallException(msg.Biz.ShortName + "错误:实例失败。");
                    }
                    try
                    {
                        var content = msg.Biz.SendMessageOnRefundDeliver(destination, info);
#if DEBUG
                        Core.Log.Info("[发送消息]发送结束:" + destination + " : " + msg.PluginInfo.PluginId + "[售后发货]");
#endif
                        if (msg.Biz.EnableLog)
                        {
                            Context.MessageLog.Add(new MessageLog()
                            {
                                SendTime = DateTime.Now, ShopId = info.ShopId, MessageContent = content, TypeId = "短信"
                            });
                            Context.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        Core.Log.Info("[发送消息]发送失败:" + msg.PluginInfo.PluginId + "[售后发货]", ex);
                    }
                }
            }

            #region 发送模板消息
            var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
            if (userinfo != null)
            {
                var msgdata = new WX_MsgTemplateSendDataModel();
                msgdata.first.value    = "您的预约单(" + info.OrderId + ")售后已审核通过,请及时发货。";
                msgdata.first.color    = "#000000";
                msgdata.keyword1.value = "审核通过,请您发货";
                msgdata.keyword1.color = "#FF0000";
                msgdata.keyword2.value = info.ProductName + "";
                msgdata.keyword2.color = "#000000";
                msgdata.keyword3.value = info.RefundMoney.ToString("F2");
                msgdata.keyword3.color = "#000000";
                msgdata.keyword4.value = info.Remark;
                msgdata.keyword4.color = "#000000";
                msgdata.keyword5.value = info.RefundAuditTime.ToString("yyyy-MM-dd HH:mm:ss");
                msgdata.keyword5.color = "#000000";
                msgdata.remark.value   = "感谢您的使用!";
                msgdata.remark.color   = "#000000";
                var _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                if (refundid > 0)
                {
                    string url = _iwxtser.GetMessageTemplateShowUrl(MessageTypeEnum.RefundDeliver);
                    url = url.Replace("{id}", refundid.ToString());
                }
                _iwxtser.SendMessageByTemplate(MessageTypeEnum.RefundDeliver, userId, msgdata);
            }
            #endregion
        }
示例#21
0
 public static void SendMessageOnRefundApply(long userId, MessageOrderInfo info, int refundMode, long refundid = 0)
 {
     _iMessageService.SendMessageOnRefundApply(userId, info, refundMode, refundid);
 }
 /// <summary>
 /// 订单支付
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="info"></param>
 public static void SendMessageOnOrderPay(long userId, MessageOrderInfo info)
 {
     _iMessageService.SendMessageOnOrderPay(userId, info);
 }
 /// <summary>
 /// 售后发货信息提醒
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="info"></param>
 public static void SendMessageOnRefundDeliver(long userId, MessageOrderInfo info, long refundid = 0)
 {
     _iMessageService.SendMessageOnRefundDeliver(userId, info, refundid);
 }
 /// <summary>
 /// 店铺有新订单
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="info"></param>
 public static void SendMessageOnShopHasNewOrder(long shopId, MessageOrderInfo info)
 {
     _iMessageService.SendMessageOnShopHasNewOrder(shopId, info);
 }
示例#25
0
        public void ConfirmRefund(long refundId, string managerRemark, string managerName)
        {
            decimal?        nullable;
            OrderRefundInfo now = context.OrderRefundInfo.FindById <OrderRefundInfo>(refundId);

            if (now.RefundPayType.HasValue)
            {
                switch (now.RefundPayType.Value)
                {
                case OrderRefundInfo.OrderRefundPayType.BackOut:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    string paymentTypeGateway = now.OrderItemInfo.OrderInfo.PaymentTypeGateway;
                    IEnumerable <Plugin <IPaymentPlugin> > plugins =
                        from item in PluginsManagement.GetPlugins <IPaymentPlugin>(true)
                        where item.PluginInfo.PluginId == paymentTypeGateway
                        select item;
                    if (plugins.Count <Plugin <IPaymentPlugin> >() <= 0)
                    {
                        throw new HimallException("退款时,未找到支付方式!");
                    }
                    OrderPayInfo      orderPayInfo = context.OrderPayInfo.FirstOrDefault((OrderPayInfo e) => e.PayState && e.OrderId == now.OrderId);
                    IQueryable <long> nums         =
                        from item in context.OrderPayInfo
                        where item.PayId == orderPayInfo.PayId && item.PayState
                        select item into e
                        select e.OrderId;
                    decimal num = (
                        from o in context.OrderInfo
                        where nums.Contains(o.Id)
                        select o).ToList().Sum <OrderInfo>((OrderInfo e) => e.OrderTotalAmount);
                    if (orderPayInfo == null)
                    {
                        throw new HimallException("退款时,未找到原支付订单信息!");
                    }
                    PaymentPara paymentPara = new PaymentPara()
                    {
                        out_refund_no = now.Id.ToString(),
                        out_trade_no  = orderPayInfo.PayId.ToString(),
                        refund_fee    = now.Amount,
                        total_fee     = num
                    };
                    PaymentPara paymentPara1 = paymentPara;
                    PaymentInfo paymentInfo  = plugins.FirstOrDefault <Plugin <IPaymentPlugin> >().Biz.ProcessRefundFee(paymentPara1);
                    if (paymentInfo.OrderIds == null || paymentInfo.OrderIds.Count() <= 0)
                    {
                        break;
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }

                case OrderRefundInfo.OrderRefundPayType.BackCapital:
                {
                    if (now.RefundPayStatus.HasValue && now.RefundPayStatus.Value == OrderRefundInfo.OrderRefundPayStatus.PaySuccess)
                    {
                        break;
                    }
                    CapitalInfo capitalInfo = context.CapitalInfo.FirstOrDefault((CapitalInfo e) => e.MemId == now.UserId);
                    OrderBO     orderBO     = new OrderBO();
                    if (capitalInfo != null)
                    {
                        CapitalDetailInfo capitalDetailInfo = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CapitalID  = capitalInfo.Id,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            SourceData = now.Id.ToString(),
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        CapitalDetailInfo capitalDetailInfo1 = capitalDetailInfo;
                        CapitalInfo       capitalInfo1       = capitalInfo;
                        decimal?          balance            = capitalInfo1.Balance;
                        decimal           amount             = now.Amount;
                        if (balance.HasValue)
                        {
                            nullable = new decimal?(balance.GetValueOrDefault() + amount);
                        }
                        else
                        {
                            nullable = null;
                        }
                        capitalInfo1.Balance = nullable;
                        context.CapitalDetailInfo.Add(capitalDetailInfo1);
                    }
                    else
                    {
                        CapitalInfo capitalInfo2 = new CapitalInfo()
                        {
                            Balance      = new decimal?(now.Amount),
                            MemId        = now.UserId,
                            FreezeAmount = new decimal?(new decimal(0)),
                            ChargeAmount = new decimal?(new decimal(0))
                        };
                        List <CapitalDetailInfo> capitalDetailInfos = new List <CapitalDetailInfo>();
                        CapitalDetailInfo        capitalDetailInfo2 = new CapitalDetailInfo()
                        {
                            Amount     = now.Amount,
                            CreateTime = new DateTime?(DateTime.Now),
                            SourceData = now.Id.ToString(),
                            SourceType = CapitalDetailInfo.CapitalDetailType.Refund,
                            Id         = orderBO.GenerateOrderNumber()
                        };
                        capitalDetailInfos.Add(capitalDetailInfo2);
                        capitalInfo2.ChemCloud_CapitalDetail = capitalDetailInfos;
                        capitalInfo = capitalInfo2;
                        context.CapitalInfo.Add(capitalInfo);
                    }
                    now.RefundPayStatus = new OrderRefundInfo.OrderRefundPayStatus?(OrderRefundInfo.OrderRefundPayStatus.PaySuccess);
                    context.SaveChanges();
                    break;
                }
                }
            }
            if (now.ManagerConfirmStatus != OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm)
            {
                throw new HimallException("只有未确认状态的退款/退货才能进行确认操作");
            }
            now.ManagerConfirmStatus = OrderRefundInfo.OrderRefundConfirmStatus.Confirmed;
            now.ManagerConfirmDate   = DateTime.Now;
            now.ManagerRemark        = managerRemark;
            OrderOperationLogInfo orderOperationLogInfo = new OrderOperationLogInfo()
            {
                Operator       = managerName,
                OrderId        = now.OrderId,
                OperateDate    = DateTime.Now,
                OperateContent = "确认退款/退货"
            };

            context.OrderOperationLogInfo.Add(orderOperationLogInfo);
            UserMemberInfo userMemberInfo   = context.UserMemberInfo.FindById <UserMemberInfo>(now.UserId);
            OrderInfo      orderInfo        = context.OrderInfo.FindById <OrderInfo>(now.OrderId);
            decimal        orderTotalAmount = orderInfo.OrderTotalAmount - orderInfo.Freight;
            decimal        amount1          = now.Amount - (orderInfo.IntegralDiscount * (now.Amount / orderTotalAmount));

            amount1 = Math.Round(amount1, 2);
            if (amount1 > new decimal(0))
            {
                OrderInfo refundTotalAmount = orderInfo;
                refundTotalAmount.RefundTotalAmount = refundTotalAmount.RefundTotalAmount + amount1;
                if (orderInfo.RefundTotalAmount > orderTotalAmount)
                {
                    orderInfo.RefundTotalAmount = orderTotalAmount;
                }
            }
            if (now.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
            {
                MemberIntegralExchangeRules integralChangeRule = Instance <IMemberIntegralService> .Create.GetIntegralChangeRule();

                if (integralChangeRule != null)
                {
                    int            moneyPerIntegral = integralChangeRule.MoneyPerIntegral;
                    int            num1             = (int)Math.Floor(now.Amount / moneyPerIntegral);
                    MemberIntegral memberIntegral   = userMemberInfo.ChemCloud_MemberIntegral.FirstOrDefault();
                    int            num2             = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);
                    if (num1 > 0 && num2 > 0 && orderInfo.OrderStatus == OrderInfo.OrderOperateStatus.Finish)
                    {
                        MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord()
                        {
                            UserName   = userMemberInfo.UserName,
                            MemberId   = userMemberInfo.Id,
                            RecordDate = new DateTime?(DateTime.Now),
                            TypeId     = MemberIntegral.IntegralType.Others
                        };
                        object[] id = new object[] { "售后编号【", now.Id, "】退款应扣除积分", num1.ToString() };
                        memberIntegralRecord.ReMark = string.Concat(id);
                        num1 = (num1 > num2 ? num2 : num1);
                        num1 = -num1;
                        IConversionMemberIntegralBase conversionMemberIntegralBase = Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Others, num1);

                        Instance <IMemberIntegralService> .Create.AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase);
                    }
                }
            }
            context.SaveChanges();
            MessageOrderInfo messageOrderInfo = new MessageOrderInfo()
            {
                OrderId     = orderInfo.Id.ToString(),
                ShopId      = orderInfo.ShopId,
                ShopName    = orderInfo.ShopName,
                RefundMoney = now.Amount,
                SiteName    = Instance <ISiteSettingService> .Create.GetSiteSettings().SiteName,
                TotalMoney  = orderInfo.OrderTotalAmount
            };

            Task.Factory.StartNew(() => Instance <IMessageService> .Create.SendMessageOnOrderRefund(orderInfo.UserId, messageOrderInfo));
            if (orderInfo.PayDate.HasValue)
            {
                UpdateShopVisti(now, orderInfo.PayDate.Value);
                UpdateProductVisti(now, orderInfo.PayDate.Value);
            }
        }
示例#26
0
        /// <summary>
        /// 退款/退货成功通知
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="info"></param>
        /// <param name="refundid"></param>
        public void SendMessageOnOrderRefund(long userId, MessageOrderInfo info, long refundid = 0)
        {
            var message = PluginsManagement.GetPlugins <IMessagePlugin>().ToList();

            foreach (var msg in message)
            {
                if (msg.Biz.GetStatus(MessageTypeEnum.OrderRefund) == StatusEnum.Open)
                {
                    string destination = GetDestination(userId, msg.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General);
                    if (!msg.Biz.CheckDestination(destination))
                    {
                        throw new HimallException(msg.Biz.ShortName + "错误");
                    }
                    var content = msg.Biz.SendMessageOnOrderRefund(destination, info);
                    if (msg.Biz.EnableLog)
                    {
                        Context.MessageLog.Add(new MessageLog()
                        {
                            SendTime = DateTime.Now, ShopId = info.ShopId, MessageContent = content, TypeId = "短信"
                        });
                        Context.SaveChanges();
                    }
                }
            }

            #region 发送模板消息
            if (info.MsgOrderType == MessageOrderType.Normal)
            {
                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.first.value    = "您的预约单已经完成退款,¥" + info.RefundMoney.ToString("F2") + "已经退回您的付款账户(或预存款账户),请留意查收。";
                    msgdata.first.color    = "#000000";
                    msgdata.keyword1.value = "¥" + info.RefundMoney.ToString("F2");
                    msgdata.keyword1.color = "#FF0000";
                    msgdata.keyword2.value = info.ProductName + "";
                    msgdata.keyword2.color = "#000000";
                    msgdata.keyword3.value = info.OrderId.ToString();
                    msgdata.keyword3.color = "#000000";
                    //msgdata.remark.value = "请您耐心等候";
                    //msgdata.remark.color = "#000000";
                    var _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    if (refundid > 0)
                    {
                        string url = _iwxtser.GetMessageTemplateShowUrl(MessageTypeEnum.OrderRefund);
                        url = url.Replace("{id}", refundid.ToString());
                    }
                    _iwxtser.SendMessageByTemplate(MessageTypeEnum.OrderRefund, userId, msgdata);
                }
            }
            else
            {
                //小程序发送
                string status = "退货/退款成功";
                string remark = "您的预约单已经完成退款,¥" + info.RefundMoney.ToString("F2") + "已经退回您的付款账户(或预存款账户),请留意查收.";

                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.keyword1.value = "¥" + info.RefundMoney.ToString("F2") + "元";
                    msgdata.keyword1.color = "#173177";
                    msgdata.keyword2.value = status;
                    msgdata.keyword2.color = "#173177";
                    msgdata.keyword3.value = remark;
                    msgdata.keyword3.color = "#173177";
                    msgdata.keyword4.value = info.RefundTime.ToString("yyyy-MM-dd HH:mm:ss");
                    msgdata.keyword4.color = "#173177";
                    msgdata.keyword5.value = info.OrderId.ToString();
                    msgdata.keyword5.color = "#173177";

                    //处理url
                    var    _iwxtser   = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    var    _iwxmember = Himall.ServiceProvider.Instance <IMemberService> .Create;
                    string page       = _iwxtser.GetWXAppletMessageTemplateShowUrl(MessageTypeEnum.OrderRefund);//小程序跳转地址
                    page = page.Replace("{id}", info.OrderId.ToString());

                    string openId = _iwxmember.GetMemberOpenIdInfoByuserIdAndType(userId, "WeiXinSmallProg").OpenId;//登录小程序的OpenId

                    string formid    = "";
                    var    formmodel = _iwxtser.GetWXAppletFromDataById(MessageTypeEnum.OrderRefund, info.OrderId.ToString());
                    if (formmodel != null)
                    {
                        formid = formmodel.FormId;//根据OrderId获取FormId
                    }
                    _iwxtser.SendAppletMessageByTemplate(MessageTypeEnum.OrderRefund, userId, msgdata, page, openId, formid);
                }
            }
            #endregion
        }
示例#27
0
        /// <summary>
        /// 发货通知
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="info"></param>
        public void SendMessageOnOrderShipping(long userId, MessageOrderInfo info)
        {
            var message = PluginsManagement.GetPlugins <IMessagePlugin>().ToList();

            foreach (var msg in message)
            {
                if (msg.Biz.GetStatus(MessageTypeEnum.OrderShipping) == StatusEnum.Open)
                {
                    string destination = GetDestination(userId, msg.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General);
                    if (!msg.Biz.CheckDestination(destination))
                    {
                        throw new HimallException(msg.Biz.ShortName + "错误");
                    }
                    var content = msg.Biz.SendMessageOnOrderShipping(destination, info);
                    if (msg.Biz.EnableLog)
                    {
                        Context.MessageLog.Add(new MessageLog()
                        {
                            SendTime = DateTime.Now, ShopId = info.ShopId, MessageContent = content, TypeId = "短信"
                        });
                        Context.SaveChanges();
                    }
                }
            }
            #region 发送模板消息
            if (info.MsgOrderType == MessageOrderType.Normal)
            {
                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.first.value    = "嗖嗖,您的预约单已发货,正加速送到您的手上。";
                    msgdata.first.color    = "#000000";
                    msgdata.keyword1.value = info.ProductName + "等...";
                    msgdata.keyword1.color = "#000000";
                    msgdata.keyword2.value = info.ShippingCompany.ToString();
                    msgdata.keyword2.color = "#000000";
                    msgdata.keyword3.value = info.ShippingNumber.ToString();
                    msgdata.keyword3.color = "#FF0000";
                    msgdata.keyword4.value = info.ShipTo;
                    msgdata.keyword4.color = "#000000";
                    msgdata.remark.value   = "请您耐心等候";
                    msgdata.remark.color   = "#000000";
                    var    _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    string url      = _iwxtser.GetMessageTemplateShowUrl(MessageTypeEnum.OrderShipping);
                    url = url.Replace("{id}", info.OrderId.ToString());
                    _iwxtser.SendMessageByTemplate(MessageTypeEnum.OrderShipping, userId, msgdata);
                }
            }
            #endregion
            #region 小程序模版
            else
            {
                var userinfo = Context.UserMemberInfo.FirstOrDefault(d => d.Id == userId);
                if (userinfo != null)
                {
                    var msgdata = new WX_MsgTemplateSendDataModel();
                    msgdata.keyword1.value = info.ShippingCompany; //快递公司
                    msgdata.keyword1.color = "#173177";
                    msgdata.keyword2.value = info.ShippingNumber;  //快递单号
                    msgdata.keyword2.color = "#173177";
                    msgdata.keyword3.value = info.OrderTime.ToString("yyyy-MM-dd HH:mm:ss");
                    msgdata.keyword3.color = "#173177";
                    msgdata.keyword4.value = info.ProductName + "等...";
                    msgdata.keyword4.color = "#173177";
                    msgdata.keyword5.value = info.ShipTo;
                    msgdata.keyword5.color = "#173177";

                    //处理url
                    var    _iwxtser   = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create;
                    var    _iwxmember = Himall.ServiceProvider.Instance <IMemberService> .Create;
                    string page       = _iwxtser.GetWXAppletMessageTemplateShowUrl(MessageTypeEnum.OrderShipping);//小程序跳转地址
                    page = page.Replace("{id}", info.OrderId.ToString());

                    string openId = _iwxmember.GetMemberOpenIdInfoByuserIdAndType(userId, "WeiXinSmallProg").OpenId;//登录小程序的OpenId

                    string formid    = "";
                    var    formmodel = _iwxtser.GetWXAppletFromDataById(MessageTypeEnum.OrderPay, info.OrderId.ToString());
                    if (formmodel != null)
                    {
                        formid = formmodel.FormId;//根据OrderId获取FormId
                    }
                    _iwxtser.SendAppletMessageByTemplate(MessageTypeEnum.OrderShipping, userId, msgdata, page, openId, formid);
                }
            }
            #endregion
        }