首页>代码>Spring MVC、Vue、layui、layer等成熟技术开发个人博客网站>/ExcellentCodeProject/src/main/java/com/ecp/common/communal/controller/PortalPayController.java
package com.ecp.common.communal.controller;
import com.alibaba.fastjson.JSONObject;
import com.ecp.common.communal.entity.JsonResult;
import com.ecp.common.communal.util.Base64Utils;
import com.ecp.common.communal.util.KeywordsUtils;
import com.ecp.portal.ebook.service.EBookService;
import com.ecp.portal.project.service.ProjectService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* 用于不需要登录或者权限认证即可调用获取支付码页面
*/
@Controller
@RequestMapping(path = {"/common/communal/portal/pay/"})
public class PortalPayController {
private static final Logger logger = LoggerFactory.getLogger(PortalPayController.class);
@Resource
ProjectService projectService;
@Resource
EBookService eBookService;
/**
* 加载付款码页面
* @param request
* @param response
* @param session
* @param paramsJsonStr
* @return
*/
@RequestMapping(path = {"gotoPaymentCode"}, method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView gotoPaymentCode (HttpServletRequest request, ModelAndView modelAndView,
HttpServletResponse response, HttpSession session, String paramsJsonStr, String resourceType) {
try {
request.setCharacterEncoding(KeywordsUtils.UTF_8);
response.setCharacterEncoding(KeywordsUtils.UTF_8);
System.out.println("==========前端传过来的参数:" + paramsJsonStr);
JSONObject paramsJO = new JSONObject();
if (StringUtils.isNotBlank(paramsJsonStr)) {
paramsJO = JSONObject.parseObject(Base64Utils.javaBase64Decode(paramsJsonStr));
}
System.out.println("==========前端传过来的参数转化成JSONObject:" + paramsJO);
modelAndView.addObject("paramsJsonStr", paramsJO);
modelAndView.addObject("resourceType", resourceType);
modelAndView.setViewName("portal/include/payment_code");
//累计下载次数(因为没有做支付对接不能游客付款成功后累计)
if (StringUtils.isNotBlank(resourceType)) {
if (resourceType.trim().toLowerCase().equals("project")) {
JsonResult jsonResult = projectService.addProjectDownloadNum(paramsJO, session);
if (jsonResult.isSuccess()) {
logger.info("==========" + jsonResult.getMessage());
} else {
logger.info("==========项目信息:" + paramsJO + ", 累计下载次数失败");
}
} else if (resourceType.trim().toLowerCase().equals("ebook")) {
JsonResult jsonResult = eBookService.addEBookDownloadNum(paramsJO, session);
if (jsonResult.isSuccess()) {
logger.info("==========" + jsonResult.getMessage());
} else {
logger.info("==========电子书信息:" + paramsJO + ", 累计下载次数失败");
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return modelAndView;
}
}
最近下载更多
1690356080 LV38
2023年11月12日
123456nty LV37
2022年4月8日
ljm2s LV3
2021年9月24日
seve980508 LV1
2020年5月26日
499755609 LV8
2020年4月7日
jiajia91323 LV23
2019年12月13日
powerful LV7
2019年12月4日
admin123456686 LV10
2019年11月1日
xiongtianming18 LV12
2019年9月26日
wzsq20 LV12
2019年9月22日

最近浏览