Просмотр исходного кода

[招商]adjust

release_toaliyun_real
Burce 6 лет назад
Родитель
Сommit
63aee79f9a
9 измененных файлов: 122 добавлений и 107 удалений
  1. +3
    -4
      mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java
  2. +0
    -19
      mallinkAdmin/src/main/resources/db/migration/V201909261900__W_INVEST_MENU.sql
  3. +0
    -78
      mallinkAdmin/src/main/resources/db/migration/V201909261910__W_INVEST_CREATE.sql
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  5. +15
    -5
      mallinkService/src/main/java/com/iformall/domain/po/BaseInvestEntity.java
  6. +10
    -1
      mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java
  7. +6
    -0
      mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java
  8. +22
    -0
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java
  9. +63
    -0
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java

+ 3
- 4
mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java Просмотреть файл

@@ -1,12 +1,11 @@
package com.iformall.log;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

@@ -15,10 +14,10 @@ import java.util.Arrays;
/**
*
*/
@Slf4j
@Aspect
@Component
public class TableOperateAspect {
private final Logger log = LoggerFactory.getLogger(TableOperateAspect.class);

private final Environment env;

@@ -33,7 +32,7 @@ public class TableOperateAspect {
@Around("pointcut()")
public Object round(ProceedingJoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
log.debug("before , {}.{}() with argument[s] = {}", signature.getClass(),
log.debug("before , {}.{}() with argument[s] = {}", signature.getDeclaringType(),
signature.getName(), Arrays.toString(joinPoint.getArgs()));
Object object = null;
try {


+ 0
- 19
mallinkAdmin/src/main/resources/db/migration/V201909261900__W_INVEST_MENU.sql Просмотреть файл

@@ -1,19 +0,0 @@
INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`)
VALUES
(11, '招商管理', 0, 'Y', NULL, 0, '#d4237a', '212,35,122', NULL, NULL, 0, 11);

INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`)
VALUES
(1001, '招商概览', 11, 'Y', NULL, 1, '#d4237a', '212,35,122', 'InvestPromotion', NULL, 0, 1);

INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`)
VALUES
(1002, '我的招商任务', 11, 'Y', NULL, 1, '#d4237a', '212,35,122', 'InvestTask', NULL, 0, 2);

INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`)
VALUES
(1003, '我的客户管理', 11, 'Y', NULL, 1, '#d4237a', '212,35,122', 'InvestCustomer', NULL, 0, 3);

INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`)
VALUES
(1004, '品牌库', 11, 'Y', NULL, 1, '#d4237a', '212,35,122', 'brandlist', NULL, 0, 4);

+ 0
- 78
mallinkAdmin/src/main/resources/db/migration/V201909261910__W_INVEST_CREATE.sql Просмотреть файл

@@ -1,84 +0,0 @@
CREATE TABLE `invest_task` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`owner` json DEFAULT NULL COMMENT '负责人',
`status` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '任务状态:-1-关闭;0-待分配;1-洽谈中;2-意向签约;3-已完成',
`target_type` SMALLINT(2) NOT NULL DEFAULT '0' COMMENT '目标类型:0-商铺招租;1-其他',
`target_id` BIGINT(20) NOT NULL COMMENT '目标ID',
`content` json DEFAULT NULL COMMENT '任务设定条件',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='招商任务';

CREATE TABLE `invest_demand` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`owner` BIGINT(20) DEFAULT NULL COMMENT '负责人',
`customer_id` BIGINT(20) NOT NULL COMMENT '客户ID',
`intent` json DEFAULT NULL COMMENT '客户意向',
`target_type` SMALLINT(2) NOT NULL DEFAULT '0' COMMENT '目标类型:0-商铺招租;1-其他',
`target_id` BIGINT(20) NOT NULL COMMENT '目标ID',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='客户需求';

CREATE TABLE `invest_remind` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`owner` BIGINT(20) NOT NULL COMMENT '提醒用户',
`content` json DEFAULT NULL COMMENT '提醒内容',
`minute` BIGINT(6) NOT NULL COMMENT '提醒时间',
`begin_date` DATETIME NOT NULL COMMENT '开始时间',
`end_date` DATETIME NOT NULL COMMENT '结束时间',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='招商提醒';

CREATE TABLE `invest_customer` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`name` VARCHAR(30) NOT NULL COMMENT '客户名称',
`phone` VARCHAR(20) NOT NULL COMMENT '电话',
`business` int(11) NOT NULL COMMENT '经营业态',
`brand_id` BIGINT(20) NOT NULL COMMENT '品牌ID',
`type` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败',
`rating` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙' ,
`invest_channel` VARCHAR(10) NOT NULL COMMENT '招商渠道:0-无;1-电视;2-广播;3-报纸;4-刊物;5-物联网;6-招商活动;7-中介机构;8-自定义渠道',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='客户列表';

CREATE TABLE `invest_follow_record` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`owner` BIGINT(20) NOT NULL COMMENT '主谈人',
`customer_id` BIGINT(20) NOT NULL COMMENT '客户ID',
`content` json NOT NULL COMMENT '洽谈内容',
`type` SMALLINT(2) NOT NULL COMMENT '跟踪类型:0-招商任务;1-客户需求',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='跟踪记录';

CREATE TABLE `invest_operate_record` (
`id` BIGINT(20) NOT NULL COMMENT '主键ID',
`tenant_id` VARCHAR(10) NOT NULL COMMENT '租户ID',
`tbl` VARCHAR(30) DEFAULT NULL COMMENT '表名称',
`tid` BIGINT(20) NOT NULL COMMENT '主键ID',
`operator` BIGINT(20) NOT NULL DEFAULT '0' COMMENT '操作人:0-系统;其它',
`operate_type` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '操作类型:0-ADD;1-UPDATE;2-DELETE',
`before` json DEFAULT NULL COMMENT '更新前',
`after` json DEFAULT NULL COMMENT '更新后',
`create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COMMENT='操作记录';

+ 3
- 0
mallinkService/src/main/java/com/iformall/common/ErrorCode.java Просмотреть файл

@@ -514,6 +514,9 @@ public enum ErrorCode{
*/
POWER_BILL_CONFIGU_NOT_FOUND(50001, "未配置电费账单生成规则"),

// 品牌 51000 begin
BRAND_NOT_FOUND(51000, "品牌不存在"),
// 品牌 52000 end

;



+ 15
- 5
mallinkService/src/main/java/com/iformall/domain/po/BaseInvestEntity.java Просмотреть файл

@@ -1,5 +1,6 @@
package com.iformall.domain.po;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -11,10 +12,7 @@ import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;

/**
* @author luozukai
@@ -125,7 +123,7 @@ public class BaseInvestEntity implements Serializable {
* @param camelCaseName
* @return
*/
private static String underscoreName(String camelCaseName) {
private String underscoreName(String camelCaseName) {
StringBuilder result = new StringBuilder();
if (camelCaseName != null && camelCaseName.length() > 0) {
result.append(camelCaseName.substring(0, 1).toLowerCase());
@@ -158,7 +156,19 @@ public class BaseInvestEntity implements Serializable {
sb.append(fields[k].toString());
}
this.sortColumns=sb.toString();
}

/**
* json数组转Long集合
*
* @return
*/
public List<Long> parseJsonArray(String json) {
if (Objects.nonNull(json)) {
List<Long> ids = JSONArray.parseArray(json, Long.class);
return ids;
}
return null;
}

public enum SortField {


+ 10
- 1
mallinkService/src/main/java/com/iformall/service/MallUserInfoService.java Просмотреть файл

@@ -2,10 +2,11 @@ package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallPermission;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.vo.MallUserInfoVo;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Set;

@@ -75,6 +76,14 @@ public interface MallUserInfoService {
MallUserInfo getById(Long id);

/**
* 根据Id获得实体
*
* @param ids
* @return
*/
List<MallUserInfo> getByIds(Collection<? extends Serializable> ids);

/*
* 保存或更新实体
*
* @param record


+ 6
- 0
mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java Просмотреть файл

@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

@@ -64,6 +65,11 @@ public class MallUserInfoServiceImpl implements MallUserInfoService {
return mallUserInfoMapper.getById(id);
}

@Override
public List<MallUserInfo> getByIds(Collection<? extends Serializable> ids) {
return mallUserInfoMapper.selectBatchIds(ids) ;
}

@Override
public MallUserInfo getByBOpenId(String openId, String tenantId) {
return mallUserInfoMapper.selectByBOpenId(openId, tenantId);


+ 22
- 0
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestCustomerServiceImpl.java Просмотреть файл

@@ -2,17 +2,30 @@ package com.iformall.service.invest.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iformall.common.ErrorCode;
import com.iformall.common.TableLog;
import com.iformall.domain.po.InvestCustomerEntity;
import com.iformall.domain.po.WxBrand;
import com.iformall.domain.po.WxBusiness;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.InvestCustomerDao;
import com.iformall.service.WxBrandService;
import com.iformall.service.WxBusinessService;
import com.iformall.service.invest.InvestCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class InvestCustomerServiceImpl extends ServiceImpl<InvestCustomerDao, InvestCustomerEntity> implements InvestCustomerService {

@Autowired
private WxBrandService brandService;
@Autowired
private WxBusinessService businessService ;

@Override
public List queryPage(InvestCustomerEntity params) {
return this.list();
@@ -21,6 +34,15 @@ public class InvestCustomerServiceImpl extends ServiceImpl<InvestCustomerDao, In
@TableLog
@Override
public boolean save(InvestCustomerEntity entity) {
WxBrand brand = brandService.getById(entity.getBrandId());
if (Objects.isNull(brand)) {
throw new MallinkException(ErrorCode.BRAND_NOT_FOUND);
}

if (Objects.isNull(entity.getType())) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),
ErrorCode.SYS_PARAMETER_NOT_NULL.getMessage("type"));
}
return super.save(entity);
}



+ 63
- 0
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java Просмотреть файл

@@ -1,19 +1,37 @@
package com.iformall.service.invest.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.iformall.common.ErrorCode;
import com.iformall.common.TableLog;
import com.iformall.domain.po.InvestTaskEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxShop;
import com.iformall.enums.EnumInvestType;
import com.iformall.enums.EnumShopStatus;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.InvestTaskDao;
import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxShopService;
import com.iformall.service.invest.InvestTaskService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


@Service
public class InvestTaskServiceImpl extends ServiceImpl<InvestTaskDao, InvestTaskEntity> implements InvestTaskService {

@Autowired
private WxShopService shopService;
@Autowired
private MallUserInfoService userInfoService;

@Override
public List queryPage(InvestTaskEntity params) {
return this.list() ;
@@ -22,24 +40,69 @@ public class InvestTaskServiceImpl extends ServiceImpl<InvestTaskDao, InvestTask
@TableLog
@Override
public boolean save(InvestTaskEntity entity) {
// 1 check shop 状态
checkShop(entity);
// 2 check user
checkUserExit(entity);

return super.save(entity);
}

@TableLog
@Override
public boolean update(InvestTaskEntity entity, Wrapper<InvestTaskEntity> updateWrapper) {
// 1 check shop 状态
checkShop(entity);
// 2 check user
checkUserExit(entity);
return super.update(entity, updateWrapper);
}

@TableLog
@Override
public boolean saveOrUpdate(InvestTaskEntity entity) {
// 1 check shop 状态
checkShop(entity);
// 2 check user
checkUserExit(entity);
return super.saveOrUpdate(entity);
}

@TableLog
@Override
public boolean updateById(InvestTaskEntity entity) {
// 1 check shop 状态
checkShop(entity);
// 2 check user
checkUserExit(entity);
return super.updateById(entity);
}

private void checkShop(InvestTaskEntity entity) {
if (EnumInvestType.SHOP.equals(entity.getTargetType())) {
WxShop shop = shopService.getById(entity.getTargetId());
if (Objects.isNull(shop)) {
throw new MallinkException(ErrorCode.SHOP_IS_NOT_FOUND);
}

if (Objects.equals(shop.getStatus(), EnumShopStatus.RENT.getCode())) {
throw new MallinkException(ErrorCode.SHOP_IS_RENT);
}
}
}

/**
* 校验用户是否存在
* @param entity
*/
private void checkUserExit(InvestTaskEntity entity) {
List<Long> userIds = entity.parseJsonArray(entity.getOwner());
if (CollectionUtils.isNotEmpty(userIds)) {
List<Long> usersFromDb = userInfoService.getByIds(userIds).stream().map(MallUserInfo::getId).collect(Collectors.toList());
List<Long> notExsitIds = userIds.stream().filter(uid -> !usersFromDb.contains(uid)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(notExsitIds)) {
throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), notExsitIds + ErrorCode.USER_IS_EMPTY.getMessage());
}
}
}
}

Загрузка…
Отмена
Сохранить