コード例 #1
0
        public IActionResult DeliveryAdd(yoshop_delivery model, List <string> regions, List <double> firsts, List <decimal> first_fees, List <double> additionals, List <decimal> additional_fees)
        {
            var dt       = DateTime.Now.ConvertToTimeStamp();
            var wxapp_id = GetAdminSession().wxapp_id;

            model.create_time = dt;
            model.update_time = dt;
            model.wxapp_id    = wxapp_id;

            try
            {
                //LogManager.Info(regions.ObjectToJson());
                uint delivery_id = (uint)DeliveryService.AddEntityReturnIdentity(model);
                if (delivery_id > 0)
                {
                    if (regions != null && regions.Any())
                    {
                        List <yoshop_delivery_rule> rules = new List <yoshop_delivery_rule>();

                        for (int i = 0; i < regions.Count; i++)
                        {
                            var _ = new yoshop_delivery_rule
                            {
                                region         = regions[i],
                                first          = firsts[i],
                                first_fee      = first_fees[i],
                                additional     = additionals[i],
                                additional_fee = additional_fees[i],
                                delivery_id    = delivery_id,
                                wxapp_id       = wxapp_id,
                                create_time    = dt
                            };
                            rules.Add(_);
                        }
                        DeliveryRuleService.AddEntities(rules);
                    }
                    else
                    {
                        return(No("请选择可配送区域"));
                    }
                }
            }
            catch (Exception e)
            {
                LogManager.Error(GetType(), e);
                return(No(e.Message));
            }

            return(YesRedirect("添加成功", "/setting.delivery/index"));
        }