public static bool Update(SE_GiftManageConfigModel model)
        {
            try
            {
                var giftFlag = true;
                var reGiftP  = SE_GiftManageConfigDAL.DeleteGiftProductConfig(model.Id);
                giftFlag = giftFlag && reGiftP >= 0;
                var giftProductModels = JsonConvert.DeserializeObject <List <GiftStockModel2> >(model.GiftProducts);
                foreach (var g in giftProductModels)
                {
                    g.RuleId = model.Id;
                    giftFlag = giftFlag && SE_GiftManageConfigDAL.MergeIntoGiftProductStock(g.Pid, g.Stock, model.Id) > 0;
                    giftFlag = giftFlag && SE_GiftManageConfigDAL.InsertGiftProductConfig(g) > 0;
                }

                var result = SE_GiftManageConfigDAL.Update(ProcessConnection.OpenConfiguration, model) && giftFlag;
                // 按PID配置赠品后刷新牛皮癣缓存
                RefreshGiftPicture(model);
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
 /// <summary>
 /// 获取赠品销售数量
 /// </summary>
 /// <param name="pid"></param>
 /// <returns></returns>
 public static int SelectGiftStock(string pid)
 {
     if (!string.IsNullOrEmpty(pid) && pid == "initial")
     {
         var datas =
             SE_GiftManageConfigDAL.SelectAllGiftManageConfigModels(ProcessConnection.OpenConfigurationReadOnly);
         {
             foreach (var model in datas)
             {
                 try
                 {
                     SE_GiftManageConfigDAL.DeleteGiftProductConfig(model.Id);
                     if (model.GiftProducts != null && model.GiftProducts.Any())
                     {
                         var giftProductModels =
                             JsonConvert.DeserializeObject <List <GiftStockModel2> >(model.GiftProducts);
                         foreach (var g in giftProductModels)
                         {
                             g.IsRetrieve = g.IsRetrieve ?? 0;
                             g.RuleId     = model.Id;
                             SE_GiftManageConfigDAL.InsertGiftProductConfig(g);
                         }
                     }
                 }
                 catch (Exception e)
                 {
                     throw e;
                 }
             }
         }
     }
     return(SE_GiftManageConfigDAL.SelectGiftStock(pid));
 }
        public static bool Insert(SE_GiftManageConfigModel model, SE_DictionaryConfigModel log)
        {
            try
            {
                var result   = SE_GiftManageConfigDAL.Insert(ProcessConnection.OpenConfiguration, model);
                var giftFlag = true;
                log.ParentId = result;
                //var reGiftP = SE_GiftManageConfigDAL.DeleteGiftProductConfig(result);
                var giftProductModels = JsonConvert.DeserializeObject <List <GiftStockModel2> >(model.GiftProducts);
                foreach (var g in giftProductModels)
                {
                    g.RuleId     = result;
                    g.IsGiveAway = model.GiveAway;
                    giftFlag     = giftFlag && SE_GiftManageConfigDAL.MergeIntoGiftProductStock(g.Pid, g.Stock, result) > 0;
                    giftFlag     = giftFlag && SE_GiftManageConfigDAL.InsertGiftProductConfig(g) > 0;
                }

                // 按PID配置赠品后刷新牛皮癣缓存
                RefreshGiftPicture(model);
                return(result > 0 && SE_GiftManageConfigDAL.InsertLog(ProcessConnection.OpenConfiguration, log) && giftFlag);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }