/// <summary>
        /// 根据日期获取当前结算周期
        /// </summary>
        /// <returns></returns>
        private static SettlementCycle GetCurrentBilingTime()
        {
            var settlementCycle = _iSiteSettingService.GetSiteSettings().WeekSettlement;
            var end             = _iBillingService.GetLastSettlementTime();

            return(GetDateBilingTime(settlementCycle, end, DateTime.Now));
        }
Esempio n. 2
0
        // GET: Mobile/Capital
        public ActionResult Index()
        {
            //判断是否需要跳转到支付地址
            if (this.Request.Url.AbsolutePath.EndsWith("/Capital/Index", StringComparison.OrdinalIgnoreCase) || this.Request.Url.AbsolutePath.EndsWith("/Capital", StringComparison.OrdinalIgnoreCase))
            {
                return(Redirect(Url.RouteUrl("PayRoute") + "?area=mobile&platform=" + this.PlatformType.ToString() + "&controller=Capital&action=Index"));
            }

            var capitalService  = _iMemberCapitalService;
            var model           = capitalService.GetCapitalInfo(CurrentUser.Id);
            var redPacketAmount = 0M;

            if (model != null)
            {
                redPacketAmount        = model.Himall_CapitalDetail.Where(e => e.SourceType == Model.CapitalDetailInfo.CapitalDetailType.RedPacket).Sum(e => e.Amount);
                ViewBag.CapitalDetails = model.Himall_CapitalDetail.OrderByDescending(e => e.CreateTime).Take(15);
            }

            ViewBag.RedPacketAmount = redPacketAmount;
            ViewBag.IsSetPwd        = string.IsNullOrWhiteSpace(CurrentUser.PayPwd) ? false : true;
            var siteSetting = _iSiteSettingService.GetSiteSettings();

            ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum;
            ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum;
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult AndriodDownLoad()
        {
            var DownLoadApk = _iSiteSettingService.GetSiteSettings().AndriodDownLoad;

            if (!string.IsNullOrEmpty(DownLoadApk))
            {
                ViewBag.DownLoadApk = DownLoadApk;
                return(View());
            }
            return(RedirectToAction("DownLoadError"));
        }
        public JsonResult GetWXMaterialList(int pageIdx, int pageSize)
        {
            var siteSetting = _iSiteSettingService.GetSiteSettings();

            if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId))
            {
                throw new HimallException("未配置微信公众号");
            }
            var offset = (pageIdx - 1) * pageSize;
            var list   = _iWXMsgTemplateService.GetMediaMsgTemplateList(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret, offset, pageSize);

            return(Json(list));
        }
Esempio n. 5
0
        // GET: Admin/SiteSetting
        public ActionResult Edit()
        {
            var siteSetting = _iSiteSettingService.GetSiteSettings();

            Mapper.CreateMap <SiteSettingsInfo, SiteSettingModel>().ForMember(a => a.SiteIsOpen, b => b.MapFrom(s => s.SiteIsClose));
            var siteSettingModel = Mapper.Map <SiteSettingsInfo, SiteSettingModel>(siteSetting);

            siteSettingModel.Logo       = Core.HimallIO.GetImagePath(siteSettingModel.Logo);
            siteSettingModel.MemberLogo = Core.HimallIO.GetImagePath(siteSettingModel.MemberLogo);
            siteSettingModel.PCLoginPic = Core.HimallIO.GetImagePath(siteSettingModel.PCLoginPic);
            siteSettingModel.QRCode     = Core.HimallIO.GetImagePath(siteSettingModel.QRCode);
            siteSettingModel.WXLogo     = Core.HimallIO.GetImagePath(siteSettingModel.WXLogo);
            return(View(siteSettingModel));
        }
        public JsonResult Send(string pluginId, string destination)
        {
            var messagePlugin = PluginsManagement.GetPlugin <IMessagePlugin>(pluginId);

            if (string.IsNullOrEmpty(destination))
            {
                return(Json(new Result {
                    success = false, msg = "你填写的" + messagePlugin.Biz.ShortName + "不能为空!"
                }));
            }

            if (!messagePlugin.Biz.CheckDestination(destination))
            {
                return(Json(new Result {
                    success = false, msg = "你填写的" + messagePlugin.Biz.ShortName + "不正确"
                }));
            }
            var siteName = _iSiteSettingService.GetSiteSettings().SiteName;
            var result   = messagePlugin.Biz.SendTestMessage(destination, "该条信息,请勿回复!【" + siteName + "】", "这是一封测试邮件");

            if (result == "发送成功")
            {
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new Result {
                    success = false, msg = result
                }));
            }
        }
Esempio n. 7
0
        public ActionResult SetSettlementWeek()
        {
            WeekSettlementModel model = new WeekSettlementModel();
            var settings = _iSiteSettingService.GetSiteSettings();

            model.CurrentWeekSettlement = settings.WeekSettlement;
            return(View(model));
        }
Esempio n. 8
0
 public ActionResult Management()
 {
     try
     {
         var siteSetting = _iSiteSettingService.GetSiteSettings();
         if (string.IsNullOrEmpty(siteSetting.WeixinAppId) || string.IsNullOrEmpty(siteSetting.WeixinAppSecret))
         {
             return(RedirectToAction("UnConfig"));
         }
         return(View());
     }
     catch (Exception e)
     {
         Exception innerEx = e.InnerException == null ? e : e.InnerException;
         Log.Info("微信红包进入出错:", innerEx);
         throw e;
     }
 }
