public JsonHelp Isok(int id, int type, string userid, string username) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "操作失败" }; using (var tran = DB.Fin_Remit.BeginTransaction) { try { var remit = FindEntity(id); if (remit.RemitState == "已通过" || remit.RemitState == "已驳回") { json.Msg = "不能重复审核!"; return(json); } if (type == 1) { remit.RemitState = "已通过"; remit.ConfirmTime = DateTime.Now; remit.ConfirmEmpId = userid; remit.ConfirmEmpName = username; if (Update(remit)) { var member = DB.Member_Info.FindEntity(p => p.MemberId == remit.MemberId); member.Commission = member.Commission + remit.Amount; DB.Fin_LiuShui.AddLS(member.MemberId, remit.Amount.Value, "汇款通过"); DB.Member_Info.Update(member); //流水账单 Fin_LiuShui _liushui = new Fin_LiuShui(); _liushui.MemberId = member.MemberId; _liushui.Code = member.Code; _liushui.NickName = member.NickName; _liushui.Type = "流水账单"; _liushui.Comment = "汇款报单积分(+)"; _liushui.Amount = remit.Amount; _liushui.CreateTime = DateTime.Now; DB.Fin_LiuShui.Insert(_liushui); json.Status = "y"; json.Msg = "操作成功"; DB.SysLogs.setAdminLog(Enums.EventType.Edit, string.Format("汇款申请已通过,汇款人:[{0}],金额:[{1}]", remit.MemberCode, remit.Amount)); } } else if (type == 2) { remit.RemitState = "已驳回"; remit.ConfirmTime = DateTime.Now; remit.ConfirmEmpId = userid; remit.ConfirmEmpName = username; if (Update(remit)) { json.Status = "y"; json.Msg = "操作成功"; DB.SysLogs.setAdminLog(Enums.EventType.Edit, string.Format("汇款申请已驳回,汇款人:[{0}],金额:[{1}]", remit.MemberCode, remit.Amount)); } } tran.Complete(); } catch (Exception e) { DB.Rollback(); LogHelper.Error("是否通过汇款申请,出错:" + e.Message); } } return(json); }
/// <summary> /// 保存 /// </summary> /// <param name="pwd2">支付密码</param> /// <param name="commission">可用收益余额</param> /// <param name="coins">可用余额(电子币)</param> /// <param name="entity">当前实体对象</param> public JsonHelp Save(string pwd2, Fin_Transfer entity) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "保存失败" }; if (entity.Amount <= 0) { json.Msg = "转账金额要大于0!"; return(json); } using (var tran = DB.Fin_Transfer.BeginTransaction) { try { var members = DB.Member_Info.Where(a => a.MemberId == entity.FromMemberId || a.Code == entity.ToMemberCode).ToList(); var fm = members.FirstOrDefault(a => a.MemberId == entity.FromMemberId); var tm = members.FirstOrDefault(a => a.Code == entity.ToMemberCode); if (tm == null) { json.Msg = "转给会员编号不正确!"; return(json); } if (fm.Pwd2 != pwd2) { json.Msg = "支付密码不正确!"; return(json); } if (fm.MemberId == tm.MemberId) { json.Msg = "不能转给自己!"; return(json); } if (!DB.XmlConfig.XmlSite.IsTransfer) { json.Msg = "转账总开关关闭,操作失败!"; return(json); } if (fm.IsSub.Value) { json.Msg = "转出方开关关闭,操作失败!"; return(json); } if (tm.IsSub.Value) { json.Msg = "转入方开关关闭,操作失败!"; return(json); } //if (entity.TransferType == "收益币互转") //{ // if (fm.Commission < entity.Amount) // { // json.Msg = "收益不足,不能转账!"; // return json; // } //} if (entity.TransferType == "余额互转") { if (fm.Commission < entity.Amount) { json.Msg = "余额不足,不能转账!"; return(json); } } #region 只能上下级关系转账 //var canTransfer = false; //// 1.安置关系 //if (tm.Position.StartsWith(fm.Position) || fm.Position.StartsWith(tm.Position)) //{ // canTransfer = true; //} //// 2.推荐关系 //if (tm.RPosition.StartsWith(fm.RPosition) || fm.RPosition.StartsWith(tm.RPosition)) //{ // canTransfer = true; //} //if (canTransfer == false) //{ // json.Msg = "只有上下级关系才可以转账!"; // return json; //} #endregion //var min = DB.XmlConfig.XmlSite.MinAmountHuZ; //提现最小金额 //var Multiple = DB.XmlConfig.XmlSite.MultipleHuZ; //提现金额是这个的整数倍 //if (entity.Amount < min) //{ // json.Msg = "最小互转金额" + min + "!"; // return json; //} //if (entity.Amount % Multiple != 0) //{ // json.Msg = "互转倍数为" + Multiple + "!"; // return json; //} if (entity.TransferId == 0) { entity.ToMemberId = tm.MemberId; entity.ToNickName = tm.NickName; entity.FromMemberCode = fm.Code; entity.FromNickName = fm.NickName; entity.CreateTime = DateTime.Now; if (Insert(entity)) { if (entity.TransferType == "余额互转") { fm.Commission = fm.Commission - entity.Amount; tm.Commission = tm.Commission + entity.Amount; DB.Member_Info.Update(fm, tm); //流水账单 Fin_LiuShui _liushui = new Fin_LiuShui(); _liushui.MemberId = fm.MemberId; _liushui.Code = fm.Code; _liushui.NickName = fm.NickName; _liushui.Type = "余额"; _liushui.Comment = "余额互转"; _liushui.Amount = -entity.Amount; _liushui.CreateTime = DateTime.Now; DB.Fin_LiuShui.Insert(_liushui); _liushui.MemberId = tm.MemberId; _liushui.Code = tm.Code; _liushui.NickName = tm.NickName; _liushui.Type = "余额"; _liushui.Comment = "余额互转"; _liushui.Amount = entity.Amount; _liushui.CreateTime = DateTime.Now; DB.Fin_LiuShui.Insert(_liushui); } //if (entity.TransferType == "收益币互转") //{ // fm.Commission = fm.Commission - entity.Amount; // tm.Commission = tm.Commission + entity.Amount; // DB.Member_Info.Update(fm, tm); //} json.Status = "y"; json.Msg = "操作成功"; //添加操作日志 DB.SysLogs.setMemberLog("Save", string.Format("会员转账,转出会员编号:[{0}],转入会员编号:[{2}],金额:[{1}],转账类型:[{3}]操作成功", entity.FromMemberCode, entity.Amount, entity.ToMemberCode, entity.TransferType)); } } tran.Complete(); } catch (Exception e) { DB.Rollback(); LogHelper.Error("会员转账出错:" + e.Message); } } return(json); }
/// <summary> /// 购物结算处理 /// </summary> /// <param name="AddressID"></param> /// <param name="remark"></param> /// <returns></returns> public bool Calcute(Member_Info curUser, string orderid, string payPwd) { using (var tran = BeginTransaction) { try { if (curUser.Pwd2 != Common.CryptHelper.DESCrypt.Encrypt(payPwd)) { throw new Exception("支付密码不正确"); } Xml_Shop shopConfig = DB.XmlConfig.XmlShop; int state = ShopEnum.OrderState.Submit.GetHashCode(); var query = DB.ShopOrder.Where(q => q.MemberID == curUser.MemberId && q.State == state); if (string.IsNullOrEmpty(orderid) == false) { query = query.Where(q => q.GUID == orderid); } List <ShopOrder> orderList = query.ToList(); foreach (var order in orderList) { if (order.State != 1) { throw new Exception("订单不是待支付订单不可支付"); } Fin_LiuShui _liushui = new Fin_LiuShui(); //1.修改订单状态 order.PayState = ShopEnum.OrderPayState.Pay.GetHashCode(); order.PayTime = DateTime.Now; order.State = ShopEnum.OrderState.Pay.GetHashCode(); if (DB.ShopOrder.Update(order) == false) { throw new Exception("修改订单失败"); } decimal zong = (order.RealAmount + order.Postage.Value); if (curUser.Commission < zong) { throw new Exception("余额不足"); } curUser.Commission = Convert.ToDecimal(curUser.Commission - zong); DB.Fin_LiuShui.AddLS(curUser.MemberId, -zong, "商城下单"); if (DB.Member_Info.Update(curUser) == false) { throw new Exception("修改会员信息失败"); } DB.Jiang.GiveJiang(DB.Member_Info.FindEntity(order.MemberID), order); } tran.Complete(); return(true); } catch (Exception ex) { DB.Rollback(); throw ex; } } }
/// <summary> /// 增加奖金 /// </summary> /// <param name="member">要增加奖金的会员,</param> /// <param name="refMember">相关的会员,</param> /// <param name="amount">金额</param> /// <param name="db">数据库连接实例</param> /// <param name="typeName">奖金类型名称</param> /// <param name="Comment">奖金描述</param> /// <returns></returns> public JsonHelp InsertFin(DbMallEntities db, Member_Info member, Member_Info refMember, decimal amount, string typeName, string Comment) { JsonHelp json = new JsonHelp(true); if (amount < 0) { json.Msg = "奖金不能小于0"; return(json); } else if (amount == 0) { //奖金为0,直接返回,不向数据库增加数据 json.Msg = "奖金为0"; return(json); } //检查是否锁定此会员不得奖 if (member.IsLockCommission == true) { json.Msg = "此会员已锁定得奖,奖金不能分配"; return(json); } var Poundage = System.DB.XmlConfig.XmlSite.Poundage; var ChongXiao = System.DB.XmlConfig.XmlSite.ChongXiao; //插入费用明细 var mFin = new Fin_Info(); mFin.MemberId = member.MemberId; mFin.MemberCode = member.Code; mFin.NickName = member.NickName; mFin.Amount = amount; if (typeName == "挂卖奖励收益") { mFin.Poundage = 0; mFin.CongXiao = 0; if (typeName == "挂卖奖励收益") { mFin.RealAmount = 2100; } } else { mFin.Poundage = 0; mFin.CongXiao = 0; mFin.RealAmount = mFin.Amount; } mFin.TypeName = typeName; mFin.Comment = string.IsNullOrEmpty(Comment) ? typeName : Comment; mFin.RefMemberId = refMember.MemberId; mFin.RefMemberCode = refMember.Code; mFin.RefNickName = refMember.NickName; mFin.CreateTime = DateTime.Now; mFin.IsSettlement = true; mFin.SettlementTime = mFin.CreateTime; db.Fin_Info.Add(mFin); if (typeName == "挂卖奖励收益") { if (typeName == "挂卖奖励收益") { member.Commission += Convert.ToDecimal(mFin.RealAmount); member.CommissionSum += Convert.ToDecimal(mFin.RealAmount); Fin_LiuShui _liushui = new Fin_LiuShui(); //收益 _liushui.MemberId = member.MemberId; _liushui.Code = member.Code; _liushui.NickName = member.NickName; _liushui.Type = "流水账单"; _liushui.Comment = "收益(+)"; _liushui.Amount = mFin.RealAmount; _liushui.CreateTime = DateTime.Now; DB.Fin_LiuShui.Insert(_liushui); //累计收益 _liushui.MemberId = member.MemberId; _liushui.Code = member.Code; _liushui.NickName = member.NickName; _liushui.Type = "流水账单"; _liushui.Comment = "累计收益(+)"; _liushui.Amount = mFin.RealAmount; _liushui.CreateTime = DateTime.Now; } } else { member.Commission += mFin.RealAmount; member.CommissionSum += mFin.RealAmount; //收益 Fin_LiuShui _liushui = new Fin_LiuShui(); _liushui.MemberId = member.MemberId; _liushui.Code = member.Code; _liushui.NickName = member.NickName; _liushui.Type = "流水账单"; _liushui.Comment = "收益(+)"; _liushui.Amount = mFin.RealAmount; _liushui.CreateTime = DateTime.Now; //累计收益 _liushui.MemberId = member.MemberId; _liushui.Code = member.Code; _liushui.NickName = member.NickName; _liushui.Type = "流水账单"; _liushui.Comment = "累计收益(+)"; _liushui.Amount = mFin.RealAmount; _liushui.CreateTime = DateTime.Now; } json.Msg = "插入奖金成功"; return(json); }
/// <summary> /// 保存(添加与更新) /// </summary> /// <param name="Pwd2">支付密码</param> /// <param name="entity">当前实体对象</param> /// <returns></returns> public bool Save(string Pwd2, Fin_Convert entity) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "保存失败" }; Xml_Site config = DB.XmlConfig.XmlSite; #region 检查支付密码是否正确,转换金额是否超限, using (var tran = DB.Fin_Convert.BeginTransaction) { try { var model = DB.Member_Info.FindEntity(entity.MemberId); if (model != null && model.Pwd2 == Pwd2) { } else { throw new Exception("支付密码错误"); } if (entity.Amount <= 0) { throw new Exception("转换金额要大于0"); } if (entity.ConvertType == "奖金转余额") { if (entity.Amount > model.Coins) { throw new Exception("奖金额度不足!"); } } if (entity.ConvertId == 0) { if (Insert(entity)) { //流水账单 Fin_LiuShui _liushui = new Fin_LiuShui(); //更新会员表的收益,电子币 if (entity.ConvertType == "奖金转余额") { model.Coins -= entity.Amount; model.Commission += entity.Amount; DB.Fin_LiuShui.AddLS(model.MemberId, -entity.Amount.Value, "奖金转余额", "奖金"); DB.Fin_LiuShui.AddLS(model.MemberId, entity.Amount.Value, "奖金转余额"); } DB.Member_Info.Update(model); json.Status = "y"; json.Msg = "操作成功"; //添加操作日志 DB.SysLogs.setMemberLog(Enums.EventType.Add, string.Format("货币转换,操作人:[{0}],金额:[{1}],操作成功", entity.NickName, entity.Amount)); } } tran.Complete(); return(true); } catch (Exception ex) { DB.Rollback(); throw ex; } } #endregion }