Beispiel #1
0
        /// <summary>
        /// 重新生成合同模板附件
        /// </summary>
        /// <param name="itemList"></param>
        /// <param name="newTemplate"></param>
        private void NewContractTemplate(List <Am_ContractImage> itemList, Am_ContractTemplate newTemplate)
        {
            //合同模板附件
            List <DbParameter> par2 = new List <DbParameter>();

            par2.Add(DbFactory.CreateDbParameter("@ACT_Number", newTemplate.Number));
            var contractTemplateImageList = database.FindList <Am_ContractTemplateImage>(" and ACT_Number=@ACT_Number ", par2.ToArray());

            if (contractTemplateImageList != null)
            {
                //清除,重新建立
                if (contractTemplateImageList.Count() == 0 || database.Delete <Am_ContractTemplateImage>(contractTemplateImageList.Select(x => x.ACT_Number).ToArray()) > 0)
                {
                    List <Am_ContractTemplateImage> newList = new List <Am_ContractTemplateImage>();
                    if (itemList == null)
                    {
                        return;
                    }
                    foreach (var item in itemList)
                    {
                        var model = new Am_ContractTemplateImage
                        {
                            ACT_Number = newTemplate.Number,
                            Number     = CommonHelper.GetGuid,
                            ImageMark  = item.ImageMark,
                            ImagePath  = item.ImagePath,
                            Name       = item.Name,
                            Num        = item.Num,
                            Price      = item.Price,
                            Remark     = ""
                        };
                        newList.Add(model);
                    }
                    database.Insert <Am_ContractTemplateImage>(newList);
                }
            }
        }
Beispiel #2
0
        public ActionResult SubContract(Am_Contract contract, List <Am_ContractImage> itemList)
        {
            List <DbParameter> parameter = new List <DbParameter>();

            parameter.Add(DbFactory.CreateDbParameter("@Number", contract.AmmeterNumber));

            var ammeter = database.FindEntityByWhere <Am_Ammeter>(" and Number=@Number ", parameter.ToArray());

            if (ammeter != null && ammeter.Number != null)
            {
                List <DbParameter> par1 = new List <DbParameter>();
                par1.Add(DbFactory.CreateDbParameter("@AmmeterNumber", contract.AmmeterNumber));
                var contractTemplate = database.FindEntityByWhere <Am_ContractTemplate>(" and AmmeterNumber=@AmmeterNumber ", par1.ToArray());
                var newTemplate      = new Am_ContractTemplate();
                if (contractTemplate != null && contractTemplate.Number != null)
                {
                    newTemplate = new Am_ContractTemplate
                    {
                        Number          = contractTemplate.Number,
                        Address         = contract.Address,
                        AmmeterCode     = contractTemplate.AmmeterCode,
                        AmmeterNumber   = contractTemplate.AmmeterNumber,
                        Am_Money        = contract.Am_Money,
                        BackMoney       = contract.BackMoney,
                        BackTime        = contract.BackTime,
                        BankCode        = contract.BankCode,
                        BankInfo        = contract.BankInfo,
                        BankUserName    = contract.BankUserName,
                        Cell            = contract.Cell,
                        City            = contract.City,
                        ContractPaht    = contractTemplate.ContractPaht,
                        County          = contract.County,
                        CreateTime      = contract.CreateTime,
                        CycleTime       = contract.CycleTime,
                        DepositMoney    = contract.DepositMoney,
                        DepositMoneyStr = contract.DepositMoneyStr,
                        Floor           = contract.Floor,
                        GarbageMoney    = contract.GarbageMoney,
                        GoMoney         = contract.GoMoney,
                        GoOnTime        = contract.GoOnTime,
                        GoTime          = contract.GoTime,
                        HallNum         = contract.HallNum,
                        HoName          = contract.HoName,
                        HoUserMobile    = contract.HoUserMobile,
                        HoUserName      = contract.HoUserName,
                        HouseSize       = contract.HouseSize,
                        KitchenNum      = contract.KitchenNum,
                        Money           = contract.Money,
                        MoneyStr        = contract.MoneyStr,
                        NetMoney        = contract.NetMoney,
                        PenaltyMoney    = contract.PenaltyMoney,
                        PenaltyTime     = contract.PenaltyTime,
                        PropertyMoeny   = contract.PropertyMoeny,
                        Province        = contract.Province,
                        Remark          = contract.Remark,
                        RentMoneyTime   = contract.RentMoneyTime,
                        Room            = contract.Room,
                        RoomNum         = contract.RoomNum,
                        ToiletNum       = contract.ToiletNum,
                        TotalMoney      = contract.TotalMoney,
                        TotalMoneyStr   = contract.TotalMoneyStr,
                        Useing          = contract.Useing,
                        UseingSize      = contract.UseingSize,
                        UserName        = ammeter.UserName,
                        U_Name          = ammeter.U_Name,
                        U_Number        = ammeter.U_Number,
                        WaterMoney      = contract.WaterMoney
                    };

                    database.Update <Am_ContractTemplate>(newTemplate);
                }
                else
                {
                    newTemplate = new Am_ContractTemplate
                    {
                        Number          = CommonHelper.GetGuid,
                        Address         = contract.Address,
                        AmmeterCode     = ammeter.AM_Code,
                        AmmeterNumber   = ammeter.Number,
                        Am_Money        = contract.Am_Money,
                        BackMoney       = contract.BackMoney,
                        BackTime        = contract.BackTime,
                        BankCode        = contract.BankCode,
                        BankInfo        = contract.BankInfo,
                        BankUserName    = contract.BankUserName,
                        Cell            = contract.Cell,
                        City            = contract.City,
                        ContractPaht    = "",
                        County          = contract.County,
                        CreateTime      = contract.CreateTime,
                        CycleTime       = contract.CycleTime,
                        DepositMoney    = contract.DepositMoney,
                        DepositMoneyStr = contract.DepositMoneyStr,
                        Floor           = contract.Floor,
                        GarbageMoney    = contract.GarbageMoney,
                        GoMoney         = contract.GoMoney,
                        GoOnTime        = contract.GoOnTime,
                        GoTime          = contract.GoTime,
                        HallNum         = contract.HallNum,
                        HoName          = contract.HoName,
                        HoUserMobile    = contract.HoUserMobile,
                        HoUserName      = contract.HoUserName,
                        HouseSize       = contract.HouseSize,
                        KitchenNum      = contract.KitchenNum,
                        Money           = contract.Money,
                        MoneyStr        = contract.MoneyStr,
                        NetMoney        = contract.NetMoney,
                        PenaltyMoney    = contract.PenaltyMoney,
                        PenaltyTime     = contract.PenaltyTime,
                        PropertyMoeny   = contract.PropertyMoeny,
                        Province        = contract.Province,
                        Remark          = contract.Remark,
                        RentMoneyTime   = contract.RentMoneyTime,
                        Room            = contract.Room,
                        RoomNum         = contract.RoomNum,
                        ToiletNum       = contract.ToiletNum,
                        TotalMoney      = contract.TotalMoney,
                        TotalMoneyStr   = contract.TotalMoneyStr,
                        Useing          = contract.Useing,
                        UseingSize      = contract.UseingSize,
                        UserName        = ammeter.UserName,
                        U_Name          = ammeter.U_Name,
                        U_Number        = ammeter.U_Number,
                        WaterMoney      = contract.WaterMoney
                    };
                    database.Insert <Am_ContractTemplate>(newTemplate);
                }
                //重新生成模板附件
                NewContractTemplate(itemList, newTemplate);

                var contractCount = database.FindCount <Am_Contract>();

                var addContract = new Am_Contract
                {
                    Address         = contract.Address,
                    Remark          = contract.Remark,
                    AgoDay          = contract.AgoDay,
                    AmmeterCode     = ammeter.AM_Code,
                    AmmeterNumber   = ammeter.Number,
                    Number          = CommonHelper.GetGuid,
                    Am_Money        = contract.Am_Money,
                    BackMoney       = contract.BackMoney,
                    BackTime        = contract.BackTime,
                    BankCode        = contract.BankCode,
                    BankInfo        = contract.BankInfo,
                    BankUserName    = contract.BankUserName,
                    Cell            = contract.Cell,
                    City            = contract.City,
                    ContractCode    = DateTime.Now.ToString("yyyyMMdd") + "_" + contract.Cell + "_" + contract.Floor + "_" + contract.Room + "_" + contractCount,
                    Room            = contract.Room,
                    Floor           = contract.Floor,
                    County          = contract.County,
                    CreateAddress   = contract.CreateAddress,
                    CreateTime      = contract.CreateTime,
                    CycleTime       = contract.CycleTime,
                    DepositMoney    = contract.DepositMoney,
                    DepositMoneyStr = contract.DepositMoneyStr,
                    F_UserName      = ammeter.UY_UserName,
                    F_U_Name        = ammeter.UY_Name,
                    F_U_Number      = ammeter.UY_Number,
                    GarbageMoney    = contract.GarbageMoney,
                    GoMoney         = contract.GoMoney,
                    GoOnTime        = contract.GoOnTime,
                    GoTime          = contract.GoTime,
                    HallNum         = contract.HallNum,
                    HoName          = contract.HoName,
                    HoUserMobile    = contract.HoUserMobile,
                    HoUserName      = contract.HoUserName,
                    HouseSize       = contract.HouseSize,
                    KitchenNum      = contract.KitchenNum,
                    Money           = contract.Money,
                    MoneyStr        = contract.MoneyStr,
                    NetMoney        = contract.NetMoney,
                    PenaltyMoney    = contract.PenaltyMoney,
                    PenaltyTime     = contract.PenaltyTime,
                    PropertyMoeny   = contract.PropertyMoeny,
                    Province        = contract.Province,
                    RentBeginTime   = contract.RentBeginTime,
                    RentDate        = contract.RentDate,
                    RentEndTime     = contract.RentEndTime,
                    RentMoneyTime   = contract.RentMoneyTime,
                    RoomNum         = contract.RoomNum,
                    Status          = 0,
                    StatusStr       = "待签订",
                    TemplateNumber  = newTemplate.Number,
                    ToiletNum       = contract.ToiletNum,
                    TotalMoney      = contract.TotalMoney,
                    TotalMoneyStr   = contract.TotalMoneyStr,
                    UpdateTime      = DateTime.Now,
                    Useing          = contract.Useing,
                    UseingSize      = contract.UseingSize,
                    UserName        = ammeter.UserName,
                    U_Code          = contract.U_Code,
                    U_Mobile        = contract.U_Mobile,
                    U_Name          = contract.U_Name,
                    U_Number        = ammeter.U_Number,
                    WaterMoney      = contract.WaterMoney
                };
                database.Insert <Am_Contract>(addContract);
                //生成合同附件
                NewContract(itemList, addContract.Number);

                //推送通知用户
                var first = new First()
                {
                    color = "#000000",
                    value = addContract.U_Name + ",您有新的合同待签!"
                };
                var keynote1 = new Keynote1()
                {
                    color = "#0000ff",
                    value = addContract.ContractCode
                };
                var keynote2 = new Keynote2()
                {
                    color = "#0000ff",
                    value = addContract.TotalMoney.Value.ToString("0.00")
                };
                var keynote3 = new Keynote3()
                {
                    color = "#0000ff",
                    value = addContract.Address + addContract.Cell + "单元" + addContract.Floor + "楼" + addContract.Room + "房"
                };
                var keynote4 = new Keynote4()
                {
                    color = "#0000ff",
                    value = addContract.RentBeginTime.Value.ToString("yyyy-MM-dd") + "至" + addContract.RentEndTime.Value.ToString("yyyy-MM-dd")
                };
                var keynote5 = new Keynote5()
                {
                    color = "#0000ff",
                    value = addContract.F_U_Name
                };
                Weixin.Mp.Sdk.Domain.Remark remark = new Remark();
                remark.color = "#464646";
                remark.value = "请尽快完成线上签约。";
                Weixin.Mp.Sdk.Domain.Data data = new Data();
                data.first    = first;
                data.keynote1 = keynote1;
                data.keynote2 = keynote2;
                data.keynote3 = keynote3;
                data.keynote4 = keynote4;
                data.keynote5 = keynote5;
                data.remark   = remark;
                Weixin.Mp.Sdk.Domain.Miniprogram miniprogram = new Miniprogram();
                miniprogram.appid    = "";
                miniprogram.pagepath = "";
                Weixin.Mp.Sdk.Domain.TemplateMessage templateMessage = new TemplateMessage();
                templateMessage.AppId       = ConfigHelper.AppSettings("WEPAY_WEB_APPID");
                templateMessage.AppSecret   = ConfigHelper.AppSettings("WEPAY_WEb_AppSecret");
                templateMessage.data        = data;
                templateMessage.miniprogram = miniprogram;
                templateMessage.template_id = "hs52Q2SBFc1iEdJrPD9CH3NR6t_IMfYDN-Yg2z6U0ak";
                var usermodel = database.FindEntity <Ho_PartnerUser>(addContract.U_Number);
                templateMessage.touser = usermodel.OpenId;
                templateMessage.url    = "http://am.zst0771.com/Common/Contract?KeyValue=" + addContract.Number;
                templateMessage.SendTemplateMessage();


                return(Json(new { res = "Ok", msg = "提交成功" }));
            }
            return(Json(new { res = "No", msg = "提交失败" }));
        }