| @@ -8,16 +8,20 @@ import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.enums.EnumSpuSyncStatus; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import me.chanjar.weixin.common.util.crypto.SHA1; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| @RestController | |||
| @@ -38,6 +42,10 @@ public class TtWebController extends BaseController { | |||
| @Autowired | |||
| private TtCouponGoodsService ttCouponGoodsService; | |||
| @Autowired | |||
| @Qualifier("openRedisTemplate") | |||
| RedisTemplate<String, String> openRedisTemplate; | |||
| /** | |||
| * { | |||
| * "event": "verify_webhook", | |||
| @@ -68,19 +76,24 @@ public class TtWebController extends BaseController { | |||
| resultMap.put("err_tips","error"); | |||
| return resultMap; | |||
| } | |||
| String log_id = (String) parameterMap.get("log_id"); | |||
| String key = "life_goods_audit:"+log_id; | |||
| if(openRedisTemplate.hasKey(key)){ | |||
| resultMap.put("err_code",0); | |||
| resultMap.put("err_tips","success"); | |||
| return resultMap; | |||
| } | |||
| String header = request.getHeader("X-Douyin-Signature"); | |||
| String sha1gen = SHA1.gen(appInfo.getSecret(), JSON.toJSONString(parameterMap)); | |||
| // String header = request.getHeader("X-Douyin-Signature"); | |||
| // String sha1gen = SHA1.gen(appInfo.getSecret(), JSON.toJSONString(parameterMap)); | |||
| //发邮件 | |||
| String[] receivers = fmExceptionEmails.split(","); | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append(DateUtils.date2String(new Date())); | |||
| sb.append("\n"); | |||
| sb.append("抖音开放平台通知{}"+JSON.toJSONString(parameterMap)); | |||
| sb.append("\n"); | |||
| sb.append("sha1gen{}"+sha1gen); | |||
| sb.append("抖音开放平台通知:"); | |||
| sb.append("\n"); | |||
| sb.append("header{}"+header); | |||
| sb.append(JSON.toJSONString(parameterMap)); | |||
| //发送邮件 | |||
| mailService.sendSimpleMail(receivers, "抖音开放平台通知", sb.toString()); | |||
| @@ -114,6 +127,7 @@ public class TtWebController extends BaseController { | |||
| ttCouponGoodsService.handlerTtGoodsAudit(couponChannelPoi); | |||
| resultMap.put("err_code",0); | |||
| resultMap.put("err_tips","success"); | |||
| openRedisTemplate.opsForValue().set(key,"1",16*60, TimeUnit.SECONDS); | |||
| return resultMap; | |||
| } | |||