|
|
|
@@ -0,0 +1,100 @@ |
|
|
|
package com.iformall.controller.callback; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.controller.base.BaseController; |
|
|
|
import com.iformall.domain.po.TtCouponChannelPoi; |
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.service.MailService; |
|
|
|
import com.iformall.service.TtCouponGoodsService; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
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 |
|
|
|
@RequestMapping("/ttgoods/notify") |
|
|
|
public class TtGoodsController extends BaseController { |
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private String fmExceptionEmails; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MailService mailService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxAppinfoService wxAppinfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TtCouponGoodsService ttCouponGoodsService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Qualifier("openRedisTemplate") |
|
|
|
RedisTemplate<String, String> openRedisTemplate; |
|
|
|
|
|
|
|
/** |
|
|
|
* { |
|
|
|
* "event": "verify_webhook", |
|
|
|
* "client_key": "", |
|
|
|
* "content": { |
|
|
|
* "challenge": 12345 |
|
|
|
* } |
|
|
|
* } |
|
|
|
*/ |
|
|
|
@PostMapping(value = "/notice") |
|
|
|
@ResponseBody |
|
|
|
public Map notice( @RequestBody Map<String, Object> parameterMap,HttpServletRequest request){ |
|
|
|
logger.debug("[" + getIpAddr() + "] TtOrderCallbackController::notice"); |
|
|
|
logger.info("抖音开放平台通知v2-----{}"+JSON.toJSONString(parameterMap)); |
|
|
|
|
|
|
|
String msgSignature = request.getHeader("Byte-Signature"); |
|
|
|
String timestamp = request.getHeader("Byte-Timestamp"); |
|
|
|
String nonce = request.getHeader("Byte-Nonce-Str"); |
|
|
|
|
|
|
|
String identifyName = request.getHeader("Byte-IdentifyName"); |
|
|
|
String product_audit_notify = "/msg/common/goods/product_audit_notify"; |
|
|
|
Map resultMap = new HashMap<>(); |
|
|
|
if(!product_audit_notify.equals(identifyName)){ |
|
|
|
resultMap.put("err_code",1000); |
|
|
|
resultMap.put("err_tips","error"); |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
try{ |
|
|
|
Long product_id = (Long) parameterMap.get("product_id"); |
|
|
|
String status = (String) parameterMap.get("status"); |
|
|
|
|
|
|
|
TtCouponChannelPoi couponChannelPoi = ttCouponGoodsService.getCouponChannelBySpuId(product_id.toString()); |
|
|
|
ResultData resultData = ttCouponGoodsService.productDraftGet(couponChannelPoi, couponChannelPoi.getId(), false); |
|
|
|
|
|
|
|
if(resultData.code == 200){ |
|
|
|
resultMap.put("err_code",0); |
|
|
|
resultMap.put("err_tips","success"); |
|
|
|
}else{ |
|
|
|
resultMap.put("err_code",resultData.code); |
|
|
|
resultMap.put("err_tips",resultData.message); |
|
|
|
} |
|
|
|
return resultMap; |
|
|
|
|
|
|
|
}catch(Exception e){ |
|
|
|
resultMap.put("err_code",1000); |
|
|
|
resultMap.put("err_tips","error"); |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |