Пример #1
0
    private void DoUpdate(Control button)
    {
        Control _temp    = button.NamingContainer;
        string  main_key = (string)this.ViewState["main_key"];
        string  sub_key  = (_temp.FindControl("hidden_sub_key") as HtmlInputHidden).Value.Trim();
        string  content  = (_temp.FindControl("textbox_content") as TextBox).Text.Trim();
        string  desc     = (_temp.FindControl("textbox_description") as TextBox).Text.Trim();

        if (string.IsNullOrEmpty(content))
        {
            ScriptHelper.AjaxAlert(this.UpdatePanel1, "please input content");
            return;
        }

        SysCodeList entity = new SysCodeList(main_key, sub_key);

        entity.Content     = content;
        entity.Description = desc;

        CodeBiz.UpdateCodeList(entity);

        this.LoadData();

        this.GridView1.EditIndex = -1;
        this.GridView1.DataBind();
    }
Пример #2
0
    private void DoAddFirst(Control button)
    {
        Control _temp    = button.NamingContainer;
        string  main_key = (string)this.ViewState["main_key"];
        string  sub_key  = (_temp.FindControl("textbox_sub_key") as TextBox).Text.Trim();
        string  content  = (_temp.FindControl("textbox_content") as TextBox).Text.Trim();
        string  desc     = (_temp.FindControl("textbox_description") as TextBox).Text.Trim();

        if (string.IsNullOrEmpty(sub_key))
        {
            ScriptHelper.AjaxAlertFocus(this.UpdatePanel1, "please input sub_key.",
                                        _temp.FindControl("textbox_sub_key"));
            return;
        }

        if (string.IsNullOrEmpty(content))
        {
            ScriptHelper.AjaxAlertFocus(this.UpdatePanel1, "please input content",
                                        _temp.FindControl("textbox_content"));
            return;
        }

        SysCodeList entity = new SysCodeList(main_key, sub_key);

        entity.Content     = content;
        entity.Description = desc;

        CodeBiz.InsertCodeList(entity);

        this.LoadData();
    }
Пример #3
0
    private void DoAddNew(Control button)
    {
        Control _temp    = button.NamingContainer;
        string  main_key = (_temp.FindControl("textbox_main_key") as TextBox).Text.Trim();
        string  desc     = (_temp.FindControl("textbox_description") as TextBox).Text.Trim();

        if (string.IsNullOrEmpty(main_key))
        {
            ScriptHelper.AjaxAlertFocus(this.UpdatePanel1, "please input main_key.",
                                        _temp.FindControl("textbox_main_key"));
            return;
        }

        if (string.IsNullOrEmpty(desc))
        {
            ScriptHelper.AjaxAlertFocus(this.UpdatePanel1, "please input description",
                                        _temp.FindControl("textbox_description"));
            return;
        }

        SysCodeMaster entity = new SysCodeMaster();

        entity.MainKey     = main_key;
        entity.Description = desc;


        CodeBiz.InsertMaster(entity);

        this.LoadData();
    }
Пример #4
0
    private void DoDelete(Control button)
    {
        Control _temp    = button.NamingContainer;
        string  main_key = (string)this.ViewState["main_key"];
        string  sub_key  = (_temp.FindControl("hidden_sub_key") as HtmlInputHidden).Value;

        SysCodeList entity = new SysCodeList(main_key, sub_key);

        CodeBiz.DeleteCodeList(entity);
        this.LoadData();
    }
Пример #5
0
    private void DoDelete(Control button)
    {
        Control _temp = button.NamingContainer;

        string main_key = (_temp.FindControl("hidden_main_key") as HtmlInputHidden).Value;

        SysCodeMaster entity = new SysCodeMaster(main_key);

        CodeBiz.DeleteMaster(entity);
        this.LoadData();
    }
