| | |
| | | package com.tcm.training.admin.agent.service; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import cn.idev.excel.FastExcel; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.tcm.training.admin.common.PageResponse; |
| | | import com.tcm.training.admin.live.entity.Clinic; |
| | | import com.tcm.training.admin.live.mapper.ClinicMapper; |
| | | import com.tcm.training.admin.utils.VzanHttpUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class ProvincialAgentAppService { |
| | | private final ProvincialAgentMapper agentMapper; |
| | | private final AgentRegionMapper regionMapper; |
| | | private final SysRegionMapper sysRegionMapper; |
| | | private final ClinicMapper clinicMapper; |
| | | private final VzanHttpUtil vzanHttpUtil; |
| | | |
| | | public ProvincialAgentAppService(ProvincialAgentMapper agentMapper, AgentRegionMapper regionMapper, |
| | | SysRegionMapper sysRegionMapper, ClinicMapper clinicMapper) { |
| | | SysRegionMapper sysRegionMapper, ClinicMapper clinicMapper, VzanHttpUtil vzanHttpUtil) { |
| | | this.agentMapper = agentMapper; |
| | | this.regionMapper = regionMapper; |
| | | this.sysRegionMapper = sysRegionMapper; |
| | | this.clinicMapper = clinicMapper; |
| | | this.vzanHttpUtil = vzanHttpUtil; |
| | | } |
| | | |
| | | public PageResponse<ProvincialAgentListItemVO> page(int page, int pageSize, String regionCode, |
| | |
| | | saveRegions(agent, request); |
| | | if (firstAgent) { |
| | | clinicMapper.update(null, new LambdaUpdateWrapper<Clinic>().set(Clinic::getAgentId, agent.getId())); |
| | | } |
| | | log.info("调用微赞创建代理,入参 agentMobile={}, agentName={}, levelCode={}, parentMobile={}, storeName={}", |
| | | request.getContactInfo(), request.getAgentName(), 2, null, request.getAgentName()); |
| | | try { |
| | | JsonNode vzanResponse = vzanHttpUtil.createAgent( |
| | | request.getContactInfo(), request.getAgentName(), 2, null, request.getAgentName()); |
| | | log.info("微赞创建代理成功,出参={}", JSONUtil.toJsonStr(vzanResponse)); |
| | | } catch (RuntimeException ex) { |
| | | log.error("微赞创建代理失败,本地事务将回滚,入参 agentMobile={}, agentName={}, levelCode={}, parentMobile={}, storeName={}", |
| | | request.getContactInfo(), request.getAgentName(), 1, null, request.getAgentName(), ex); |
| | | throw ex; |
| | | } |
| | | return detail(agent.getId()); |
| | | } |
| | |
| | | this.name = name; |
| | | } |
| | | } |
| | | } |
| | | } |