瀏覽代碼

Merge remote-tracking branch 'origin/children_day' into children_day

周箭河 4 年之前
父節點
當前提交
5aba665d76

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserCashAccountDetailDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.page.ExportUserAccountQueryInfo;
 import com.ym.mec.common.dal.BaseDAO;
 
 import org.apache.ibatis.annotations.Param;
@@ -38,5 +39,5 @@ public interface SysUserCashAccountDetailDao extends BaseDAO<Long, SysUserCashAc
     List<SysUserCashAccountDetail> queryAccountDetail(Map<String, Object> params);
     int countAccountDetails(Map<String, Object> params);
 
-    List<SysUserCashAccountDetail> exportDetail(Integer userId);
+    List<SysUserCashAccountDetail> exportDetail(@Param("queryInfo") ExportUserAccountQueryInfo queryInfo);
 }

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserCoursesAccountDetailDao.java

@@ -1,12 +1,14 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.SysUserCoursesAccountDetail;
+import com.ym.mec.biz.dal.page.ExportUserAccountQueryInfo;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 public interface SysUserCoursesAccountDetailDao extends BaseDAO<Long, SysUserCoursesAccountDetail> {
 
 
-    List<SysUserCoursesAccountDetail> exportDetail(Integer userId);
+    List<SysUserCoursesAccountDetail> exportDetail(@Param("queryInfo") ExportUserAccountQueryInfo queryInfo);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysUserCashAccountDetail.java

@@ -88,6 +88,16 @@ public class SysUserCashAccountDetail {
 	@ApiModelProperty(value = "平台账户号",required = false)
 	private String platformAccountNo;
 
+	private String organName;
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
 	public String getPhone() {
 		return phone;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysUserCoursesAccountDetail.java

@@ -65,6 +65,16 @@ public class SysUserCoursesAccountDetail {
 	/** 平台账户号 */
 	private String platformAccountNo;
 
+	private String organName;
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
 	public String getPhone() {
 		return phone;
 	}

+ 46 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ExportUserAccountQueryInfo.java

@@ -0,0 +1,46 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class ExportUserAccountQueryInfo extends QueryInfo {
+
+    private Integer userId;
+
+    private String startTime;
+
+    private String endTime;
+
+    private String organId;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+}

+ 18 - 3
mec-biz/src/main/resources/config/mybatis/SysUserCashAccountDetailMapper.xml

@@ -26,6 +26,7 @@
         <result column="update_time_" property="updateTime"/>
         <result column="attribute1_" property="attribute"/>
         <result column="channel_" property="channel"/>
+        <result column="organ_name_" property="organName"/>
         <result column="platform_account_no_" property="platformAccountNo"/>
     </resultMap>
 
@@ -242,12 +243,26 @@
         ) t
     </select>
     <select id="exportDetail" resultMap="SysUserCashAccountDetail">
-        SELECT su.username_,su.phone_,GROUP_CONCAT(sb.name_ ORDER BY sb.name_) subject_name_,cad.* FROM sys_user_cash_account_detail cad
+        SELECT o.name_ organ_name_,su.username_,su.phone_,GROUP_CONCAT(sb.name_ ORDER BY sb.name_) subject_name_,cad.* FROM sys_user_cash_account_detail cad
         LEFT JOIN sys_user su ON su.id_ = cad.user_id_
+        LEFT JOIN organization o ON o.id_ = su.organ_id_
         LEFT JOIN student s ON s.user_id_ = su.id_
         LEFT JOIN `subject` sb ON FIND_IN_SET(sb.id_,s.subject_id_list_)
-        WHERE cad.user_id_ = #{userId}
+        <where>
+            <if test="queryInfo.userId != null">
+                AND cad.user_id_ = #{queryInfo.userId}
+            </if>
+            <if test="queryInfo.organId != null">
+                AND FIND_IN_SET(su.organ_id_,#{queryInfo.organId})
+            </if>
+            <if test="queryInfo.startTime != null and queryInfo.startTime != ''">
+                AND cad.create_time_ >= #{queryInfo.startTime}
+            </if>
+            <if test="queryInfo.endTime != null and queryInfo.startTime != ''">
+                AND cad.create_time_ &lt;= #{queryInfo.endTime}
+            </if>
+        </where>
         GROUP BY cad.id_
-        ORDER BY cad.id_ DESC
+        ORDER BY cad.user_id_,cad.id_ DESC
     </select>
 </mapper>

+ 18 - 3
mec-biz/src/main/resources/config/mybatis/SysUserCoursesAccountDetailMapper.xml

@@ -24,6 +24,7 @@
 		<result column="update_time_" property="updateTime" />
 		<result column="attribute1_" property="attribute1" />
 		<result column="channel_" property="channel" />
+		<result column="organ_name_" property="organName" />
 		<result column="platform_account_no_" property="platformAccountNo" />
 	</resultMap>
 	
@@ -115,12 +116,26 @@
 		<include refid="queryPageCondition" />
 	</select>
 	<select id="exportDetail" resultMap="SysUserCoursesAccountDetail">
-		SELECT su.username_,su.phone_,GROUP_CONCAT(sb.name_ ORDER BY sb.name_) subject_name_,cad.* FROM sys_user_courses_account_detail cad
+		SELECT o.name_ organ_name_,su.username_,su.phone_,GROUP_CONCAT(sb.name_ ORDER BY sb.name_) subject_name_,cad.* FROM sys_user_courses_account_detail cad
 		LEFT JOIN sys_user su ON su.id_ = cad.user_id_
+		LEFT JOIN organization o ON o.id_ = su.organ_id_
 		LEFT JOIN student s ON s.user_id_ = su.id_
 		LEFT JOIN `subject` sb ON FIND_IN_SET(sb.id_,s.subject_id_list_)
-		WHERE cad.user_id_ = #{userId}
+		<where>
+			<if test="queryInfo.userId != null">
+				AND cad.user_id_ = #{queryInfo.userId}
+			</if>
+			<if test="queryInfo.organId != null">
+				AND FIND_IN_SET(su.organ_id_,#{queryInfo.organId})
+			</if>
+			<if test="queryInfo.startTime != null and queryInfo.startTime != ''">
+				AND cad.create_time_ >= #{queryInfo.startTime}
+			</if>
+			<if test="queryInfo.endTime != null and queryInfo.startTime != ''">
+				AND cad.create_time_ &lt;= #{queryInfo.endTime}
+			</if>
+		</where>
 		GROUP BY cad.id_
-		ORDER BY cad.id_ DESC
+		ORDER BY cad.user_id_,cad.id_ DESC
 	</select>
 </mapper>

+ 42 - 12
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -245,8 +245,23 @@ public class ExportController extends BaseController {
     @ApiOperation(value = "学生个人账户余额导出")
     @PostMapping("export/userCashAccountDetail")
     @PreAuthorize("@pcs.hasPermissions('export/userCashAccountDetail')")
-    public void userCashAccountDetail(HttpServletResponse response, Integer userId) throws IOException {
-       List<SysUserCashAccountDetail> cashAccountDetails = sysUserCashAccountDetailDao.exportDetail(userId);
+    public void userCashAccountDetail(HttpServletResponse response, ExportUserAccountQueryInfo queryInfo) throws IOException {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            throw new BizException("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                throw new BizException("非法请求");
+            }
+        }
+       List<SysUserCashAccountDetail> cashAccountDetails = sysUserCashAccountDetailDao.exportDetail(queryInfo);
        if(cashAccountDetails.size() < 1){
            throw new BizException("没有可导出数据");
        }
@@ -255,10 +270,10 @@ public class ExportController extends BaseController {
        }
         OutputStream outputStream = response.getOutputStream();
         try {
-            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "姓名", "电话", "声部",
-                    "交易类型", "交易金额", "交易时间", "备注"}, new String[]{
-                    "userId", "username", "phone", "subjectName",
-                    "type.msg", "amount", "createTime", "comment"}, cashAccountDetails);
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部","学员编号", "姓名", "电话", "声部",
+                    "交易类型", "交易金额", "交易时间", "备注","可用余额"}, new String[]{
+                    "organName","userId", "username", "phone", "subjectName",
+                    "type.msg", "amount", "createTime", "comment","balance"}, cashAccountDetails);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attac:wq" +
                     "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");
@@ -282,8 +297,23 @@ public class ExportController extends BaseController {
     @ApiOperation(value = "学生个人课程余额导出")
     @PostMapping("export/userCoursesAccount")
     @PreAuthorize("@pcs.hasPermissions('export/userCoursesAccount')")
-    public void userCoursesAccount(HttpServletResponse response, Integer userId) throws IOException {
-        List<SysUserCoursesAccountDetail> coursesAccountDetails = sysUserCoursesAccountDetailDao.exportDetail(userId);
+    public void userCoursesAccount(HttpServletResponse response,ExportUserAccountQueryInfo queryInfo) throws IOException {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            throw new BizException("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                throw new BizException("非法请求");
+            }
+        }
+        List<SysUserCoursesAccountDetail> coursesAccountDetails = sysUserCoursesAccountDetailDao.exportDetail(queryInfo);
         if(coursesAccountDetails.size() < 1){
             throw new BizException("没有可导出数据");
         }
@@ -292,10 +322,10 @@ public class ExportController extends BaseController {
         }
         OutputStream outputStream = response.getOutputStream();
         try {
-            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "姓名", "电话", "声部",
-                    "交易类型", "交易金额", "交易时间", "备注"}, new String[]{
-                    "userId", "username", "phone", "subjectName",
-                    "type.msg", "amount", "createTime", "comment"}, coursesAccountDetails);
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部", "学员编号", "姓名", "电话", "声部",
+                    "交易类型", "交易金额", "交易时间", "备注","可用余额"}, new String[]{
+                    "organName", "userId", "username", "phone", "subjectName",
+                    "type.msg", "amount", "createTime", "comment","balance"}, coursesAccountDetails);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attac:wq" +
                     "hment;filename=classGroup-" + DateUtil.getDate(new Date()) + ".xls");