Пример #1
0
        /// <summary>
        /// 计算运费
        /// </summary>
        /// <param name="store"></param>
        /// <returns></returns>
        private int GetFreight(QiyeStore store, List <QiyeGoodsCart> cartList, int getWay, string goodCarIdStr, int aid, WxAddress address, ref string msg)
        {
            int friPrice = 0;
            QiyeStoreSwitchModel config = JsonConvert.DeserializeObject <QiyeStoreSwitchModel>(store.SwitchConfig);

            int qtySum = cartList.Sum(x => x.Count);

            switch (getWay)
            {
            case (int)miniAppOrderGetWay.到店自取:
                break;

            case (int)miniAppOrderGetWay.商家配送:
                DeliveryFeeResult deliueryResult = DeliveryTemplateBLL.SingleModel.GetQiyeFee(goodCarIdStr, aid, address.provinceName, address.cityName, ref msg);
                if (msg.Length > 0)
                {
                    return(0);
                }

                friPrice = deliueryResult.Fee;
                break;
            }

            return(friPrice);
        }
Пример #2
0
        /// <summary>
        /// 运费模板设置
        /// </summary>
        /// <param name="model"></param>
        /// <param name="updateSet"></param>
        /// <returns></returns>
        public bool UpdateConfig(QiyeStore model, Dictionary <string, object> updateSet)
        {
            if (model == null || updateSet == null || updateSet.Count == 0)
            {
                return(false);
            }

            QiyeStoreSwitchModel config = string.IsNullOrWhiteSpace(model.SwitchConfig) ? new QiyeStoreSwitchModel() : JsonConvert.DeserializeObject <QiyeStoreSwitchModel>(model.SwitchConfig);

            try
            {
                config = SetConfigValue(updateSet, config);
            }
            catch (Exception ex)
            {
                log4net.LogHelper.WriteError(this.GetType(), ex);
                return(false);
            }

            model.SwitchConfig = JsonConvert.SerializeObject(config);
            return(Update(model, "SwitchConfig"));
        }
Пример #3
0
        public QiyeStoreSwitchModel SetConfigValue(Dictionary <string, object> updateList, QiyeStoreSwitchModel config)
        {
            Type configType = typeof(QiyeStoreSwitchModel);

            foreach (var set in updateList)
            {
                object newValue = Convert.ChangeType(set.Value, configType.GetProperty(set.Key).PropertyType);
                configType.GetProperty(set.Key).SetValue(config, newValue, null);
            }
            return(config);
        }