java版Spring Cloud+Spring Boot+mybatis+MQ前后端分离 分布式微服务架构

皮嘉德
2023-12-01

 源码地址来源: https://minglisoft.cn/honghu2/business.html

/**
 * Copyright &copy; 2012-2017 <a href="http://minglisoft.cn">HongHu</a> All rights reserved.
 */
package com.honghu.cloud.controller;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.honghu.cloud.bean.ComExamine;
import com.honghu.cloud.bean.Store;
import com.honghu.cloud.bean.StoreGrade;
import com.honghu.cloud.bean.StorePoint;
import com.honghu.cloud.bean.WareHouse;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.common.page.Page;
import com.honghu.cloud.configure.StoreVisitMqClient;
import com.honghu.cloud.dto.AreaDto;
import com.honghu.cloud.dto.CouponDto;
import com.honghu.cloud.dto.CouponInfoDto;
import com.honghu.cloud.dto.FavoriteDto;
import com.honghu.cloud.dto.FloorDto;
import com.honghu.cloud.dto.GoodsCartDto;
import com.honghu.cloud.dto.GoodsClassDto;
import com.honghu.cloud.dto.GoodsDto;
import com.honghu.cloud.dto.H5LevelBannerDto;
import com.honghu.cloud.dto.MenuDto;
import com.honghu.cloud.dto.ModularClassDto;
import com.honghu.cloud.dto.PlatformPayDto;
import com.honghu.cloud.dto.ShipAddressDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.dto.UserGoodsClassDto;
import com.honghu.cloud.dto.WareHouseDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.AreaFeignClient;
import com.honghu.cloud.feign.CouponFeignClient;
import com.honghu.cloud.feign.CouponInfoFeignClient;
import com.honghu.cloud.feign.FavoriteFeignClient;
import com.honghu.cloud.feign.FloorFeignClient;
import com.honghu.cloud.feign.GoodsClassFeignClient;
import com.honghu.cloud.feign.GoodsFeignClient;
import com.honghu.cloud.feign.IconViewFeignClient;
import com.honghu.cloud.feign.MenuFeignClient;
import com.honghu.cloud.feign.ModularClassFeignClient;
import com.honghu.cloud.feign.OrderFormFeignClient;
import com.honghu.cloud.feign.PlatformPayFeignClient;
import com.honghu.cloud.feign.ShipAddressFeignClient;
import com.honghu.cloud.feign.StoreVisitLogFeignClient;
import com.honghu.cloud.feign.TXTemplateFeignClient;
import com.honghu.cloud.feign.UserFeignClient;
import com.honghu.cloud.feign.UserGoodsClassFeignClient;
import com.honghu.cloud.service.IComExamineService;
import com.honghu.cloud.service.IOpeningTimeService;
import com.honghu.cloud.service.IStoreGradeService;
import com.honghu.cloud.service.IStorePointService;
import com.honghu.cloud.service.IStoreService;
import com.honghu.cloud.service.IStoreVisitLogService;
import com.honghu.cloud.service.IWareHouseService;
import com.honghu.cloud.service.impl.StoreVisitLogServiceImpl;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.tools.StoreTools;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.utils.Exceptions;
 
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
 
/**
 * 店铺Controller
 * 
 * @author Administrator
 * @param <E>
 *
 */
@Slf4j
@RestController
@RequestMapping(value = "/store")
public class StoreController<E> {
 
	@Autowired
	private IStoreService storeService;
	@Autowired
	private IWareHouseService wareHouseService;
	@Autowired
	private AccessoryFeignClient accessoryFeignClient;
	@Autowired
	private IStorePointService storePointService;
	@Autowired
	private AreaFeignClient areaFeignClient;
	@Autowired
	private IStoreGradeService storeGradeService;
	@Autowired
	private GoodsClassFeignClient goodsClassFeignClient;
	@Autowired
	private ModularClassFeignClient modularClassFeignClient;
	@Autowired
	private IStoreVisitLogService storeVisitLogService;
	@Autowired
	private StoreTools storeTools;
	@Autowired
	private PlatformPayFeignClient platformPayFeignClient;
	@Autowired
	private UserFeignClient userFeignClient;
	@Autowired
	private MenuFeignClient menuFeignClient;
	@Autowired
	private FavoriteFeignClient favoriteFeignClient;
	@Autowired
	private GoodsFeignClient goodsFeignClient;
	@Autowired
	private QueryTools queryTools;
	@Autowired
	private FloorFeignClient floorFeignClient;
	@Autowired
	private UserGoodsClassFeignClient UserGoodsClassFeignClient;
	@Autowired
	private StoreVisitMqClient storeVisitMqClient;
	@Autowired
	private OrderFormFeignClient orderFormFeignClient;
	@Autowired
	private StoreVisitLogFeignClient storeVisitLogFeignClient;
	@Autowired
	private ShipAddressFeignClient shipAddressFeignClient;
	@Autowired
	private IOpeningTimeService openingTimeService;
	@Autowired
	private IconViewFeignClient iconViewFeignClient;
	@Autowired
	private CouponFeignClient couponFeignClient;
	@Autowired
	private IComExamineService comExamineService;
	@Autowired
	private CouponInfoFeignClient couponInfoFeignClient;
	@Autowired
	private TXTemplateFeignClient tXTemplateFeignClient;
 
