| @@ -4,14 +4,11 @@ import com.alibaba.fastjson.JSON; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.InvestResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxUserDataRule; | |||
| import com.iformall.domain.vo.invest.InvestUserContext; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxUserDataRuleService; | |||
| import com.iformall.service.invest.InvestHelper; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| @@ -23,9 +20,6 @@ import java.util.function.Function; | |||
| @Slf4j | |||
| public class InvestBaseController extends BaseController { | |||
| @Autowired | |||
| private WxUserDataRuleService wxUserDataRuleService; | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| super.InitBinder(dataBinder); | |||
| @@ -39,6 +33,7 @@ public class InvestBaseController extends BaseController { | |||
| public <R, T> InvestResultData<R> execute(T params, Function<T, R> function) { | |||
| try { | |||
| log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(params)); | |||
| setUserRule(); | |||
| InvestUserContext.setUser(getUser()); | |||
| R r = function.apply(params); | |||
| return new InvestResultData(r); | |||
| @@ -57,12 +52,8 @@ public class InvestBaseController extends BaseController { | |||
| } | |||
| } | |||
| private void setDataRule() { | |||
| WxUserDataRule userDataRule = wxUserDataRuleService.findByUserId(getUserId()); | |||
| if (userDataRule == null) { | |||
| log.info("用户的数据权限未配置"); | |||
| } | |||
| EnumInvestUserType investUserType = EnumInvestUserType.getEnum(userDataRule.getType()) ; | |||
| private void setUserRule() { | |||
| EnumInvestUserType investUserType = EnumInvestUserType.getEnum(getUser().getInvestRule()) ; | |||
| InvestUserContext.setInvestUserType(investUserType); | |||
| } | |||
| @@ -26,10 +26,10 @@ public class InvestController extends InvestBaseController { | |||
| private InvestBizService bizService ; | |||
| /** | |||
| * 用户列表 | |||
| * 招商人员列表 | |||
| */ | |||
| @ApiOperation("用户列表") | |||
| @SystemControllerLog(description = "用户列表") | |||
| @ApiOperation("招商人员列表") | |||
| @SystemControllerLog(description = "招商人员列表") | |||
| @PostMapping("/users") | |||
| public InvestResultData<Collection<MallUserInfo>> userList() { | |||
| return execute(null, p -> bizService.queryUserList()); | |||
| @@ -41,6 +41,8 @@ public class MallUserInfo extends BaseEntity { | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="0 不是超管 1是超管",name="isAdmin") | |||
| private Integer isAdmin; | |||
| @io.swagger.annotations.ApiModelProperty(value="招商用户角色",name="investRule") | |||
| private Integer investRule; | |||
| @io.swagger.annotations.ApiModelProperty(value="昵称",name="nickName") | |||
| private String nickName; | |||
| @@ -2,8 +2,8 @@ package com.iformall.enums; | |||
| public enum EnumInvestUserType { | |||
| MANAGER(301, "招商管理人员"), | |||
| USER(302, "招商人员"), | |||
| MANAGER(0, "招商管理人员"), | |||
| USER(1, "招商人员"), | |||
| ; | |||
| public static EnumInvestUserType getEnum(Integer code) { | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service; | |||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| @@ -83,6 +84,13 @@ public interface MallUserInfoService { | |||
| */ | |||
| List<MallUserInfo> getByIds(Collection<? extends Serializable> ids); | |||
| /** | |||
| * | |||
| * @param queryWrapper | |||
| * @return | |||
| */ | |||
| List<MallUserInfo> selectList(Wrapper<MallUserInfo> queryWrapper) ; | |||
| /* | |||
| * 保存或更新实体 | |||
| * | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| @@ -74,6 +75,11 @@ public class MallUserInfoServiceImpl implements MallUserInfoService { | |||
| return mallUserInfoMapper.selectBatchIds(ids) ; | |||
| } | |||
| @Override | |||
| public List<MallUserInfo> selectList(Wrapper<MallUserInfo> queryWrapper) { | |||
| return mallUserInfoMapper.selectList(queryWrapper) ; | |||
| } | |||
| @Override | |||
| public MallUserInfo getByBOpenId(String openId, String tenantId) { | |||
| return mallUserInfoMapper.selectByBOpenId(openId, tenantId); | |||
| @@ -21,6 +21,10 @@ public interface InvestBizService { | |||
| InvestPageResult<InvestMessageEntity> queryPageMessage(InvestMessageQuery params) ; | |||
| /** | |||
| * 获取招商用户 | |||
| * @return | |||
| */ | |||
| Collection<MallUserInfo> queryUserList() ; | |||
| boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; | |||
| @@ -13,5 +13,6 @@ import com.iformall.domain.po.invest.InvestDemandEntity; | |||
| */ | |||
| public interface InvestDemandService extends IService<InvestDemandEntity>,InvestBaseService<InvestDemandEntity> { | |||
| InvestDemandEntity getByCustomerId(Long customerId) ; | |||
| } | |||
| @@ -15,7 +15,6 @@ import com.iformall.enums.EnumNegotiationType; | |||
| import com.iformall.service.MallUserInfoService; | |||
| import com.iformall.service.WxBrandService; | |||
| import com.iformall.service.WxShopService; | |||
| import com.iformall.service.WxUserDataRuleService; | |||
| import com.iformall.service.invest.*; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.collections.MapUtils; | |||
| @@ -54,8 +53,6 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| private WxBrandService brandService; | |||
| @Autowired | |||
| private MallUserInfoService userInfoService; | |||
| @Autowired | |||
| private WxUserDataRuleService wxUserDataRuleService; | |||
| @Override | |||
| public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { | |||
| @@ -145,7 +142,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| Collection<WxShop> shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId)); | |||
| Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId); | |||
| //3、用户信息 | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(this.queryUserList(), MallUserInfo::getId); | |||
| List<InvestTaskVo> resultList = new ArrayList<>(); | |||
| for (InvestTaskEntity item : taskList) { | |||
| WxShop shop = shopsMap.get(item.getTargetId()); | |||
| @@ -198,7 +195,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| Collection<InvestFollowRecordEntity> recordList = recordPage.getRecords(); | |||
| //2、用户信息 | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(this.queryUserList(), MallUserInfo::getId); | |||
| //3、客户 | |||
| Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId)); | |||
| @@ -295,11 +292,9 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Override | |||
| public List<MallUserInfo> queryUserList() { | |||
| WxUserDataRule query = new WxUserDataRule(); | |||
| query.setTenantId(InvestUserContext.getUser().getTenantId()); | |||
| query.setType(EnumInvestUserType.USER.getCode()); | |||
| List<WxUserDataRule> ruleList = wxUserDataRuleService.list(query); | |||
| return userInfoService.getByIds(getIds(ruleList, WxUserDataRule::getUserId)); | |||
| LambdaQueryWrapper<MallUserInfo> queryWrapper = new LambdaQueryWrapper<>(); | |||
| queryWrapper.eq(MallUserInfo::getInvestRule, EnumInvestUserType.USER.getCode()); | |||
| return userInfoService.selectList(queryWrapper); | |||
| } | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @@ -330,11 +325,11 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Override | |||
| public InvestDemandVo findDemandById(Long id) { | |||
| InvestDemandEntity demandEntity = demandService.getByIdNotNull(id); | |||
| InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); | |||
| InvestCustomerEntity customerEntity = customerService.getByIdNotNull(id); | |||
| InvestDemandEntity demandEntity = demandService.getByCustomerId(customerEntity.getId()); | |||
| WxBrand brand = brandService.getById(customerEntity.getBrandId()); | |||
| WxShop shop = shopService.getById(demandEntity.getTargetId()); | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(this.queryUserList(), MallUserInfo::getId); | |||
| return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap); | |||
| } | |||
| @@ -342,7 +337,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| public InvestTaskVo findTaskById(Long id) { | |||
| InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); | |||
| WxShop shop = shopService.getById(taskEntity.getTargetId()); | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(this.queryUserList(), MallUserInfo::getId); | |||
| return buildTaskItem(taskEntity, shop, usersMap); | |||
| } | |||
| @@ -427,7 +422,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Override | |||
| public InvestFollowRecordVo findFollowRecordById(Long id) { | |||
| InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); | |||
| Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); | |||
| Map<Long, MallUserInfo> usersMap = getMap(this.queryUserList(), MallUserInfo::getId); | |||
| InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId()); | |||
| WxBrand brand = brandService.getById(customerEntity.getBrandId()); | |||
| return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service.invest.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
| import com.iformall.common.TableLog; | |||
| import com.iformall.domain.po.invest.InvestDemandEntity; | |||
| import com.iformall.enums.EnumFollowType; | |||
| @@ -82,4 +83,12 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl<InvestDemandD | |||
| notSupport(); | |||
| return false ; | |||
| } | |||
| @Override | |||
| public InvestDemandEntity getByCustomerId(Long customerId) { | |||
| if(Objects.isNull(customerId)) { | |||
| return null ; | |||
| } | |||
| return getOne(new LambdaUpdateWrapper<InvestDemandEntity>().eq(InvestDemandEntity::getCustomerId,customerId)) ; | |||
| } | |||
| } | |||
| @@ -11,6 +11,7 @@ | |||
| <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/> | |||
| <result column="invest_rule" jdbcType="INTEGER" property="investRule"/> | |||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||
| <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/> | |||
| @@ -19,11 +20,11 @@ | |||
| </resultMap> | |||
| <sql id="allSafeColumns"> | |||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`,`web_open_id`,email | |||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,`web_open_id`,email | |||
| </sql> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`, | |||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`, | |||
| `bopen_id`,`web_open_id`,email | |||
| </sql> | |||
| @@ -68,6 +69,10 @@ | |||
| <if test=" null != isAdmin "> | |||
| and `is_admin` = #{isAdmin} | |||
| </if> | |||
| <if test=" null != investRule "> | |||
| and `invest_rule` = #{investRule} | |||
| </if> | |||
| <if test=" null != phone and ''!=phone"> | |||
| and `phone` = #{phone} | |||
| </if> | |||
| @@ -262,6 +267,7 @@ | |||
| <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/> | |||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||
| <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/> | |||
| <result column="invest_rule" jdbcType="INTEGER" property="investRule"/> | |||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||
| <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/> | |||
| @@ -275,12 +281,12 @@ | |||
| </resultMap> | |||
| <sql id="allSafeVColumns"> | |||
| u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`nick_name`,u.`phone`, | |||
| u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, | |||
| m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email | |||
| </sql> | |||
| <sql id="allVColumns"> | |||
| u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`nick_name`,u.`phone`, | |||
| u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`, | |||
| u.`bopen_id`,u.`web_open_id`, | |||
| m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email | |||
| </sql> | |||