Java教程

spring boot商城o2o商城JAVA版 B2B2C商城源码 分销商城 直播商城

本文主要是介绍spring boot商城o2o商城JAVA版 B2B2C商城源码 分销商城 直播商城,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

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

直播带货源码:

/**
 * Copyright &copy; 2012-2017 <a href="http://minglisoft.cn">HongHu</a> All rights reserved.
 */
package com.honghu.cloud.controller;
 
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.google.common.collect.Maps;
import com.honghu.cloud.bean.Album;
import com.honghu.cloud.bean.CustomerService;
import com.honghu.cloud.bean.MemberFans;
import com.honghu.cloud.bean.Menu;
import com.honghu.cloud.bean.PredepositLog;
import com.honghu.cloud.bean.PullUserOrder;
import com.honghu.cloud.bean.Role;
import com.honghu.cloud.bean.User;
import com.honghu.cloud.bean.UserCard;
import com.honghu.cloud.bean.VerifyidCard;
import com.honghu.cloud.code.MemberResponseCode;
import com.honghu.cloud.code.ResponseCode;
import com.honghu.cloud.code.ResponseVO;
import com.honghu.cloud.constant.Globals;
import com.honghu.cloud.dto.AccessoryDto;
import com.honghu.cloud.dto.AreaDto;
import com.honghu.cloud.dto.IntegralLogDto;
import com.honghu.cloud.dto.ModularClassDto;
import com.honghu.cloud.dto.StoreDto;
import com.honghu.cloud.dto.SysConfigDto;
import com.honghu.cloud.dto.TemplateDto;
import com.honghu.cloud.dto.UserDto;
import com.honghu.cloud.dto.VerifyCodeDto;
import com.honghu.cloud.feign.AccessoryFeignClient;
import com.honghu.cloud.feign.AreaFeignClient;
import com.honghu.cloud.feign.CouponInfoFeignClient;
import com.honghu.cloud.feign.IntegralLogFeignClient;
import com.honghu.cloud.feign.IntegralToolsFeignClient;
import com.honghu.cloud.feign.ModularClassFeignClient;
import com.honghu.cloud.feign.MsgToolsFeignClient;
import com.honghu.cloud.feign.OrderFormFeignClient;
import com.honghu.cloud.feign.QrCodeFeignClient;
import com.honghu.cloud.feign.StoreFeignClient;
import com.honghu.cloud.feign.SysConfigFeignClient;
import com.honghu.cloud.feign.TemplateFeignClient;
import com.honghu.cloud.feign.TencentIMFeignClient;
import com.honghu.cloud.feign.VerifyCodeFeignClient;
import com.honghu.cloud.redis.RedisUtil;
import com.honghu.cloud.service.IAlbumService;
import com.honghu.cloud.service.ICustomerService;
import com.honghu.cloud.service.IFavoriteService;
import com.honghu.cloud.service.IFootPointService;
import com.honghu.cloud.service.IMemberFansService;
import com.honghu.cloud.service.IPredepositLogService;
import com.honghu.cloud.service.IPullUserOrderService;
import com.honghu.cloud.service.IRoleService;
import com.honghu.cloud.service.IUserCardService;
import com.honghu.cloud.service.IUserService;
import com.honghu.cloud.service.IVerifyidCardService;
import com.honghu.cloud.tools.SecurityUserHolder;
import com.honghu.cloud.utils.CommUtil;
import com.honghu.cloud.utils.JWT;
import com.honghu.cloud.utils.beans.BeanUtils;
import com.honghu.cloud.utils.tools.Md5Encrypt;
 
import net.sf.json.JSONObject;
 
 
/**
 * 用户Controller
 * @author Administrator
 * @param <V>
 *
 */
@SuppressWarnings({"rawtypes","unchecked"})
@RestController
@RequestMapping(value = "/user")
/*/*@CrossOrigin(origins = "*", maxAge = 3600, methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
		RequestMethod.PUT })*/
public class UserController  {
	
	private static final Logger logger = LoggerFactory.getLogger(UserController.class);
 
	@Autowired
	private IUserService userService;
	@Autowired
	private IFootPointService footPointService;
	@Autowired
	private CouponInfoFeignClient couponInfoFeignClient;
	@Autowired
	private OrderFormFeignClient orderFormFeignClient;
	@Autowired
	private SysConfigFeignClient sysConfigFeignClient;
	@Autowired
	private AccessoryFeignClient accessoryFeignClient;
	@Autowired
	private VerifyCodeFeignClient verifyCodeFeignClient;
	@Autowired
	private MsgToolsFeignClient msgToolsFeignClient;
	@Autowired
	private IPullUserOrderService pullUserOrderService;
	@Autowired
	private QrCodeFeignClient qrCodeFeignClient;
	@Autowired
	private IRoleService roleService;
	@Autowired
	private AreaFeignClient areaFeignClient;
	@Autowired
	private IntegralLogFeignClient integralLogFeignClient;
	@Autowired
	private TemplateFeignClient templateFeignClient;
	@Autowired
	private ModularClassFeignClient modularClassFeignClient;
	@Autowired
	private ICustomerService customerService;
	@Autowired
	private IAlbumService albumService;
	@Autowired
	private IFavoriteService favoriteService;
	@Autowired
	private RedisUtil redisUtil;
	@Autowired
	private IVerifyidCardService verifyidCardService;
	@Autowired
	private StoreFeignClient storeFeignClient;
	@Autowired
	private TencentIMFeignClient tencentIMFeignClient;
	@Autowired
	private IUserCardService userCardService;
	@Autowired
	private IPredepositLogService predepositLogService;
	@Autowired
	private IMemberFansService memberFansService;
	@Autowired
	private IntegralToolsFeignClient integralToolsFeignClient;
	
	
	@RequestMapping(value = "/apiForFeign/selectByIds", method = RequestMethod.POST)
	public List<User> selectByIds(@RequestBody Map<String, Object> params) {
		return userService.selectByIds(params);
	}
	
	@RequestMapping(value = "/apiForFeign/getMsgSubUsers", method = RequestMethod.GET)
	public List<User> getMsgSubUsers(@RequestParam("parent_id") Long parent_id){
		return userService.getMsgSubUsers(parent_id);
	}
 
	@RequestMapping(value = "/apiForFeign/auditNoteUser", method = RequestMethod.GET)
	public List<User> auditNoteUser(){
		return userService.auditNoteUser();
	}
	@RequestMapping(value = "/apiForFeign/selectCount", method = RequestMethod.GET)
	public int selectCount(@RequestParam("params")Map<String, Object> params){
		return userService.selectCount(params);
	}
	
	@RequestMapping(value = "/apiForFeign/whetherFans", method = RequestMethod.GET)
	public boolean whetherFans(@RequestParam("mid") Long mid, @RequestParam("fansid") Long fansid) {
		MemberFans memberFans = memberFansService.whetherFans(mid, fansid);
		if (memberFans != null)
			return true;
		return false;
	}
	
