Exemplo n.º 1
0
        public bool UpdateFinance_InCome(Finance_InCome fwinfo)
        {
            if (fwinfo == null)
            {
                return(false);
            }
            Finance_InCome fw = context.Finance_InCome.FirstOrDefault((Finance_InCome m) => m.Id == fwinfo.Id);

            if (fw == null)
            {
                return(false);
            }
            int i = 0;

            fw.InCome_Number    = fwinfo.InCome_Number;
            fw.InCome_UserId    = fwinfo.InCome_UserId;
            fw.InCome_UserType  = fwinfo.InCome_UserType;
            fw.InCome_StartTime = fwinfo.InCome_StartTime;
            fw.InCome_EndTime   = fwinfo.InCome_EndTime;
            fw.InCome_Money     = fwinfo.InCome_Money;
            fw.InCome_MoneyType = fwinfo.InCome_MoneyType;
            fw.InCome_OrderNum  = fwinfo.InCome_OrderNum;
            fw.InCome_Address   = fwinfo.InCome_Address;
            fw.InCome_Type      = fwinfo.InCome_Type;
            fw.InCome_Status    = fwinfo.InCome_Status;
            i = context.SaveChanges();
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public Finance_InCome GetFinance_InComeInfo(long uid, int usertype, int moneytype)
        {
            Finance_InCome finfo = new Finance_InCome();

            finfo = (
                from p in context.Finance_InCome
                where p.InCome_UserId.Equals(uid) && p.InCome_UserType.Equals(usertype) && p.InCome_MoneyType.Equals(moneytype)
                select p).FirstOrDefault();
            return(finfo);
        }
Exemplo n.º 3
0
        public bool AddFinance_InCome(Finance_InCome fwinfo)
        {
            int i = 0;

            if (fwinfo == null || fwinfo.Id != 0)
            {
                return(false);
            }
            context.Finance_InCome.Add(fwinfo);
            i = context.SaveChanges();
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <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(""));
            }
        }
Exemplo n.º 5
0
        /// <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
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <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
            }
        }