/// <summary>
        /// 采购退货
        /// </summary>
        /// <param name="eEvent"></param>
        /// <returns></returns>
        protected override async Task Receive(ErpSaveReceilBackBillCheckEvent eEvent)
        {
            var receiptBack = await CustomServiceLocator.GetInstance <IReceiptBackBLL>().GetPoBackReceipt(eEvent.BackId);

            var shop = await CustomServiceLocator.GetInstance <IShopBLL>().GetShop(receiptBack.user_shop_id);

            if (shop.Province == null)
            {
                Log.Warn($"【采购退货消费者】门店未设置省份信息,参数:{JsonConvert.SerializeObject(eEvent)}", this.GetType());
                return;
            }
            var areas = await CustomServiceLocator.GetInstance <IAreaBLL>().GetArea();

            var province = areas.FirstOrDefault(p => p.AreaId == shop.Province.Value);
            var executor = SaveReceilBackBillCheckFactory.CreateExecutor(province?.AreaName);

            if (executor == null)
            {
                Log.Warn($"【采购退货消费者】未找到合适的处理者,参数:{JsonConvert.SerializeObject(eEvent)}", this.GetType());
                return;
            }
            try
            {
                await executor.Process(shop, receiptBack, areas);

                Log.Info($"【采购退货消费者】消费成功,参数:{JsonConvert.SerializeObject(eEvent)}", this.GetType());
            }
            catch (Exception ex)
            {
                Log.Error($"【采购退货消费者】发生异常,参数:{JsonConvert.SerializeObject(eEvent)}", ex, this.GetType());
            }
        }
Beispiel #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="redis"></param>
        public RedisProvider(ConnectionMultiplexer redis)
        {
            _redis = redis;
            var redisConfig = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings.RedisConfig;

            _database = redis.GetDatabase(redisConfig.DefaultDb);
        }
Beispiel #3
0
        /// <summary>
        /// 需要消费Event时
        /// </summary>
        /// <param name="host">服务器IP</param>
        /// <param name="queue">消费queue</param>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码</param>
        public IBusControl SubscribeAt <T>(string host, string queue, string userName, string password)
            where T : TTY.Event.GMP.Event
        {
            var uri = new Uri($"rabbitmq://{host}");
            var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var sbcHost = sbc.Host(uri, h =>
                {
                    h.Username(userName);
                    h.Password(password);
                });
                sbc.ReceiveEndpoint(sbcHost, queue, x =>
                {
                    x.Handler <T>(msgBag =>
                    {
                        if (!IsSystemLoadingFinish)
                        {
                            System.Threading.Thread.Sleep(60 * 1000);
                        }
                        return(CustomServiceLocator.GetInstance <IEventConsumer <T> >().Consume(msgBag.Message));
                    });
                });
            });

            bus.Start();
            return(bus);
        }
Beispiel #4
0
        /// <summary>
        /// 执行更新门店统计信息
        /// </summary>
        private void Process()
        {
            var shopStatisticsBll = CustomServiceLocator.GetInstance <IShopStatisticsBLL>();

            shopStatisticsBll.UpdateShopStatistics(ShopStatisticsTypeEnum.Province);
            shopStatisticsBll.UpdateShopStatistics(ShopStatisticsTypeEnum.City);
        }
