Пример #1
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Add(ChargeCardsModel model)
        {
            model.ChargeCardNo = "H" + model.CustomId + DateTime.Now.ToString("yyyyMMddHHmmss");
            //开启事务
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();

            int returnvalue = 0;

            try
            {
                db.BeginTransaction();
                //客户财务信息操作

                //获取当前客户财务信息
                CustomFinancialModel financialModel = OQL.FromObject <CustomFinancialModel>().Select().Where((cmp, m) => cmp.Comparer(m.CustomId, "=", model.CustomId) & cmp.Comparer(m.TenantId, "=", TenantId)).END.ToObject(db);
                if (financialModel == null)
                {
                    db.Rollback();
                    return(new JsonRsp {
                        success = false, retmsg = "获取客户合同信息失败"
                    });
                }
                decimal amount = model.CurrentAmount;
                string  remark = "客户充卡";
                if (model.MoneyType == (int)MoneyTypeEnum.应收)
                {
                    if (financialModel.MoneyTypeOneAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeOneAmount + ""
                        });
                    }
                    financialModel.MoneyTypeOneAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeOneAmount;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.赠送)
                {
                    if (financialModel.MoneyTypeTwoAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeTwoAmount + ""
                        });
                    }
                    financialModel.MoneyTypeTwoAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeTwoAmount;;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.置换)
                {
                    if (financialModel.MoneyTypeThreeAmount < amount)
                    {
                        db.Rollback();
                        return(new JsonRsp {
                            success = false, retmsg = "余额只有" + financialModel.MoneyTypeThreeAmount + ""
                        });
                    }
                    financialModel.MoneyTypeThreeAmount -= amount;
                    CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                    financialDetail.CustomFinancialId = financialModel.ID;
                    financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                    financialDetail.Remark            = remark;
                    financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                    financialDetail.CurrentAmount     = amount;
                    financialDetail.Balance           = financialModel.MoneyTypeThreeAmount;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetail, db);
                }
                returnvalue += Update <CustomFinancialModel>(financialModel, db);
                returnvalue += Add <ChargeCardsModel>(model, db);

                //新增客户应付
                CustomAccReceiptModel customAR = new CustomAccReceiptModel();
                customAR.CustomId      = model.CustomId;
                customAR.ChargeCardNo  = model.ChargeCardNo;
                customAR.CurrentAmount = model.MoneyType == (int)MoneyTypeEnum.应收 ? model.CurrentAmount : 0;
                customAR.Status        = (int)ARStatusEnum.已确认;
                customAR.CreateId      = AdminId;
                customAR.CreateUser    = AdminName;
                customAR.CreateIP      = Util.GetLocalIP;
                customAR.CreateTime    = DateTime.Now;
                returnvalue           += Add <CustomAccReceiptModel>(customAR, db);

                //事务提交
                if (returnvalue == 4)
                {
                    db.Commit();
                }
                else
                {
                    returnvalue = 0;
                    db.Rollback();
                }
            }
            catch (Exception ex)
            {
                //事务回滚
                db.Rollback();
                return(new JsonRsp {
                    success = false, retmsg = ex.Message.ToString()
                });
            }
            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });
        }
Пример #2
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Audit(long[] Ids, int status)
        {
            if (Ids == null)
            {
                return(new JsonRsp {
                    success = false, retmsg = "请选择要操作的数据"
                });
            }


            //更新状态
            ContractModel model = new ContractModel();

            model.Status = status;
            OQL q = OQL.From(model)
                    .Update(model.Status)
                    .Where(cmp => cmp.Comparer(model.ID, "IN", Ids))       //为了安全,不带Where条件是不会全部删除数据的
                    .END;
            //初始化客户财务信息

            OQL qList = OQL.From(model)
                        .Select()
                        .OrderBy(model.Sort, "asc")
                        .END;
            List <ContractModel> items = qList.ToList <ContractModel>();
            int returnvalue            = 0;

            foreach (ContractModel item in items)
            {
                if (item.Status != 0)
                {
                    return(new JsonRsp {
                        success = false, retmsg = "只能审核待审核合同,该合同当前状态为:" + Util.getStatus(item.Status, typeof(BaseEnum.ProtocolTypeEnum))
                    });
                }
                //客户财务信息初始化
                CustomFinancialModel financialModel = new CustomFinancialModel();
                financialModel.CreateUser      = AdminName;
                financialModel.CreateIP        = Util.GetLocalIP();
                financialModel.CreateTime      = DateTime.Now;
                financialModel.CustomId        = item.CustomId;
                financialModel.ARAmount        = item.AccountReceivable;
                financialModel.ARBalance       = item.AccountReceivable;
                financialModel.LargessAmount   = item.LargessAmount;
                financialModel.LargessBalance  = item.LargessAmount;
                financialModel.ExChangeAmount  = item.ExChangeAmount;
                financialModel.ExChangeBalance = item.ExChangeAmount;
                financialModel.Remark          = "合同/协议号:" + item.ContractNo;
                returnvalue = Add <CustomFinancialModel>(financialModel);

                //新增客户财务信息日志
                List <CustomFinancialDetailModel> details = new List <CustomFinancialDetailModel>();

                CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                financialDetail.CurrentAmount     = item.AccountReceivable;
                financialDetail.Balance           = financialDetail.CurrentAmount;
                financialDetail.Remark            = "合同/协议号:" + item.ContractNo;
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                returnvalue = Add <CustomFinancialDetailModel>(financialDetail);

                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                financialDetail.CurrentAmount     = item.LargessAmount;
                financialDetail.Balance           = financialDetail.CurrentAmount;
                financialDetail.Remark            = "合同/协议号:" + item.ContractNo;
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                returnvalue = Add <CustomFinancialDetailModel>(financialDetail);

                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                financialDetail.CurrentAmount     = item.ExChangeAmount;
                financialDetail.Balance           = financialDetail.CurrentAmount;
                financialDetail.Remark            = "合同/协议号:" + item.ContractNo;
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                returnvalue = Add <CustomFinancialDetailModel>(financialDetail);
            }
            returnvalue = EntityQuery <TicketInfo> .Instance.ExecuteOql(q);

            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });
        }
