Example #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 Entities.WXSyncJSInfoCardInfo MakeSyncWXJSInfo(string cardid, long couponRecordId, Entities.WXCardLogInfo.CouponTypeEnum couponType)
        {
            Entities.WXSyncJSInfoCardInfo result = null;
            if (!string.IsNullOrWhiteSpace(cardid))
            {
                var card = DbFactory.Default.Get <Entities.WXCardLogInfo>().Where(d => d.CardId == cardid).FirstOrDefault();
                //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 Entities.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 = JSSDKHelper.GetCardSign(apiticket, result.nonce_str, result.timestamp, result.card_id);
                        result.signature = JSSDKHelper.GetCardSign(card.AppId, card.AppSecret, card.ShopId.ToString(), result.nonce_str, result.timestamp, result.card_id, card.CouponType.ToString());


                        result.outerid = outerid;
                    }
                    else
                    {
                        Log.Info("[Coupon]票据获取失败");
                    }
                }
            }
            return(result);
        }