public CardExtModel ApplyMCard(ApplyMCardContext context) { Logger.DebugFormat("context", context.SerializeToJson()); Guard.ArgumentNotNull(context, "context"); Guard.ArgumentNotNullOrEmpty( new string[] { context.MCode, context.CardId }, new string[] { "MCode", "CardId" }); return(client.PrepareCardSign(context)); }
public CardExtModel PrepareCardSign(ApplyMCardContext context) { var timestamp = DateTime.UtcNow.ToUnixStampDateTime(); //var nonceStr = this.generator.Genernate();// Guid.NewGuid().ToString().Replace("-", string.Empty); //var nonceStr = this.generator.Genernate(); var nonceStr = Guid.NewGuid().ToString().Replace("-", string.Empty); var official = this.sharingHostService.MerchantDetails.Where(o => o.MCode == context.MCode).SelectMany(o => o.Apps) .FirstOrDefault(o => o.AppType == AppTypes.Official); var miniprogram = this.sharingHostService.MerchantDetails.Where(o => o.MCode == context.MCode).SelectMany(o => o.Apps) .FirstOrDefault(o => o.AppType == AppTypes.Miniprogram); var cardsign = new CardExtModel() { Signature = this.wxapi.GenerateSignForApplyMCard(official, miniprogram, context.CardId, timestamp, nonceStr), TimeStamp = timestamp.ToString(), NonceStr = nonceStr, //CardId = context.CardId }; return(cardsign); }