Exemple #1
0
        /// <summary>
        /// 根据人员信息获取营收信息
        /// </summary>
        /// <param name="personModel"></param>
        /// <returns></returns>
        public U_Revenue GetRevenueMsgByPersonInfo(Business_Personnel_Information personModel)
        {
            //获取司机ID和车辆ID
            var driverModel = _rl.GetDriverMsg(personModel);
            //driverModel.OrganizationID = 55;
            //driverModel.Id = 21033;
            //获取营收信息
            var       paymentModel = _rl.GetRevenueAPI_PaymentMonthlyData(driverModel);
            U_Revenue revenue      = new U_Revenue();

            if (paymentModel == null)
            {
                revenue.HistoricalArrears     = "0";
                revenue.TheBalance            = "0";
                revenue.AmountDue             = "0";
                revenue.CurrentPayment        = "0";
                revenue.CurrentAccountBalance = "0";
            }
            else
            {
                //revenue.TheBalance = (paymentModel.DebtAmount * -1).ToString("F2");     //上期结余
                //revenue.HistoricalArrears = (paymentModel.DebtAmount * -1) >= 0 ? "0.00" : paymentModel.DebtAmount.ToString("F2"); //历史欠款
                //revenue.AmountDue = paymentModel.DueAmount.ToString("F2");  //应缴金额
                //revenue.CurrentPayment = paymentModel.PaidAmount.ToString("F2");  //本期缴款
                //revenue.CurrentAccountBalance = (paymentModel.PaidAmount - paymentModel.DueAmount + (paymentModel.DebtAmount * -1)).ToString("F2"); //本期结余

                revenue.HistoricalArrears = "0";
                revenue.TheBalance        = paymentModel.DebtAmount.ToString("F2");          //历史欠款
                //revenue.TheBalance = paymentModel.DebtAmount.ToString("F2");
                revenue.AmountDue      = paymentModel.DueAmount.ToString("F2");              //应缴金额
                revenue.CurrentPayment = paymentModel.PaidAmount.ToString("F2");             //本期缴款
                //revenue.CurrentAccountBalance = (paymentModel.PayDebtAmount * -1).ToString("F2");  //本期欠款
                revenue.CurrentAccountBalance = (paymentModel.PayDebtAmount).ToString("F2"); //本期欠款
                revenue.Fee         = paymentModel.fee;
                revenue.FeeMoney    = paymentModel.feeMoney.ToString("F2");
                revenue.TotalAmount = (paymentModel.totalAmount * -1).ToString("F2");
                //revenue.Fee_CurrentAccountBalance = paymentModel.PayDebtAmount >= 0 ? paymentModel.PayDebtAmount.ToString("f2") : (paymentModel.PayDebtAmount * -1).ToString("F2");  //本期欠款
                revenue.Fee_CurrentAccountBalance = paymentModel.PayDebtAmount >= 0 ? "0" : (paymentModel.PayDebtAmount * -1).ToString("F2");  //本期欠款
                revenue.Fee_TotalAmount           = paymentModel.totalAmount >= 0 ? paymentModel.totalAmount.ToString("F2") : (paymentModel.totalAmount * -1).ToString("F2");

                revenue.PaymentInfoList    = paymentModel.PaymentInfoList;
                revenue.PaidAmountInfoList = paymentModel.PaidAmountInfoList;
            }
            return(revenue);
        }
        /// <summary>
        /// 营收支付手机界面
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult RevenuePay(string code)
        {
            #region 获取人员表信息

            string accessToken = WeChatTools.GetAccessoken();
            string userInfoStr = WeChatTools.GetUserInfoByCode(accessToken, code);
            var    userInfo    = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfoStr); //用户ID
            //U_WeChatUserID userInfo = new U_WeChatUserID();
            //userInfo.UserId = "18936495119";
            //userInfo.UserId = "WangCunbiao";
            var personInfoModel = _wl.GetUserInfo(userInfo.UserId); //获取人员表信息
            ViewData["vguid"] = personInfoModel.Vguid;

            var driverInfo = _rl.GetDriverMsg(personInfoModel);
            //var driverInfo = getDriverInfo(personInfoModel);
            //ViewData["driverId"] = "21033";
            //ViewData["organizationId"] = "55";
            ViewData["driverId"]       = driverInfo.Id;
            ViewData["organizationId"] = driverInfo.OrganizationID;

            //Business_Personnel_Information personInfoModel = new Business_Personnel_Information();
            //personInfoModel.Vguid = Guid.Parse("B0167926-C8AF-4AAE-9B18-573EEEDFE740");
            //ViewData["vguid"] = personInfoModel.Vguid;
            #endregion

            #region 查询车牌号是否为空
            ViewData["payException"] = "0";
            //var driverInfo = _weChatRevenueLogic.GetDriverInfo(personInfoModel);
            //if (driverInfo == null)
            //{
            //    ViewData["payException"] = "1";
            //}
            #endregion

            #region 获取openid

            //var openInfoStr = WeChatTools.ConvertToOpenidByUserId(accessToken, userInfo.UserId);
            //var openInfo = Common.JsonHelper.JsonToModel<U_OpenInfo>(openInfoStr);
            //var openidExt = openInfo.openid;
            //ViewData["openid"] = openidExt;

            #endregion

            //var configList = _configManagementLogic.GetConfigList();
            //var fee = configList[13].ConfigValue;
            //ViewData["driverPay"] = fee;
            //var driverPayfee = double.Parse(fee.Trim('%')) / 100;            //获取司机支付的手续费


            //string pushContentVguid = "CCA89587-50BA-4B89-B87B-B53603B74F1B"; //推送的主键
            string pushContentVguid = Request.QueryString["Vguid"]; //推送的主键
            ViewData["pushContentVguid"] = pushContentVguid;
            var  pushContentModel = _pl.GetPushDetail(pushContentVguid);
            bool isValidTime      = false; //未过有效期

            if (pushContentModel != null)
            {
                //判断是否已经支付过
                bool isExist = _weChatRevenueLogic.HasPaymentHistory(personInfoModel.Vguid, pushContentModel.VGUID, 2);
                ViewData["isExist"] = isExist ? "1" : "0";
                #region 判断是否过了有效期

                if (pushContentModel.PeriodOfValidity != null)
                {
                    if (DateTime.Now > pushContentModel.PeriodOfValidity)
                    {
                        isValidTime = true; //已过有效期
                    }
                }

                #endregion

                #region 判断是否是司机

                //去查询营收
                //if (personInfoModel.DepartmenManager == 1) //说明是司机
                //{
                //    ViewData["IsDriver"] = "1";
                //}

                #endregion

                #region 查询营收金额

                if (pushContentModel.RevenueType == 2) //营收金额
                {
                    //去查询营收
                    var revenue = _weChatRevenueLogic.GetRevenueMsgByPersonInfo(personInfoModel);
                    //if (revenue.CurrentAccountBalance == "0" || revenue.CurrentAccountBalance == "0.00")
                    //{
                    //    revenue.CurrentAccountBalance = "-10000.123984";
                    //}
                    //decimal caBalance = Convert.ToDecimal(revenue.CurrentAccountBalance);
                    //var currentAccountBalance = FormatData(caBalance);
                    //revenue.CurrentAccountBalance = FormatData(caBalance).ToString();
                    ViewBag.Revenue = revenue;

                    //if (caBalance < 0)
                    //{
                    //    caBalance = caBalance * -1;
                    //}

                    //ViewBag.CurrentAccountBalance = caBalance.ToString("F2");
                    //var handlingFee = Convert.ToDecimal(revenue.FeeMoney);

                    //handlingFee = FormatData(handlingFee);
                    //if (handlingFee < 0)
                    //{
                    //    handlingFee = handlingFee * -1;
                    //}
                    //ViewBag.HandlingFee = handlingFee;

                    //ViewBag.TotalAmount = currentAccountBalance + handlingFee;
                }

                #endregion
            }
            ViewBag.isValidTime          = isValidTime;
            ViewData["PushContentModel"] = pushContentModel;
            return(View());
        }