Esempio n. 9
0
        public ActionResult edit()
        {
            var siteSetting      = _iSiteSettingService.GetSiteSettings();
            var siteSettingModel = new SiteSettingModel()
            {
                AdvancePaymentPercent     = siteSetting.AdvancePaymentPercent,
                AdvancePaymentLimit       = siteSetting.AdvancePaymentLimit,
                UnpaidTimeout             = siteSetting.UnpaidTimeout,
                NoReceivingTimeout        = siteSetting.NoReceivingTimeout,
                OrderCommentTimeout       = siteSetting.OrderCommentTimeout,
                SalesReturnTimeout        = siteSetting.SalesReturnTimeout,
                AS_ShopConfirmTimeout     = siteSetting.AS_ShopConfirmTimeout,
                AS_SendGoodsCloseTimeout  = siteSetting.AS_SendGoodsCloseTimeout,
                AS_ShopNoReceivingTimeout = siteSetting.AS_ShopNoReceivingTimeout
            };

            return(View(siteSettingModel));
        }
 public UserInviteController(ISiteSettingService iSiteSettingService,
                             IMemberInviteService iMemberInviteService,
                             IMemberIntegralService iMemberIntegralService
                             )
 {
     _iMemberInviteService   = iMemberInviteService;
     _iMemberIntegralService = iMemberIntegralService;
     _iSiteSettingService    = iSiteSettingService;
     this._siteSetting       = _iSiteSettingService.GetSiteSettings();
 }
Esempio n. 11
0
 public BonusController(IBonusService iBonusService, ISiteSettingService iSiteSettingService)
 {
     _iBonusService       = iBonusService;
     _iSiteSettingService = iSiteSettingService;
     this._siteSetting    = _iSiteSettingService.GetSiteSettings();
     if (string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppSecret))
     {
         throw new HimallException("未配置公众号参数");
     }
 }
Esempio n. 12
0
        public ActionResult Return(string id, decimal balance)
        {
            id = DecodePaymentId(id);
            string errorMsg = string.Empty;

            try
            {
                var payment                 = Core.PluginsManagement.GetPlugin <IPaymentPlugin>(id);
                var payInfo                 = payment.Biz.ProcessReturn(HttpContext.Request);
                var accountService          = _iCashDepositsService;
                CashDepositDetailInfo model = new CashDepositDetailInfo();
                bool result                 = Cache.Get(CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds))) == null ? false : true;
                if (!result)
                {
                    model.AddDate     = DateTime.Now;
                    model.Balance     = balance;
                    model.Description = "充值";
                    model.Operator    = CurrentSellerManager.UserName;

                    List <CashDepositDetailInfo> list = new List <CashDepositDetailInfo>();
                    list.Add(model);
                    if (accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId) == null)
                    {
                        CashDepositInfo cashDeposit = new CashDepositInfo()
                        {
                            CurrentBalance           = balance,
                            Date                     = DateTime.Now,
                            ShopId                   = CurrentSellerManager.ShopId,
                            TotalBalance             = balance,
                            EnableLabels             = true,
                            Himall_CashDepositDetail = list
                        };
                        accountService.AddCashDeposit(cashDeposit);
                    }

                    else
                    {
                        model.CashDepositId = accountService.GetCashDepositByShopId(CurrentSellerManager.ShopId).Id;

                        _iCashDepositsService.AddCashDepositDetails(model);
                    }

                    //写入支付状态缓存
                    string payStateKey = CacheKeyCollection.PaymentState(string.Join(",", payInfo.OrderIds)); //获取支付状态缓存键
                    Cache.Insert(payStateKey, true);                                                          //标记为已支付
                }
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            ViewBag.Error = errorMsg;
            ViewBag.Logo  = _iSiteSettingService.GetSiteSettings().Logo;//获取Logo
            return(View());
        }
 public DistributionShopController(IDistributionService iDistributionService, IMemberService iMemberService, IMessageService iMessageService
                                   , IRegionService iRegionService, ISiteSettingService iSiteSettingService, IShopService iShopService)
 {
     _iDistributionService = iDistributionService;
     _iMemberService       = iMemberService;
     _iMessageService      = iMessageService;
     _iRegionService       = iRegionService;
     _iSiteSettingService  = iSiteSettingService;
     this._siteSetting     = _iSiteSettingService.GetSiteSettings();
     _iShopService         = iShopService;
 }
Esempio n. 14
0
        /// <summary>
        /// 确认预约单信息并提交
        /// </summary>
        /// <param name="id"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public ActionResult SubmitOrder(long id, long?regionId, int count = 1)
        {
            //Checkout
            GiftOrderConfirmPageModel data         = new Models.GiftOrderConfirmPageModel();
            List <GiftOrderItemInfo>  gorditemlist = new List <GiftOrderItemInfo>();
            GiftOrderItemInfo         gorditem; //预约单项

            #region 礼品信息判断
            //礼品信息
            GiftInfo giftdata = _iGiftService.GetById(id);
            if (giftdata == null)
            {
                throw new HimallException("错误的礼品编号!");
            }
            #endregion

            gorditem              = new GiftOrderItemInfo(); //补充预约单项
            gorditem.GiftId       = giftdata.Id;
            gorditem.GiftName     = giftdata.GiftName;
            gorditem.GiftValue    = giftdata.GiftValue;
            gorditem.ImagePath    = giftdata.ImagePath;
            gorditem.OrderId      = 0;
            gorditem.Quantity     = count;
            gorditem.SaleIntegral = giftdata.NeedIntegral;
            gorditemlist.Add(gorditem);

            data.GiftList = gorditemlist;

            data.GiftValueTotal = (decimal)data.GiftList.Sum(d => d.Quantity * d.GiftValue);
            data.TotalAmount    = (int)data.GiftList.Sum(d => d.SaleIntegral * d.Quantity);

            //用户地址
            data.ShipAddress = GetShippingAddress(regionId);

            //顶部信息 Logo
            ViewBag.Logo = _iSiteSettingService.GetSiteSettings().Logo;//获取Logo
            ViewBag.Step = 2;

            return(View(data));
        }
