Exemple #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));
        }
Exemple #2
0
 /// <summary>
 /// 添加固定收费记录
 /// </summary>
 /// <param name="flog"></param>
 /// <returns></returns>
 public async Task <Response> AddFixLogAsync(FixUserChargeLog flog)
 {
     return(await fixChgLogManager.AddAsync(flog));
 }
Exemple #3
0
        public async Task <ActionResult> ChangeDeadline(ChangeDeadlineModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "参数设置不正确");
                return(View(model));
            }
            Log log = LogFactory.GetLogger("ChangeDeadline");

            try
            {
                CWICCard cwiccd = new CWICCard();
                Customer cust   = await cwiccd.FindCustAsync(model.ID);

                if (cust != null)
                {
                    if ((int)cust.Type < 2)
                    {
                        ModelState.AddModelError("", "临时卡,无法设置使用期限");
                        return(View(model));
                    }
                    string olddeadline = cust.Deadline.ToString();

                    cust.Deadline = model.NewDeadline;
                    Response resp = cwiccd.UpdateCust(cust);
                    if (resp.Code == 1)
                    {
                        string oprtname = User.Identity.Name;
                        string utype    = "";
                        if (cust.Type == EnmICCardType.FixedLocation)
                        {
                            utype = "固定";
                        }
                        else if (cust.Type == EnmICCardType.Periodical)
                        {
                            utype = "定期";
                        }

                        FixUserChargeLog fixlog = new FixUserChargeLog
                        {
                            UserName     = cust.UserName,
                            PlateNum     = cust.PlateNum,
                            UserType     = utype,
                            Proof        = "手动",
                            LastDeadline = olddeadline,
                            CurrDeadline = cust.Deadline.ToString(),
                            FeeType      = "",
                            FeeUnit      = 0,
                            CurrFee      = 0,
                            RecordDTime  = DateTime.Now,
                            OprtCode     = oprtname
                        };
                        await new CWTariffLog().AddFixLogAsync(fixlog);
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());

                ModelState.AddModelError("", "系统异常,请联系厂家!");
                return(View(model));
            }
        }