| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | @PreAuthorize("@pms.hasPermission('business_businessCustomer_view')" ) |
| | | public R getBusinessCustomerPage(@ParameterObject Page page, @ParameterObject BusinessCustomer businessCustomer) { |
| | | |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) || |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)|| |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | LambdaQueryWrapper<BusinessCustomer> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(StrUtil.isNotEmpty(businessCustomer.getProvince()),BusinessCustomer::getProvince,businessCustomer.getProvince()); |
| | | wrapper.eq(StrUtil.isNotEmpty(businessCustomer.getIndustryId()),BusinessCustomer::getIndustryId,businessCustomer.getIndustryId()); |
| | | wrapper.like(StrUtil.isNotEmpty(businessCustomer.getCompanyName()),BusinessCustomer::getCompanyName,businessCustomer.getCompanyName()); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | // smjList.add(smjsc); |
| | | // smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | wrapper.in(BusinessCustomer::getCompId, smjList); |
| | | wrapper.orderByDesc(BusinessCustomer::getCreateTime); |
| | |
| | | @PreAuthorize("@pms.hasPermission('business_businessCustomer_view')" ) |
| | | public R getBusinessCustomerList(@ParameterObject BusinessCustomer businessCustomer) { |
| | | |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) || |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)|| |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | LambdaQueryWrapper<BusinessCustomer> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.like(StrUtil.isNotEmpty(businessCustomer.getCompanyName()),BusinessCustomer::getCompanyName,businessCustomer.getCompanyName()); |
| | | |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | // smjList.add(smjsc); |
| | | // smjList.add(smjzt); |
| | | smjList.add(smjhw); |
| | | wrapper.in(BusinessCustomer::getCompId, smjList); |
| | | List<BusinessCustomer> businessCustomerList = businessCustomerService.list(wrapper); |
| | |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_businessCustomer_add')" ) |
| | | public R save(@RequestBody BusinessCustomer businessCustomer) { |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) || |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)|| |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | if (StrUtil.isBlank(businessCustomer.getErpCompanyCode())) { |
| | | return R.failed("erp客户编码不能为空"); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(businessCustomer.getCreditCode())){ |
| | | businessCustomer.setBipCode(businessCustomer.getCreditCode()); |
| | | } |
| | | BusinessCustomer customer = null; |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjhw); |
| | | customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode, businessCustomer.getCreditCode()) |
| | | .in(BusinessCustomer::getCompId, smjList) |
| | | .last("limit 1")); |
| | | }else { |
| | | customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode, businessCustomer.getCreditCode()) |
| | | .eq(BusinessCustomer::getCompId,SecurityUtils.getUser().getCompId()) |
| | | .last("limit 1")); |
| | | } |
| | | if (ObjUtil.isNotNull(customer)){ |
| | | return R.failed("客户已存在"); |
| | | } |
| | | return R.ok(businessCustomerService.save(businessCustomer)); |
| | | } |
| | | |
| | |
| | | @PutMapping |
| | | @PreAuthorize("@pms.hasPermission('business_businessCustomer_edit')" ) |
| | | public R updateById(@RequestBody BusinessCustomer businessCustomer) { |
| | | if (StrUtil.isNotBlank(businessCustomer.getCreditCode())){ |
| | | businessCustomer.setBipCode(businessCustomer.getCreditCode()); |
| | | } |
| | | return R.ok(businessCustomerService.updateById(businessCustomer)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询客商信息 |
| | | * @param id id |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "通过id更新客户名称" , description = "通过id更新客户名称" ) |
| | | @GetMapping("/syncCustomer/{id}" ) |
| | | public R syncCustomer(@PathVariable("id" ) Long id) { |
| | | return businessCustomerService.syncCustomer(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 同步主数据 企业名称 法人 三合一码 银行信息 |
| | | * @return R |
| | | */ |