一个好的SpringCloud+SpringBoot b2b2c 电子商务平台涉及哪些技术、运营方案?以下是我结合公司的产品做的总结,希望可以帮助到大家!
搜索体验小程序:海哇
1. 涉及平台
平台管理、商家端(PC端、手机端)、买家平台(H5/公众号、小程序、APP端(IOS/Android)、微服务平台(业务服务)
2. 核心架构
Spring Cloud、Spring Boot、Mybatis、Redis
3. 前端框架
VUE、Uniapp、Bootstrap/H5/CSS3、IOS、Android、小程序
4. 核心思想
分布式、微服务、云架构、模块化、原子化、持续集成、集群部署、前后端分离、支持阿里Docker
5. 开发模式
前后端分离、微服务开发
6. 社交模式
VR全景虚拟现实、直播带货、短视频带货、分销分润、代跑腿配送、内容营销、社交种草、社交电商、秒杀、积分商城、限时折扣、活动商品、拼团活动等
7. 营销模式
通用版本(标准多商户入驻+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动)
直播、短视频带货版本(标准多商户入驻+直播、短视频带货+二级分销体系+满减、满送、优惠券、组合销售、平台礼包等营销活动)
特殊营销方案(一):一县一特(一个县城,一个特色,集本地特产、特色、名胜、小吃、文化为一体的营销方案)
特殊营销方案(二):短距离配送(外卖、生鲜水果配送,解决1.5公里配送问题,接入第三方代跑腿服务)
特殊营销方案(三):酒店行业(酒店商家入驻,根据定位,可针对附近酒店,不同城酒店进行线上预定、下线核销等,参考去哪儿网酒店业务)
特殊营销方案(四):VR全景(商家入驻后,可以进行VR全景拍摄,VR店铺体验,全新购物方式,通过虚拟现实技术,线上线下打通,实现全新O2O,深度场景体验,感受另一个大千世界,让用户足不出户完美购物。通过VR让您的店铺曝光率更高,让天下没有难销的商品)
特殊营销方案(五):线下套餐体验(针对于实体行业,用户线上消费后生成核销码,用户到实体店铺体验套餐,可凭借核销码进行体验项目)
特殊营销方案(六):旅游业(周边游、本地游、异地游等,旅游景区和VR全景结合,用户足不出户先感受一下旅游项目、旅游攻略等,可线上订票、预定等)
特殊营销方案(七):供应求购(简易供应链供应、求购模式)
特殊营销方案(八):社交资讯(用户发布文章,可进行带货)
特殊营销方案(九):社交动态(个人信息、动态、视频,如:文字+图片、文字+视频,可进行带货;粉丝、关注、分享等)
活动商品(平台发布活动商品,如:可以进行0元领取,领取需要进行用户拉新,拉新后可进行现金奖励等)
特殊营销方案(十):异业联盟(不同行业的联盟销售,如:在某餐饮店面消费后可送附近健身卡优惠券,凭借优惠券可进行线下体验)
特殊营销方案(十一):一键代发营销(商家选择平台商品后放入自己店面销售,用户购买后商家可获取特殊分润提成,商家不需要发货,由平台厂家直接发货,并支持本店面自提)
首页控制器代码:
package com.honghu.cloud.controller;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
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.RestController;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.honghu.cloud.bean.AdvertPosition;
import com.honghu.cloud.bean.Floor;
import com.honghu.cloud.bean.H5Menu;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.dto.AdvertPositionDto;
import com.honghu.cloud.dto.StoreDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.AdvertPositionFeignClient;
import com.honghu.cloud.feign.GoodsFeignClient;
import com.honghu.cloud.feign.MessageFeignClient;
import com.honghu.cloud.feign.SearchFeignClient;
import com.honghu.cloud.feign.StoreFeignClient;
import com.honghu.cloud.feign.SysConfigFeignClient;
import com.honghu.cloud.redis.RedisUtil;
import com.honghu.cloud.service.IAdvertPositionService;
import com.honghu.cloud.service.IAdvertService;
import com.honghu.cloud.service.IFloorService;
import com.honghu.cloud.service.IH5MenuService;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.utils.QueryUtils;
import net.sf.json.JSONObject;
/**
* 首页控制器
* @author Administrator
* @param <V>
* @param <K>
*
*/
@RestController
@SuppressWarnings({ "rawtypes", "unchecked" })
/*/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
RequestMethod.PUT })*/
public class IndexViewController<V, K>{
private static final Logger logger = LoggerFactory.getLogger(IndexViewController.class);
@Autowired
private SysConfigFeignClient sysConfigFeignClient;
@Autowired
private StoreFeignClient storeFeignClient;
@Autowired
private SearchFeignClient searchFeignClient;
@Autowired
private AdvertPositionFeignClient advertPositionFeignClient;
@Autowired
private IFloorService floorService;
@Autowired
private IH5MenuService h5MenuService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private QueryUtils queryUtils;
@Autowired
private GoodsFeignClient goodsFeignClient;
@Autowired
private IAdvertPositionService advertPositionService;
@Autowired
private MessageFeignClient messageFeignClient;
/**
* 手机客户端商城首页
* @param request
* @param response
* @return
*/
@RequestMapping(value="/index")
public Map<String, Object> index(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> resultMap = new HashMap<String, Object>();
Map<String,Object> maps = Maps.newHashMap();
maps.put("orderBy", "sequence");
maps.put("orderType", "asc");
maps.put("store_id_is_null", "yes");
List<Floor> list = floorService.queryPageList(maps);
resultMap.put("floor_list", list);
String weixin_navigator = sysConfigFeignClient.getSysConfig().getWeixin_navigator();
Map index_nav_map = Maps.newHashMap();
Map weixin_nav_map;
if ((weixin_navigator != null) && (!weixin_navigator.equals(""))) {
weixin_nav_map = JSON.parseObject(weixin_navigator);
for (Object obj : weixin_nav_map.keySet()) {
if (obj.toString().indexOf("index") >= 0) {
index_nav_map.put(obj, weixin_nav_map.get(obj));
}
}
} else {
weixin_nav_map = Maps.newHashMap();
}
resultMap.put("index_nav_map", index_nav_map);
return ResponseCode.buildSuccessMap(resultMap);
}
//TODO
@RequestMapping({ "/index/v3" })
public Map<String, Object> indexv3(HttpServletRequest request,
HttpServletResponse response) {
Map<String, Object> maps = Maps.newHashMap();
Map<String, Object> resultMap = Maps.newHashMap();
maps.put("orderBy", "sequence");
maps.put("orderType", "asc");
maps.put("store_id_is_null", "yes");
List<Floor> queryPageList = this.floorService.queryPageList(maps);
String weixin_navigator = sysConfigFeignClient.getSysConfig().getWeixin_navigator();
Map index_nav_map = Maps.newHashMap();
Map weixin_nav_map;
if ((weixin_navigator != null) && (!weixin_navigator.equals(""))) {
weixin_nav_map = JSON.parseObject(weixin_navigator);
for (Object obj : weixin_nav_map.keySet()) {
if (obj.toString().indexOf("index") >= 0) {
index_nav_map.put(obj, weixin_nav_map.get(obj));
}
}
} else {
weixin_nav_map = Maps.newHashMap();
}
resultMap.put("floor", queryPageList);
Object object = redisUtil.get("everyday_refresh");
if (object != null) {
redisUtil.set("everyday_refresh", false, CommUtil.null2Long(CommUtil.subSecond()));
redisUtil.remove("h5_advert_invoke_new");
}
// show menu
/* Object object2 = redisUtil.get("h5_menus_new");
if (object2 != null) {
List<H5Menu> result = (List<H5Menu>) object2;
resultMap.put("menu", result);
} else {*/
maps = Maps.newHashMap();
maps.put("orderBy", "seq");
maps.put("orderType", "asc");
/*maps.put("h5_status", 0);*/
maps.put("no_pid", "no_pid"); //不查询子menu
List<H5Menu> menus = this.h5MenuService.queryPages(maps);
resultMap.put("menu", menus);
if (menus != null && menus.size() > 0) {
redisUtil.set("h5_menus_new", menus);
}
//}
// 首页广告位
object = redisUtil.get("h5_advert_invoke_new");
// object = null;
if (object != null) {
AdvertPosition result = (AdvertPosition) object;
resultMap.put("adv", result);
} else {
AdvertPosition index_advert_invoke = advertPositionService.getAdvoPos(11L);
resultMap.put("adv", index_advert_invoke);
if (index_advert_invoke != null) {
redisUtil.set("h5_advert_invoke_new", index_advert_invoke);
}
}
// 查询微商城推荐
Map<String, Object> map = (Map<String, Object>) redisUtil.get("wechat_recommend_list");
if (null == map||map.get("rowCount").toString().equals("0")) {
Map<String, Object> params = this.queryUtils.getParams(null, 12, "weixin_recommendTime", "desc");
params.put("goods_status", 0);
params.put("weixin_recommend", true);
params.put("deleteStatus", 0);
Map<String, Object> list = goodsFeignClient.listIndex(params);
redisUtil.set("wechat_recommend_list", list);
resultMap.put("recommend_list", list);
}else {
resultMap.put("recommend_list", map);
}
//查询未读消息记录
UserDto user = SecurityUserHolder.getCurrentUser(request);
if(user != null){
maps.clear();
maps.put("read_status", 0);
maps.put("toUser_id", user.getId());
int messageCount = messageFeignClient.selectCount(maps);
resultMap.put("messageCount", messageCount);
}
UserDto currentUser = SecurityUserHolder.getCurrentUser(request);
if(currentUser != null&¤tUser.getStore_id()!=null){
StoreDto storeDto = storeFeignClient.selectByPrimaryKey(currentUser.getStore_id());
resultMap.put("store_status", storeDto!=null?storeDto.getStore_status():null);
}
return resultMap;
}
/**
* 手机客户端商城首页
* @param request
* @param response
* @return
*/
@RequestMapping(value="/index/v3_date", method = RequestMethod.POST)
public Map<String, Object> v3_date(@RequestBody JSONObject json, HttpServletRequest request,
HttpServletResponse response) {
String currentPage = json.optString("currentPage"); //当前页
Map<String, Object> resultMap = Maps.newHashMap();
// 查询微商城推荐
Map<String, Object> params = this.queryUtils.getParams(currentPage, 12, "weixin_recommendTime", "desc");
params.put("goods_status", 0);
params.put("weixin_recommend", true);
params.put("deleteStatus", 0);
//Map<String, Object> list = goodsFeignClient.list(params);
Map<String, Object> list = goodsFeignClient.listIndex(params);
resultMap.put("recommend_list", list);
return resultMap;
}
/**
* 手机客户端商城首页
* @param request
* @param response
* @return
*/
@RequestMapping(value="/index/v2", method = RequestMethod.POST)
public Map<String, Object> indexV2(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> resultMap = new HashMap<String, Object>();
/*// 广告
String advert_id=json.getString("advert_id");
if ((advert_id != null) && (!advert_id.equals(""))) {
AdvertPositionDto advertPositionDto = advertPositionFeignClient.selectAdvertPosition(advert_id);
AdvertPositionDto selectByPrimaryKey = advertPositionFeignClient.selectByPrimaryKey(CommUtil.null2Long(advert_id));
resultMap.put("advertPositionDto", advertPositionDto);
resultMap.put("selectByPrimaryKey", selectByPrimaryKey);
}
//show menu导航
HashMap<String, Object> maps = new HashMap<String, Object>();
maps.put("orderBy", "seq");
maps.put("orderType", "asc");
List<H5Menu> menus = this.h5MenuService.queryPages(maps);
resultMap.put("menus", menus);
*/
// TODO List<每日推荐>10 List<新品推荐>6 List<微商城推荐推荐>1000
// 每日推荐
// 查询微商城推荐
Map<String, Object> map = (Map<String, Object>) redisUtil.get("wechat_goods_no_break_list");
if (null == map||map.get("rowCount").toString().equals("0")) {
Map<String, Object> params = this.queryUtils.getParams(null, 10, "", "desc");
params.put("goods_status", 0);
params.put("goods_no_break", true);
params.put("deleteStatus", 0);
Map<String, Object> list = goodsFeignClient.list(params);
redisUtil.set("wechat_goods_no_break_list", list);
resultMap.put("goods_no_break_list", list);
}else {
resultMap.put("goods_no_break_list", map);
}
// 新品推荐
map = (Map<String, Object>) redisUtil.get("wechat_goods_new_products");
if (null == map||map.get("rowCount").toString().equals("0")) {
Map<String, Object> params = this.queryUtils.getParams(null, 6, "", "desc");
params.put("goods_status", 0);
params.put("goods_new_products", true);
params.put("deleteStatus", 0);
Map<String, Object> list = goodsFeignClient.list(params);
redisUtil.set("wechat_goods_new_products", list);
resultMap.put("goods_new_products", list);
}else{
resultMap.put("goods_new_products", map);
}
// 查询微商城推荐
map = (Map<String, Object>) redisUtil.get("wechat_recommend_list");
if (null == map||map.get("rowCount").toString().equals("0")) {
Map<String, Object> params = this.queryUtils.getParams(null, 1000, "weixin_recommendTime", "desc");
params.put("goods_status", 0);
params.put("weixin_recommend", true);
params.put("deleteStatus", 0);
Map<String, Object> list = goodsFeignClient.list(params);
redisUtil.set("wechat_recommend_list", list);
resultMap.put("recommend_list", list);
}else {
resultMap.put("recommend_list", map);
}
String weixin_navigator = sysConfigFeignClient.getSysConfig().getWeixin_navigator();
Map index_nav_map = Maps.newHashMap();
Map weixin_nav_map;
if ((weixin_navigator != null) && (!weixin_navigator.equals(""))) {
weixin_nav_map = JSON.parseObject(weixin_navigator);
for (Object obj : weixin_nav_map.keySet()) {
if (obj.toString().indexOf("index") >= 0) {
index_nav_map.put(obj, weixin_nav_map.get(obj));
}
}
} else {
weixin_nav_map = Maps.newHashMap();
}
resultMap.put("index_nav_map", index_nav_map);
return ResponseCode.buildSuccessMap(resultMap);
}
/**
* 手机端商品搜索
* @param request
* @param response
* @param gc_id
* @param currentPage
* @param orderBy
* @param orderType
* @param goods_type
* @param goods_inventory
* @param keyword
* @param goods_transfee
* @param goods_cod
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping(value="/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpServletRequest request, HttpServletResponse response,@RequestBody JSONObject json
) throws UnsupportedEncodingException {
String keyword = json.optString("keyword");
String currentPage = json.optString("currentPage");
String orderBy = json.optString("orderBy");
String orderType = json.optString("orderType");
String gc_id = json.optString("gc_id");
String goods_transfee = json.optString("goods_transfee");
String goods_inventory = json.optString("goods_inventory");
String goods_type = json.optString("goods_type");
String goods_cod = json.optString("goods_cod");
Map<String, Object> resultMap = new HashMap<String, Object>();
if ((keyword != null) && (!keyword.equals(""))) {
if (CommUtil.null2Int(currentPage) <= 1) {
response.addCookie(search_history_cookie(request, keyword));
if ((keyword != null) && (!keyword.equals(""))
&& (keyword.length() > 1)) {
resultMap.put("stores", search_stores_seo(keyword));
}
}
resultMap = searchFeignClient.searchGoods(orderBy, orderType, gc_id, keyword, goods_transfee, currentPage,
goods_inventory, goods_type, goods_cod);
}
return ResponseCode.buildSuccessMap(resultMap);
}
/**
* APP下载
* @param request
* @param response
*/
@RequestMapping({ "/app/download" })
public void app_download(HttpServletRequest request,
HttpServletResponse response) {
String user_agent = request.getHeader("User-Agent").toLowerCase();
String url = CommUtil.getURL(request);
if (user_agent.indexOf("iphone") > 0) {
url = sysConfigFeignClient.getSysConfig().getIos_download();
}
if (user_agent.indexOf("android") > 0) {
url = sysConfigFeignClient.getSysConfig().getAndroid_download();
}
try {
response.sendRedirect(CommUtil.getURL(request) + "/" + url);
} catch (IOException e) {
e.printStackTrace();
}
}
public List<StoreDto> search_stores_seo(String keyword) {
Map<String, Object> params = Maps.newHashMap();
params.put("store_seo_keywords1", keyword);
List<StoreDto> stores = storeFeignClient.queryPageList(params, 0, 3);
Collections.sort(stores, new Comparator() {
public int compare(Object o1, Object o2) {
StoreDto store1 = (StoreDto) o1;
StoreDto store2 = (StoreDto) o2;
int l1 = store1.getStore_seo_keywords().split(",").length;
int l2 = store2.getStore_seo_keywords().split(",").length;
if (l1 > l2) {
return 1;
}
if (l1 == l2) {
if (store1.getPoint().getStore_evaluate()
.compareTo(store2.getPoint().getStore_evaluate()) == 1) {
return -1;
}
if (store1.getPoint().getStore_evaluate()
.compareTo(store2.getPoint().getStore_evaluate()) == -1) {
return 1;
}
return 0;
}
return -1;
}
});
return stores;
}
/**
* 手机端广告
* @param request
* @param response
* @param id 手机端广告id=11
* @return
*/
@RequestMapping(value="/advert_invoke")
public Map<String, Object> advert_invoke(HttpServletRequest request, HttpServletResponse response) {
AdvertPositionDto advertPositionDto = advertPositionFeignClient.selectAdvertPosition("11");
return ResponseCode.buildSuccessMap(advertPositionDto);
}
public Cookie search_history_cookie(HttpServletRequest request,
String keyword) throws UnsupportedEncodingException {
String str = "";
Cookie[] cookies = request.getCookies();
Cookie search_cookie = null;
for (Cookie cookie : cookies) {
if (cookie.getName().equals("search_history")) {
String str_temp = URLDecoder.decode(cookie.getValue(), "UTF-8");
for (String s : str_temp.split(",")) {
if ((!s.equals(keyword)) && (!str.equals(""))) {
str = str + "," + s;
} else if (!s.equals(keyword)) {
str = s;
}
}
break;
}
}
if (str.equals("")) {
str = keyword;
str = URLEncoder.encode(str, "UTF-8");
search_cookie = new Cookie("search_history", str);
} else {
str = keyword + "," + str;
str = URLEncoder.encode(str, "UTF-8");
search_cookie = new Cookie("search_history", str);
}
return search_cookie;
}
/**
* 手机端文章
* @param request
* @param response
* @param mark
* @return
@RequestMapping({ "/doc" })
public ModelAndView doc(HttpServletRequest request,
HttpServletResponse response, String mark) {
ModelAndView mv = new HongHuJModelAndView("weixin/article.html",
this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
mv.addObject("doc", "doc");
Document obj = this.documentService.getObjByProperty("mark","=", mark);
mv.addObject("obj", obj);
return mv;
}*/
/**
*
* @param request
* @param response
* @return
@RequestMapping({ "/layer" })
public ModelAndView layer(HttpServletRequest request,
HttpServletResponse response) {
ModelAndView mv = new HongHuJModelAndView("weixin/layer.html",
this.configService.getSysConfig(),
this.userConfigService.getUserConfig(), 1, request, response);
String weixin_navigator = sysConfigFeignClient.getSysConfig().getWeixin_navigator();
Map layer_nav_map = Maps.newHashMap();
Map weixin_nav_map;
if ((weixin_navigator != null) && (!weixin_navigator.equals(""))) {
weixin_nav_map = JSON.parseObject(weixin_navigator);
for (Object obj : weixin_nav_map.keySet()) {
if (obj.toString().indexOf("nav_") >= 0) {
layer_nav_map.put(obj, weixin_nav_map.get(obj));
}
}
String ret = CommUtil.null2String(weixin_nav_map
.get("navigator_bar"));
layer_nav_map.put("navigator_bar", ret);
} else {
weixin_nav_map = Maps.newHashMap();
}
mv.addObject("layer_nav_map", layer_nav_map);
mv.addObject("op", CommUtil.null2String(request.getAttribute("op")));
return mv;
}
@SuppressWarnings("unused")
private List<GoodsCart> cart_calc(HttpServletRequest request) {
String cart_session_id = "";
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("cart_session_id")) {
try {
cart_session_id = CommUtil.null2String(URLDecoder.decode(cookie.getValue(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
}
if (cart_session_id.equals("")) {
cart_session_id = UUID.randomUUID().toString();
Cookie cookie;
try {
cookie = new Cookie("cart_session_id", URLEncoder.encode(cart_session_id,"UTF-8"));
cookie.setDomain(CommUtil.generic_domain(request));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
List<GoodsCart> carts_list = Lists.newArrayList();
List<GoodsCart> carts_cookie = Lists.newArrayList();
List<GoodsCart> carts_user = Lists.newArrayList();
User user = SecurityUserHolder.getCurrentUser();
Map cart_map = Maps.newHashMap();
if (user != null) {
user = this.userService.selectByPrimaryKey(user.getId());
if (!cart_session_id.equals("")) {
cart_map.clear();
cart_map.put("cart_session_id", cart_session_id);
cart_map.put("cart_status", Integer.valueOf(0));
carts_cookie = this.goodsCartService.queryPageList(cart_map);
if (user.getStore() != null) {
for (GoodsCart gc : carts_cookie) {
gc.getGoods().getGoods_type();
}
}
cart_map.clear();
cart_map.put("user_id", user.getId());
cart_map.put("cart_status", Integer.valueOf(0));
carts_user = this.goodsCartService.queryPageList(cart_map);
} else {
cart_map.clear();
cart_map.put("user_id", user.getId());
cart_map.put("cart_status", Integer.valueOf(0));
carts_user = this.goodsCartService.queryPageList(cart_map);
}
} else if (!cart_session_id.equals("")) {
cart_map.clear();
cart_map.put("cart_session_id", cart_session_id);
cart_map.put("cart_status", Integer.valueOf(0));
carts_cookie = this.goodsCartService.queryPageList(cart_map);
}
if (user != null) {
for (GoodsCart ugc : carts_user) {
carts_list.add(ugc);
}
for (GoodsCart cookie : carts_cookie) {
boolean add = true;
for (GoodsCart gc2 : carts_user) {
if ((cookie.getGoods().getId().equals(gc2.getGoods()
.getId()))
&& (cookie.getSpec_info()
.equals(gc2.getSpec_info()))) {
add = false;
this.goodsCartService.deleteById(cookie.getId());
}
}
if (add) {
cookie.setCart_session_id(null);
cookie.setUser(user);
this.goodsCartService.updateById(cookie);
carts_list.add(cookie);
}
}
} else {
for (GoodsCart cookie : carts_cookie) {
carts_list.add(cookie);
}
}
return carts_list;
}*/
}