public IRAPError CheckTransact(long transactNo, string userCode) { TransactEntity t1 = GetEntities <TransactEntity>().FirstOrDefault(c => c.PartitioningKey == TransPK && c.TransactNo == transactNo); if (t1 == null) { throw new Exception($"交易号:{t1.TransactNo} 不存在!"); } t1.Checked = userCode; t1.OkayTime = DateTime.Now; t1.Status = 3; SaveChanges(); return(new IRAPError(0, "交易复核成功!")); }
/// <summary> /// 撤销交易 /// </summary> /// <param name="transactNo">交易号</param> /// <param name="deleteFact">是否删除事实(默认是)</param> /// <returns></returns> public virtual IRAPError UnCheckTransact(long transactNo, bool deleteFact = true) { TransactEntity t1 = GetEntities <TransactEntity>().FirstOrDefault(c => c.PartitioningKey == TransPK && c.TransactNo == transactNo); if (t1 == null) { throw new Exception($"交易号:{t1.TransactNo} 不存在!"); } t1.Status = 1; t1.Checked = ""; t1.OkayTime = null; if (deleteFact) { IDbSet <FactEntity> tempFactList = _db.Set <FactEntity>(); var list = tempFactList.Where(c => c.TransactNo == t1.TransactNo && c.PartitioningKey == FactPK); foreach (FactEntity r in list) { tempFactList.Remove(r); } } SaveChanges(); return(new IRAPError(0, "交易撤销成功!")); }
/// <summary> /// 申请交易号 /// </summary> /// <param name="cnt">申请数量</param> /// <param name="remark">交易备注</param> /// <param name="opNodes">操作类型清单,多个用逗号隔开</param> /// <param name="voucherNo">票据号</param> /// <returns></returns> public long GetTransactNo(int cnt = 1, string remark = "", string opNodes = "", string voucherNo = "") { try { if (opNodes == "") { opNodes = (-_opID).ToString(); } LoginEntity log = new IRAPLog().GetLogIDByToken(access_token); if (log == null) { throw new Exception("申请交易号时出错,令牌无效!"); } long transactNo = IRAPSequence.GetTransactNo(); TransactEntity e = new TransactEntity() { AgencyLeaf1 = log.AgencyLeaf, IPAddress = log.IPAddress, Operator = log.UserCode, OperTime = DateTime.Now, OpNodes = _opID.ToString(), PartitioningKey = TransPK, StationID = log.StationID, Status = 1, Remark = remark, TransactNo = transactNo, VoucherNo = voucherNo }; _db.Set <TransactEntity>().Add(e); _db.SaveChanges(); return(transactNo); } catch (Exception err) { throw err; } }
/// <summary> /// 交易撤销到回收站 /// </summary> /// <param name="transactNo"></param> /// <returns></returns> public IRAPError DeleteToRecycle(long transactNo) { TransactEntity t1 = GetEntities <TransactEntity>().FirstOrDefault(c => c.PartitioningKey == TransPK && c.TransactNo == transactNo); if (t1 == null) { throw new Exception($"交易号:{t1.TransactNo} 不存在!"); } if (t1.Status > 3) { throw new Exception($"交易号:{t1.TransactNo} 已被撤销或已被固化!{t1.Status}"); } t1.Revoker = log.UserCode; t1.RevokeTime = DateTime.Now; t1.Status = 4; //移动到Recycle var list = GetEntities <FactEntity>().Where(c => c.PartitioningKey == TempFactPK && c.TransactNo == transactNo); int i = 0; foreach (var r in list) { RecycleFactEntity t2 = new RecycleFactEntity(); r.CopyTo(t2); t2.Remark = t2.Remark + "[撤销]"; _db.Set <RecycleFactEntity>().Add(t2); _db.Set <FactEntity>().Remove(r); i++; } if (i == 0) { return(new IRAPError(11, "交易没有对应的事实记录!")); } SaveChanges(); return(new IRAPError(0, "交易撤销成功!")); }
//保存主交易 protected virtual IRAPError SaveTransact(TransactEntity e) { return(null); }