Ejemplo n.º 1
0
        private void SendSpreadPoster(string openid)
        {
            if (_user == null)
            {
                return;
            }
            AsyncHelper.RunSync(async() =>
            {
                _accessToken = await _wechatCommonManager.GetAccessTokenAsync(_tenant.Id);

                try
                {
                    SpreadPosterManager spreadPosterManager = IocManager.Instance.Resolve <SpreadPosterManager>();
                    string path       = await spreadPosterManager.GetDefaultSpreadPosterAsync(_user.ToUserIdentifier());
                    string serverPath = HttpContext.Current.Server.MapPath(path);
                    UploadTemporaryMediaResult uploadTemporaryMediaResult = await MediaApi.UploadTemporaryMediaAsync(
                        _accessToken,
                        UploadMediaFileType.image,
                        serverPath);
                    _customerServiceMessageHelper.SendImage(_accessToken, openid, uploadTemporaryMediaResult.media_id);
                }
                catch (Exception exception)
                {
                    _customerServiceMessageHelper.SendText(_accessToken, openid, exception.Message);
                }
            });
        }
Ejemplo n.º 2
0
        public void HandleEvent(OrderPayedEventData eventData)
        {
            if (eventData.Order is ProductOrder)
            {
                ProductOrder      order             = eventData.Order as ProductOrder;
                DecreaseStockWhen DecreaseStockWhen = (DecreaseStockWhen)(Enum.Parse(typeof(DecreaseStockWhen),
                                                                                     SettingManager.GetSettingValueForTenant(ShopSettings.General.DecreaseStockWhen, eventData.Order.TenantId)));

                foreach (OrderItem orderItem in order.OrderItems)
                {
                    //Decreate stock
                    if (DecreaseStockWhen == DecreaseStockWhen.Pay)
                    {
                        ProductManager.DecreaseStock(orderItem.Specification, orderItem.Count);
                    }

                    //Increse sale
                    ProductManager.IncreaseSale(orderItem.Specification, orderItem.Count);

                    if (!string.IsNullOrEmpty(orderItem.Specification.Product.MasterQrcode))
                    {
                        //Send masterQrcode
                        AsyncHelper.RunSync(async() =>
                        {
                            string accessToken = await WechatCommonManager.GetAccessTokenAsync(order.TenantId);
                            string openid      = WechatUserManager.GetOpenid(order.GetUserIdentifier());

                            if (!string.IsNullOrEmpty(openid))
                            {
                                CustomerServiceMessageHelper.SendImage(accessToken, openid, orderItem.Specification.Product.MasterQrcode);
                            }
                        });
                    }
                }
            }
        }