| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxProjectConfig; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxMall; | |||
| @@ -86,4 +87,6 @@ public interface WxMallService { | |||
| List<TenantEntity> getTenantEntitys(TenantEntity tenantEntity); | |||
| PageInfo<WxMall> listAadminAsPage(WxMall wxMall, Integer pageNum, Integer pageSize); | |||
| ResultData addAadmin(WxMall wxMall); | |||
| } | |||
| @@ -3,13 +3,19 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumInvestUserType; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.mapper.WxMallBuildingMapper; | |||
| import com.iformall.mapper.WxMallFloorMapper; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| import com.iformall.service.MallUserInfoService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.PasswordHelper; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -19,6 +25,8 @@ import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.util.Assert; | |||
| import java.util.List; | |||
| import java.util.concurrent.TimeUnit; | |||
| @@ -37,6 +45,9 @@ public class WxMallServiceImpl implements WxMallService { | |||
| @Autowired | |||
| WxMallFloorMapper wxMallFloorMapper; | |||
| @Autowired | |||
| MallUserInfoService userInfoService; | |||
| @Autowired | |||
| @Qualifier("mallRedisTemplate") | |||
| RedisTemplate<String, WxMall> mallRedisTemplate; | |||
| @@ -259,4 +270,80 @@ public class WxMallServiceImpl implements WxMallService { | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public ResultData addAadmin(WxMall wxMall) { | |||
| if(wxMall.getId() == null){ | |||
| if(StringUtils.isBlank(wxMall.getBusinessHours())){ | |||
| wxMall.setBusinessHours("[]"); | |||
| } | |||
| if(StringUtils.isBlank(wxMall.getIntroduction())){ | |||
| wxMall.setIntroduction(""); | |||
| } | |||
| if(StringUtils.isBlank(wxMall.getImg())){ | |||
| wxMall.setImg(""); | |||
| } | |||
| wxMall.setTenantId("-1"); | |||
| this.save(wxMall); | |||
| wxMall.setTenantId(wxMall.getId().toString()); | |||
| } | |||
| this.update(wxMall); | |||
| boolean bChangedPhone = false; | |||
| MallUserInfo userInfo = new MallUserInfo(); | |||
| userInfo.setId(wxMall.getAdminId()); | |||
| userInfo.updateTenantInfo(wxMall.getTenantInfo()); | |||
| userInfo.setName(wxMall.getAdminName()); | |||
| userInfo.setUsername(wxMall.getAdminUsername()); | |||
| userInfo.setPhone(wxMall.getAdminPhone()); | |||
| userInfo.setPassword(wxMall.getAdminPassword()); | |||
| if(userInfo.getId() == null){ | |||
| if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){ | |||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||
| } | |||
| if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){ | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||
| } | |||
| if(StringUtils.isBlank(userInfo.getPassword())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"密码不能为空"); | |||
| } | |||
| Assert.notNull(userInfo.getPassword(), "密码不能为空"); | |||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||
| passwordHelper.encryptPassword(userInfo); | |||
| userInfo.setIsAdmin(EnumUserAdmin.ADMIN.getCode()); | |||
| userInfo.setInvestRule(EnumInvestUserType.ALL.getCode()); | |||
| }else{ | |||
| MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | |||
| if(!oldUser.getTenantId().equals(userInfo.getTenantId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"tenant_id不匹配"); | |||
| } | |||
| if (!oldUser.getUsername().equals(userInfo.getUsername())) { | |||
| if(userInfoService.cntByUserName(userInfo.getUsername()) > 0){ | |||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||
| } | |||
| } | |||
| if (!oldUser.getPhone().equals(userInfo.getPhone())) { | |||
| if(userInfoService.cntByUserPhone(userInfo.getPhone()) > 0){ | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||
| } | |||
| bChangedPhone = true; | |||
| } | |||
| if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||
| passwordHelper.encryptPassword(userInfo); | |||
| }else{ | |||
| userInfo.setPassword(null); | |||
| } | |||
| } | |||
| userInfoService.saveOrUpdate(userInfo); | |||
| if(bChangedPhone) { | |||
| // 手机号修改,清除bopen_id, 清除web_open_id | |||
| userInfoService.cleanAllOpenId(userInfo); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -2,13 +2,14 @@ package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.MallUserInfoService; | |||
| import com.iformall.service.WxMallService; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -17,6 +18,10 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxMall") | |||
| public class WxMallController extends BaseController { | |||
| @@ -24,12 +29,14 @@ public class WxMallController extends BaseController { | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Autowired | |||
| MallUserInfoService userInfoService; | |||
| @ApiOperation("查询商场集团列表") | |||
| @GetMapping(value = "/listAadmin") | |||
| @SystemControllerLog(description = "商场基础数据") | |||
| public ResultData getlistAadmin(@ModelAttribute WxMall wxMall, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getMallList"); | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::getlistAadmin"); | |||
| try { | |||
| if(wxMall == null){ | |||
| wxMall = new WxMall(); | |||
| @@ -47,7 +54,7 @@ public class WxMallController extends BaseController { | |||
| @PostMapping("addAadmin") | |||
| @SystemControllerLog(description = "商场基础数据") | |||
| public ResultData addAadmin(@RequestBody WxMall wxMall) { | |||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::getMallList"); | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::addAadmin"); | |||
| try { | |||
| if(wxMall == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| @@ -61,15 +68,56 @@ public class WxMallController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"管理员不能为空"); | |||
| } | |||
| if(StringUtils.isBlank(wxMall.getAdminPhone())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"手机号不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"管理员手机号不能为空"); | |||
| } | |||
| wxMall.setServicePhone(wxMall.getAdminPhone()); | |||
| if(wxMall.getSaleType() == null){ | |||
| wxMall.setSaleType(1); | |||
| } | |||
| if(wxMall.getAdminStatus() == null){ | |||
| wxMall.setAdminStatus(EnumYesOrNo.YES.getCode()); | |||
| } | |||
| if(wxMall.getId() == null){ | |||
| if(StringUtils.isBlank(wxMall.getAdminUsername())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"管理员帐号不能为空"); | |||
| } | |||
| if(StringUtils.isBlank(wxMall.getAdminPassword())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"管理员密码不能为空"); | |||
| } | |||
| }else{ | |||
| if(wxMall.getAdminId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"admin_id不能为空"); | |||
| } | |||
| wxMall.setAdminUsername(null); | |||
| } | |||
| return wxMallService.addAadmin(wxMall); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("查询详情") | |||
| @GetMapping(value = "/getAadmin") | |||
| @SystemControllerLog(description = "商场基础数据") | |||
| public ResultData getAadmin(String tenantId) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::getAadmin"); | |||
| try { | |||
| if(StringUtils.isBlank(tenantId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| } | |||
| Map<String,Object> map = new HashMap<>(); | |||
| WxMall mall = wxMallService.getByTenantId(tenantId); | |||
| map.put("mall",mall); | |||
| return new ResultData(); | |||
| MallUserInfo mallUserInfo = new MallUserInfo(); | |||
| mallUserInfo.setTenantId(mall.getTenantId()); | |||
| mallUserInfo. setIsAdmin(1); | |||
| List<MallUserInfo> mallUserInfoList = userInfoService.findList(mallUserInfo); | |||
| map.put("adminUser",mallUserInfoList); | |||
| return new ResultData(map); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||