package com.cweb.controller.group; import com.alibaba.fastjson.JSONObject; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.BsMsg; import com.hai.entity.HighGroupCode; import com.hai.group.GroupCodeService; import com.hai.group.GroupService; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.BsMsgService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @author sum1dream */ @Controller @RequestMapping(value = "/group") @Api(value = "团购") public class GroupController { Logger log = LoggerFactory.getLogger(GroupController.class); @Resource private GroupService groupService; @Resource private GroupCodeService groupCodeService; @RequestMapping(value="/getStoreList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "商户查询门店列表") public ResponseData getStoreListByMer( @RequestParam(value = "name" , required = false) String name, @RequestParam(value = "childId" , required = false) Long childId, @RequestParam(value = "parentId" , required = false) Long parentId, @RequestParam(name = "longitude", required = false) String longitude, @RequestParam(name = "latitude", required = false) String latitude ) { try { JSONObject map = new JSONObject(); map.put("name" , name); map.put("childId" , childId); map.put("parentId" , parentId); map.put("longitude" , longitude); map.put("latitude" , latitude); JSONObject object = groupService.getStoreList(map); if (object.getString("return_code").equals("000000")) { return ResponseMsgUtil.success(object.getJSONArray("return_data")); } else { return ResponseMsgUtil.success(object.getString("return_msg")); } } catch (Exception e) { log.error(e.getMessage(), e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getGroupContent",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团购内容") public ResponseData getGroupContent(@RequestParam(value = "groupId" , required = true) Long groupId) { try { JSONObject object = groupService.getGroupContent(groupId); if (object.getString("return_code").equals("000000")) { return ResponseMsgUtil.success(object.getJSONObject("return_data")); } else { return ResponseMsgUtil.success(object.getString("return_msg")); } } catch (Exception e) { log.error(e.getMessage(), e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getGroupContentByCode",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团购内容") public ResponseData getGroupContentByCode(@RequestParam(value = "groupCode" , required = true) String groupCode) { try { Map map = new HashMap<>(); map.put("groupCode" , groupCode); HighGroupCode highGroupCode = groupCodeService.findGroupCode(map); JSONObject object = groupService.getGroupContent(highGroupCode.getGroupId()); if (object.getString("return_code").equals("000000")) { return ResponseMsgUtil.success(object.getJSONObject("return_data")); } else { return ResponseMsgUtil.success(object.getString("return_msg")); } } catch (Exception e) { log.error(e.getMessage(), e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getStoreMsg",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询门店信息") public ResponseData getStoreMsg(@RequestParam(value = "storeId" , required = true) Long storeId) { try { JSONObject object = groupService.getStoreMsg(storeId); if (object.getString("return_code").equals("000000")) { return ResponseMsgUtil.success(object.getJSONObject("return_data")); } else { return ResponseMsgUtil.success(object.getString("return_msg")); } } catch (Exception e) { log.error(e.getMessage(), e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getBsStoreImgByList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询门店图片列表") public ResponseData getBsStoreImgByList( @RequestParam(value = "type" , required = false) Integer type, @RequestParam(value = "storeId" , required = false) Long storeId) { try { JSONObject map = new JSONObject(); map.put("storeId" , storeId); map.put("type" , type); JSONObject object = groupService.getBsStoreImgByList(map); if (object.getString("return_code").equals("000000")) { return ResponseMsgUtil.success(object.getJSONArray("return_data")); } else { return ResponseMsgUtil.success(object.getString("return_msg")); } } catch (Exception e) { log.error(e.getMessage(), e); return ResponseMsgUtil.exception(e); } } }