public void HandleEvent(OrderShipedEventData eventData)
        {
            AsyncHelper.RunSync(async() =>
            {
                string openid = WechatUserManager.GetOpenid(new UserIdentifier(eventData.Order.TenantId, eventData.Order.UserId));

                if (String.IsNullOrEmpty(openid))
                {
                    return;
                }
                OrderShipedTemplateMessageData data = new OrderShipedTemplateMessageData()
                {
                    first    = new TemplateDataItem(eventData.Order.Title),
                    keyword1 = new TemplateDataItem(eventData.Order.Number),
                    keyword4 = new TemplateDataItem(eventData.Order.CreationTime.ToString()),
                    remark   = new TemplateDataItem(L("ThankYouForYourPatronage"))
                };

                if (eventData.ExpressInfo != null)
                {
                    ExpressCompany expressCompany = ExpressCompanyRepository.Get(eventData.ExpressInfo.ExpressCompanyId);
                    data.keyword2 = new TemplateDataItem(expressCompany.Name);
                    data.keyword3 = new TemplateDataItem(eventData.ExpressInfo.TrackingNumber);
                }
                else
                {
                    data.keyword2 = new TemplateDataItem(L("Null"));
                    data.keyword3 = new TemplateDataItem(L("Null"));
                }
                await TemplateMessageManager.SendTemplateMessageOfOrderShipedAsync(eventData.Order.TenantId, openid, OrderHelper.GetOrderDetailUrl(eventData.Order.Id), data);
            });
        }
Exemple #2
0
        public async Task SetAsSpreader(User user)
        {
            if (user.IsSpreader)
            {
                return;
            }
            user.IsSpreader = true;
            UserRepository.Update(user);

            WechatUserManager wechatUserManager = IocManager.Instance.Resolve <WechatUserManager>();
            string            openid            = wechatUserManager.GetOpenid(user.ToUserIdentifier());

            if (openid.HasValue())
            {
                try
                {
                    UpgradeTemplateMessageData data = new UpgradeTemplateMessageData(
                        new TemplateDataItem(L("CongratulationsOnBeenSpreader")),
                        new TemplateDataItem(user.Id.ToString()),
                        new TemplateDataItem(L("NoLimit")),
                        new TemplateDataItem(L("ThankYouForYourPatronage"))
                        );
                    await TemplateMessageManager.SendTemplateMessageOfUpgradeAsync(user.TenantId.Value, openid, null, data);
                }
                catch
                {
                }
            }
        }
Exemple #3
0
        public void HandleEvent(BindParentEventData eventData)
        {
            AsyncHelper.RunSync(async() =>
            {
                string openid = WechatUserManager.GetOpenid(new UserIdentifier(eventData.ParentUser.TenantId, eventData.ParentUser.Id));

                if (string.IsNullOrEmpty(openid))
                {
                    return;
                }
                NewCustomerTemplateMessageData data = new NewCustomerTemplateMessageData(
                    new TemplateDataItem(L("YouHasANewCustomer")),
                    new TemplateDataItem(eventData.SourceUser.UserName),
                    new TemplateDataItem(eventData.SourceUser.NickName),
                    new TemplateDataItem(eventData.SourceUser.CreationTime.ToString("yyyy-MM-dd hh:mm:ss")),
                    new TemplateDataItem(L("ThankYouForYourPatronage"))
                    );
                await TemplateMessageManager.SendTemplateMessageOfNewCustomerAsync(eventData.ParentUser.TenantId.Value, openid, "", data);
            });
        }