CustomerController.java 21.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.dto.CustomerPropertyInfoDTO;
import cn.com.glsx.entmicro.model.response.CustomerClusterListResponse;
import cn.com.glsx.entmicro.model.response.CustomerRecordResponse;
import cn.com.glsx.entmicro.request.customer.*;
import cn.com.glsx.entmicro.request.portraitp.CustomerPortraitRopRequest;
import cn.com.glsx.entmicro.request.sop.SopCusSendRopRequest;
import cn.com.glsx.entmicro.response.customer.*;
import cn.com.glsx.entmicro.response.portraitp.CustomerPortraitRopResponse;
import cn.com.glsx.entmicro.service.CustomerService;
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * @author fengzhi
 * @version 1.0
 * @description: 客户模块接口
 * @date 2021/9/23 16:52
 */
@Slf4j
@Api("客户模块接口")
@ServiceMethodBean(version = "1.0.0")
@Controller
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 客户列表获取分页数据接口
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("客户列表获取分页数据接口")
    public RopResponse<Pagination<CustRes>> getCustomerPage(CustSearchRequest request) {
        try {
            return RopResponse.success(customerService.getCustomerPage(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 根据userId获取客户详情接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.detail", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据Id获取客户详情接口")
    public RopResponse<CustDetailRes> getCustomerDetail(OneIdRequest request) {
        try {
            return RopResponse.success(customerService.getCustomerDetailById(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerDetailById__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 根据userId获取客户详情接口(只返回客户的基本信息)
     *
     * @param externalUseridRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.detail.single", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据Id获取客户详情接口")
    public RopResponse<CustInfoRes> getCustomerDetailSingle(ExternalUseridRequest externalUseridRequest) {
        try {
            log.info("getCustomerDetailSingle request:{}", externalUseridRequest.toString());
            return RopResponse.success(customerService.getCustomerSingleInfoByExternalUserId(externalUseridRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerDetailById__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /***************************** 客户管理数据概览  *****************************/

    /**
     * 获取客户概览数据接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.Customer.customer.view.data", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取客户概览数据接口")
    public RopResponse<CustDataViewRes> getCustomerDataView(CustDefRequest request) {
        try {
            return RopResponse.success(customerService.getCustomerDataView(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerDataView__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 获取客户概览柱状图数据接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.view.chart", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取客户概览柱状图数据接口")
    public RopResponse<CustChartRes> getCustomerChart(DayRequest request) {
        try {
            return RopResponse.success(customerService.getCustomerChart(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerChart__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /***************************** scrm首页数据概览  *****************************/


    /**
     * 首页概览——汇总数据查询接口(商户登录)
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.home.view.shop.data", needInSession = NeedInSessionType.YES)
    @ApiOperation("汇总数据查询接口(商户登录)")
    public RopResponse<ShopCollectViewRes> getShopCollectView(DateTimeRequest request) {
        try {
            return RopResponse.success(customerService.getShopCollectView(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getShopCollectView__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 首页概览——汇总数据查询接口(门店登录)
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.home.view.store.data", needInSession = NeedInSessionType.YES)
    @ApiOperation("汇总数据查询接口(门店登录)")
    public RopResponse<StoreCollectViewRes> getStoreCollectView(DateTimeRequest request) {
        try {
            return RopResponse.success(customerService.getStoreCollectView(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getStoreCollectView__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * scrm首页概览——商户登录1-2——折线图
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.home.view.chart", needInSession = NeedInSessionType.YES)
    @ApiOperation("商户登录1-2——折线图")
    public RopResponse<ShopLineChartsResponse> getShopLineChart(DayRequest request) {
        try {
            return RopResponse.success(customerService.getShopLineChart(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getShopLineChart__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * scrm首页概览——商户登录1-3——门店企微客户排行
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.home.view.sort", needInSession = NeedInSessionType.YES)
    @ApiOperation("商户登录1-3——门店企微客户排行")
    public RopResponse<ShopCustSortRes> getShopCustSort(CustSortTypeRequest request) {
        try {
            return RopResponse.success(customerService.getShopCustSort(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getShopCustSort__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }


    /***************************** 数据侧接口  *****************************/


    /**
     * oneid变更
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.oneid.change",needInSession = NeedInSessionType.NO)
    @ApiOperation("oneid变更")
    public RopResponse<Boolean> changeOneID(ChangeOneIdRequest request) {
        try {
            return RopResponse.success(customerService.changeOneID(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__changeOneID__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 变更客户信息
     *
     * @param customerMagicRequestRop
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.editcustomer",needInSession = NeedInSessionType.NO)
    @ApiOperation("变更客户信息")
    public RopResponse<Boolean> editcustomer(CustomerMagicRequestRop customerMagicRequestRop) {
        try {
            return RopResponse.success(customerService.editcustomer(customerMagicRequestRop));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__editcustomer__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 客户数据变更
     *
     * @param customerMagicRequestRop
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.editdata",needInSession = NeedInSessionType.YES)
    @ApiOperation("客户数据变更")
    public RopResponse<Boolean> editCustomerData(CustomerMagicRequestRop customerMagicRequestRop) {
        try {
            return RopResponse.success(customerService.editCustomerData(customerMagicRequestRop));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__editCustomerData__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 客户概览列表导出
     *
     * @param custListSearchRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.customerViewExport", needInSession = NeedInSessionType.YES)
    @ApiOperation("客户概览列表导出")
    public RopResponse<String> customerViewExport(CustListSearchRequest custListSearchRequest) {
        try {
            return RopResponse.success(customerService.customerViewExport(custListSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__customerViewExport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 客户列表导出
     *
     * @param custListSearchRequest 客户列表导出
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.customerListExport", needInSession = NeedInSessionType.YES)
    @ApiOperation("客户列表导出")
    public RopResponse<String> customerListExport(CustListSearchRequest custListSearchRequest) {
        try {
            return RopResponse.success(customerService.customerListExport(custListSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__customerListExport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 一客一群-根据客户外部联系人Id获取客户详情接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.externalUserId", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据客户外部联系人Id获取客户详情接口(一客一群使用)")
    public RopResponse<CustDetailRes> groupOneCustomerDetailByExternalUserId(OneIdRequest request) {
        try {
            return RopResponse.success(customerService.groupOneCustomerDetailById(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__groupOneCustomerDetailByExternalUserId__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 渠道活码客户列表获取分页数据接口
     *
     * @param request 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.code.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("渠道活码客户列表获取分页数据接口")
    public RopResponse<Pagination<CustRes>> getCodeCustomerByPage(CustSearchRequest request) {
        try {
            return RopResponse.success(customerService.getCodeCustomerByPage(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCodeCustomerByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }


    /***************************** 分群客户列表  *****************************/


    /**
     * 获取客户分群列表数据接口
     *
     * @param custSearchRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.cluster.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取客户分群列表数据接口")
    public RopResponse<Pagination<CustomerClusterListResponse>> getCustomerClusterListPage(CustSearchRequest custSearchRequest) {
        try {
            return RopResponse.success(customerService.getCustomerClusterListByPage(custSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerClusterListPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 获取自定义分群客户列表数据接口
     *
     * @param custSearchRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.crowd.page", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取自定义分群客户列表数据接口")
    public RopResponse<Pagination<CustomerClusterListResponse>> getCrowdManagementCustomerList(CustSearchRequest custSearchRequest) {
        try {
            return RopResponse.success(customerService.getCrowdManagementCustomerList(custSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCrowdManagementCustomerList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 客户分群列表导出
     *
     * @param custSearchRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.customerClusterListExport", needInSession = NeedInSessionType.YES)
    @ApiOperation("客户分群列表导出")
    public RopResponse<String> customerClusterListExport(CustSearchRequest custSearchRequest) {
        try {
            return RopResponse.success(customerService.customerClusterListExport(custSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__customerClusterListExport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 根据标签获取客户列表
     *
     * @param custTagSearchRequest 搜索入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.getCustomerPageByTag", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据标签获取客户列表")
    public RopResponse<Pagination<CustRes>> getCustomerPageByTag(CustTagPageSearchRequest custTagSearchRequest) {
        try {
            return RopResponse.success(customerService.getCustomerPageByTag(custTagSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerPageByTag__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 根据标签获取客户列表导出
     *
     * @param custTagSearchRequest 客户列表导出
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.customerPageByTagExport", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据标签获取客户列表导出")
    public RopResponse<String> customerPageByTagExport(CustTagSearchRequest custTagSearchRequest) {
        try {
            return RopResponse.success(customerService.customerPageByTagExport(custTagSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__customerPageByTagExport__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 脚本 - 批量添加客户数据性能测试用
     */
    @ServiceMethod(method = "entmicro.api.customer.addBatchMagicCustomer.script", needInSession = NeedInSessionType.NO)
    @ApiOperation("脚本 - 批量添加客户数据性能测试用")
    public RopResponse<Boolean> addBatchMagicCustomerScript(CustSearchRequest custSearchRequest) {
        try {
            return RopResponse.success(customerService.addBatchMagicCustomerScript(custSearchRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__addBatchMagicCustomer__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 完善客户手机号
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.perfectCustomerPhone", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据userId完善客户手机号返回客户oneId")
    public RopResponse<String> perfectCustomerPhone(CustSearchRequest request) {
        try {
            return RopResponse.success(customerService.perfectCustomerPhone(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__perfectCustomerPhone__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

 /*   @ServiceMethod(method = "entmicro.api.customer.customerMergeDataCompare", needInSession = NeedInSessionType.YES)
    @ApiOperation("客户合并表数据比对接口")
    public RopResponse<Boolean> customerMergeDataCompare(CustCompareRequest request) {
        try {
            return RopResponse.success(customerService.customerMergeDataCompare(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__customerMergeDataCompare__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }*/


    /**
     * 客户跟进记录
     */
    @ServiceMethod(method = "entmicro.api.customer.record", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据Id获取客户跟进记录列表")
    public RopResponse<List<CustomerRecordResponse>> getCustomerRecords(CustomerRecordReq request) {
        try {
            return RopResponse.success(customerService.getCustomerRecords(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getCustomerRecords__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 获取用户物业信息
     */
    @ServiceMethod(method = "entmicro.api.customer.property.message.get", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取用户物业信息")
    public RopResponse<CustomerPropertyInfoDTO> getUserPropertyMessageByOneId(OneIdRequest request) {
        try {
            return RopResponse.success(customerService.getUserPropertyMessageByOneId(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__getUserPropertyMessageByOneId__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 更新用户物业信息
     */
    @ServiceMethod(method = "entmicro.api.customer.property.message.update", needInSession = NeedInSessionType.YES)
    @ApiOperation("更新用户物业信息")
    public RopResponse<Boolean> updateUserPropertyMessageByOneId(CustomerPropertyInfoRequest request) {
        try {
            return RopResponse.success(customerService.updateUserPropertyMessageByOneId(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__updateUserPropertyMessageByOneId__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 客户画像展示
     */
    @ServiceMethod(method = "entmicro.api.customer.portrait.view", needInSession = NeedInSessionType.NO)
    @ApiOperation("客户画像展示")
    public RopResponse<CustomerPortraitRopResponse> viewCustomerPortrait(CustomerPortraitRopRequest request) {
        try {
            return RopResponse.success(customerService.viewCustomerPortrait(request));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__viewCustomerPortrait__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 推送企微客户到sop
     *
     * @param sopCusSendRopRequest 入参
     * @return
     */
    @ServiceMethod(method = "entmicro.api.customer.sendCustomerToSop",needInSession = NeedInSessionType.NO)
    @ApiOperation("推送企微客户到sop")
    public RopResponse<Boolean> sendCustomerToSop(SopCusSendRopRequest sopCusSendRopRequest) {
        try {
            return RopResponse.success(customerService.sendCustomerToSop(sopCusSendRopRequest));
        } catch (RpcServiceException e) {
            log.info("=======CustomerController__invoke__sendCustomerToSop__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }
}