/// <summary> /// 更新 /// </summary> /// <param name="pEntity">实体实例</param> /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param> public void Update(CouponTypeItemMappingEntity pEntity, IDbTransaction pTran) { _currentDAO.Update(pEntity, pTran); }
/// <summary> /// 创建一个新实例 /// </summary> /// <param name="pEntity">实体实例</param> public void Create(CouponTypeItemMappingEntity pEntity) { _currentDAO.Create(pEntity); }
/// <summary> /// 分页根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public PagedQueryResult <CouponTypeItemMappingEntity> PagedQueryByEntity(CouponTypeItemMappingEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex) { return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex)); }
/// <summary> /// 根据实体条件查询实体 /// </summary> /// <param name="pQueryEntity">以实体形式传入的参数</param> /// <param name="pOrderBys">排序组合</param> /// <returns>符合条件的实体集</returns> public CouponTypeItemMappingEntity[] QueryByEntity(CouponTypeItemMappingEntity pQueryEntity, OrderBy[] pOrderBys) { return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys)); }
/// <summary> /// 删除 /// </summary> /// <param name="pEntity"></param> public void Delete(CouponTypeItemMappingEntity pEntity) { _currentDAO.Delete(pEntity); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetCouponRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var couponTypeBLL = new CouponTypeBLL(loggingSessionInfo); var couponBLL = new CouponBLL(loggingSessionInfo); var couponTypeUnitMappingBLL = new CouponTypeUnitMappingBLL(loggingSessionInfo); CouponTypeItemMappingBLL bllCouponTypeItemMapping = new CouponTypeItemMappingBLL(loggingSessionInfo); CouponTypeItemMappingEntity entityCouponTypeItemMapping = null; var redisCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisCouponBLL(); if (couponTypeBLL.ExistsCouponTypeName(para.CouponTypeName, loggingSessionInfo.ClientID) > 0) { throw new APIException(-1, "优惠券名称不可重复!"); } var pTran = couponTypeBLL.GetTran();//事务 using (pTran.Connection) { try { CouponTypeEntity couponTypeEntity = null; //保存券产品表 if (string.IsNullOrEmpty(para.CouponTypeID))//生成优惠券 { couponTypeEntity = new CouponTypeEntity(); couponTypeEntity.CouponTypeName = para.CouponTypeName; couponTypeEntity.CouponTypeDesc = para.CouponTypeDesc; couponTypeEntity.CouponCategory = para.CouponCategory; couponTypeEntity.ParValue = para.ParValue; couponTypeEntity.IsVoucher = 0; couponTypeEntity.UsableRange = para.UsableRange; if (para.BeginTime != DateTime.MinValue) { couponTypeEntity.BeginTime = para.BeginTime; } if (para.EndTime != DateTime.MinValue) { para.EndTime = para.EndTime.AddHours(23).AddMinutes(59).AddSeconds(59); couponTypeEntity.EndTime = para.EndTime; } couponTypeEntity.ServiceLife = para.ServiceLife; couponTypeEntity.ConditionValue = para.ConditionValue; couponTypeEntity.SuitableForStore = para.SuitableForStore; couponTypeEntity.CustomerId = loggingSessionInfo.ClientID; couponTypeEntity.IsNotLimitQty = para.IsNotLimitQty; if (para.IsNotLimitQty != null && para.IsNotLimitQty == 1) { couponTypeEntity.IssuedQty = 1000; } else { couponTypeEntity.IssuedQty = para.IssuedQty; } couponTypeEntity.IsRepeatable = 0; couponTypeEntity.IsMixable = 0; couponTypeEntity.ValidPeriod = 0; couponTypeEntity.CouponTypeID = couponTypeBLL.CreateReturnID(couponTypeEntity, pTran); redisCouponBLL.RedisSetSingleCoupon(new CC_Coupon() { CustomerId = couponTypeEntity.CustomerId, CouponTypeId = couponTypeEntity.CouponTypeID.ToString(), CouponTypeDesc = couponTypeEntity.CouponTypeDesc, CouponTypeName = couponTypeEntity.CouponTypeName, BeginTime = couponTypeEntity.BeginTime.ToString(), EndTime = couponTypeEntity.EndTime.ToString(), ServiceLife = couponTypeEntity.ServiceLife ?? 0, CouponLenth = couponTypeEntity.IssuedQty ?? 0, CouponCategory = couponTypeEntity.CouponCategory }); //保存适用门店 if (para.SuitableForStore == 2) { CouponTypeUnitMappingEntity mapping = null; foreach (var obj in para.ObjectIDList) { mapping = new CouponTypeUnitMappingEntity() { CouponTypeID = couponTypeEntity.CouponTypeID, ObjectID = obj.ObjectID, CustomerID = loggingSessionInfo.ClientID }; couponTypeUnitMappingBLL.Create(mapping, pTran); } } if (!string.IsNullOrEmpty(para.BindType) && para.BindTypeIdList != null) { foreach (var objId in para.BindTypeIdList) { entityCouponTypeItemMapping = new CouponTypeItemMappingEntity() { CouponTypeID = couponTypeEntity.CouponTypeID, BindType = para.BindType, ObjectId = objId.ObjectID }; bllCouponTypeItemMapping.Create(entityCouponTypeItemMapping); } } } else//追加优惠券 { couponTypeEntity = couponTypeBLL.GetByID(para.CouponTypeID); couponTypeEntity.IssuedQty += para.IssuedQty; couponTypeBLL.Update(couponTypeEntity); redisCouponBLL.RedisSetSingleCoupon(new CC_Coupon() { CustomerId = couponTypeEntity.CustomerId, CouponTypeId = couponTypeEntity.CouponTypeID.ToString(), CouponTypeDesc = couponTypeEntity.CouponTypeDesc, CouponTypeName = couponTypeEntity.CouponTypeName, BeginTime = couponTypeEntity.BeginTime.ToString(), EndTime = couponTypeEntity.EndTime.ToString(), ServiceLife = couponTypeEntity.ServiceLife ?? 0, CouponLenth = para.IssuedQty, CouponCategory = couponTypeEntity.CouponCategory }); } pTran.Commit();//提交事物 //批量生成券 //if (couponTypeEntity != null) //{ // Hashtable htCouponInfo = new Hashtable(); // htCouponInfo["CouponTypeID"] = couponTypeEntity.CouponTypeID; // htCouponInfo["CouponName"] = couponTypeEntity.CouponTypeName; // htCouponInfo["CouponDesc"] = couponTypeEntity.CouponTypeDesc; // if (couponTypeEntity.BeginTime != DateTime.MinValue) // htCouponInfo["BeginTime"] = couponTypeEntity.BeginTime; // else // htCouponInfo["BeginTime"] = null; // if (couponTypeEntity.EndTime != DateTime.MinValue) // htCouponInfo["EndTime"] = couponTypeEntity.EndTime; // else // htCouponInfo["EndTime"] = null; // htCouponInfo["IssuedQty"] = para.IssuedQty; // couponBLL.GenerateCoupon(htCouponInfo); //} } catch (Exception ex) { pTran.Rollback(); throw new APIException(ex.Message); } } return(rd); }