static void Main(string[] args)
        {
            CarQueryDataList_Params pams = new CarQueryDataList_Params();

            pams.carNo     = "粤YGY662";
            pams.carType   = "02";
            pams.enginNo   = "713477";
            pams.rackNo    = "004711";
            pams.isCompany = "false";
            var s = HeLianApi.CarQueryDataList(pams);

            List <DataLllegal> r = new List <DataLllegal>();

            if (s != null)
            {
                if (s.data != null)
                {
                    var d = s.data;
                    foreach (var m in d)
                    {
                        DataLllegal dl = new DataLllegal();
                        dl.bookNo         = m.bookNo;
                        dl.bookType       = m.bookType;
                        dl.cityCode       = m.cityCode;
                        dl.lllegalCode    = m.lllegalCode;
                        dl.lllegalTime    = m.lllegalTime;
                        dl.point          = m.point;
                        dl.fine           = m.fine;
                        dl.lllegalAddress = m.address;
                        r.Add(dl);
                    }
                }
            }

            CarQueryGetLllegalPrice_Params pams1 = new CarQueryGetLllegalPrice_Params();

            pams1.carNo       = "粤YGY662";
            pams1.carType     = "02";
            pams1.enginNo     = "713477";
            pams1.rackNo      = "004711";
            pams1.isCompany   = "false";
            pams1.dataLllegal = r;
            var s1 = HeLianApi.CarQueryGetLllegalPrice(pams1);

            Console.ReadLine();
        }