	/**
	 * 根据用户id查询用户
	 * @param congelationDto
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/selectByPrimaryKey", method = RequestMethod.GET)
	public User selectByPrimaryKey(@RequestParam("id") Long id) {
		User user = userService.selectByPrimaryKey(id);
		if(user != null && user.getPhoto_id() != null){
			user.setPhoto(accessoryFeignClient.selectByPrimaryKey(user.getPhoto_id()));
		}
		return user;
	}
	@RequestMapping(value = "/apiForFeign/selectUserCardByUserId", method = RequestMethod.GET)
	public UserCard selectUserCardByUserId(@RequestParam("id") Long id) {
		return userCardService.selectByUserId(id);
	}
	
 
	@RequestMapping(value = "/apiForFeign/queryPageList", method = RequestMethod.GET)
	public List<User> queryPageList(@RequestParam("params")Map<String, Object> params) {
		return userService.queryPageList(params, null, null);
	}
	
	
	@RequestMapping(value = "/apiForFeign/verityUserNamePassword", method = RequestMethod.POST)
	public List<User> verityUserNamePassword(@RequestBody Map<String, Object> params) {
		return userService.verityUserNamePassword(params);
	}
	@RequestMapping(value = "/apiForFeign/selectPullByOrderId", method = RequestMethod.GET)
	public PullUserOrder selectPullByOrderId(@RequestParam("id") Long id) {
		PullUserOrder obj = pullUserOrderService.selectPullByOrderId(id);
		return obj;
	}
	
	
	
	@RequestMapping(value = "/apiForFeign/savePullUserOrder", method = RequestMethod.POST)
	public void savePullUserOrder(@RequestBody PullUserOrder obj) {
		pullUserOrderService.saveEntity(obj);
	}
	/**
	 * 根据订单id查询拉新用户表 ,进行删除
	 * @param id
	 */
	@RequestMapping(value = "/apiForFeign/delPullByOrderId", method = RequestMethod.GET)
	public void delPullByOrderId(@RequestParam("id") Long id) {
		pullUserOrderService.deleteByOrderId(id);
		
	}
	
	
	
	@RequestMapping(value = "/apiForFeign/queryByProperty", method = RequestMethod.POST)
	public User queryByProperty(@RequestParam("params")Map<String, Object> params) {
		return userService.queryByProperty(params);
	}
	
	
	@RequestMapping(value = "/apiForFeign/updateById", method = RequestMethod.POST)
	public void updateById(@RequestBody User obj) {
		userService.updateById(obj);
	}
	
	
	@RequestMapping(value = "/apiForFeign/update", method = RequestMethod.POST)
	public void update(@RequestBody User obj) {
		userService.update(obj);
	}
	
	@RequestMapping(value = "/apiForFeign/saveEntity", method = RequestMethod.POST)
	public User saveEntity(@RequestBody User obj) {
		return userService.saveEntity(obj);
	}
	@RequestMapping(value = "/apiForFeign/saveUserCard", method = RequestMethod.POST)
	public void saveUserCard(@RequestBody UserCard obj) {
		 userCardService.saveEntity(obj);
	}
	
