七十三、java版商城之买家端商品详情Spring Cloud+SpringBoot+mybatis+uniapp b2b2c o2o 多商家入驻商城 直播带货商城 电子商务

一个好的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.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

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

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.CombinPlan;
import com.honghu.cloud.bean.ComplaintGoods;
import com.honghu.cloud.bean.Consult;
import com.honghu.cloud.bean.Evaluate;
import com.honghu.cloud.bean.Goods;
import com.honghu.cloud.bean.GoodsBrand;
import com.honghu.cloud.bean.GoodsCart;
import com.honghu.cloud.bean.GoodsClass;
import com.honghu.cloud.bean.GoodsSpecProperty;
import com.honghu.cloud.bean.GoodsSpecification;
import com.honghu.cloud.bean.Transport;
import com.honghu.cloud.bean.UserGoodsClass;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.common.page.Page;
import com.honghu.cloud.configure.StoreVisitMqClient;
import com.honghu.cloud.dto.AccessoryDto;
import com.honghu.cloud.dto.ActivityDto;
import com.honghu.cloud.dto.ActivityGoodsDto;
import com.honghu.cloud.dto.AreaDto;
import com.honghu.cloud.dto.BuyGiftDto;
import com.honghu.cloud.dto.EnoughReduceDto;
import com.honghu.cloud.dto.FavoriteDto;
import com.honghu.cloud.dto.FeignCommonPageDto;
import com.honghu.cloud.dto.FreeApplyLogDto;
import com.honghu.cloud.dto.FreeGoodsDto;
import com.honghu.cloud.dto.GoodsDto;
import com.honghu.cloud.dto.GoodsPhotosDto;
import com.honghu.cloud.dto.GroupDto;
import com.honghu.cloud.dto.GroupGoodsDto;
import com.honghu.cloud.dto.MerchantServicesDto;
import com.honghu.cloud.dto.PinPayRecordDto;
import com.honghu.cloud.dto.PinRuleDto;
import com.honghu.cloud.dto.StoreDto;
import com.honghu.cloud.dto.SysConfigDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.ActivityFeignClient;
import com.honghu.cloud.feign.ActivityGoodsFeignClient;
import com.honghu.cloud.feign.ActivityToolsFeignClient;
import com.honghu.cloud.feign.AreaFeignClient;
import com.honghu.cloud.feign.AreaToolsFeignClient;
import com.honghu.cloud.feign.BuyGiftFeignClient;
import com.honghu.cloud.feign.CouponToolsFeignClient;
import com.honghu.cloud.feign.CustomerrelmanaFeignClient;
import com.honghu.cloud.feign.EnoughReduceFeignClient;
import com.honghu.cloud.feign.FavoriteFeignClient;
import com.honghu.cloud.feign.FootPointFeignClient;
import com.honghu.cloud.feign.FreeApplyLogFeignClient;
import com.honghu.cloud.feign.FreeGoodsFeignClient;
import com.honghu.cloud.feign.GroupGoodsFeignClient;
import com.honghu.cloud.feign.JiguangPushFeignClient;
import com.honghu.cloud.feign.LiveGoodsClickFeignClient;
import com.honghu.cloud.feign.MerchantServicesFeignClient;
import com.honghu.cloud.feign.OrderFormFeignClient;
import com.honghu.cloud.feign.OrderFormToolsFeignClient;
import com.honghu.cloud.feign.PinRuleFeignClient;
import com.honghu.cloud.feign.StoreFeignClient;
import com.honghu.cloud.feign.SysConfigFeignClient;
import com.honghu.cloud.feign.TXTemplateFeignClient;
import com.honghu.cloud.feign.UserFeignClient;
import com.honghu.cloud.service.ICombinPlanService;
import com.honghu.cloud.service.IConsultService;
import com.honghu.cloud.service.IGoodsBrandService;
import com.honghu.cloud.service.IGoodsCartService;
import com.honghu.cloud.service.IGoodsClassService;
import com.honghu.cloud.service.IGoodsService;
import com.honghu.cloud.service.IGoodsSpecPropertyService;
import com.honghu.cloud.service.IGoodsSpecificationService;
import com.honghu.cloud.service.IInventoryService;
import com.honghu.cloud.service.ITransportService;
import com.honghu.cloud.service.impl.ComplaintGoodsServiceImpl;
import com.honghu.cloud.tools.CartTools;
import com.honghu.cloud.tools.EvaluateViewTools;
import com.honghu.cloud.tools.GoodsTools;
import com.honghu.cloud.tools.GoodsViewTools;
import com.honghu.cloud.tools.QueryTools;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.tools.TransportTools;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.utils.Exceptions;
import com.honghu.cloud.vo.GoodsVo;

import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;

/**
 * 商品控制器
 * @author Administrator
 *
 */
@Slf4j
@SuppressWarnings({"rawtypes","unchecked"})
@RestController
@RequestMapping(value = "/goods")
/*/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
		RequestMethod.PUT })*/
public class GoodsController{
	