Пример #3
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Add(CustomChargeCardsModel model)
        {
            model.ChargeCardNo = "H" + model.CustomId + DateTime.Now.ToString("yyyyMMddHHmmss");;
            //客户财务信息操作
            //新增客户财务明细信息
            CustomFinancialModel financialModel = new CustomFinancialBLL().GetCustomFinancialByCustomId(model.CustomId);
            decimal amount = model.CurrentAmount;

            if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.应收)
            {
                financialModel.ARBalance -= amount;

                CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                financialDetail.Remark            = "客户充卡";
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                financialDetail.CurrentAmount     = amount;
                financialDetail.Balance           = financialModel.ARBalance - amount;;
                Add <CustomFinancialDetailModel>(financialDetail);
            }
            else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.赠送)
            {
                financialModel.LargessBalance -= amount;

                CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                financialDetail.Remark            = "客户充卡";
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                financialDetail.CurrentAmount     = amount;
                financialDetail.Balance           = financialModel.LargessBalance - amount;;
                Add <CustomFinancialDetailModel>(financialDetail);
            }
            else if (model.MoneyType == (int)BaseEnum.MoneyTypeEnum.置换)
            {
                financialModel.ExChangeBalance = amount;

                CustomFinancialDetailModel financialDetail = new CustomFinancialDetailModel();
                financialDetail.CreateUser        = AdminName;
                financialDetail.CreateIP          = Util.GetLocalIP();
                financialDetail.CreateTime        = DateTime.Now;
                financialDetail.CustomFinancialId = financialModel.ID;
                financialDetail.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.减少;
                financialDetail.Remark            = "客户充卡";
                financialDetail.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                financialDetail.CurrentAmount     = amount;
                financialDetail.Balance           = financialModel.ExChangeBalance - amount;;
                Add <CustomFinancialDetailModel>(financialDetail);
            }
            int returnvalue = EntityQuery <CustomFinancialModel> .Instance.Update(financialModel);

            model.CreateUser = AdminName;
            model.CreateIP   = Util.GetLocalIP();
            model.CreateTime = DateTime.Now;
            returnvalue      = EntityQuery <CustomChargeCardsModel> .Instance.Insert(model);

            //新增客户应付
            CustomAccReceiptModel customAR = new CustomAccReceiptModel();

            customAR.CustomId     = model.CustomId;
            customAR.ChargeCardNo = model.ChargeCardNo;
            customAR.ARAmount     = model.CurrentAmount;
            customAR.Status       = (int)ARStatusEnum.已确认;
            customAR.CreateUser   = AdminName;
            customAR.CreateIP     = Util.GetLocalIP();
            customAR.CreateTime   = DateTime.Now;
            returnvalue           = EntityQuery <CustomAccReceiptModel> .Instance.Insert(customAR);


            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });
        }