Beispiel #5
0
        /// <summary>
        /// 处理逻辑
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="inReceipt"></param>
        /// <param name="areas"></param>
        /// <returns></returns>
        public async Task Process(Shop shop, PoInReceipt inReceipt, List <Area> areas)
        {
            var inReceiptBll           = CustomServiceLocator.GetInstance <IInReceiptBLL>();
            var baseSupplierBll        = CustomServiceLocator.GetInstance <IBaseSupplierBLL>();
            var agencyBll              = CustomServiceLocator.GetInstance <IAgencyBLL>();
            var governmentGuangDongBll = CustomServiceLocator.GetInstance <IGovernmentGuangDongBLL>();
            var appSettings            = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
            var agency = await Common.CreateAgency(appSettings.GovernmentApiConfig, agencyBll, governmentGuangDongBll, shop, areas);

            var poInReceiptDetails = await inReceiptBll.GetPoInReceiptDetailView(inReceipt.in_id);

            var supplier = await baseSupplierBll.GetBaseSupplier(inReceipt.in_offer_id);

            var inDate = inReceipt.in_date.ToDateTimeFromTimeStamp().ToString("yyyy-MM-dd");

            foreach (var inReceiptDetail in poInReceiptDetails)
            {
                var sgdRequest = new UploadSgdRequest()
                {
                    no                = inReceipt.in_id.ToString(),
                    detailno          = inReceiptDetail.in_detail_id.ToString(),
                    product_info_name = inReceiptDetail.goods_name,
                    product_info_id   = string.Empty,
                    product_info_code = inReceiptDetail.goods_code,
                    nyjx              = inReceiptDetail.dosage_forms,
                    nydx              = inReceiptDetail.toxicity_grade_name,
                    yxq               = string.Empty,
                    pzwh              = string.Empty,
                    specification     = inReceiptDetail.goods_spec,
                    zsm               = string.Empty,
                    fromId            = supplier.supplier_id.ToString(),
                    fromCode          = supplier.supplier_code,
                    fromName          = supplier.supplier_name,
                    gldx_company_code = string.Empty,
                    gldx_company_name = inReceiptDetail.goods_product,
                    gys               = supplier.supplier_name,
                    djh               = inReceiptDetail.registration_number,
                    batchno           = string.Empty,
                    date              = inDate,
                    total             = inReceiptDetail.qty.ToString(),
                    price             = "0",
                    totalprice        = "0",
                    totalunit         = inReceiptDetail.unit_name,
                    scrq              = string.Empty,
                    isxzshop          = 0,
                    isxz              = inReceiptDetail.goods_restrictive,
                    info              = string.Empty
                };
                var result = await governmentGuangDongBll.UploadSgd(appSettings.GovernmentApiConfig.GuangDong.ApiAddress,
                                                                    appSettings.GovernmentApiConfig.GuangDong.QyCode, agency, sgdRequest);

                if (result.result.status != "0")
                {
                    Log.Warn($"【广东省农药经营管理系统平台】上传采购记录失败,参数in_id:{inReceiptDetail.in_id}", this.GetType());
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// 初始化成员
        /// </summary>
        private void Initialize()
        {
            var now = DateTime.Now;

            _startTime = now.Date;
            _endTime   = _startTime.AddDays(1).AddSeconds(-1);
            _statisticsBillCountBll = CustomServiceLocator.GetInstance <IStatisticsBillCountBLL>();
            _reportBll = CustomServiceLocator.GetInstance <IReportBLL>();
        }
Beispiel #7
0
        /// <summary>
        /// 处理采购入库撤销
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="inReceipt"></param>
        /// <param name="areas"></param>
        /// <returns></returns>
        public async Task Process(Shop shop, PoInReceipt inReceipt, List <Area> areas)
        {
            var appSettings            = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
            var governmentGuangDongBll = CustomServiceLocator.GetInstance <IGovernmentGuangDongBLL>();
            var result = await governmentGuangDongBll.UpdSgdStatus(appSettings.GovernmentApiConfig.GuangDong.ApiAddress,
                                                                   appSettings.GovernmentApiConfig.GuangDong.QyCode, inReceipt.in_id.ToString(), "QX");

            if (result.result.status != "0")
            {
                Log.Warn($"【广东省农药经营管理系统平台】采购撤销失败,in_id:{inReceipt.in_id}", this.GetType());
            }
        }
 /// <summary>
 /// 初始化类公共属性
 /// </summary>
 private void Initialize()
 {
     _shopBll                 = CustomServiceLocator.GetInstance <IShopBLL>();
     _shopRetailRankBll       = CustomServiceLocator.GetInstance <IShopRetailRankBLL>();
     _shopRetailRankWinnerBll = CustomServiceLocator.GetInstance <IShopRetailRankLimitBLL>();
     _platformBll             = CustomServiceLocator.GetInstance <IPlatformBLL>();
     _appSettings             = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
     _config      = _appSettings.ShopRetailRankConfig;
     _now         = DateTime.Now;
     _startGrowth = _now.GetStartOfTheWeek();
     _endGrowth   = _now;
     _startKing   = _config.KingStartTime;
     _endKing     = _now;
 }
Beispiel #9
0
        /// <summary>
        /// 获取登录凭证
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        internal static AppTicket GetAppTicket(HttpContext httpContext)
        {
            var tempTicket = httpContext.Session.GetObject <AppTicket>("app_ticket");

            if (tempTicket != null)
            {
                return(tempTicket);
            }
            var sysUserBll     = CustomServiceLocator.GetInstance <ISysUserBLL>();
            var user           = sysUserBll.GetSysUser(httpContext.Request.GetUserId()).Result;
            var sysUserRoleBll = CustomServiceLocator.GetInstance <ISysUserRoleBLL>();
            var userRole       = sysUserRoleBll.GetSysUserRole(user.UserRoleId).Result;

            return(SetAppTicket(httpContext, user, userRole));
        }
        /// <summary>
        /// 零售退货处理
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="soRetailBack"></param>
        /// <param name="areas"></param>
        /// <returns></returns>
        public async Task Process(Shop shop, SoRetailBack soRetailBack, List <Area> areas)
        {
            var appSettings            = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
            var governmentGuangDongBll = CustomServiceLocator.GetInstance <IGovernmentGuangDongBLL>();
            var soRetailBackDetails    = await CustomServiceLocator.GetInstance <IRetailBackBLL>().GetSoRetailBackDetail(soRetailBack.retail_back_id);

            var detailNos = string.Join(";", soRetailBackDetails.Select(p => p.retail_detail_id));
            var result    = await governmentGuangDongBll.UpdXsdStatus(appSettings.GovernmentApiConfig.GuangDong.ApiAddress,
                                                                      appSettings.GovernmentApiConfig.GuangDong.QyCode, soRetailBack.retail_bill_id.ToString(), detailNos,
                                                                      "QX");

            if (result.result.status != "0")
            {
                Log.Warn($"【广东省农药经营管理系统平台】零售退货失败,retail_back_id:{soRetailBack.retail_back_id}", this.GetType());
            }
        }
        /// <summary>
        /// 记录用户行为日志
        /// </summary>
        /// <param name="context"></param>
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;

            if (actionDescriptor != null)
            {
                var attribute = actionDescriptor.MethodInfo.GetCustomAttributes(typeof(UserBehaviorAttribute), false).FirstOrDefault();
                if (attribute != null)
                {
                    var userBehaviorAttribute = (UserBehaviorAttribute)attribute;
                    CustomServiceLocator.GetInstance <ISysUserLogBLL>().AddSysUserLog(new SysUserLog()
                    {
                        UserId    = context.HttpContext.Request.GetUserId(),
                        IpAddress = string.Empty,
                        Ot        = DateTime.Now,
                        Describe  = userBehaviorAttribute.Describe,
                        Type      = (int)userBehaviorAttribute.Type
                    });
                }
            }
        }
Beispiel #12
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="shopRetailRankBll"></param>
 public GetShopRetailRankAboutKingAction(IShopRetailRankBLL shopRetailRankBll)
 {
     this._shopRetailRankBll = shopRetailRankBll;
     _shopRetailRankConfig   = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings.ShopRetailRankConfig;
 }
Beispiel #13
0
 /// <summary>
 /// 获取erp项目数据连接
 /// </summary>
 /// <returns></returns>
 public DbConnection GetErpSqlConnection()
 {
     return(new MySqlConnection(CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings.MySqlErpConnectionString));
 }
Beispiel #14
0
 /// <summary>
 /// EF配置
 /// </summary>
 /// <param name="optionsBuilder"></param>
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     base.OnConfiguring(optionsBuilder);
     optionsBuilder.UseMySQL(CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings.MySqlErpConnectionString);
 }
Beispiel #15
0
 /// <summary>
 /// 初始化成员
 /// </summary>
 private void Initialize()
 {
     _stockQtyBll = CustomServiceLocator.GetInstance <IStockQtyBLL>();
     _reportBll   = CustomServiceLocator.GetInstance <IReportBLL>();
 }
Beispiel #16
0
        /// <summary>
        /// 处理逻辑
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="soRetail"></param>
        /// <param name="areas"></param>
        public async Task Process(Shop shop, SoRetail soRetail, List <Area> areas)
        {
            var retailBll = CustomServiceLocator.GetInstance <IRetailBLL>();
            var agencyBll = CustomServiceLocator.GetInstance <IAgencyBLL>();
            var governmentGuangDongBll = CustomServiceLocator.GetInstance <IGovernmentGuangDongBLL>();
            var appSettings            = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings;
            var agency = await Common.CreateAgency(appSettings.GovernmentApiConfig, agencyBll, governmentGuangDongBll, shop, areas);

            var soRetailDetails = await retailBll.GetSoRetailDetail(soRetail.RetailId);

            var cmRetailCustomer = await retailBll.GetCmRetailCustomer(soRetail.RetailId);

            var billDate = soRetail.BillDate.ToDateTimeFromTimeStamp().ToString("yyyy-MM-dd");

            foreach (var retailDetail in soRetailDetails)
            {
                Area toProvince = null;
                if (cmRetailCustomer != null && cmRetailCustomer.Province != null)
                {
                    toProvince = areas.FirstOrDefault(p => p.AreaId == cmRetailCustomer.Province.Value);
                }
                var xsdRequest = new UploadXsdRequest()
                {
                    no                = soRetail.RetailId.ToString(),
                    detailno          = retailDetail.retail_detail_id.ToString(),
                    product_info_name = retailDetail.goods_name,
                    product_info_id   = string.Empty,
                    product_info_code = retailDetail.goods_code,
                    nyjx              = retailDetail.dosage_forms,
                    nydx              = retailDetail.toxicity_grade_name,
                    scrq              = string.Empty,
                    yxq               = string.Empty,
                    pzwh              = string.Empty,
                    specification     = retailDetail.goods_spec,
                    zsm               = string.Empty,
                    toaddress         = cmRetailCustomer?.AddressDetail,
                    topost            = string.Empty,
                    touser            = cmRetailCustomer?.RetailCustomerName,
                    toheadmen         = cmRetailCustomer?.RetailCustomerName,
                    toidcard          = cmRetailCustomer?.Identification,
                    toprovince        = toProvince?.AreaName,
                    tophone           = cmRetailCustomer?.RetailCustomerTel,
                    gldx_company_code = string.Empty,
                    gldx_company_name = retailDetail.goods_product,
                    djh               = retailDetail.registration_number,
                    batchno           = string.Empty,
                    date              = billDate,
                    total             = retailDetail.qty.ToString(),
                    price             = "0",
                    totalprice        = "0",
                    totalunit         = retailDetail.unit_name,
                    isxzshop          = 0,
                    isxz              = retailDetail.goods_restrictive,
                    info              = soRetail.Explain
                };
                var result = await governmentGuangDongBll.UploadXsd(appSettings.GovernmentApiConfig.GuangDong.ApiAddress,
                                                                    appSettings.GovernmentApiConfig.GuangDong.QyCode, agency, xsdRequest);

                if (result.result.status != "0")
                {
                    Log.Warn($"【广东省农药经营管理系统平台】上传销售记录失败,参数retail_detail_id:{retailDetail.retail_detail_id}", this.GetType());
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// 静态构造函数
 /// 初始化平台配置信息
 /// </summary>
 static PlatformHelper()
 {
     _platformConfig = CustomServiceLocator.GetInstance <IAppConfigurtaionServices>().AppSettings.PlatformConfig;
 }