	private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);
	
	@Autowired
	private SysConfigFeignClient sysConfigFeignClient;
	@Autowired
	private AreaFeignClient areaFeignClient;
	
	@Autowired
	private FootPointFeignClient footPointFeignClient;
	@Autowired
	private UserFeignClient userFeignClient;
	@Autowired
	private FavoriteFeignClient favoriteFeignClient;
	
	@Autowired
	private ActivityGoodsFeignClient activityGoodsFeignClient;
	@Autowired
	private ActivityFeignClient activityFeignClient;
	@Autowired
	private ActivityToolsFeignClient activityToolsFeignClient;
	@Autowired
	private BuyGiftFeignClient buyGiftFeignClient;
	@Autowired
	private EnoughReduceFeignClient enoughReduceFeignClient;
	@Autowired
	private FreeGoodsFeignClient freeGoodsFeignClient;
	@Autowired
	private FreeApplyLogFeignClient freeApplyLogFeignClient;
	
	@Autowired
	private IGoodsClassService goodsClassService;
	
	@Autowired
	private GoodsTools goodsTools;
	@Autowired
	private AreaToolsFeignClient areaToolsFeignClient;
	@Autowired
	private QueryTools queryTools;
	@Autowired
	private TransportTools transportTools;
	@Autowired
	private IGoodsService goodsService; 
	@Autowired
	private IConsultService consultService;
	@Autowired
	private IGoodsCartService goodsCartService;
	@Autowired
	private ICombinPlanService combinplanService;
	@Autowired
	private MerchantServicesFeignClient merchantServicesFeignClient;
	@Autowired
	private EvaluateViewTools evaluateViewTools;
	@Autowired
	private AccessoryFeignClient accessoryFeignClient;
	@Autowired
	private IGoodsSpecificationService goodsSpecificationService;
	@Autowired
	private ITransportService transportService;
	@Autowired
	private StoreFeignClient storeFeignClient;
	@Autowired
	private IInventoryService inventoryService;
	@Autowired
	private GoodsViewTools goodsViewTools;
	@Autowired
	private GroupGoodsFeignClient groupGoodsFeignClient;
	@Autowired
	public IGoodsBrandService goodsBrandService;
	@Autowired
	private CartTools cartTools;
	@Autowired
	private IGoodsSpecPropertyService specPropertyService;
	@Autowired
	private LiveGoodsClickFeignClient liveGoodsClickFeignClient;
	@Autowired
	private StoreVisitMqClient storeVisitMqClient;
	@Autowired
	private ComplaintGoodsServiceImpl complaintGoodsService;
	@Autowired
	private TXTemplateFeignClient tXTemplateFeignClient;
	@Autowired
	private JiguangPushFeignClient jiguangPushFeignClient;
	@Autowired
	private CustomerrelmanaFeignClient customerrelmanaFeignClient;
	@Autowired
	private OrderFormToolsFeignClient orderFormToolsFeignClient;
	@Autowired
	private PinRuleFeignClient pinRuleFeignClient;
	@Autowired
	private CouponToolsFeignClient couponToolsFeignClient;
	

	@RequestMapping(value = "/apiForFeign/batchDeleteUserGoodsClass", method = RequestMethod.POST)
	public void batchDeleteUserGoodsClass(@RequestBody Map<String, Object> params) {
		goodsService.batchDeleteUserGoodsClass(params);
	}
	@RequestMapping(value = "/apiForFeign/batchDeleteGoodsPhotos", method = RequestMethod.POST)
	public void batchDeleteGoodsPhotos(@RequestBody Map<String, Object> params) {
		goodsService.batchDeleteGoodsPhotos(params);
	}
	@RequestMapping(value = "/apiForFeign/saveGoodsPhotos", method = RequestMethod.POST)
	public void saveGoodsPhotos(@RequestBody GoodsPhotosDto GoodsPhotosDto) {
		goodsService.saveGoodsPhotos_new(GoodsPhotosDto);
	}
	@RequestMapping(value = "/apiForFeign/batchDeleteGoodsSpecProperty", method = RequestMethod.POST)
	public void batchDeleteGoodsSpecProperty(@RequestBody Map<String, Object> params) {
		goodsService.batchDeleteGoodsSpecProperty(params);
	}
	@RequestMapping(value = "/apiForFeign/selectCount", method = RequestMethod.POST)
	public int selectCount(@RequestBody Map<String, Object> params) {
		return goodsService.selectCount(params);
	}
	@RequestMapping(value = "/apiForFeign/selectSalenum", method = RequestMethod.POST)
	public int selectSalenum(@RequestBody Map<String, Object> params) {
		return goodsService.selectSalenum(params);
	}
	
	@RequestMapping(value = "/apiForFeign/saveGoodsUserGoodsClass", method = RequestMethod.POST)
	public void saveGoodsUserGoodsClass(@RequestBody Map<String, Object> params) {
		List<UserGoodsClass> goods_ugcs =(List<UserGoodsClass>) params.get("goods_ugcs");
		goodsService.saveGoodsUserGoodsClass(CommUtil.null2Long(params.get("id")),goods_ugcs);
	}
	
	@RequestMapping(value = "/apiForFeign/deleteById", method = RequestMethod.GET)
	public void deleteById(@RequestParam("id")Long id) {
		Goods goods = goodsService.selectByPrimaryKey(id);
		goodsListDel(goods);
		goodsService.deleteById(id);
	}

	private void goodsListDel(Goods goods) {
		Map<String,Object> params = Maps.newHashMap();
		params.put("goods_id", goods.getId());
		List<ComplaintGoods> complaintGoodses = this.complaintGoodsService.queryPageList(params);
		
		for (ComplaintGoods cg : complaintGoodses) {
			this.complaintGoodsService.deleteById(cg.getId());
		}
		/*params.clear();
		
		params.put("gg_goods_id", goods.getId());
		List<GroupGoodsDto> groupGoodses = this.groupGoodsFeignClient.queryPageList(params);
		
		for (GroupGoodsDto gg : groupGoodses) {
			this.groupGoodsFeignClient.deleteById(gg.getId());
		}*/
		
		/*params.clear();
		params.put("zgl_goods_id", goods.getId());
		List<ZTCGoldLog> ztcGoldLogs = this.iztcGoldLogService.queryPageList(params);
		
		if (((List) ztcGoldLogs).size() > 0) {
			for (ZTCGoldLog ztcGoldLog : ztcGoldLogs) {
				this.iztcGoldLogService.deleteById(ztcGoldLog.getId());
			}
		}*/
		for (GoodsCart cart : goods.getCarts()) {
			this.goodsCartService.deleteById(cart.getId());
		}
		goods.getCarts().clear();
		goods.getGoods_ugcs().clear();
		goods.getAg_goods_list().clear();
		goods.getGroup_goods_list().clear();
		goods.setDeleteStatus(1);
		this.goodsService.delete(goods.getId());

	/*	this.goodsTools.deleteGoodsLucene(goods);*/
	}
	@RequestMapping(value = "/apiForFeign/saveEntity", method = RequestMethod.POST)
	public Long saveEntity(@RequestBody Goods obj) {
		Goods goods=obj;
		goodsService.saveEntity(goods);
		return goods.getId();
	}
	
	@RequestMapping(value = "/apiForFeign/getRecommendGoods", method = RequestMethod.POST)
	public List<Goods> getRecommendGoods(@RequestBody List<Long> ids){
		return goodsService.getRecommendGoods(ids);
	}
	
	@RequestMapping(value = "/apiForFeign/list", method = RequestMethod.POST)
	public Map<String, Object> list(@RequestBody Map<String, Object> params) {
		Page<Goods> iPageList = goodsService.list(params);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("currentPage", iPageList.getCurrentPage());
		resultMap.put("pages", iPageList.getPages());
		resultMap.put("pageSize", iPageList.getPageSize());
		resultMap.put("result", iPageList.getResult());
		resultMap.put("rowCount", iPageList.getRowCount());
		return resultMap;
	}
	@RequestMapping(value = "/apiForFeign/listIndex", method = RequestMethod.POST)
	public Map<String, Object> listIndex(@RequestBody Map<String, Object> params) {
		Page<GoodsVo> iPageList = goodsService.listIndex(params);
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("currentPage", iPageList.getCurrentPage());
		resultMap.put("pages", iPageList.getPages());
		resultMap.put("pageSize", iPageList.getPageSize());
		resultMap.put("result", iPageList.getResult());
		resultMap.put("rowCount", iPageList.getRowCount());
		return resultMap;
	}
	
	@RequestMapping(value = "/apiForFeign/queryPageList", method = RequestMethod.POST)
	public List<Goods> queryPageList(@RequestBody FeignCommonPageDto commonPageDto) {
		return goodsService.queryPageList(commonPageDto.getParams(), 
				commonPageDto.getBegin(), commonPageDto.getMax());
	}
	
	/**
	 * 根据商品id查询商品
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/selectByPrimaryKey", method = RequestMethod.GET)
	public Goods selectByPrimaryKey(@RequestParam("id")Long id) {
		Goods goods = goodsService.selectByPrimaryKey(id);
		return goods;
	}
	

	@RequestMapping(value = "/apiForFeign/deleteGoodsPhotosById", method = RequestMethod.GET)
	public void deleteGoodsPhotosById(@RequestParam("id")Long id) {
		goodsService.deleteGoodsPhotosById(id);
	}
	@RequestMapping(value = "/apiForFeign/updateById", method = RequestMethod.POST)
	public void updateById(@RequestBody Goods obj) {
		goodsService.updateById(obj);
	}
	
	/**
	 * 查询用户添加的商品是否存在
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/findUserLiveGoods", method = RequestMethod.GET)
	public Integer findUserLiveGoods(@RequestParam("user_id")Long user_id, @RequestParam("goods_id")Long goods_id) {
		return goodsService.findUserLiveGoods(user_id, goods_id);
	}
	
	/**
	 * 主播用户添加商品
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/addUserLiveGoods", method = RequestMethod.POST)
	public void addUserLiveGoods(@RequestBody Map<String, Object> params) {
		goodsService.addUserLiveGoods(params);
	}
	
	/**
	 * 主播用户删除商品
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/delUserLiveGoods", method = RequestMethod.POST)
	public void delUserLiveGoods(@RequestBody Map<String, Object> params) {
		goodsService.delUserLiveGoods(params);
	}
	
	
	/**
	 * 手机端商品详情
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping({ "/items" })
	public Map<String, Object> items(HttpServletRequest request,HttpServletResponse response, @RequestBody JSONObject json) {
		String id = json.optString("id");
		String share_uid = null;
		String live_id = null;
		if(json.containsKey("share_uid")){
			 share_uid = json.optString("share_uid");
		}
		
		if(json.containsKey("live_id")){
			live_id = json.optString("live_id");
		}
		
		Map<String, Object> result = new HashMap<String, Object>();
		Goods obj = goodsService.selectByPrimaryKey(CommUtil.null2Long(id));
		if(obj == null){
			return ResponseCode.buildCodeMap("10003", "商品不存在", null);
		}
		Long wx_user_id = null;
		if(obj.getGoods_store_id() != null){
			obj.setGoods_store(storeFeignClient.selectByPrimaryKey(obj.getGoods_store_id()));
			UserDto user = userFeignClient.getUserByStoreId(obj.getGoods_store_id());
			if (user!=null) {
				obj.setStoreUserId(user.getId());
				obj.setStoreUserName(user.getUserName());
				wx_user_id=user.getId();
			}
		}
		// 商品图片
		List<AccessoryDto> goods_photos = accessoryFeignClient.getGoodsPhotosByAccessoryId(obj.getId());
		goods_photos.add(0, obj.getGoods_main_photo());
		obj.setGoods_photos(goods_photos);
		
		
		// 查询商品规格集合
		List<GoodsSpecification> goods_specis = goodsSpecificationService.getGoodsIdSpecification(obj.getId());
		// 查询自定义规格
		if (StringUtils.isNotEmpty(obj.getGoods_specs_info()) && goods_specis.size() > 0) {
			List<Map> goods_specs_info = JSON.parseArray(obj.getGoods_specs_info(), Map.class);
			for (GoodsSpecification goods_speci : goods_specis) {
				// Map specs_info = goods_specs_info.stream().filter(o ->o.get("id").toString().equals(goods_speci.getProperties().get(0).getId().toString())).findAny().orElse(null);
				for (Map map : goods_specs_info) {
					List<GoodsSpecProperty> properties = goods_speci.getProperties();
					for (GoodsSpecProperty goodsSpecProperty : properties) {
						if (map.get("id").equals(goodsSpecProperty.getId().toString())) {
							goodsSpecProperty.setValue(map.get("name").toString());
						}
					}

				}
			}
		}
		obj.setGoods_specis(goods_specis);
		
		//商品品牌
		if (null!=obj.getGoods_brand_id()) {
			GoodsBrand GoodsBrandDto = goodsBrandService.selectByPrimaryKey(obj.getGoods_brand_id());
			obj.setGoods_brand(GoodsBrandDto);
		}
		if (obj.getDelivery_area_id()!=null&&StringUtils.isEmpty(obj.getDelivery_area())) {
			//店铺地址
			AreaDto area = areaFeignClient.selectByPrimaryKeyFullParent(obj.getDelivery_area_id());
			if (area!=null&&area.getParent()!=null&&area.getParent().getParent()!=null) {
				String delivery_area = area.getParent().getParent()
						.getAreaName()
						+ area.getParent().getAreaName()
						+ area.getAreaName();
				obj.setDelivery_area(delivery_area);
			}
		}
	
		
		// 运费模板
		if(null != obj.getTransport_id()){
			obj.setTransport(transportService.selectByPrimaryKey(obj.getTransport_id()));
		}
		
		// 店铺信息
		if(null != obj.getGoods_store_id()){
			StoreDto storeDto = storeFeignClient.selectByPrimaryKey(obj.getGoods_store_id());
			obj.setGoods_store(storeDto);
		}
		
		SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
		// 处理详细说明app
		if(StringUtils.isNotEmpty(obj.getGoods_details_mobile())){
			obj.setGoods_details_mobile(CommUtil.addImgWebServer2(sysConfig.getImageWebServer(), obj.getGoods_details_mobile()));
		}
		UserDto current_user = userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		
		result.put("user", current_user);
		//记录用户浏览历史
		boolean sendMsg = false;
		if (current_user != null&&obj.getGoods_nearby()==0) {
			UserDto user = new UserDto();
			BeanUtils.copyProperties(current_user, user);
			GoodsDto goods = new GoodsDto();
			BeanUtils.copyProperties(obj, goods);
			
			sendMsg = footPointFeignClient.recordFootPoint(current_user.getId(),obj.getId());
			UserDto current_userDto = userFeignClient.selectByPrimaryKey(current_user.getId());
			BeanUtils.copyProperties(current_user, current_userDto);
		}
		if(com.honghu.cloud.utils.StringUtils.isNotBlank(live_id)){
			//记录直播间商品点击数量
			liveGoodsClickFeignClient.livegoodsclick_add(Long.parseLong(live_id), obj.getId());
		}
		//保存用户点击商品日志
		goodsTools.save_click_goodsLog(request, obj);
		int falcount = 0;
		if (((obj != null) && (obj.getGoods_status() == 0)) ) {
			String cart_session_id;
			List<GoodsCart> carts_user;
			
			//0为自营商品
			if (obj.getGoods_type() == 0) {
				obj.setGoods_click(obj.getGoods_click() + 1);
				
				//设置直通车点击量
				if ((sysConfig.getZtc_status()) && (obj.getZtc_status() == 2)) {
					obj.setZtc_click_num(obj.getZtc_click_num() + 1);
				}
				
				//用户购买限购数量
				userLimitCount(result, obj, current_user);
				
				//设置商品过期状态
//				this.updateActivityGoodsStatus(obj);
				
				//如果团购结束时间在当前时间过去。那么修改团购状态为0无团购信息
//				this.updateGoodsGroupBuyStatus(obj);
				
				//更新满就送状态
				this.updateEnoughGive(result, obj);
				
				//更新满就减
				this.updateEnoughReduce(result, obj);
				
				//更新商品
				goodsService.updateById(obj);
				
				//查询满就减数量
				falcount = freeCount(id, result, obj, falcount);
				
				Map cmap = Maps.newHashMap();
				cmap.put("goods_id", CommUtil.null2Long(id));
				//产品咨询管理
				List<Consult> consult_list = consultService.queryPageList(cmap);
				
				result.put("consul_count",consult_list.size());
				result.put("free_count", falcount);
				result.put("obj", obj);
				/*mv.addObject("goodsViewTools", this.goodsViewTools);
				mv.addObject("transportTools", this.transportTools);*/
				
				/*result.put("userTools", this.userTools);
				result.put("goodsViewTools", this.goodsViewTools);
				result.put("activityViewTools", this.activityViewTools);*/
				
				//获取cart_session_id
				cart_session_id = cart_session_id(request);
				
				List<GoodsCart> carts_list = Lists.newArrayList();//购物车
				List<GoodsCart> carts_cookie = Lists.newArrayList();//cookie中的购物车
				carts_user = Lists.newArrayList();
				
				Map cart_map = Maps.newHashMap();
				
				if (current_user != null) {
					
					if (!cart_session_id.equals("")) {
						cart_map.clear();
						cart_map.put("cart_session_id", cart_session_id);
					//	cart_map.put("cart_status", 0);//0表示没有提交为订单
						
						carts_cookie = this.goodsCartService.queryPageList(cart_map);
						
						//删除购买自己店铺的商品购物车
						this.deleteMineGoodsCart(carts_cookie, current_user);
						
						cart_map.clear();
						cart_map.put("user_id", current_user.getId());
						//cart_map.put("cart_status", 0);//0表示没有提交为订单
						
						carts_user = this.goodsCartService.queryPageList(cart_map);
						
					} else {
						cart_map.clear();
						cart_map.put("user_id", current_user.getId());
						//cart_map.put("cart_status", 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", 0);//0表示没有提交为订单
					
					carts_cookie = this.goodsCartService.queryPageList(cart_map);
					
				}
				
				boolean add;
				if (current_user != null) {
					for (GoodsCart cookie : carts_cookie) {
						add = true;
						for (GoodsCart gc2 : carts_user) {
							//如果购物车里面的商品和cookie中的购物车中的商品一致。就删除购物车中的cookie商品ID
							if (cookie.getGoods().getId().equals(gc2.getGoods().getId())) {
								// 规格内容
								if (cookie.getSpec_info().equals(gc2.getSpec_info())) {
									add = false;
									this.goodsCartService.deleteById(cookie.getId());
								}
							}
						}
						if (add) {
							cookie.setCart_session_id(null);
							cookie.setUser(current_user);
							this.goodsCartService.updateById(cookie);
							carts_list.add(cookie);
						}
					}
				} else {
					for (GoodsCart gc : carts_cookie) {
						carts_list.add(gc);
					}
				}
				
				for (GoodsCart gc : carts_user) {
					carts_list.add(gc);
				}
				
				List<GoodsCart> combin_carts_list = Lists.newArrayList();
				for (GoodsCart gc : carts_list) {
					if ((gc.getCart_type() != null)&& (gc.getCart_type().equals("combin")) && (gc.getCombin_main() != 1)) {
						combin_carts_list.add(gc);
					}
				}
				
				if (combin_carts_list.size() > 0) {
					carts_list.removeAll(combin_carts_list);
				}
				result.put("carts", carts_list);
			} else {
				obj.setGoods_click(obj.getGoods_click() + 1);
				if ((sysConfig.getZtc_status()) && (obj.getZtc_status() == 2)) {
					obj.setZtc_click_num(obj.getZtc_click_num() + 1);
				}
				int count = -1;
				if ((obj.getGoods_limit() == 1) && (obj.getGoods_limit_count() > 0)) {
					count = obj.getGoods_limit_count();
					if (current_user != null) {
						String info = CommUtil.null2String(current_user.getBuy_goods_limit_info());
						if (!info.equals("")) {
							Map maps = JSON.parseObject(CommUtil.null2String(info));
							List<Map> list = (List) maps.get("data");
							for (Map map : list) {
								String gid = CommUtil.null2String(map.get("gid"));
								if (CommUtil.null2Int(gid) == obj.getId().longValue()) {
									count = obj.getGoods_limit_count() - CommUtil.null2Int(map.get("count"));
									if (count < 1) {
										count = 0;
									}
								}
							}
						}
					}
				} else {
					count = -1;
				}
				result.put("count", Integer.valueOf(count));
				//设置商品过期状态
				this.updateActivityGoodsStatus(obj);
				
				//如果团购结束时间在当前时间过去。那么修改团购状态为0无团购信息
				this.updateGoodsGroupBuyStatus(obj);
				
				//设置套餐过期
				if (obj.getCombin_status() == 1) {
					Map<String, Object> params = Maps.newHashMap();
					params.put("endTime_less_than_equal", new Date());
					params.put("main_goods_id", obj.getId());
					
					List<CombinPlan> combins = combinplanService.queryPageList(params);

					if (combins.size() > 0) {
						for (CombinPlan com : combins) {
							if (com.getCombin_status()==0) {
								obj.setCombin_status(0);
								break;
							}
							if (com.getCombin_type() == 0) {
								if (obj.getCombin_suit_id().equals(com.getId())) {
									obj.setCombin_suit_id(null);
								}
							} else if (obj.getCombin_parts_id().equals(com.getId())) {
								obj.setCombin_parts_id(null);
							}
							obj.setCombin_status(0);
						}
					}
				}
				
				Goods goods;
				/*if (obj.getOrder_enough_give_status() == 1&&obj.getBuyGift_id()!=null) {
					BuyGiftDto bg = buyGiftFeignClient.selectByPrimaryKey(obj.getBuyGift_id());
					if ((bg != null) && (bg.getEndTime().before(new Date()))) {
						bg.setGift_status(20);
						List<Map> maps = JSON.parseArray(bg.getGift_info(),Map.class);
						maps.addAll(JSON.parseArray(bg.getGoods_info(),Map.class));
						for (Map map : maps) {
							goods = goodsService.selectByPrimaryKey(CommUtil.null2Long(map.get("goods_id")));
							if (goods != null) {
								goods.setOrder_enough_give_status(0);
								goods.setOrder_enough_if_give(0);
								goods.setBuyGift_id(null);
								goodsService.updateById(goods);
							}
						}
						buyGiftFeignClient.updateById(bg);
					}
					if ((bg != null) && (bg.getGift_status() == 10)) {
						result.put("isGift", Boolean.valueOf(true));
					}
				}else{
					result.put("isGift", Boolean.valueOf(true));
				}*/
				
			/*	if (obj.getOrder_enough_if_give() == 1) {
					BuyGiftDto bg = buyGiftFeignClient.selectByPrimaryKey(obj.getBuyGift_id());
					if ((bg != null) && (bg.getGift_status() == 10)) {
						result.put("isGive", Boolean.valueOf(true));
						
					}
				}*/
				//更新满就送状态
				this.updateEnoughGive(result, obj);
				//更新满就减
				this.updateEnoughReduce(result, obj);
				
				goodsService.updateById(obj);
				
				result.put("obj", obj);
				result.put("store", obj.getGoods_store());
				
				generic_evaluate(obj.getGoods_store(), result);
				
			}
			
			String current_ip = CommUtil.getIpAddr(request);
			// 调用feign获取城市信息
			AreaDto current_city = areaToolsFeignClient.getUserAreaInfo(current_ip);
			result.put("current_city", current_city);
			
			// 获取地址列表
			/*Map<String, Object> paramMap = new HashMap<String, Object>();
			paramMap.put("parent", -1);
			List<AreaDto> areas = areaFeignClient.queryPageList(paramMap);
			result.put("areas", areas);*/
			List coupons = Lists.newArrayList();
			coupons = couponToolsFeignClient.getUsableCoupon(CommUtil.null2Long(id), current_user.getId());
			result.put("coupons",coupons);
			//查询商品是否收藏
			result.put("mark", Integer.valueOf(0));
			if (null !=current_user &&  null!=current_user.getId()) {
				Map<String,Object> map = Maps.newHashMap();
				map.put("goods_id", obj.getId());
				map.put("user_id", current_user.getId());
				
				List<FavoriteDto> favorites = favoriteFeignClient.queryPageList(map);
				
				if (favorites.size() > 0) {
					result.put("mark", Integer.valueOf(1));
				}
			}
			
			List<Map> service_list = Lists.newArrayList();
			if (obj.getMerchantService_info() != null) {
				List<String> ms_list = JSON.parseArray(obj.getMerchantService_info(), String.class);
				for (String ms_id : ms_list) {
					MerchantServicesDto ms = merchantServicesFeignClient.selectByPrimaryKey(CommUtil.null2Long(ms_id));
					if(ms != null){
						Map m = Maps.newHashMap();
						m.put("id", ms_id);
						m.put("name", ms.getServe_name());
						m.put("img", ms.getService_img());
						m.put("path", ms.getService_img() != null ? ms
								.getService_img().getPath() + "/"
								+ ms.getService_img().getName() : "");
						service_list.add(m);
					}
				}
			}
			
			List<Map> advance_list = Lists.newArrayList();
			if ((obj.getAdvance_sale_type() == 1) && (obj.getAdvance_sale_info() != null)) {
				advance_list = JSON.parseArray(obj.getAdvance_sale_info(),Map.class);
			}
			
			result.put("advance_list", advance_list);
			
			int evaluates_count = this.evaluateViewTools.queryByEva(obj.getId().toString(), "all").size();
			int eva_count = evaluates_count + falcount;
			result.put("eva_count", eva_count);
			result.put("evaluates_count", evaluates_count);
			result.put("whether_free", obj.getWhether_free());
			
			int limit_count = -1;
			if ((obj.getGoods_limit() == 1) && (obj.getGoods_limit_count() > 0)) {
				limit_count = obj.getGoods_limit_count();
				if (current_user != null) {
					String info = CommUtil.null2String(current_user.getBuy_goods_limit_info());
					if (!info.equals("")) {
						Map maps = JSON.parseObject(CommUtil.null2String(info));
						List<Map> list = (List) maps.get("data");
						for (Map map : list) {
							String gid = CommUtil.null2String(map.get("gid"));
							if (CommUtil.null2Int(gid) == obj.getId()) {
								limit_count = obj.getGoods_limit_count() - CommUtil.null2Int(map.get("count"));
								if (limit_count < 1) {
									limit_count = 0;
								}
							}
						}
					}
				}
			} else {
				limit_count = -1;
			}
			
			if (obj.getCombin_status() == 1) {
				// 查询组合销售信息
				if (obj.getCombin_suit_id() != null) {
					//CombinPlan CombinPlan = combinplanService.selectByPrimaryKey(obj.getCombin_suit_id());
					result.put("CombinPlans", goodsViewTools.getCombinPlans(obj.getId() + "", "suit"));
				}else{result.put("CombinPlans",null);}
				//查询配件信息
				if (obj.getCombin_parts_id() != null) {
					//CombinPlan parts = combinplanService.selectByPrimaryKey(obj.getCombin_parts_id());
					result.put("parts", goodsViewTools.getCombinPlans(obj.getId() + "", "parts"));
				}
			}else{
				result.put("CombinPlans",null);
			}
			//查询增送商品
			if (obj.getOrder_enough_give_status()== 1&&obj.getBuyGift_id()!=null) {
				BuyGiftDto buyGift = buyGiftFeignClient.selectByPrimaryKey(obj.getBuyGift_id());
				result.put("buyGift", buyGift);
			}
			//查询拼的商品
			if(obj.getPin()==1){
				//TODO  查商品价格   需要查询折扣
				PinRuleDto PinRule = orderFormToolsFeignClient.getPinRuleByGoodsId(obj.getId());
				result.put("PinRule", PinRule);
				//查询商品           
				List<PinPayRecordDto> pinPayRecordList = orderFormToolsFeignClient.getPinPayRecordList(obj.getId(),PinRule.getNumber());
				result.put("pinPayRecordList", pinPayRecordList);
				
				
			}
			
			// 组合套装数量	
			result.put("suitCombinPlansSize", goodsViewTools.getCombinPlans(obj.getId()+"", "suit").size());
			// 组合配件数量
			result.put("partsCombinPlansSize", goodsViewTools.getCombinPlans(obj.getId()+"", "parts").size());
			// 活动商品信息
			if(obj.getActivity_status() == 2 && current_user != null){
				Map activityGoodsInfo = activityToolsFeignClient.getActivityGoodsInfo(obj.getId()+"", current_user.getId()+"");
				result.put("activity_map", activityGoodsInfo);
				obj.setStore_price(new BigDecimal(CommUtil.null2Double(activityGoodsInfo.get("rate_price"))));
				ActivityGoodsDto activitygoodsdto = activityGoodsFeignClient.selectByPrimaryKey(obj.getActivity_goods_id());
				ActivityDto activityDto = activityFeignClient.selectByPrimaryKey(activitygoodsdto.getAct_id());
				result.put("activityDto", activityDto);
				
			}
			result.put("limit_count", limit_count);
			if(com.honghu.cloud.utils.StringUtils.isNotBlank(share_uid)){
				result.put("share_uid", share_uid);
			}
			
			try {
				JSONObject jsonMsg = new JSONObject();
				jsonMsg.put("source", "1"); // 来源(1.小程序,2.app)
				jsonMsg.put("store_id", obj.getGoods_store_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));;
			}
			//浏览记录公众号推送
			try {
				//如果是自己进自己的店铺不需要发消息
				if(obj.getStoreUserId().longValue() != current_user.getId().longValue() && sysConfig.getSys_store_news() == 1 && obj.getGoods_store().getStore_news() == 1 && sendMsg){
					//判断 一人一个商品只发送一次
					Map<String, Object> params = new HashMap<String, Object>();
					//params.put("wx_open_id", wx_open_id);
					params.put("user_id", wx_user_id.toString());
					params.put("nickname", current_user.getNickName());
					params.put("store_name", obj.getGoods_store().getStore_name());
					params.put("goods_name", obj.getGoods_name());
					SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					String come_time  = df.format(new Date());	//YYYY-MM-DD HH:DD:SS
					params.put("come_time", come_time);
					tXTemplateFeignClient.browseMsg(params);
					jiguangPushFeignClient.viewGoods(wx_user_id);
				}
			} catch (Exception e) {
				log.error("浏览记录公众号推送给商家异常:"+Exceptions.getStackTraceAsString(e));;
			}
			//用户访问商品统计
			try {
				Map<String, Object> params = new HashMap<String, Object>();
				params.put("cus_type", "3");
				params.put("goods_id", obj.getId().toString());
				params.put("goods_name", obj.getGoods_name());
				params.put("store_id", obj.getGoods_store_id().toString());
				params.put("userName", current_user.getUserName());
				params.put("user_id", current_user.getId().toString());
				customerrelmanaFeignClient.saveEntity(params);
			} catch (Exception e) {
				log.error("统计商品浏览记录统计异常:"+Exceptions.getStackTraceAsString(e));;
			}
			return ResponseCode.buildSuccessMap(result);
		} else {
			result.put("op_title", "参数错误,商品查看失败");
			result.put("url", CommUtil.getURL(request) + "/index");
			return ResponseCode.buildFailMap("参数错误,商品查看失败", null);
		}
	}
	
	/**
	 * 查询商品规格值价格
	 * @param request
	 * @param response
	 * @param gsp
	 * @param id
	 * @throws Exception
	 */
	@RequestMapping(value="/load_goods_gsp")
	public Map<String, Object> load_goods_gsp(HttpServletRequest request, HttpServletResponse response, 
			@RequestBody JSONObject json) throws Exception{
		String id = json.optString("id");
		String gsp = json.optString("gsp");
		Map<String, Object> result = new HashMap<String, Object>();
		Goods goods = goodsService.selectByPrimaryKey(CommUtil.null2Long(id));
		
		// 商品价格
		double price = 0.0D;
		if ((goods.getGroup_id() != null) && (goods.getGroup_buy() == 2)) {
			result.put("group_id", goods.getGroup_id());
			result.put("gg_status", 2);
			result.put("gg_goods_id",id);
			List<GroupGoodsDto> goodsGroup = groupGoodsFeignClient.goodsGroup(result);
			if (goodsGroup==null) {
				return ResponseCode.buildFailMap("商品信息错误", null);
			}
			result.clear();
			for (GroupGoodsDto gg : goodsGroup) {
				if (gg.getGg_goods_id().toString().equals(id)) {
					price = CommUtil.null2Double(gg.getGg_price());
				}
			}
		} else {
			price = CommUtil.null2Double(goods.getStore_price());
			if ("spec".equals(goods.getInventory_type())) {
				List<HashMap> list = JSON.parseArray(
						goods.getGoods_inventory_detail(), HashMap.class);
				String[] gsp_ids = gsp.split(",");
				for (Map temp : list) {
					String[] temp_ids = CommUtil.null2String(temp.get("id"))
							.split("_");
					Arrays.sort(gsp_ids);
					Arrays.sort(temp_ids);
					if (Arrays.equals(gsp_ids, temp_ids)) {
						price = CommUtil.null2Double(temp.get("price"));
					}
				}
			}
		}
		UserDto user = SecurityUserHolder.getCurrentUser(request);
		if ((goods.getActivity_status() == 2) && (user != null)) {
			if(StringUtils.isEmpty(gsp)){
				gsp = getGsp(goods);
			}
			Map act_map = cartTools.generic_goods_default_Info(goods,
					gsp,user.getId());
		}
		result.put("rate_price", CommUtil.formatMoney(Double.valueOf(price)));
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 查询库存信息
	 * @param request
	 * @param response
	 * @param city_name
	 * @param goods_id
	 * @param city_id
	 * @param gsp
	 */
	@RequestMapping(value="/goods_inventory")
	public Map<String, Object> goods_inventory(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) {
		String city_name = json.optString("city_name");
		String goods_id = json.optString("goods_id");
		String city_id = json.optString("city_id");
		String gsp = json.optString("gsp");
		Map<String, Object> result = new HashMap<String, Object>();
		Goods goods = this.goodsService
				.selectByPrimaryKey(CommUtil.null2Long(goods_id));
		int inventory = this.inventoryService.queryGoodsInventory(goods_id,city_id, gsp);
		//areaToolsFeignClient.setDefaultArea(request, city_id);
		float mail_fee = 0.0F;
		float express_fee = 0.0F;
		float ems_fee = 0.0F;
		if ((goods != null) && (goods.getTransport() != null)) {
			mail_fee = this.transportTools.cal_goods_trans_fee(
					CommUtil.null2String(goods.getTransport().getId()), "mail",
					CommUtil.null2String(goods.getGoods_weight()),
					CommUtil.null2String(goods.getGoods_volume()), city_name);
			express_fee = this.transportTools.cal_goods_trans_fee(
					CommUtil.null2String(goods.getTransport().getId()),
					"express", CommUtil.null2String(goods.getGoods_weight()),
					CommUtil.null2String(goods.getGoods_volume()), city_name);
			ems_fee = this.transportTools.cal_goods_trans_fee(
					CommUtil.null2String(goods.getTransport().getId()), "ems",
					CommUtil.null2String(goods.getGoods_weight()),
					CommUtil.null2String(goods.getGoods_volume()), city_name);
		}
		result.put("inventory", Integer.valueOf(inventory));
		result.put("mail_fee", Float.valueOf(mail_fee));
		result.put("express_fee", Float.valueOf(express_fee));
		result.put("ems_fee", Float.valueOf(ems_fee));
		
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 商品运费模板服务,获取运费
	 * @param request
	 * @param response
	 * @param transport_id 运送模板id
	 * @param type  mail:平邮|express:快递|ems:EMS
	 * @param weight 重量
	 * @param volume 体积
	 * @param current_city 城市
	 * @return
	 */
	@RequestMapping(value="/goods_trans_fee", method = RequestMethod.POST)
	public Map<String, Object> goods_trans_fee(HttpServletRequest request, HttpServletResponse response, 
			  @RequestBody JSONObject json) {
		String transport_id = json.optString("transport_id");
		String type = json.optString("type");
		String weight = json.optString("weight");
		String volume = json.optString("volume");
		String current_city = json.optString("current_city");
		
		Transport transport = transportService.selectByPrimaryKey(CommUtil.null2Long(transport_id));
		if(transport == null){
			return ResponseCode.buildFailMap("运费模板不存在", null);
		}
		if(!(StringUtils.equals(type, "mail") || StringUtils.equals(type, "express") || StringUtils.equals(type, "ems"))){
			return ResponseCode.buildFailMap("运费方式错误", null);
		}
		float express_info = 0f;
		if (StringUtils.equals(type, "mail")) {
			express_info = transportTools.cal_goods_trans_fee1(transport, "mail", weight, volume, current_city);
		}else if (StringUtils.equals(type, "express")) {
			express_info = transportTools.cal_goods_trans_fee1(transport, "express", weight, volume, current_city);
		}else if (StringUtils.equals(type, "ems")) {
			express_info = transportTools.cal_goods_trans_fee1(transport, "ems", weight, volume, current_city);
		}
		return ResponseCode.buildSuccessMap(express_info);
	}
	
	
	/**
	 * 猜你喜欢
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/goods_list_bottom")
	public Map<String, Object> goods_list_bottom(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Map<String, Object> result = new HashMap<String, Object>();
		
		List<Goods> your_like_goods = Lists.newArrayList();
		Long your_like_GoodsClass = null;
		Cookie[] cookies = request.getCookies();
		Goods goods;
		int gcs_size;
		List<Goods> like_goods;
		if (cookies != null) {
			for (Cookie cookie : cookies) {
				if (cookie.getName().equals("goodscookie")) {
					String[] like_gcid = URLDecoder.decode(cookie.getValue(), "UTF-8").split(",", 2);
					goods = goodsService.selectByPrimaryKey(CommUtil.null2Long(like_gcid[0]));
					if (goods == null) {
						break;
					}
					
					your_like_GoodsClass = goods.getGc_id();
					Map<String,Object> maps = Maps.newHashMap();
					maps.put("goods_status", 0);
					maps.put("gc_id", your_like_GoodsClass);
					maps.put("id_no", goods.getId());
					maps.put("orderBy", "goods_salenum");
					maps.put("orderType", "desc");
					
					your_like_goods = goodsService.queryPageList(maps, 0,6);
					// 主图片
					
					gcs_size = your_like_goods.size();
					if (gcs_size >= 6) {
						break;
					}
					maps.clear();
					maps.put("goods_status", 0);
					
					maps.put("id_no", goods.getId());
					maps.put("orderBy", "goods_salenum");
					maps.put("orderType", "desc");
					
					
					like_goods = goodsService.queryPageList(maps,0, 6 - gcs_size);
					
					for (int i = 0; i < like_goods.size(); i++) {
						int k = 0;
						for (int j = 0; j < your_like_goods.size(); j++) {
							if (like_goods.get(i).getId().equals(your_like_goods.get(j).getId())) {
								k++;
							}
						}
						if (k == 0) {
							Goods likeGoods = like_goods.get(i);
							// 主图片
							your_like_goods.add(likeGoods);
						}
					}
					break;
				}
				Map<String,Object> maps = Maps.newHashMap();
				maps.put("goods_status", 0);
				maps.put("orderBy", "goods_salenum");
				maps.put("orderType", "desc");
				
				your_like_goods = goodsService.queryPageList(maps, 0, 6);
				
			}
		} else {
			Map<String,Object> maps = Maps.newHashMap();
			maps.put("goods_status", 0);
			maps.put("orderBy", "goods_salenum");
			maps.put("orderType", "desc");
			
			
			your_like_goods = goodsService.queryPageList(maps, 0, 6);
			// 主图片
		}
		result.put("your_like_goods", your_like_goods);
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	private void generic_evaluate(StoreDto store, Map<String, Object> result) {
		double description_result = 0.0D;
		double service_result = 0.0D;
		double ship_result = 0.0D;
		GoodsClass gc = goodsClassService.selectByPrimaryKey(store.getGc_main_id());
		if ((store != null) && (gc != null) && (store.getPoint() != null)) {
			float description_evaluate = CommUtil.null2Float(gc.getDescription_evaluate());
			float service_evaluate = CommUtil.null2Float(gc.getService_evaluate());
			float ship_evaluate = CommUtil.null2Float(gc.getShip_evaluate());

			float store_description_evaluate = CommUtil.null2Float(store
					.getPoint().getDescription_evaluate());
			float store_service_evaluate = CommUtil.null2Float(store.getPoint()
					.getService_evaluate());
			float store_ship_evaluate = CommUtil.null2Float(store.getPoint()
					.getShip_evaluate());

			description_result = CommUtil.div(
					Float.valueOf(store_description_evaluate - description_evaluate),
					Float.valueOf(description_evaluate));
			service_result = CommUtil.div(
					Float.valueOf(store_service_evaluate - service_evaluate),
					Float.valueOf(service_evaluate));
			ship_result = CommUtil.div(
					Float.valueOf(store_ship_evaluate - ship_evaluate),
					Float.valueOf(ship_evaluate));
		}
		if (description_result > 0.0D) {
			result.put("description_css", "value_strong");
			result.put("description_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(Double.valueOf(description_result),
						Integer.valueOf(100)) > 100.0D ? 100.0D : CommUtil.mul(Double.valueOf(description_result),
								Integer.valueOf(100)))) + "%");
		}
		if (description_result == 0.0D) {
			result.put("description_css", "value_normal");
			result.put("description_result", "-----");
		}
		if (description_result < 0.0D) {
			result.put("description_css", "value_light");
			result.put("description_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(Double.valueOf(-description_result),
							Integer.valueOf(100)))) + "%");
		}
		if (service_result > 0.0D) {
			result.put("service_css", "value_strong");
			result.put("service_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(
							Double.valueOf(service_result), Integer.valueOf(100)))) + "%");
		}
		if (service_result == 0.0D) {
			result.put("service_css", "value_normal");
			result.put("service_result", "-----");
		}
		if (service_result < 0.0D) {
			result.put("service_css", "value_light");
			result.put("service_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(
						Double.valueOf(-service_result), Integer.valueOf(100)))) + "%");
		}
		if (ship_result > 0.0D) {
			result.put("ship_css", "value_strong");
			result.put("ship_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(
							Double.valueOf(ship_result), Integer.valueOf(100)))) + "%");
		}
		if (ship_result == 0.0D) {
			result.put("ship_css", "value_normal");
			result.put("ship_result", "-----");
		}
		if (ship_result < 0.0D) {
			result.put("ship_css", "value_light");
			result.put(
					"ship_result",
					CommUtil.null2String(Double.valueOf(CommUtil.mul(
							Double.valueOf(-ship_result), Integer.valueOf(100))))
							+ "%");
		}
	}
	
	
	/**
	 * 删除购买自己店铺的商品购物车
	 * @param carts_cookie
	 * @param user
	 */
	private void deleteMineGoodsCart(List<GoodsCart> carts_cookie, UserDto user) {
		if (user.getStore() != null) {//商户
			for (GoodsCart gc : carts_cookie) {//cookie中的购物车
				if (gc.getGoods().getGoods_type() == 1) {//1为第三方经销商
					// 所属店铺ID等于用户店铺ID。也就是当前用户买了自己店铺的商品。需要删除掉
					if (gc.getGoods().getGoods_store().getId().equals(user.getStore().getId())) {
						this.goodsCartService.deleteById(gc.getId());
					}
				}
			}
		}
	}
	
	
	/**
	  * 获取String cart_session_id
	 * @param request
	 * @return
	 */
	private String cart_session_id(HttpServletRequest request) {
		String cart_session_id = "";
		Cookie[] cookies1 = request.getCookies();
		if (cookies1 != null) {
			for (Cookie cookie : cookies1) {
				if (cookie.getName().equals("cart_session_id")) {
					cart_session_id = CommUtil.null2String(cookie.getValue());
				}
			}
		}
		
		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();
			}
		}
		
		return cart_session_id;
	}
	
	
	/**
	  * 查询满就减数量
	 * @param id
	 * @param mv
	 * @param obj
	 * @param falcount
	 * @return
	 */
	private int freeCount(String id, Map<String, Object> result, Goods obj, int falcount) {
		// 是否有0元试用 0为无 1为是
		if (obj.getWhether_free() == 1) {
			Map fmap = Maps.newHashMap();
			fmap.put("goods_id", CommUtil.null2Long(id));
			List<FreeGoodsDto> list = freeGoodsFeignClient.queryPageList(fmap);
			
			if (list.size() > 0) {
				FreeGoodsDto fg = (FreeGoodsDto) list.get(0);
				if ((fg != null) && (!"".equals(fg))) {
					Map<String, Object> map = Maps.newHashMap();
					map.put("freegoods_id", fg.getId());
					List<FreeApplyLogDto> free_list = freeApplyLogFeignClient.queryPageList(map);
					
					result.put("free_list", free_list);
					if (free_list.size() >= 1) {
						falcount = free_list.size();
					}
				}
			}
		}
		return falcount;
	}
	
	//更新满就减
	private void updateEnoughReduce(Map<String, Object> result, Goods obj) {
		// 0为未参加满就减,1为已参加
		if (obj.getEnough_reduce() == 1) {
			EnoughReduceDto er = enoughReduceFeignClient.selectByPrimaryKey(CommUtil.null2Long(obj.getOrder_enough_reduce_id()));
			if ((er.getErstatus() == 10) && (er.getErbegin_time().before(new Date())) && (er.getErend_time().after(new Date()))) {
				result.put("enoughreduce", er);
			} else if (er.getErend_time().before(new Date())) {
				er.setErstatus(20);
				enoughReduceFeignClient.updateById(er);
				String goods_json = er.getErgoods_ids_json();
				List<String> goods_id_list = JSON.parseArray(goods_json, String.class);
				for (String goods_id : goods_id_list) {
					Goods ergood = goodsService.selectByPrimaryKey(CommUtil.null2Long(goods_id));
					ergood.setEnough_reduce(0);
					ergood.setOrder_enough_reduce_id(null);
					goodsService.updateById(ergood);
				}
			}
		}
	}
	
	/**
	 * 更新满就送状态
	 * @param mv
	 * @param obj
	 */
	private Map<String, Object> updateEnoughGive(Map<String, Object> result, Goods obj) {
		Goods goods;
		// 满就送状态,0为非满就送商品,1为满就送商品
		if (obj.getOrder_enough_give_status() == 1&&obj.getBuyGift_id()!=null) {
			BuyGiftDto bg = buyGiftFeignClient.selectByPrimaryKey(obj.getBuyGift_id());
			if ((bg != null) && (bg.getEndTime().before(new Date()))) {
				//审核状态 默认为0待审核  10为 审核通过  -10为审核未通过  20为已结束。
				bg.setGift_status(20);
				List<Map> maps = JSON.parseArray(bg.getGift_info(),Map.class);
				maps.addAll(JSON.parseArray(bg.getGoods_info(),Map.class));
				for (Map map : maps) {
					goods = goodsService.selectByPrimaryKey(CommUtil.null2Long(map.get("goods_id")));
					if (goods != null) {
						goods.setOrder_enough_give_status(0);// 满就送状态,0为非满就送商品,1为满就送商品
						goods.setOrder_enough_if_give(0);// 是否是满就送,赠送的商品。0为不送
						goods.setBuyGift_id(null);
					}
				}
				buyGiftFeignClient.updateById(bg);
			}
			if ((bg != null) && (bg.getGift_status() == 10) && (bg.getBeginTime().before(new Date()))) {
				result.put("isGift", Boolean.valueOf(true));
			}else{
				result.put("isGift", Boolean.valueOf(false));
			}
		}else{
			result.put("isGift", Boolean.valueOf(false));
		}
		// 是否是满就送,赠送的商品。0为不送 1为送。送的商品正常价格出售,只有满足订单金额时才已0元出售。
		if (obj.getOrder_enough_if_give() == 1) {
			if (obj.getBuyGift_id() != null) {
				BuyGiftDto bg = buyGiftFeignClient.selectByPrimaryKey(obj.getBuyGift_id());
				if ((bg != null) && (bg.getGift_status() == 10)) {
					result.put("isGive", Boolean.valueOf(true));
				} else {
					result.put("isGive", Boolean.valueOf(false));
				}
			}else{
				result.put("isGive", Boolean.valueOf(false));
			}
		}else{
			result.put("isGive", Boolean.valueOf(false));
		}
		return result;
		
	}
	
	/**
	  * 如果团购结束时间在当前时间过去。那么修改团购状态为0无团购信息
	 * @param obj
	 */
	private void updateGoodsGroupBuyStatus(Goods obj) {
		// 团购状态,0为无团购,1为待审核,2为审核通过,3为团购商品已经卖完 4为审核通过 但未开始
		if ((obj.getGroup() != null) && (obj.getGroup_buy() == 2)) {
			GroupDto group = obj.getGroup();
			if (group.getEndTime().before(new Date())) {//如果团购结束时间在当前时间过去。那么修改团购状态为0无团购信息
				obj.setGroup(null);
				obj.setGroup_buy(0);
				obj.setGoods_current_price(obj.getStore_price());
			}
		}
	}

	/**
	  * 用户购买数量
	 * @param mv
	 * @param obj
	 * @param current_user
	 */
	private void userLimitCount(Map<String, Object> result, Goods obj, UserDto current_user) {
		int count = -1;
		if ((obj.getGoods_limit() == 1) && (obj.getGoods_limit_count() > 0)) {
			count = obj.getGoods_limit_count();
			if (current_user != null) {
				String info = CommUtil.null2String(current_user.getBuy_goods_limit_info());//获取用户购买的限购商品信息
				if (!info.equals("")) {
					Map maps = JSON.parseObject(CommUtil.null2String(info));//{"data":[{"gid":391,"count":1,"spec":""}]}
					List<Map> list = (List) maps.get("data");//[{"gid":391,"count":1,"spec":""}]
					
					for (Map<String,Object> map : list) {
						
						String gid = CommUtil.null2String(map.get("gid"));
						if (CommUtil.null2Int(gid) == obj.getId()) {//如果用户购买的限购商品的ID和当前商品ID一样
							count = obj.getGoods_limit_count()- CommUtil.null2Int(map.get("count"));//商品限购数量-用户已经购买的限购商品量
							if (count < 1) {//如果小于1表示用户没有购买过限购商品
								count = 0;
							}
						}
					}
				}
			}
		} else {
			count = -1;
		}
		
		//限购商品数量
		result.put("count", Integer.valueOf(count));
	}
	
	
	/**
	  * 设置商品过期状态
	 * @param obj
	 */
	private void updateActivityGoodsStatus(Goods obj) {
		// 活动状态,0为无活动,1为待审核,2为审核通过,3为活动已经过期活结束,审核未通过时状态为0
		if ((obj.getActivity_status() == 1) || (obj.getActivity_status() == 2)) {
			if (!CommUtil.null2String(obj.getActivity_goods_id()).equals("")) {
				ActivityGoodsDto ag = activityGoodsFeignClient.selectByPrimaryKey(obj.getActivity_goods_id());
				
				if ((ag != null) && (ag.getAct().getAc_end_time().before(new Date()))) {//如果活动时间在当前时间过去。设置活动已过期
					// 活动商品审核状态,0为待审核,1为审核通过,-1为审核拒绝,-2为已经到期关闭
					ag.setAg_status(-2);
					activityGoodsFeignClient.updateById(ag);
					obj.setActivity_status(0);
					obj.setActivity_goods_id(null);
				}
			}
		}
	}
	
	
	/**
	 * 
	 * @param request
	 * @param response
	 * @param type
	 * @param store_id
	 * @param begin_count
	 * @param orderBy
	 * @param orderType
	 * @return
	 **/
	@RequestMapping({ "/goods_list" })
	public Map<String, Object> goods_list(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) {
		String type = json.optString("type");
		String store_id = json.optString("store_id");
		//String begin_count = json.optString("begin_count");
		String orderBy = json.optString("orderBy");
		String orderType = json.optString("orderType");
		
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("orderBy", orderBy);
		result.put("orderType", orderType);
		Map<String,Object> maps = Maps.newHashMap();
		
		if (CommUtil.null2String(orderBy).equals("goods_collect")) {
			maps.put("orderBy", "goods_collect");
			maps.put("orderType", "desc");
		}
		
		if (CommUtil.null2String(orderBy).equals("goods_salenum")) {
			maps.put("orderBy", "goods_salenum");
			maps.put("orderType", "desc");
		}
		
		if (CommUtil.null2String(orderBy).equals("store_price")) {
			maps.put("orderBy", "store_price");
			maps.put("orderType", orderType);
		}
		Map<String,Object> params = Maps.newHashMap();
		if ((type != null) && (type.equals("h"))) {
			maps.put("mobile_hot", Integer.valueOf(1));
			maps.put("goods_status", Integer.valueOf(0));
			
			params.put("mobile_hot", Integer.valueOf(1));
			params.put("goods_status", Integer.valueOf(0));
			params.put("orderBy", "mobile_hotTime");
			params.put("orderType", "desc");
			
				List<Goods> goods_hots = goodsService.queryPageList(maps,0,6);
				result.put("goods", goods_hots);
				result.put("type", "mobile_hot");
		}
		if ((type != null) && (type.equals("r"))) {

			maps.put("mobile_recommend", Integer.valueOf(1));
			maps.put("goods_status", Integer.valueOf(0));

			params.put("mobile_recommend", Integer.valueOf(1));
			params.put("goods_status", Integer.valueOf(0));

			List<Goods> goods_recommends = goodsService.queryPageList(maps, 0, 6);
			result.put("goods", goods_recommends);
			result.put("type", "mobile_recommend");
		}
		if (!CommUtil.null2String(store_id).equals("")) {
			params.clear();
			params.put("store_id", CommUtil.null2Long(store_id));
			params.put("goods_status", Integer.valueOf(0));
				
				List<Goods> store_goods = goodsService.queryPageList(params);
				
				result.put("goods", store_goods);
				result.put("store_id", store_id);
				result.put("type", "store_id");
		}
		return ResponseCode.buildSuccessMap(result);
	}



	@RequestMapping({ "/goods_introduce" })
	public Map<String, Object> goods_introduce(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) {
		String id = json.optString("id");
		Map<String, Object> result = new HashMap<String, Object>();
		Goods obj = goodsService.selectByPrimaryKey(CommUtil.null2Long(id));
		result.put("obj", obj);
		result.put("id", id);
		return ResponseCode.buildSuccessMap(result);
	}

	@RequestMapping({ "/goods_consult" })
	public Map<String, Object> goods_consult(HttpServletRequest request, HttpServletResponse response, 
			String goods_id, String consult_type, String currentPage) {
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String,Object> maps= queryTools.getParams(currentPage,10, "addTime", "desc");
		
		maps.put("goods_id", CommUtil.null2Long(goods_id));
		
		if (!CommUtil.null2String(consult_type).equals("")) {
			maps.put("consult_type", consult_type);
		}
		
		Page<Consult> pList = this.consultService.list(maps);
		String url2 = CommUtil.getURL(request) + "/goods_consult";
		result.put("consult_objs", pList.getResult());
		result.put("consult_gotoPageAjaxHTML", CommUtil.showPageAjaxHtml(
				url2, "", pList.getCurrentPage(), pList.getPages(),
				pList.getPageSize()));

		result.put("goods_id", goods_id);
		// mv.addObject("consultViewTools", this.consultViewTools);
		result.put("consult_type", CommUtil.null2String(consult_type));
		return ResponseCode.buildSuccessMap(result);
	}

	@RequestMapping({ "/goods_consult_save" })
	public Map<String, Object> goods_consult_saveEntity(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) {
		String goods_id = json.optString("goods_id");
		String consult_content = json.optString("consult_content");
		String consult_type = json.optString("consult_type");
		String consult_code = json.optString("consult_code");
		
		Map<String, Object> result = new HashMap<String, Object>();
		String verify_code = CommUtil.null2String(request.getSession(false).getAttribute("consult_code"));
		SysConfigDto sysconfig = sysConfigFeignClient.getSysConfig();
		boolean visit_consult = true;
		if ((!sysconfig.getVisitorConsult())
				&& (SecurityUserHolder.getCurrentUser(request) == null)) {
			visit_consult = false;
		}
		
		if ((visit_consult)
				&& (CommUtil.null2String(consult_code).equals(verify_code))) {
			Consult obj = new Consult();
			Goods goods = goodsService.selectByPrimaryKey(CommUtil
					.null2Long(goods_id));
			obj.setAddTime(new Date());
			obj.setConsult_type(consult_type);
			obj.setConsult_content(consult_content);
			UserDto user = SecurityUserHolder.getCurrentUser(request);
			if (user != null) {
				obj.setConsult_user_id(user.getId());
				obj.setConsult_user_name(user.getUserName());
				obj.setConsult_email(user.getEmail());
			} else {
				obj.setConsult_user_name("游客");
			}
			List<Map> maps = Lists.newArrayList();
			Map<String, Object> map = Maps.newHashMap();
			map.put("goods_id", goods.getId());
			map.put("goods_name", goods.getGoods_name());
			map.put("goods_main_photo", goods.getGoods_main_photo().getPath()
					+ "/" + goods.getGoods_main_photo().getName() + "_small."
					+ goods.getGoods_main_photo().getExt());
			map.put("goods_price", goods.getGoods_current_price());
			String goods_domainPath = CommUtil.getURL(request) + "/items_"
					+ goods.getId() + "";
			
			if ((sysconfig.getSecond_domain_open())
					&& (goods.getGoods_store() != null)
					&& (goods.getGoods_store().getStore_second_domain() != "")
					&& (goods.getGoods_type() == 1)) {
				String store_second_domain = "http://"
						+ goods.getGoods_store().getStore_second_domain() + "."
						+ CommUtil.generic_domain(request);
				goods_domainPath = store_second_domain + "/items_"
						+ goods.getId() + "";
			}
			map.put("goods_domainPath", goods_domainPath);
			maps.add(map);
			obj.setGoods_info(JSON.toJSONString(maps));
			obj.setGoods_id(goods.getId());
			if (goods.getGoods_store() != null) {
				obj.setStore_id(goods.getGoods_store().getId());
				obj.setStore_name(goods.getGoods_store().getStore_name());
			} else {
				obj.setWhether_self(1);
			}
			consultService.saveEntity(obj);
			request.getSession(false).removeAttribute("consult_code");
		}
		
		Map<String,Object> maps= queryTools.getParams("1","addTime","desc");
		maps.put("goods_id", CommUtil.null2Long(goods_id));
		
		if (!CommUtil.null2String(consult_type).equals("")) {
			maps.put("consult_type", consult_type);
		}
		
		Page<Consult> pList = this.consultService.list(maps);
		result.put("pList", pList);
		result.put("goods_id", goods_id);
		// mv.addObject("consultViewTools", this.consultViewTools);
		result.put("consult_type", CommUtil.null2String(consult_type));
		return ResponseCode.buildSuccessMap(result);
	}

	@RequestMapping({ "/recomend_items" })
	public Map<String, Object> recomend_goods(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) {
		String currentPage = json.optString("currentPage");
		Map<String,Object> maps= queryTools.getParams(currentPage,4,"weixin_recommendTime", "desc");
		maps.put("weixin_recommend", 1);
		maps.put("goods_status", 0);
		
		Page<Goods> pList = goodsService.list(maps);
		return ResponseCode.buildSuccessMap(pList);
	}

	
	/**
	 * 查询拼团商品规格值价格
	 * @param request
	 * @param response
	 * @param gsp 规格id,多个逗号分隔
	 * @param id 商品id
	 */
	@RequestMapping(value="/loadPinGoodsGsp")
	public Map<String, Object> loadPinGoodsGsp(HttpServletRequest request, HttpServletResponse response, 
			@RequestBody JSONObject json){
		String id = json.optString("id");
		String gsp = json.optString("gsp");
		
		Map<String, Object> result = new HashMap<String, Object>();
		Long uid = SecurityUserHolder.getCurrentUserId(request);
		result.put("price", goodsTools.loadPinGoodsGspPrice(uid, id, gsp));
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 查询拼团商品规格值价格(feign调用)
	 * @param uid 用户id
	 * @param gsp 规格id,多个逗号分隔
	 * @param id 商品id
	 * @return
	 */
	@RequestMapping(value="/apiForFeign/loadPinGoodsPriceByGsp")
	public String loadPinGoodsPriceByGsp(Long uid, String gsp, String goodsId){
		return goodsTools.loadPinGoodsGspPrice(uid, goodsId, gsp);
	}
	/**
	 * 获取默认规格
	 * @param obj
	 * @return
	 */
	public String getGsp(Goods obj){
		String fina_gsp = "";
		if (obj != null) {
			List<GoodsSpecification> specs = Lists.newArrayList();
			if ("spec".equals(obj.getInventory_type())) {
				List<GoodsSpecProperty> goodsSpecsByGoodsId = specPropertyService.getGoodsSpecsByGoodsId(obj.getId());
				for (GoodsSpecProperty gsp : goodsSpecsByGoodsId) {
					GoodsSpecification spec = goodsSpecificationService.selectByPrimaryKey(gsp.getSpec_id());
					boolean noExist = true;
					for(GoodsSpecification gsp1 : specs){
						if(gsp1.getId().longValue() == spec.getId().longValue()){
							noExist = false;
							break;
						}
					}
					if (noExist) {
						specs.add(spec);
					}
				}
				Collections.sort(specs,
						new Comparator<GoodsSpecification>() {
							public int compare(GoodsSpecification gs1,
									GoodsSpecification gs2) {
								return gs1.getSequence()
										- gs2.getSequence();
							}
						});
			}
			for (GoodsSpecification spec : specs) {
				
				for (GoodsSpecProperty prop : obj.getGoods_specs()) {
					if (prop.getSpec().getId().equals(spec.getId())) {
						fina_gsp = prop.getId() + "," + fina_gsp;
						break;
					}
				}
			}
		}
		return fina_gsp;
	}
	
	
	/**
	 * 创建主播添加商品列表
	 * @param request
	 * @param response
	 * @param type
	 * @param store_id
	 * @param begin_count
	 * @param orderBy
	 * @param orderType
	 * @return
	 **/
	@RequestMapping({ "/addLiveGoodList" })
	public Map<String, Object> addLiveGoodList(HttpServletRequest request,
			HttpServletResponse response, @RequestBody JSONObject json) {
		String orderBy = json.optString("orderBy");
		String orderType = json.optString("orderType");
		String currentPage = json.optString("currentPage");

		Map<String, Object> result = new HashMap<String, Object>();
		result.put("orderBy", orderBy);
		result.put("orderType", orderType);
		//查询登录用户
		UserDto user = userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		
		if (StringUtils.isNotBlank(user.getStore_id().toString())) {
			Map<String, Object> maps = queryTools.getParams(currentPage, orderBy, orderType);
			maps.put("store_id", user.getStore_id());
			maps.put("goods_status", Integer.valueOf(0));

			List<Goods> store_goods = goodsService.queryPageList(maps);

			result.put("goods", store_goods);
		}
		return ResponseCode.buildSuccessMap(result);
	}
	

	
	/**
	 * 查询主播商品列表
	 * @param json
	 * @return
	 */
	@RequestMapping({"/apiForFeign/getQueryPageList_bak" })
	public Map<String, Object> getQueryPageList_bak(@RequestBody Map<String, Object> params){
		SysConfigDto sysConfigDto=sysConfigFeignClient.getSysConfig();
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Page<Goods> page = goodsService.list(params);
	   	for (Goods g : page.getResult()) {
	  		 Map<String,Object> goods = new HashMap<String, Object>();
	  		 goods.put("id", g.getId());									//商品编号
	  		 if(null!=sysConfigDto && g.getGoods_main_photo() != null){
	  			 goods.put("BigPicture",sysConfigDto.getImageWebServer()+"/"+
	  					 g.getGoods_main_photo().getPath()+"/"+g.getGoods_main_photo().getName());	//商品主图片访问路径
	  		 }else{
	  			 goods.put("BigPicture",null);	//商品主图片访问路径
	  		 }
	  		 goods.put("goods_name", g.getGoods_name());					//商品名称
	  		 goods.put("store_price", g.getStore_price());					//商品店铺价格
	  		 goods.put("dis_money", g.getDis_money());						//商品分销收益(具体的金额)
	  		 goods.put("goods_inventory", g.getGoods_inventory());			//商品库存数量
	  		 goods.put("smallProgram", "");									//小程序访问路径
	  		list.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", list);
		resultMap.put("rowCount", page.getRowCount());
		return resultMap;
	}	
	
	/**
	 * 查询主播商品列表
	 * @param json
	 * @return
	 */
	@RequestMapping({"/apiForFeign/getQueryPageList" })
	public Map<String, Object> getQueryPageList(@RequestBody Map<String, Object> params){
		SysConfigDto sysConfigDto=sysConfigFeignClient.getSysConfig();
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Page<Goods> page = goodsService.list(params);
		for (Goods g : page.getResult()) {
			Map<String,Object> goods = new HashMap<String, Object>();
			goods.put("id", g.getId());									//商品编号
			if(null!=sysConfigDto && g.getGoods_main_photo() != null){
				goods.put("BigPicture",sysConfigDto.getImageWebServer()+"/"+
						g.getGoods_main_photo().getPath()+"/"+g.getGoods_main_photo().getName()+"_middle."+g.getGoods_main_photo().getExt());	//商品主图片访问路径
			}else{
				goods.put("BigPicture",null);	//商品主图片访问路径
			}
			
			goods.put("whetherAdd", false);
			if(g.getUlg_gid() != null){
	  			goods.put("whetherAdd", true);		//是否已经被添加
	  		}
			goods.put("agentAdd", false);
			if(g.getSag_gid() != null){
				goods.put("agentAdd", true);		//是否已经被添加
			}
			goods.put("goods_name", g.getGoods_name());					//商品名称
			goods.put("store_price", g.getStore_price());					//商品店铺价格
			goods.put("dis_money", g.getDis_money());						//商品分销收益(具体的金额)
			goods.put("special_money", g.getSpecial_money());				//商品代理收益(具体的金额)
			goods.put("goods_inventory", g.getGoods_inventory());			//商品库存数量
			goods.put("smallProgram", "");									//小程序访问路径
			list.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", list);
		resultMap.put("rowCount", page.getRowCount());
		return resultMap;
	}	
	
	/**
	 * 查询已播商品列表
	 * @param json
	 * @return
	 */
	@RequestMapping({ "/apiForFeign/getGoodsBroadcast" })
	public List<Goods> getGoodsBroadcast( @RequestBody Map<String, Object> params){
		String user_id = params.get("user_id").toString();
		String type = params.get("type").toString();
		List<Goods> store_goods =new LinkedList<Goods>();
		UserDto user = userFeignClient.selectByPrimaryKey(CommUtil.null2Long(user_id)); //查询登录用户
		if (StringUtils.isNotBlank(user.getStore_id().toString())) {
			Map<String, Object> maps = new HashMap<String, Object>();
			maps.put("goods_store_id", user.getStore_id());   				//商品所属店铺编号
			maps.put("live_goods_status", Integer.valueOf(-2));				//商品状态标识
			if(type.equals("not")){
				maps.put("live_creater_id", user_id); 						//主播用户编号
			}
			store_goods = goodsService.queryPageList(maps);
		}
		return store_goods;
	}	
	
	
	/*//生成商品分享二维码海报
	@RequestMapping(value = "/sharePoster", method = RequestMethod.POST)
	public Map<String, Object> sharePoster(HttpServletRequest request,
			HttpServletResponse response, @RequestBody JSONObject json){
		String id = json.optString("id");
		SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig(); 
		String imageWebServer = sysConfigDto.getImageWebServer();
		Goods goods = goodsService.selectByPrimaryKey(Long.parseLong(id));
		
		
		
		try {
			//创建图片
	        BufferedImage img = new BufferedImage(750, 1334, BufferedImage.TYPE_INT_RGB);
	        //开启画图
	        Graphics g = img.getGraphics();
	        //背景 -- 读取互联网图片
	        File newfile = new File("C://Users//Administrator//Desktop//1111.jpg");
	        BufferedImage back  = ImageIO.read(newfile);
	        g.drawImage(back.getScaledInstance(750, 1334, Image.SCALE_DEFAULT), 0, 0, null); // 绘制缩小后的图
	        //获取推荐人信息
	        UserDto user = SecurityUserHolder.getCurrentUser(request);
	        //文案标题
	        g.setFont(new Font("微软雅黑", Font.BOLD, 34));
	        g.setColor(new Color(29,29,29));
	        //绘制文字
	        if(user != null){
	        	g.drawString(user.getUserName()+"用户推荐", 300, 30);//TODO
			}
	        //商品  banner图
	        //读取互联网图片
	        File file22 = new File(imageWebServer+File.pathSeparator+goods.getGoods_main_photo().getPath()+File.pathSeparator+goods.getGoods_main_photo().getName());
	        BufferedImage priductUrl = ImageIO.read(file22); //TODO
	        g.drawImage(priductUrl.getScaledInstance(690,516,Image.SCALE_DEFAULT),29,61,null);
	       
	        //绘制文字
	        g.drawString("填写文案标题", 31, 638);//TODO
	        //文案
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 30));
	        g.setColor(new Color(47,47,47));
	        int fontlen = getWatermarkLength("填写文内容", g);//TODO
	        //文字长度相对于图片宽度应该有多少行
	        int line = fontlen / (back.getWidth() - 90);
	        //高度
	        int y = back.getHeight() - (line + 1) * 30 - 500;
	        //文字叠加,自动换行叠加
	        int tempX = 32;
	        int tempY = y;
	        //单字符长度
	        int tempCharLen = 0;
	        //单行字符总长度临时计算
	        int tempLineLen = 0;
	        StringBuffer sb =new StringBuffer();
	        for(int i=0; i < "填写文内容".length(); i++) {//TODO
	            char tempChar = "填写文内容".charAt(i);//TODO
	            tempCharLen = getCharLen(tempChar, g);
	            tempLineLen += tempCharLen;
	            if(tempLineLen >= (back.getWidth()-90)) {
	                //长度已经满一行,进行文字叠加
	                g.drawString(sb.toString(), tempX, tempY + 50);
	                //清空内容,重新追加
	                sb.delete(0, sb.length());
	                //每行文字间距50
	                tempY += 50;
	                tempLineLen =0;
	            }
	            //追加字符
	            sb.append(tempChar);
	        }
	        //最后叠加余下的文字
	        g.drawString(sb.toString(), tempX, tempY + 50);
	 
	        //价格背景
	        //读取互联网图片
	        File file33 = new File("C://Users//Administrator//Desktop//333.png");
	       
	        BufferedImage bground  = ImageIO.read(file33);//TODO
	        // 绘制缩小后的图
	        g.drawImage(bground.getScaledInstance(160, 40, Image.SCALE_DEFAULT), 30, 1053, null);
	 
	        //限时促销价
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 24));
	        g.setColor(new Color(255,255,255));
	        g.drawString("限时促销价", 50, 1080);
	 
	        //价格
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 50));
	        g.setColor(new Color(249,64,64));
	        g.drawString("¥" + "填写商品的价格", 29, 1162);//TODO
	 
	        //原价
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 36));
	        g.setColor(new Color(171,171,171));
	        String price = "¥" + "填写商品的原价";//TODO
	        g.drawString(price, 260, 1160);
	        g.drawLine(250,1148,260+150,1148);
	 
	        //商品名称
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 32));
	        g.setColor(new Color(29,29,29));
	        g.drawString("填写商品名称", 30, 1229);//TODO
	 
	        //生成二维码返回链接
	        String url = "http://hhwap.minglisoft.cn/items?id=293";//TODO
	        //读取互联网图片
	        File file44 = new File("C://Users//Administrator//Desktop//444.png");
        
	        BufferedImage qrCode  = ImageIO.read(file44);
	        // 绘制缩小后的图
	        g.drawImage(qrCode.getScaledInstance(174, 174, Image.SCALE_DEFAULT), 536, 1057, null);
	 
	        //二维码字体
	        g.setFont(new Font("微软雅黑", Font.PLAIN, 25));
	        g.setColor(new Color(171,171,171));
	        //绘制文字
	        g.drawString("扫描或长按小程序码", 515, 1260);
	 
	        g.dispose();
	        //保存到本地 生成文件名字
	        String iconKey = UUID.randomUUID().toString() +".png"; //TODO
	        //先将画好的海报写到本地
	        String picUrl = "C://Users//Administrator//Desktop//" + iconKey; // TODO
	        File file = new File(picUrl);
	       
			ImageIO.write(img, "jpg",file);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        //再将file上传至七牛返回链接存入数据库
        //end
        // TODO

	
	
	}*/

	/**
     * 获取水印文字总长度
     *@paramwaterMarkContent水印的文字
     *@paramg
     *@return水印文字总长度
     */
   /* public int getWatermarkLength(String waterMarkContent, Graphics g) {
        return g.getFontMetrics(g.getFont()).charsWidth(waterMarkContent.toCharArray(),0, waterMarkContent.length());
    }
    public int getCharLen(char c, Graphics g) {
        return g.getFontMetrics(g.getFont()).charWidth(c);
    }*/
	
	
	@RequestMapping(value="/getGoodsSpecification" , method = RequestMethod.POST)
	public Map<String, Object> getGoodsSpecification(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String id = json.optString("id");
		// 查询商品规格集合
		List<GoodsSpecification> goods_specis = goodsSpecificationService.getGoodsIdSpecification(CommUtil.null2Long(id));
		HashMap<String, Object> result = new HashMap<>();
		result.put("goods_specis", goods_specis);
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 查询商品规格值价格
	 * @param request
	 * @param response
	 * @param gsp
	 * @param id
	 * @throws Exception
	 */
	@RequestMapping(value="/load_livegoods_gsp")
	public Map<String, Object> load_livegoods_gsp(HttpServletRequest request, HttpServletResponse response, 
			@RequestBody JSONObject json) throws Exception{
		String id = json.optString("id");
		String gsp = json.optString("gsp");
		Map<String, Object> result = new HashMap<String, Object>();
		Goods goods = goodsService.selectByPrimaryKey(CommUtil.null2Long(id));
		if (goods==null) {
			return ResponseCode.buildFailMap("商品信息不存在", null);
		}
		// 商品价格
		double price = 0.0D;
		if ((goods.getGroup_id() != null) && (goods.getGroup_buy() == 2)) {
			result.put("group_id", goods.getGroup_id());
			result.put("gg_status", 2);
			result.put("gg_goods_id",id);
			List<GroupGoodsDto> goodsGroup = groupGoodsFeignClient.goodsGroup(result);
			if (goodsGroup==null) {
				return ResponseCode.buildFailMap("商品信息错误", null);
			}
			result.clear();
			for (GroupGoodsDto gg : goodsGroup) {
				if (gg.getGg_goods_id().toString().equals(id)) {
					price = CommUtil.null2Double(gg.getGg_price());
				}
			}
		} else {
			price = CommUtil.null2Double(goods.getStore_price());
			if ("spec".equals(goods.getInventory_type())) {
				List<HashMap> list = JSON.parseArray(
						goods.getGoods_inventory_detail(), HashMap.class);
				String[] gsp_ids = gsp.split(",");
				for (Map temp : list) {
					String[] temp_ids = CommUtil.null2String(temp.get("id"))
							.split("_");
					Arrays.sort(gsp_ids);
					Arrays.sort(temp_ids);
					if (Arrays.equals(gsp_ids, temp_ids)) {
						price = CommUtil.null2Double(temp.get("price"));
					}
				}
			}
		}
		result.put("rate_price", CommUtil.formatMoney(Double.valueOf(price)));
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	/**
	 * 店铺商品数据(发布视频选择商品)
	 * @param paraMap
	 * @return
	 */
	@RequestMapping({"/apiForFeign/goodsPageList" })
	public Map<String, Object> goodsPageList(@RequestBody Map<String, Object> params){
		SysConfigDto sysConfigDto=sysConfigFeignClient.getSysConfig();
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Page<Goods> page = goodsService.list(params);
	   	for (Goods g : page.getResult()) {
	  		 Map<String,Object> goods = new HashMap<String, Object>();
	  		 goods.put("id", g.getId());									//商品编号
	  		 if(null!=sysConfigDto && g.getGoods_main_photo() != null){
	  			 goods.put("BigPicture",sysConfigDto.getImageWebServer()+"/"+
	  					 g.getGoods_main_photo().getPath()+"/"+g.getGoods_main_photo().getName()+"_middle."+g.getGoods_main_photo().getExt());	//商品主图片访问路径
	  		 }else{
	  			 goods.put("BigPicture",null);	//商品主图片访问路径
	  		 }
	  		 goods.put("goods_name", g.getGoods_name());					//商品名称
	  		 goods.put("store_price", g.getStore_price());					//商品店铺价格
	  		 goods.put("dis_money", g.getDis_money());						//商品分销收益(具体的金额)
	  		 goods.put("goods_inventory", g.getGoods_inventory());			//商品库存数量
	  		 goods.put("smallProgram", "");									//小程序访问路径
	  		list.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", list);
		resultMap.put("rowCount", page.getRowCount());
		return resultMap;
	}
	
	
	/**
	 * 查询店铺商品统计
	 * @param store_id
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/goodsStoreStatis", method = RequestMethod.GET)
	public Map<String, Object> goodsStoreStatis(@RequestParam("store_id")Long store_id){
		return goodsService.goodsStoreStatis(store_id);
	}
	
	
	/**
	 * 线下商品
	 * @param store_id
	 * @return
	 */
	@RequestMapping(value = "/offlineGoodsList", method = RequestMethod.POST)
	public Map<String, Object> travelGoodsList(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {

		// 获取定位
		String currentPage = json.optString("currentPage");
		String lat = json.optString("lat");
		String lng = json.optString("lng");

		if (StringUtils.isBlank(lat) || StringUtils.isBlank(lng)) {
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}

		// 周边游 查询本市的 景点
		Map<String, Object> params = queryTools.getParams(currentPage, 12, "obj.goods_salenum desc , distance  ", "asc");

		// 根据经纬度查询城市
		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);
		Page<GoodsVo> pList = goodsService.offLineList(params);

		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("currentPage", pList.getCurrentPage());
		resultMap.put("pages", pList.getPages());
		resultMap.put("pageSize", pList.getPageSize());
		resultMap.put("result", pList.getResult());
		resultMap.put("rowCount", pList.getRowCount());
		return ResponseCode.buildSuccessMap(resultMap);
	}
	
	
	/**
	 * 商品评价
	 * @param request
	 * @param response
	 * @param goods_id
	 * @param currentPage
	 * @param goods_eva
	 * @return
	 */
	@RequestMapping(value="/killGoods")
	public Map<String, Object> killGoods(HttpServletRequest request,
			HttpServletResponse response, @RequestBody JSONObject json) {
		String id = json.optString("id");
		Goods obj = goodsService.selectByPrimaryKey(CommUtil.null2Long(id));
		if(obj == null){
			return ResponseCode.buildCodeMap("10003", "商品不存在", null);
		}
		// 商品图片
		List<AccessoryDto> goods_photos = accessoryFeignClient.getGoodsPhotosByAccessoryId(obj.getId());
		goods_photos.add(0, obj.getGoods_main_photo());
		obj.setGoods_photos(goods_photos);
		
		
		// 查询商品规格集合
		List<GoodsSpecification> goods_specis = goodsSpecificationService.getGoodsIdSpecification(obj.getId());
		// 查询自定义规格
		if (StringUtils.isNotEmpty(obj.getGoods_specs_info()) && goods_specis.size() > 0) {
			List<Map> goods_specs_info = JSON.parseArray(obj.getGoods_specs_info(), Map.class);
			for (GoodsSpecification goods_speci : goods_specis) {
				// Map specs_info = goods_specs_info.stream().filter(o ->o.get("id").toString().equals(goods_speci.getProperties().get(0).getId().toString())).findAny().orElse(null);
				for (Map map : goods_specs_info) {
					List<GoodsSpecProperty> properties = goods_speci.getProperties();
					for (GoodsSpecProperty goodsSpecProperty : properties) {
						if (map.get("id").equals(goodsSpecProperty.getId().toString())) {
							goodsSpecProperty.setValue(map.get("name").toString());
						}
					}

				}
			}
		}
		obj.setGoods_specis(goods_specis);
		
		
		Map<String, Object> result = new HashMap<String, Object>();
		String d = "2021-9-1 17:14:00";
		String f = "2021-9-2 20:00:00";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			Date parse = sdf.parse(d);
			Date parse2 = sdf.parse(f);
			obj.setSeckill_start_time(parse);
			obj.setSeckill_end_time(parse2);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		         // 调用parse()方法,将字符串转换为日期
		result.put("goods_id", id);
		result.put("obj", obj);
		
		return ResponseCode.buildSuccessMap(result);
	}
	
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

企业软件定制

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

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

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

打赏作者

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

抵扣说明:

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

余额充值