diff --git a/src/main/java/au/com/royalpay/payment/manage/posters/core/PosterService.java b/src/main/java/au/com/royalpay/payment/manage/posters/core/PosterService.java new file mode 100644 index 000000000..918e19999 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/posters/core/PosterService.java @@ -0,0 +1,9 @@ +package au.com.royalpay.payment.manage.posters.core; + + +/** + * create by todking at 2019-6-3 + */ +public interface PosterService { + void updatePoster(String imgUrl); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/posters/core/impls/PosterServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/posters/core/impls/PosterServiceImpl.java new file mode 100644 index 000000000..bacc18d93 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/posters/core/impls/PosterServiceImpl.java @@ -0,0 +1,35 @@ +package au.com.royalpay.payment.manage.posters.core.impls; + +import au.com.royalpay.payment.manage.posters.core.PosterService; +import cn.yixblog.platform.http.HttpRequestGenerator; +import com.alibaba.fastjson.JSONObject; +import com.yeepay.shade.org.apache.http.protocol.HTTP; +import org.apache.http.entity.StringEntity; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.net.URISyntaxException; + + +/** + * create by todking at 2019-6-3 + */ + +@Service +public class PosterServiceImpl implements PosterService { + @Value("${app.cms.host}") + private String cmsHost; + + @Override + public void updatePoster(String imgUrl) { + String url = cmsHost + "/api/statistics/count"; + try { + new HttpRequestGenerator(url, RequestMethod.PUT).addQueryString("imgUrl", imgUrl).execute(); + }catch (URISyntaxException e) { + e.printStackTrace(); + } + } + + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/posters/web/posterController.java b/src/main/java/au/com/royalpay/payment/manage/posters/web/posterController.java new file mode 100644 index 000000000..bf56f78c3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/posters/web/posterController.java @@ -0,0 +1,25 @@ +package au.com.royalpay.payment.manage.posters.web; + + +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.posters.core.PosterService; +import com.alibaba.fastjson.JSONObject; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * create by todking at 2019-6-3 + */ +@RestController +@RequestMapping(value = "/app/poster") +public class posterController { + + @Resource + private PosterService posterService; + + @RequestMapping(method = RequestMethod.PUT) + public void updatePoster(@RequestBody JSONObject img ){ + posterService.updatePoster(img.getString("imgUrl")); + } +} diff --git a/src/main/ui/static/templates/payment/success.js b/src/main/ui/static/templates/payment/success.js index a0590a154..18fdc1fb3 100644 --- a/src/main/ui/static/templates/payment/success.js +++ b/src/main/ui/static/templates/payment/success.js @@ -112,3 +112,20 @@ $(function () { }); }); + +//点击广告统计次数 +function timesCount(imgUrl,linkUrl){ + $.ajax({ + data:JSON.stringify({imgUrl:imgUrl}), + contentType: 'application/json', + url:"/app/poster", + method:'PUT', + dataType:'text', + success: function (data) { + window.location.href = linkUrl; + }, + error: function (data) { + window.location.href = linkUrl; + } + }); +}