| @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.InitBinder; | |||||
| import java.beans.PropertyEditor; | import java.beans.PropertyEditor; | ||||
| import java.beans.PropertyEditorSupport; | import java.beans.PropertyEditorSupport; | ||||
| import java.util.function.BiConsumer; | import java.util.function.BiConsumer; | ||||
| import java.util.function.Consumer; | |||||
| import java.util.function.Function; | import java.util.function.Function; | ||||
| @@ -54,7 +55,7 @@ public class InvestBaseController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| public <T, U> void export(T t, U u, BiConsumer<T, U> action) { | |||||
| public <T, U> void exportData(T t, U u, BiConsumer<T, U> action) { | |||||
| try { | try { | ||||
| log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(t)); | log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(t)); | ||||
| InvestUserContext.setUser(getUser()); | InvestUserContext.setUser(getUser()); | ||||
| @@ -64,6 +65,16 @@ public class InvestBaseController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| public <T> void importData(T t, Consumer<T> action) { | |||||
| try { | |||||
| log.debug("[" + getIpAddr() + "] request , params : {}", JSON.toJSONString(t)); | |||||
| InvestUserContext.setUser(getUser()); | |||||
| action.accept(t); | |||||
| } finally { | |||||
| InvestUserContext.remove(); | |||||
| } | |||||
| } | |||||
| private void setUserRule() { | private void setUserRule() { | ||||
| EnumInvestUserType investUserType = EnumInvestUserType.getEnum(getUser().getInvestRule()) ; | EnumInvestUserType investUserType = EnumInvestUserType.getEnum(getUser().getInvestRule()) ; | ||||
| InvestUserContext.setInvestUserType(investUserType); | InvestUserContext.setInvestUserType(investUserType); | ||||
| @@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -90,7 +91,14 @@ public class InvestCustomerController extends InvestBaseController{ | |||||
| @GetMapping("/exportCustomer") | @GetMapping("/exportCustomer") | ||||
| @SystemControllerLog(description = "招商管理-导出客户信息") | @SystemControllerLog(description = "招商管理-导出客户信息") | ||||
| public void exportCustomer(InvestDemandQuery params, HttpServletResponse response) { | public void exportCustomer(InvestDemandQuery params, HttpServletResponse response) { | ||||
| export(params, response, (p, u) -> investBizService.exportCustomer(p, u)); | |||||
| exportData(params, response, (p, u) -> investBizService.exportCustomer(p, u)); | |||||
| } | |||||
| @ApiOperation("导入客户信息") | |||||
| @GetMapping("/importCustomer") | |||||
| @SystemControllerLog(description = "招商管理-导入客户信息") | |||||
| public void importCustomer(@RequestParam("file") MultipartFile mFile) { | |||||
| importData(mFile, p -> investBizService.importCustomer(p)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -5,6 +5,8 @@ import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.invest.InvestMessageEntity; | import com.iformall.domain.po.invest.InvestMessageEntity; | ||||
| import com.iformall.domain.po.invest.InvestTaskEntity; | import com.iformall.domain.po.invest.InvestTaskEntity; | ||||
| import com.iformall.domain.vo.invest.*; | import com.iformall.domain.vo.invest.*; | ||||
| import org.springframework.web.bind.annotation.RequestParam; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| @@ -16,6 +18,8 @@ public interface InvestBizService { | |||||
| void exportCustomer(InvestDemandQuery params, HttpServletResponse response); | void exportCustomer(InvestDemandQuery params, HttpServletResponse response); | ||||
| void importCustomer(@RequestParam("file") MultipartFile mFile); | |||||
| List<InvestDemandVo> queryCustomer(); | List<InvestDemandVo> queryCustomer(); | ||||
| InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params); | InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params); | ||||
| @@ -165,7 +165,7 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||||
| */ | */ | ||||
| private void checkShopNotNull(WxShop shop) { | private void checkShopNotNull(WxShop shop) { | ||||
| InvestHelper.notNull(shop, ErrorCode.SHOP_IS_NOT_FOUND); | InvestHelper.notNull(shop, ErrorCode.SHOP_IS_NOT_FOUND); | ||||
| InvestHelper.isTrue(Objects.equals(shop.getStatus(), EnumShopStatus.NOT_RENT.getCode()), ErrorCode.SHOP_IS_RENT, null); | |||||
| //InvestHelper.isTrue(Objects.equals(shop.getStatus(), EnumShopStatus.NOT_RENT.getCode()), ErrorCode.SHOP_IS_RENT, null); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -122,6 +123,11 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void importCustomer(MultipartFile mFile) { | |||||
| } | |||||
| @Override | @Override | ||||
| public List<InvestDemandVo> queryCustomer() { | public List<InvestDemandVo> queryCustomer() { | ||||
| List<InvestCustomerEntity> customerEntities = customerService.list(); | List<InvestCustomerEntity> customerEntities = customerService.list(); | ||||
| @@ -397,7 +403,9 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| customerService.save(customerEntity); | customerService.save(customerEntity); | ||||
| InvestDemandEntity demandEntity = demandDto.getDemand(); | InvestDemandEntity demandEntity = demandDto.getDemand(); | ||||
| demandEntity.setCustomerId(customerEntity.getId()); | demandEntity.setCustomerId(customerEntity.getId()); | ||||
| return demandService.save(demandEntity); | |||||
| demandService.save(demandEntity); | |||||
| saveMessage(demandEntity, demandDto.getCustomer()); | |||||
| return true; | |||||
| } | } | ||||
| @Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
| @@ -414,7 +422,20 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| if (Objects.isNull(demandEntity.getCustomerId())) { | if (Objects.isNull(demandEntity.getCustomerId())) { | ||||
| demandEntity.setCustomerId(customerId); | demandEntity.setCustomerId(customerId); | ||||
| } | } | ||||
| return demandService.updateById(demandEntity); | |||||
| demandService.updateById(demandEntity); | |||||
| saveMessage(demandEntity, demandDto.getCustomer()); | |||||
| return true; | |||||
| } | |||||
| private void saveMessage(InvestDemandEntity entity, InvestCustomerEntity customerEntity) { | |||||
| if (Objects.isNull(entity)) { | |||||
| return; | |||||
| } | |||||
| Long owner = entity.getOwner(); | |||||
| if (Objects.nonNull(owner)) { | |||||
| List<Long> ownerArray = Arrays.asList(owner); | |||||
| demandService.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE.getInfo(), EnumInvestMessageTag.CUSTOMER_CREATE, EnumFollowType.DEMAND, customerEntity.getId()); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -32,33 +32,19 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl<InvestDemandD | |||||
| @Override | @Override | ||||
| public boolean save(InvestDemandEntity entity) { | public boolean save(InvestDemandEntity entity) { | ||||
| super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||||
| saveMessage(entity); | |||||
| return true; | |||||
| return super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||||
| } | } | ||||
| @TableLog | @TableLog | ||||
| @Override | @Override | ||||
| public boolean update(InvestDemandEntity entity, Wrapper<InvestDemandEntity> updateWrapper) { | public boolean update(InvestDemandEntity entity, Wrapper<InvestDemandEntity> updateWrapper) { | ||||
| super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); | |||||
| saveMessage(entity); | |||||
| return true; | |||||
| return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); | |||||
| } | } | ||||
| @TableLog | @TableLog | ||||
| @Override | @Override | ||||
| public boolean updateById(InvestDemandEntity entity) { | public boolean updateById(InvestDemandEntity entity) { | ||||
| super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate); | |||||
| saveMessage(entity); | |||||
| return true; | |||||
| } | |||||
| private void saveMessage(InvestDemandEntity entity) { | |||||
| Long owner = entity.getOwner(); | |||||
| if (Objects.nonNull(owner)) { | |||||
| List<Long> ownerArray = Arrays.asList(owner); | |||||
| this.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE.getInfo(), EnumInvestMessageTag.CUSTOMER_CREATE, EnumFollowType.DEMAND, entity.getId()); | |||||
| } | |||||
| return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate); | |||||
| } | } | ||||
| private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { | private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { | ||||