Exemple #1
0
        /// <summary>
        /// 修改发收货地址
        /// </summary>
        /// <param name="shopId"></param>
        /// <param name="data"></param>
        public static void Update(long shopId, ShopShipper data)
        {
            //  var _d = AutoMapper.Mapper.Map<ShopShipperInfo>(data);

            var _d = data.Map <ShopShipperInfo>();

            _iShopShippersServiceService.Update(shopId, _d);
        }
        public ActionResult Add(long id = 0)
        {
            int    sceneid   = 0;
            string ticketstr = "";
            var    settings  = SiteSettingApplication.SiteSettings;

            try
            {
                if (!string.IsNullOrWhiteSpace(settings.WeixinAppId) && !string.IsNullOrWhiteSpace(settings.WeixinAppSecret))
                {
                    string token = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret);
                    if (string.IsNullOrWhiteSpace(token))
                    {
                        token = AccessTokenContainer.TryGetToken(settings.WeixinAppId, settings.WeixinAppSecret, true);
                    }

                    SceneModel scene = new SceneModel(QR_SCENE_Type.ShopShipper)
                    {
                        //Object = CurrentUser.Id.ToString()
                    };
                    SceneHelper helper = new SceneHelper();
                    sceneid = helper.SetModel(scene);
                    var ticket = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 300, sceneid);
                    ticketstr = ticket.ticket;
                }
            }
            catch {
                Log.Error("设置退货地址出错:微信配置错误,无法获取到微信凭证");
            }
            ViewBag.ticket  = ticketstr;
            ViewBag.Sceneid = sceneid;
            ShopShipper data = new ShopShipper
            {
                ShopId = CurShopId
            };

            if (id > 0)
            {
                data = ShopShippersApplication.GetShopShipper(CurShopId, id);
                if (data == null)
                {
                    throw new HimallException("错误的参数");
                }
            }
            return(View(data));
        }
 public JsonResult Save(ShopShipper model)
 {
     if (model.RegionId <= 0)
     {
         ModelState.AddModelError("Latitude", "请选择发货地区");
     }
     if (!model.Latitude.HasValue || !model.Longitude.HasValue)
     {
         ModelState.AddModelError("Latitude", "请定位发货地址");
     }
     if (ModelState.IsValid)
     {
         bool isadd = false;
         if (model.Id == 0)
         {
             isadd = true;
         }
         model.ShopId = CurShopId;
         if (isadd)
         {
             ShopShippersApplication.Add(CurShopId, model);
         }
         else
         {
             var curdata = ShopShippersApplication.GetShopShipper(CurShopId, model.Id);
             if (curdata == null)
             {
                 throw new HimallException("错误参数");
             }
             UpdateModel(curdata);
             ShopShippersApplication.Update(CurShopId, curdata);
         }
         return(Json(new Result()
         {
             success = true, msg = "保存发收货地址成功"
         }));
     }
     else
     {
         return(Json(new Result()
         {
             success = false, msg = "数据参数错误"
         }));
     }
 }
Exemple #4
0
        /// <summary>
        /// 添加发收货地址
        /// </summary>
        /// <param name="shopId"></param>
        /// <param name="data"></param>
        public static void Add(long shopId, ShopShipper data)
        {
            var _d = AutoMapper.Mapper.Map <ShopShipperInfo>(data);

            _iShopShippersServiceService.Add(shopId, _d);
        }