Пример #6
0
        public async Task <IActionResult> AddDictionaryAsync([FromBody] AddDictionaryRequestDto request)
        {
            var dictionaryBiz = new DictionaryBiz();
            var entity2       = await dictionaryBiz.GetDictionaryByNameAsync(request.ConfigName);

            if (entity2 != null)
            {
                return(Failed(ErrorCode.UserData, "已经存在相同的字典名"));
            }
            //var entitys = await dictionaryBiz.GetListByCodeAsync(request.ConfigCode);
            var code    = new CodeBiz().GetDictionaryCode("D", 6);
            var entitys = await dictionaryBiz.GetListByCodeAsync(code);

            if (entitys.Count() > 0)
            {
                return(Failed(ErrorCode.UserData, "code不能重复"));
            }
            var pentity = await dictionaryBiz.GetAsync(request.ParentGuid);

            if (pentity == null)
            {
                return(Failed(ErrorCode.UserData, "数据被禁用"));
            }
            var model = request.ToModel <DictionaryModel>();

            model.TypeName      = pentity?.ConfigName;
            model.TypeCode      = pentity?.ConfigCode;
            model.ParentGuid    = pentity?.DicGuid;
            model.ConfigCode    = code;
            model.ValueRange    = string.IsNullOrWhiteSpace(request.ValueRange) ? "{}" : request.ValueRange;
            model.DicGuid       = Guid.NewGuid().ToString("N");
            model.CreatedBy     = UserID;
            model.LastUpdatedBy = UserID;
            model.OrgGuid       = string.Empty;

            var result = await dictionaryBiz.InsertAsync(model);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "添加失败"));
            }
            return(Success());
        }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string main_key = Request["main_key"];

            if (string.IsNullOrEmpty(main_key))
            {
                this.Response.End();
                return;
            }

            this.ViewState["main_key"] = main_key;
            SysCodeMaster master = CodeBiz.GetMaster(main_key);
            this.label_main_key.Text         = main_key;
            this.label_main_description.Text = master.Description;
        }

        this.LoadData();
    }
        public async Task <IActionResult> SubmitMealOrderAsync([FromBody] SubmitMealOrderRequestDto requestDto)
        {
            var dishesIds         = requestDto.DishesDetails.Select(a => a.DishesGuid).Distinct().ToList();
            var dishesCategoryIds = requestDto.DishesDetails.Select(a => a.CategoryGuid).Distinct().ToList();

            var accountModels = await new MealAccountBiz().GetModelsByUserIdAsync(UserID, requestDto.HospitalGuid);

            if (!accountModels.Any())
            {
                return(Failed(ErrorCode.Empty, "未检测到钱包账户,请先充值"));
            }
            var isInternal = accountModels.FirstOrDefault(a => a.UserType == MealUserTypeEnum.Internal.ToString()) != null;

            var dishesModels      = await new MealDishesBiz().GetModelsByIdsAsync(dishesIds);
            var checkDishesOnsale = dishesModels.FirstOrDefault(a => a.DishesOnsale == 0);

            if (checkDishesOnsale != null)
            {
                return(Failed(ErrorCode.UserData, "订单中存在下架的菜品"));
            }

            var codeBiz = new CodeBiz();
            var orderNo = codeBiz.GetMealOrderCode("M");
            //餐别基础数据
            var dishesCategoryModels = await new MealCategoryBiz().GetModelsByIdsAsync(dishesCategoryIds);
            var groupDishes          = requestDto.DishesDetails.GroupBy(a => new { a.MealDate, a.CategoryGuid });
            List <MealOrderModel>              orders             = new List <MealOrderModel>();              //点餐订单列表
            List <MealOrderDetailModel>        orderDetails       = new List <MealOrderDetailModel>();        //点餐订单明细列表
            List <MealAccountDetailModel>      accountDetails     = new List <MealAccountDetailModel>();      //点餐钱包流水列表
            List <MealAccountTradeModel>       tradeModels        = new List <MealAccountTradeModel>();       //点餐交易流水列表
            List <MealAccountTradeDetailModel> tradeDetailsModels = new List <MealAccountTradeDetailModel>(); //点餐交易流水明细列表
            var orderIndex = 1;

            foreach (var item in groupDishes)
            {
                var theDishesCategory = dishesCategoryModels.FirstOrDefault(a => a.CategoryGuid == item.Key.CategoryGuid);
                var order             = new MealOrderModel
                {
                    OrderGuid     = Guid.NewGuid().ToString("N"),
                    OrderNo       = $"{orderNo}-{orderIndex++}",
                    CategoryGuid  = item.Key.CategoryGuid,
                    CategoryName  = theDishesCategory?.CategoryName,
                    MealDate      = item.Key.MealDate,
                    MealStartTime = Convert.ToDateTime($"{item.Key.MealDate.ToString("yyyy-MM-dd")} {theDishesCategory.MealStartTime}"),
                    MealEndTime   = Convert.ToDateTime($"{item.Key.MealDate.ToString("yyyy-MM-dd")} {theDishesCategory.MealEndTime}"),
                    UserGuid      = UserID,
                    HospitalGuid  = requestDto.HospitalGuid,
                    OrderStatus   = MealOrderStatusEnum.Paided.ToString(),
                    Quantity      = item.Sum(a => a.Quantity),
                    TotalPrice    = 0,
                    CreatedBy     = UserID,
                    LastUpdatedBy = UserID,
                    OrgGuid       = string.Empty
                };
                var totalPrice = 0M;
                foreach (var dish in item)
                {
                    var theDishes     = dishesModels.FirstOrDefault(a => a.DishesGuid == dish.DishesGuid);
                    var internalPrice = theDishes.DishesInternalPrice;
                    var externalPrice = theDishes.DishesExternalPrice;
                    var orderDetail   = new MealOrderDetailModel
                    {
                        OrderDetailGuid = Guid.NewGuid().ToString("N"),
                        OrderGuid       = order.OrderGuid,
                        DishesGuid      = dish.DishesGuid,
                        DishesName      = theDishes.DishesName,
                        Quantity        = dish.Quantity,
                        UnitPrice       = isInternal ? internalPrice : externalPrice,
                        CreatedBy       = UserID,
                        LastUpdatedBy   = UserID,
                        OrgGuid         = string.Empty
                    };
                    totalPrice += orderDetail.Quantity * orderDetail.UnitPrice;
                    orderDetails.Add(orderDetail);
                }
                order.TotalPrice = totalPrice;
                orders.Add(order);



                #region 交易流水记录
                tradeModels.Add(new MealAccountTradeModel
                {
                    AccountTradeGuid        = Guid.NewGuid().ToString("N"),
                    OrderGuid               = order.OrderGuid,
                    AccountTradeType        = (sbyte)MealAccountTradeTypeEnum.Consumer,
                    AccountTradeFee         = order.TotalPrice,
                    AccountTradeDescription = string.Empty,
                    CreatedBy               = UserID,
                    LastUpdatedBy           = UserID,
                    OrgGuid = string.Empty
                });
                #endregion
            }
            var accountToal = accountModels.Sum(a => a.AccountBalance);
            var orderTotal  = orders.Sum(a => a.TotalPrice);
            if (accountToal < orderTotal)
            {
                return(Failed(ErrorCode.UserData, "余额不足,请先充值"));
            }
            var rechargeAccount = accountModels.FirstOrDefault(a => a.AccountType == MealAccountTypeEnum.Recharge.ToString());
            var grantAccount    = accountModels.FirstOrDefault(a => a.AccountType == MealAccountTypeEnum.Grant.ToString());
            var paidMoney       = orderTotal;

            var orderDic = orders.ToDictionary(a => a.OrderGuid, a => a.TotalPrice);
            //创建钱包流水记录
            if (grantAccount != null && grantAccount.AccountBalance > 0)
            {
                var grantPaid = grantAccount.AccountBalance > paidMoney ? paidMoney : grantAccount.AccountBalance;
                accountDetails.Add(new MealAccountDetailModel
                {
                    AccountDetailGuid        = Guid.NewGuid().ToString("N"),
                    AccountGuid              = grantAccount.AccountGuid,
                    AccountDetailType        = MealAccountDetailTypeEnum.Consume.ToString(),
                    AccountDetailIncomeType  = (sbyte)MealAccountDetailIncomeTypeEnum.Expenditure,
                    AccountDetailBeforeFee   = grantAccount.AccountBalance,
                    AccountDetailFee         = grantPaid,
                    AccountDetailAfterFee    = grantAccount.AccountBalance - grantPaid,
                    AccountDetailDescription = "订单消费",
                    Remark        = orderNo,
                    CreatedBy     = UserID,
                    LastUpdatedBy = UserID,
                    OrgGuid       = string.Empty
                });
                paidMoney -= grantPaid;

                for (int i = 0; i < orderDic.Count; i++)
                {
                    var item = orderDic.ElementAt(i);
                    if (item.Value > 0 && grantPaid > 0)
                    {
                        var orderPaid = grantPaid > item.Value ? item.Value : grantPaid;
                        tradeDetailsModels.Add(new MealAccountTradeDetailModel
                        {
                            AccountTradeDetailGuid = Guid.NewGuid().ToString("N"),
                            AccountGuid            = grantAccount.AccountGuid,
                            AccountTradeGuid       = tradeModels.FirstOrDefault(a => a.OrderGuid == item.Key)?.AccountTradeGuid,
                            AccountTradeFee        = orderPaid,
                            CreatedBy     = UserID,
                            LastUpdatedBy = UserID,
                            OrgGuid       = string.Empty
                        });
                        orderDic[item.Key] -= orderPaid;
                        grantPaid          -= orderPaid;
                    }
                }
            }
            if (paidMoney > 0 && rechargeAccount != null && rechargeAccount.AccountBalance > 0)
            {
                accountDetails.Add(new MealAccountDetailModel
                {
                    AccountDetailGuid        = Guid.NewGuid().ToString("N"),
                    AccountGuid              = rechargeAccount.AccountGuid,
                    AccountDetailType        = MealAccountDetailTypeEnum.Consume.ToString(),
                    AccountDetailIncomeType  = (sbyte)MealAccountDetailIncomeTypeEnum.Expenditure,
                    AccountDetailBeforeFee   = rechargeAccount.AccountBalance,
                    AccountDetailFee         = paidMoney,
                    AccountDetailAfterFee    = rechargeAccount.AccountBalance - paidMoney,
                    AccountDetailDescription = "订单消费",
                    Remark        = orderNo,
                    CreatedBy     = UserID,
                    LastUpdatedBy = UserID,
                    OrgGuid       = string.Empty
                });
                for (int i = 0; i < orderDic.Count; i++)
                {
                    var item = orderDic.ElementAt(i);
                    if (item.Value > 0)
                    {
                        tradeDetailsModels.Add(new MealAccountTradeDetailModel
                        {
                            AccountTradeDetailGuid = Guid.NewGuid().ToString("N"),
                            AccountGuid            = rechargeAccount.AccountGuid,
                            AccountTradeGuid       = tradeModels.FirstOrDefault(a => a.OrderGuid == item.Key)?.AccountTradeGuid,
                            AccountTradeFee        = item.Value,
                            CreatedBy     = UserID,
                            LastUpdatedBy = UserID,
                            OrgGuid       = string.Empty
                        });
                        orderDic[item.Key] -= item.Value;
                    }
                }
            }

            var res = await new MealOrderBiz().SubmitMealOrderAsync(orders, orderDetails, accountDetails, tradeModels, tradeDetailsModels);
            return(res ? Success() : Failed(ErrorCode.DataBaseError));
        }
Пример #9
0
 private void LoadData()
 {
     this.GridView1.DataSource = CodeBiz.GetCodeList((string)this.ViewState["main_key"]);
     this.GridView1.DataBind();
 }
Пример #10
0
 private void LoadData()
 {
     this.GridView1.DataSource = CodeBiz.GetMarsterList();
     this.GridView1.DataBind();
 }