public ShopBonusController()
 {
     _siteSetting = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
     if (string.IsNullOrWhiteSpace(_siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(_siteSetting.WeixinAppSecret))
     {
         throw new HimallException("未配置公众号参数");
     }
     _bonusService = ServiceHelper.Create <IShopBonusService>();
     ser_wxcard    = ServiceHelper.Create <IWXCardService>();
 }
Example #2
0
 public WXApiController(
     IWXCardService iWXCardService,
     IBonusService iBonusService,
     IVShopService iVShopService,
     IWXApiService iWXApiService,
     ILimitTimeBuyService iLimitTimeBuyService,
     IWXMsgTemplateService iWXMsgTemplateService
     )
 {
     _iWXCardService        = iWXCardService;
     _iBonusService         = iBonusService;
     _iVShopService         = iVShopService;
     _iWXApiService         = iWXApiService;
     _iLimitTimeBuyService  = iLimitTimeBuyService;
     _iWXMsgTemplateService = iWXMsgTemplateService;
 }
Example #3
0
 public ShopBonusController(IShopBonusService iShopBonusService,
                            IWXCardService iWXCardService,
                            IVShopService iVShopService,
                            IShopService iShopService
                            )
 {
     this._siteSetting = CurrentSiteSetting;
     if (string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(this._siteSetting.WeixinAppSecret))
     {
         throw new HimallException("未配置公众号参数");
     }
     this._bonusService   = iShopBonusService;
     this._iWXCardService = iWXCardService;
     _iVShopService       = iVShopService;
     _iShopService        = iShopService;
 }
        public WXApiController(
            ISiteSettingService iSiteSettingService,
            IWXCardService iWXCardService,
            IBonusService iBonusService,
            IVShopService iVShopService,
            IWXApiService iWXApiService,
            ILimitTimeBuyService iLimitTimeBuyService
            )
        {
            _iSiteSettingService = iSiteSettingService;
            _iWXCardService = iWXCardService;
            _iBonusService = iBonusService;
            _iVShopService = iVShopService;
            _iWXApiService = iWXApiService;
            _iLimitTimeBuyService = iLimitTimeBuyService;

        }
Example #5
0
        public ShopBonusController(IShopBonusService iShopBonusService,
                                   IWXCardService iWXCardService,
                                   IVShopService iVShopService,
                                   IShopService iShopService
                                   )
        {
            var settings = SiteSettingApplication.SiteSettings;

            if (string.IsNullOrWhiteSpace(settings.WeixinAppId) || string.IsNullOrWhiteSpace(settings.WeixinAppSecret))
            {
                throw new MallException("未配置公众号参数");
            }
            this._bonusService   = iShopBonusService;
            this._iWXCardService = iWXCardService;
            _iVShopService       = iVShopService;
            _iShopService        = iShopService;
        }
Example #6
0
 public CouponService()
 {
     ser_wxcard = Instance <IWXCardService> .Create;
 }
Example #7
0
 public VShopController()
 {
     _siteSetting = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
     ser_wxcard   = ServiceHelper.Create <IWXCardService>();
 }
        public ActionResult Index()
        {
            Log.Info("进入微信API");
            SiteSettingsInfo siteSettings = ServiceHelper.Create <ISiteSettingService>().GetSiteSettings();
            string           weixinToken  = "";
            string           item         = "";
            string           str          = "";
            string           item1        = "";
            string           str1         = "";

            weixinToken = siteSettings.WeixinToken;
            item        = base.Request["signature"];
            str         = base.Request["nonce"];
            item1       = base.Request["timestamp"];
            str1        = base.Request["echostr"];
            ActionResult user = base.Content("");

            if (base.Request.HttpMethod != "GET")
            {
                if (!Senparc.Weixin.MP.CheckSignature.Check(item, item1, str, weixinToken))
                {
                    Log.Info("验证不通过");
                }
                XDocument xDocument = XDocument.Load(base.Request.InputStream);
                Senparc.Weixin.MP.Entities.IRequestMessageBase requestEntity = Senparc.Weixin.MP.RequestMessageFactory.GetRequestEntity(xDocument, null);
                SceneHelper    sceneHelper   = new SceneHelper();
                IWXCardService wXCardService = ServiceHelper.Create <IWXCardService>();
                if (requestEntity.MsgType == RequestMsgType.Event)
                {
                    RequestMessageEventBase requestMessageEventBase = requestEntity as RequestMessageEventBase;
                    Event @event = requestMessageEventBase.Event;
                    switch (@event)
                    {
                    case Event.subscribe:
                    {
                        RequestMessageEvent_Subscribe requestMessageEventSubscribe = requestMessageEventBase as RequestMessageEvent_Subscribe;
                        bool flag = false;
                        if (requestMessageEventSubscribe.EventKey != string.Empty)
                        {
                            string     str2  = requestMessageEventSubscribe.EventKey.Replace("qrscene_", string.Empty);
                            SceneModel model = sceneHelper.GetModel(str2);
                            if (model != null)
                            {
                                if (model.SceneType == QR_SCENE_Type.WithDraw)
                                {
                                    flag = true;
                                    str1 = ProcessWithDrawScene(requestMessageEventSubscribe, str2, model);
                                    user = base.Content(str1);
                                }
                                else if (model.SceneType == QR_SCENE_Type.Bonus)
                                {
                                    flag = true;
                                    user = SendActivityToUser(sceneHelper.GetModel(str2).Object, requestEntity);
                                }
                            }
                        }
                        if (!flag)
                        {
                            user = SendAttentionToUser(requestEntity);
                        }
                        Subscribe(requestEntity.FromUserName);
                        break;
                    }

                    case Event.unsubscribe:
                    {
                        UnSubscribe(requestMessageEventBase.FromUserName);
                        break;
                    }

                    case Event.CLICK:
                    {
                        break;
                    }

                    case Event.scan:
                    {
                        RequestMessageEvent_Scan requestMessageEventScan = requestMessageEventBase as RequestMessageEvent_Scan;
                        if (string.IsNullOrWhiteSpace(requestMessageEventScan.EventKey))
                        {
                            break;
                        }
                        SceneModel sceneModel = sceneHelper.GetModel(requestMessageEventScan.EventKey);
                        if (sceneModel == null || sceneModel.SceneType != QR_SCENE_Type.WithDraw)
                        {
                            break;
                        }
                        str1 = ProcessWithDrawScene(requestMessageEventScan, requestMessageEventScan.EventKey, sceneModel);
                        user = base.Content(str1);
                        break;
                    }

                    default:
                    {
                        switch (@event)
                        {
                        case Event.card_pass_check:
                        {
                            RequestMessageEvent_Card_Pass_Check requestMessageEventCardPassCheck = requestMessageEventBase as RequestMessageEvent_Card_Pass_Check;
                            if (string.IsNullOrWhiteSpace(requestMessageEventCardPassCheck.CardId))
                            {
                                return(user);
                            }
                            wXCardService.Event_Audit(requestMessageEventCardPassCheck.CardId, WXCardLogInfo.AuditStatusEnum.Audited);
                            break;
                        }

                        case Event.card_not_pass_check:
                        {
                            RequestMessageEvent_Card_Pass_Check requestMessageEventCardPassCheck1 = requestMessageEventBase as RequestMessageEvent_Card_Pass_Check;
                            if (string.IsNullOrWhiteSpace(requestMessageEventCardPassCheck1.CardId))
                            {
                                return(user);
                            }
                            wXCardService.Event_Audit(requestMessageEventCardPassCheck1.CardId, WXCardLogInfo.AuditStatusEnum.AuditNot);
                            break;
                        }

                        case Event.user_get_card:
                        {
                            RequestMessageEvent_User_Get_Card requestMessageEventUserGetCard = requestMessageEventBase as RequestMessageEvent_User_Get_Card;
                            if (string.IsNullOrWhiteSpace(requestMessageEventUserGetCard.CardId) || string.IsNullOrWhiteSpace(requestMessageEventUserGetCard.UserCardCode))
                            {
                                return(user);
                            }
                            wXCardService.Event_Send(requestMessageEventUserGetCard.CardId, requestMessageEventUserGetCard.UserCardCode, requestMessageEventUserGetCard.FromUserName, requestMessageEventUserGetCard.OuterId);
                            break;
                        }

                        case Event.user_del_card:
                        {
                            RequestMessageEvent_User_Del_Card requestMessageEventUserDelCard = requestMessageEventBase as RequestMessageEvent_User_Del_Card;
                            if (string.IsNullOrWhiteSpace(requestMessageEventUserDelCard.CardId) || string.IsNullOrWhiteSpace(requestMessageEventUserDelCard.UserCardCode))
                            {
                                return(user);
                            }
                            wXCardService.Event_Unavailable(requestMessageEventUserDelCard.CardId, requestMessageEventUserDelCard.UserCardCode);
                            break;
                        }
                        }
                        break;
                    }
                    }
                }
            }
            else if (Senparc.Weixin.MP.CheckSignature.Check(item, item1, str, weixinToken))
            {
                user = base.Content(str1);
            }
            return(user);
        }
Example #9
0
 public ShopBonusService()
 {
     ser_wxcard = Instance <IWXCardService> .Create;
 }
Example #10
0
 public CouponService()
 {
     ser_wxcard = Himall.ServiceProvider.Instance <IWXCardService> .Create;
 }
 public ShopBonusService()
 {
     ser_wxcard = Himall.ServiceProvider.Instance <IWXCardService> .Create;
 }