Beispiel #1
0
        /// <summary>
        /// 设置跟踪信息
        /// </summary>
        /// <param name="recordId">记录ID</param>
        /// <param name="trackInfo">跟踪信息</param>
        public void SetTrackInfo(long recordId, string trackInfo)
        {
            PointGiftExchangeRecord record = this.GetRecord(recordId);

            record.TrackInfo = trackInfo;
            recordRepository.Update(record);
        }
Beispiel #2
0
        /// <summary>
        /// 是否批准申请
        /// </summary>
        /// <remarks>
        /// 1.需要触发的事件:1)Update的OnBefore、OnAfter;
        /// 2.如果申请通过,则不能被取消。
        /// 3.申请通过后触发动态,通知。
        /// 4.申请被否决后,积分返还。
        /// </remarks>
        /// <param name="record">记录对象</param>
        /// <param name="isApprove">是否批准</param>
        public void IsApprove(PointGiftExchangeRecord record, bool isApprove)
        {
            if (isApprove)
            {
                PointGift gift = this.GetGift(record.GiftId);
                record.LastModified = DateTime.UtcNow;
                record.Status       = ApproveStatus.Approved;
                gift.ExchangedCount = gift.ExchangedCount + record.Number;
                giftRepository.Update(gift);
                pointService.TradeToSystem(record.PayerUserId, record.Price, "兑换商品", false);
                EventBus <PointGiftExchangeRecord> .Instance().OnAfter(record, new CommonEventArgs(EventOperationType.Instance().Approved()));
            }
            else
            {
                record.Status = ApproveStatus.Rejected;
                userService.UnfreezeTradePoints(record.PayerUserId, record.Price);
                EventBus <PointGiftExchangeRecord> .Instance().OnAfter(record, new CommonEventArgs(EventOperationType.Instance().Disapproved()));
            }

            //处理统计数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(record.PayerUserId, OwnerDataKeys.Instance().PostCount(), -1);

            recordRepository.Update(record);
        }
Beispiel #3
0
        /// <summary>
        /// 设置评价
        /// </summary>
        /// <param name="recordId">记录ID</param>
        /// <param name="appraise">评价内容</param>
        public void SetAppraise(long recordId, string appraise)
        {
            PointGiftExchangeRecord record = this.GetRecord(recordId);

            record.Appraise = appraise;
            recordRepository.Update(record);
        }
        /// <summary>
        /// 新建实体时使用
        /// </summary>
        public static PointGiftExchangeRecord New()
        {
            PointGiftExchangeRecord record = new PointGiftExchangeRecord()
            {
                DateCreated  = DateTime.UtcNow,
                LastModified = DateTime.UtcNow,
                Status       = ApproveStatus.Pending
            };

            return(record);
        }
Beispiel #5
0
        /// <summary>
        /// 创建兑换记录
        /// </summary>
        /// <remarks>
        /// 1.冻结相应积分
        /// </remarks>
        /// <param name="record">记录对象</param>
        /// <returns></returns>
        public long CreateRecord(PointGiftExchangeRecord record)
        {
            if (record.Price > 0)
            {
                userService.FreezeTradePoints(record.PayerUserId, record.Price);

                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(record.PayerUserId, OwnerDataKeys.Instance().PostCount(), 1);
            }
            recordRepository.Insert(record);
            return(record.RecordId);
        }
Beispiel #6
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <remarks>
        /// 1.管理员无权删除兑换记录
        /// 2.记录已经批准则不能删除记录
        /// 3.冻结积分返还
        /// </remarks>
        /// <param name="record">记录对象</param>
        public bool CancelRecord(PointGiftExchangeRecord record)
        {
            if (record.Status == ApproveStatus.Pending)
            {
                userService.UnfreezeTradePoints(record.PayerUserId, record.Price);

                //处理统计数据
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(record.PayerUserId, OwnerDataKeys.Instance().PostCount(), -1);

                recordRepository.Delete(record);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
 /// <summary>
 /// 转化为ViewModel
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 public static RecordEditModel AsRecordEditModel(this PointGiftExchangeRecord record)
 {
     return(new RecordEditModel
     {
         Address = record.Address,
         GiftName = record.GiftName,
         Addressee = record.Addressee,
         PostCode = record.PostCode,
         Tel = record.Tel,
         DateCreated = record.DateCreated,
         GiftId = record.GiftId,
         LastModified = record.LastModified,
         Number = record.Number,
         Payer = record.Payer,
         PayerUserId = record.PayerUserId,
         RecordId = record.RecordId,
         Status = record.Status,
         TrackInfo = record.TrackInfo,
     });
 }
Beispiel #8
0
        /// <summary>
        /// 转化为数据库实体
        /// </summary>
        /// <returns></returns>
        public PointGiftExchangeRecord AsPointGiftExchangeRecord()
        {
            PointGiftExchangeRecord record = PointGiftExchangeRecord.New();

            record.Address      = this.Address ?? string.Empty;
            record.Addressee    = this.Addressee ?? string.Empty;
            record.Appraise     = string.Empty;
            record.AppraiseDate = null;
            record.DateCreated  = DateTime.UtcNow;
            record.GiftId       = this.GiftId;
            record.GiftName     = record.PointGift.Name;
            record.LastModified = DateTime.UtcNow;
            record.Number       = this.Number;
            record.Payer        = UserContext.CurrentUser.DisplayName;
            record.PayerUserId  = UserContext.CurrentUser.UserId;
            record.PostCode     = this.PostCode ?? string.Empty;
            record.Status       = this.Status;
            record.TrackInfo    = string.Empty;
            record.Tel          = this.Tel;
            return(record);
        }