package com.demo.wjj.controller; import com.demo.wjj.po.DiggerAgent; import com.demo.wjj.po.Sale; import com.demo.wjj.service.AgentService; import com.demo.wjj.service.DiggerAgentService; import com.demo.wjj.service.SaleService; import com.demo.wjj.utils.ApiResult; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.Map; /** * icegan---新增,获取销售员信息 */ @RestController @RequestMapping("/saler") public class SaleController { private final Logger LOG = LoggerFactory.getLogger(getClass()); @Autowired private DiggerAgentService diggerAgentService; @Autowired private AgentService agentService; @Autowired private SaleService saleService; /** * 获取销售员数据 * @param agentId 商家id * @param openId 公众号id * @return */ @GetMapping("/get") public ApiResult getDiggerAgent(String agentId, String openId){ LOG.info("调用获取getDiggerAgent接口,agentId:{},openId",agentId,openId); try { Sale sale = saleService.getSale(agentId, openId); ApiResult apiResult = ApiResult.createSuccess(sale); LOG.info("调用获取销售员(/diggerAgent/get)接口成功"); LOG.debug("获取销售员(/diggerAgent/get), apiResult:{}", apiResult); return apiResult; }catch (Exception e){ LOG.error("调用获取销售员(/diggerAgent/get)接口异常",e); return ApiResult.createFailure(); } } /** * 获取支付固定保证金状态 * @param agentId 代理商id * @param openId 公众号id * @return */ @GetMapping("/getStatus") public ApiResult getStatus(@RequestParam(required = false) String agentId, @RequestParam(required = false) String openId){ if (StringUtils.isBlank(agentId)) { LOG.info("agentId为空"); return ApiResult.createFailure(); } if (StringUtils.isBlank(openId)) { LOG.info("openId为空"); return ApiResult.createFailure(); } Map map = new HashMap(); Sale sale = saleService.getSale(agentId, openId); Integer memberLevel = sale.getMemberLevel(); if(memberLevel>=2){ map.put("status","0"); }else { map.put("status","1"); } return ApiResult.createSuccess(map); } }