使用微信助手搭建微信返利机器人流程

  [HttpPost]

  public async Task FanliAsync(string appkey)

  {

  WeixinTBKConfigEntity configEntity = GetConfigEntity(appkey);

  if (configEntity == null)

  {

  LogHelper.WriteLog(typeof(OtherWechatController), "appkey接口验证时,appkey不存在");

  return Content("验证失败。appkey接口验证时,appkey不存在");

  }

  Request.InputStream.Position = 0;

  Stream stream = Request.InputStream;

  string json = string.Empty;

  if (stream.Length != 0)

  {

  StreamReader streamreader = new StreamReader(stream);

  json = streamreader.ReadToEnd();

  }

  WeChatToolMessage responseMsg = new WeChatToolMessage();

  if (string.IsNullOrEmpty(json))

  {

  return Json(responseMsg);

  }

  WeChatToolMessage msg = JsonConvert.DeserializeObject(json);

  if (string.IsNullOrEmpty(msg.wxid) || string.IsNullOrEmpty(msg.content))

  {

  return Json(responseMsg);

  }

  string content = msg.content;

  string responseStr = string.Empty;

  if (content.Contains("yangkeduo.com"))

  {

  //访问拼多多接口

  responseStr = await GetPddCouponAsync(configEntity, msg);

  }

  else if (content.Contains("jd.com"))

  {

  if (!string.IsNullOrEmpty(configEntity.JdPID))

  {

  //访问京东联盟接口

  responseStr = GetJdCoupon(configEntity, msg);

  }

  }

  else

  {

  //访问淘宝联盟接口

  responseStr = GetTBKCouponByPassword(configEntity, msg.content);

  }

  responseMsg.wxid = msg.wxid;

  responseMsg.content = responseStr;

  return Json(responseMsg);

  }