java版Spring Cloud + Mybatis + uniapp + Redis + MQ + VR全景 + 直播带货 + 短视频带货 + 三级分销 构建分布式+微服务b2b2c o2o商城

 @源码地址来源: https://minglisoft.cn/honghu/business.html
package com.honghu.cloud.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
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.RestController;

import com.honghu.cloud.bean.LiveBaby;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.common.page.Page;
import com.honghu.cloud.dto.GoodsDto;
import com.honghu.cloud.dto.ModularClassDto;
import com.honghu.cloud.dto.SysConfigDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.feign.GoodsFeignClient;
import com.honghu.cloud.feign.ModularClassFeignClient;
import com.honghu.cloud.feign.SysConfigFeignClient;
import com.honghu.cloud.feign.UserFeignClient;
import com.honghu.cloud.service.LiveBabyService;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;

import net.sf.json.JSONObject;

/**
 * 直播间宝贝控制器
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value="/liveBaby")
public class LiveBabyController {

    @Autowired
    private LiveBabyService liveBabyService;
    @Autowired
    private GoodsFeignClient goodsFeignClient;
    @Autowired
	private SysConfigFeignClient sysConfigFeignClient;
    @Autowired
	private UserFeignClient userFeignClient;
    @Autowired
    private ModularClassFeignClient modularClassFeignClient;
    
    /**
     * 直播宝贝列表数据查询
     * @param request
     * @param json	
     * 		currentPage:当前页数
     * 		pageSize:每页大小
     * 		type:  查询类【all-全部,yes-已播,not-未播    pay-已购】
     * @return
     */
    @RequestMapping("/getLiveBabyAll_bak")
    public ResponseVO getLiveBabyAll_bak(@RequestBody JSONObject json) {
    	String currentPage = json.optString("currentPage");			//当前页数
    	String pageSize = json.optString("pageSize");			    //每页大小
    	String type = json.optString("type");						//查询方式
    	String userName = json.optString("userName");			    //用户名
    	if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);	//用户userName不能为空
    	}
    	if(StringUtils.isEmpty(type)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null);	//直播间宝贝类型不能为空
    	}
    	UserDto user = userFeignClient.selectByUserName(userName);
    	if(user == null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null);	//用户不存在
    	}
    	if(user.getStore_id() == null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null);	//你未开通店铺
    	}
    	Map<String, Object> paraMap = new HashMap<String, Object>();
    	paraMap.put("currentPage", currentPage);
    	paraMap.put("pageSize", pageSize);
    	paraMap.put("goods_store_id", user.getStore_id());   			//商品所属店铺编号
    	paraMap.put("goods_status", 0);		//商品状态标识
    	if(type.equals("not")){
    		paraMap.put("live_user_id", user.getUserName()); 					//主播用户编号
		}
		if(type.equals("yes")){
			paraMap.put("live_creater_id", user.getUserName()); 				//主播用户编号
		}
		if(type.equals("pay")){
			paraMap.put("pay_status", 1); 								//是否已购,0为未购买,1为已购
			paraMap.put("live_creater_id", user.getUserName()); 				//主播用户编号
		}
		Map<String, Object> resultMap = goodsFeignClient.getQueryPageList(paraMap);	//查询店铺商品列表
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);	//请求成功、结果处理成功
    }
    
    
    
    
    /**
     * 直播宝贝列表数据查询
     * @param request
     * @param json	
     * 		currentPage:当前页数
     * 		pageSize:每页大小
     * 		type:  查询类【all-全部,yes-已播,not-未播    pay-已购】
     * @return
     */
    @RequestMapping("/getLiveBabyAll_bak_new")
    public ResponseVO getLiveBabyAll_bak_new(@RequestBody JSONObject json,HttpServletRequest request) {
    	String currentPage = json.optString("currentPage");			//当前页数
    	String pageSize = json.optString("pageSize");			    //每页大小
    	String type = json.optString("type");						//查询方式
    	String tokenStr = request.getHeader("token");
		Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
		if(user_id == null){
			return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null); 
		}
		UserDto user = userFeignClient.selectByPrimaryKey(user_id);
		if(user == null){
			// 用户不存在
			return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
		}
    	if(StringUtils.isEmpty(type)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null);	//直播间宝贝类型不能为空
    	}
    	if(user.getStore_id() == null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null);	//你未开通店铺
    	}
    	Map<String, Object> paraMap = new HashMap<String, Object>();
    	paraMap.put("currentPage", currentPage);
    	paraMap.put("pageSize", pageSize);
    	paraMap.put("goods_store_id", user.getStore_id());   			//商品所属店铺编号
    	paraMap.put("goods_status", 0);		//商品状态标识
    	if(type.equals("not")){
    		paraMap.put("live_user_id", user.getUserName()); 					//主播用户编号
		}
		if(type.equals("yes")){
			paraMap.put("live_creater_id", user.getUserName()); 				//主播用户编号
		}
		if(type.equals("pay")){
			paraMap.put("pay_status", 1); 								//是否已购,0为未购买,1为已购
			paraMap.put("live_creater_id", user.getUserName()); 				//主播用户编号
		}
		
		

		Map<String, Object> resultMap = goodsFeignClient.getQueryPageList(paraMap);	//查询店铺商品列表
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);	//请求成功、结果处理成功
    }
    
    
    /**
     * 直播宝贝列表数据查询
     * @param request
     * @param json	
     * 		currentPage:当前页数
     * 		pageSize:每页大小
     * 		type:  查询类【all-全部,yes-已播,not-未播    pay-已购】
     * @return
     */
    @RequestMapping("/getLiveBabyAll")
    public ResponseVO getLiveBabyAll(@RequestBody JSONObject json) {
    	String currentPage = json.optString("currentPage");			//当前页数
    	String pageSize = json.optString("pageSize");			    //每页大小
    	String type = json.optString("type");						//查询方式
    	String userName = json.optString("userName");			    //用户名
    	if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);	//用户userName不能为空
    	}
    	if(StringUtils.isEmpty(type)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null);	//直播间宝贝类型不能为空
    	}
    	UserDto user = userFeignClient.selectByUserName(userName);
    	if(user == null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null);	//用户不存在
    	}
    	if(user.getStore_id() == null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null);	//你未开通店铺
    	}
    	
    	Map<String, Object> paraMap = new HashMap<String, Object>();
    	paraMap.put("currentPage", currentPage);
    	paraMap.put("pageSize", pageSize);
    	paraMap.put("goods_status", 0);		//商品状态标识
    	paraMap.put("live_uid", user.getId()); 	
    	if(type.equals("not")){
    		
		}
		if(type.equals("yes")){
			
		}
		if(type.equals("pay")){
			paraMap.put("pay_status", 1); 	
			//是否已购,0为未购买,1为已购
			
		}
		Map<String, Object> resultMap = goodsFeignClient.getQueryPageList(paraMap);	//查询店铺商品列表
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);	//请求成功、结果处理成功
    }
    
    
    /**
     * 直播宝贝列表数据查询
     * @param request
     * @param json	
     * 		currentPage:当前页数
     * 		pageSize:每页大小
     * 		type:  查询类【all-全部,yes-已播,not-未播    pay-已购】
     * @return
     */
    @RequestMapping("/getLiveBabyAll_new")
	public ResponseVO getLiveBabyAll_new(@RequestBody JSONObject json, HttpServletRequest request) {
		String currentPage = json.optString("currentPage"); // 当前页数
		String pageSize = json.optString("pageSize"); // 每页大小
		String type = json.optString("type"); // 查询方式
		String tokenStr = request.getHeader("token");
		Long user_id = SecurityUserHolder.getTokenUserId(tokenStr);
		if (user_id == null) {
			return ResponseCode.buildEnumResponseVO(ResponseCode.TOKEN_EXPIRE, null);
		}
		UserDto user = userFeignClient.selectByPrimaryKey(user_id);
		if (user == null) {
			// 用户不存在
			return ResponseCode.buildEnumResponseVO(ResponseCode.USER_NOT_EXISTS_ERROR, null);
		}
		if (StringUtils.isEmpty(type)) {
			return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_TYPE_ISNULL, null); // 直播间宝贝类型不能为空
		}
		

		Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("currentPage", currentPage);
		paraMap.put("pageSize", pageSize);
		paraMap.put("goods_status", 0); // 商品状态标识

		boolean seleteStore = false;
		if (user.getStore_id() != null) { // 查询是否是特殊行业的店,
			ModularClassDto modularClassDto = modularClassFeignClient.selectByStoreId(user.getStore_id());
			if (modularClassDto != null && !modularClassDto.isTimely()) {
				seleteStore = true;
			}
		}
		if (type.equals("yes") && seleteStore) {
			if (user.getStore_id() == null) {
				return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNULL, null); // 你未开通店铺
			}
			paraMap.put("and_store_goods", user.getId()); // 店铺商品
		} else if (type.equals("all") && seleteStore) {
			paraMap.put("or_store_goods", user.getId()); // 查全部
			paraMap.put("live_uid", user.getId());
		} else if (type.equals("all") && !seleteStore) {
			paraMap.put("live_uid", user.getId()); // 查询中间表 , 但是店铺为特殊行业 ,不查店铺
		} else if (type.equals("yes") && !seleteStore) {
			return ResponseCode.buildEnumResponseVO(ResponseCode.STORE_ISNEARBY, null); // 店铺为特殊行业暂无法添加
		}

		Map<String, Object> resultMap = goodsFeignClient.getQueryPageList(paraMap); // 查询店铺商品列表
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap); // 请求成功、结果处理成功
	}
    
    
    /**
     * 直播间宝贝列表数据查询
     * @param params
     */
    @RequestMapping("/getLiveGoodsList")   
    public ResponseVO getLiveGoodsList(@RequestBody JSONObject json) {
    	String currentPage = json.optString("currentPage");			//当前页数
    	String pageSize = json.optString("pageSize");			    // 每页大小
    	String live_id = json.optString("live_id");			    	//主播间编号
    	if(StringUtils.isEmpty(live_id)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_ID_ISNULL, null);			//直播间ID不能为空
    	}
    	
    	Map<String ,Object>  params = new HashMap<String, Object>();
    	params.put("currentPage",currentPage);
    	params.put("pageSize",pageSize);
    	params.put("live_id",live_id);
    	
    	Page<GoodsDto> page = liveBabyService.getLiveGoodsList(params);
    	List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
    	SysConfigDto sysConfigDto=sysConfigFeignClient.getSysConfig();
    	for (GoodsDto obj : page.getResult()) {
    		 Map<String,Object> goods = new HashMap<String, Object>();
    		 goods.put("id", obj.getId());									//商品编号
    		 if(null!=sysConfigDto && null != obj.getGoods_main_photo()){
    			 goods.put("BigPicture",sysConfigDto.getImageWebServer()+"/"+
    					 obj.getGoods_main_photo().getPath()+"/"+obj.getGoods_main_photo().getName());	//商品主图片访问路径
    			
    		 }else{
    			 goods.put("BigPicture",null);	//商品主图片访问路径
    		 }
    		 goods.put("goods_name", obj.getGoods_name());					//商品名称
    		 goods.put("store_price", obj.getStore_price());				//商品店铺价格
    		 goods.put("dis_money", obj.getDis_money());					//商品分销收益(具体的金额)
    		 goods.put("goods_inventory",obj.getGoods_inventory());			//商品库存数量
    		 goods.put("smallProgram", "");									//小程序访问路径
    		 result.add(goods);                                             //迭加商品到list集合中
		}
    	
    	Map<String ,Object> resultMap = new HashMap<String, Object>();
    	resultMap.put("currentPage", page.getCurrentPage());
		resultMap.put("pages", page.getPages());
		resultMap.put("pageSize", page.getPageSize());
		resultMap.put("result", result);
		resultMap.put("rowCount", page.getRowCount());
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);			//请求成功、结果处理成功
    }
    
    
    
    
    /**
     * 直播宝贝数据查询
     * @param id
     * @return
     */
    @RequestMapping("/livebaby")
    public LiveBaby findUserById(@RequestBody JSONObject json) {
    	Long id = json.optLong("id");
        return liveBabyService.selectByPrimaryKey(id);
    }

    /**
     * 添加直播宝贝数据
     * @param liveBaby
     */
    @RequestMapping("/add_livebaby")
    public LiveBaby add_livebaby(@RequestBody JSONObject json) {
    	JSONObject obj = JSONObject.fromObject(json);
    	LiveBaby liveBaby = (LiveBaby)JSONObject.toBean(obj,LiveBaby.class);
    	liveBabyService.addLiveBaby(liveBaby);;
        return liveBaby;
    }
    
    
	/**
	 * vr添加商品
	 * @param json
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/myLiveGoodsApp", method = RequestMethod.POST)
	public ResponseVO myLiveGoods(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) {
		String currentPage = json.optString("currentPage"); 
		Integer pageSize = json.optInt("pageSize");			    //数据长度
		String orderBy = json.optString("orderBy");					//排序字段(默认添加的时间)
		String orderType = json.optString("orderType");				//排序方式(倒序)
		String type = json.optString("type"); 						//hall_goods 大厅商品   store_goods 店铺商品  
		String userName = json.optString("userName");			//用户userName
		
		if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);			//用户userName不能为空
    	}
		
		if(StringUtils.isEmpty(type)){
			return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USER_GOODS_TYPE_ISNULL, null);			//用户我的商品类型不能为空
		}
		
		UserDto user = userFeignClient.selectByUserName(userName);			//用户
    	if(user==null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null);	//用户不存在
    	}
		
		Map<String,Object> maps= QueryTools.getParams(currentPage, pageSize, orderBy, orderType);
		maps.put("goods_status", 0);
		
		if(StringUtils.equals(type, "hall_goods")){
			maps.put("live_uid", user.getId());
			if(user.getStore_id() != null){
				maps.put("no_goods_store_id", user.getStore_id());
			}
		}
		Map<String, Object> resultMap = new HashMap<String, Object>();
		if(StringUtils.equals(type, "store_goods")){
			maps.put("goods_store_id", user.getStore_id());
			if(user.getStore_id() == null){
				resultMap.put("currentPage", 0);
				resultMap.put("pages", 0);
				resultMap.put("pageSize", 12);
				List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
				resultMap.put("result", list);
				resultMap.put("rowCount", 0);
				return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
			}
		}
		resultMap = goodsFeignClient.getQueryPageList(maps);
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
	}
}
 @源码地址来源: https://minglisoft.cn/honghu/business.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

企业软件定制

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值