コード例 #1
0
        public JsonResult Paying(ExpenseDetailsModel model)
        {
            JsonModel jm = new JsonModel();
            //获取要去缴费的缴费明细
            IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

            var expenseDetails = expenseDetailsBLL.GetEntity(u => u.Id == model.Id);

            if (expenseDetails == null)
            {
                jm.Msg = "该缴费记录不存在";
            }
            else if (expenseDetails.IsPayed == ConstantParam.PAYED_TRUE)
            {
                jm.Msg = "该缴费记录已缴费";
            }
            else
            {
                expenseDetails.IsPayed     = ConstantParam.PAYED_TRUE;
                expenseDetails.PaymentType = 1;
                expenseDetails.PayedDate   = DateTime.Now;
                expenseDetails.Operator    = GetSessionModel().UserID;
                expenseDetails.InvoiceType = model.InvoiceType;

                //编辑成功
                if (expenseDetailsBLL.Update(expenseDetails))
                {
                    //记录操作日志
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Paying(int id)
        {
            IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

            var expenseDetails = expenseDetailsBLL.GetEntity(u => u.Id == id);

            if (expenseDetails != null)
            {
                ExpenseDetailsModel model = new ExpenseDetailsModel();
                model.Id = expenseDetails.Id;
                if (expenseDetails.BuildDoorId != null)
                {
                    model.UnitDoor = expenseDetails.BuildDoor.BuildUnit.Build.BuildName + " "
                                     + expenseDetails.BuildDoor.BuildUnit.UnitName + " " + expenseDetails.BuildDoor.DoorName;
                }
                else if (expenseDetails.BuildCompanyId != null)
                {
                    model.UnitDoor = expenseDetails.BuildCompany.Name;
                }
                model.ExpenseTypeName = expenseDetails.PropertyExpenseType.Name;
                switch (expenseDetails.ExpenseCycleId)
                {
                case ConstantParam.ExpenseCycle_ONE_MONTH:
                    model.ExpenseCycle = "每月";
                    break;

                case ConstantParam.ExpenseCycle_TWO_MONTH:
                    model.ExpenseCycle = "每两月";
                    break;

                case ConstantParam.ExpenseCycle_ONE_QUARTER:
                    model.ExpenseCycle = "每季度";
                    break;

                case ConstantParam.ExpenseCycle_HARF_YEAR:
                    model.ExpenseCycle = "每半年";
                    break;

                case ConstantParam.ExpenseCycle_ONE_YEAR:
                    model.ExpenseCycle = "每年";
                    break;
                }
                model.Expense         = expenseDetails.Expense;
                model.ExpenseDateDesc = expenseDetails.ExpenseDateDes;
                model.InvoiceTypeList = GetInvoiceTypeList();

                return(View(model));
            }
            else
            {
                return(RedirectToAction("ExpenseList"));
            }
        }
コード例 #3
0
        public ApiResultModel SetRecordToExpensed(DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //设置缴费记录为已在线缴费
                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var record = expenseDetailsBLL.GetEntity(e => e.Id == model.Id);
                    if (record != null)
                    {
                        record.IsPayed     = ConstantParam.PAYED_TRUE;
                        record.PaymentType = 2;
                        record.PayedDate   = DateTime.Now;

                        expenseDetailsBLL.Update(record);
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXPENSE_RECORD_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
コード例 #4
0
        public JsonResult PayRemind(int id)
        {
            JsonModel jm = new JsonModel();

            IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

            var expenseDetails = expenseDetailsBLL.GetEntity(u => u.Id == id);

            if (expenseDetails == null)
            {
                jm.Msg = "该缴费记录不存在";
            }
            else if (expenseDetails.IsPayed == ConstantParam.PAYED_TRUE)
            {
                jm.Msg = "该缴费记录已缴费";
            }
            else
            {
                List <int> userIds = null;
                IUserBLL   userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                if (expenseDetails.BuildDoorId != null)
                {
                    userIds = expenseDetails.BuildDoor.PropertyIdentityVerifications.Where(v => v.IsVerified == 1 && v.User.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)
                              .Select(v => v.AppUserId).Distinct().ToList();
                }
                else if (expenseDetails.BuildCompanyId != null)
                {
                    userIds = expenseDetails.BuildCompany.PropertyIdentityVerification.Where(v => v.IsVerified == 1 && v.User.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)
                              .Select(v => v.AppUserId).Distinct().ToList();
                }

                //推送缴费提醒
                //推送给业主客户端
                IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                string alert           = expenseDetails.ExpenseDateDes + expenseDetails.PropertyExpenseType.Name + "缴费提醒";
                var    registrationIds = userPushBLL.GetList(p => userIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                bool   flag            = PropertyUtils.SendPush("缴费提醒", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);
                if (!flag)
                {
                    jm.Msg = "推送发生异常";
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
ファイル: CommonController.cs プロジェクト: IMAXZ/PropertyGit
        public ActionResult WeixinExpenseNotifyUrl()
        {
            Stream       st       = Request.InputStream;
            StreamReader sr       = new StreamReader(st);
            string       SRstring = sr.ReadToEnd();

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(SRstring);
            sr.Close();

            string return_code = doc.GetElementsByTagName("return_code")[0].InnerText;

            //如果返回成功
            if (return_code == "SUCCESS")
            {
                string result_code = doc.GetElementsByTagName("result_code")[0].InnerText;
                if (result_code == "SUCCESS")
                {
                    string expenseOrderNo = doc.GetElementsByTagName("out_trade_no")[0].InnerText;

                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var record = expenseDetailsBLL.GetEntity(e => e.PayTradeNo == expenseOrderNo);

                    if (record != null && record.IsPayed == ConstantParam.PAYED_FALSE)
                    {
                        //获取物业微信账户信息
                        T_PropertyAccount wxAccount = null;
                        if (record.BuildDoorId != null)
                        {
                            wxAccount = record.BuildDoor.BuildUnit.Build.PropertyPlace.PropertyAccounts.Where(
                                a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                        }
                        else
                        {
                            wxAccount = record.BuildCompany.PropertyPlace.PropertyAccounts.Where(
                                a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                        }
                        if (wxAccount != null)
                        {
                            string WeixinPayKey = wxAccount.AccountKey;
                            //组装签名字符串
                            StringBuilder signStr = new StringBuilder();
                            signStr.Append("appid=" + doc.GetElementsByTagName("appid")[0].InnerText + "&");
                            signStr.Append("bank_type=" + doc.GetElementsByTagName("bank_type")[0].InnerText + "&");
                            signStr.Append("cash_fee=" + doc.GetElementsByTagName("cash_fee")[0].InnerText + "&");
                            signStr.Append("fee_type=" + doc.GetElementsByTagName("fee_type")[0].InnerText + "&");
                            signStr.Append("is_subscribe=" + doc.GetElementsByTagName("is_subscribe")[0].InnerText + "&");
                            signStr.Append("mch_id=" + doc.GetElementsByTagName("mch_id")[0].InnerText + "&");
                            signStr.Append("nonce_str=" + doc.GetElementsByTagName("nonce_str")[0].InnerText + "&");
                            signStr.Append("openid=" + doc.GetElementsByTagName("openid")[0].InnerText + "&");
                            signStr.Append("out_trade_no=" + expenseOrderNo + "&");
                            signStr.Append("result_code=" + result_code + "&");
                            signStr.Append("return_code=" + return_code + "&");
                            signStr.Append("time_end=" + doc.GetElementsByTagName("time_end")[0].InnerText + "&");
                            signStr.Append("total_fee=" + doc.GetElementsByTagName("total_fee")[0].InnerText + "&");
                            signStr.Append("trade_type=" + doc.GetElementsByTagName("trade_type")[0].InnerText + "&");
                            signStr.Append("transaction_id=" + doc.GetElementsByTagName("transaction_id")[0].InnerText + "&");
                            signStr.Append("key=" + WeixinPayKey);
                            string sign = PropertyUtils.GetMD5Str(signStr.ToString()).ToUpper();
                            //签名验证成功
                            if (doc.GetElementsByTagName("sign")[0].InnerText == sign)
                            {
                                record.IsPayed     = ConstantParam.PAYED_TRUE;
                                record.PaymentType = 2;
                                record.PayedDate   = DateTime.Now;
                                expenseDetailsBLL.Update(record);
                            }
                        }
                    }
                    return(Content("success"));
                }
            }
            return(Content("fail"));
        }
コード例 #6
0
        public ApiResultModel ExpenseRecordDetail([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var record = expenseDetailsBLL.GetEntity(e => e.Id == model.Id);
                    if (record != null)
                    {
                        //返回详细数据
                        resultModel.result = new
                        {
                            RecordId                                      = record.Id,
                            ExpenseTypeName                               = record.PropertyExpenseType.Name,
                            ExpenseDateDes                                = record.ExpenseDateDes,
                            Expense                                       = record.Expense,
                            PayedTime                                     = record.PayedDate != null?record.PayedDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                                                              PaymentType = record.PaymentType != null ? (record.PaymentType.Value == 1 ? "前台缴费" : "在线缴费") : "",
                                                              PlaceName   = record.BuildCompanyId == null ? record.BuildDoor.BuildUnit.Build.PropertyPlace.Name : record.BuildCompany.PropertyPlace.Name,
                                                              Door        = record.BuildCompanyId == null ? record.BuildDoor.BuildUnit.Build.BuildName + record.BuildDoor.BuildUnit.UnitName
                                                                            + record.BuildDoor.DoorName : record.BuildCompany.Name,
                                                              OwnerName = record.BuildDoor != null && record.BuildDoor.HouseUsers.Count > 0 ? record.BuildDoor.HouseUsers.FirstOrDefault().Name : "",
                                                              Tel       = record.BuildDoor != null ? (record.BuildDoor.HouseUsers.Count > 0 ? record.BuildDoor.HouseUsers.FirstOrDefault().Phone : "") : record.BuildCompany.Phone,
                        };
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXPENSE_RECORD_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
コード例 #7
0
        public ApiResultModel CreateWeixinPayTrade(DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //生成微信支付订单
                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var record = expenseDetailsBLL.GetEntity(e => e.Id == model.Id);
                    if (record != null)
                    {
                        //获取物业缴费账户信息
                        T_PropertyAccount wxAccount = null;
                        if (record.BuildDoorId != null)
                        {
                            wxAccount = record.BuildDoor.BuildUnit.Build.PropertyPlace.PropertyAccounts.Where(
                                a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                        }
                        else
                        {
                            wxAccount = record.BuildCompany.PropertyPlace.PropertyAccounts.Where(
                                a => a.AccountType == ConstantParam.PROPERTY_ACCOUNT_WeChat).FirstOrDefault();
                        }
                        if (wxAccount == null)
                        {
                            resultModel.Msg = "该用户所属物业未设置账户信息";
                            return(resultModel);
                        }
                        //获取物业账户信息
                        string WeixinAppId  = wxAccount.Number;
                        string WeixinMchId  = wxAccount.MerchantNo;
                        string WeixinPayKey = wxAccount.AccountKey;
                        //生成预订单
                        string result = CreateTradePost(record, WeixinAppId, WeixinMchId, WeixinPayKey);

                        //如果请求失败
                        if (result == null)
                        {
                            resultModel.Msg = APIMessage.WEIXIN_YUORDER_FAIL;
                            return(resultModel);
                        }
                        //解析返回结果
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(result);
                        string return_code = doc.GetElementsByTagName("return_code")[0].InnerText;
                        //如果返回成功
                        if (return_code == "SUCCESS")
                        {
                            string result_code = doc.GetElementsByTagName("result_code")[0].InnerText;
                            if (result_code == "SUCCESS")
                            {
                                //预支付交易会话标识
                                string prepayid = doc.GetElementsByTagName("prepay_id")[0].InnerText;

                                //随机字符串
                                string str          = "1234567890abcdefghijklmnopqrstuvwxyz";
                                Random r            = new Random();
                                string PayRandomStr = "";
                                for (int i = 0; i < 32; i++)
                                {
                                    PayRandomStr += str[r.Next(str.Length)].ToString();
                                }
                                //时间戳
                                var timestamp = Convert.ToInt64(DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalMilliseconds / 10000) * 10;
                                //签名字符串
                                string PaySignStr = "appid=" + WeixinAppId + "&noncestr=" + PayRandomStr + "&package=Sign=WXPay&partnerid="
                                                    + WeixinMchId + "&prepayid=" + prepayid + "&timestamp=" + timestamp + "&key=" + WeixinPayKey;
                                resultModel.result = new
                                {
                                    appid     = WeixinAppId,
                                    partnerid = WeixinMchId,
                                    package   = "Sign=WXPay",
                                    prepayid  = prepayid,
                                    noncestr  = PayRandomStr,
                                    timestamp = timestamp,
                                    sign      = PropertyUtils.GetMD5Str(PaySignStr.ToString()).ToUpper()
                                };
                            }
                            else
                            {
                                string err_code_des = doc.GetElementsByTagName("err_code_des")[0].InnerText;
                                resultModel.Msg = err_code_des;
                            }
                        }
                        else
                        {
                            string return_msg = doc.GetElementsByTagName("return_msg")[0].InnerText;
                            resultModel.Msg = return_msg;
                        }
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXPENSE_RECORD_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }