Exemplo n.º 1
0
        public async Task <ActionResult> SetFixUserFee()
        {
            Log      log  = LogFactory.GetLogger("SetFixUserFee");
            Response resp = new Response();

            #region
            CWICCard cwiccd = new CWICCard();
            try
            {
                string proof = Request.Form["uiccd"];
                //计费类型
                string feetype = Request.Form["feetype"];
                //费用标准
                string feeStd = Request.Form["feeunit"];
                //实收费用
                string actualfee = Request.Form["actualfee"];

                if (TempData["CustInfo"] == null)
                {
                    resp.Message = "请先点击< 查询信息 >,再 确认缴费 !";
                    return(Json(resp));
                }

                FixCustInfo oldInfo = (FixCustInfo)TempData["CustInfo"];
                if (proof.Trim() != oldInfo.Proof.Trim())
                {
                    resp.Message = "查询条件已改变,请先点击< 查询信息 >,再 确认缴费 !";
                    return(Json(resp));
                }
                Customer cust = await cwiccd.FindCustAsync(oldInfo.CustID);

                float standard = Convert.ToSingle(feeStd);
                float actual   = Convert.ToSingle(actualfee);
                int   rnd      = (int)(actual / standard);

                EnmFeeUnit unit   = (EnmFeeUnit)Convert.ToInt16(feetype);
                int        months = 0;
                switch (unit)
                {
                case EnmFeeUnit.Month:
                    months = 1 * rnd;
                    break;

                case EnmFeeUnit.Season:
                    months = 3 * rnd;
                    break;

                case EnmFeeUnit.Year:
                    months = 12 * rnd;
                    break;

                default:
                    break;
                }
                if (months == 0)
                {
                    resp.Message = "系统异常,rnd- " + rnd + " , Unit- " + unit.ToString();
                    return(Json(resp));
                }
                DateTime current = cust.Deadline;
                if (current == DateTime.Parse("2017-1-1"))
                {
                    current = DateTime.Now;
                }
                cust.StartDTime = DateTime.Now;
                cust.Deadline   = current.AddMonths(months);
                //更新期限
                resp = cwiccd.UpdateCust(cust);

                oldInfo.LastDeadline = oldInfo.CurrDeadline;
                oldInfo.CurrDeadline = cust.Deadline.ToString();

                if (resp.Code == 1)
                {
                    #region 记录日志
                    string uty = "";
                    switch (cust.Type)
                    {
                    case EnmICCardType.Periodical:
                        uty = "定期用户";
                        break;

                    case EnmICCardType.FixedLocation:
                        uty = "固定用户";
                        break;

                    default:
                        uty = cust.Type.ToString();
                        break;
                    }
                    string umsg = "";
                    switch (unit)
                    {
                    case EnmFeeUnit.Month:
                        umsg = "月";
                        break;

                    case EnmFeeUnit.Season:
                        umsg = "季";
                        break;

                    case EnmFeeUnit.Year:
                        umsg = "年";
                        break;

                    default:
                        break;
                    }
                    string           oprt   = User.Identity.Name;
                    FixUserChargeLog fixlog = new FixUserChargeLog
                    {
                        UserName     = cust.UserName,
                        PlateNum     = cust.PlateNum,
                        UserType     = uty,
                        Proof        = oldInfo.Proof,
                        LastDeadline = oldInfo.LastDeadline,
                        CurrDeadline = oldInfo.CurrDeadline,
                        FeeType      = umsg,
                        FeeUnit      = standard,
                        CurrFee      = actual,
                        OprtCode     = oprt,
                        RecordDTime  = DateTime.Now
                    };

                    await new CWTariffLog().AddFixLogAsync(fixlog);

                    #endregion

                    resp.Message = "缴费成功!";

                    NBackInfo nback = new NBackInfo()
                    {
                        LastDeadline = oldInfo.LastDeadline,
                        CurrDeadline = oldInfo.CurrDeadline
                    };
                    resp.Data = nback;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            #endregion
            return(Json(resp));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询用户信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="uiccd"></param>
        /// <returns></returns>
        public async Task <JsonResult> QueryCustInfo(int type, string uiccd)
        {
            Response resp = new Response();

            #region
            CWICCard cwiccd = new CWICCard();
            Customer cust   = null;
            if (type == 1)
            {
                //是卡号
                ICCard iccd = await cwiccd.FindAsync(ic => ic.UserCode == uiccd);

                if (iccd == null)
                {
                    resp.Message = "不是本系统用卡,iccode - " + uiccd;
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                if (iccd.CustID == 0)
                {
                    resp.Message = "当前用卡为临时用卡,无法完成操作! ICCode - " + uiccd;
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                cust = cwiccd.FindCust(iccd.CustID);
            }
            else if (type == 2)
            {
                //是车牌
                cust = await cwiccd.FindCustAsync(cc => cc.PlateNum == uiccd);
            }
            else if (type == 3)
            {
                //是车主姓名
                cust = await cwiccd.FindCustAsync(cc => cc.UserName == uiccd);
            }
            if (cust == null)
            {
                resp.Message = "当前用户不存在,无法进行操作!iccode - " + uiccd;
                return(Json(resp, JsonRequestBehavior.AllowGet));
            }
            if (cust.Type == EnmICCardType.Temp)
            {
                resp.Message = "临时用户,不在此界面缴费! iccode - " + uiccd;
                return(Json(resp, JsonRequestBehavior.AllowGet));
            }

            FixChargingRule rule = new CWTariff().FindFixCharge(fix => fix.Unit == EnmFeeUnit.Month && fix.ICType == cust.Type);
            if (rule == null)
            {
                resp.Message = "找不到(月份)收费规则,ICType - " + cust.Type.ToString();
                return(Json(resp, JsonRequestBehavior.AllowGet));
            }

            FixCustInfo info = new FixCustInfo
            {
                CustID       = cust.ID,
                Proof        = uiccd,
                ICType       = (int)cust.Type,
                CurrDeadline = cust.Deadline.ToString(),
                MonthFee     = rule.Fee
            };
            resp.Code    = 1;
            resp.Message = "查询成功";
            resp.Data    = info;

            TempData["CustInfo"] = info;
            #endregion
            return(Json(resp, JsonRequestBehavior.AllowGet));
        }