	/**
	 * 根据unionid查询用户
	 * @param unionid
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/selectByUnionid", method = RequestMethod.POST)
	public User selectByUnionid(@RequestParam("unionid") String unionid){
		return userService.selectByUnionid(unionid);
	}
	
	@RequestMapping(value = "/apiForFeign/selectByWxOpenId", method = RequestMethod.POST)
	public User selectByWxOpenId(@RequestParam("openid") String openid){
		return userService.selectByWxOpenId(openid);
	}
	
	@RequestMapping(value = "/apiForFeign/getUserByStoreId", method = RequestMethod.GET)
	public User getUserByStoreId(@RequestParam("id") Long id) {
		return userService.getUserByStoreId(id);
	}
	
	
	@RequestMapping(value = "/apiForFeign/deleteUserMenu", method = RequestMethod.GET)
	public void deleteUserMenu(@RequestParam("id") Long id) {
		userService.deleteUserMenu(id);
	}
	@RequestMapping(value = "/apiForFeign/updateLiveById", method = RequestMethod.GET)
	public void updateLiveById(@RequestParam("id") Long id) {
		userService.updateLiveById(id);
	}
	@RequestMapping(value = "/apiForFeign/saveUserMenu", method = RequestMethod.POST)
	public void saveUserMenu(@RequestParam("id") Long id,@RequestBody List<Menu> ms) {
		 userService.saveUserMenu(id,ms);
	}
	
	
	
	/**
	 * 客服列表
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(value="/buyer/customerServiceList", method = RequestMethod.POST)
	public Map<String, Object> customerServiceList(HttpServletRequest request,HttpServletResponse response)  {
		Map<String,Object> params = Maps.newHashMap();
		List<CustomerService> list = customerService.queryPages(params);
		HashMap<String, Object> result = new HashMap<>();
		result.put("list", list);
		System.out.println(result);
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	/**
	 * 用户中心完善资料
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/buyer/account")
	public Map<String, Object> account(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		long user_id = SecurityUserHolder.getCurrentUser(request).getId().longValue();
		
		User user = selectByPrimaryKey(user_id);
		if(user == null){
			return ResponseCode.buildEnumMap(ResponseCode.USER_NOT_EXISTS_ERROR, null);
		}
		
		result.put("obj", user);
		result.put("imageFilesize", Integer.valueOf(sysConfigFeignClient.getSysConfig().getImageFilesize()));
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	
	/**
	 * 用户中心完善资料
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/buyer/liveCode")
	public Map<String, Object> liveCode(HttpServletRequest request,
			HttpServletResponse response) {
		HashMap<String, Object> result = new HashMap<>();
		User user = userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		result.put("liveCode", user.getLive_code());
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 用户中资料保存
	 * @param request
	 * @param response
	 * @param USER_AGE
	 * @param card
	 * @param userName
	 * @param sex
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/buyer/account_save", method = RequestMethod.POST)
	public Map<String, Object> account_saveEntity(HttpServletRequest request,
			HttpServletResponse response,@RequestBody JSONObject json) throws Exception {
		String userName = json.optString("userName");
		String nickName = json.optString("nickName");
		String sex = json.optString("sex");
		String photo_id = json.optString("photo_id");
		String USER_AGE = json.optString("USER_AGE");
		
		
		User user = this.userService.selectByPrimaryKey(SecurityUserHolder
				.getCurrentUser(request).getId());
		
		if ((userName != null) && (!userName.equals(""))) {
			user.setTrueName(userName);
		}
		if ((USER_AGE != null) && (!USER_AGE.equals(""))) {
			user.setBirthday(CommUtil.formatDate(USER_AGE));
		}
		if ((nickName != null) && (!nickName.equals(""))) {
			user.setNickName(nickName);
		}
		if ((sex != null) && (!sex.equals(""))) {
			user.setSex(CommUtil.null2Int(sex));
		}
		if(StringUtils.isNotBlank(photo_id)){
			user.setPhoto_id(CommUtil.null2Long(photo_id));
		}
		this.userService.updateById(user);
		try{
			//腾讯IM账号资料更改
			UserDto userDto = new UserDto();
			BeanUtils.copyProperties(user, userDto);
			tencentIMFeignClient.portraitSet(userDto);
		}catch (Exception e) {
			logger.error("UserController >> account_saveEntity >> IM portraitSet  "+ e.getMessage());
		}
		return ResponseCode.buildSuccessMap(null);
	}
	
	
	/**
	 * 手机客户端商城首页
	 * @param request
	 * @param response
	 * @param store_id
	 * @return
	 */
	@RequestMapping(value="/center", method = RequestMethod.POST)
	public Map<String, Object> center(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		UserDto u = SecurityUserHolder.getCurrentUser(request);
		if ((u != null) && (!u.equals(""))) {
			User user = this.userService.selectByPrimaryKey(SecurityUserHolder
					.getCurrentUser(request).getId());
			if (user!=null&&user.getPhoto_id()!=null) {
				AccessoryDto photo = accessoryFeignClient.selectByPrimaryKey(user.getPhoto_id());
				user.setPhoto(photo);
			}
			int selectCount = footPointService.selectSumCount(user.getId());
			/*Map<String,Object> foot_params = Maps.newHashMap();
			foot_params.put("fp_user_id", user.getId());
			foot_params.put("deleteStatus", 0);
			//List<FootPoint> fps = footPointService.queryPageList(foot_params);
			//result.put("objs", fps);*/		
			result.put("footsize", selectCount);
			Map<String, Object> params = Maps.newHashMap();
			params.put("user_id", user.getId());
			params.put("status", Integer.valueOf(0));
			
			result.put("couponInfos",Integer.valueOf(couponInfoFeignClient.selectCount(params)));
		/*	params.clear();
			params.put("status", Integer.valueOf(10));
			params.put("user_id", user.getId().toString());
			result.put("orders_10",Integer.valueOf(orderFormFeignClient.selectCount(params)));*/
			
			// result.put("integralViewTools", this.integralViewTools);
			params.clear();
			params.put("type", Integer.valueOf(0));
			params.put("user_id", user.getId());
			
			int favorite_goods = favoriteService.selectCount(params);
			
			result.put("favorite_goods", favorite_goods);
			params.clear();
			params.put("type", Integer.valueOf(1));
			params.put("user_id", user.getId());
			
			result.put("favorite_store",favoriteService.selectCount(params));
			params.clear();
			params.put("order_status", Integer.valueOf(10));
			params.put("user_id", user.getId().toString());
			//params.put("order_main", Integer.valueOf(1));
			
			//List<OrderFormDto> order_nopays = orderFormFeignClient.queryPageList(params);
			Integer order_nopays = orderFormFeignClient.selectCount(params);
			String order_nopay = "";
			if (order_nopays > 99) {
				order_nopay = "99+";
			} else {
				order_nopay = order_nopays + "";
			}
			
			result.put("order_nopay", order_nopay);
			params.clear();
			params.put("order_status1", Integer.valueOf(14));
			params.put("order_status2", Integer.valueOf(20));
			params.put("user_id", user.getId().toString());
			//params.put("order_main", Integer.valueOf(1));
 
			//List<OrderFormDto> order_noships = orderFormFeignClient.queryPageList(params);
			
			
			
			Integer order_noships = orderFormFeignClient.selectCount(params);
			String order_noship = "";
			if (order_noships > 99) {
				order_noship = "99+";
			} else {
				order_noship = order_noships + "";
			}
			
			result.put("order_noship", order_noship);
			params.clear();
			params.put("order_status1", Integer.valueOf(30));
			params.put("order_status2", Integer.valueOf(35));
			params.put("user_id", user.getId().toString());
			//params.put("order_main", Integer.valueOf(1));
			
			//List<OrderFormDto> order_notakes = orderFormFeignClient.queryPageList(params);
			Integer order_notakes = orderFormFeignClient.selectCount(params);
			
			String order_notake = "";
			if (order_notakes > 99) {
				order_notake = "99+";
			} else {
				order_notake = order_notakes + "";
			}
			result.put("order_notake", order_notake);
			
			params.clear();
			params.put("order_status", Integer.valueOf(40));
			params.put("user_id", user.getId().toString());
			
			 Integer order_noevaluate = orderFormFeignClient.selectCount(params);
			
			String noevaluate = "0";
			if (order_noevaluate > 99) {
				noevaluate = "99+";
			} else {
				noevaluate = order_noevaluate + "";
			}
			result.put("noevaluate", noevaluate);
			
			params.clear();
		/*	params.put("status", Integer.valueOf(0));
			params.put("user_id", user.getId());
			params.put("parent", -1);
			
			List<MessageDto> msgs  = messageFeignClient.queryPageList(params);
			
			result.put("msg_size", msgs.get(0));*/
			result.put("user", user);
			// result.put("integralViewTools", this.integralViewTools);
			
			result.put("level", integralToolsFeignClient.query_user_level(String.valueOf(user.getId())));
			Integer	store_status=0;
			if (user.getStore_id()!=null) {
				StoreDto store = storeFeignClient.selectByPrimaryKey(user.getStore_id());
				if (store!=null) {
					store_status = store.getStore_status();
					ModularClassDto ModularClassDto = modularClassFeignClient.selectByStoreId(store.getId());
					if (ModularClassDto!=null) {
						result.put("timely", ModularClassDto.isTimely());
					}else{
						result.put("timely",false);
					}
					
				}
			}
			result.put("store_status", store_status);
			
			//是否是代理商(业务员:推荐开店能获取店铺收益的那种)
			Integer platAgent = userService.agentCount(user.getId());
			result.put("platAgent", platAgent);
 
		}
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	/**
	 * 个人二维码
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping(value="/buyer/myQrcode", method = RequestMethod.GET)
	public Map<String, Object> myQrcode(HttpServletRequest request,HttpServletResponse response) throws Exception {
		UserDto userDto = SecurityUserHolder.getCurrentUser(request);
		User user = userService.selectByPrimaryKey(userDto.getId());
		if(StringUtils.isEmpty(user.getDirect_selling_qr_path())) {
			if(null != user.getPhoto_id()){
				user.setPhoto(accessoryFeignClient.selectByPrimaryKey(user.getPhoto_id()));
			}
			BeanUtils.copyProperties(user, userDto);
			// 生成用户分销二维码
			String myQrcode = qrCodeFeignClient.myQrcode(userDto);
			user.setDirect_selling_qr_path(myQrcode);
			userService.updateById(user);
		}
		return ResponseCode.buildSuccessMap(user.getDirect_selling_qr_path());
	}
	
	
	/**
	 * 用户中心支付密码修改
	 * @param request
	 * @param response
	 * @return
	 
	@RequestMapping(value="/buyer/account_pay_password", method = RequestMethod.GET)
	public Map<String, Object> account_pay_password(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		User user = this.userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUser().getId());
		result.put("user", user);
		if ((user.getMobile() != null) && (!user.getMobile().equals(""))) {
			String show_tel = user.getMobile();
			result.put("show_tel", show_tel);
			result.put("first", Integer.valueOf(-1));
		} else {
			result.put("first", "1");
		}
		return ResponseCode.buildSuccessMap(result);
	}*/
	
	
	/**
	 * 修改支付密码提交
	 * @param request
	 * @param response
	 * @param pay_password
	 * @param pay_password_confirm
	 * @param phone_number
	 * @param code
	 * @param t
	 * @return
	 */
	@RequestMapping(value="/buyer/account_pay_password_save", method = RequestMethod.POST)
	public Map<String, Object> account_pay_password_saveEntity(HttpServletRequest request,
			HttpServletResponse response, String pay_password, String pay_password_confirm, String phone_number, String code) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		if(null == code || StringUtils.isEmpty(code)){
			result.put("op_title", "验证码不能为空,支付密码修改失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_pay_password");
			return ResponseCode.buildCodeMap("20004", "不要做违规操作,超过一定次数将冻结预存款", result);
		}
		
		VerifyCodeDto vc = verifyCodeFeignClient.getObjByProperty("mobile", "=",  phone_number);
		if (vc == null) {
			result.put("op_title", "不要做违规操作,超过一定次数将冻结预存款");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_pay_password");
			return ResponseCode.buildCodeMap("20003", "不要做违规操作,超过一定次数将冻结预存款", result);
		} 
			
		if (!code.equalsIgnoreCase(vc.getCode())) {
			result.put("op_title", "验证码错误,支付密码修改失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_pay_password");
			return ResponseCode.buildCodeMap("20002", "验证码错误,支付密码修改失败", result);
		}
			
		if (StringUtils.isEmpty(pay_password) || StringUtils.isEmpty(pay_password_confirm)
				|| !StringUtils.equals(pay_password, pay_password_confirm)){
			result.put("op_title", "两次密码输入不相同");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_pay_password");
			return ResponseCode.buildCodeMap("20001", "两次密码输入不相同", result);
		}
			
		User user = this.userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
		user.setMobile(phone_number);
		user.setPay_password(Md5Encrypt.md5(pay_password));
		this.userService.updateById(user);
		result.put("op_title", "支付密码修改成功");
		result.put("url", CommUtil.getURL(request) + "/index");
		return ResponseCode.buildSuccessMap(result);
			
	}
	
	
	