Exemple #2
0
        public CustomJsonResult <LllegalQueryResult> Query(int operater, LllegalQueryParams pms)
        {
            CustomJsonResult <LllegalQueryResult> result = new CustomJsonResult <LllegalQueryResult>();

            using (TransactionScope ts = new TransactionScope())
            {
                if (pms.EnginNo.Length < 6)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, "请输入发动机号后6位", null));
                }

                if (pms.RackNo.Length < 6)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, "请输入车架号后6位", null));
                }

                var lllegalQueryScore = CurrentDb.LllegalQueryScore.Where(m => m.UserId == pms.UserId && m.MerchantId == pms.MerchantId).FirstOrDefault();

                if (lllegalQueryScore.Score == 0)
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.LllegalQueryNotEnoughScore, "当前的查询积分为0,请充值积分", null));
                }

                pms.CarNo   = pms.CarNo.ToUpper();
                pms.EnginNo = pms.EnginNo.ToUpper();
                pms.RackNo  = pms.RackNo.ToUpper();

                List <DataLllegal> dataLllegal = new List <DataLllegal>();


                CarQueryDataList_Params p = new CarQueryDataList_Params();
                p.carNo     = pms.CarNo;
                p.enginNo   = pms.EnginNo;
                p.rackNo    = pms.RackNo;
                p.isCompany = pms.IsCompany;
                p.carType   = pms.CarType;
                var api_result = HeLianApi.CarQueryDataList(p);


                if (api_result.resultCode != "0")
                {
                    return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, api_result.resultMsg, null));
                }

                List <LllegalRecord> lllegalRecords = new List <LllegalRecord>();


                var d = api_result.data;
                if (d != null)
                {
                    foreach (var m in d)
                    {
                        DataLllegal dl = new DataLllegal();
                        dl.bookNo         = m.bookNo;
                        dl.bookType       = m.bookType;
                        dl.cityCode       = m.cityCode;
                        dl.lllegalCode    = m.lllegalCode;
                        dl.lllegalTime    = m.lllegalTime;
                        dl.point          = m.point;
                        dl.fine           = m.fine;
                        dl.lllegalAddress = m.address;
                        dataLllegal.Add(dl);

                        LllegalRecord lllegalRecord = new LllegalRecord();
                        lllegalRecord.bookNo        = m.bookNo;
                        lllegalRecord.bookType      = m.bookType;
                        lllegalRecord.bookTypeName  = GetBookTypeName(m.bookType);
                        lllegalRecord.offerType     = m.offerType;
                        lllegalRecord.ofserTypeName = GetOfferTypeName(m.offerType);
                        lllegalRecord.lllegalDesc   = m.lllegalDesc;
                        lllegalRecord.cityCode      = m.cityCode;
                        lllegalRecord.lllegalCode   = m.lllegalCode;
                        lllegalRecord.lllegalCity   = m.lllegalCity;
                        lllegalRecord.lllegalTime   = m.lllegalTime;
                        lllegalRecord.point         = m.point;

                        lllegalRecord.fine = m.fine;
                        if (lllegalRecord.point == 0)
                        {
                            lllegalRecord.serviceFee = m.serviceFee + 3;//非扣分单
                        }
                        else
                        {
                            lllegalRecord.serviceFee = m.serviceFee;
                        }

                        lllegalRecord.serviceFee = m.serviceFee;
                        lllegalRecord.address    = m.address;
                        lllegalRecord.content    = m.content;
                        lllegalRecord.late_fees  = m.late_fees;

                        lllegalRecords.Add(lllegalRecord);
                    }
                }

                CarQueryGetLllegalPrice_Params p1 = new CarQueryGetLllegalPrice_Params();

                p1.carNo       = pms.CarNo;
                p1.enginNo     = pms.EnginNo;
                p1.rackNo      = pms.RackNo;
                p1.isCompany   = pms.IsCompany;
                p1.carType     = pms.CarType;
                p1.dataLllegal = dataLllegal;

                var queryResult = new LllegalQueryResult();

                queryResult.IsOfferPrice = pms.IsOfferPrice == "true" ? true : false;
                queryResult.CarNo        = pms.CarNo;

                string msg = "";
                if (queryResult.IsOfferPrice)
                {
                    var api_result1 = HeLianApi.CarQueryGetLllegalPrice(p1);

                    if (api_result1.resultCode != "0")
                    {
                        return(new CustomJsonResult <LllegalQueryResult>(ResultType.Failure, ResultCode.Failure, api_result1.resultMsg, null));
                    }

                    msg = api_result1.resultMsg;

                    var d1 = api_result1.data;

                    if (d1 != null)
                    {
                        foreach (var record in lllegalRecords)
                        {
                            var priceresult = d1.Where(m => m.bookNo == record.bookNo).FirstOrDefault();
                            if (priceresult != null)
                            {
                                record.serviceFee = priceresult.serviceFee;
                                record.fine       = priceresult.fine;
                                record.late_fees  = priceresult.fine;
                            }

                            record.status = "待处理";


                            if (record.point == 0)
                            {
                                record.canDealt = true;
                            }
                            else
                            {
                                record.canDealt = false;
                            }

                            var details = CurrentDb.OrderToLllegalDealtDetails.Where(m => m.BookNo == record.bookNo).ToList();
                            if (details != null)
                            {
                                var hasDealt     = details.Where(m => m.Status == Enumeration.OrderToLllegalDealtDetailsStatus.InDealt).Count();
                                var hasCompleted = details.Where(m => m.Status == Enumeration.OrderToLllegalDealtDetailsStatus.Completed).Count();


                                if (hasDealt > 0)
                                {
                                    record.status   = "处理中";
                                    record.canDealt = false;
                                }

                                if (hasCompleted > 0)
                                {
                                    record.status   = "完成";
                                    record.canDealt = false;
                                }
                            }
                        }
                    }
                }

                queryResult.DealtTip = "扣分单需处理,请咨询客服";
                queryResult.SumCount = lllegalRecords.Count().ToString();
                queryResult.SumFine  = lllegalRecords.Sum(m => m.fine).ToString();
                queryResult.SumPoint = lllegalRecords.Sum(m => m.point).ToString();


                var lllegalQueryLog = new LllegalQueryLog();

                lllegalQueryLog.UserId     = pms.UserId;
                lllegalQueryLog.MerchantId = pms.MerchantId;
                lllegalQueryLog.CarNo      = pms.CarNo;
                lllegalQueryLog.EnginNo    = pms.EnginNo;
                lllegalQueryLog.RackNo     = pms.RackNo;
                lllegalQueryLog.IsCompany  = pms.IsCompany;
                lllegalQueryLog.CarType    = pms.CarType;
                lllegalQueryLog.Result     = Newtonsoft.Json.JsonConvert.SerializeObject(lllegalRecords);
                lllegalQueryLog.Creator    = operater;
                lllegalQueryLog.CreateTime = this.DateTime;
                CurrentDb.LllegalQueryLog.Add(lllegalQueryLog);

                var changeScore = -1;
                lllegalQueryScore.Score         += changeScore;
                lllegalQueryScore.Mender         = operater;
                lllegalQueryScore.LastUpdateTime = this.DateTime;

                var lllegalQueryScoreTrans = new LllegalQueryScoreTrans();
                lllegalQueryScoreTrans.UserId      = pms.UserId;
                lllegalQueryScoreTrans.ChangeScore = changeScore;
                lllegalQueryScoreTrans.Score       = lllegalQueryScore.Score;
                lllegalQueryScoreTrans.Type        = Enumeration.LllegalQueryScoreTransType.DecreaseByQuery;
                lllegalQueryScoreTrans.Description = string.Format("查询违章扣除积分:{0}", changeScore);
                lllegalQueryScoreTrans.Creator     = operater;
                lllegalQueryScoreTrans.CreateTime  = this.DateTime;
                CurrentDb.LllegalQueryScoreTrans.Add(lllegalQueryScoreTrans);
                CurrentDb.SaveChanges();
                lllegalQueryScoreTrans.Sn = Sn.Build(SnType.LllegalQueryScoreTrans, lllegalQueryScoreTrans.Id).Sn;
                CurrentDb.SaveChanges();

                ts.Complete();

                queryResult.QueryScore = lllegalQueryScore.Score;

                queryResult.Record = lllegalRecords;


                result = new CustomJsonResult <LllegalQueryResult>(ResultType.Success, ResultCode.Success, msg, queryResult);
            }

            return(result);
        }