protected override SetEvaluationRD ProcessRequest(APIRequest <SetEvaluationRP> pRequest)
        {
            SetEvaluationRD rd    = new SetEvaluationRD();
            var             oeBll = new ObjectEvaluationBLL(CurrentUserInfo);
            var             pTran = oeBll.GetTran();//事务

            using (pTran.Connection)
            {
                try
                {
                    SetEvaluationRP rp = pRequest.Parameters;

                    //查询参数
                    List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                    };
                    complexCondition.Add(new EqualsCondition()
                    {
                        FieldName = "CustomerID", Value = pRequest.CustomerID
                    });
                    complexCondition.Add(new EqualsCondition()
                    {
                        FieldName = "ObjectID", Value = rp.ObjectID
                    });
                    complexCondition.Add(new EqualsCondition()
                    {
                        FieldName = "Type", Value = 4
                    });
                    complexCondition.Add(new EqualsCondition()
                    {
                        FieldName = "VipID", Value = pRequest.UserID
                    });
                    complexCondition.Add(new DirectCondition(" (CreateTime between '" + DateTime.Now.Date + "' and '" + DateTime.Now.AddDays(1).Date + "' )"));
                    var tempList = oeBll.Query(complexCondition.ToArray(), null);

                    //var oeEntitys = oeBll.QueryByEntity(new ObjectEvaluationEntity() { VipID = rp.ObjectID,CustomerID = pRequest.CustomerID }, null);
                    if (tempList.Length > 0)
                    {
                        throw new APIException("一天只可以评论一次!")
                              {
                                  ErrorCode = 103
                              };
                    }
                    //评论
                    var entity = new ObjectEvaluationEntity()
                    {
                        EvaluationID = Guid.NewGuid().ToString(),
                        CustomerID   = pRequest.CustomerID,
                        VipID        = pRequest.UserID,
                        ObjectID     = rp.ObjectID,
                        Type         = rp.Type,
                        Content      = rp.Content,
                        StarLevel    = rp.StarLevel,
                        StarLevel1   = rp.StarLevel1,
                        StarLevel2   = rp.StarLevel2,
                        StarLevel3   = rp.StarLevel3,
                        StarLevel4   = rp.StarLevel4,
                        StarLevel5   = rp.StarLevel5,
                        Platform     = rp.Platform,
                        IsAnonymity  = rp.IsAnonymity
                    };
                    oeBll.Create(entity, pTran);


                    pTran.Commit();//提交事务
                }
                catch (Exception ex)
                {
                    pTran.Rollback();
                    throw new APIException(ex.Message);
                }
            }

            return(rd);
        }
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(ObjectEvaluationEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(ObjectEvaluationEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <ObjectEvaluationEntity> PagedQueryByEntity(ObjectEvaluationEntity 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 ObjectEvaluationEntity[] QueryByEntity(ObjectEvaluationEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(ObjectEvaluationEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(ObjectEvaluationEntity pEntity)
 {
     _currentDAO.Update(pEntity);
 }
Exemple #8
0
        protected override SetEvaluationRD ProcessRequest(APIRequest <SetEvaluationItemRP> pRequest)
        {
            SetEvaluationRD rd    = new SetEvaluationRD();
            var             bll   = new ObjectEvaluationBLL(CurrentUserInfo);
            var             pTran = bll.GetTran();//事务

            using (pTran.Connection)
            {
                try
                {
                    SetEvaluationItemRP rp = pRequest.Parameters;
                    var inoutBll           = new T_InoutBLL(CurrentUserInfo);
                    //评论订单
                    var entity = new ObjectEvaluationEntity()
                    {
                        EvaluationID = Guid.NewGuid().ToString(),
                        CustomerID   = pRequest.CustomerID,
                        VipID        = pRequest.UserID,
                        ObjectID     = rp.OrderID,
                        OrderID      = rp.OrderID,
                        Type         = rp.Type,
                        Content      = rp.Content,
                        StarLevel    = rp.StarLevel,
                        StarLevel1   = rp.StarLevel1,
                        StarLevel2   = rp.StarLevel2,
                        StarLevel3   = rp.StarLevel3,
                        StarLevel4   = rp.StarLevel4,
                        StarLevel5   = rp.StarLevel5,
                        Platform     = rp.Platform,
                        IsAnonymity  = rp.IsAnonymity
                    };
                    bll.Create(entity, pTran);

                    //批量评论商品
                    if (rp.ItemEvaluationInfo != null)
                    {
                        ObjectEvaluationEntity evaluation = null;
                        foreach (var item in rp.ItemEvaluationInfo)
                        {
                            evaluation             = new ObjectEvaluationEntity();
                            evaluation.ObjectID    = item.ObjectID;
                            evaluation.StarLevel   = item.StarLevel;
                            evaluation.Content     = item.Content;
                            evaluation.Remark      = item.Remark;
                            evaluation.CustomerID  = pRequest.CustomerID;
                            evaluation.IsAnonymity = rp.IsAnonymity;
                            evaluation.OrderID     = rp.OrderID;
                            evaluation.Type        = rp.Type;
                            evaluation.VipID       = pRequest.UserID;
                            bll.Create(evaluation, pTran);
                        }
                    }

                    //修改订单评论状态
                    var order = inoutBll.GetByID(rp.OrderID);
                    if (order != null)
                    {
                        order.IsEvaluation = 1;
                        inoutBll.Update(order, pTran);
                    }
                    pTran.Commit(); //提交事物

                    #region 评论触点活动奖励

                    var bllPrize = new LPrizesBLL(CurrentUserInfo);
                    //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Comment");

                    RedisContactBLL redisContactBll = new RedisContactBLL();
                    redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact()
                    {
                        CustomerId  = CurrentUserInfo.ClientID,
                        ContactType = "Comment",
                        VipId       = CurrentUserInfo.UserID
                    });

                    #endregion

                    try
                    {
                        var msg = new EventContract
                        {
                            Operation  = OptEnum.Create,
                            EntityType = EntityTypeEnum.OrderComment,
                            Id         = rp.OrderID
                        };
                        var eventService = new EventService();
                        eventService.PublishMsg(msg);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    pTran.Rollback();
                    throw new APIException(ex.Message);
                }
            }

            return(rd);
        }