	/**手机短信密码修改 TODO:(小程序没有
	 * @param request
	 * @param response
	 * @param password  密码
	 * @param mobile  手机号
	 * @param mobile_code  验证码
	 * @return
	 *//*
	@RequestMapping({ "/mobile_account_password_save" })
	@ResponseBody
	public String mobile_account_password_save(HttpServletRequest request,
			HttpServletResponse response,String password,String mobile ,String mobile_code,String password_or) {
		if(mobile == null || "".equals(mobile)){
			return "403";
		}
		if(mobile_code == null || "".equals(mobile_code)){
			return "404";
		}
		Jedis jedis = RedisCache.getJedis();
		if(jedis.exists(SerializeUtil.serialize(mobile))){
			byte[] bs = jedis.get(SerializeUtil.serialize(mobile));
			Object deserialize = SerializeUtil.deserialize(bs);
			if(deserialize != null){
				if(!CommUtil.null2String(mobile_code).equals(deserialize.toString())){
					return "402";
				}
			}
		}else{
			return "401";
		}
		if(jedis != null){
			jedis.close();
		}
		if(password != null && password_or != null){
					if(password.equals(password_or)){
			
						if(!CommUtil.null2String(mobile).equals("")){
							List<User> users=this.userService.selectByMobileOrUserName(mobile);
							if(users != null && users.size() > 0){
								User user = users.get(0);
								user.setPassword(Md5Encrypt.md5(password));
								this.userService.updateById(user);
							}else{
								return "400";
							}
						}
					}else{
						return "406";
					}
			}else{
				return "405";
			}
		 return "200";
	}
	*/
	
	
	
	
	
	
/*	*//**
	 * 修改支付密码-手机短信发送
	 * @param request
	 * @param response
	 * @param mobile
	 *//*
	@RequestMapping(value="/buyer/account_mobile_sms", method = RequestMethod.POST)
	public Map<String, Object> account_mobile_sms(HttpServletRequest request,
			HttpServletResponse response, String mobile) {
		SysConfigDto sysConfigDto = sysConfigFeignClient.getSysConfig();
		if (!sysConfigDto.getSmsEnbale()) {
			return ResponseCode.buildCodeMap("20002", "短信服务未开启", null);
		}
		
		String code = CommUtil.randomInt(4);
		String content = "尊敬的" + SecurityUserHolder.getCurrentUser(request).getUserName()
				+ "您好,您在试图修改" + sysConfigDto.getWebsiteName() + "的支付密码," 
				+ "手机验证码为:" + code + "。[" + sysConfigDto.getTitle() + "]";
		
		boolean ret_op = msgToolsFeignClient.sendSMS(mobile, content);
		if (!ret_op) {
			return ResponseCode.buildCodeMap("20001", "发送短信失败", null);
		}
		
		VerifyCodeDto mvc = verifyCodeFeignClient.getObjByProperty("mobile","=",  mobile);
		if (mvc == null) {
			mvc = new VerifyCodeDto();
		}
		mvc.setAddTime(new Date());
		mvc.setCode(code);
		mvc.setMobile(mobile);
		verifyCodeFeignClient.updateById(mvc);
		
		return ResponseCode.buildSuccessMap(null);
	}
	
	*//**
	 * 修改绑定手机
	 * @param request
	 * @param response
	 * @return
	 
	@RequestMapping(value="/buyer/account_mobile_bind", method = RequestMethod.POST)
	public Map<String, Object> account_mobile_password(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		User user = this.userService.selectByPrimaryKey(SecurityUserHolder
				.getCurrentUser().getId());
		if ((user.getMobile() != null) && (!user.getMobile().equals(""))) {
			String show_tel = user.getMobile().substring(0, 3) + "*****"
					+ user.getMobile().substring(8, 11);
			result.put("show_tel", show_tel);
			result.put("first", "-1");
		} else {
			result.put("first", "1");
		}
		return ResponseCode.buildSuccessMap(result);
	}*//*
	
	*//**
	 * 手机号码绑定提交
	 * @param request
	 * @param response
	 * @param code
	 * @param new_mobile
	 * @param t
	 * @return
	 * @throws Exception
	 *//*
	@RequestMapping(value="/buyer/account_mobile_bind_save", method = RequestMethod.POST)
	public Map<String, Object> account_mobile_bind_saveEntity(HttpServletRequest request,
			HttpServletResponse response, String code, String new_mobile,
			String t) throws Exception {
		
		Map<String, Object> result = new HashMap<String, Object>();
		if (StringUtils.isEmpty(code)) {
			result.put("op_title", "验证码不能为空,支付密码修改失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_mobile_bind");
			return ResponseCode.buildCodeMap("20004", "验证码不能为空,支付密码修改失败", result);
		}
		
		VerifyCodeDto mvc = verifyCodeFeignClient.getObjByProperty("mobile","=",  new_mobile);
		if (mvc == null) {
			result.put("op_title", "请填写正确的验证码和手机号码,手机绑定失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_mobile_bind");
			return ResponseCode.buildCodeMap("20003", "请填写正确的验证码和手机号码,手机绑定失败", result);
		}
		
		if (!StringUtils.equals(mvc.getCode(), code)) {
			result.put("op_title", "验证码错误,手机绑定失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_mobile_bind");
			return ResponseCode.buildCodeMap("20002", "验证码错误,手机绑定失败", result);
		}
		
		User user = this.userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
		if (new_mobile.equals(user.getMobile())) {
			result.put("op_title", "新旧输入电话号码不能相同,手机绑定失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_mobile_bind");
			return ResponseCode.buildCodeMap("20001", "新旧输入电话号码不能相同,手机绑定失败", result);
		}
		
		user.setMobile(new_mobile);
		this.userService.updateById(user);
		verifyCodeFeignClient.deleteById(mvc.getId());
		result.put("op_title", "手机绑定成功");
		String content = "尊敬的" + SecurityUserHolder.getCurrentUser(request).getUserName() 
						+ "您好,您于" + CommUtil.formatLongDate(new Date())+ "绑定手机号成功。["
						+ sysConfigFeignClient.getSysConfig().getTitle() + "]";
		
		msgToolsFeignClient.sendSMS(user.getMobile(), content);
		result.put("op_title", "手机绑定成功");
		result.put("url", CommUtil.getURL(request) + "/buyer/account_safe");
		
		return ResponseCode.buildSuccessMap(result);
	}
	
	*//**
	 * 手机绑定短信发送
	 * @param request
	 * @param response
	 * @param new_mobile
	 * @param t
	 *//*
	@RequestMapping(value="/buyer/account_mobile_bind_sms", method = RequestMethod.POST)
	public Map<String, Object> account_mobile_bind_sms(HttpServletRequest request,
			HttpServletResponse response, String new_mobile) {
		SysConfigDto configDto = sysConfigFeignClient.getSysConfig();
		if (!configDto.getSmsEnbale()) {
			return ResponseCode.buildCodeMap("20002", "短信服务未开启", null);
		}
			
		String code = CommUtil.randomInt(4);
		String content = "";
		content = "尊敬的" + SecurityUserHolder.getCurrentUser(request).getUserName()
				+ "您好,您在试图修改" + configDto.getWebsiteName() + "的绑定手机号码," 
				+ "手机验证码为:" + code + "。[" + configDto.getTitle() + "]";
		
		boolean ret_op = msgToolsFeignClient.sendSMS(new_mobile, content);
		if (!ret_op) {
			return ResponseCode.buildCodeMap("20001", "发送短信失败", null);
		}
		
		VerifyCodeDto mvc = verifyCodeFeignClient.getObjByProperty("mobile","=",  new_mobile);
		if (mvc == null) {
			mvc = new VerifyCodeDto();
		}
		mvc.setAddTime(new Date());
		mvc.setCode(code);
		mvc.setMobile(new_mobile);
		verifyCodeFeignClient.updateById(mvc);
		
		return ResponseCode.buildSuccessMap(null);
	}*/
	
