@源码地址来源:http://minglisoft.cn/hhcloud
@源码地址来源:http://minglisoft.cn/hhcloud
@获取源码+wx: haiwabbc2
/**
* Copyright © 2012-2017 HongHu 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
*
*/
@Slf4j
@RestController
@RequestMapping(value = "/store")
public class StoreController {
@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 queryPageList(@RequestBody Map 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 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 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 result = new HashMap();
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 params = Maps.newHashMap();
params.put("user_id", SecurityUserHolder.getCurrentUserId(request));
params.put("store_id", CommUtil.null2Long(id));
List 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 bannerFloor = floorFeignClient.queryPages(params);
if (bannerFloor.size() > 0) {
result.put("bannerFloor", bannerFloor.get(0));
}
// VR
params.put("edit_mo", "1");
List 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 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 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 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 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 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 storeAgentGoods(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String id = json.optString("id");
String currentPage = json.optString("currentPage");
String key = json.optString("key");
Map 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 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 store_type_list(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
String storeId = json.optString("storeId");
Map result = new HashMap();
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 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 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 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 result = new HashMap();
if(store.getArea_id() != null){
String areainfo = areaFeignClient.genericAreaInfo(store.getArea_id(), "");
store.setStore_address(areainfo+store.getStore_address());
}
result.put("store", store);
Map 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 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 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 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 goodsList = this.goodsFeignClient.list(maps);
Map result = new HashMap();
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 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 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
* 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 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 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 ids =
* genericUserGcIds(ugc); List ugc_list =
* Lists.newArrayList(); for (Long g_id : ids) { UserGoodsClass temp_ugc =
* this.userGoodsClassService.selectByPrimaryKey(g_id);
* ugc_list.add(temp_ugc); }
*
* List 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 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 ids =
* genericUserGcIds(ugc); List ugc_list =
* Lists.newArrayList(); for (Long g_id : ids) { UserGoodsClass temp_ugc =
* this.userGoodsClassService.selectByPrimaryKey(g_id);
* ugc_list.add(temp_ugc); }
*
* List 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 genericUserGcIds(UserGoodsClass ugc) { Set ids =
* new HashSet(); ids.add(ugc.getId()); for (UserGoodsClass child :
* ugc.getChilds()) { Set 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 user_store_add(HttpServletRequest request, HttpServletResponse response,
@RequestBody JSONObject json) {
Map result = Maps.newHashMap();
Map 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 grades = this.storeGradeService.queryPageList(params);
result.put("storeGrades", grades);
result.put("user", user);
params.clear();
params.put("parent", -1);
params.put("level", 0);
List 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 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 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
@源码地址来源:http://minglisoft.cn/hhcloud