public ActionResult CapitalCharge() { string value = ""; Finance_Wallet fw = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); string m_type = ConfigurationManager.AppSettings["CoinType"].ToString(); if (m_type == "1") { ViewBag.MoneyType = "CNY"; } else if (m_type == "2") { ViewBag.MoneyType = "USD"; } else { ViewBag.MoneyType = ""; } if (fw != null) { value = fw.Wallet_UserLeftMoney.ToString("F2"); } ViewBag.Balance = value; return(View()); //IMemberCapitalService memberCapitalService = ServiceHelper.Create<IMemberCapitalService>(); //CapitalInfo capitalInfo = memberCapitalService.GetCapitalInfo(base.CurrentUser.Id); //return View(capitalInfo); }
public JsonResult GetPayBankInfo(string bankName, string bankuserName, string bankId) { Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { Log.Error("用户:" + base.CurrentUser.Id + "在" + DateTime.Now + "体现时获取自己的提现信息失败."); return(Json("")); } else { fwinfo.Wallet_UserBankName = bankName; fwinfo.Wallet_UserBankUserName = bankuserName; fwinfo.Wallet_UserBankNumber = bankId; fwinfo.Wallet_DoIpAddress = ChemCloud.Core.Common.GetIpAddress(); fwinfo.Wallet_DoLastTime = DateTime.Now; fwinfo.Wallet_DoUserId = base.CurrentUser.Id; fwinfo.Wallet_DoUserName = base.CurrentUser.UserName; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { Log.Info("用户:" + base.CurrentUser.Id + "在" + DateTime.Now + "体现时设置提现信息成功."); return(Json("ok")); } else { Log.Error("用户:" + base.CurrentUser.Id + "在" + DateTime.Now + "体现时设置提现信息失败."); return(Json("")); } } }
/// <summary> /// 充值提交 /// </summary> /// <param name="amount"></param> /// <returns></returns> public JsonResult ChargeSubmit(decimal amount) { Finance_Wallet Fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); if (Fwinfo != null) { } ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); long orderid = _orderBO.GenerateOrderNumber(); Finance_Recharge frinfo = new Finance_Recharge(); frinfo.Recharge_Number = orderid; frinfo.Recharge_UserId = base.CurrentUser.Id; frinfo.Recharge_UserType = base.CurrentUser.UserType; frinfo.Recharge_Time = DateTime.Now; frinfo.Recharge_Address = ChemCloud.Core.Common.GetIpAddress(); frinfo.Recharge_Money = amount; frinfo.Recharge_MoneyLeft = Fwinfo.Wallet_UserLeftMoney; frinfo.Recharge_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); frinfo.Recharge_Type = 0; frinfo.Recharge_Status = 1; if (ServiceHelper.Create <IFinance_RechargeService>().AddFinance_Recharge(frinfo)) { return(Json(frinfo.Recharge_Number)); } else { return(Json("")); } }
/// <summary> /// 设置支付密码 /// </summary> /// <param name="pwd">支付密码</param> /// <returns></returns> public JsonResult SavePayPwd(string pwd) { Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); if (fwinfo == null) { Log.Error("在用户:" + base.CurrentUser.Id + "提现时,获取用户支付密码信息失败."); return(Json("")); } else { string str = Guid.NewGuid().ToString("N"); fwinfo.Wallet_PayPassword = pwd;//当前未加密 SecureHelper.MD5(string.Concat(SecureHelper.MD5(pwd), str)); fwinfo.Wallet_DoUserId = base.CurrentUser.Id; fwinfo.Wallet_DoLastTime = DateTime.Now; fwinfo.Wallet_DoUserName = base.CurrentUser.UserName; fwinfo.Wallet_DoIpAddress = ChemCloud.Core.Common.GetIpAddress(); if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { return(Json(new { success = true })); } else { Log.Error("在用户:" + base.CurrentUser.Id + "提现时,设置用户支付密码失败."); return(Json("")); } } }
/// <summary> /// 提交提现操作 /// </summary> /// <param name="amount">提现金额</param> /// <param name="pwd">支付密码</param> /// <returns></returns> public JsonResult ApplyWithDrawSubmit(decimal amount, string pwd) { Finance_Wallet fwino = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwino == null) { Log.Error("用户" + base.CurrentUser.Id + "在" + DateTime.Now + "时提现 获取提现信息失败."); return(Json("")); } else { if (!pwd.Equals(fwino.Wallet_PayPassword)) { throw new HimallException("支付密码不对,请重新输入!"); } else { if (amount > fwino.Wallet_UserLeftMoney) { throw new HimallException("提现金额不能超出可用金额!"); } else { //创建提现记录 并且更新用户提现后的钱包 Finance_WithDraw fwdinfo = new Finance_WithDraw(); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); fwdinfo.Withdraw_Number = _orderBO.GenerateOrderNumber(); fwdinfo.Withdraw_UserId = base.CurrentUser.Id; fwdinfo.Withdraw_UserType = base.CurrentUser.UserType; fwdinfo.Withdraw_Money = amount; fwdinfo.Withdraw_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"]); fwdinfo.Withdraw_BankName = fwino.Wallet_UserBankName; fwdinfo.Withdraw_BankUserName = fwino.Wallet_UserBankUserName; fwdinfo.Withdraw_Account = fwino.Wallet_UserBankNumber; fwdinfo.Withdraw_Time = DateTime.Now; fwdinfo.Withdraw_Status = 0; fwdinfo.Withdraw_shenhe = 0; fwdinfo.Withdraw_shenheDesc = ""; fwdinfo.Withdraw_shenheTime = DateTime.Now; fwdinfo.Withdraw_shenheUid = 0; fwdinfo.Withdraw_shenheUname = ""; fwino.Wallet_UserMoneyLock = amount; fwino.Wallet_UserLeftMoney = fwino.Wallet_UserLeftMoney - amount; fwino.Wallet_DoIpAddress = ChemCloud.Core.Common.GetIpAddress(); fwino.Wallet_DoLastTime = DateTime.Now; fwino.Wallet_DoUserId = base.CurrentUser.Id; fwino.Wallet_DoUserName = base.CurrentUser.UserName; if (ServiceHelper.Create <IFinance_WithDrawService>().AddFinance_WithDraw(fwdinfo) && ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwino)) { return(Json("ok")); } else { Log.Error("用户" + base.CurrentUser.Id + "在" + DateTime.Now + "时添加提现记录失败."); return(Json("")); } } } } }
public JsonResult SubmitWithdraw(string Id, string Withdraw_shenhe, string Withdraw_shenheDesc) { Finance_WithDraw model = ServiceHelper.Create <IFinance_WithDrawService>().GetFinance_WithDrawInfo(long.Parse(Id)); model.Withdraw_shenhe = int.Parse(Withdraw_shenhe); model.Withdraw_shenheDesc = Withdraw_shenheDesc; if (Withdraw_shenhe == "1") { model.Withdraw_Status = 1; } model.Withdraw_shenheTime = DateTime.Now; model.Withdraw_shenheUid = CurrentManager.Id; model.Withdraw_shenheUname = CurrentManager.UserName; bool result = ServiceHelper.Create <IFinance_WithDrawService>().UpdateFinance_WithDraw(model); if (result) { Finance_Wallet _Finance_Wallet = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(model.Withdraw_UserId, model.Withdraw_UserType, model.Withdraw_MoneyType); if (Withdraw_shenhe == "1") { //提现通过 _Finance_Wallet.Wallet_UserMoneyLock = _Finance_Wallet.Wallet_UserMoneyLock - model.Withdraw_Money; } else if (Withdraw_shenhe == "2") { //拒绝提现 _Finance_Wallet.Wallet_UserMoneyLock = _Finance_Wallet.Wallet_UserMoneyLock - model.Withdraw_Money; _Finance_Wallet.Wallet_UserLeftMoney = _Finance_Wallet.Wallet_UserLeftMoney + model.Withdraw_Money; } ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(_Finance_Wallet); } return(Json(new { success = result })); }
public Finance_Wallet GetWalletInfo(long uid, int usertype, int cointype) { Finance_Wallet finfo = new Finance_Wallet(); finfo = ( from p in context.Finance_Wallet where p.Wallet_UserId.Equals(uid) && p.Wallet_UserType.Equals(usertype) && p.Wallet_MoneyType.Equals(cointype) select p).FirstOrDefault(); return(finfo); }
public ActionResult ApplyWithDraw() { Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { return(RedirectToAction("Index", "Finance")); } ViewBag.ApplyWithMoney = fwinfo.Wallet_UserLeftMoney; ViewBag.IsSetPwd = (string.IsNullOrWhiteSpace(fwinfo.Wallet_PayPassword) ? false : true); return(View()); }
public ActionResult AccountSafety() { MemberAccountSafety memberAccountSafety = new MemberAccountSafety() { AccountSafetyLevel = 1 }; string cointype = System.Configuration.ConfigurationManager.AppSettings["CoinType"].ToString(); Finance_Wallet walletInfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(cointype)); if (walletInfo != null && walletInfo.Wallet_PayPassword != null) { memberAccountSafety.PayPassword = true; MemberAccountSafety accountSafetyLevel = memberAccountSafety; accountSafetyLevel.AccountSafetyLevel = accountSafetyLevel.AccountSafetyLevel + 1; } IEnumerable <Plugin <IMessagePlugin> > plugins = PluginsManagement.GetPlugins <IMessagePlugin>(); IMessageService create = Instance <IMessageService> .Create; IEnumerable <PluginsInfo> pluginsInfo = from item in plugins select new PluginsInfo() { ShortName = item.Biz.ShortName, PluginId = item.PluginInfo.PluginId, Enable = item.PluginInfo.Enable, IsSettingsValid = item.Biz.IsSettingsValid, IsBind = !string.IsNullOrEmpty(create.GetDestination(CurrentUser.Id, item.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General)) }; foreach (PluginsInfo pluginsInfo1 in pluginsInfo) { if (pluginsInfo1.PluginId.IndexOf("SMS") <= 0) { if (!pluginsInfo1.IsBind) { continue; } memberAccountSafety.BindEmail = true; MemberAccountSafety accountSafetyLevel1 = memberAccountSafety; accountSafetyLevel1.AccountSafetyLevel = accountSafetyLevel1.AccountSafetyLevel + 1; } else { if (!pluginsInfo1.IsBind) { continue; } memberAccountSafety.BindPhone = true; MemberAccountSafety memberAccountSafety1 = memberAccountSafety; memberAccountSafety1.AccountSafetyLevel = memberAccountSafety1.AccountSafetyLevel + 1; } } return(View(memberAccountSafety)); }
/// <summary> /// 获取当前用户的可用余额 /// </summary> /// <returns></returns> public JsonResult GetMyValMoney() { Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); if (fwinfo == null) { return(Json("0")); } else { return(Json(fwinfo.Wallet_UserLeftMoney)); } }
/// <summary> /// 添加用户钱包 /// </summary> /// <param name="uid">用户编号</param> /// <param name="utype">用户了类别</param> /// <param name="uname">用户姓名</param> /// <returns></returns> public JsonResult AddUserWallet(long uid, int utype, string uname) { List <Finance_Wallet> list = ServiceHelper.Create <IFinance_WalletService>().GetWalletList(uid, utype); List <ChemCloud_Dictionaries> cd = ServiceHelper.Create <IChemCloud_DictionariesService>().GetListByType(1); if (list.Count < 1) { if (uid != 0 && utype != 0 && !string.IsNullOrEmpty(uname)) { if (cd.Count > 0) { #region 循环添加用户币种账户 for (int i = 0; i < cd.Count; i++) { Finance_Wallet fw = new Finance_Wallet(); fw.Wallet_UserId = uid; fw.Wallet_UserType = utype; fw.Wallet_DoIpAddress = ChemCloud.Core.Common.GetIpAddress(); fw.Wallet_DoLastTime = DateTime.Now; fw.Wallet_DoUserId = uid; fw.Wallet_DoUserName = uname; fw.Wallet_Status = 1; fw.Wallet_MoneyType = int.Parse(cd[i].DValue);//读后台币种配置信息 if (ServiceHelper.Create <IFinance_WalletService>().AddFinance_Wallet(fw)) { Log.Info("用户(" + uname + ")在IP(" + fw.Wallet_DoIpAddress + ")于" + fw.Wallet_DoLastTime + "创建钱包成功."); } else { Log.Error("用户(" + uname + ")在IP(" + fw.Wallet_DoIpAddress + ")于" + fw.Wallet_DoLastTime + "创建钱包时失败."); } } return(Json("")); #endregion } else { return(Json("")); } } else { return(Json("")); } } else { return(Json("")); } }
/// <summary> /// 判断当前用户 是否设置了支付密码 /// </summary> /// <param name="useid"></param> /// <returns></returns> public bool IsNullWalletPayPassword(long useid, int cointype) { bool result = false; Finance_Wallet finfo = ( from p in context.Finance_Wallet where p.Wallet_UserId.Equals(useid) && p.Wallet_MoneyType.Equals(cointype) select p).FirstOrDefault(); if (finfo != null && !string.IsNullOrEmpty(finfo.Wallet_PayPassword)) { result = true; } return(result); }
/// <summary> /// 验证支付密码 /// </summary> /// <param name="useid"></param> /// <param name="password"></param> /// <param name="cointype"></param> /// <returns></returns> public bool CheckPaymentpassword(long useid, string password, int cointype) { bool result = false; Finance_Wallet finfo = ( from p in context.Finance_Wallet where p.Wallet_UserId.Equals(useid) && p.Wallet_PayPassword.Equals(password) && p.Wallet_MoneyType.Equals(cointype) select p).FirstOrDefault(); if (finfo != null) { result = true; } return(result); }
/// <summary> /// 同意退款 /// </summary> /// <param name="thnum">退款单号</param> /// <param name="orderid">订单号</param> /// <returns></returns> public JsonResult TKTY(string thnum, string orderid) { if (string.IsNullOrWhiteSpace(thnum)) { return(Json("no")); } Finance_Refund fr = ServiceHelper.Create <IFinance_RefundService>().GetFinance_RefundInfo(long.Parse(thnum)); if (fr == null) { return(Json("no")); } //更新采购商可用余额 增加退款金额 OrderInfo oinfo = ServiceHelper.Create <IOrderService>().GetOrder(long.Parse(orderid)); Finance_Wallet fwuserinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(oinfo.UserId, 3, int.Parse(oinfo.CoinType.ToString())); fwuserinfo.Wallet_UserLeftMoney = fwuserinfo.Wallet_UserLeftMoney + fr.Refund_Money; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwuserinfo)) { //更新供应商的锁定金额 减去退款金额 Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); fwinfo.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock - fr.Refund_Money; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { //更新退款状态 fr.Refund_Status = 1; if (ServiceHelper.Create <IFinance_RefundService>().UpdateFinance_Refund(fr)) { //更新订单状态 已退款 ServiceHelper.Create <IOrderService>().UpdateOrderStatu(long.Parse(orderid), 11); return(Json("yes")); } else { return(Json("no")); } } else { return(Json("no")); } } else { return(Json("no")); } }
public bool AddFinance_Wallet(Finance_Wallet fwinfo) { int i = 0; if (fwinfo == null || fwinfo.Id != 0) { return(false); } context.Finance_Wallet.Add(fwinfo); i = context.SaveChanges(); if (i > 0) { return(true); } else { return(false); } }
// GET: SellerAdmin/Finance public ActionResult Index() { ViewBag.LeftMoney = "0.00"; ViewBag.LockMoney = "0.00"; ViewBag.ShowIDLock = "有效"; ViewBag.DoTime = ""; ViewBag.DoIP = ""; string money_type = ConfigurationManager.AppSettings["CoinType"].ToString(); if (money_type == "1") { ViewBag.M_type = "CNY"; } else if (money_type == "2") { ViewBag.M_type = "USD"; } else { ViewBag.M_type = ""; } Finance_Wallet fw = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); if (fw != null) { ViewBag.LeftMoney = fw.Wallet_UserLeftMoney.ToString("F2"); ViewBag.LockMoney = fw.Wallet_UserMoneyLock.ToString("F2"); ViewBag.DoTime = fw.Wallet_DoLastTime; ViewBag.DoIP = fw.Wallet_DoIpAddress; if (fw.Wallet_Status == 1) { ViewBag.ShowIDLock = "有效"; } else { ViewBag.ShowIDLock = "锁定"; } } ViewBag.userid = base.CurrentUser.Id; ViewBag.usertype = base.CurrentUser.UserType; return(View()); }
public bool UpdateFinance_Wallet(Finance_Wallet fwinfo) { if (fwinfo == null) { return(false); } Finance_Wallet fw = context.Finance_Wallet.FirstOrDefault((Finance_Wallet m) => m.Id == fwinfo.Id); if (fw == null) { return(false); } int i = 0; fw.Wallet_UserId = fwinfo.Wallet_UserId; fw.Wallet_UserType = fwinfo.Wallet_UserType; fw.Wallet_UserMoney = fwinfo.Wallet_UserMoney; fw.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock; fw.Wallet_UserLeftMoney = fwinfo.Wallet_UserLeftMoney; fw.Wallet_UserBankName = fwinfo.Wallet_UserBankName; fw.Wallet_UserBankNumber = fwinfo.Wallet_UserBankNumber; fw.Wallet_UserBankUserName = fwinfo.Wallet_UserBankUserName; fw.Wallet_UserBankAddress = fwinfo.Wallet_UserBankAddress; fw.Wallet_DoLastTime = fwinfo.Wallet_DoLastTime; fw.Wallet_DoIpAddress = fwinfo.Wallet_DoIpAddress; fw.Wallet_DoUserName = fwinfo.Wallet_DoUserName; fw.Wallet_DoUserId = fwinfo.Wallet_DoUserId; fw.Wallet_MoneyType = fwinfo.Wallet_MoneyType; fw.Wallet_PayPassword = fwinfo.Wallet_PayPassword; fw.Wallet_Status = fwinfo.Wallet_Status; i = context.SaveChanges(); if (i > 0) { return(true); } else { return(false); } }
/// <summary> /// 转账 /// </summary> /// <param name="uname">转账接收方</param> /// <param name="zmoney">转账金额</param> /// <returns></returns> public JsonResult AddZZinfo(string uname, string zmoney) { #region 获取转账对方的用户id和用户类型 int touid = 0; int toutype = 0; string strsql = string.Format("select * from ChemCloud_Members where username='******'", uname); DataSet ds = DbHelperSQL.Query(strsql.ToString()); if (ds == null) { return(Json("")); } else { if (ds.Tables[0].Rows.Count == 1) { touid = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); toutype = int.Parse(ds.Tables[0].Rows[0]["UserType"].ToString()); } else { return(Json("")); } } #endregion #region 转账方的财务信息 Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); fwinfo.Wallet_UserLeftMoney = fwinfo.Wallet_UserLeftMoney - decimal.Parse(zmoney);//获取当前用的可用金额 #endregion #region 转账对方的财务信息 Finance_Wallet fwinfoto = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(touid, toutype, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); fwinfoto.Wallet_UserLeftMoney = fwinfoto.Wallet_UserLeftMoney + decimal.Parse(zmoney);//获取当前用的可用金额 #endregion #region 添加财务转账信息 Finance_Transfer ftinfo = new Finance_Transfer(); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); ftinfo.Trans_Number = _orderBO.GenerateOrderNumber();//创建转账单号 ftinfo.Trans_UserId = base.CurrentUser.Id; ftinfo.Trans_UserType = base.CurrentUser.UserType; ftinfo.Trans_Money = decimal.Parse(zmoney); ftinfo.Trans_SXMoney = 0; ftinfo.Trans_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ftinfo.Trans_Time = DateTime.Now; ftinfo.Trans_Address = ChemCloud.Core.Common.GetIpAddress(); ftinfo.Trans_ToUserId = touid; ftinfo.Trans_ToUserType = toutype; ftinfo.Trans_Status = 1; //对方账户金额转入信息 Finance_InCome ftcome = new Finance_InCome(); ftcome.InCome_Number = _orderBO.GenerateOrderNumber(); ftcome.InCome_UserId = touid; ftcome.InCome_UserType = toutype; ftcome.InCome_StartTime = DateTime.Now; ftcome.InCome_EndTime = DateTime.Now.AddDays(int.Parse(ChemCloud.Web.Framework.ServiceHelper.Create <ChemCloud.IServices.IChemCloud_DictionariesService>().GetValueBYKey("PayoutTime"))); ftcome.InCome_Money = decimal.Parse(zmoney); ftcome.InCome_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ftcome.InCome_Address = ChemCloud.Core.Common.GetIpAddress(); ftcome.InCome_Type = 2;/// 收入类型(1交易2转账3退款默认1) ftcome.InCome_Status = 1; ftcome.InCome_OrderNum = _orderBO.GenerateOrderNumber(); #endregion if (ServiceHelper.Create <IFinance_InComeService>().AddFinance_InCome(ftcome) && ServiceHelper.Create <IFinance_TransferService>().AddFinance_Transfer(ftinfo) && ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo) && ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfoto)) { return(Json("ok")); } else { Log.Error("用户" + base.CurrentUser.Id + "在" + DateTime.Now + "时转账失败."); return(Json("")); } }
/*审核退货单*/ public JsonResult CheckTH(long id) { Result res = new Result(); try { /*1、转账*/ TH tk = ServiceHelper.Create <ITHService>().GetTHByOrderNum(id); if (tk != null) { long buyid = tk.TH_UserId; long sellid = tk.TH_ToUserId; decimal tkamount = tk.TH_ProductMoney; /* 获取转账方的用户id和用户类型 供应商2*/ Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(sellid, 2, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); fwinfo.Wallet_UserLeftMoney = fwinfo.Wallet_UserLeftMoney - tkamount;//获取当前用的可用金额 /* 获取转账接受方的用户id和用户类型 采购商3*/ Finance_Wallet fwinfoto = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(buyid, 3, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); fwinfoto.Wallet_UserLeftMoney = fwinfoto.Wallet_UserLeftMoney + tkamount;//获取当前用的可用金额 /*添加财务转账信息*/ Finance_Transfer ftinfo = new Finance_Transfer(); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); ftinfo.Trans_Number = _orderBO.GenerateOrderNumber();/*创建转账单号*/ ftinfo.Trans_UserId = sellid; ftinfo.Trans_UserType = 2; ftinfo.Trans_Money = tkamount; ftinfo.Trans_SXMoney = 0; ftinfo.Trans_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ftinfo.Trans_Time = DateTime.Now; ftinfo.Trans_Address = ChemCloud.Core.Common.GetIpAddress(); ftinfo.Trans_ToUserId = buyid; ftinfo.Trans_ToUserType = 3; ftinfo.Trans_Status = 1; ServiceHelper.Create <IFinance_TransferService>().AddFinance_Transfer(ftinfo); ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo); ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfoto); //添加财务退款信息 Finance_Refund frinfo = new Finance_Refund(); frinfo.Refund_Number = _orderBO.GenerateOrderNumber();//创建退款单号 frinfo.Refund_OrderNum = id; frinfo.Refund_UserId = sellid; frinfo.Refund_UserType = 2; frinfo.Refund_UserName = ServiceHelper.Create <IMemberService>().GetMember(sellid).UserName == null ? "" : ServiceHelper.Create <IMemberService>().GetMember(sellid).UserName; frinfo.Refund_Money = tkamount; frinfo.Refund_MoneyType = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); frinfo.Refund_SXMoney = 0; frinfo.Refund_ISChujing = 0; frinfo.Refund_Address = ChemCloud.Core.Common.GetIpAddress(); frinfo.Refund_Time = tk.TH_Time; frinfo.Refund_Status = 1; frinfo.Refund_ToUserId = buyid; frinfo.Refund_ToUserType = 3; frinfo.Refund_ToUserName = ServiceHelper.Create <IMemberService>().GetMember(buyid).UserName == null ? "" : ServiceHelper.Create <IMemberService>().GetMember(buyid).UserName; ServiceHelper.Create <IFinance_RefundService>().AddFinance_Refund(frinfo); /*2、更改退货单的状态 为已完成*/ ServiceHelper.Create <ITHService>().UpdateTHStatus(id, 6); /*3更改订单的状态 单状态为已退货*/ ServiceHelper.Create <IOrderService>().UpdateOrderStatu(id, 9); res.success = true; } else { res.success = false; } } catch (Exception) { res.success = false; } return(Json(res)); }
/// <summary> /// 同意退货 /// </summary> /// <param name="thnum">退货单号</param> /// <param name="orderid">订单号</param> /// <returns></returns> public JsonResult THTY(string thnum, string orderid) { if (string.IsNullOrWhiteSpace(thnum)) { return(Json("no")); } TH th = ServiceHelper.Create <ITHService>().GetTHInfo(thnum); if (th == null) { return(Json("no")); } th.TH_Status = 6; if (ServiceHelper.Create <ITHService>().UpdateTH(th)) { Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { return(Json("no")); } //更新供应商的锁定金额 减去退款金额 fwinfo.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock - th.TH_ProductMoneyReal; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { #region 添加退款信息 OrderInfo oinfo = ServiceHelper.Create <IOrderService>().GetOrder(long.Parse(orderid)); Finance_Refund frinfo = new Finance_Refund(); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); long frid = _orderBO.GenerateOrderNumber(); frinfo.Refund_Number = frid; frinfo.Refund_OrderNum = long.Parse(thnum); frinfo.Refund_UserId = base.CurrentUser.Id; frinfo.Refund_UserType = base.CurrentUser.UserType; frinfo.Refund_UserName = base.CurrentUser.UserName; frinfo.Refund_ToUserId = oinfo.UserId; frinfo.Refund_ToUserType = 3; frinfo.Refund_ToUserName = oinfo.UserName; frinfo.Refund_Money = th.TH_ProductMoneyReal; frinfo.Refund_MoneyType = th.TH_ProductMoneyType; frinfo.Refund_SXMoney = 0; frinfo.Refund_ISChujing = 0; frinfo.Refund_Address = ChemCloud.Core.Common.GetIpAddress(); frinfo.Refund_Time = DateTime.Now; frinfo.Refund_Status = 1; if (ServiceHelper.Create <IFinance_RefundService>().AddFinance_Refund(frinfo)) { //更新采购商的可用余额 返还退款金额 Finance_Wallet fwuinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(oinfo.UserId, 3, int.Parse(oinfo.CoinType.ToString())); fwuinfo.Wallet_UserLeftMoney = fwuinfo.Wallet_UserLeftMoney + th.TH_ProductMoneyReal; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwuinfo)) { //更新订单状态 已退货 ServiceHelper.Create <IOrderService>().UpdateOrderStatu(long.Parse(orderid), 9); return(Json("yes")); } else { return(Json("no")); } } else { return(Json("no")); } #endregion } else { return(Json("no")); } } else { return(Json("no")); } }
public ActionResult Home() { RedirectToAction("Bargain"); //string str; long num; UserCenterModel userCenterModel = ServiceHelper.Create <IMemberService>().GetUserCenterModel(base.CurrentUser.Id); dynamic viewBag = base.ViewBag; //str = base.CurrentUser.UserName; viewBag.UserName = base.CurrentUser.UserName; // UserMemberInfo uminfo = ServiceHelper.Create<IMemberDetailService>().GetMemberInfoById(base.CurrentUser.Id); MemberDetail md = ServiceHelper.Create <IMemberDetailService>().GetMemberDetailByUid(base.CurrentUser.Id); if (md != null) { ViewBag.Logo = md.CompanySign;//old: base.CurrentUser.Photo; } else { ViewBag.Logo = ""; } long[] array = ( from a in ServiceHelper.Create <ICartService>().GetCart(base.CurrentUser.Id).Items orderby a.AddTime descending select a into p select p.ProductId).Take(3).ToArray(); ViewBag.ShoppingCartItems = ServiceHelper.Create <IProductService>().GetProductByIds(array).ToArray(); OrderItemInfo[] orderItemInfoArray = ServiceHelper.Create <ICommentService>().GetUnEvaluatProducts(base.CurrentUser.Id).ToArray(); ViewBag.UnEvaluatProductsNum = orderItemInfoArray.Count(); ViewBag.Top3UnEvaluatProducts = orderItemInfoArray.Take(3).ToArray(); ViewBag.Top3RecommendProducts = ServiceHelper.Create <IProductService>().GetPlatHotSaleProductByNearShop(8, base.CurrentUser.Id).ToArray(); dynamic browsingProducts = base.ViewBag; num = (base.CurrentUser == null ? 0 : base.CurrentUser.Id); browsingProducts.BrowsingProducts = BrowseHistrory.GetBrowsingProducts(4, num); IEnumerable <Plugin <IMessagePlugin> > plugins = PluginsManagement.GetPlugins <IMessagePlugin>(); IEnumerable <PluginsInfo> pluginsInfo = from item in plugins select new PluginsInfo() { ShortName = item.Biz.ShortName, PluginId = item.PluginInfo.PluginId, Enable = item.PluginInfo.Enable, IsSettingsValid = item.Biz.IsSettingsValid, IsBind = !string.IsNullOrEmpty(ServiceHelper.Create <IMessageService>().GetDestination(base.CurrentUser.Id, item.PluginInfo.PluginId, MemberContactsInfo.UserTypes.General)) }; ViewBag.BindContactInfo = pluginsInfo; IOrderService orderService = ServiceHelper.Create <IOrderService>(); OrderQuery orderQuery = new OrderQuery() { PageNo = 1, PageSize = 2147483647, UserId = new long?(base.CurrentUser.Id) }; PageModel <OrderInfo> orders = orderService.GetOrders <OrderInfo>(orderQuery, null); ViewBag.OrderCount = orders.Total; dynamic obj = base.ViewBag; IQueryable <OrderInfo> models = orders.Models; obj.WaitEvaluationOrders = ( from c in models where (int)c.OrderStatus == 6 //已签收=未评价 select c).Count(); obj.OrderWaitReceiving = ( from c in models where (int)c.OrderStatus == 3 select c).Count(); dynamic viewBag1 = base.ViewBag; IQueryable <OrderInfo> orderInfos = orders.Models; viewBag1.OrderWaitPay = ( from c in orderInfos where (int)c.OrderStatus == 1 select c).Count(); ICommentService commentService = ServiceHelper.Create <ICommentService>(); CommentQuery commentQuery = new CommentQuery() { UserID = base.CurrentUser.Id, PageSize = 2147483647, PageNo = 1, Sort = "PComment" }; IQueryable <long> nums = ( from item in commentService.GetProductEvaluation(commentQuery).Models where !item.EvaluationStatus select item.OrderId).Distinct <long>(); ViewBag.OrderEvaluationStatus = nums.Count(); //CapitalInfo capitalInfo = ServiceHelper.Create<IMemberCapitalService>().GetCapitalInfo(base.CurrentUser.Id); string value = "0.00"; Finance_Wallet fw = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString())); string m_type = ConfigurationManager.AppSettings["CoinType"].ToString(); if (m_type == "1") { ViewBag.MoneyType = "CNY"; } else if (m_type == "2") { ViewBag.MoneyType = "USD"; } else { ViewBag.MoneyType = ""; } if (fw != null) { value = fw.Wallet_UserLeftMoney.ToString("F2"); } ViewBag.Balance = value; MemberAccountSafety memberAccountSafety = new MemberAccountSafety() { AccountSafetyLevel = 1 }; string cointype = System.Configuration.ConfigurationManager.AppSettings["CoinType"] == null ? "" : System.Configuration.ConfigurationManager.AppSettings["CoinType"].ToString(); Finance_Wallet walletInfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(base.CurrentUser.Id, base.CurrentUser.UserType, int.Parse(cointype)); if (walletInfo != null && walletInfo.Wallet_PayPassword != null) { memberAccountSafety.PayPassword = true; MemberAccountSafety accountSafetyLevel = memberAccountSafety; accountSafetyLevel.AccountSafetyLevel = accountSafetyLevel.AccountSafetyLevel + 1; } IMessageService create = Instance <IMessageService> .Create; foreach (PluginsInfo pluginsInfo1 in pluginsInfo) { if (pluginsInfo1.PluginId.IndexOf("SMS") <= 0) { if (!pluginsInfo1.IsBind) { continue; } memberAccountSafety.BindEmail = true; MemberAccountSafety accountSafetyLevel1 = memberAccountSafety; accountSafetyLevel1.AccountSafetyLevel = accountSafetyLevel1.AccountSafetyLevel + 1; } else { if (!pluginsInfo1.IsBind) { continue; } memberAccountSafety.BindPhone = true; MemberAccountSafety memberAccountSafety1 = memberAccountSafety; memberAccountSafety1.AccountSafetyLevel = memberAccountSafety1.AccountSafetyLevel + 1; } } userCenterModel.memberAccountSafety = memberAccountSafety; foreach (var p in userCenterModel.FollowShopCarts) { int pub_cid = ServiceHelper.Create <IProductService>().GetProduct(p.ProductId) == null ? 0 : (ServiceHelper.Create <IProductService>().GetProduct(p.ProductId).Pub_CID == null ? 0 : ServiceHelper.Create <IProductService>().GetProduct(p.ProductId).Pub_CID); p.ImagePath = pub_cid.ToString(); } return(View(userCenterModel)); }
/// <summary> /// 成功添加支付记录后更新平台的的 锁定金额和 平台的收入记录 /// </summary> /// <param name="orderId">订单号</param> /// <param name="price">实付金额</param> /// <returns></returns> public JsonResult AddInComeAndUpdatePlatformWallet(string orderId, string price, string paytype) { long userid = 0; int usertype = 1; /*4定制合成 5代理采购 (此时支付给供应商)*/ if (paytype == "4") { string strsql = string.Format("SELECT * FROM dbo.ChemCloud_OrderSynthesis where OrderNumber='" + orderId + "';"); DataTable dt = DbHelperSQL.QueryDataTable(strsql); if (dt.Rows.Count > 0) { if (dt.Rows[0]["ZhifuImg"] != null) { userid = long.Parse(dt.Rows[0]["ZhifuImg"].ToString()); usertype = 2; } } } if (paytype == "5") { string strsql = string.Format("SELECT * FROM dbo.ChemCloud_OrderPurchasing where OrderNum='" + orderId + "';"); DataTable dt = DbHelperSQL.QueryDataTable(strsql); if (dt.Rows.Count > 0) { if (dt.Rows[0]["ZhifuImg"] != null) { userid = long.Parse(dt.Rows[0]["ZhifuImg"].ToString()); usertype = 2; } } } /*我要采购 支付*/ if (paytype == "7") { //orderId string strsql = string.Format("SELECT SupplierID FROM dbo.ChemCloud_IWantToSupply where Id='" + orderId + "';"); DataTable dt = DbHelperSQL.QueryDataTable(strsql); if (dt.Rows.Count > 0) { if (dt.Rows[0]["SupplierID"] != null) { userid = long.Parse(dt.Rows[0]["SupplierID"].ToString()); usertype = 2; } } int montype = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); Finance_InCome fi = new Finance_InCome(); fi.InCome_Number = _orderBO.GenerateOrderNumber(); fi.InCome_UserId = userid; fi.InCome_UserType = usertype; fi.InCome_StartTime = DateTime.Now; fi.InCome_EndTime = DateTime.Now.AddDays(int.Parse(ChemCloud.Web.Framework.ServiceHelper.Create <ChemCloud.IServices.IChemCloud_DictionariesService>().GetValueBYKey("PayoutTime"))); fi.InCome_Money = decimal.Parse(price); fi.InCome_MoneyType = montype; fi.InCome_OrderNum = long.Parse(orderId); fi.InCome_Address = ChemCloud.Core.Common.GetIpAddress(); fi.InCome_Type = 1; fi.InCome_Status = 1; if (ServiceHelper.Create <IFinance_InComeService>().AddFinance_InCome(fi)) { //更新供应商锁定金额 Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(-1, 1, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { return(Json("")); } fwinfo.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock + (decimal.Parse(price)); if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { return(Json("ok")); } else { return(Json("")); } } else { return(Json("")); } } else { #region 平台的收入记录 int montype = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); Finance_InCome fi = new Finance_InCome(); fi.InCome_Number = _orderBO.GenerateOrderNumber(); fi.InCome_UserId = userid; fi.InCome_UserType = usertype; fi.InCome_StartTime = DateTime.Now; fi.InCome_EndTime = DateTime.Now.AddDays(int.Parse(ChemCloud.Web.Framework.ServiceHelper.Create <ChemCloud.IServices.IChemCloud_DictionariesService>().GetValueBYKey("PayoutTime"))); fi.InCome_Money = decimal.Parse(price); fi.InCome_MoneyType = montype; fi.InCome_OrderNum = long.Parse(orderId); fi.InCome_Address = ChemCloud.Core.Common.GetIpAddress(); fi.InCome_Type = 1; fi.InCome_Status = 1; if (ServiceHelper.Create <IFinance_InComeService>().AddFinance_InCome(fi)) { Log.Info(DateTime.Now + "时,成功添加平台的收入信息,收入金额:" + (fi.InCome_Money) + ",收入币种:" + fi.InCome_MoneyType); //更新供应商锁定金额 Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(-1, 1, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { return(Json("")); } fwinfo.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock + (decimal.Parse(price)); if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { return(Json("ok")); } else { return(Json("")); } } else { Log.Info(DateTime.Now + "时,添加平台的收入信息失败."); return(Json("")); } #endregion } }
/// <summary> /// 成功添加支付记录后更新供应商的锁定金额和添加供应商的收入记录 /// </summary> /// <param name="orderId">订单号</param> /// <param name="price">实付金额</param> /// <returns></returns> public JsonResult AddInComeAndUpdateManagerWallet(string orderId, string price) { decimal bxfei = 0; OrderInfo oinfo = ServiceHelper.Create <IOrderService>().GetOrder(long.Parse(orderId)); if (oinfo == null) { Log.Error("获取成功支付的订单信息失败"); return(Json("")); } else { bxfei = oinfo.Insurancefee; ManagerInfo minfo = ServiceHelper.Create <IManagerService>().GetManagerInfoByShopId(oinfo.ShopId); if (minfo == null) { Log.Error("获取成功支付订单的供应商信息失败."); return(Json("")); } else { UserMemberInfo uminfo = ServiceHelper.Create <IMemberService>().GetMemberByName(minfo.UserName); if (uminfo == null) { Log.Error("获取成功支付订单的供应商用户编号、用户类型失败."); return(Json("")); } else { #region 添加供应商的收入记录 int montype = int.Parse(ConfigurationManager.AppSettings["CoinType"].ToString()); ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); Finance_InCome fi = new Finance_InCome(); fi.InCome_Number = _orderBO.GenerateOrderNumber(); fi.InCome_UserId = uminfo.Id; fi.InCome_UserType = uminfo.UserType; fi.InCome_StartTime = DateTime.Now; fi.InCome_EndTime = DateTime.Now.AddDays(int.Parse(ChemCloud.Web.Framework.ServiceHelper.Create <ChemCloud.IServices.IChemCloud_DictionariesService>().GetValueBYKey("PayoutTime"))); fi.InCome_Money = decimal.Parse(price) - bxfei; fi.InCome_MoneyType = montype; fi.InCome_OrderNum = long.Parse(orderId); fi.InCome_Address = ChemCloud.Core.Common.GetIpAddress(); fi.InCome_Type = 1; fi.InCome_Status = 1; if (ServiceHelper.Create <IFinance_InComeService>().AddFinance_InCome(fi)) { Log.Info(DateTime.Now + "时,成功添加供应商编号" + uminfo.Id + "的收入信息,收入金额:" + (fi.InCome_Money) + ",收入币种:" + fi.InCome_MoneyType); //更新供应商锁定金额 Finance_Wallet fwinfo = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(uminfo.Id, uminfo.UserType, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (fwinfo == null) { return(Json("")); } fwinfo.Wallet_UserMoneyLock = fwinfo.Wallet_UserMoneyLock + (fi.InCome_Money); if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(fwinfo)) { #region 保险费付给平台 Finance_InCome managerFi = new Finance_InCome() { InCome_Number = _orderBO.GenerateOrderNumber(), InCome_UserId = -1, //平台 InCome_UserType = 1, //平台 InCome_StartTime = DateTime.Now, InCome_EndTime = DateTime.Now.AddDays(int.Parse(ChemCloud.Web.Framework.ServiceHelper.Create <ChemCloud.IServices.IChemCloud_DictionariesService>().GetValueBYKey("PayoutTime"))), InCome_Money = bxfei,//保险费付给平台 InCome_MoneyType = montype, InCome_OrderNum = long.Parse(orderId), InCome_Address = fi.InCome_Address, InCome_Type = 1, InCome_Status = 1 }; if (ServiceHelper.Create <IFinance_InComeService>().AddFinance_InCome(managerFi)) { Log.Info(DateTime.Now + "时,成功添加收入信息,收入金额:" + (fi.InCome_Money - bxfei) + ",收入币种:" + fi.InCome_MoneyType); //更新平台账户金额 如果保险费用大于0 if (bxfei > 0) { Finance_Wallet pingtai = ServiceHelper.Create <IFinance_WalletService>().GetWalletInfo(-1, 1, int.Parse(ConfigurationManager.AppSettings["CoinType"])); if (pingtai == null) { Log.Info(DateTime.Now + "时,获取平台账号信息失败."); return(Json("")); } pingtai.Wallet_UserMoneyLock = pingtai.Wallet_UserMoneyLock + bxfei; if (ServiceHelper.Create <IFinance_WalletService>().UpdateFinance_Wallet(pingtai)) { return(Json("ok")); } else { Log.Info(DateTime.Now + "时,更新平台账号信息错误."); return(Json("")); } } else { return(Json("ok")); } } else { Log.Info(DateTime.Now + "时,平台账户的保险金收入信息失败."); return(Json("")); } #endregion } else { return(Json("")); } } else { Log.Info(DateTime.Now + "时,添加供应商编号" + uminfo.Id + "的收入信息失败."); return(Json("")); } #endregion } } } }