Esempio n. 15
0
        public ActionResult BasicSettings()
        {
            var siteSetting = _iSiteSettingService.GetSiteSettings();

            if (string.IsNullOrEmpty(siteSetting.WeixinToken))
            {
                siteSetting.WeixinToken = CreateKey(8);
                _iSiteSettingService.SetSiteSettings(siteSetting);
            }
            var siteSettingMode = new SiteSettingModel()
            {
                WeixinAppId     = string.IsNullOrEmpty(siteSetting.WeixinAppId) ? string.Empty : siteSetting.WeixinAppId.Trim(),
                WeixinAppSecret = string.IsNullOrEmpty(siteSetting.WeixinAppSecret) ? string.Empty : siteSetting.WeixinAppSecret.Trim(),
                WeixinToKen     = siteSetting.WeixinToken.Trim()
            };

            ViewBag.Url = String.Format("http://{0}/m-Weixin/WXApi", Request.Url.Host);
            //TODO:演示站处理
            //如果是演示站,支付方式参数做特别处理
            if (DemoAuthorityHelper.IsDemo())
            {
                siteSettingMode.WeixinAppId     = "*".PadRight(siteSettingMode.WeixinAppId.Length, '*');
                siteSettingMode.WeixinAppSecret = "*".PadRight(siteSettingMode.WeixinAppSecret.Length, '*');
                ViewBag.isDemo = true;
            }
            return(View(siteSettingMode));
        }
        public JsonResult SetKeyWords(string keyword, string hotkeywords)
        {
            ISiteSettingService siteSettingService = ServiceHelper.Create <ISiteSettingService>();
            SiteSettingsInfo    siteSettings       = siteSettingService.GetSiteSettings();

            siteSettings.Hotkeywords = hotkeywords;
            siteSettings.Keyword     = keyword;
            siteSettingService.SetSiteSettings(siteSettings);
            return(Json(new Result()
            {
                success = true
            }));
        }
Esempio n. 17
0
 public DistributionController(IDistributionService iDistributionService, IMemberService iMemberService, IMessageService iMessageService, IRegionService iRegionService, ISiteSettingService iSiteSettingService)
 {
     _iDistributionService     = iDistributionService;
     _iMemberService           = iMemberService;
     _iMessageService          = iMessageService;
     _iRegionService           = iRegionService;
     _iSiteSettingService      = iSiteSettingService;
     this._siteSetting         = _iSiteSettingService.GetSiteSettings();
     this._distributionsetting = _iDistributionService.GetDistributionSetting();
     if (this._distributionsetting == null)
     {
         throw new HimallException("平台未开启分佣!");
     }
 }
Esempio n. 18
0
        // GET: Admin/PageSettings
        public ActionResult Index()
        {
            var settings = _iSiteSettingService.GetSiteSettings();

            ViewBag.Logo        = settings.Logo;
            ViewBag.Keyword     = settings.Keyword;
            ViewBag.Hotkeywords = settings.Hotkeywords;

            var imageAds = _iSlideAdsService.GetImageAds(0).ToList();

            ViewBag.ImageAdsTop            = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BannerAds).ToList();
            ViewBag.HeadAds                = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList();
            ViewBag.CenterAds              = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Customize).ToList();
            ViewBag.ShopAds                = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.BrandsAds).ToList();
            ViewBag.BottomPic              = CurrentSiteSetting.PCBottomPic;
            ViewBag.AdvertisementUrl       = CurrentSiteSetting.AdvertisementUrl;
            ViewBag.AdvertisementImagePath = CurrentSiteSetting.AdvertisementImagePath;
            ViewBag.AdvertisementState     = CurrentSiteSetting.AdvertisementState;

            var imageAdsz = imageAds.Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.Single).ToArray();

            return(View(imageAdsz));
        }
        // GET: Mobile/Register
        public ActionResult Index(long id = 0, string openid = "")
        {
            ViewBag.Introducer = id;
            if (id > 0)
            {
                if (string.IsNullOrWhiteSpace(openid))
                {
                    string webRoot = Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + (HttpContext.Request.Url.Port == 80 ? "" : (":" + HttpContext.Request.Url.Port.ToString()));
                    string url     = webRoot + "/m-" + PlatformType + "/Register/InviteRegist?id=" + id;
                    return(Redirect("/m-" + PlatformType.ToString() + "/WXApi/WXAuthorize?returnUrl=" + url));
                    //return Redirect(url);
                }
            }
            var setting = _iSiteSettingService.GetSiteSettings();
            var type    = setting.RegisterType;

            ViewBag.EmailVerifOpen = setting.EmailVerifOpen;
            if (type == (int)Himall.Model.SiteSettingsInfo.RegisterTypes.Mobile)
            {
                return(View("MobileReg"));
            }
            return(View());
        }
Esempio n. 20
0
 public RegisterActivityController(
     IMemberService iMemberService,
     ISiteSettingService iSiteSettingService,
     IMemberInviteService iMemberInviteService,
     IMemberIntegralService iMemberIntegralService,
     IMemberIntegralConversionFactoryService iMemberIntegralConversionFactoryService,
     IBonusService iBonusService,
     IMessageService iMessageService
     )
 {
     _iMessageService        = iMessageService;
     _iSiteSettingService    = iSiteSettingService;
     _iMemberInviteService   = iMemberInviteService;
     _iMemberIntegralService = iMemberIntegralService;
     this._siteSetting       = _iSiteSettingService.GetSiteSettings();
 }
Esempio n. 21
0
        public ActionResult Cart()
        {
            //Logo
            ViewBag.Logo = _iSiteSettingService.GetSiteSettings().Logo;
            ViewBag.Step = 1;

            CartCartModel model = new CartCartModel();

            var memberInfo = base.CurrentUser;

            ViewBag.Member = memberInfo;
            long uid = 0;

            if (CurrentUser != null)
            {
                uid = CurrentUser.Id;
            }

            model.Top3RecommendProducts = _iProductService.GetPlatHotSaleProductByNearShop(10, uid, true).ToList();
            return(View(model));
        }
Esempio n. 22
0
 public DistributionMarketController(
     IDistributionService iDistributionService,
     IShopService iShopService,
     ISlideAdsService iSlideAdsService
     , ICategoryService iCategoryService,
     ISiteSettingService iSiteSettingService,
     IProductService iProductService,
     IMemberService iMemberService,
     ITypeService iTypeService
     )
 {
     _iDistributionService = iDistributionService;
     _iShopService         = iShopService;
     _iCategoryService     = iCategoryService;
     _iSiteSettingService  = iSiteSettingService;
     _iProductService      = iProductService;
     this._siteSetting     = _iSiteSettingService.GetSiteSettings();
     _iSlideAdsService     = iSlideAdsService;
     _iMemberService       = iMemberService;
     _iTypeService         = iTypeService;
 }
