package com.platform.yijia.controller; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.platform.yijia.service.CustomerGradeServices; import com.platform.yijia.utils.CodeMsg; import com.platform.yijia.utils.ResultData; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; /** * 客户优惠和营销 */ @Controller @RequestMapping("/api") public class CustomerGradeController { private static Logger logger =(Logger) LoggerFactory.getLogger(CustomerGradeController.class); @Resource private CustomerGradeServices customerGradeServices; /* * 查询直降客户等级条件和优惠 * @param stationId * @return */ @RequestMapping(value = "/getCustomerGradeList", method = RequestMethod.GET) @ResponseBody public String getCustomerGradeList(@RequestParam("stationId") String stationId){ Gson gson =new Gson(); ResultData resultData =null; if(StringUtils.isNotBlank(stationId)){ Map params = new HashMap(); params.put("stationId", stationId); resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params)); }else { resultData=ResultData.error(CodeMsg.SEARCH_FAIL); } return gson.toJson(resultData); } /* * 查询客户等级信息 * @param jsonObject * @return */ @RequestMapping(value = "/getCustomerGradeInfo", method = RequestMethod.POST) @ResponseBody public String getCustomerGradeInfo(@RequestBody JSONObject jsonObject){ Gson gson =new Gson(); ResultData resultData =null; Map params = new HashMap<>(); //oilName params.put("oilName", jsonObject.get("oilName")); params.put("mobilePhone", jsonObject.get("mobilePhone")); params.put("stationId", jsonObject.get("stationId")); params.put("userType", jsonObject.get("userType")); //params.put("grade", jsonObject.get("grade")); switch (jsonObject.get("userType").toString()){ case "1": params.put("blogOpenid", jsonObject.get("openId").toString()); break; case "2": params.put("minaOpenid", jsonObject.get("openId").toString()); break; } logger.info("查询客户等级所传参数:"+params.toString()); if(jsonObject.get("discountPlanType").toString().equals("直降")){ //直降 resultData = ResultData.success(customerGradeServices.getCustomerGradeInfo(params)); }else { //营销优惠立减 满减 params.put("discountPlanType", jsonObject.get("discountPlanType").toString()); resultData = ResultData.success(customerGradeServices.getCustomerGradeInfoByYouHui(params)); } return gson.toJson(resultData); } }