CustomerGradeController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.platform.yijia.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.google.gson.Gson;
  4. import com.platform.yijia.service.CustomerGradeServices;
  5. import com.platform.yijia.utils.CodeMsg;
  6. import com.platform.yijia.utils.ResultData;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.stereotype.Controller;
  11. import org.springframework.web.bind.annotation.*;
  12. import javax.annotation.Resource;
  13. import java.util.HashMap;
  14. import java.util.Map;
  15. /**
  16. * 客户优惠和营销
  17. */
  18. @Controller
  19. @RequestMapping("/api")
  20. public class CustomerGradeController {
  21. private static Logger logger =(Logger) LoggerFactory.getLogger(CustomerGradeController.class);
  22. @Resource
  23. private CustomerGradeServices customerGradeServices;
  24. /*
  25. * 查询直降客户等级条件和优惠
  26. * @param stationId
  27. * @return
  28. */
  29. @RequestMapping(value = "/getCustomerGradeList", method = RequestMethod.GET)
  30. @ResponseBody
  31. public String getCustomerGradeList(@RequestParam("stationId") String stationId){
  32. Gson gson =new Gson();
  33. ResultData resultData =null;
  34. if(StringUtils.isNotBlank(stationId)){
  35. Map params = new HashMap();
  36. params.put("stationId", stationId);
  37. resultData = ResultData.success(customerGradeServices.getCustomerGradeList(params));
  38. }else {
  39. resultData=ResultData.error(CodeMsg.SEARCH_FAIL);
  40. }
  41. return gson.toJson(resultData);
  42. }
  43. /*
  44. * 查询客户等级信息
  45. * @param jsonObject
  46. * @return
  47. */
  48. @RequestMapping(value = "/getCustomerGradeInfo", method = RequestMethod.POST)
  49. @ResponseBody
  50. public String getCustomerGradeInfo(@RequestBody JSONObject jsonObject){
  51. Gson gson =new Gson();
  52. ResultData resultData =null;
  53. Map<String, Object> params = new HashMap<>();
  54. //oilName
  55. params.put("oilName", jsonObject.get("oilName"));
  56. params.put("mobilePhone", jsonObject.get("mobilePhone"));
  57. params.put("stationId", jsonObject.get("stationId"));
  58. params.put("userType", jsonObject.get("userType"));
  59. //params.put("grade", jsonObject.get("grade"));
  60. switch (jsonObject.get("userType").toString()){
  61. case "1":
  62. params.put("blogOpenid", jsonObject.get("openId").toString());
  63. break;
  64. case "2":
  65. params.put("minaOpenid", jsonObject.get("openId").toString());
  66. break;
  67. }
  68. logger.info("查询客户等级所传参数:"+params.toString());
  69. if(jsonObject.get("discountPlanType").toString().equals("直降")){
  70. //直降
  71. resultData = ResultData.success(customerGradeServices.getCustomerGradeInfo(params));
  72. }else {
  73. //营销优惠立减 满减
  74. params.put("discountPlanType", jsonObject.get("discountPlanType").toString());
  75. resultData = ResultData.success(customerGradeServices.getCustomerGradeInfoByYouHui(params));
  76. }
  77. return gson.toJson(resultData);
  78. }
  79. }