Esempio n. 23
0
        public ActionResult ApplyWithDraw()
        {
            var siteSetting = _iSiteSettingService.GetSiteSettings();

            if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))
            {
                throw new HimallException("未配置公众号参数");
            }

            var token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);

            SceneModel scene = new SceneModel(QR_SCENE_Type.WithDraw)
            {
                Object = CurrentUser.Id.ToString()
            };
            SceneHelper helper  = new SceneHelper();
            var         sceneid = helper.SetModel(scene);
            var         ticket  = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 300, sceneid);

            ViewBag.ticket  = ticket.ticket;
            ViewBag.Sceneid = sceneid;
            var capitalService = _iMemberCapitalService;
            var model          = capitalService.GetCapitalInfo(CurrentUser.Id);

            if (model != null)
            {
                ViewBag.ApplyWithMoney = model.Balance.Value;
            }
            else
            {
                ViewBag.ApplyWithMoney = 0;
            }
            var member = _iMemberService.GetMember(CurrentUser.Id);//CurrentUser对象有缓存,取不到最新数据

            ViewBag.IsSetPwd        = string.IsNullOrWhiteSpace(member.PayPwd) ? false : true;
            ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum;
            ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum;
            return(View());
        }
        public JsonResult getWinxin(string pluginId, string destination)
        {
            long uid         = ShopApplication.GetShopManagers(CurrentSellerManager.ShopId);
            var  siteSetting = _iSiteSettingService.GetSiteSettings();

            //微信二维码
            if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))
            {
                throw new HimallException("未配置公众号参数");
            }
            var token = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);

            SceneModel scene = new SceneModel(QR_SCENE_Type.Binding)
            {
                Object = uid.ToString()
            };
            SceneHelper helper  = new SceneHelper();
            var         sceneid = helper.SetModel(scene);
            var         ticket  = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 300, sceneid);

            return(Json(new { success = true, msg = "成功", ticket = ticket.ticket, Sceneid = sceneid }));
        }
        public JsonResult UserPerformanceList(int page, int rows, long userid, int?days, long?orderId)
        {
            UserProformanceQuery query = new UserProformanceQuery();

            query.UserId   = userid;
            query.OrderId  = orderId;
            query.PageNo   = page;
            query.PageSize = rows;
            if (days.HasValue)
            {
                if (days == 3)
                {
                    query.startTime = DateTime.Now.AddDays(-3);
                }
                else if (days == 7)
                {
                    query.startTime = DateTime.Now.AddDays(-7);
                }
                else if (days == 30)
                {
                    query.startTime = DateTime.Now.AddDays(-30);
                }
            }
            var m       = _iDistributionService.GetPerformanceDetail(query);
            var model   = m.Models.ToList();
            var expried = _iSiteSettingService.GetSiteSettings().SalesReturnTimeout;

            foreach (var t in model)
            {
                if (t.OrderStatus == Model.OrderInfo.OrderOperateStatus.Finish && t.FinshedTime.Value.AddDays(expried) < DateTime.Now)
                {
                    t.Expired = true;
                }
            }
            var dataGrid = new { rows = model, total = m.Total };

            return(Json(dataGrid));
        }
Esempio n. 26
0
        public ActionResult Index(long id = 0)
        {
            Log.Info("进入微信API");

            //string token = "weixin_test";
            string token = "", signature = "", nonce = "", timestamp = "", echostr = "";
            if (id == 0)
            {
                var siteSetting = _iSiteSettingService.GetSiteSettings();
                token = siteSetting.WeixinToken;
            }
            else
            {
                var _tmp = _iVShopService.GetVShopSetting(id);
                if (_tmp == null)
                {
                    throw new HimallException("错误的商铺编号");
                }
                token = _tmp.Token;
            }
            signature = Request["signature"];
            nonce = Request["nonce"];
            timestamp = Request["timestamp"];
            echostr = Request["echostr"];
            ActionResult actionResult = Content("");

            Log.Info(string.Format("传入信息:signature = {0} , nonce = {1} , timestamp = {2} , echostr = {3} , id = {4}", signature, nonce, timestamp, echostr, id));
            if (Request.HttpMethod == "GET")
            {
                if (CheckSignature.Check(signature, timestamp, nonce, token))
                {
                    actionResult = Content(echostr);
                }
            }
            else
            {
                //TODO:[lly] 微信消息处理
                if (!CheckSignature.Check(signature, timestamp, nonce, token))
                {
                    Log.Info("验证不通过");
                }

                XDocument requestDoc = XDocument.Load(Request.InputStream);

#if DEBUG
                //调试时记录数据日志
                Core.Log.Debug(requestDoc);
#endif

                var requestBaseMsg = RequestMessageFactory.GetRequestEntity(requestDoc);
                SceneHelper helper = new SceneHelper();

                //卡券服务
                var cardser = _iWXCardService;

                switch (requestBaseMsg.MsgType)
                {
                    #region Event处理
                    case RequestMsgType.Event:
                        var requestMsg = requestBaseMsg as Senparc.Weixin.MP.Entities.RequestMessageEventBase;
                        Log.Info("进入RequestMsgType - Event:" + requestMsg.Event.ToString());
                        switch (requestMsg.Event)
                        {
                            //取消公众号订阅事件
                            case Event.unsubscribe:
                                UnSubscribe(requestMsg.FromUserName);
                                break;

                            //订阅公众号事件
                            case Event.subscribe:

                                //关注红包
                                actionResult = SendAttentionToUser(requestBaseMsg);


                                #region 关注公众号,欢迎语!
                                int nowtime = ConvertDateTimeInt(DateTime.Now);

                                string msg = "";//关注时,需要发送的内容
                                var data = WeixinAutoReplyApplication.GetAutoReplyByKey(CommonModel.ReplyType.Follow, "", false, true, true);
                                if (data != null)
                                {
                                    msg = data.TextReply;
                                }
                                else
                                    Log.Info("请设置关注后自动回复消息内容!");

                                string resxml = "<xml><ToUserName><![CDATA[" + requestBaseMsg.FromUserName + "]]></ToUserName><FromUserName><![CDATA[" + requestBaseMsg.ToUserName + "]]></FromUserName><CreateTime>" + nowtime + "</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + msg + "]]></Content><FuncFlag>0</FuncFlag></xml>";
                                Response.Write(resxml);
                                #endregion

                                var requestSubscribe = requestMsg as Senparc.Weixin.MP.Entities.RequestMessageEvent_Subscribe;
#if DEBUG
                                Log.Debug(requestSubscribe, new Exception("进入订阅事件"));
#endif
                                bool isActivityBonus = false;
                                SceneModel sceneModel = null;
#if DEBUG
                                Log.Info("进入订阅事件requestSubscribe.EventKey =" + requestSubscribe.EventKey);
#endif
                                #region 场景二维码

                                if (requestSubscribe.EventKey != string.Empty)
                                {
                                    var scene = requestSubscribe.EventKey.Replace("qrscene_", string.Empty);
                                    sceneModel = helper.GetModel(scene);
                                    if (sceneModel != null)
                                    {
#if DEBUG
                                        Log.Info("sceneModel.Type = " + sceneModel.SceneType.ToString());
#endif
                                        if (sceneModel.SceneType == Himall.Model.QR_SCENE_Type.WithDraw)
                                        {//提现场景(未关注时)
                                            echostr = ProcessWithDrawScene(requestSubscribe, scene, sceneModel);
                                            actionResult = Content(echostr);
                                        }
                                        else if (sceneModel.SceneType == Himall.Model.QR_SCENE_Type.Bonus)
                                        {
                                            //TODO:ZJT 用户通过场景二维码扫描关注后 推送消息给用户
                                            //isActivityBonus用于判断激发关注事件的是活动红包还是其他
                                            isActivityBonus = true;
                                            actionResult = SendActivityToUser(sceneModel.Object, requestBaseMsg);
                                        }
                                        else if (sceneModel.SceneType == Himall.Model.QR_SCENE_Type.FlashSaleRemind)
                                        {
#if DEBUG
                                            Log.Info("进入限时购场景二维码事件");
#endif
                                            long flashSaleId = (long)sceneModel.Object;
                                            SendFlashSaleRemindMessage(flashSaleId, requestBaseMsg.FromUserName);
                                        }
                                        else if (sceneModel.SceneType == Himall.Model.QR_SCENE_Type.Binding)//绑定微信
                                        {
                                            echostr = Binding(requestSubscribe, scene, sceneModel);
                                            actionResult = Content(echostr);
                                        }
                                    }
                                }
                                #endregion
                                Log.Info("开始isActivityBonus=" + isActivityBonus);

                                //通过场景二维码进来,并且二维码不是活动红包,则进行关注送红包事件
                                //if (!isActivityBonus && sceneModel != null && sceneModel.SceneType == QR_SCENE_Type.Bonus)
                                //{
                                // actionResult = SendAttentionToUser(requestBaseMsg);
                                //}

#if DEBUG
                                Log.Info("开始Subscribe requestBaseMsg.FromUserName="******"进入限时购场景二维码事件");
                                            long flashSaleId = (long)sceneModel.Object;
                                            SendFlashSaleRemindMessage(flashSaleId, requestBaseMsg.FromUserName);
                                        }
                                        else if (sceneModel.SceneType == Himall.Model.QR_SCENE_Type.Binding)//绑定微信
                                        {
                                            echostr = Binding(requestScan, requestScan.EventKey, sceneModel);
                                            actionResult = Content(echostr);
                                        }
                                    }
                                }
                                break;
                            case Event.card_pass_check:
                                //TODO:DZY[150907] 卡券审核通过
                                var reqpasscard = requestMsg as Senparc.Weixin.MP.Entities.RequestMessageEvent_Card_Pass_Check;
                                if (!string.IsNullOrWhiteSpace(reqpasscard.CardId))
                                {
                                    cardser.Event_Audit(reqpasscard.CardId, WXCardLogInfo.AuditStatusEnum.Audited);
                                }
                                break;
                            case Event.card_not_pass_check:
                                //TODO:DZY[150907] 卡券审核失败
                                var reqnopasscard = requestMsg as Senparc.Weixin.MP.Entities.RequestMessageEvent_Card_Pass_Check;
                                if (!string.IsNullOrWhiteSpace(reqnopasscard.CardId))
                                {
                                    cardser.Event_Audit(reqnopasscard.CardId, WXCardLogInfo.AuditStatusEnum.AuditNot);
                                }
                                break;
                            case Event.user_del_card:
                                //TODO:DZY[150907] 删除卡包内优惠券
                                var requdelcard = requestMsg as Senparc.Weixin.MP.Entities.RequestMessageEvent_User_Del_Card;
                                if (!string.IsNullOrWhiteSpace(requdelcard.CardId) && !string.IsNullOrWhiteSpace(requdelcard.UserCardCode))
                                {
                                    cardser.Event_Unavailable(requdelcard.CardId, requdelcard.UserCardCode);
                                }
                                break;
                            case Event.user_get_card:
                                //TODO:DZY[150907] 用户获取优惠券
                                var requgetcard = requestMsg as Senparc.Weixin.MP.Entities.RequestMessageEvent_User_Get_Card;
                                Log.Debug("WXCard:" + requgetcard.CardId + "_" + requgetcard.UserCardCode);
                                if (!string.IsNullOrWhiteSpace(requgetcard.CardId) && !string.IsNullOrWhiteSpace(requgetcard.UserCardCode))
                                {
                                    cardser.Event_Send(requgetcard.CardId, requgetcard.UserCardCode, requgetcard.FromUserName, requgetcard.OuterId);
                                }
                                break;
                        }
                        break;
                    #endregion
                    case RequestMsgType.Text:
                        textCase(requestBaseMsg);
                        break;
                }
                Response.End();
            }
            return actionResult;
        }
        public ActionResult Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            string price = "";

            #region 定义Model和变量

            LimitTimeProductDetailModel model = new LimitTimeProductDetailModel
            {
                MainId = long.Parse(id),
                HotAttentionProducts = new List <HotProductInfo>(),
                HotSaleProducts      = new List <HotProductInfo>(),
                Product      = new Model.ProductInfo(),
                Shop         = new ShopInfoModel(),
                ShopCategory = new List <CategoryJsonModel>(),
                Color        = new CollectionSKU(),
                Size         = new CollectionSKU(),
                Version      = new CollectionSKU()
            };

            FlashSaleModel market = null;
            ShopInfo       shop   = null;

            long gid = 0, mid = 0;

            #endregion


            #region 商品Id不合法
            if (long.TryParse(id, out mid))
            {
            }
            if (mid == 0)
            {
                //跳转到出错页面
                return(RedirectToAction("Error404", "Error", new { area = "Web" }));
            }
            #endregion


            #region 初始化商品和店铺

            market = _iLimitTimeBuyService.Get(mid);

            switch (market.Status)
            {
            case FlashSaleInfo.FlashSaleStatus.Ended:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                break;

            case FlashSaleInfo.FlashSaleStatus.Cancelled:
                return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));

                break;
            }
            if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                return(RedirectToAction("Home"));
            }
            model.FlashSale = market;
            if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
            {
                //可能参数是商品ID
                market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market;

                if (market == null)
                {
                    //跳转到404页面
                    return(RedirectToAction("Error404", "Error", new { area = "Mobile" }));
                }
                if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)
                {
                    return(RedirectToAction("Detail", "Product", new { id = market.ProductId }));
                }
            }

            model.MaxSaleCount = market.LimitCountOfThePeople;
            model.Title        = market.Title;

            shop            = _iShopService.GetShop(market.ShopId);
            model.Shop.Name = shop.ShopName;
            #endregion

            #region 商品描述
            var product = _iProductService.GetProduct(market.ProductId);
            gid = market.ProductId;
            //product.MarketPrice = market.MinPrice;
            //product.SaleCounts = market.SaleCount;

            var brandModel = ServiceHelper.Create <IBrandService>().GetBrand(product.BrandId);
            product.BrandName = brandModel == null ? "" : brandModel.Name;

            model.Product            = product;
            model.ProductDescription = product.ProductDescriptionInfo.Description;
            if (product.ProductDescriptionInfo.DescriptionPrefixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId);
                model.DescriptionPrefix = desc == null ? "" : desc.Content;
            }

            if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0)
            {
                var desc = _iProductDescriptionTemplateService
                           .GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId);
                model.DescriptiondSuffix = desc == null ? "" : desc.Content;
            }

            #endregion

            #region 店铺

            var categories = _iShopCategoryService.GetShopCategory(product.ShopId);
            List <ShopCategoryInfo> allcate = categories.ToList();
            foreach (var main in allcate.Where(s => s.ParentCategoryId == 0))
            {
                var topC = new CategoryJsonModel()
                {
                    Name        = main.Name,
                    Id          = main.Id.ToString(),
                    SubCategory = new List <SecondLevelCategory>()
                };
                foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id))
                {
                    var secondC = new SecondLevelCategory()
                    {
                        Name = secondItem.Name,
                        Id   = secondItem.Id.ToString(),
                    };

                    topC.SubCategory.Add(secondC);
                }
                model.ShopCategory.Add(topC);
            }
            model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id);

            #endregion

            #region 热门销售

            var sale = _iProductService.GetHotSaleProduct(shop.Id, 5);
            if (sale != null)
            {
                foreach (var item in sale.ToArray())
                {
                    model.HotSaleProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.SaleCounts
                    });
                }
            }

            #endregion

            #region 热门关注

            var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5);
            if (hot != null)
            {
                foreach (var item in hot.ToArray())
                {
                    model.HotAttentionProducts.Add(new HotProductInfo
                    {
                        ImgPath   = item.ImagePath,
                        Name      = item.ProductName,
                        Price     = item.MinSalePrice,
                        Id        = item.Id,
                        SaleCount = (int)item.ConcernedCount
                    });
                }
            }
            #endregion

            #region 商品规格

            ProductTypeInfo typeInfo     = _iTypeService.GetType(product.TypeId);
            string          colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string          sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string          versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;
            if (product.SKUInfo != null && product.SKUInfo.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                foreach (var sku in product.SKUInfo)
                {
                    var specs = sku.Id.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name         = "选择" + sizeAlias,
                                    EnabledClass = ss != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择版本",
                                    Name         = "选择" + versionAlias,
                                    EnabledClass = v != 0 ? "enabled" : "disabled",
                                    //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
                decimal min = 0, max = 0;
                if (product.SKUInfo.FirstOrDefault(s => s.Stock >= 0) != null)
                {
                    min = product.SKUInfo.Where(s => s.Stock >= 0).Min(s => s.SalePrice);
                }
                if (product.SKUInfo.FirstOrDefault(s => s.Stock >= 0) != null)
                {
                    max = product.SKUInfo.Where(s => s.Stock >= 0).Max(s => s.SalePrice);
                }
                if (min == 0 && max == 0)
                {
                    price = product.MinSalePrice.ToString("f2");
                }
                else if (max > min)
                {
                    price = string.Format("{0}-{1}", min.ToString("f2"), max.ToString("f2"));
                }
                else
                {
                    price = string.Format("{0}", min.ToString("f2"));
                }
            }
            model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price;
            #endregion

            #region 商品属性
            List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>();
            var prodAttrs = _iProductService.GetProductAttribute(product.Id).ToList();
            foreach (var attr in prodAttrs)
            {
                if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId))
                {
                    TypeAttributesModel attrModel = new TypeAttributesModel()
                    {
                        AttrId     = attr.AttributeId,
                        AttrValues = new List <TypeAttrValue>(),
                        Name       = attr.AttributesInfo.Name
                    };
                    foreach (var attrV in attr.AttributesInfo.AttributeValueInfo)
                    {
                        if (prodAttrs.Any(p => p.ValueId == attrV.Id))
                        {
                            attrModel.AttrValues.Add(new TypeAttrValue
                            {
                                Id   = attrV.Id.ToString(),
                                Name = attrV.Value
                            });
                        }
                    }
                    ProductAttrs.Add(attrModel);
                }
                else
                {
                    var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId);

                    if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString()))
                    {
                        attrTemp.AttrValues.Add(new TypeAttrValue
                        {
                            Id   = attr.ValueId.ToString(),
                            Name = attr.AttributesInfo.AttributeValueInfo.FirstOrDefault(a => a.Id == attr.ValueId).Value
                        });
                    }
                }
            }
            model.ProductAttrs = ProductAttrs;
            #endregion

            #region 获取评论、咨询数量
            //var comments = _iCommentService.GetComments( new CommentQuery
            //{
            //    ProductID = product.Id ,
            //    PageNo = 1 ,
            //    PageSize = 10000
            //} );
            //model.CommentCount = comments.Total;

            var com      = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);
            var comCount = com.Count();
            model.CommentCount = comCount;

            var consultations = _iConsultationService.GetConsultations(gid);
            model.Consultations = consultations.Count();

            #endregion

            #region 累加浏览次数、 加入历史记录
            if (CurrentUser != null)
            {
                BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id);
            }
            else
            {
                BrowseHistrory.AddBrowsingProduct(product.Id);
            }

            //_iProductService.LogProductVisti(gid);
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);
            #endregion

            #region 红包
            var bonus = ServiceHelper.Create <IShopBonusService>().GetByShopId(product.ShopId);
            if (bonus != null)
            {
                model.GrantPrice = bonus.GrantPrice;
            }
            else
            {
                model.GrantPrice = 0;
            }
            #endregion

            #region 获取店铺的评价统计

            var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == StatisticOrderCommentsInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 客服
            model.Service = ServiceHelper.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool);
            #endregion

            #region 开团提醒场景二维码
            var siteSetting = _iSiteSettingService.GetSiteSettings();
            if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret))
            {
                var                     token   = AccessTokenContainer.TryGetToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);
                SceneHelper             helper  = new SceneHelper();
                Himall.Model.SceneModel scene   = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id);
                int                     sceneId = helper.SetModel(scene);
                var                     ticket  = Senparc.Weixin.MP.AdvancedAPIs.QrCode.QrCodeApi.Create(token, 86400, sceneId).ticket;
                ViewBag.ticket = ticket;
            }
            #endregion

            model.Logined    = (null != CurrentUser) ? 1 : 0;
            model.EnabledBuy = product.AuditStatus == ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale;
            if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.EndDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }
            else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now)
            {
                TimeSpan end   = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks);
                TimeSpan start = new TimeSpan(DateTime.Now.Ticks);
                TimeSpan ts    = end.Subtract(start);
                model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds;
            }

            //补充当前店铺红包功能
            ViewBag.isShopPage     = true;
            ViewBag.CurShopId      = product.ShopId;
            TempData["isShopPage"] = true;
            TempData["CurShopId"]  = product.ShopId;

            return(View(model));
        }