	/**
	 * 查询店铺
	 * 
	 * @param congelationDto
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/queryPageList", method = RequestMethod.POST)
	public List<Store> queryPageList(@RequestBody Map<String, Object> params, @RequestParam("begin") Integer begin,
			@RequestParam("max") Integer max) {
		return storeService.queryPageList(params, begin, max);
	}
	
	@RequestMapping(value = "/apiForFeign/selectCount", method = RequestMethod.POST)
	public int selectCount(@RequestBody Map<String, Object> params) {
		return storeService.selectCount(params);
	}
 
	@RequestMapping(value = "/apiForFeign/selectByPrimaryKey", method = RequestMethod.GET)
	public Store selectByPrimaryKey(@RequestParam("id") Long id) {
		Store store = storeService.selectByPrimaryKey(id);
		if (store==null) {
			return null;
		}
		// 店铺logo
		if (store != null && store.getStore_logo_id() != null) {
			store.setStore_logo(accessoryFeignClient.selectByPrimaryKey(store.getStore_logo_id()));
		}
		// 查询店铺评分统计
		store.setPoint(storePointService.getStoreByStoreId(id));
		// 公司所在地完整的父级地址信息
		if (store.getLicense_c_area_id() != null) {
			store.setLicense_c_area(areaFeignClient.selectByPrimaryKey(store.getLicense_c_area_id()));
		}
		return store;
	}
	@RequestMapping(value = "/apiForFeign/selectStoreAndWare", method = RequestMethod.GET)
	public Store selectStoreAndWare(@RequestParam("id") Long id) {
		Store store = storeService.selectByPrimaryKey(id);
		if (store==null) {
			return null;
		}
		// 店铺logo
		if (store != null && store.getStore_logo_id() != null) {
			store.setStore_logo(accessoryFeignClient.selectByPrimaryKey(store.getStore_logo_id()));
		}
		// 查询店铺评分统计
		store.setPoint(storePointService.getStoreByStoreId(id));
		// 公司所在地完整的父级地址信息
		if (store.getLicense_c_area_id() != null) {
			store.setLicense_c_area(areaFeignClient.selectByPrimaryKey(store.getLicense_c_area_id()));
		}
		if (store.getLicense_c_area_id() != null) {
			store.setLicense_c_area(areaFeignClient.selectByPrimaryKey(store.getLicense_c_area_id()));
		}
		if (store.getWarehouse_id() != null) {
			WareHouse wareHouse = wareHouseService.selectByPrimaryKey(store.getWarehouse_id());
			WareHouseDto wareHouseDto = new WareHouseDto();
			BeanUtils.copyProperties(wareHouse, wareHouseDto);
			store.setWarehouse(wareHouseDto);
		}
		
		return store;
	}
	@RequestMapping(value = "/apiForFeign/updateById", method = RequestMethod.POST)
	public void updateById(@RequestBody Store obj) {
		storeService.updateById(obj);
	}
 
	// 查询外卖店铺是否在营业中
	@RequestMapping(value = "/apiForFeign/openingDoor", method = RequestMethod.GET)
	public boolean openingDoor(@RequestParam("id") Long id) {
		return openingTimeService.openingDoor(id);
	}
 
	/**
	 * 手机店铺
	 * 
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/store", method = RequestMethod.POST)
	public Map<String, Object> store(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String id = json.optString("id");
		String currentPage = json.optString("currentPage");
		String key = json.optString("key");
		String sa_id = json.optString("sa_id");
		String sa_name = json.optString("sa_name");
 
		Map<String, Object> result = new HashMap<String, Object>();
 
		Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(id));
		if (store == null) {
			return ResponseCode.buildCodeMap("20001", "不存在该店铺信息!", null);
		}
 
		// 查询开店的人
		UserDto user = userFeignClient.getUserByStoreId(store.getId());
		store.setUser(user);
		result.put("store", store);
 
		if ((CommUtil.null2Int(store.getStore_status()) == 25) || (CommUtil.null2Int(store.getStore_status()) == 26)) {
			return ResponseCode.buildCodeMap("20002", "店铺因为合同到期现已关闭,如有疑问请联系商城客服", null);
		} else if (store.getStore_status() < 15) {
			return ResponseCode.buildCodeMap("20003", "店铺未正常营业", null);
		} else if (store.getStore_status() == 20) {
			return ResponseCode.buildCodeMap("20004", "店铺因为违反商城相关规定现已关闭,如有疑问请联系商城客服", null);
		}
 
		// 查询是否收藏店铺 if (SecurityUserHolder.getCurrentUser(request) != null) {
		Map<String, Object> params = Maps.newHashMap();
		params.put("user_id", SecurityUserHolder.getCurrentUserId(request));
		params.put("store_id", CommUtil.null2Long(id));
 
		List<FavoriteDto> list = this.favoriteFeignClient.queryPageList(params);
		if (null != list && list.size() > 0) {
			result.put("all_col", Integer.valueOf(1));
		}
		
		// banner
		params.clear();
		params.put("edit_mo", "5");
		params.put("store_id", id);
		List<FloorDto> bannerFloor = floorFeignClient.queryPages(params);
		if (bannerFloor.size() > 0) {
			result.put("bannerFloor", bannerFloor.get(0));
		}
		// VR
		params.put("edit_mo", "1");
		List<FloorDto> vrFloor = floorFeignClient.queryPages(params);
		if (vrFloor != null && vrFloor.size() > 0) {
			result.put("vrFloor", vrFloor.get(0));
		}
		// custom
		params.put("edit_mo", "6");
		params.put("orderBy", "sequence");
		params.put("orderType", "asc");
		List<FloorDto> customFloor = floorFeignClient.queryPages(params);
		result.put("customFloor", customFloor);
 
		// 店铺发货地址
		if (StringUtils.isBlank(sa_id) || StringUtils.isBlank(sa_name)) {
			params.clear();
			params.put("store_id", CommUtil.null2Long(id));
			List<ShipAddressDto> saList = shipAddressFeignClient.queryPages(params);
			if (saList != null && saList.size() > 0) {
				sa_id = saList.get(0).getId().toString();
				sa_name = saList.get(0).getSa_name();
			}
		}
 
		// 店铺的商品
		Map<String, Object> maps = queryTools.getParams(currentPage, 12, "obj.addTime", "desc");
		maps.put("goods_store_id", store.getId()); // 店铺ID
		maps.put("goods_status", 0); // 商品审核状态
		maps.put("honghu_goods_name", key);
		Map<String, Object> goodsList = goodsFeignClient.list(maps);
		result.put("goodsList", goodsList);
		result.put("key", key);
		result.put("id", id);
		result.put("sa_id", sa_id);
		result.put("sa_name", sa_name);
		// result.put("share_user_id", share_user_id);
 
		// 查询店铺是否显示手机号
		ModularClassDto ModularClassDto = modularClassFeignClient.selectByPrimaryKey(store.getMc_id());
		result.put("showphone", ModularClassDto.isShow_phone());
 
		maps.clear();
		maps.put("store_id", store.getId());
		maps.put("coupon_end_time_able", "coupon_end_time_able");
 
		List<CouponDto> couponlist = couponFeignClient.queryPageList(maps);
		result.put("couponlist", couponlist);
		try {
			String current_ip = CommUtil.getIpAddr(request);
			JSONObject jsonMsg = new JSONObject();
			jsonMsg.put("source", "1"); // 来源(1.小程序,2.app)
			jsonMsg.put("store_id", id);
			jsonMsg.put("user_id", SecurityUserHolder.getCurrentUserId(request));
			jsonMsg.put("access_ip", current_ip);
			storeVisitMqClient.sendStoreVisitMsg(jsonMsg);
		} catch (Exception e) {
			log.error("记录用户访问店铺数据失败:" + Exceptions.getStackTraceAsString(e));
			;
		}
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	@RequestMapping(value = "/storeAgentGoods", method = RequestMethod.POST)
	public Map<String, Object> storeAgentGoods(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		
		String id = json.optString("id");
		String currentPage = json.optString("currentPage");
		String key = json.optString("key");
		
		
		Map<String, Object> maps = queryTools.getParams(currentPage, 12, "obj.addTime", "desc");
		maps.put("agent_sid", Long.parseLong(id));
		maps.put("goods_status", 0); // 商品审核状态
		if(StringUtils.isNotBlank(key)){
			maps.put("honghu_goods_name", key);
		}
		maps.put("no_goods_store_id", Long.parseLong(id));
		Map<String, Object> goodsList = goodsFeignClient.list(maps);
		return ResponseCode.buildSuccessMap(goodsList);
	}
 
	/**
	 * 商品分类-ajax
	 * 
	 * @param request
	 * @param response
	 * @param ugc_id
	 *            商品类别
	 * @param store_id
	 *            商店编号
	 * @param orderBy
	 *            分组类型
	 * @param orderType
	 *            排序方式
	 * @param currentPage
	 * @param all
	 * @param ty
	 *            底部图标首页访问路径的判断标识
	 * @return
	 */
	@RequestMapping(value = "/store_type_list", method = RequestMethod.POST)
	public Map<String, Object> store_type_list(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String storeId = json.optString("storeId");
 
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("storeId", storeId);
		Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(storeId)); // 根据店铺ID查询店铺信息
		if (store == null) {
			return ResponseCode.buildCodeMap("20001", "不存在该店铺信息!", null);
		}
		// 店铺信息
		result.put("store", store);
		UserDto user = userFeignClient.getUserByStoreId(store.getId());
		if (user == null) {
			result.put("ugcs", null);// 商品分类集合
			return ResponseCode.buildSuccessMap(result);
			// return ResponseCode.buildCodeMap("20005", "开店用户信息异常!", null);
		}
		// 商品分类集合
		Map<String, Object> maps = Maps.newHashMap();
		maps.put("user_id", user.getId());
		maps.put("deleteStatus", 0);
		maps.put("parent", "-1");
		maps.put("dispaly", 1);
		maps.put("orderBy", "obj.sequence");
		maps.put("orderType", "ASC");
		List<UserGoodsClassDto> ugcs = this.UserGoodsClassFeignClient.queryPageList(maps); // 商品分类集合
		result.put("ugcs", ugcs);// 商品分类集合
		// 店铺分类信息
		return ResponseCode.buildSuccessMap(result);
	}
 
	/**
	 * 名片
	 * @param request
	 * @param response
	 * @param store_id
	 *            店铺编号
	 * @param ty 底部图标首页访问路径的判断标识
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/business_card", method = RequestMethod.POST)
	public Map<String, Object> business_card(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		
		Long storeId = json.optLong("storeId");
		Store store = this.storeService.selectByPrimaryKey(storeId); // 查询商店信息
		if (store == null) {
			return ResponseCode.buildCodeMap("20001", "不存在该店铺信息!", null);
		} 
		Map<String, Object> result = new HashMap<String, Object>();
		if(store.getArea_id() != null){
			String areainfo = areaFeignClient.genericAreaInfo(store.getArea_id(), "");
			store.setStore_address(areainfo+store.getStore_address());
		}
		result.put("store", store);
		
		Map<String, Object> params = Maps.newHashMap();
		// 查询是否用户是否收藏
		UserDto currentUser = SecurityUserHolder.getCurrentUser(request);
		if (currentUser != null) {
			params.clear();
			params.put("user_id", currentUser.getId());
			params.put("store_id", CommUtil.null2Long(storeId));
			List<FavoriteDto> list = this.favoriteFeignClient.queryPageList(params);
 
			if (null != list && list.size() > 0) {
				result.put("all_col", Integer.valueOf(1));
			}
			//result.put("user", currentUser);
		}// 查询店铺是否显示手机号
		ModularClassDto ModularClassDto = modularClassFeignClient.selectByPrimaryKey(store.getMc_id());
		result.put("showphone", ModularClassDto.isShow_phone());
		//用户的banner
		FloorDto floor = floorFeignClient.selectStoreBanner(storeId);
		result.put("floor", floor);
		return ResponseCode.buildSuccessMap(result);
	}
 
	/**
	 * 手机店铺中商品(全部宝贝)
	 * 
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/store_goods_new", method = RequestMethod.POST)
	public Map<String, Object> store_goods_new(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String orderBy = json.optString("orderBy");
		String orderType = json.optString("orderType");
		String keyword = json.optString("keyword");
		String storeId = json.optString("storeId");
		String currentPage = json.optString("currentPage");
		String ugc_id = json.optString("ugc_id");
 
		if ((orderBy == null) || ("".equals(orderBy))) {
			orderBy = "goods_salenum";
		} else if (CommUtil.null2String(orderBy).equals("store_salenum")) {
			orderBy = "goods_salenum";// 销量
		} else if (CommUtil.null2String(orderBy).equals("goods_collect")) {
			orderBy = "goods_collect";// 人气
		} else if (CommUtil.null2String(orderBy).equals("well_evaluate")) {
			orderBy = "well_evaluate";// 评分高(综合)
		} else if (CommUtil.null2String(orderBy).equals("store_price")) {
			orderBy = "store_price"; // 价格
		}
		if (CommUtil.null2String(orderType).equals("asc") || CommUtil.null2String(orderType).equals("ASC")) {
			orderType = "ASC";
		} else {
			orderType = "DESC";
		}
		Map<String, Object> maps = queryTools.getParams(currentPage, 12, "obj." + orderBy, orderType);
		if (StringUtils.isNotBlank(ugc_id)) {
			maps.put("ugc_id", ugc_id);
		}
		if (StringUtils.isNotBlank(keyword)) {
			maps.put("honghu_goods_name", keyword);
		}
		maps.put("goods_store_id", storeId);
		maps.put("enough_reduce", "enough_reduce");
		maps.put("goods_status", 0);
		Map<String, Object> goodsList = this.goodsFeignClient.list(maps);
 
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("goodsList", goodsList);
		result.put("orderBy", orderBy);
		result.put("orderType", orderType);
		result.put("keyword", keyword);
		result.put("storeId", storeId);
		result.put("currentPage", currentPage);
		result.put("ugc_id", ugc_id);
 
		return ResponseCode.buildSuccessMap(result);
	}
 
	/**
	 * 
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	/*
	 * @RequestMapping({ "/store_user_goods_class" }) public ModelAndView
	 * store_user_goods_class(HttpServletRequest request, HttpServletResponse
	 * response, String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/store_user_goods_class.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); Store
	 * store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(id)); if
	 * (store != null) { Map params = Maps.newHashMap(); params.put("user_id",
	 * store.getUser().getId()); params.put("display", Boolean.valueOf(true));
	 * params.put("parent", -1); params.put("orderBy", "sequence");
	 * params.put("orderBy", "sequence"); params.put("orderType", "asc");
	 * 
	 * List<UserGoodsClass> ugcs =
	 * this.userGoodsClassService.queryPageList(params);
	 * 
	 * result.put("ugcs", ugcs); } return mv; }
	 * 
	 *//**
		 * 店铺活动
		 * 
		 * @param request
		 * @param response
		 * @param id
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_activity" }) public ModelAndView
	 * store_activity(HttpServletRequest request, HttpServletResponse response,
	 * String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/store_activity.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); if ((id !=
	 * null) && (!"".equals(id))) { Store store =
	 * this.storeService.selectByPrimaryKey(CommUtil.null2Long(id)); if (store
	 * != null) { result.put("store", store); Map map = Maps.newHashMap();
	 * map.put("ag_goods_goods_store_id", store.getId()); map.put("ag_status",
	 * 1);
	 * 
	 * List<ActivityGoods> ags = this.activityGoodsService.queryPageList(map);
	 * 
	 * Set ids = new HashSet(); for (ActivityGoods ag : ags) { if (ag.getAct()
	 * != null) { ids.add(ag.getAct().getId()); } } if (null != ids &&
	 * ids.size() > 0) { Map paras = Maps.newHashMap(); paras.put("ids", ids);
	 * 
	 * List list = this.activityService.queryPageList(paras);
	 * 
	 * result.put("objs", list); } } } return mv; }
	 * 
	 *//**
		 * 活动商品列表
		 * 
		 * @param request
		 * @param response
		 * @param act_id
		 * @param id
		 * @return
		 */
	/*
	 * @RequestMapping({ "/activity_goods_list" }) public ModelAndView
	 * activity_goods_list(HttpServletRequest request, HttpServletResponse
	 * response, String act_id, String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/activity_goods_list.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); Activity
	 * act =
	 * this.activityService.selectByPrimaryKey(CommUtil.null2Long(act_id)); if
	 * ((id != null) && (!"".equals(id)) && (act != null)) { Map<String, Object>
	 * maps = this.hongHuQueryTools.getParams(null, "addTime", "desc");
	 * maps.put("ag_goods_goods_store_id", CommUtil.null2Long(id));
	 * maps.put("act_id", CommUtil.null2Long(act_id)); maps.put("ag_status", 1);
	 * 
	 * IPageList pList = this.activityGoodsService.list(maps);
	 * CommUtil.saveIPageList2ModelAndView("", "", "", pList, mv); }
	 * result.put("act_id", act_id); if ((id != null) && (!"".equals(id))) {
	 * Store store =
	 * this.storeService.selectByPrimaryKey(CommUtil.null2Long(id)); if (store
	 * != null) { result.put("store", store); } } return mv; }
	 * 
	 * 
	 * 
	 *//**
		 * 店铺分类列表
		 * 
		 * @param request
		 * @param response
		 * @param id
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_class_list" }) public ModelAndView
	 * store_class_list(HttpServletRequest request, HttpServletResponse
	 * response, String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/store_class_list.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); Store
	 * store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(id)); if
	 * (store != null) { Map params = Maps.newHashMap(); params.put("user_id",
	 * store.getUser().getId()); params.put("display", Boolean.valueOf(true));
	 * params.put("parent", Boolean.valueOf(true)); params.put("orderBy",
	 * "sequence"); params.put("orderType", "asc");
	 * 
	 * List<UserGoodsClass> ugcs =
	 * this.userGoodsClassService.queryPageList(params);
	 * 
	 * result.put("store", store); result.put("ugcs", ugcs); } return mv; }
	 * 
	 *//**
		 * 店铺商品
		 * 
		 * @param request
		 * @param response
		 * @param ugc_id
		 * @param store_id
		 * @param keyword
		 * @param orderBy
		 * @param orderType
		 * @param currentPage
		 * @param all
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_goods" }) public ModelAndView
	 * store_goods(HttpServletRequest request, HttpServletResponse response,
	 * String ugc_id, String store_id, String keyword, String orderBy, String
	 * orderType, String currentPage, String all) { ModelAndView mv = new
	 * HongHuJModelAndView("weixin/store_goods.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response);
	 * Map<String, Object> maps = this.hongHuQueryTools.getParams(currentPage,
	 * 12, orderBy, orderType); if (!"all".equals(all)) { mv = new
	 * HongHuJModelAndView("weixin/store_goods_data.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); } if
	 * ((orderBy == null) || (orderBy.equals(""))) { orderBy = "goods_salenum";
	 * } if ((orderType == null) || (orderType.equals(""))) { orderType =
	 * "desc"; } if ((currentPage == null) || ("".equals(currentPage))) {
	 * currentPage = "1"; } Store store =
	 * this.storeService.selectByPrimaryKey(CommUtil.null2Long(store_id)); if
	 * (store != null) { result.put("store", store); maps.put("goods_store_id",
	 * store.getId());
	 * 
	 * maps.put("goods_status", 0); if ((keyword != null) &&
	 * (!keyword.equals(""))) { maps.put("goods_name_like", keyword);
	 * result.put("keyword", keyword); }
	 * 
	 * UserGoodsClass ugc =
	 * this.userGoodsClassService.selectByPrimaryKey(CommUtil.null2Long(ugc_id))
	 * ; if (ugc != null) { result.put("ugc", ugc); Set<Long> ids =
	 * genericUserGcIds(ugc); List<UserGoodsClass> ugc_list =
	 * Lists.newArrayList(); for (Long g_id : ids) { UserGoodsClass temp_ugc =
	 * this.userGoodsClassService.selectByPrimaryKey(g_id);
	 * ugc_list.add(temp_ugc); }
	 * 
	 * List<Long> goods_ugcs_ugc_ids = Lists.newArrayList();
	 * 
	 * for (int i = 0; i < ugc_list.size(); i++) { UserGoodsClass userGoodsClass
	 * = ugc_list.get(i); goods_ugcs_ugc_ids.add(userGoodsClass.getId()); }
	 * maps.put("goods_ugcs_ugc_ids", goods_ugcs_ugc_ids); }
	 * 
	 * if ((orderBy != null) && (!orderBy.equals(""))) { result.put("orderBy",
	 * orderBy); result.put("orderType", orderType); }
	 * 
	 * IPageList pList = this.goodsService.list(maps); result.put("objs",
	 * pList.getResult()); result.put("totalPage",
	 * Integer.valueOf(pList.getPages())); String url =
	 * this.configService.getSysConfig().getAddress();
	 * CommUtil.saveIPageList2ModelAndView(url + "/goods_list", "", "", pList,
	 * mv); } else { mv = new HongHuJModelAndView("error.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response);
	 * result.put("op_title", "请求参数错误"); result.put("url",
	 * CommUtil.getURL(request) + "/index"); } return mv; }
	 * 
	 *//**
		 * 店铺商品
		 * 
		 * @param request
		 * @param response
		 * @param ugc_id
		 * @param store_id
		 * @param keyword
		 * @param orderBy
		 * @param orderType
		 * @param currentPage
		 * @param all
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_items" }) public ModelAndView
	 * store_items(HttpServletRequest request, HttpServletResponse response,
	 * String ugc_id, String store_id, String keyword, String orderBy, String
	 * orderType, String currentPage, String all) { ModelAndView mv = new
	 * HongHuJModelAndView("weixin/store_goods.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response);
	 * 
	 * Map<String, Object> maps = this.hongHuQueryTools.getParams(currentPage,
	 * 12, orderBy, orderType);
	 * 
	 * if (!"all".equals(all)) { mv = new
	 * HongHuJModelAndView("weixin/store_goods_data.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); } if
	 * ((orderBy == null) || (orderBy.equals(""))) { orderBy = "goods_salenum";
	 * } if ((orderType == null) || (orderType.equals(""))) { orderType =
	 * "desc"; } if ((currentPage == null) || ("".equals(currentPage))) {
	 * currentPage = "1"; } Store store =
	 * this.storeService.selectByPrimaryKey(CommUtil.null2Long(store_id)); if
	 * (store != null) { result.put("store", store);
	 * 
	 * maps.put("goods_store_id", store.getId());
	 * 
	 * maps.put("goods_status", 0);
	 * 
	 * if ((keyword != null) && (!keyword.equals(""))) {
	 * maps.put("goods_name_like", keyword); result.put("keyword", keyword); }
	 * 
	 * UserGoodsClass ugc =
	 * this.userGoodsClassService.selectByPrimaryKey(CommUtil.null2Long(ugc_id))
	 * ; if (ugc != null) { result.put("ugc", ugc); Set<Long> ids =
	 * genericUserGcIds(ugc); List<UserGoodsClass> ugc_list =
	 * Lists.newArrayList(); for (Long g_id : ids) { UserGoodsClass temp_ugc =
	 * this.userGoodsClassService.selectByPrimaryKey(g_id);
	 * ugc_list.add(temp_ugc); }
	 * 
	 * List<Long> goods_ugcs_ugc_ids = Lists.newArrayList();
	 * 
	 * for (int i = 0; i < ugc_list.size(); i++) {
	 * goods_ugcs_ugc_ids.add(ugc_list.get(i).getId()); }
	 * maps.put("goods_ugcs_ugc_ids", goods_ugcs_ugc_ids);
	 * 
	 * }
	 * 
	 * IPageList pList = this.goodsService.list(maps); result.put("objs",
	 * pList.getResult()); result.put("totalPage",
	 * Integer.valueOf(pList.getPages())); String url =
	 * this.configService.getSysConfig().getAddress();
	 * CommUtil.saveIPageList2ModelAndView(url + "/goods_list", "", "", pList,
	 * mv); } else { mv = new HongHuJModelAndView("error.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response);
	 * result.put("op_title", "请求参数错误"); result.put("url",
	 * CommUtil.getURL(request) + "/index"); } return mv; }
	 * 
	 *//**
		 * 
		 * @param request
		 * @param response
		 * @param id
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_head" }) public ModelAndView
	 * store_head(HttpServletRequest request, HttpServletResponse response,
	 * String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/store_head.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); Store
	 * store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(id));
	 * result.put("store", store); return mv; }
	 * 
	 *//**
		 * 
		 * @param request
		 * @param response
		 * @param id
		 * @return
		 */
	/*
	 * @RequestMapping({ "/store_foot" }) public ModelAndView
	 * store_foot(HttpServletRequest request, HttpServletResponse response,
	 * String id) { ModelAndView mv = new
	 * HongHuJModelAndView("/weixin/store_foot.html",
	 * this.configService.getSysConfig(),
	 * this.userConfigService.getUserConfig(), 1, request, response); Store
	 * store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(id));
	 * result.put("store", store); return mv; }
	 * 
	 *//**
		 * 
		 * @param ugc
		 * @return
		 *//*
		 * private Set<Long> genericUserGcIds(UserGoodsClass ugc) { Set ids =
		 * new HashSet(); ids.add(ugc.getId()); for (UserGoodsClass child :
		 * ugc.getChilds()) { Set<Long> cids = genericUserGcIds(child); for
		 * (Long cid : cids) { ids.add(cid); } ids.add(child.getId()); } return
		 * ids; }
		 * 
		 */
 
	/**
	 * 用户申请开店
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/buyer/user_store_add" })
	public Map<String, Object> user_store_add(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		Map<String, Object> result = Maps.newHashMap();
		Map<String, Object> params = Maps.newHashMap();
		String type = json.optString("type");
		UserDto user = SecurityUserHolder.getCurrentUser(request);
 
		Store store = null;
		if (user != null) {
			params.clear();
			params.put("user_id", user.getId());
			store = this.storeService.queryByProperty(params);
		}
 
		params.clear();
 
		List<StoreGrade> grades = this.storeGradeService.queryPageList(params);
 
		result.put("storeGrades", grades);
		result.put("user", user);
 
		params.clear();
		params.put("parent", -1);
		params.put("level", 0);
		List<GoodsClassDto> gcs = this.goodsClassFeignClient.queryPageList(params);
 
		result.put("goodsClass", gcs);
 
		if (store != null) {
			if (StringUtils.isNotEmpty(type)) {
				store.setStore_status(0); // 重新提交
				storeService.updateById(store);
			}
			// 跳转审核页面
			result.put("store", store);
		}
		// 查询店铺保证金购买记录
		params.clear();
		params.put("user_id", user.getId());
		params.put("pay_status", 1);
		PlatformPayDto platformPay = platformPayFeignClient.findUserDepositPay(params);
		if (platformPay != null && platformPay.getPay_status() == 1) {
			result.put("deposit_mark", "true");
		}
		params.clear();
		List<ModularClassDto> modularclass = modularClassFeignClient.queryPageList(params);
		result.put("modularclass", modularclass);
		result.put("usecard", false);
		return ResponseCode.buildSuccessMap(result);
	}
 
	/**
	 * 店铺保存
	 * 
	 * @param request
	 * @param response
	 * @param id
	 * @param store_status
	 * @param currentPage
	 * @param cmd
	 * @param list_url
	 * @param add_url
	 * @param user_id
	 * @param grade_id
	 * @param area_id
	 * @param validity
	 * @param gc_main_id_clone
	 * @param gc_detail_ids
	 * @param gc_detail_info
	 * @param serve_ids
	 * @param cart_session
	 * @return String trueName, String id, String store_name, String cmd, String
	 *         user_id, String storeGrades, String validity, String gc_main_id,
	 *         String gc_detail_ds, String telephone, String gc_detail_info,
	 *         String serve_ids, String recommend, String store_add_session,
	 *         String gc_id, String mc_id,
	 * @throws Exception
	 */
	@RequestMapping({ "/store_save" })
	public Map<String, Object> store_save(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
 
		String store_name = json.optString("store_name"); // 店铺名称
		String trueName = json.optString("trueName"); // 真实姓名
		String telephone = json.optString("telephone"); // 电话号码
		String recommend = json.optString("recommend"); // 推荐人
		String mc_id = json.optString("mc_id"); // 行业
		String warehouse_id = json.optString("warehouse_id"); // 仓库地址id
		String storeGrades = json.optString("storeGrades"); // 店铺种类
		String gc_main_id = json.optString("gc_main_id"); // 主营类目
		String gc_id = json.optString("gc_id"); // 分类list
		String store_type = json.optString("store_type"); // 店铺类型 0 为个人 ,1 为公司
		String area_id = json.optString("area_id"); // 地址id
		String lat = json.optString("lat"); // 经纬度
		String lng = json.optString("lng");
		String area_name = json.optString("area_name"); // 详细地址名称
		String bank_permit_image_id = json.optString("bank_permit_image_id"); // 开户许可证
		String food_license_id = json.optString("food_license_id"); // 开户许可证
 
		// String serve_ids = json.optString("serve_ids");
		String license_legal_idCard_image_id = json.optString("license_legal_idCard_image_id"); // 身份证正面
		String license_legal_idCard_image2_id = json.optString("license_legal_idCard_image2_id");// 身份证反面
		String license_image_id = json.optString("license_img_id"); // 开户许可证 id
		String bank_c_account = json.optString("bank_c_account"); // 开户行账号
		String bank_account_name = json.optString("bank_account_name"); // 银行开户名
		String bank_name = json.optString("bank_name"); // 开户行支行名称
 
		UserDto user = userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		Store store = null;
		if (user.getStore_id() != null) {
			store = this.storeService.selectByPrimaryKey(user.getStore_id());
		} else {
			store = new Store();
		}
		store.setStore_status(5);
		if ((null != user) && (null != user.getId())) {
			store.setUser(user);
			store.setStore_name(store_name);
			store.setStore_ower(trueName);
			store.setLng(Double.valueOf(lng));
			store.setLat(Double.valueOf(lat));
			store.setArea_id(CommUtil.null2Long(area_id));
			store.setStore_address(area_name); // 详细地址
			store.setStore_telephone(telephone); // 店铺电话号码
			store.setRecommend(recommend); // 推荐人
			store.setGc_main_id(CommUtil.null2Long(gc_main_id));
			store.setAddTime(new Date());
			if (StringUtils.isNotEmpty(mc_id)) {
				store.setMc_id(CommUtil.null2Long(mc_id)); // 店铺所属行业
			}
			if (StringUtils.isNotEmpty(warehouse_id)) {
				store.setWarehouse_id(CommUtil.null2Long(warehouse_id)); // 店铺配送仓库地址
			}
			if (StringUtils.isNotBlank(storeGrades)) {
				store.setGrade_id(CommUtil.null2Long(storeGrades));
			}
			if (StringUtils.isNotBlank(store_type)) {
				store.setStore_type(Integer.valueOf(store_type)); // 店铺类型
			}
			if (StringUtils.isNotBlank(bank_c_account)) {
				store.setBank_c_account(bank_c_account); // 开户行账号
			}
			if (StringUtils.isNotBlank(bank_account_name)) {
				store.setBank_account_name(bank_account_name); // 银行开户名
			}
			if (StringUtils.isNotBlank(bank_name)) {
				store.setBank_name(bank_name); // 开户行支行名称
			}
 
			// 保存店铺位置坐标
 
			if (StringUtils.isNotBlank(gc_id)) {
				String[] str = gc_id.split(",");
				List<Map> list = Lists.newArrayList();
				Map<String, Object> map = Maps.newHashMap();
				List gc_list = Lists.newArrayList();
				GoodsClassDto parent = null;
				for (int b = 1; b < str.length; b++) {
					GoodsClassDto gc = this.goodsClassFeignClient.selectByPrimaryKey(CommUtil.null2Long(str[b]));
					parent = gc.getParent();
				}
				List<GoodsClassDto> gc_mains = this.storeTools.query_store_detail_MainGc(store.getGc_detail_info());
				for (GoodsClassDto gc_main : gc_mains) {
					Map map_main = this.storeTools.query_MainGc_Map(CommUtil.null2String(gc_main.getId()),
							store.getGc_detail_info());
					list.add(map_main);
				}
				for (int a = 0; a < str.length; a++) {
					GoodsClassDto gc = this.goodsClassFeignClient.selectByPrimaryKey(CommUtil.null2Long(str[a]));
					if (null == gc) {
						continue;
					}
					Set<GoodsClassDto> detail_info = this.storeTools.query_store_DetailGc(store.getGc_detail_info());
					if (((Set) detail_info).size() == 0) {
						gc_list.add(gc.getId());
					} else {
						int m = 0;
						for (GoodsClassDto gc2 : detail_info) {
							if (gc.getId().equals(gc2.getId())) {
								m++;
							}
						}
						if (m == ((Set) detail_info).size()) {
							gc_list.add(gc.getId());
						}
					}
					if (gc.getParent_id() != null) {
						parent = goodsClassFeignClient.selectByPrimaryKey(gc.getParent_id());
					}
 
				}
				map.put("m_id", parent.getId());
				map.put("gc_list", gc_list);
				list.add(map);
				store.setGc_detail_info(JSON.toJSONString(list));
 
			}
 
		}
 
		Map<String, Object> params = Maps.newHashMap();
		// 1、搜索出所有父菜单
		params.clear();
		params.put("parent", -1);
		params.put("type", "SELLER");
 
		List<MenuDto> menus = this.menuFeignClient.list(params);
		List<MenuDto> ms = Lists.newArrayList();
		// 2、通过父菜单获取所有子菜单
		for (MenuDto menu : menus) {
			ms.add(menu);
			ms.addAll(menu.getAllChilds());
		}
 
		this.userFeignClient.deleteUserMenu(user.getId());
 
		this.userFeignClient.saveUserMenu(user.getId(), ms);
		// 处理图片
 
		if (StringUtils.isNotBlank(license_legal_idCard_image_id)) { // 身份证正面
			store.setLicense_legal_idCard_image_id(CommUtil.null2Long(license_legal_idCard_image_id));
		}
		if (StringUtils.isNotBlank(license_legal_idCard_image2_id)) { // 身份证背面
			store.setLicense_legal_idCard_image2_id(CommUtil.null2Long(license_legal_idCard_image2_id));
		}
		if (StringUtils.isNotBlank(license_image_id)) { // 营业执照
			store.setLicense_image_id(CommUtil.null2Long(license_image_id));
		}
 
		if (StringUtils.isNotBlank(bank_permit_image_id)) { // 营业执照
			store.setBank_permit_image_id(CommUtil.null2Long(bank_permit_image_id));
		}
		if (StringUtils.isNotBlank(food_license_id)) { // 营业执照
			store.setFood_license_id(CommUtil.null2Long(food_license_id));
		}
 
		if (store.getId() == null) {
			this.storeService.saveEntity(store);
			
			//通知用户审核
			try{
				params = new HashMap<String, Object>();
				params.put("kind", "店铺");
				params.put("nickname", user.getNickName());
				tXTemplateFeignClient.auditNsgNote(params);
			}catch(Exception e){
				log.error("StoreController >> store_save >> auditNsgNote  " + e.getMessage());
			}
			
		} else {
			this.storeService.updateById(store);
		}
 
		if (store.getPoint() == null) {
			StorePoint sp = new StorePoint();
			sp.setAddTime(new Date());
			sp.setStore(store);
			sp.setStore_evaluate(BigDecimal.valueOf(0L));
			sp.setDescription_evaluate(BigDecimal.valueOf(0L));
			sp.setService_evaluate(BigDecimal.valueOf(0L));
			sp.setShip_evaluate(BigDecimal.valueOf(0L));
			this.storePointService.saveEntity(sp);
		}
		user.setStore_id(store.getId());
		this.userFeignClient.updateById(user);
 
		return ResponseCode.buildSuccessMap(null);
	}
 
	/**
	 * 我的店铺
	 * 
	 * @param request
	 * @param response
	 * @param json
	 * @return
	 */
	@RequestMapping(value = "/my_store", method = RequestMethod.POST)
	public Map<String, Object> my_store(HttpServletRequest request, HttpServletResponse response) {
 
		Map<String, Object> resultMap = new HashMap<String, Object>();
 
		UserDto user = SecurityUserHolder.getCurrentUser(request);
		if (user == null) {
			return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
		}
		user = userFeignClient.selectByPrimaryKey(user.getId());
		Store store = storeService.selectByPrimaryKey(user.getStore_id());
		if (store == null) {
			return ResponseCode.buildCodeMap("20002", "无法找到该店铺", null);
		}
		resultMap.put("store", store);
		return ResponseCode.buildSuccessMap(resultMap);
	}
 
	@RequestMapping(value = "/save_my_store", method = RequestMethod.POST)
	public Map<String, Object> save_my_store(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String store_name = json.optString("store_name");
		String store_info = json.optString("store_info");
		Long mobile_logo_id = json.optLong("mobile_logo_id");
		Long store_photo_id = json.optLong("store_photo_id");
 
		if (StringUtils.isBlank(store_name) || StringUtils.isBlank(store_info) || mobile_logo_id == null
				|| store_photo_id == null) {
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
 
		UserDto user = SecurityUserHolder.getCurrentUser(request);
		if (user == null) {
			return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
		}
 
		Store store = storeService.selectByPrimaryKey(user.getId());
		if (store == null) {
			return ResponseCode.buildCodeMap("20002", "无法找到该店铺", null);
		}
		store.setStore_name(store_name);
		store.setStore_info(store_info);
		store.setMobile_logo_id(mobile_logo_id);
		store.setStore_photo_id(store_photo_id);
		storeService.updateById(store);
		return ResponseCode.buildEnumMap(ResponseCode.SUCCESS, null);
	}
 
	/**
	 * 去逛街
	 * 
	 * @param request
	 * @param response
	 * @param search
	 *            店铺名称搜索
	 * @param id
	 *            店铺id
	 * @param orderBy
	 *            分组类型
	 * @param orderType
	 *            排序方式
	 * @return
	 */
	@RequestMapping(value = "/go_shopping", method = RequestMethod.POST)
	public Map<String, Object> go_shopping(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
 
		String currentPage = json.optString("currentPage");
		String search = json.optString("search");
		String orderBy = json.optString("orderBy");
		String orderType = json.optString("orderType");
		String lat = json.optString("lat");
		String lng = json.optString("lng");
		String gb_id = json.optString("gb_id");
		String mc_id = json.optString("mc_id");
		String newShop = json.optString("newShop");
 
		if (StringUtils.isBlank(lat) || StringUtils.isBlank(lng) || StringUtils.isBlank(currentPage)) {
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
 
		Map<String, Object> result = new HashMap<String, Object>();
 
		Map<String, Object> params = queryTools.getParams(currentPage, 12, "obj." + orderBy, orderType);
		params.put("notakeaway", "yes");
		if (CommUtil.null2String(orderType).equals("")) {
			orderType = "desc";
		}
		if ((orderBy == null) || ("".equals(orderBy)) || "comprehensive".equals(orderBy)) {
			// 综合
			params.put("orderBy", "obj.deposit  " + orderType
					+ ", obj.fileId desc, avg(sp.store_evaluate) desc, count(goods.goods_salenum)");
		} else if (CommUtil.null2String(orderBy).equals("well_evaluate")) {
			// 评分
			params.put("orderBy", "IFNULL(avg(sp.store_evaluate), 5)");
		} else if (CommUtil.null2String(orderBy).equals("store_distance")) {
			// 距离
			params.put("orderBy", "distance");
		}
		Map<String, Object> map = Maps.newHashMap();
		
		if (StringUtils.isNotBlank(search)) {
			params.put("search_key", search); // 商店名称模糊匹配
		}else{  //存在搜索的情况,就不做区域限制
			String city = areaFeignClient.getCoordinate(lat, lng);
			
			map.put("level", 1);
			map.put("areaName", city);
			List<AreaDto> list = areaFeignClient.queryPageList(map);
			if (list.size() <= 0) {
				// 如果查询不到,就设定地址为深圳
				map.clear();
				map.put("level", 1);
				map.put("areaName", "深圳市");
				list = areaFeignClient.queryPageList(map);
			}
			AreaDto area = list.get(0);
			params.put("area_id", area.getId());
		}
 
		params.put("lat", lat);
		params.put("lng", lng);
		params.put("orderType", orderType);
		params.put("group_by", "sa.id");
		if (StringUtils.isNotEmpty(gb_id)) {
			params.put("screen_gb_id", gb_id); // 品牌
		}
		if (StringUtils.isNotEmpty(newShop)) {
			params.put("screen_newShop", newShop); // 新店
		}
		if (StringUtils.isNotEmpty(mc_id)) {
			params.put("screen_mc_id", CommUtil.null2Long(mc_id)); // 行业
		}
 
		Page<Store> pList = this.storeService.goShoppingPage(params);
		Page<Store> recomList = null;
		if (pList.getRowCount() <= 10) {
			// 没有数据获取默认地方深圳的数据
			map.clear();
			map.put("level", 1);
			map.put("areaName", "深圳市");
			List<AreaDto> list = areaFeignClient.queryPageList(map);
			AreaDto area = list.get(0);
 
			params.clear();
			params = queryTools.getParams(currentPage, 12, "obj." + orderBy, orderType);
			params.put("notakeaway", "yes");
			params.put("orderBy", "obj.deposit  " + orderType
					+ ", obj.fileId desc, avg(sp.store_evaluate) desc, count(goods.goods_salenum)");
			params.put("lat", lat);
			params.put("lng", lng);
			params.put("orderType", orderType);
			params.put("group_by", "sa.id");
 
			params.put("area_id", area.getId());
			recomList = this.storeService.goShoppingPage(params);
		}
		//地图上的名称
		/*if (pList.getResult()!=null&&pList.getResult().size()>0) {
			for (Store store : pList.getResult()) {
				if (store.getStore_name().length()>4) {
					store.setStore_map_name(store.getStore_name().substring(0, 5)+"..");
				}else{
					store.setStore_map_name(store.getStore_name());
				}
			}
		}*/
		result.put("recomList", recomList);
		result.put("pList", pList);
		result.put("currentPage", currentPage);
		result.put("search", search);
		result.put("orderBy", orderBy);
		result.put("orderType", orderType);
		result.put("lat", lat);
		result.put("lng", lng);
		result.put("gb_id", gb_id);
		result.put("mc_id", mc_id);
		result.put("newShop", newShop);
 
		return result;
	}
 
	// 获取行业信息
	@RequestMapping(value = "/allModularClass", method = RequestMethod.GET)
	public Map<String, Object> allModularClass() {
		Map<String, Object> params = Maps.newHashMap();
		List<ModularClassDto> mcList = modularClassFeignClient.queryPageList(params);
		return ResponseCode.buildEnumMap(ResponseCode.SUCCESS, mcList);
	}
 
	/**
	 * 手机店铺首页
	 * 
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/home", method = RequestMethod.GET)
	public Map<String, Object> home(HttpServletRequest request, HttpServletResponse response) {
		Long login_user_id = SecurityUserHolder.getCurrentUserId(request);
		UserDto user = userFeignClient.selectByPrimaryKey(login_user_id);
		if (user.getStore_id() == null) {
			return ResponseCode.buildCodeMap("40001", "未开店", null);
		}
		user.setStore_id(user.getStore_id());
		/**
		 * 查询订单、退款售后统计{wait_pay_num:待付款,wait_send_num:待发货,return_goods_num:退款售后,wait_evaluate_num:待评价,
		 * return_num:退款中,today_order_num:今日订单数,today_order_price:今日总成交额,lastday_order_price:昨日成交金额}
		 */
		Map<String, Object> orderStatis = orderFormFeignClient.orderStoreStatis(user.getStore_id());
 
		/** 查询商品统计{today_collect:今日收藏,today_look:今日浏览,today_cart_num:今日购物车} **/
		Map<String, Object> goodsStatis = goodsFeignClient.goodsStoreStatis(user.getStore_id());
		orderStatis.putAll(goodsStatis);
 
		/** 查询店铺访问统计{today_visit:今日总访客,today_flow:今日总流量,lastday_visit:昨日总访客} **/
		Map<String, Object> visitStatis = storeVisitLogService.visitStoreStatis(user.getStore_id());
		orderStatis.putAll(visitStatis);
 
		return ResponseCode.buildEnumMap(ResponseCode.SUCCESS, orderStatis);
	}
 
	// 外卖店铺
	@RequestMapping(value = "/takeaway_shop", method = RequestMethod.POST)
	public Map<String, Object> takeaway_shop(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
 
		String currentPage = json.optString("currentPage");
		String search = json.optString("search");
		String orderBy = json.optString("orderBy");
		String orderType = json.optString("orderType");
		String lat = json.optString("lat");
		String lng = json.optString("lng");
		String gb_id = json.optString("gb_id");
		String newShop = json.optString("newShop");
		String mc_id = json.optString("mc_id"); // 行业
		String free_delivery = json.optString("free_delivery"); // 免费配送
		String full_reduction = json.optString("full_reduction"); // 满就减
		String full_send = json.optString("full_send"); // 满就送
		String invoice = json.optString("invoice"); // 发票
 
		if (StringUtils.isBlank(lat) || StringUtils.isBlank(lng) || StringUtils.isBlank(currentPage)) {
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
 
		Map<String, Object> result = new HashMap<String, Object>();
		List<H5LevelBannerDto> hlbList = iconViewFeignClient.selectByHmId(6L);
		result.put("hlbList", hlbList);
 
		Map<String, Object> params = queryTools.getParams(currentPage, 12, "obj." + orderBy, orderType);
		params.put("takeaway", "yes");
		if (CommUtil.null2String(orderType).equals("")) {
			orderType = "desc";
		}
		if ((orderBy == null) || ("".equals(orderBy)) || "comprehensive".equals(orderBy)) {
			// 综合
			params.put("orderBy", "obj.deposit  " + orderType
					+ ", obj.fileId desc, avg(sp.store_evaluate) desc, count(goods.goods_salenum)");
		} else if (CommUtil.null2String(orderBy).equals("well_evaluate")) {
			// 评分
			params.put("orderBy", "IFNULL(avg(sp.store_evaluate), 5)");
		} else if (CommUtil.null2String(orderBy).equals("store_distance")) {
			// 距离
			params.put("orderBy", "distance");
			orderType = "ASC";
		} else if (CommUtil.null2String(orderBy).equals("store_salenum")) {
			// 销量 ORDER BY store_salenum DESC
			params.put("orderBy", "store_salenum");
			orderType = "DESC";
		} else if (CommUtil.null2String(orderBy).equals("send_money")) {
			// 起送价最低 ORDER BY send_money ASC
			params.put("orderBy", "obj.send_money");
			orderType = "ASC";
		} else if (CommUtil.null2String(orderBy).equals("delivery_money")) {
			// 配送费最低 ORDER BY delivery_money ASC
			params.put("orderBy", "obj.delivery_money");
			orderType = "ASC";
		} else if (CommUtil.null2String(orderBy).equals("prepare_time")) {
			// 配送速度最快 ORDER BY prepare_time ASC
			params.put("orderBy", "obj.prepare_time");
			orderType = "ASC";
		}
		if (StringUtils.isNotBlank(search)) {
			params.put("search_key", search); // 商店名称模糊匹配
		}
		if (StringUtils.isNotBlank(free_delivery)) {
			params.put("free_delivery", free_delivery); // 免费配送
		}
		if (StringUtils.isNotBlank(full_reduction)) {
			params.put("full_reduction", full_reduction); // 满就减
		}
		if (StringUtils.isNotBlank(full_send)) {
			params.put("full_send", full_send); // 满就送
		}
		if (StringUtils.isNotBlank(invoice)) {
			params.put("invoice", invoice); // 发票
		}
		if (StringUtils.isNotBlank(mc_id)) {
			params.put("screen_mc_id", mc_id); // 行业
		}
 
		String city = areaFeignClient.getCoordinate(lat, lng);
		Map<String, Object> map = Maps.newHashMap();
		map.put("level", 1);
		map.put("areaName", city);
		List<AreaDto> list = areaFeignClient.queryPageList(map);
		if (list.size() <= 0) {
			// 如果查询不到,就设定地址为北京
			map.clear();
			map.put("level", 1);
			map.put("areaName", "北京市");
			list = areaFeignClient.queryPageList(map);
		}
		AreaDto area = list.get(0);
		params.put("area_id", area.getId());
 
		params.put("lat", lat);
		params.put("lng", lng);
		params.put("orderType", orderType);
		params.put("group_by", "sa.id");
		if (StringUtils.isNotEmpty(gb_id)) {
			params.put("screen_gb_id", gb_id); // 品牌
		}
		if (StringUtils.isNotEmpty(newShop)) {
			params.put("screen_newShop", newShop); // 新店
		}
 
		Page<Store> pList = this.storeService.goShoppingPage(params);
		List<Long> ids = new ArrayList<Long>();
		for (Store store : pList.getResult()) {
			ids.add(store.getId());
		}
		List<GoodsDto> goodsList = goodsFeignClient.getRecommendGoods(ids);
 
		Map<Long, List<GoodsDto>> goodsResult = new HashMap<Long, List<GoodsDto>>();
		for (Long id : ids) {
			List<GoodsDto> goodsMap = new ArrayList<GoodsDto>();
			for (GoodsDto goodsDto : goodsList) {
				if (id.longValue() == goodsDto.getGoods_store_id().longValue()) {
					goodsMap.add(goodsDto);
				}
			}
			goodsResult.put(id, goodsMap);
		}
 
		for (Store store : pList.getResult()) {
			store.setRecommendList(goodsResult.get(store.getId()));
		}
		result.put("pList", pList);
		result.put("currentPage", currentPage);
		result.put("search", search);
		result.put("orderBy", orderBy);
		result.put("orderType", orderType);
		result.put("lat", lat);
		result.put("lng", lng);
		result.put("gb_id", gb_id);
		result.put("newShop", newShop);
		result.put("free_delivery", free_delivery); // 免费配送
		result.put("full_reduction", full_reduction); // 满就减
		result.put("full_send", full_send); // 满就送
		result.put("invoice", invoice); // 发票
		return ResponseCode.buildEnumMap(ResponseCode.SUCCESS, result);
 
	}
 
	// 外卖店铺
	@RequestMapping(value = "/takeaway_shop_count", method = RequestMethod.POST)
	public Map<String, Object> takeaway_shop_count(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
 
		String search = json.optString("search");
		String lat = json.optString("lat");
		String lng = json.optString("lng");
		String gb_id = json.optString("gb_id");
		String newShop = json.optString("newShop");
		String free_delivery = json.optString("free_delivery"); // 免费配送
		String full_reduction = json.optString("full_reduction"); // 满就减
		String full_send = json.optString("full_send"); // 满就送
		String invoice = json.optString("invoice"); // 发票
 
		if (StringUtils.isBlank(lat) || StringUtils.isBlank(lng)) {
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
 
		Map<String, Object> result = new HashMap<String, Object>();
 
		Map<String, Object> params = Maps.newHashMap();
		params.put("takeaway", "yes");
		if (StringUtils.isNotBlank(search)) {
			params.put("search_key", search); // 商店名称模糊匹配
		}
		if (StringUtils.isNotBlank(free_delivery)) {
			params.put("free_delivery", free_delivery); // 免费配送
		}
		if (StringUtils.isNotBlank(full_reduction)) {
			params.put("full_reduction", full_reduction); // 满就减
		}
		if (StringUtils.isNotBlank(full_send)) {
			params.put("full_send", full_send); // 满就送
		}
		if (StringUtils.isNotBlank(invoice)) {
			params.put("invoice", invoice); // 发票
		}
 
		String city = areaFeignClient.getCoordinate(lat, lng);
		Map<String, Object> map = Maps.newHashMap();
		map.put("level", 1);
		map.put("areaName", city);
		List<AreaDto> list = areaFeignClient.queryPageList(map);
		if (list.size() <= 0) {
			// 如果查询不到,就设定地址为北京
			map.clear();
			map.put("level", 1);
			map.put("areaName", "北京市");
			list = areaFeignClient.queryPageList(map);
		}
		AreaDto area = list.get(0);
		params.put("area_id", area.getId());
 
		params.put("lat", lat);
		params.put("lng", lng);
		if (StringUtils.isNotEmpty(gb_id)) {
			params.put("screen_gb_id", gb_id); // 品牌
		}
		if (StringUtils.isNotEmpty(newShop)) {
			params.put("screen_newShop", newShop); // 新店
		}
		int count = this.storeService.goShoppingCount(params);
 
		result.put("count", count);
		result.put("search", search);
		result.put("lat", lat);
		result.put("lng", lng);
		result.put("gb_id", gb_id);
		result.put("newShop", newShop);
		result.put("free_delivery", free_delivery); // 免费配送
		result.put("full_reduction", full_reduction); // 满就减
		result.put("full_send", full_send); // 满就送
		result.put("invoice", invoice); // 发票
		return ResponseCode.buildEnumMap(ResponseCode.SUCCESS, result);
 
	}
 
	/**
	 * 用户申请开店
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/buyer/user_store_check" })
	public Map<String, Object> user_store_check(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		Map<String, Object> result = Maps.newHashMap();
		Map<String, Object> params = Maps.newHashMap();
		UserDto user = userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
 
		Store store = null;
		if (user != null) {
			params.clear();
			params.put("user_id", user.getId());
			store = this.storeService.queryByProperty(params);
		}
		result.put("user", user);
		result.put("store", store);
		ModularClassDto modularClassDto = null;
		if (store != null) {
			modularClassDto = modularClassFeignClient.selectByStoreId(store.getId());
		}
		result.put("modularclass", modularClassDto);
		return ResponseCode.buildSuccessMap(result);
	}
 
	/**
	 * 修改银行卡信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/buyer/storeModifyComExamine" })
	public Map<String, Object> storeModifyComExamine(HttpServletRequest request, HttpServletResponse response,
			@RequestBody ComExamine comExamine) {
		Map<String, Object> result = Maps.newHashMap();
		UserDto user = userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		Store store = null;
		if (user != null && user.getStore_id() != null) {
			store = storeService.selectByPrimaryKey(user.getStore_id());
		}
		if (store == null) {
			return ResponseCode.buildFailMap("用户信息有误", null);
		}
		comExamine.setAddTime(new Date());
		comExamine.setDeleteStatus(0);
		comExamine.setStore_id(store.getId());
		comExamine.setUser_id(user.getId());
		comExamine.setStatus(0);
		if (comExamine.getId() != null) {
			comExamineService.updateById(comExamine);
		} else {
			comExamineService.saveEntity(comExamine);
		}
 
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 修改银行卡信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/coupon_itme" })
	public Map<String, Object> coupon_itme(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		Map<String, Object> result = Maps.newHashMap();
		Store store = null;
 
		String id = json.optString("id");
		String coupon_id = json.optString("coupon_id");
		store = storeService.selectByPrimaryKey(CommUtil.null2Long(id));
		if (store == null) {
			return ResponseCode.buildFailMap("信息有误", null);
		}
		result.put("coupon_id", CommUtil.null2Long(coupon_id));
		result.put("free_status", 1);
		result.put("user_id", SecurityUserHolder.getCurrentUserId(request));
		
		List<CouponInfoDto> queryPageList = couponInfoFeignClient.queryPageList(result);
		if (queryPageList == null||queryPageList.size()<1) {
			return ResponseCode.buildFailMap("信息有误", null);
		}
		if (store.getArea_id() != null) {
			AreaDto areaDto = areaFeignClient.selectByPrimaryKeyFullParent(store.getArea_id());
			if (areaDto != null) {
				String store_address = store.getStore_address();
				store.setStore_address(areaDto.getParent().getParent().getAreaName() + areaDto.getParent().getAreaName()
						+ areaDto.getAreaName() + store_address);
			}
		}
		CouponDto couponDto = couponFeignClient.selectByPrimaryKey(CommUtil.null2Long(coupon_id));
		result.clear();
		result.put("couponDto", couponDto);
		result.put("couponinfodto", queryPageList.get(0));
		result.put("store", store);
		return ResponseCode.buildSuccessMap(result);
	}
 
}
 源码地址来源: https://minglisoft.cn/honghu2/business.html
 类似资料: