Пример #1
0
        public List <BaoYangPackagePromotionDetailSimpleModel> GetPromotionDetailsByBatchCode(string batchCode, int index, int size)
        {
            var result = null as List <BaoYangPackagePromotionDetailSimpleModel>;

            if (!string.IsNullOrEmpty(batchCode))
            {
                try
                {
                    result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectPromotionDetailsByBatchCode(conn,
                                                                                                                       batchCode, index, size));
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message, ex);
                }
            }

            if (result != null && result.Any())
            {
                GetPromotionCodesRequest request = new GetPromotionCodesRequest()
                {
                    PKIDList = result.Where(o => o.PromotionId.HasValue && o.PromotionId.Value > 0).Select(o => (int)o.PromotionId).ToList()
                };
                using (var client = new PromotionClient())
                {
                    var serviceResult = client.GetPromotionCodeByIDs(request);
                    if (serviceResult.Success && serviceResult.Result != null)
                    {
                        foreach (var detail in result)
                        {
                            if (detail.PromotionId > 0)
                            {
                                var code = serviceResult.Result.FirstOrDefault(o => o.Pkid == detail.PromotionId);
                                detail.PromotionStatus = code != null ? code.Status : 2;
                                if (!string.IsNullOrEmpty(code.UsedTime))
                                {
                                    detail.PromotionUsedTime = DateTime.Parse(code.UsedTime);
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Пример #2
0
        public bool IsAllUnUsed(List <int> codes)
        {
            bool result = false;
            GetPromotionCodesRequest request = new GetPromotionCodesRequest()
            {
                PKIDList = codes
            };

            using (var client = new PromotionClient())
            {
                var serviceResult = client.GetPromotionCodeByIDs(request);
                if (serviceResult.Success && serviceResult.Result != null)
                {
                    result = serviceResult.Result.All(o => o.Status == 0);
                }
            }

            return(result);
        }