| | |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.dao.UserMapper; |
| | | import com.stylefeng.guns.modular.system.factory.UserFactory; |
| | | import com.stylefeng.guns.modular.system.model.TAgent; |
| | | import com.stylefeng.guns.modular.system.model.TBranchOffice; |
| | | import com.stylefeng.guns.modular.system.model.TCompany; |
| | | import com.stylefeng.guns.modular.system.model.User; |
| | | import com.stylefeng.guns.modular.system.service.ITCompanyService; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IUserService; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.transfer.UserDto; |
| | | import com.stylefeng.guns.modular.system.util.OssUploadUtil; |
| | | import com.stylefeng.guns.modular.system.util.huawei.OBSUtil; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 系统管理员控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITDriverService itDriverService; |
| | | @Autowired |
| | | private ITAgentService agentService; |
| | | @Autowired |
| | | private ITBranchOfficeService branchOfficeService; |
| | | |
| | | |
| | | /** |
| | |
| | | page.setRecords(userService.getUserListPage(page,null, name, beginTime, endTime, deptid)); |
| | | return super.packForBT(page); |
| | | } else { |
| | | DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope()); |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(userService.getUserListPage(page,dataScope, name, beginTime, endTime, deptid)); |
| | | return super.packForBT(page); |
| | | Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); |
| | | Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType(); |
| | | |
| | | if(roleType == 3){ |
| | | // 查询下级分公司账号 |
| | | TAgent tAgent = agentService.selectById(objectId); |
| | | List<TBranchOffice> branchOffices = branchOfficeService.selectList(new EntityWrapper<TBranchOffice>() |
| | | .eq("agentId", tAgent.getId())); |
| | | |
| | | List<Integer> officeIds = branchOffices.stream().map(TBranchOffice::getId).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(officeIds)){ |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(new ArrayList<>()); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | | // List<User> userList = userService.selectList(new EntityWrapper<User>() |
| | | // .in("object_id", officeIds)); |
| | | // List<Integer> userIds = userList.stream().map(User::getId).collect(Collectors.toList()); |
| | | |
| | | DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope()); |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<Map<String, Object>> userListPage = userService.getUserListPageAgent(page, null, name, beginTime, endTime, deptid,officeIds); |
| | | page.setRecords(userListPage); |
| | | return super.packForBT(page); |
| | | }else { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | page.setRecords(new ArrayList<>()); |
| | | return super.packForBT(page); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @Param("beginTime") String beginTime, |
| | | @Param("endTime") String endTime, |
| | | @Param("deptid") Integer deptid); |
| | | |
| | | List<Map<String, Object>> getUserListPageAgent(@Param("page") Page<Map<String, Object>> page, |
| | | @Param("dataScope") DataScope dataScope, |
| | | @Param("name") String name, |
| | | @Param("beginTime") String beginTime, |
| | | @Param("endTime") String endTime, |
| | | @Param("deptid") Integer deptid, |
| | | @Param("officeIds")List<Integer> officeIds); |
| | | |
| | | } |
| | |
| | | order by o.id desc |
| | | </select> |
| | | |
| | | <select id="getUserListPageAgent" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page"> |
| | | SELECT * FROM (select CASE when d2.simplename is null then d1.simplename else d2.simplename end as parentName, |
| | | case when uu.sex = 1 then '男' when uu.sex = 2 then '女' else '' end as sexName, |
| | | d1.simplename as deptName,case when uu.status = 1 then '启用' when uu.status = 2 then '冻结' when uu.status = 3 then '删除' else '' end as statusName, |
| | | rr.roleName, |
| | | uu.* from sys_user as uu |
| | | LEFT JOIN sys_dept as d1 on d1.id = uu.deptid |
| | | LEFT JOIN sys_dept as d2 on d2.id = d1.pid |
| | | LEFT JOIN (select s.id,s.name,GROUP_CONCAT(r.name) as roleName from sys_user s |
| | | left join sys_role r on find_in_set(r.id,s.roleid) group by s.id) as rr on rr.id = uu.id |
| | | ) as o |
| | | <where> |
| | | o.status != 3 |
| | | <if test="name != null and name != ''"> |
| | | and (o.phone like CONCAT('%',#{name},'%') |
| | | or o.account like CONCAT('%',#{name},'%') |
| | | or o.name like CONCAT('%',#{name},'%')) |
| | | </if> |
| | | <if test="deptid != null and deptid != 0"> |
| | | and (o.deptid = #{deptid} or o.deptid in ( select id from sys_dept where pids like CONCAT('%[', #{deptid}, ']%') )) |
| | | </if> |
| | | <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''"> |
| | | and (o.createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')) |
| | | </if> |
| | | <if test="officeIds != null and officeIds.size() > 0"> |
| | | and o.object_id in |
| | | <foreach collection="officeIds" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | and o.role_type = 2 |
| | | </where> |
| | | order by o.id desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | @Param("endTime") String endTime, |
| | | @Param("deptid") Integer deptid); |
| | | |
| | | /** |
| | | * 代理商查看旗下分公司账号 |
| | | * @param page |
| | | * @param dataScope |
| | | * @param name |
| | | * @param beginTime |
| | | * @param endTime |
| | | * @param deptid |
| | | * @param officeIds |
| | | * @return |
| | | */ |
| | | List<Map<String, Object>> getUserListPageAgent(Page<Map<String, Object>> page, |
| | | DataScope dataScope, |
| | | String name, |
| | | String beginTime, |
| | | String endTime, |
| | | Integer deptid, |
| | | List<Integer> officeIds); |
| | | } |
| | |
| | | model.addAttribute("driverCount",drivers.size()); |
| | | // 司机充值计算 |
| | | List<Integer> driverIds = drivers.stream().map(TDriver::getId).collect(Collectors.toList()); |
| | | List<TRechargeRecord> tRechargeRecords = tRechargeRecordMapper.selectList(new EntityWrapper<TRechargeRecord>().in("userId", driverIds) |
| | | .eq("type", UserTypeEnum.DRIVER.getCode()) |
| | | List<TRechargeRecord> tRechargeRecords = tRechargeRecordMapper.selectList(new EntityWrapper<TRechargeRecord>() |
| | | .in("userId", driverIds) |
| | | .eq("type", UserTypeEnum.AGENT.getCode()) |
| | | .eq("payStatus", PayStatusEnum.FINISH.getCode())); |
| | | if(CollectionUtils.isEmpty(tRechargeRecords)){ |
| | | model.addAttribute("driverRecharge",BigDecimal.ZERO); |
| | |
| | | tAgentResp.setDriverCount(drivers.size()); |
| | | // 司机充值计算 |
| | | List<Integer> driverIds = drivers.stream().map(TDriver::getId).collect(Collectors.toList()); |
| | | List<TRechargeRecord> tRechargeRecords = tRechargeRecordMapper.selectList(new EntityWrapper<TRechargeRecord>().in("userId", driverIds) |
| | | .eq("type", UserTypeEnum.DRIVER.getCode()) |
| | | List<TRechargeRecord> tRechargeRecords = tRechargeRecordMapper.selectList(new EntityWrapper<TRechargeRecord>() |
| | | .eq("agentId", tAgent.getId()) |
| | | .eq("type", UserTypeEnum.AGENT.getCode()) |
| | | .eq("payStatus", PayStatusEnum.FINISH.getCode())); |
| | | tRechargeRecords.stream().map(TRechargeRecord::getAmount).reduce(BigDecimal::add).ifPresent(tAgentResp::setDriverRecharge); |
| | | } |
| | |
| | | public List<Map<String, Object>> getUserListPage(Page<Map<String, Object>> page, DataScope dataScope, String name, String beginTime, String endTime, Integer deptid) { |
| | | return this.baseMapper.getUserListPage(page, dataScope, name, beginTime, endTime, deptid); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getUserListPageAgent(Page<Map<String, Object>> page, DataScope dataScope, String name, String beginTime, String endTime, Integer deptid, List<Integer> officeIds) { |
| | | return this.baseMapper.getUserListPageAgent(page, dataScope, name, beginTime, endTime, deptid,officeIds); |
| | | } |
| | | } |