Пример #4
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonRsp Audit(long[] Ids, int status)
        {
            #region
            if (Ids == null)
            {
                return(new JsonRsp {
                    success = false, retmsg = "请选择要操作的数据"
                });
            }

            int returnvalue = 0;
            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            try
            {
                //开始事务
                db.BeginTransaction();

                //更新状态
                ContractModel model = new ContractModel();
                OQL           qList = OQL.From(model)
                                      .Select()
                                      .OrderBy(model.Sort, "asc")
                                      .END;
                List <ContractModel> items = qList.ToList <ContractModel>();
                foreach (ContractModel item in items)
                {
                    if (item.Status != 0)
                    {
                        return(new JsonRsp {
                            success = false, retmsg = "只能审核待审核合同,该合同当前状态为:" + Util.getStatus(item.Status, typeof(BaseEnum.ProtocolTypeEnum))
                        });
                    }
                    //更新合同状态
                    item.Status  = status;
                    returnvalue += Update <ContractModel>(item, db, false);

                    string remark = "合同/协议号:" + item.ContractNo + "审核通过";
                    //获取当前客户财务信息
                    CustomFinancialModel financialModel = OQL.FromObject <CustomFinancialModel>().Select().Where((cmp, m) => cmp.Comparer(m.CustomId, "=", item.CustomId) & cmp.Comparer(m.TenantId, "=", item.TenantId)).END.ToObject(db);
                    if (financialModel == null)
                    {
                        financialModel = new CustomFinancialModel();
                        //客户财务信息初始化
                        financialModel.CustomId                  = item.CustomId;
                        financialModel.MoneyTypeOneAmount        = item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeOneTotalAmount   = item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeTwoAmount        = item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeTwoTotalAmount   = item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeThreeAmount      = item.MoneyTypeThreeAmount;
                        financialModel.MoneyTypeThreeTotalAmount = item.MoneyTypeThreeAmount;
                        financialModel.Status = 1;
                        returnvalue          += Add <CustomFinancialModel>(financialModel, db);
                    }
                    else
                    {
                        //客户财务信息修改
                        financialModel.CustomId                   = item.CustomId;
                        financialModel.MoneyTypeOneAmount        += item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeOneTotalAmount   += item.MoneyTypeOneAmount;
                        financialModel.MoneyTypeTwoAmount        += item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeTwoTotalAmount   += item.MoneyTypeTwoAmount;
                        financialModel.MoneyTypeThreeAmount      += item.MoneyTypeThreeAmount;
                        financialModel.MoneyTypeThreeTotalAmount += item.MoneyTypeThreeAmount;
                        financialModel.Status = 1;
                        returnvalue          += Update <CustomFinancialModel>(financialModel, db);
                    }

                    //新增客户财务信息日志
                    //应收明细
                    CustomFinancialDetailModel financialDetailOne = new CustomFinancialDetailModel();
                    financialDetailOne.CustomFinancialId = financialModel.ID;
                    financialDetailOne.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailOne.CurrentAmount    += item.MoneyTypeOneAmount;
                    financialDetailOne.Balance          += item.MoneyTypeOneAmount;
                    financialDetailOne.Remark            = remark;
                    financialDetailOne.Status            = 1;
                    financialDetailOne.MoneyType         = (int)BaseEnum.MoneyTypeEnum.应收;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailOne, db);
                    //赠送明细
                    CustomFinancialDetailModel financialDetailTwo = new CustomFinancialDetailModel();
                    financialDetailTwo.CustomFinancialId = financialModel.ID;
                    financialDetailTwo.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailTwo.CurrentAmount    += item.MoneyTypeTwoAmount;
                    financialDetailTwo.Balance          += item.MoneyTypeTwoAmount;
                    financialDetailTwo.Remark            = remark;
                    financialDetailTwo.Status            = 1;
                    financialDetailTwo.MoneyType         = (int)BaseEnum.MoneyTypeEnum.赠送;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailTwo, db);
                    //置换明细
                    CustomFinancialDetailModel financialDetailThree = new CustomFinancialDetailModel();
                    financialDetailThree.CustomFinancialId = financialModel.ID;
                    financialDetailThree.FinanciaOpeType   = (int)FinanciaOpeTypeEnum.增加;
                    financialDetailThree.CurrentAmount    += item.MoneyTypeThreeAmount;
                    financialDetailThree.Balance          += item.MoneyTypeThreeAmount;
                    financialDetailThree.Remark            = remark;
                    financialDetailThree.Status            = 1;
                    financialDetailThree.MoneyType         = (int)BaseEnum.MoneyTypeEnum.置换;
                    returnvalue += Add <CustomFinancialDetailModel>(financialDetailThree);
                    //事务提交
                    if (returnvalue == 5)
                    {
                        db.Commit();
                    }
                    else
                    {
                        returnvalue = 0;
                        db.Rollback();
                    }
                }
            }
            catch (Exception ex)
            {
                //事务回滚
                db.Rollback();
                return(new JsonRsp {
                    success = false, retmsg = ex.Message.ToString()
                });
            }
            return(new JsonRsp {
                success = returnvalue > 0, code = returnvalue
            });

            #endregion
        }