| | |
| | | package com.xzx.gc.user.controller; |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.xzx.gc.common.constant.CommonEnum; |
| | | import com.xzx.gc.common.constant.Constants; |
| | | import com.xzx.gc.common.dto.log.OperationAppLog; |
| | | import com.xzx.gc.common.request.BaseController; |
| | | import com.xzx.gc.entity.AccountInfo; |
| | | import com.xzx.gc.entity.RedPaperRule; |
| | | import com.xzx.gc.entity.UserHeadRelate; |
| | | import com.xzx.gc.model.JsonResult; |
| | | import com.xzx.gc.model.admin.ExportParamModel; |
| | | import com.xzx.gc.model.admin.PromoterModel; |
| | | import com.xzx.gc.model.admin.UserModel; |
| | | import com.xzx.gc.user.dto.*; |
| | | import com.xzx.gc.user.mapper.AccountMapper; |
| | | import com.xzx.gc.user.mapper.RedPaperRuleMapper; |
| | | import com.xzx.gc.user.mapper.UserHeadRelateMapper; |
| | | import com.xzx.gc.user.service.DistribService; |
| | | import com.xzx.gc.user.vo.DistribInfoListVo; |
| | | import com.xzx.gc.user.vo.DistribListVo; |
| | | import com.xzx.gc.user.vo.ViewSettingVo; |
| | | import com.xzx.gc.user.vo.*; |
| | | import com.xzx.gc.util.DoubleUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import io.swagger.annotations.ApiResponses; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private AccountMapper accountMapper; |
| | | |
| | | @Autowired |
| | | private UserHeadRelateMapper userHeadRelateMapper; |
| | | |
| | | /** |
| | | * 查看分銷系統设置详情 |
| | |
| | | @ApiOperation(value="分銷系統管理--新增团长", notes="test: 仅0有正确返回") |
| | | public JsonResult adddistrib(@RequestBody AdddistribDto model, HttpServletRequest request) { |
| | | String id = model.getId(); |
| | | AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(accountInfo)){ |
| | | return JsonResult.failMessage("账户不存在!"); |
| | | List<String> ids = StrUtil.split(id, ','); |
| | | // AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); |
| | | List<AccountInfo> accountInfos = accountMapper.selectAccountInfoByIds(ids); |
| | | if (CollUtil.isNotEmpty(accountInfos)) { |
| | | for (AccountInfo accountInfo : accountInfos) { |
| | | // if(ObjectUtil.isEmpty(accountInfo)){ |
| | | // return JsonResult.failMessage("账户不存在!"); |
| | | // } |
| | | if(ObjectUtil.isEmpty(accountInfo.getIsHead()) |
| | | || accountInfo.getIsHead() == 1){ |
| | | return JsonResult.failMessage(accountInfo.getAccountName() + "账户不能重复添加!"); |
| | | } |
| | | if(ObjectUtil.isEmpty(accountInfo.getDelFlag()) |
| | | || accountInfo.getDelFlag() == 1){ |
| | | return JsonResult.failMessage(accountInfo.getAccountName() + "账户已删除!"); |
| | | } |
| | | if(ObjectUtil.isEmpty(accountInfo.getIsProhibit()) |
| | | || "1".equals(accountInfo.getIsProhibit())){ |
| | | return JsonResult.failMessage(accountInfo.getAccountName() + "账户已冻结!"); |
| | | } |
| | | //团员不能当团长 |
| | | String userId = accountInfo.getUserId(); |
| | | UserHeadRelate userHeadRelate = userHeadRelateMapper.selectMemberByUserId(userId); |
| | | if(ObjectUtil.isNotEmpty(userHeadRelate)){ |
| | | return JsonResult.failMessage(accountInfo.getAccountName() + "账户不能申请成为团长!"); |
| | | } |
| | | distribService.adddistrib(model); |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.USER_MODUL_NAME).operateAction("分銷系統管理--新增团长-"+id).build(); |
| | | mqUtil.sendApp(build); |
| | | } |
| | | |
| | | return JsonResult.success("操作成功!"); |
| | | } else { |
| | | return JsonResult.failMessage("参数错误"); |
| | | } |
| | | if(ObjectUtil.isEmpty(accountInfo.getIsHead()) |
| | | || accountInfo.getIsHead() == 1){ |
| | | return JsonResult.failMessage("账户不能重复添加!"); |
| | | } |
| | | if(ObjectUtil.isEmpty(accountInfo.getDelFlag()) |
| | | || accountInfo.getDelFlag() == 1){ |
| | | return JsonResult.failMessage("账户已删除!"); |
| | | } |
| | | if(ObjectUtil.isEmpty(accountInfo.getIsProhibit()) |
| | | || accountInfo.getIsProhibit() == "1"){ |
| | | return JsonResult.failMessage("账户已冻结!"); |
| | | } |
| | | distribService.adddistrib(model); |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.USER_MODUL_NAME).operateAction("分銷系統管理--新增团长-"+id).build(); |
| | | mqUtil.sendApp(build); |
| | | return JsonResult.success("操作成功!"); |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "团长列表") |
| | |
| | | return JsonResult.success(distribService.distribInfoList(distribInfoListDto)); |
| | | } |
| | | |
| | | /** |
| | | * 查看团长信息详情-个人信息 |
| | | */ |
| | | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/distrib/viewDistribInfo.json") |
| | | @ApiResponses({@ApiResponse( code = 200, message = "success", response = ViewDistribInfoVo.class)}) |
| | | @ApiOperation(value="团长列表-个人信息详情", notes="test: 仅0有正确返回") |
| | | public JsonResult<ViewDistribInfoVo> viewDistribInfo(@RequestBody ViewDistribInfoDto viewDistribInfoDto) { |
| | | String id = viewDistribInfoDto.getId(); |
| | | AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(accountInfo)){ |
| | | return JsonResult.failMessage("账户不存在!"); |
| | | } |
| | | ViewDistribInfoVo viewDistribInfoVo = distribService.viewDistribInfo(id); |
| | | return JsonResult.success(viewDistribInfoVo); |
| | | } |
| | | |
| | | @ApiOperation(value = "团长列表-团队信息") |
| | | @ApiResponses( |
| | | @ApiResponse(code = 200, message = "success", response = UserHeadInfoVo.class) |
| | | ) |
| | | @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/distrib/userHeadInfoList.json") |
| | | public JsonResult<Map<String, Object>> userHeadInfoList(@RequestBody UserHeadInfoListDto userHeadInfoListDto) { |
| | | return JsonResult.success(distribService.userHeadInfoList(userHeadInfoListDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "团长列表-订单详情") |
| | | @ApiResponses( |
| | | @ApiResponse(code = 200, message = "success", response = OrderItemsVo.class) |
| | | ) |
| | | @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/distrib/orderItemsList.json") |
| | | public JsonResult<Map<String, Object>> orderItemsList(@RequestBody UserHeadInfoListDto userHeadInfoListDto) { |
| | | return JsonResult.success(distribService.orderItemsList(userHeadInfoListDto)); |
| | | } |
| | | |
| | | /** |
| | | * 启用禁用团长 |
| | | */ |
| | | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/distrib/prohibitDistrib.json") |
| | | @ApiOperation(value="分銷系統管理--启用禁用团长", notes="test: 仅0有正确返回") |
| | | public JsonResult prohibitDistrib(@RequestBody ProhibitDistribDto model, HttpServletRequest request) { |
| | | String id = model.getId(); |
| | | AccountInfo accountInfo = accountMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(accountInfo)){ |
| | | return JsonResult.failMessage("账户不存在!"); |
| | | } |
| | | distribService.prohibitDistrib(model); |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.USER_MODUL_NAME).operateAction("分銷系統管理--启用禁用团长-"+id).build(); |
| | | mqUtil.sendApp(build); |
| | | return JsonResult.success("操作成功!"); |
| | | } |
| | | |
| | | @ApiOperation(value = "团长数据--头部") |
| | | @ApiResponses( |
| | | @ApiResponse(code = 200, message = "success", response = DistribDataInfoVo.class) |
| | | ) |
| | | @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/distrib/distribDataInfo.json") |
| | | public JsonResult<DistribDataInfoVo> distribDataInfo(@RequestBody DistribDataInfoDto distribDataInfoDto) { |
| | | return JsonResult.success(distribService.distribDataInfo(distribDataInfoDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "团长数据--列表") |
| | | @ApiResponses( |
| | | @ApiResponse(code = 200, message = "success", response = DistribDataListVo.class) |
| | | ) |
| | | @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/distrib/distribDataList.json") |
| | | public JsonResult<Map<String, Object>> distribDataList(@RequestBody DistribDataListDto distribDataListDto) { |
| | | return JsonResult.success(distribService.distribDataList(distribDataListDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "团长数据--列表导出",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) |
| | | @PostMapping(value = Constants.ADMIN_VIEW_PREFIX + "/distrib/distribDataExport.json") |
| | | public void distribDataExport(@RequestBody ExportDistribDataListDto distribDataListDto, HttpServletRequest request, HttpServletResponse response) { |
| | | List<List<String>> rows = new ArrayList<>(); |
| | | List<String> header=new ArrayList<>(); |
| | | //标题 |
| | | header=CollUtil.newArrayList( "团长名称", "手机号", "身份", "团员数量", "交易单数", "累计积分收益", "累计环保币收益", "累计订单重量(kg)","累计订单数量(家电)"); |
| | | rows.add(header); |
| | | Map<String, Object> stringObjectMap = distribService.distribDataExport(distribDataListDto); |
| | | List<DistribDataListVo> distribDataListVos = (List<DistribDataListVo>) stringObjectMap.get("data"); |
| | | if (CollUtil.isNotEmpty(distribDataListVos)) { |
| | | for(DistribDataListVo m : distribDataListVos){ |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(m.getNickname()); |
| | | list.add(m.getPhone()); |
| | | list.add("团长"); |
| | | list.add(m.getCnt().toString()); |
| | | list.add(m.getOrderCnt()); |
| | | list.add(m.getScore()); |
| | | list.add(m.getAmount()); |
| | | list.add(m.getKg()); |
| | | list.add(m.getJdsl()); |
| | | rows.add(list); |
| | | } |
| | | } |
| | | //导出 |
| | | export(rows,response); |
| | | |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.USER_MODUL_NAME).operateAction("用户导出-团长数据").build(); |
| | | mqUtil.sendApp(build); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |