Ejemplo n.º 1
0
        /// <summary>
        /// 部分退款
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> PartRefund([FromServices] IThirdOrderRepository service)
        {
            var notifyType = formDic["notify_type"];

            if (notifyType != "part")
            {
                return(Json(new { data = "ok" }));
            }
            var id    = formDic["order_id"];
            var order = await service.GetOrderByCodeAsync(id);

            if (order.LogisticsType != LogisticsType.Yichengfeike)
            {
                return(Json(new { data = "ok" }));
            }
            var reason = formDic["reason"];
            var foods  = formDic["food"];

            if (!string.IsNullOrEmpty(foods))
            {
                var detail = JArray.Parse(foods);
                reason += ",退款商品:";
                foreach (var item in detail)
                {
                    reason += item["food_name"].Value <string>() + " " + item["count"].Value <int>();
                }
            }

            Log.Debug("部分退款:" + reason);

            var helper = YcfkHelper.GetHelper();
            await helper.ApplyCancel(order.Data1, reason, order.Business.YcfkKey, order.Business.YcfkSecret);

            return(Json(new { data = "ok" }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 一城飞客发单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        private async Task YcfkHandlerAsync(ThirdOrder order)
        {
            var helper    = YcfkHelper.GetHelper();
            var ycfkOrder = new YcfkOrder
            {
                OrderId             = $"{order.OrderId}_{UtilHelper.RandNum()}_{order.OrderSource}",
                Flag                = order.OrderSource == 0 ? "美团" : "饿了么",
                ViewOrderId         = order.OrderId,
                ShopId              = order.Business.StoreId,
                ShopName            = order.Business.Name,
                OrderUserName       = order.RecipientName,
                OrderUserPhone      = order.RecipientPhone,
                OrderUserAddress    = order.RecipientAddress,
                OrderRemark         = order.Caution,
                BoxFee              = Convert.ToDecimal(order.PackageFee),
                Freight             = Convert.ToDecimal(order.ShippingFee),
                ActivityMoney       = Convert.ToDecimal(order.OriginalAmount - order.Amount),
                ReachTime           = order.DeliveryTime?.ToString("yyyy-MM-dd HH:mm:ss"),
                UserGaodeCoordinate = order.Longitude + "|" + order.Latitude,
                DayIndex            = order.DaySeq
            };

            ycfkOrder.FoodList = order.ThirdOrderProducts.Select(a => new YcfkFoodItem
            {
                FoodName  = a.Name,
                FoodPrice = Convert.ToDecimal(a.Price),
                FoodCount = Convert.ToInt32(a.Quantity)
            }).ToList();

            var json = await helper.Send(ycfkOrder, order.Business.YcfkKey, order.Business.YcfkSecret);

            try
            {
                var jObj = JObject.Parse(json);
                var code = jObj["StateCode"].Value <int>();
                if (code > 0)
                {
                    order.Error = jObj["StateMsg"].Value <string>();
                    //Log.Debug("一城飞客配送异常:" + json);
                    return;
                }
            }
            catch (Exception e)
            {
                throw new Exception("一城飞客自动发单异常:" + e.Message + $"。返回值:【{json}】");
            }
            //Log.Debug("一城飞客配送成功:" + json);

            order.Status        = OrderStatus.DistributorReceipt;
            order.LogisticsType = LogisticsType.Yichengfeike;
            order.Error         = "";
            order.Data1         = ycfkOrder.OrderId;
        }
Ejemplo n.º 3
0
        private async Task <JsonData> YcfkCancel(Order order)
        {
            var result = new JsonData();
            var helper = YcfkHelper.GetHelper();
            var reason = Request.Query["reason"].First() + "";
            var json   = await helper.Cancel(order.OrderCode + "_" + order.DistributionFlow, reason, Business.YcfkKey, Business.YcfkSecret);

            var jObj = JObject.Parse(json);
            var code = jObj["StateCode"].Value <int>();

            if (code > 0)
            {
                result.Msg = jObj["StateMsg"].Value <string>();
                return(result);
            }
            order.Status   = OrderStatus.CallOff;
            result.Data    = OrderStatus.CallOff;
            result.Success = true;
            result.Msg     = "配送取消成功";
            Service.Commit();
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 全部退款
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> AllRefund([FromServices] IThirdOrderRepository service)
        {
            var notifyType = formDic["notify_type"];

            if (notifyType != "apply")
            {
                return(Json(new { data = "ok" }));
            }
            var id    = formDic["order_id"];
            var order = await service.GetOrderByCodeAsync(id);

            if (order.LogisticsType != LogisticsType.Yichengfeike)
            {
                return(Json(new { data = "ok" }));
            }
            var reason = formDic["reason"];

            var helper = YcfkHelper.GetHelper();
            await helper.ApplyCancel(order.Data1, reason, order.Business.YcfkKey, order.Business.YcfkSecret);

            Log.Debug("全额退款:" + reason);

            return(Json(new { data = "ok" }));
        }
Ejemplo n.º 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                // 注册全局异常过滤器
                options.Filters.Add <GlobalExceptionAttribute>();
            })
            .AddJsonOptions(a => a.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
            // 配置会话应用状态
            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                options.IdleTimeout     = TimeSpan.FromSeconds(600);
                options.Cookie.HttpOnly = true;
            });

            // 配置依赖
            //services.AddDbContext<CatDbContext>(a => a.UseLazyLoadingProxies()
            //.ConfigureWarnings(b => b.Log(CoreEventId.DetachedLazyLoadingWarning))
            //.UseSqlServer(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            //services.AddDbContext<CatDbContext>(a => a.UseSqlServer(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            services.AddDbContext <CatDbContext>(a => a.UseMySql(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            // 注册redis连接
            services.AddSingleton <IConnectionMultiplexer>(ConnectionMultiplexer.Connect(Configuration.GetConnectionString("RedisConn")));

            services.AddScoped <IBusinessRepository, BusinessRepository>();
            services.AddScoped <IProductRepository, ProductRepository>();
            services.AddScoped <IOrderRepository, OrderRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IDwdRepository, DwdRepository>();
            services.AddScoped <IClientRepository, ClientRepository>();
            services.AddScoped <IStoreRepository, StoreRepository>();
            services.AddScoped <ITangRepository, TangRepository>();
            services.AddScoped <IUtilRepository, UtilRepository>();
            services.AddScoped <ICardRepository, CardRepository>();
            services.AddScoped <IThirdOrderRepository, ThirdOrderRepository>();
            services.AddSingleton(new List <City>());
            services.AddSingleton(new List <DadaCancelReason>());
            // 系统参数
            var config = new AppData();

            config.Init(Configuration);
            services.AddSingleton(config);
            //InputData.Key = config.ServerKey;
            AppSetting.SetAppData(config);
            // 序列化参数
            services.AddSingleton(AppData.JsonSetting);


            // 达达请求
            var dada = DadaHelper.GetHelper();

            dada.Init(config, AppData.JsonSetting);
            services.AddSingleton(dada);
            // 点我达请求
            var dwd = DwdHelper.GetHelper();

            dwd.Init(config);
            services.AddSingleton(dwd);
            // 飞印
            var feyin = new FeYinHelper
            {
                AppId      = config.FeyinAppId,
                MemberCode = config.FeyinMemberCode,
                ApiKey     = config.FeyinApiKey
            };

            services.AddSingleton(feyin);
            // 易联云
            var yly = YlyHelper.GetHelper();

            yly.Init(config.YlyPartnerId, config.YlyApiKey, config.YlyUrl);
            services.AddSingleton(yly);
            // 飞鹅
            var feie = FeieHelper.GetHelper();

            feie.Init(config.FeieUser, config.FeieKey, config.FeieUrl);
            services.AddSingleton(yly);
            // 外卖管家
            var wmgj = WmgjHelper.GetHelper();

            wmgj.Init(int.Parse(config.WmgjAppId), config.WmgjAppKey, config.WmgjUrl);
            services.AddSingleton(yly);
            // 微信加解密对象
            services.AddSingleton(new WXBizMsgCrypt(config.OpenToken, config.OpenEncodingAESKey, config.OpenAppId));
            // 一城飞客
            services.AddSingleton(YcfkHelper.GetHelper().Init(config));
            // 微信
            WxHelper.Init(config);

            // 注册定时服务
            if (config.IsTimer)
            {
                services.AddHostedService <TimedHostedService>();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 取消一城飞客配送
 /// </summary>
 /// <param name="order"></param>
 /// <param name="reason"></param>
 /// <returns></returns>
 private async Task UnYcfkHandlerAsync(ThirdOrder order, string reason)
 {
     var helper = YcfkHelper.GetHelper();
     await helper.Cancel(order.Data1, reason, order.Business.YcfkKey, order.Business.YcfkSecret);
 }
Ejemplo n.º 7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                // 注册全局异常过滤器
                options.Filters.Add <GlobalExceptionAttribute>();
            });
            // 配置会话应用状态
            //services.AddDistributedMemoryCache();
            //services.AddSession(options =>
            //{
            //    options.IdleTimeout = TimeSpan.FromSeconds(600);
            //    options.Cookie.HttpOnly = true;
            //});
            // 配置依赖
            //services.AddDbContext<CatDbContext>(a => a.UseLazyLoadingProxies()
            //.ConfigureWarnings(b => b.Log(CoreEventId.DetachedLazyLoadingWarning))
            //.UseSqlServer(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            //services.AddDbContext<CatDbContext>(a => a.UseSqlServer(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            services.AddDbContext <CatDbContext>(a => a.UseMySql(Configuration.GetConnectionString("CatContext"), b => b.MigrationsAssembly("JdCat.Cat.Model")));
            // 注册redis连接
            services.AddSingleton <IConnectionMultiplexer>(ConnectionMultiplexer.Connect(Configuration.GetConnectionString("RedisConn")));

            services.AddScoped <IBusinessRepository, BusinessRepository>();
            services.AddScoped <IProductRepository, ProductRepository>();
            services.AddScoped <IUserRepository, UserRepository>();
            services.AddScoped <IOrderRepository, OrderRepository>();
            services.AddScoped <ISessionDataRepository, SessionDataRepository>();
            services.AddScoped <IUtilRepository, UtilRepository>();
            // 系统参数
            var config = new AppData();

            config.Init(Configuration);
            services.AddSingleton(config);
            //InputData.Key = config.ServerKey;
            AppSetting.SetAppData(config);
            // 达达请求
            var dada = DadaHelper.GetHelper();

            dada.Init(config, AppData.JsonSetting);
            services.AddSingleton(dada);
            // 点我达请求
            var dwd = DwdHelper.GetHelper();

            dwd.Init(config);
            services.AddSingleton(dwd);
            // 易联云
            var yly = YlyHelper.GetHelper();

            yly.Init(config.YlyPartnerId, config.YlyApiKey, config.YlyUrl);
            services.AddSingleton(yly);
            // 飞鹅
            var feie = FeieHelper.GetHelper();

            feie.Init(config.FeieUser, config.FeieKey, config.FeieUrl);
            services.AddSingleton(yly);
            // 外卖管家
            var wmgj = WmgjHelper.GetHelper();

            wmgj.Init(int.Parse(config.WmgjAppId), config.WmgjAppKey, config.WmgjUrl);
            services.AddSingleton(yly);
            // 一城飞客
            services.AddSingleton(YcfkHelper.GetHelper().Init(config));
            // 微信
            WxHelper.Init(config);
        }