コード例 #1
0
        /// <summary>
        /// 生成同步微信按扭JS信息
        /// </summary>
        /// <param name="cardid"></param>
        /// <param name="openid"></param>
        /// <param name="couponRecordId"></param>
        /// <param name="couponType"></param>
        /// <param name="url">当前页地址</param>
        /// <returns></returns>
        private WXSyncJSInfoCardInfo MakeSyncWXJSInfo(string cardid, long couponRecordId, WXCardLogInfo.CouponTypeEnum couponType)
        {
            WXSyncJSInfoCardInfo result = null;

            if (!string.IsNullOrWhiteSpace(cardid))
            {
                var card = Context.WXCardLogInfo.FirstOrDefault(d => d.CardId == cardid);
                if (card != null)
                {
                    string acctoken  = GetAccessToken(card.AppId, card.AppSecret);
                    string apiticket = GetCardJSApiTicket(acctoken);
                    if (!string.IsNullOrWhiteSpace(apiticket))
                    {
                        result = new WXSyncJSInfoCardInfo();
                        //生成记录
                        long        logid     = SyncCouponRecordInfo(cardid, couponRecordId, couponType);
                        int         outerid   = (int)logid;
                        JSSDKHelper jsshelper = new JSSDKHelper();
                        result.card_id   = cardid;
                        result.timestamp = JSSDKHelper.GetTimestamp();
                        result.nonce_str = "";
                        result.signature = jsshelper.GetCardSign2015(apiticket, result.nonce_str, result.timestamp, result.card_id);
                        result.outerid   = outerid;
                    }
                    else
                    {
                        Log.Info("[Coupon]票据获取失败");
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        private WXSyncJSInfoCardInfo MakeSyncWXJSInfo(string cardid, long couponRecordId, WXCardLogInfo.CouponTypeEnum couponType)
        {
            WXSyncJSInfoCardInfo wXSyncJSInfoCardInfo = null;

            if (!string.IsNullOrWhiteSpace(cardid))
            {
                WXCardLogInfo wXCardLogInfo = context.WXCardLogInfo.FirstOrDefault((WXCardLogInfo d) => d.CardId == cardid);
                if (wXCardLogInfo != null)
                {
                    string accessToken     = GetAccessToken(wXCardLogInfo.AppId, wXCardLogInfo.AppSecret);
                    string cardJSApiTicket = GetCardJSApiTicket(accessToken);
                    if (string.IsNullOrWhiteSpace(cardJSApiTicket))
                    {
                        Log.Info("[Coupon]票据获取失败");
                    }
                    else
                    {
                        wXSyncJSInfoCardInfo = new WXSyncJSInfoCardInfo();
                        int         num         = (int)SyncCouponRecordInfo(cardid, couponRecordId, couponType);
                        JSSDKHelper jSSDKHelper = new JSSDKHelper();
                        wXSyncJSInfoCardInfo.card_id   = cardid;
                        wXSyncJSInfoCardInfo.timestamp = JSSDKHelper.GetTimestamp();
                        wXSyncJSInfoCardInfo.nonce_str = "";
                        wXSyncJSInfoCardInfo.signature = jSSDKHelper.GetCardSign2015(cardJSApiTicket, wXSyncJSInfoCardInfo.nonce_str, wXSyncJSInfoCardInfo.timestamp, wXSyncJSInfoCardInfo.card_id, "", "");
                        wXSyncJSInfoCardInfo.outerid   = num;
                    }
                }
            }
            return(wXSyncJSInfoCardInfo);
        }