private bool Create2BOrder(decimal price, string pid, string name, Guid vipUserId, int count, string batchCode) { var success = false; try { var result = VipBaoYangPackageService.CreateOrder(price, pid, name, vipUserId, count, batchCode); if (result != null && result.OrderId > 0) { VipBaoYangPackageService.ExecuteOrderProcess(new ExecuteOrderProcessRequest() { OrderId = result.OrderId, OrderProcessEnum = OrderProcessEnum.GeneralCompleteToHome, CreateBy = vipUserId.ToString() }); logger.Info($"创建买断制2B订单{result.OrderId}成功, 一共{count}个产品数量, 关联批次号:{batchCode}"); success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdateRedemptionCode(conn, batchCode, result.OrderId)); } else { logger.Error($"创建买断制2B订单失败, 一共{count}个产品数量, 批次号:{batchCode}"); } } catch (Exception ex) { logger.Error(ex.Message, ex); } return(success); }
public bool UpdateVipBaoYangPackage(VipBaoYangPackageViewModel package) { var success = false; try { var inputPackage = new VipBaoYangPackageDbModel(package); var dbPackage = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectVipBaoYangPackageByPkid(conn, package.PKID)); if (dbPackage != null) { var oldData = JsonConvert.SerializeObject(dbPackage); dbPackage.Brands = inputPackage.Brands; success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdateVipBaoYangPackage(conn, dbPackage)); if (success) { dbPackage.LastUpdateDateTime = DateTime.Now; var newData = JsonConvert.SerializeObject(dbPackage); InsertLog(dbPackage.PID, oldData, newData, "Update", package.CreateUser); } } } catch (Exception ex) { logger.Error(ex); } return(success); }
public bool UpdateSendSmsStatus(Guid vipUserId, bool isSendSms, string user) { var result = false; try { dbScopeManager.CreateTransaction(conn => { var data = DALVipBaoYangPackage.IsExistsSmsConfig(conn, vipUserId); if (data > 0) { result = DALVipBaoYangPackage.UpdateSendSmsStatus(conn, vipUserId, isSendSms) > 0; } else { result = DALVipBaoYangPackage.InsertVipSmsCofig(conn, vipUserId, isSendSms, user) > 0; } }); } catch (Exception ex) { logger.Error(ex); } return(result); }
/// <summary> /// 添加礼包优惠券配置 /// </summary> /// <param name="packId"></param> /// <param name="getRuleId"></param> /// <param name="quantity"></param> /// <returns></returns> public bool AddGiftPackCouponConfig(long packId, Guid getRuleGUID, int quantity, string user) { bool succes = false; try { var pkid = dbScopeManager.Execute(conn => DALVipBaoYangPackage.AddGiftPackCouponConfig(conn, packId, getRuleGUID, quantity)); succes = pkid > 0; if (succes) { VipBaoYangPackageService.InsertBaoYangOprLog(new { LogType = "VipBaoYangPackageRedemptionCodeCoupon", IdentityID = pkid.ToString(), OldValue = string.Empty, NewValue = JsonConvert.SerializeObject(new { PKID = pkid, PackId = packId, GetRuleGUID = getRuleGUID, Quantity = quantity }), Remarks = $"Add", OperateUser = user, }); } } catch (Exception ex) { logger.Error(ex.Message, ex); } return(succes); }
public List <VipBaoYangPackageModel> SelectVipBaoYangPackage(string pid, Guid vipUserId, int pageIndex, int pageSize) { List <VipBaoYangPackageModel> result = null; try { IDictionary <int, List <VipBaoYangPackageOilConfig> > oilConfigs = null; dbScopeReadManager.Execute(conn => { result = DALVipBaoYangPackage.SelectVipBaoYangPackage(conn, pid, vipUserId, pageIndex, pageSize); oilConfigs = DALVipBaoYangPackage.SelectBaoYangPackageOilConfigs(conn, result.Select(x => x.PKID)); }); if (result != null && result.Any()) { result.ForEach(x => { x.OilConfigs = (oilConfigs.ContainsKey(x.PKID)) ? oilConfigs[x.PKID].OrderBy(o => o.PKID).ToList() : new List <VipBaoYangPackageOilConfig>(); }); } } catch (Exception ex) { logger.Error(ex); } return(result ?? new List <VipBaoYangPackageModel>()); }
/// <summary> /// 验证礼包优惠券配置 /// </summary> /// <param name="packId"></param> /// <param name="getRuleId"></param> /// <returns></returns> public Tuple <bool, string> ValidateGiftPackCouponConfig(long packId, Guid getRuleGUID) { Tuple <bool, string> result = null; try { dbScopeReadManager.Execute(conn => { var getRuleValidateResult = DALVipBaoYangPackage.SelectCouponInfos(conn, new[] { getRuleGUID }).FirstOrDefault() != null; if (!getRuleValidateResult) { result = Tuple.Create(false, "优惠券规则不存在"); return; } var packValidateResult = DALVipBaoYangPackage.SelectVipBaoYangGiftPackConfigById(conn, packId) != null; if (!packValidateResult) { result = Tuple.Create(false, "礼包不存在"); return; } var exist = DALVipBaoYangPackage.IsExistsGiftPackCouponConfig(conn, packId, getRuleGUID); if (exist) { result = Tuple.Create(false, "已存在相同数据"); } }); } catch (Exception ex) { logger.Error(ex.Message, ex); result = Tuple.Create(false, ex.Message); } return(result ?? Tuple.Create(true, string.Empty)); }
/// <summary> /// 根据礼包Id获取优惠券配置 /// </summary> /// <param name="packId"></param> /// <returns></returns> public List <GiftPackCouponConfig> GetGiftPackCouponConfig(long packId) { var result = null as List <GiftPackCouponConfig>; try { var configs = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectGiftPackCouponConfig(conn, packId)).ToList(); var extraInfo = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectCouponInfos(conn, configs.Select(x => x.GetRuleGUID))); result = (from x in configs join y in extraInfo on x.GetRuleGUID equals y.GetRuleGUID into temp from z in temp.DefaultIfEmpty() select new GiftPackCouponConfig { PKID = x.PKID, GetRuleID = z?.GetRuleID ?? 0, GetRuleGUID = x.GetRuleGUID, PackId = x.PackId, Quantity = x.Quantity, Name = z?.Name, Description = z?.Description, PromtionName = z?.PromtionName, RuleID = z?.RuleID ?? 0, Term = z?.Term, ValiEndDate = z?.ValiEndDate, ValiStartDate = z?.ValiStartDate, }).ToList(); } catch (Exception ex) { logger.Error(ex.Message, ex); } return(result ?? new List <GiftPackCouponConfig>()); }
/// <summary> /// 新增礼包配置 /// </summary> /// <param name="config"></param> /// <returns></returns> public bool AddVipBaoYangGiftPackConfig(VipBaoYangGiftPackConfig config, string user) { bool success = false; try { var pkid = dbScopeManager.Execute(conn => DALVipBaoYangPackage.AddVipBaoYangGiftPackConfig(conn, config)); success = pkid > 0; config.PKID = pkid; if (success) { VipBaoYangPackageService.InsertBaoYangOprLog(new { LogType = "VipBaoYangPackageRedemptionCodeGiftPack", IdentityID = pkid.ToString(), OldValue = string.Empty, NewValue = JsonConvert.SerializeObject(new { config.PackId, config.PackageId, config.IsValid, config.PackName }), Remarks = $"Add", OperateUser = user, }); } } catch (Exception ex) { logger.Error(ex.Message, ex); } return(success); }
/// <summary> /// 添加保养套餐 /// </summary> /// <param name="package"></param> /// <returns></returns> public bool InsertVipBaoYangPackage(VipBaoYangPackageViewModel package) { var result = false; var productId = string.Empty; try { dbScopeManager.CreateTransaction(conn => { var pkid = DALVipBaoYangPackage.InsertVipBaoYangPackage(conn, new VipBaoYangPackageDbModel(package)); if (pkid > 0) { productId = $"BY-TUHU-BXGSDCBY|{pkid.ToString()}"; result = DALVipBaoYangPackage.UpdateVipBaoYangPackagePID(conn, pkid, productId) > 0; } if (result) { package.PKID = pkid; package.PID = productId; VipBaoYangPackageService.CreateProduct(pkid.ToString(), package.PackageName, package.CreateUser); } }); if (result) { InsertLog(productId, null, JsonConvert.SerializeObject(package), "Insert", package.CreateUser); } } catch (Exception ex) { logger.Error(ex); } return(result); }
/// <summary> /// 获取单次保养套餐Id和Name /// </summary> /// <returns></returns> public Dictionary <int, string> GetVipBaoYangConfigSimpleInfo() { var dict = null as Dictionary <int, string>; try { dict = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectVipBaoYangConfigSimpleInfo(conn)); } catch (Exception ex) { logger.Error(ex.Message, ex); } return(dict ?? new Dictionary <int, string>()); }
/// <summary> /// 修改礼包配置 /// </summary> /// <param name="config"></param> /// <returns></returns> public bool EditVipBaoYangGiftPackConfig(VipBaoYangGiftPackConfig config) { bool success = false; try { success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.EditVipBaoYangGiftPackConfig(conn, config)); } catch (Exception ex) { logger.Error(ex.Message, ex); } return(success); }
/// <summary> /// 是否存在礼包名称 /// </summary> /// <param name="config"></param> /// <returns></returns> public bool IsExisitsVipBaoYangGiftPackName(VipBaoYangGiftPackConfig config) { bool exists = false; try { exists = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.IsExisitsVipBaoYangGiftPackName(conn, config)); } catch (Exception ex) { logger.Error(ex.Message, ex); } return(exists); }
/// <summary> /// 根据RuleId获取'获取优惠券规则' /// </summary> /// <param name="ruleId"></param> /// <returns></returns> public List <Tuple <int, Guid, string, string> > GetCouponGetRules(int ruleId) { List <Tuple <int, Guid, string, string> > result = null; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectCouponGetRules(conn, ruleId)); } catch (Exception ex) { logger.Error(ex); } return(result ?? new List <Tuple <int, Guid, string, string> >()); }
public List <BaoYangPackagePromotionDetail> SelectPromotionDetailsByBatchCode(string batchCode) { List <BaoYangPackagePromotionDetail> result = new List <BaoYangPackagePromotionDetail>(); try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectPromotionDetailsByBatchCode(conn, batchCode)); } catch (Exception ex) { logger.Error(ex); } return(result); }
public List <VipBaoYangRedemptionCodeSimpleModel> GetRedemptionCodeSimpleInfo(long packId) { List <VipBaoYangRedemptionCodeSimpleModel> result = null; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectRedemptionCodeSimpleInfo(conn, packId)); } catch (Exception ex) { logger.Error("GetRedemptionCodeSimpleInfo", ex); } return(result ?? new List <VipBaoYangRedemptionCodeSimpleModel>()); }
/// <summary> /// 获取所有优惠券规则 /// </summary> /// <returns></returns> public Dictionary <int, string> GetAllCouponRules() { Dictionary <int, string> result = null; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectCouponRules(conn)); } catch (Exception ex) { logger.Error(ex); } return(result ?? new Dictionary <int, string>()); }
/// <summary> /// 获取所有的保养套餐 /// </summary> /// <returns></returns> public List <VipBaoYangPackageModel> SelectAllVipBaoYangPackage() { List <VipBaoYangPackageModel> result = null; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectAllVipBaoYangPackage(conn)); } catch (Exception ex) { logger.Error(ex); } return(result ?? new List <VipBaoYangPackageModel>()); }
/// <summary> /// 获取配置了套餐的喷漆大客户 /// </summary> /// <returns></returns> public List <VipSimpleUser> GetAllBaoYangPackageUser() { List <VipSimpleUser> result = new List <VipSimpleUser>(); try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.GetAllBaoYangPackageUser(conn)); } catch (Exception ex) { logger.Error(ex); } return(result); }
public List <PromotionOperationRecord> SelectPromotionOperationRecord(string pid, Guid vipUserId, int packageId, string batchCode, string mobilePhone, int pageIndex, int pageSize) { List <PromotionOperationRecord> result = new List <PromotionOperationRecord>(); try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectPromotionOperationRecord(conn, pid, vipUserId, packageId, batchCode, mobilePhone, pageIndex, pageSize)); } catch (Exception ex) { logger.Error(ex); } return(result); }
public List <VipBaoYangPackageModel> GetBaoYangPackageNameByVipUserId(Guid vipUserId) { List <VipBaoYangPackageModel> result = new List <VipBaoYangPackageModel>(); try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.GetBaoYangPackageNameByVipUserId(conn, vipUserId)); } catch (Exception ex) { logger.Error(ex); } return(result); }
public bool IsExistsPackageName(string packageName, int pkid) { var result = false; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.IsExistsPackageName(conn, packageName, pkid)) > 0; } catch (Exception ex) { logger.Error(ex); } return(result); }
private List <BaoYangPackagePromotionDetail> GetImportedPromotionDetail( Guid ruleGuid, IEnumerable <string> mobileNumbers) { var result = new List <BaoYangPackagePromotionDetail>(); if (ruleGuid != Guid.Empty && mobileNumbers != null && mobileNumbers.Any()) { for (var i = 1; i <= Math.Ceiling(mobileNumbers.Count() * 1.0 / 500); i++) { var batchResult = dbScopeReadManager .Execute(conn => DALVipBaoYangPackage.SelectImportedPromotionDetail(conn, ruleGuid, mobileNumbers.Skip((i - 1) * 500).Take(500))); result.AddRange(batchResult); } } return(result); }
/// <summary> /// 分页获取配置 /// </summary> /// <param name="index"></param> /// <param name="size"></param> /// <returns></returns> public VipBaoYangPagerModel <VipBaoYangGiftPackConfig> GetVipBaoYangGiftPackConfig(int index, int size) { var result = null as VipBaoYangPagerModel <VipBaoYangGiftPackConfig>; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectVipBaoYangGiftPackConfig(conn, index, size)); } catch (Exception ex) { logger.Error(ex.Message, ex); } return(result ?? new VipBaoYangPagerModel <VipBaoYangGiftPackConfig> { Total = 0, Data = new List <VipBaoYangGiftPackConfig>() }); }
public BaoYangPackageConfigSimpleInfo GetPackageConfigSimpleInfo(string batchCode) { var resulut = null as BaoYangPackageConfigSimpleInfo; if (!string.IsNullOrEmpty(batchCode)) { try { resulut = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectPackageConfigSimpleInfo(conn, batchCode)); } catch (Exception ex) { logger.Error(ex.Message, ex); } } return(resulut); }
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); }
public Dictionary <int, bool> InvalidCodes(List <int> codes, string user) { Dictionary <int, bool> result = new Dictionary <int, bool>(); List <PromotionCodeModel> promotionCodes = new List <PromotionCodeModel>(); using (var client = new PromotionClient()) { var serviceResult = client.GetPromotionCodeByIDs(new GetPromotionCodesRequest() { PKIDList = codes }); if (serviceResult.Success) { promotionCodes = serviceResult.Result.ToList(); } } foreach (var code in promotionCodes) { using (var client = new PromotionClient()) { var serviceResult = client.UpdateUserPromotionCodeStatus(new UpdateUserPromotionCodeStatusRequest() { Status = 3, PromotionCodeId = code.Pkid, OperationAuthor = user, Channel = "setting.tuhu.cn", UserID = Guid.Parse(code.UserId) }); if (serviceResult.Exception != null) { logger.Error(serviceResult.Exception); } result[code.Pkid] = serviceResult.Success && serviceResult.Result; } } foreach (var item in result) { if (item.Value) { dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdatePromotionRemarks(conn, item.Key, $"{user}于{DateTime.Now.ToString("yyyy年MM月dd日 hh:mm")}作废此券")); } } return(result); }
/// <summary> /// 根据主键Id获取套餐详情 /// </summary> /// <param name="pkid"></param> /// <returns></returns> public VipBaoYangPackageViewModel SelectVipBaoYangPackageByPkid(int pkid) { VipBaoYangPackageViewModel result = null; try { var package = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectVipBaoYangPackageByPkid(conn, pkid)); result = new VipBaoYangPackageViewModel(package); var user = BaoYangExternalService.GetCompanyUserInfo(result.VipUserId); result.VipUserName = user?.UserName; } catch (Exception ex) { logger.Error(ex); } return(result); }
/// <summary> /// 获取兑换码 /// </summary> /// <param name="batchCode"></param> /// <param name="packId"></param> /// <returns></returns> public List <VipBaoYangRedemptionCode> GetRedemptionCodeDetails(string batchCode, long packId, string user) { List <VipBaoYangRedemptionCode> result = null; try { result = dbScopeReadManager.Execute(conn => DALVipBaoYangPackage.SelectRedemptionCodeDetails(conn, batchCode, packId)); if (result.Any()) { InsertDownloadRedemptionCodeRecord(batchCode, user); } } catch (Exception ex) { logger.Error(ex.Message, ex); } return(result ?? new List <VipBaoYangRedemptionCode>()); }
public List <VipBaoYangPackageSmsConfig> SelectVipSmsConfig(Guid vipUserId, int pageIndex, int pageSize) { List <VipBaoYangPackageSmsConfig> result = new List <VipBaoYangPackageSmsConfig>(); try { dbScopeReadManager.Execute(conn => { result = DALVipBaoYangPackage.SelectVipSmsConfig(conn, vipUserId, pageIndex, pageSize); }); } catch (Exception ex) { logger.Error(ex); } return(result); }
public bool BatchBaoYangPakckagePromotion(int packageId, Guid ruleGUID, string sha1Value, string batchCode, string operatorUser) { var result = false; try { dbScopeManager.Execute(conn => { var isSendSms = DALVipBaoYangPackage.IsSendSmsByPackageId(conn, packageId); result = DALVipBaoYangPackage.InsertBaoYangPackagePromotionRecord(conn, packageId, batchCode, ruleGUID, isSendSms, operatorUser) > 0; SetUploadedFileSah1Cache(sha1Value); }); } catch (Exception ex) { logger.Error(ex); } return(result); }