Hu Jie 7 лет назад
Родитель
Сommit
2408704d51

+ 30 - 0
src/main/java/com/uas/platform/b2c/prod/store/controller/StoreApplyController.java

@@ -2,8 +2,10 @@ package com.uas.platform.b2c.prod.store.controller;
 
 import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.core.support.view.JxlsExcelView;
 import com.uas.platform.b2c.prod.store.facade.StoreApplyFacade;
 import com.uas.platform.b2c.prod.store.model.StoreApply;
+import com.uas.platform.b2c.prod.store.model.StoreInfoAndProdExport;
 import com.uas.platform.b2c.prod.store.model.StoreType;
 import com.uas.platform.b2c.prod.store.service.StoreApplyService;
 import com.uas.platform.b2c.trade.support.ResultMap;
@@ -13,12 +15,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -187,4 +194,27 @@ public class StoreApplyController {
 	public ResultMap findShopOwnerApplyByNormalStatus() {
 		return storeApplyService.findShopOwnerApplyByNormalStatus();
 	}
+
+	/**
+	 * 获取店铺信息
+	 */
+	@RequestMapping(value = "/storeinfo", method = RequestMethod.GET)
+	public com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(@PageableDefault(value = 20, page = 1) Pageable pageable,
+					@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
+		return storeApplyService.getStoreInfoAndProdCount(pageable, startTime ,endTime);
+	}
+
+	/**
+	 * 获取店铺信息
+	 */
+	@RequestMapping(value = "/export", method = RequestMethod.GET)
+	public ModelAndView storeInfoAndProdCountExport(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("startTime", startTime);
+		modelAndView.addObject("endTime", endTime);
+		List<StoreInfoAndProdExport> exports = storeApplyService.storeInfoAndProdCountExport(startTime, endTime);
+		modelAndView.addObject("data", exports);
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/product/storeInfo", "上传产品详情"));
+		return modelAndView;
+	}
 }

+ 84 - 0
src/main/java/com/uas/platform/b2c/prod/store/model/StoreInfoAndProdExport.java

@@ -0,0 +1,84 @@
+package com.uas.platform.b2c.prod.store.model;
+
+
+import java.util.Date;
+
+/**
+ * @Author: huj
+ * @Date: Created in 17:18 2018/10/8.
+ */
+public class StoreInfoAndProdExport {
+
+    /**
+     * 申请时间
+     */
+    private Date applyTime;
+    /**
+     * 店铺名称
+     */
+    private String storeName;
+    /**
+     * 企业uu
+     */
+    private Long enuu;
+    /**
+     * 审核时间
+     */
+    private Date agreeTime;
+    /**
+     * 审核人
+     */
+    private String agreeName;
+    /**
+     * 上传产品数
+     */
+    private String count;
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public Date getApplyTime() {
+        return applyTime;
+    }
+
+    public void setApplyTime(Date applyTime) {
+        this.applyTime = applyTime;
+    }
+
+    public Date getAgreeTime() {
+        return agreeTime;
+    }
+
+    public void setAgreeTime(Date agreeTime) {
+        this.agreeTime = agreeTime;
+    }
+
+    public String getAgreeName() {
+        return agreeName;
+    }
+
+    public void setAgreeName(String agreeName) {
+        this.agreeName = agreeName;
+    }
+
+    public String getCount() {
+        return count;
+    }
+
+    public void setCount(String count) {
+        this.count = count;
+    }
+}

+ 12 - 0
src/main/java/com/uas/platform/b2c/prod/store/service/StoreApplyService.java

@@ -2,11 +2,14 @@ package com.uas.platform.b2c.prod.store.service;
 
 
 import com.uas.platform.b2c.prod.store.model.StoreApply;
+import com.uas.platform.b2c.prod.store.model.StoreInfoAndProdExport;
 import com.uas.platform.b2c.prod.store.model.StoreType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -80,4 +83,13 @@ public interface StoreApplyService {
 	 * 获取当前店铺的待处理和已通过申请信息,应当有且只有一条记录
 	 */
 	ResultMap findShopOwnerApplyByNormalStatus();
+
+	/**
+	 * 导出店铺信息
+	 * @param pageable
+	 * @return
+	 */
+	com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(Pageable pageable, Date startTime, Date endTime);
+
+	List<StoreInfoAndProdExport> storeInfoAndProdCountExport(Date startTime, Date endTime);
 }

+ 55 - 8
src/main/java/com/uas/platform/b2c/prod/store/service/impl/StoreApplyServiceImpl.java

@@ -3,17 +3,12 @@ package com.uas.platform.b2c.prod.store.service.impl;
 import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
 import com.uas.platform.b2c.common.account.model.Enterprise;
 import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.common.base.dao.CommonDao;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.core.utils.UuidUtils;
 import com.uas.platform.b2c.prod.store.dao.StoreApplyDao;
 import com.uas.platform.b2c.prod.store.dao.StoreBrandInfoDao;
-import com.uas.platform.b2c.prod.store.model.EnterpriseSimple;
-import com.uas.platform.b2c.prod.store.model.Qualification;
-import com.uas.platform.b2c.prod.store.model.QualificationType;
-import com.uas.platform.b2c.prod.store.model.StoreApply;
-import com.uas.platform.b2c.prod.store.model.StoreBrandInfo;
-import com.uas.platform.b2c.prod.store.model.StoreIn;
-import com.uas.platform.b2c.prod.store.model.StoreType;
+import com.uas.platform.b2c.prod.store.model.*;
 import com.uas.platform.b2c.prod.store.service.StoreApplyService;
 import com.uas.platform.b2c.prod.store.service.StoreInService;
 import com.uas.platform.b2c.trade.support.CodeType;
@@ -23,7 +18,10 @@ import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.CriterionExpression;
 import com.uas.platform.core.persistence.criteria.SimpleExpression;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.convert.converter.Converter;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -55,12 +53,16 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 
 	private final StoreBrandInfoDao brandInfoDao;
 
+	private final CommonDao commonDao;
+
 	@Autowired
-	public StoreApplyServiceImpl(StoreApplyDao storeApplyDao, EnterpriseDao enterpriseDao, StoreInService storeInService, StoreBrandInfoDao brandInfoDao) {
+	public StoreApplyServiceImpl(StoreApplyDao storeApplyDao, EnterpriseDao enterpriseDao, StoreInService storeInService,
+								 StoreBrandInfoDao brandInfoDao, CommonDao commonDao) {
 		this.storeApplyDao = storeApplyDao;
 		this.enterpriseDao = enterpriseDao;
 		this.storeInService = storeInService;
 		this.brandInfoDao = brandInfoDao;
+		this.commonDao = commonDao;
 	}
 
 	@Override
@@ -305,4 +307,49 @@ public class StoreApplyServiceImpl implements StoreApplyService {
 			return new ResultMap(CodeType.ERROR_STATE, "数据操作异常");
 		}
 	}
+
+	@Override
+	public com.uas.sso.support.Page<StoreInfoAndProdExport> getStoreInfoAndProdCount(Pageable pageable, Date startTime, Date endTime) {
+		if (pageable == null) {
+			return null;
+		}
+		StringBuilder sql = new StringBuilder("select a.apply_create_time applyTime, a.apply_store_name storeName, "
+				+ "a.apply_store_enuu enuu,a.apply_auth_time agreeTime, a.apply_auth_person_name agreeName, " +
+				"ifnull(p.count, 0) count from `store$apply` a left join (select pr_enuu, count(1) count from products" +
+				" group by pr_enuu) p on p.pr_enuu = a.apply_store_enuu where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			sql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			sql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		sql.append(" order by a.apply_create_time limit " + pageable.getPageNumber() * pageable.getPageSize() + ","
+				+ pageable.getPageSize());
+		StringBuilder totalSql = new StringBuilder("select count(1) from `store$apply` a where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			totalSql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			totalSql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		Integer total = commonDao.queryForObject(totalSql.toString(), Integer.class);
+		List<StoreInfoAndProdExport> exports = commonDao.query(sql.toString(), StoreInfoAndProdExport.class);
+		return new com.uas.sso.support.Page<>(pageable.getPageNumber(), pageable.getPageSize(), exports, total);
+	}
+
+	@Override
+	public List<StoreInfoAndProdExport> storeInfoAndProdCountExport(Date startTime, Date endTime) {
+		StringBuilder sql = new StringBuilder("select a.apply_create_time applyTime, a.apply_store_name storeName, "
+				+ "a.apply_store_enuu enuu,a.apply_auth_time agreeTime, a.apply_auth_person_name agreeName, " +
+				"ifnull(p.count, 0) count from `store$apply` a left join (select pr_enuu, count(1) count from products" +
+				" group by pr_enuu) p on p.pr_enuu = a.apply_store_enuu where a.apply_status='PASS' ");
+		if (!StringUtils.isEmpty(startTime)) {
+			sql.append(" and date(a.apply_create_time) >= '" + new java.sql.Date(startTime.getTime()) + "'");
+		}
+		if (!StringUtils.isEmpty(endTime)) {
+			sql.append(" and date(a.apply_create_time) <= '" + new java.sql.Date(endTime.getTime()) + "' ");
+		}
+		sql.append(" order by a.apply_create_time");
+		return commonDao.query(sql.toString(), StoreInfoAndProdExport.class);
+	}
 }

BIN
src/main/resources/jxls-tpl/product/storeInfo.xls