Esempio n. 28
0
        public JsonResult GetProductAuditOnOff()
        {
            var sitesetting = _iSiteSettingService.GetSiteSettings().ProdutAuditOnOff;

            return(Json(new { value = sitesetting }));
        }
Esempio n. 29
0
        public ActionResult Index(string orderDate, string keywords, string orderids, DateTime?startDateTime, DateTime?endDateTime, int?orderStatus, int pageNo = 1, int pageSize = 10)
        {
            ViewBag.Grant = null;

            if (!string.IsNullOrEmpty(orderids) && orderids.IndexOf(',') <= 0)
            {
                ViewBag.Grant = _iShopBonusService.GetByOrderId(long.Parse(orderids));
            }

            DateTime?startDate = startDateTime;
            DateTime?endDate   = endDateTime;

            if (!string.IsNullOrEmpty(orderDate) && orderDate.ToLower() != "all")
            {
                switch (orderDate.ToLower())
                {
                case "threemonth":
                    startDate = DateTime.Now.AddMonths(-3);
                    break;

                case "halfyear":
                    startDate = DateTime.Now.AddMonths(-6);
                    break;

                case "year":
                    startDate = DateTime.Now.AddYears(-1);
                    break;

                case "yearago":
                    endDate = DateTime.Now.AddYears(-1);
                    break;
                }
            }

            if (orderStatus.HasValue && orderStatus == 0)
            {
                orderStatus = null;
            }

            var queryModel = new OrderQuery()
            {
                StartDate      = startDate,
                EndDate        = endDate,
                Status         = (Model.OrderInfo.OrderOperateStatus?)orderStatus,
                UserId         = CurrentUser.Id,
                SearchKeyWords = keywords,
                PageSize       = pageSize,
                PageNo         = pageNo
            };

            var orders        = OrderApplication.GetOrders(queryModel);
            var orderComments = OrderApplication.GetOrderCommentCount(orders.Models.Select(p => p.Id));
            var orderItems    = OrderApplication.GetOrderItemsByOrderId(orders.Models.Select(p => p.Id));
            var orderRefunds  = OrderApplication.GetOrderRefunds(orderItems.Select(p => p.Id));

            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = orders.Total
            };

            ViewBag.pageInfo = info;
            ViewBag.UserId   = CurrentUser.Id;
            var siteSetting = _iSiteSettingService.GetSiteSettings();
            var shopBonus   = _iShopBonusService;

            ViewBag.SalesRefundTimeout = siteSetting.SalesReturnTimeout;

            var cashDepositsService = _iCashDepositsService;
            //IEnumerable<OrderListModel> orderList = new IEnumerable<OrderListModel>();
            IEnumerable <OrderListModel> orderList = orders.Models.Select(item => new OrderListModel
            {
                Id                 = item.Id,
                ActiveType         = item.ActiveType,
                OrderType          = item.OrderType,
                Address            = item.Address,
                CellPhone          = item.CellPhone,
                CloseReason        = item.CloseReason,
                CommisTotalAmount  = item.CommisAmount,
                DiscountAmount     = item.DiscountAmount,
                ExpressCompanyName = item.ExpressCompanyName,
                FinishDate         = item.FinishDate,
                Freight            = item.Freight,
                GatewayOrderId     = item.GatewayOrderId,
                IntegralDiscount   = item.IntegralDiscount,
                UserId             = item.UserId,
                ShopId             = item.ShopId,
                ShopName           = item.ShopName,
                ShipTo             = item.ShipTo,
                OrderTotalAmount   = item.OrderTotalAmount,
                PaymentTypeName    = item.PaymentTypeName,
                //满额减
                FullDiscount  = item.FullDiscount,
                OrderStatus   = item.OrderStatus,
                RefundStats   = item.RefundStats,
                CommentCount  = orderComments.ContainsKey(item.Id)?orderComments[item.Id]:0,
                OrderDate     = item.OrderDate,
                PaymentType   = item.PaymentType,
                PickupCode    = item.PickupCode,
                OrderItemList = orderItems.Where(oi => oi.OrderId == item.Id).Select(oItem =>
                {
                    var itemrefund = orderRefunds.Where(or => or.OrderItemId == oItem.Id).FirstOrDefault();
                    var orderItem  = new OrderItemListModel
                    {
                        Id                     = oItem.Id,
                        ProductId              = oItem.ProductId,
                        Color                  = oItem.Color,
                        Size                   = oItem.Size,
                        Version                = oItem.Version,
                        ProductName            = oItem.ProductName,
                        ThumbnailsUrl          = oItem.ThumbnailsUrl,
                        SalePrice              = oItem.SalePrice,
                        SkuId                  = oItem.SkuId,
                        Quantity               = oItem.Quantity,
                        CashDepositsObligation = cashDepositsService.GetCashDepositsObligation(oItem.ProductId),
                    };

                    if (itemrefund != null)
                    {
                        orderItem.RefundStats  = itemrefund.RefundStatusValue;
                        orderItem.ItemRefundId = itemrefund.Id;

                        string showRefundStats = "";
                        if (itemrefund.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited)
                        {
                            showRefundStats = itemrefund.ManagerConfirmStatus.ToDescription();
                        }
                        else if (item.DeliveryType == CommonModel.Enum.DeliveryType.SelfTake || (item.ShopBranchId.HasValue && item.ShopBranchId.Value > 0))//如果是自提预约单或分配门店预约单则转为门店审核状态
                        {
                            showRefundStats = ((CommonModel.Enum.OrderRefundShopAuditStatus)itemrefund.SellerAuditStatus).ToDescription();
                        }
                        else
                        {
                            showRefundStats = itemrefund.SellerAuditStatus.ToDescription();
                        }

                        orderItem.ShowRefundStats = showRefundStats;
                    }
                    orderItem.EnabledRefundAmount = oItem.EnabledRefundAmount;
                    ProductTypeInfo typeInfo      = _iTypeService.GetTypeByProductId(oItem.ProductId);
                    orderItem.ColorAlias          = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    orderItem.SizeAlias           = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    orderItem.VersionAlias        = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;

                    return(orderItem);
                }).ToList(),
                ReceiveBonus = shopBonus.GetGrantByUserOrder(item.Id, CurrentUser.Id),
            }).ToList();

            foreach (var o in orderList)
            {
                o.HasAppendComment = HasAppendComment(o);
            }

            #region 数据补偿
            List <long> ordidl = orderList.Select(d => d.Id).ToList();
            if (ordidl.Count > 0)
            {
                foreach (var item in orderList)
                {
                    var _ord = orders.Models.FirstOrDefault(o => o.Id == item.Id);

                    item.IsRefundTimeOut     = OrderApplication.IsRefundTimeOut(_ord);
                    item.EnabledRefundAmount = _ord.OrderEnabledRefundAmount;
                    //退款状态补偿
                    var _tmpobj = orderRefunds.FirstOrDefault(d => d.OrderId == item.Id && d.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund);
                    if (_tmpobj != null)
                    {
                        item.RefundStats   = (int)_tmpobj.SellerAuditStatus;
                        item.OrderRefundId = _tmpobj.Id;
                    }

                    item.OrderCanRefund = false;

                    if (item.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.Finish)
                    {
                        if (item.FinishDate.Value.AddDays(siteSetting.SalesReturnTimeout) > DateTime.Now)
                        {
                            item.OrderCanRefund = true;
                        }
                    }
                    if (item.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.WaitReceiving)
                    {
                        item.OrderCanRefund = true;
                    }
                    if (item.PaymentType == Himall.Model.OrderInfo.PaymentTypes.CashOnDelivery)
                    {
                        if (item.OrderStatus == Himall.Model.OrderInfo.OrderOperateStatus.Finish)
                        {
                            item.OrderCanRefund = true;
                        }
                    }
                    else
                    {
                        item.OrderCanRefund = true;
                    }

                    item.FightGroupCanRefund = true;   //非拼团预约单默认可退

                    //拼团状态补偿
                    if (item.OrderType == OrderInfo.OrderTypes.FightGroup)
                    {
                        var fgord = _iFightGroupService.GetFightGroupOrderStatusByOrderId(item.Id);
                        if (fgord != null)
                        {
                            item.FightGroupJoinStatus = fgord.GetJoinStatus;
                            item.FightGroupCanRefund  = fgord.CanRefund;
                        }
                        else
                        {
                            item.FightGroupJoinStatus = CommonModel.FightGroupOrderJoinStatus.JoinFailed;
                            item.FightGroupCanRefund  = false;
                        }
                        item.OrderCanRefund = item.OrderCanRefund && item.FightGroupCanRefund;
                    }
                }
            }
            #endregion

            return(View(orderList.ToList()));
        }
 /// <summary>
 /// 获取系统配置信息
 /// </summary>
 /// <returns></returns>
 public static SiteSettingsInfo GetSiteSettings()
 {
     return(_iSiteSettingService.GetSiteSettings());
 }