Example #1
0
        public string SupplyList(QueryCommon <IWantToBuyQuery> query)
        {
            query.ParamInfo.PurchaseID = base.CurrentUser.Id;

            Result_List_Pager <Result_IWantToBuy> res = new Result_List_Pager <Result_IWantToBuy>();

            IIWantToBuyService             jobsService = ServiceHelper.Create <IIWantToBuyService>();
            Result_List_Pager <IWantToBuy> resList     = jobsService.GetIWantToBuyList_SupplyUser_Pager(query);
            var listHash = hashSet.Get_DictionariesList();

            if (resList.Msg.IsSuccess)
            {
                res.PageInfo = resList.PageInfo;
                res.Msg      = resList.Msg;
                res.List     = resList.List.Select(x => new Result_IWantToBuy()
                {
                    Id          = x.Id,
                    SupplyModel = Get_SupplyModel_ByIWantToBuyID(x.Id),
                    //SupplierID = Get_SupplierID_ByIWantToBuyID(x.Id),

                    //IsMine = Get_SupplierID_ByIWantToBuyID(x.Id) > 0 ? 1 : 0,
                    //ShopName = jobsService.GetCompanyInfo_ByUserIdAndUserType(Get_SupplierID_ByIWantToBuyID(x.Id)).Model.ShopName,

                    PurchaseID  = x.PurchaseID,
                    ProductName = x.ProductName,
                    PurchaseNum = x.PurchaseNum,
                    Quantity    = x.Quantity,
                    Remarks     = x.Remarks,
                    TotalPrice  = x.TotalPrice,
                    Unit        = x.Unit,
                    UnitPrice   = x.UnitPrice,
                    Address     = x.Address,
                    Status      = x.Status,
                    StatusStr   = listHash.Where(y => y.DictionaryTypeId == 107 && y.DKey == x.Status.ToString()).FirstOrDefault().DValue,

                    DeliveryDate = x.DeliveryDate.ToString("yyyy-MM-dd hh:mm"),
                    CreateDate   = x.CreateDate.ToString("yyyy-MM-dd hh:mm"),
                    StartDate    = x.StartDate.ToString("yyyy-MM-dd hh:mm"),
                    EndDate      = x.EndDate.ToString("yyyy-MM-dd hh:mm"),
                    UpdateDate   = x.UpdateDate.ToString("yyyy-MM-dd hh:mm"),

                    TypeOfCurrency = listHash.Where(y => y.DictionaryTypeId == 1 && y.DValue == x.TypeOfCurrency.ToString()).FirstOrDefault().Remarks
                }).ToList();

                foreach (var item in res.List)
                {
                    if (item.SupplyModel.Msg.IsSuccess)
                    {
                        item.SupplierID = item.SupplyModel.Model.SupplierID;
                        if (item.SupplyModel.Model.SupplierID == base.CurrentUser.Id)
                        {
                            item.IsMine = 1;//0:竞价中;1:我已中标;2:他人中标

                            Result_Model <ShopInfo> res1 = jobsService.GetCompanyInfo_ByUserIdAndUserType(item.SupplyModel.Model.SupplierID);
                            item.ShopName = res1.Model.CompanyName;
                        }
                        else
                        {
                            item.IsMine = 2;//0:竞价中;1:我已中标;2:他人中标

                            Result_Model <ShopInfo> res1 = jobsService.GetCompanyInfo_ByUserIdAndUserType(item.SupplyModel.Model.SupplierID);
                            item.ShopName = res1.Model.CompanyName;
                        }
                    }
                    else if (item.SupplierID == 0)
                    {
                        item.IsMine = 0;//0:竞价中;1:我已中标;2:他人中标
                    }
                    var suppy = Get_SupplyModel_ByUserIdAndIWantToBuyId(Convert.ToInt64(item.Id), base.CurrentUser.Id);
                    if (suppy.Msg.IsSuccess)
                    {
                        item.WhetherParticipation = 1;
                    }
                    else
                    {
                        item.WhetherParticipation = 0;
                    }
                }
            }
            else
            {
                res.Msg = resList.Msg;
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(res));
        }