public void GetCommissionProductDetatilsTest() { using (var client = new TuboAllianceClient()) { var model = new GetCommissionProductDetatilsRequest(); model.CpsId = new Guid("052e3b8d-5b39-4c5b-8f57-78b7bdffd35a"); model.PID = "GF-MOBIL-GIFT|18"; var result = client.GetCommissionProductDetatilsAsync(model); Assert.IsNotNull(result.Result); } }
/// <summary> /// 佣金商品详情查询接口 /// </summary> /// <param name="request"></param> /// <returns></returns> public static async Task <CommissionProductModel> GetCommissionProductDetatilsDal(GetCommissionProductDetatilsRequest request) { var resultCommissionProduct = new CommissionProductModel(); try { using (var dbHelper = DbHelper.CreateDbHelper()) { string sqlGetCommissionProductDetatils = @"SELECT [PKID] ,[CpsId] ,[PID] ,[ProductName] ,[CommissionRatio] ,[IsEnable] ,[CreateTime] ,[CreateBy] ,[UpdateTime] ,[UpdateBy] ,[IsDelete] FROM [Activity].[dbo].[Cps_ProductList] WITH(NOLOCK) WHERE IsDelete =0 AND CpsId = @CpsId AND PID = @PID"; using (var cmd = new SqlCommand(sqlGetCommissionProductDetatils)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@CpsId", request.CpsId); cmd.Parameters.AddWithValue("@PID", request.PID); resultCommissionProduct = await DbHelper.ExecuteFetchAsync <CommissionProductModel>(true, cmd); } } } catch (Exception ex) { Logger.Error($"GetCommissionProductDetatilsDal佣金商品详情查询接口异常:{ex.Message};堆栈信息:{ex.StackTrace}"); } return(resultCommissionProduct); }
/// <summary> /// 佣金商品详情查询接口 /// </summary> /// <param name="request"></param> /// <returns></returns> public static async Task <CommissionProductModel> GetCommissionProductDetatilsManager(GetCommissionProductDetatilsRequest request) { CommissionProductModel resultModel = null; try { //通用缓存Key var prefix = await CacheManager.CommonGetKeyPrefixAsync(DefaultClientName, GlobalConstant.CommissionCacheName); using (var client = CacheHelper.CreateCacheClient(DefaultClientName)) { var cacheResult = await client.GetOrSetAsync($"{prefix}/{request.CpsId}/{request.PID}", () => DalTuboAlliance.GetCommissionProductDetatilsDal(request), GlobalConstant.CommissionExpiration); if (cacheResult.Success) { resultModel = cacheResult.Value; } else { Logger.Error($"GetCommissionProductDetatilsManager佣金商品详情查询Redis执行异常"); resultModel = await DalTuboAlliance.GetCommissionProductDetatilsDal(request); } } } catch (Exception ex) { Logger.Error($"GetCommissionProductDetatilsManager佣金商品详情查询接口异常:{ex.Message};堆栈信息:{ex.StackTrace}"); } return(resultModel); }
/// <summary> /// 佣金商品详情查询接口 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <OperationResult <CommissionProductModel> > GetCommissionProductDetatilsAsync(GetCommissionProductDetatilsRequest request) { if (request == null || string.IsNullOrEmpty(request.PID) || request.CpsId == null) { return(OperationResult.FromError <CommissionProductModel> (nameof(Resource.ParameterError), Resource.ParameterError)); } else { return(OperationResult.FromResult(await TuboAllianceManager.GetCommissionProductDetatilsManager(request))); } }