public static Ui.DataGrid GetChargeMeter_ProjectFeeDetailGridByKeywords(string Keywords, List <int> RoomIDList, List <int> ProjectIDList, int MeterCategoryID, int MeterType, int MeterChargeID, string orderBy, long startRowIndex, int pageSize, int UserID = 0, int ChargeState = 0)
        {
            long totalRows = 0;
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("([IsDeleted]=0 or [IsDeleted] is null)");
            if (ChargeState == 1)//已收
            {
                conditions.Add("[ChargeState] in (1,4)");
            }
            if (ChargeState == 2)//未收
            {
                conditions.Add("[RealRoomFeeID]>0");
            }
            if (ChargeState == 3)//作废
            {
                conditions.Add("[ChargeState]=2");
            }
            if (ChargeState == 4)//催收中
            {
                conditions.Add("[ChargeState]=5");
            }
            if (ProjectIDList.Count > 0)
            {
                List <string> cmdlist = ViewRoomFeeHistory.GetProjectIDListConditions(ProjectIDList, IncludeRelation: false, RoomIDName: "[ProjectID]", UserID: UserID);
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (RoomIDList.Count > 0)
            {
                List <string> cmdlist = ViewRoomFeeHistory.GetRoomIDListConditions(RoomIDList, IncludeRelation: false, RoomIDName: "[ProjectID]");
                conditions.Add("(" + string.Join(" or ", cmdlist.ToArray()) + ")");
            }
            if (!string.IsNullOrEmpty(Keywords))
            {
                conditions.Add("([MeterName] like @Keywords or [MeterNumber] like @Keywords)");
                parameters.Add(new SqlParameter("@Keywords", "%" + Keywords + "%"));
            }
            if (MeterCategoryID > 0)
            {
                conditions.Add("[MeterCategoryID]=@MeterCategoryID");
                parameters.Add(new SqlParameter("@MeterCategoryID", MeterCategoryID));
            }
            if (MeterType > 0)
            {
                conditions.Add("[MeterType]=@MeterType");
                parameters.Add(new SqlParameter("@MeterType", MeterType));
            }
            if (MeterChargeID > 0)
            {
                conditions.Add("[MeterChargeID]=@MeterChargeID");
                parameters.Add(new SqlParameter("@MeterChargeID", MeterChargeID));
            }
            string cmdcolumns = string.Empty;

            ChargeMeter_ProjectFeeDetail[] list = new ChargeMeter_ProjectFeeDetail[] { };
            string fieldList = @"A.*";
            string Statement = " from " + CommSqlText + " where  " + string.Join(" and ", conditions.ToArray());

            list = GetList <ChargeMeter_ProjectFeeDetail>(fieldList, Statement, parameters, orderBy, startRowIndex, pageSize, out totalRows).ToArray();
            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.page  = pageSize;
            dg.total = totalRows;
            if (list.Length == 0)
            {
                dg.rows = list;
                return(dg);
            }
            var feeList = RoomFeeAnalysis.GetRoomFeeAnalysisListByIDList(list.Select(p => p.RoomFeeID).ToList());

            foreach (var item in list)
            {
                var myFee = feeList.FirstOrDefault(p => p.ID == item.RoomFeeID);
                if (myFee != null)
                {
                    item.RoomFeeUnitPrice = myFee.CalculateUnitPrice;
                }
            }
            dg.rows = list;
            return(dg);
        }
Ejemplo n.º 2
0
        private bool WxPayComplete(HuiShouYin.Domain.Pay_Option PayOption, out string errormsg)
        {
            errormsg = string.Empty;
            string OpenID = PayOption.openid;
            var    wuser  = Foresight.DataAccess.Wechat_User.GetWechat_UserByUserOpenID(OpenID);
            string AddMan = (wuser != null && !string.IsNullOrEmpty(wuser.NickName)) ? wuser.NickName : OpenID;
            PrintRoomFeeHistory printRoomFeeHistory = new PrintRoomFeeHistory();
            var ModelList = PayOption.idlist;

            if (ModelList.Count == 0)
            {
                errormsg = "需要支付的费项不存在";
                return(false);
            }
            var    list        = new List <RoomFeeAnalysis>();
            int    RoomID      = 0;
            string AllParentID = string.Empty;

            foreach (var item in ModelList)
            {
                var viewRoomFee = RoomFeeAnalysis.GetRoomFeeAnalysisByEndTime(item.ID, Convert.ToDateTime(item.EndTime));
                if (viewRoomFee == null)
                {
                    continue;
                }
                list.Add(viewRoomFee);
                RoomID      = viewRoomFee.RoomID;
                AllParentID = viewRoomFee.AllParentID;
            }
            if (list.Count == 0)
            {
                errormsg = "需要支付的费项不存在";
                return(false);
            }
            var     ConfigName            = SysConfigNameDefine.WeixinChargeMan;
            var     sysConfigList         = SysConfig.Get_SysConfigListByProjectIDList(MinProjectID: RoomID, MaxProjectID: RoomID, ConfigName: ConfigName);
            string  ChargeMan             = SysConfig.GetConfigValueByList(sysConfigList, ConfigName, AllParentID: AllParentID);
            decimal TotalCost             = list.Sum(p => p.TotalCost);
            var     ViewChargeSummaryList = ViewChargeSummary.GetViewChargeSummaries().ToArray();

            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    SavePrintRoomFeeHistory(printRoomFeeHistory, list[0].RoomID, TotalCost, ChargeMan, helper, list[0].FullName + "-" + list[0].RoomName, list[0].FinalCustomerName);
                    foreach (var field in list)
                    {
                        var roomFee = Foresight.DataAccess.RoomFee.GetRoomFee(field.ID, helper);
                        if (roomFee == null)
                        {
                            continue;
                        }
                        roomFee.StartTime         = field.CalculateStartTime > DateTime.MinValue ? field.CalculateStartTime : DateTime.MinValue;
                        roomFee.EndTime           = field.CalculateEndTime > DateTime.MinValue ? field.CalculateEndTime : DateTime.MinValue;
                        roomFee.NewEndTime        = field.NewEndTime > DateTime.MinValue ? field.NewEndTime : DateTime.MinValue;
                        roomFee.OutDays           = roomFee.OutDays;
                        roomFee.UseCount          = field.UseCount;
                        roomFee.Cost              = field.TotalCost;
                        roomFee.Remark            = roomFee.Remark;
                        roomFee.IsCharged         = true;
                        roomFee.UnitPrice         = field.CalculateUnitPrice > decimal.MinValue ? field.CalculateUnitPrice : 0;
                        roomFee.ChargeFee         = roomFee.ChargeFee > decimal.MinValue ? roomFee.ChargeFee : 0;
                        roomFee.RealCost          = roomFee.ChargeFee > 0 ? roomFee.ChargeFee : (field.TotalCost > decimal.MinValue ? field.TotalCost : 0);
                        roomFee.Discount          = field.Discount > decimal.MinValue ? field.Discount : 0;
                        roomFee.TotalRealCost     = (roomFee.TotalRealCost < 0 ? 0 : roomFee.TotalRealCost) + roomFee.RealCost;
                        roomFee.TotalDiscountCost = (roomFee.TotalDiscountCost < 0 ? 0 : roomFee.TotalDiscountCost) + roomFee.Discount;
                        decimal restcost = roomFee.Cost - roomFee.TotalDiscountCost - roomFee.TotalRealCost;
                        if (restcost < 0)
                        {
                            restcost = 0;
                        }
                        roomFee.RestCost             = restcost;
                        roomFee.ContractID           = field.ContractID;
                        roomFee.DiscountID           = roomFee.DiscountID;
                        roomFee.CuiShouStartTime     = field.CuiShouStartTime > DateTime.MinValue ? field.CuiShouStartTime : DateTime.MinValue;
                        roomFee.CuiShouEndTime       = field.CuiShouEndTime > DateTime.MinValue ? field.CuiShouEndTime : DateTime.MinValue;
                        roomFee.RelatedFeeID         = field.RelatedFeeID;
                        roomFee.ChongDiChargeID      = roomFee.ChongDiChargeID;
                        roomFee.DefaultChargeManID   = roomFee.DefaultChargeManID;
                        roomFee.DefaultChargeManName = field.DefaultChargeManName;
                        roomFee.Remark = "汇收银支付";
                        roomFee.Save(helper);
                        #region 收费后续操作
                        Web.APPCode.HandlerHelper.SaveRoomFee(roomFee, ChargeMan, helper, printRoomFeeHistory, ViewChargeSummaryList);
                        #endregion
                    }
                    helper.Commit();
                    var items = new { status = true, PrintID = printRoomFeeHistory.ID };
                    return(true);
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    LogHelper.WriteError("WechatHandler", "visit: wxpayroomfeecomplete", ex);
                    errormsg = ex.Message;
                    return(false);
                }
            }
        }