	/**
	 * 已有账号绑定保存
	 * @param request
	 * @param response
	 * @param userName
	 * @param password
	 * @param mobile_verify_code
	 * @param mobile
	 */
	@RequestMapping(value="/buyer/datum2", method = RequestMethod.POST)
	public Map<String, Object> datum2(HttpServletRequest request,
			HttpServletResponse response, String userName, String password,
			String mobile_verify_code, String mobile){
		Map<String, Object> result = new HashMap<String, Object>();
		VerifyCodeDto mvc = verifyCodeFeignClient.getObjByProperty("mobile","=",  mobile);
		if (mvc == null) {
			result.put("op_title", "请填写正确的验证码和手机号码,手机绑定失败");
			result.put("url", CommUtil.getURL(request) + "/buyer/account_mobile_bind");
			return ResponseCode.buildCodeMap("20003", "请填写正确的验证码和手机号码,手机绑定失败", result);
		}
		
		String passwd = Md5Encrypt.md5(password).toLowerCase();
		Map<String, Object> map = Maps.newHashMap();
		map.put("userName", userName);
		map.put("passwd", passwd);
		List<User> users = this.userService.queryPageList(map);
		
		if ((mvc != null) && (mvc.getCode().equalsIgnoreCase(mobile_verify_code))
				&& (users.size() > 0)) {
			User bind_user = (User) users.get(0);
			if (CommUtil.null2String(bind_user.getOpenId()).equals("")) {
				User current_user = this.userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
				if (current_user != null) {
					bind_user.setOpenId(current_user.getOpenId());
					bind_user.setUserMark(null);
					this.userService.updateById(bind_user);
					Map<String,Object> json = Maps.newHashMap();
					json.put("login", Boolean.valueOf(true));
					json.put("userName", userName);
					json.put("passwd", passwd);
					json.put("userId", current_user.getId());
					return ResponseCode.buildSuccessMap(json);
				}
			}
			return ResponseCode.buildCodeMap("20001", "参数错误", null);
		} else {
			return ResponseCode.buildCodeMap("20002", "验证码错误", null);
		}
	}
	
