java版直播商城之用户商品源码 B2B2C商城系统 多用户商城系统 直播带货 新零售商城 o2o商城 电子商务 拼团商城 分销商城 直播商城 短视频商城 springcloud商城

获取源码可搜索体验小程序: 海哇

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

package com.honghu.cloud.controller;

import java.util.ArrayList;
import java.util.HashMap;
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.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.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.dto.ModularClassDto;
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.tools.QueryTools;
import com.honghu.cloud.util.CommUtil;

import net.sf.json.JSONObject;

/**
 * 商品控制器
 * @author Administrator
 *
 */
@SuppressWarnings({"rawtypes","unchecked"})
@RestController
@RequestMapping(value = "/liveUserGoods")
/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST,RequestMethod.OPTIONS ,RequestMethod.DELETE,
		RequestMethod.PUT })*/
public class UserLiveGoodsController{
	
	@Autowired
	private GoodsFeignClient goodsFeignClient; 
	
	@Autowired
	private QueryTools queryTools;
	
	@Autowired
	private UserFeignClient userFeignClient;
	
	@Autowired
	private SysConfigFeignClient sysConfigFeignClient;
	
	@Autowired
	private ModularClassFeignClient modularClassFeignClient;
	
	
	/**
	 * 主播添加的商品
	 * @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);
			}else{
				ModularClassDto ModularClassDto = modularClassFeignClient.selectByStoreId(user.getStore_id());
				if (ModularClassDto == null || ModularClassDto.isTimely()) {//为附近配送不添加到我的商品里面
					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);
	}
	
	
	
	/**
	 * 大厅商品
	 * @param json
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/hallGoodsApp", method = RequestMethod.POST)
	public ResponseVO hallGoods(@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 userName = json.optString("userName");			//用户userName
		
		if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);			//用户userName不能为空
    	}
		
		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);
		maps.put("hall_goods", 1);
		maps.put("uid", user.getId());
		maps.put("liveUserAdd", "yes");
		maps.put("is_distribution", "yes");
		
		Map<String, Object> resultMap = goodsFeignClient.getQueryPageList(maps);
		
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, resultMap);
	}
	
	/**
	 * 添加商品
	 * @param json
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/userLiveGoodsAddApp", method = RequestMethod.POST)
	public ResponseVO user_live_goods_add(@RequestBody JSONObject json) {
		Long goods_id = json.optLong("goods_id");	//商品编号 
		String userName = json.optString("userName");			//用户userName
		
		if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);			//用户userName不能为空
    	}
		if(goods_id == null || goods_id <=0){
			return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ID_ISNULL, null);			//商品编号不能为空
    	}
		
		UserDto user = userFeignClient.selectByUserName(userName);			//用户
    	if(user==null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null);	//用户不存在
    	}
    	Long user_id = user.getId();	
    	
		Integer count = goodsFeignClient.findUserLiveGoods(user_id, goods_id);
		if(count != null && count > 0 ){
			return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ADD_REPEAT_ISNULL, null);	//重复添加数据
		}
		Map<String, Object> params = new HashMap<String,Object>();
		params.put("uid", user_id);
		params.put("goods_id", goods_id);
		goodsFeignClient.addUserLiveGoods(params);
		
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);
	}
	
	
	/**
	 * 移除商品
	 * @param json
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/userLiveGoodsDelApp", method = RequestMethod.POST)
	public ResponseVO user_live_goods_del(@RequestBody JSONObject json) {
		Long goods_id = json.optLong("goods_id");	//商品编号 
		String userName = json.optString("userName");			//用户userName
		
		if(StringUtils.isEmpty(userName)){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_USERNAME_ISNULL, null);			//用户userName不能为空
    	}
		if(goods_id == null || goods_id <=0){
			return ResponseCode.buildEnumResponseVO(ResponseCode.LIVE_GOODS_ID_ISNULL, null);			//商品编号不能为空
    	}
		
		UserDto user = userFeignClient.selectByUserName(userName);			//用户
    	if(user==null){
    		return ResponseCode.buildEnumResponseVO(ResponseCode.USER_DOES_NOT_EXIST, null);	//用户不存在
    	}
    	Long user_id = user.getId();	
		
		Map<String, Object> params = new HashMap<String,Object>();
		params.put("uid", CommUtil.null2Long(user_id));
		params.put("goods_id", CommUtil.null2Long(goods_id));
		goodsFeignClient.delUserLiveGoods(params);
		
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, null);
	}
	
	
}


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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

企业软件定制

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

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

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

打赏作者

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

抵扣说明:

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

余额充值