|
@@ -0,0 +1,251 @@
|
|
|
+package com.agent.action.deposit;
|
|
|
+
|
|
|
+import com.agent.action.common.AbstractController;
|
|
|
+import com.agent.constans.CommonConstants;
|
|
|
+import com.agent.constans.ConfigConstants;
|
|
|
+import com.agent.model.bms.bean.UserBean;
|
|
|
+import com.agent.model.common.bean.PageResultBean;
|
|
|
+import com.agent.model.common.bean.ResultBean;
|
|
|
+import com.agent.model.deposit.bean.DepositBean;
|
|
|
+import com.agent.model.deposit.service.DepositBeanService;
|
|
|
+import com.agent.model.usercolumn.bean.UserColumnRoleBean;
|
|
|
+import com.agent.util.ExcelFileUtil;
|
|
|
+import com.agent.util.HttpResult;
|
|
|
+import com.agent.util.HttpUtils;
|
|
|
+import com.agent.util.StringUtils;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 销售员保证金操作
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping("/depositsale")
|
|
|
+public class DepositSaleController extends AbstractController {
|
|
|
+ private static Logger log = LoggerFactory.getLogger(DepositSaleController.class);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保证金记录service
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ private DepositBeanService depositBeanService;
|
|
|
+ /**
|
|
|
+ * 中央后台保证金记录列表页
|
|
|
+ */
|
|
|
+ private final String PLAT_DEPOSIT_LIST = "deposit/plat/depositsalelist";
|
|
|
+ /**
|
|
|
+ * 代理商后台保证金记录列表页
|
|
|
+ */
|
|
|
+ private final String AGENT_DEPOSIT_LIST = "deposit/agent/depositsalelist";
|
|
|
+
|
|
|
+ @Value("${wjj.api.domain}")
|
|
|
+ private String wjjApiDomain;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 载入保证金记录列表页
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @RequestMapping("/showDepositList.do")
|
|
|
+ public ModelAndView showDepositList(HttpServletRequest request,
|
|
|
+ HttpServletResponse response) throws Exception{
|
|
|
+ //获取登录信息
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO);
|
|
|
+ ModelAndView mv = null;
|
|
|
+ //页面跳转
|
|
|
+ if(ConfigConstants.IS_ADMIN.equals(user.getIsAdmin())) {
|
|
|
+ mv = super.createJspView(PLAT_DEPOSIT_LIST);
|
|
|
+ }else {
|
|
|
+ mv = super.createJspView(AGENT_DEPOSIT_LIST);
|
|
|
+ //获取用户session信息中的字段权限,并组装成map带回页面
|
|
|
+ List<UserColumnRoleBean> roleList = user.getUserColumnRoleBeans();
|
|
|
+ if(roleList!=null && !roleList.isEmpty()){
|
|
|
+ for(UserColumnRoleBean role:roleList){
|
|
|
+ if(role!=null){
|
|
|
+ if(ConfigConstants.DEPOSIT_LIST.equals(role.getListCode())){
|
|
|
+ mv.addObject(role.getColumnCode(), "1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索保证金记录分页列表
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @RequestMapping("/depositList.do")
|
|
|
+ public void depositList(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute DepositBean depositBean){
|
|
|
+ //返回页面数据
|
|
|
+ PageResultBean resultBean = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ //获取登录信息
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO);
|
|
|
+ //如果不是平台用户的话,则只能搜索到他本身的商家报价信息
|
|
|
+ if(!ConfigConstants.IS_ADMIN.equals(user.getIsAdmin())){
|
|
|
+ depositBean.setAgentID(user.getAgentId());
|
|
|
+ }
|
|
|
+ // 当前页码
|
|
|
+ String currentPage = super.getParameter(request, "currentPage");
|
|
|
+ // 分页记录数
|
|
|
+ String pageSize = super.getParameter(request, "pageSize");
|
|
|
+ int currentPageInt = 1;
|
|
|
+ int pageSizeInt = 10;
|
|
|
+ if(StringUtils.isNotEmpty(currentPage)){
|
|
|
+ try {
|
|
|
+ currentPageInt = Integer.parseInt(currentPage);
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的页数!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(pageSize)){
|
|
|
+ try {
|
|
|
+ pageSizeInt = Integer.parseInt(pageSize);
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultBean = new PageResultBean(PageResultBean.FAIL_CODE,"请输入正确的分页数!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resultBean=depositBeanService.querySaleDepositRecordPage(depositBean,"",null,currentPageInt,pageSizeInt);
|
|
|
+
|
|
|
+ //获取用户session信息中的字段权限,并组装成map带回页面
|
|
|
+ List<UserColumnRoleBean> roleList = user.getUserColumnRoleBeans();
|
|
|
+ Map<String,String> columnMap = new HashMap<String,String>();
|
|
|
+ if(roleList!=null && !roleList.isEmpty()){
|
|
|
+ for(UserColumnRoleBean role:roleList){
|
|
|
+ if(role!=null){
|
|
|
+ if(ConfigConstants.DEPOSIT_LIST.equals(role.getListCode())){
|
|
|
+ columnMap.put(role.getColumnCode(), role.getColumnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultBean.setResult(columnMap);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultBean= new PageResultBean(PageResultBean.FAIL_CODE,"系统繁忙,请稍后再来!");
|
|
|
+ log.error("depositList error!",e);
|
|
|
+ }finally{
|
|
|
+ super.printResult(request, response, resultBean.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退款
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @RequestMapping("/refund.do")
|
|
|
+ public void refund(HttpServletRequest request, HttpServletResponse response){
|
|
|
+ //返回页面数据
|
|
|
+ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!");
|
|
|
+ String id = super.getParameter(request, "id");
|
|
|
+ try {
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE,"请选择退款记录!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> requestParameters = new HashMap<>();
|
|
|
+ requestParameters.put("id", id);
|
|
|
+ final HttpResult httpResult = HttpUtils.post(wjjApiDomain + "pay/applyRefund", requestParameters);
|
|
|
+ if (httpResult.getStatusCode() != 200) {
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE, "系统繁忙,请稍后再来!");
|
|
|
+ } else {
|
|
|
+ final String content = httpResult.getContent();
|
|
|
+ log.info("调用微信退款, 响应内容:{}", content);
|
|
|
+ final JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ final Integer code = jsonObject.getInteger("code");
|
|
|
+ if (code != 1) {
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE, jsonObject.getString("message"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE, "系统繁忙,请稍后再来!");
|
|
|
+ log.error("refund error!",e);
|
|
|
+ }finally{
|
|
|
+ super.printResult(request, response, resultBean.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出保证金记录
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @RequestMapping("/exportDeposit.do")
|
|
|
+ public void exportDeposit(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @ModelAttribute DepositBean depositBean){
|
|
|
+ //返回页面数据
|
|
|
+ ResultBean resultBean = new ResultBean(ResultBean.SUCCESS_CODE,"成功!");
|
|
|
+ try {
|
|
|
+ //获取登录信息
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ UserBean user = (UserBean)session.getAttribute(CommonConstants.USER_INFO);
|
|
|
+ //判断必要参数是否传递到后台
|
|
|
+ String[] queryCondition = new String[]{};
|
|
|
+ ResultBean flag = new ResultBean(ResultBean.SUCCESS_CODE,"成功!");
|
|
|
+ //删除场区
|
|
|
+ // 任务项数量 查询条件
|
|
|
+ StringBuilder conditionSql = new StringBuilder();
|
|
|
+ // 任务项 条件值
|
|
|
+ List<Object> conditions = new ArrayList<Object>();
|
|
|
+ for (int i = 0; i < queryCondition.length; i++) {
|
|
|
+ conditions.add(queryCondition[i]);
|
|
|
+ conditionSql.append("?");
|
|
|
+ if(i<queryCondition.length-1) {
|
|
|
+ conditionSql.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String path = request.getSession().getServletContext().getRealPath("/")+ "/depositexcel/";;
|
|
|
+ flag = depositBeanService.createSaleDepositXlsx(depositBean,conditionSql.toString(),conditions,path,user);
|
|
|
+ if(!ResultBean.SUCCESS_CODE.equals(flag.getCode())){
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE,"系统繁忙,请稍后再来!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String filename = flag.getMessage();
|
|
|
+ String[] tempArr= filename.split("\\.");
|
|
|
+ //设置文件下载格式XLS
|
|
|
+ ExcelFileUtil.setXLSXHeader(request, response, tempArr[0]);
|
|
|
+ //获取文件
|
|
|
+ File upfile = new File(path+filename);
|
|
|
+ ExcelFileUtil.downloadFile(response.getOutputStream(),upfile);
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultBean = new ResultBean(ResultBean.FAIL_CODE, "系统繁忙,请稍后再来!");
|
|
|
+ log.error("exportDeposit error!",e);
|
|
|
+ }/*finally{
|
|
|
+ super.pringResult(request, response, resultBean.toString());
|
|
|
+ }*/
|
|
|
+
|
|
|
+ }
|
|
|
+}
|