	/**
	 * 已有账号绑定保存错误提示
	 * @param request
	 * @param response
	 * @return
	@RequestMapping(value="/buyer/datum_error", method = RequestMethod.GET)
	public Map<String, Object> datum_error(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("op_title", "用户名或验证码输入错误!");
		result.put("url", CommUtil.getURL(request) + "/buyer/center");
		return ResponseCode.buildSuccessMap(result);
	}*/
	@RequestMapping(value = "/test", method = RequestMethod.POST)
	public ResponseVO login1( HttpServletRequest request){
		return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_PASSWORD_NOT_EMPTY, null);
		   
	}
	/**
	 * 用户登录(WAP)
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public ResponseVO login(@RequestBody JSONObject json, HttpServletRequest request){
		//获取数据
		String username = json.optString("username");
		String password = json.optString("password");
		//验证用户是否为空;
	    if(StringUtils.isEmpty(username)){
	    	return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_NAME_NOT_EMPTY, null);
	    }
	    //验证密码是否为空;
	    if(StringUtils.isEmpty(password)){
	    	return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_PASSWORD_NOT_EMPTY, null);
	    }
	    
	    HashMap<String, Object> params = new HashMap<String, Object>();
	    params.put("userName", username);
	    List<User> User_list = userService.queryPageList(params);
	    if(User_list == null||User_list.size()<1){
	    	return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_DOES_NOT_EXIST, null);
	    }
	    User info = User_list.get(0);
	    
	    //判断用户是否禁用
    	if( -1== info.getStatus()){
    		return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_NAME_IS_DISABLE, null);
    	}
    	
	    //用户密码是否匹配
    	if(!StringUtils.equals(Md5Encrypt.md5(password), info.getPassword())){
    		return MemberResponseCode.buildEnumResponseVO(MemberResponseCode.RESPONSE_CODE_USER_PASSWORD_NOT_VALIDATE, null);
    	}
		String token = JWT.sign(info.getId() + ";" + System.currentTimeMillis()+";"+"app", 0);
		// 将token存到redis中,有效期24小时 
		redisUtil.set(Globals.ANDROID_LOGIN_MARK + info.getId(), token, Globals.USER_INFO_EXPIRE_TIME);
		
		// 覆盖redis用户信息
		UserDto userDto = new UserDto();
		BeanUtils.copyProperties(info, userDto);
		redisUtil.set(Globals.USER_INFO_MARK + info.getId(), userDto, Globals.USER_INFO_EXPIRE_TIME);
 
    	//加密用户名、密码 
	   /* String token = JWT.sign(info.getId(), 0);
	    //将用户名密码生成的token信息放入redis缓存
	    redisUtil.set(Globals.WAP_LOGIN_MARK + info.getId(), token);*/
    	Map<String, Object> result = new HashMap<String, Object>();
    	//根据uid查询member信息
    	User user = userService.selectByPrimaryKey(info.getId());
    	/*if (user.getPhoto_id()!=null) {
			AccessoryDto accessoryDto = accessoryFeignClient.selectByPrimaryKey(user.getPhoto_id());
			if (accessoryDto!=null) user.setPhoto(accessoryDto);
    	}*/
    	result.put("userInfo", user);
	    result.put("token", token);
		return ResponseCode.buildEnumResponseVO(ResponseCode.SUCCESS, result);
	}
	
	
	private static final String REGEX1 = "(.*管理员.*)";
	private static final String REGEX2 = "(.*admin.*)";
	/**
	 * 注册完成
	 * @param request
	 * @param response
	 * @param userName
	 * @param password
	 * @param email
	 * @param code
	 * @param user_type
	 * @return
	 * @throws HttpException
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@RequestMapping(value="/register_finish", method = RequestMethod.POST)
	public Map<String, Object> register_finish(@RequestBody JSONObject json,HttpServletRequest request, HttpServletResponse response
			) throws HttpException, IOException, InterruptedException {
		// 获取数据
		String userName = json.optString("username");
		String password = json.optString("password");
		String user_type = json.optString("user_type");
		String directSellingParent_id = json.optString("directSellingParent_id");
		String email = json.optString("email");
 
		// 验证用户是否为空;
		if (StringUtils.isEmpty(userName)) {
			return ResponseCode.buildFailMap("10004", "参数错误");
		}
		// 验证密码是否为空;
		if (StringUtils.isEmpty(password)) {
			return ResponseCode.buildFailMap("10004", "参数错误");
		}
				
		SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
		//查询是否有用户名
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("userName", userName);
		List<User> User_list = userService.queryPageList(map);
		if (User_list.size() > 0) {
			return ResponseCode.buildFailMap("10003", "该用户名已注册");
		}
		try {
			boolean reg = true;
			if ((userName.matches(REGEX1)) || (userName.toLowerCase().matches(REGEX2))) {
				reg = false;
			}
			if (reg) {
				User user = new User();
				user.setUserName(userName);
				user.setUserRole("BUYER");
				user.setAddTime(new Date());
				user.setEmail(email);
				user.setAvailableBalance(BigDecimal.valueOf(0L));
				user.setFreezeBlance(BigDecimal.valueOf(0L));
				if (directSellingParent_id != null) {
					User directSellingParent = this.userService
							.selectByPrimaryKey(CommUtil.null2Long(directSellingParent_id));
					user.setDirectSellingParent(directSellingParent);
				}
				if ((user_type != null) && (!user_type.equals(""))) {
					user.setUser_type(CommUtil.null2Int(user_type));
					user.setContact_user(request.getParameter("contact_user"));
					user.setDepartment(request.getParameter("department"));
					user.setTelephone(request.getParameter("telephone"));
					user.setMobile(request.getParameter("mobile"));
					user.setCompany_name(request.getParameter("company_name"));
					AreaDto area = this.areaFeignClient.selectByPrimaryKey(CommUtil
							.null2Long(request.getParameter("area_id")));
					user.setCompany_address(area.getParent().getParent()
							.getAreaName()
							+ area.getParent().getAreaName()
							+ area.getAreaName()
							+ " "
							+ request.getParameter("company_address"));
					if (request.getParameter("company_purpose") != null) {
						if (!request.getParameter("company_purpose").equals("")) {
							user.setCompany_purpose(request.getParameter(
									"company_purpose").substring(
									0,
									request.getParameter("company_purpose")
											.length() - 1));
						}
					}
					user.setCompany_url(request.getParameter("company_url"));
					user.setCompany_person_num(request
							.getParameter("company_person_num"));
					user.setCompany_trade(request.getParameter("company_trade"));
					user.setCompany_nature(request
							.getParameter("company_nature"));
				}
				user.setPassword(Md5Encrypt.md5(password).toLowerCase());
				Map<String, Object> params = Maps.newHashMap();
				params.put("type", "BUYER");
				
				List<Role> roles = this.roleService.queryPageList(params);
				
				this.userService.saveUserRole(user.getId(), roles);
				
				if (sysConfig.getIntegral()) {
					user.setIntegral(sysConfig
							.getMemberRegister());
					try {
						this.userService.saveEntity(user);
					} catch (Exception e) {
						e.printStackTrace();
					}
					IntegralLogDto log = new IntegralLogDto();
					log.setAddTime(new Date());
					log.setContent("用户注册增加"
							+ sysConfig
									.getMemberRegister() + "分");
					log.setIntegral(sysConfig
							.getMemberRegister());
					log.setIntegral_user_id(user.getId());
					log.setType("reg");
					integralLogFeignClient.saveEntity(log);
				} else {
					this.userService.saveEntity(user);
				}
				Album album = new Album();
				album.setAddTime(new Date());
				album.setAlbum_default(true);
				album.setAlbum_name("默认相册");
				album.setAlbum_sequence(55536);
				album.setUser_id(user.getId());
				this.albumService.saveEntity(album);
				
				return ResponseCode.buildSuccessMap(null);
			}
			return ResponseCode.buildFailMap("10001", "请求失败");
		} catch (Exception e) {
		}
		return ResponseCode.buildSuccessMap(null);
	}
	
	/**发送短信   (用户登录界面)
	 * @param mobile
	 * @return
	 */
	@RequestMapping(value ="/mobile_send", method = RequestMethod.POST)
	public Map<String, Object> mobile_send(@RequestBody JSONObject json) {
		// 获取数据
		String mobile = json.optString("mobile");
		String type = json.optString("type");
 
		if (mobile == null || "".equals(mobile)) {
			return ResponseCode.buildReturnMap(ResponseCode.RESPONSE_CODE_USER_MOBILE_OR_TELEPHONE_NOT_EMPTY,
					"联系方式不能为空");
		}
 
	/*	// 系统配置是否开启短信功能  (后面有做验证)
		SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
		if (sysConfig.getSmsEnbale() == false) {
			return ResponseCode.buildReturnMap(ResponseCode.RESPONSE_CODE_SMS_CLOSE,"系统尚未开启短信服务");
			
		}*/
		
		// 短信模板(固定模板,一个是注册,一个登陆) 登录验证码
		String mark = "sms_tobuyer_user_login_notify"; // 后台短信模板登录标识
		if (CommUtil.null2String(type).equals("find")) {
			mark = "sms_tobuyer_find_password_notify"; // 重置密码
		} else if (CommUtil.null2String(type).equals("bind")) {
			mark = "sms_tobuyer_user_login_notify"; // 通用验证码
		} else {
			List<User> users = this.userService.selectByMobileOrUserName(mobile);// (手机号唯一),通过手机号(账号),查询用户
			if (users != null && users.size() > 0) {
				mark = "sms_tobuyer_user_login_notify"; // 登录验证码
			} else {
				mark = "sms_tobuyer_tips_notify";
			}
		}
		// 根据短信模板标识(固定)查询模板信息
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("mark", mark); // 模板标识
		hashMap.put("open", 1); // 开启
		List<TemplateDto> templatedto_list = templateFeignClient.queryPageList(hashMap);
 
		
		if (templatedto_list.size()==0) {
			return ResponseCode.buildReturnMap(ResponseCode.RESPONSE_CODE_SMS_CLOSE,"系统尚未开启短信服务");
		}
		
		
		ThreadLocalRandom current = ThreadLocalRandom.current();
		int muber = current.nextInt(100000, 1000000);
		if (!redisUtil.existsHashKey("mobile", mobile)) {    //查询是否存在
			redisUtil.setHashvValueTimeout("mobile", mobile, muber, 5, TimeUnit.MINUTES);       //不存在,则创建,超时时间为5分钟
			//TODO(待修改,动态)  目前是阿里的内容
			String content = "{\"code\":\"" + muber + "\"}";
			msgToolsFeignClient.sendSMS(mobile,templatedto_list.get(0).getSms_mark(),content);     //发送短信请求
		} else {
			Object hashValue = redisUtil.getHashValue("mobile", mobile);
			String content = "{\"code\":\"" + hashValue.toString() + "\"}";
			msgToolsFeignClient.sendSMS(mobile, templatedto_list.get(0).getSms_mark(), content);
		}
		//RedisCache.removeObject(mobile);
		return ResponseCode.buildSuccessMap("短信已发送");
	}
	
	
	/**短信验证
	 * @param mobile
	 * @param code
	 * @return
	 */
	/*@RequestMapping({"/code_validate"})
	public String  code_validate(@RequestBody JSONObject json){
		String mobile = json.optString("mobile");
		String code = json.optString("code");
		
		if(mobile == null || "".equals(mobile)){
			return "404";
		}
		if(code == null || "".equals(code)){
			return "404";
		}
		Jedis jedis = RedisCache.getJedis();
		if(jedis.exists(SerializeUtil.serialize(mobile))){
			byte[] bs = jedis.get(SerializeUtil.serialize(mobile));
			Object deserialize = SerializeUtil.deserialize(bs);
			if(deserialize != null){
				if(CommUtil.null2String(code).equals(deserialize.toString())){
					return "200";
				}else{
					return "400";
				}
			}
		}
		if(jedis != null){
			jedis.close();
		}
		return "401";
	}*/
	
	/**短信验证
	 * @param mobile
	 * @param code
	 * @return
	 *//*
	@RequestMapping({"/code_validate"})
	public  Boolean code_validate(String mobile,String code){
		if(mobile == null || "".equals(mobile)){
			return false;
		}
		if(code == null || "".equals(code)){
			return false;
		}
		Jedis jedis = RedisCache.getJedis();
		if(jedis.exists(SerializeUtil.serialize(mobile))){
			byte[] bs = jedis.get(SerializeUtil.serialize(mobile));
			Object deserialize = SerializeUtil.deserialize(bs);
			if(deserialize != null){
				if(CommUtil.null2String(code).equals(deserialize.toString())){
					RedisCache.removeObject(mobile);
					return true;
				}
			}
		}
		if(jedis != null){
			jedis.close();
		}
		return false;
	}*/
	
	
	
	/**
	 * 用户申请主播,
	 * 已是主播则进行更换上级
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/buyer/add_livecode" })
	public Map<String, Object> add_livecode(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		HashMap<String, Object> result = new HashMap<>();
		User user = userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		// 如果是审核通过的主播,则进行更换
		result.put("Is_live", user.getIs_live());// 是否是主播
		result.put("Live_code_up", user.getLive_code_up());
		result.put("goods_id", 502); // 增值服务商品id
 
		return ResponseCode.buildSuccessMap(result);
 
	}
	
	
	//进身份证验证页面
	@RequestMapping({ "/inLiveCode" })
	public Map<String, Object> inLiveCode(HttpServletRequest request, HttpServletResponse response) {
		
		UserDto userDto = SecurityUserHolder.getCurrentUser(request);
		if(userDto == null){
			return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
		}
		
		User currentUser = userService.selectByPrimaryKey(userDto.getId());
		HashMap<String, Object> result = new HashMap<>();
		result.put("is_live", currentUser.getIs_live());
		if(currentUser.getIs_live() == 1){
			VerifyidCard vc = verifyidCardService.selectByUserId(currentUser.getId());
			if(vc != null){
				result.put("vc", vc);
			}
		}
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 校验邀请码(添加了身份证验证功能)
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/checkLiveCode" })
	public Map<String, Object> checkLiveCode(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		String liveCode = json.optString("liveCode");
		String name = json.optString("name");
		String code = json.optString("code");
		String phone = json.optString("phone");
		Long img_id1 = json.optLong("img_id1");
		Long img_id2 = json.optLong("img_id2");
		Long img_id3 = json.optLong("img_id3");
		
		if(StringUtils.isBlank(name) || StringUtils.isBlank(code) || StringUtils.isBlank(phone) 
				|| img_id1 == null ||  img_id2 == null || img_id3 == null){
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
		
		if(StringUtils.isBlank(liveCode)){
			liveCode = "100000";
		}
		
		UserDto userDto = SecurityUserHolder.getCurrentUser(request);
		if(userDto == null){
			return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
		}
		
		HashMap<String, Object> result = new HashMap<>();
		User currentUser = userService.selectByPrimaryKey(userDto.getId());
		User user = userService.selectByLiveCode(CommUtil.null2Long(liveCode));//100086
		boolean isflag=false;
		if (user!=null) {  //不能是自己的邀请码并且这个邀请码存在
			currentUser.setLive_code_up(CommUtil.null2Long(liveCode));
			userService.updateById(currentUser);
			isflag=true;
		}
		result.put("check", isflag);
		result.put("goods_id", 502); // 增值服务商品id
		VerifyidCard vc = verifyidCardService.selectByUserId(currentUser.getId());
		boolean bol = false;
		if(vc == null){
			//保存用户身份证信息
			vc = new VerifyidCard();
			vc.setAddTime(new Date());
			vc.setDeleteStatus(0);
			bol = true;
		}
		vc.setName(name);
		vc.setCode(code);
		vc.setPhone(phone);
		vc.setImg_id1(img_id1);
		vc.setImg_id2(img_id2);
		vc.setImg_id3(img_id3);
		vc.setUid(currentUser.getId());
		
		if(bol){
			verifyidCardService.saveEntity(vc);
		}else{
			verifyidCardService.updateById(vc);
		}
		return ResponseCode.buildSuccessMap(result);
	}
	
	
	/**
	 * 判断店铺是否开通主播(用户名+密码)
	 * @param paraMap
	 * @return 不为空表示已经开通
	 */
	@RequestMapping(value = "/apiForFeign/checkingAccount", method = RequestMethod.POST)
	public Long checkingAccount(@RequestBody Map<String, String> paraMap){
		String userName = paraMap.get("userName");
		String password = paraMap.get("password");
		User user = userService.selectByUserName(userName);
		if(user == null){
			return null;
		}
		if(!StringUtils.equals(password, user.getPassword())){
			return null;
		}
		if(user.getIs_live() != 2){
			return null;
		}
		return user.getId();
	}
 
	/**
	 * 判断店铺是否开通主播(用户名)
	 * @param paraMap
	 * @return 不为空表示已经开通
	 */
	@RequestMapping(value = "/apiForFeign/checkingUserName", method = RequestMethod.POST)
	public Long checkingUserName(@RequestBody Map<String, String> paraMap){
		String userName = paraMap.get("userName");
		User user = userService.selectByUserName(userName);
		if(user == null){
			return null;
		}
		if(user.getIs_live() != 2){
			return null;
		}
		return user.getId();
	}
	
	/**
	 * 根据用户名查询用户
	 * @param username
	 * @return
	 */
	@RequestMapping(value = "/apiForFeign/selectByUserName", method = RequestMethod.POST)
	public User selectByUserName(@RequestParam("userName")String userName){
		return userService.selectByUserName(userName);
	}
	
	//将邀请注册奖金提现到余额
	@RequestMapping(value ="/invProChangeBalance", method = RequestMethod.POST)
	public Map<String, Object> invProChangeBalance(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject json) {
		String money = json.optString("money");
		if(StringUtils.isBlank(money)){
			return ResponseCode.buildEnumMap(ResponseCode.REQ_CANNOT_EMPTY, null);
		}
		UserDto user = SecurityUserHolder.getCurrentUser(request);
		if(user == null || user.getId() == null){
			return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
		}
		User inviter = userService.selectByPrimaryKey(user.getId());
		//判断是否超过额度
		if(new BigDecimal(money).compareTo(inviter.getInvitation_profit()) == 1){
			return ResponseCode.buildCodeMap("21001", "超过可转额度", null);
		}
		//判断金额是不是20的倍数
		Integer changeMoney = Integer.parseInt(money);
		if(changeMoney >= 0 && changeMoney%20 == 0){
			inviter.setInvitation_profit(inviter.getInvitation_profit().subtract(new BigDecimal(money)));
			BigDecimal before = inviter.getAvailableBalance();
			inviter.setAvailableBalance(inviter.getAvailableBalance().add(new BigDecimal(money)));
			userService.updateById(inviter);
			
			try{
				//添加记录
				PredepositLog log = new PredepositLog();
				log.setPd_log_user_id(inviter.getId());
				log.setPd_log_amount(new BigDecimal(money));
				log.setAmount_before(before);
				log.setAmount_after(inviter.getAvailableBalance());
				log.setAddTime(new Date());
				log.setDeleteStatus(0);
				log.setPd_log_info("邀请注册收益转余额");
				log.setPd_op_type("分销结算收益");
				log.setPd_type("可用预存款");
				predepositLogService.saveEntity(log);
			}catch (Exception e) {
				logger.error("UserController >> invProChangeBalance >> Exception:"+ e.getMessage());
			}
			
		}
		return ResponseCode.buildSuccessMap(true);
	}
	
	
	
	
 
	/**
	 * 下单显示  (随机100个用户 )
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping({ "/userIndex" })
	public Map<String, Object> userIndex(HttpServletRequest request, HttpServletResponse response) {
 
		//UserDto userDto = SecurityUserHolder.getCurrentUser(request);
 
		Map<String, Object> params = Maps.newHashMap();
		/*if (userDto!=null) {
			params.put("id_no", userDto.getId());
		}*/
		params.put("deleteStatus", 0);
		params.put("weixin_unionID_is_no", "weixin_unionID_is_no");
		// 总用户数量
		int selectCount = userService.selectCount(params);
		int c = 0;
		int nextInt =0;
		if (selectCount<100) {
			c=1;
		}else{
			c = (int) selectCount / 100;
			Random random = new Random();
			nextInt = random.nextInt(c);
		}
		HashMap<String, Object> result = new HashMap<>();
		// 用户列表
		//List<User> list = new ArrayList<User>();
		List<User> list = (List<User>) redisUtil.get("userIndexList");
		/*result.put("userIndexList", list);
		return ResponseCode.buildSuccessMap(result);*/
		
		if (null == list || list.size() < 1) {
			params.clear();
			params.put("start", nextInt);
			params.put("weixin_unionID_is_no", "weixin_unionID_is_no");
			list = userService.listIndex(params);
			//设置成一天过期
			long oneday=24*60*60;
			redisUtil.set("userIndexList", list,oneday);
			result.put("userIndexList", list);
 
		} else {
			result.put("userIndexList", list);
		}
 
		return ResponseCode.buildSuccessMap(result);
	}
	
	/**
	 * 查看用户是否有公众号openid (没有则去鱼易库里查,在没有就提示给前端)
	 * @param request
	 * @param response
	 * @return
	 *//*
	@RequestMapping({ "/buyer/selectWxOpenId" })
	public Map<String, Object> selectWxOpenId(HttpServletRequest request, HttpServletResponse response,
			@RequestBody JSONObject json) {
		HashMap<String, Object> result = new HashMap<>();
		User user = userService.selectByPrimaryKey(SecurityUserHolder.getCurrentUserId(request));
		if(user==null){
			// 用户不存在
			return ResponseCode.buildFailMap("用户不存在", null);
		}
		boolean isfalg=false;
		String openid=user.getWx_open_id();
		//为空则去鱼易数据库查
		
		if(StringUtils.isEmpty(openid)){
			
			JSONObject paramJson = new JSONObject();
			paramJson.put("username", user.getMobile());
			
			String data =  "";
	        try {
	        	// 加密data
				data = AESUtil.getInstance().Encrypt(paramJson.toString(), AESUtil.akk_secret);
			} catch (Exception e) {
				log.error("加密请求参数出错,错误信息"+Exceptions.getStackTraceAsString(e));
			}
	        
	        Map<String,String> params = new HashMap<String, String>();
	    	params.put("data", data);
	    	String url = "https://www.fishmq.cn/apply/synchroOpenid";
	        
	    	String result1 = HttpClientUtils.doPostReturn(url, params, "application/json; charset=UTF-8"); //UTF-8
	    	//{"msg":"您的账号未绑定渔易水产科技公众号","code":500}
	    	Map map = (Map)JSON.parse(result1);
	    	Integer code = (Integer)map.get("code");
	    	if(code == 200){
	    		openid=(String) map.get("msg");
	    		isfalg=true;
	    		//将openid 保存进用户表
	    		user.setWx_open_id(openid);
	    		userService.updateById(user);
	    	}
		}
		//如果openid还为空则返回false,需要用户关注公众号
		result.put("isfalg", isfalg);
		return ResponseCode.buildSuccessMap(result);
	}*/
	
	@RequestMapping(value = "/logoff", method = RequestMethod.POST)
	public Map<String,Object> logoff(HttpServletRequest request,@RequestBody JSONObject json){
		UserDto currentUser = SecurityUserHolder.getCurrentUser(request);
		User user = this.userService.selectByPrimaryKey(currentUser.getId());
		
		// 注销用户
		user.setUserName("logoff_" + user.getUserName());
		user.setMobile("logoff_" + user.getMobile());
		user.setStatus(-2);
		user.setWeixin_unionID("logoff_"+user.getWeixin_unionID());
		user.setOpenId("logoff_"+user.getOpenId());
		user.setWx_open_id("logoff_"+user.getWx_open_id());
		user.setDeleteStatus(1);
 
		// 修改登录信息
		user.setLastLoginDate(new Date());
		user.setLastLoginIp(CommUtil.getIpAddr(request));
 
		userService.updateById(user);
 
		// 将token删除
		redisUtil.remove(Globals.ANDROID_LOGIN_MARK + user.getId());
 
		// 返回结果集
		return ResponseCode.buildSuccessMap(new HashMap<>());
	}
	
}
 @源码地址来源: https://minglisoft.cn/honghu2/business.html

这篇关于spring boot商城o2o商城JAVA版 B2B2C商城源码 分销商城 直播商城的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!