Parcourir la source

fix 接口转移、店铺详情

zoujiajian il y a 2 ans
Parent
commit
579f1860ab

+ 31 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/YhShopInfo.java

@@ -0,0 +1,31 @@
+package com.cyksj.model.dto;
+
+import com.cyksj.model.manage.entity.YhShop;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/*
+ *项目名: yhlxj
+ *文件名: YhShopInfo
+ *创建者: JavaZou
+ *创建时间:2023/9/20 14:26
+ */
+@Getter
+@Setter
+public class YhShopInfo {
+	private Long yhsId;
+
+	private String customId;
+
+	private String name;
+
+	private YhShop.Status verifyStatus;
+
+	private Boolean status;
+
+	private String contact;
+
+	private Date createdTime;
+}

+ 1 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -601,6 +601,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
 			if (order.getMoney().compareTo(BigDecimal.ZERO) > 0 && order.getIsDistribute()) {
 				TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
 				TASK_POOL.execute(() -> distributeWaitingSendPointsRecord(order));
 			}
 			}
+			//店铺分销 存在
 			if (order.getYhsId() != null && order.getYhsId() > 0) {
 			if (order.getYhsId() != null && order.getYhsId() > 0) {
 				TASK_POOL.execute(() -> yhShopDistributeWaitingSendPointsRecord(order));
 				TASK_POOL.execute(() -> yhShopDistributeWaitingSendPointsRecord(order));
 			}
 			}

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/shop/YhShopFrontService.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.shop;
 package com.cyksj.service.shop;
 
 
+import com.cyksj.model.dto.YhShopInfo;
 import com.cyksj.model.manage.entity.YhShop;
 import com.cyksj.model.manage.entity.YhShop;
 
 
 /*
 /*
@@ -19,4 +20,6 @@ public interface YhShopFrontService {
 	 * @return
 	 * @return
 	 */
 	 */
 	Long checkShopCustomIdAndReturnShopId(String customId);
 	Long checkShopCustomIdAndReturnShopId(String customId);
+
+	YhShopInfo getYhShopInfo(String customId);
 }
 }

+ 11 - 0
netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopServiceImpl.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.shop.impl;
 package com.cyksj.service.shop.impl;
 
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.constant.Constant;
@@ -7,6 +8,7 @@ import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.mapper.SysConfigMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
+import com.cyksj.model.dto.YhShopInfo;
 import com.cyksj.model.entity.SysConfig;
 import com.cyksj.model.entity.SysConfig;
 import com.cyksj.model.manage.entity.YhShop;
 import com.cyksj.model.manage.entity.YhShop;
 import com.cyksj.service.shop.YhShopFrontService;
 import com.cyksj.service.shop.YhShopFrontService;
@@ -131,6 +133,15 @@ public class YhShopServiceImpl implements YhShopFrontService {
 		return yhShop.getId();
 		return yhShop.getId();
 	}
 	}
 
 
+	@Override
+	public YhShopInfo getYhShopInfo(String customId) {
+		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getCustomId, customId).last("limit 1"));
+		YhShopInfo yhShopInfo = new YhShopInfo();
+		BeanUtil.copyProperties(yhShop, yhShopInfo);
+		return yhShopInfo;
+	}
+
 	public void checkShopInfo(String name, String customId) {
 	public void checkShopInfo(String name, String customId) {
 		if (StrUtil.isEmpty(name)) {
 		if (StrUtil.isEmpty(name)) {
 			throw BusinessRuntimeException.getInstance("请输入店铺名称");
 			throw BusinessRuntimeException.getInstance("请输入店铺名称");

+ 8 - 150
netflix-web/src/main/java/com/cyksj/web/controller/cps/YhShopLoginController.java → netflix-web/src/main/java/com/cyksj/web/controller/cps/shop/YhShopDateController.java

@@ -1,63 +1,45 @@
-package com.cyksj.web.controller.cps;
+package com.cyksj.web.controller.cps.shop;
 
 
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.cyksj.common.annotation.NoSubmit;
-import com.cyksj.common.exception.BusinessRuntimeException;
-import com.cyksj.common.snowflake.Sequence;
-import com.cyksj.common.util.Codec;
-import com.cyksj.common.util.Jsons;
-import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
 import com.cyksj.dto.Result;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonMapper;
-import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
-import com.cyksj.model.dto.AuthRedirect;
-import com.cyksj.model.dto.AuthToken;
-import com.cyksj.model.dto.CpsAuthDto;
-import com.cyksj.model.dto.GzhOAuth2UserInfo;
 import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.User;
 import com.cyksj.model.entity.User;
 import com.cyksj.model.entity.YhShopDistributeMoneyApply;
 import com.cyksj.model.entity.YhShopDistributeMoneyApply;
 import com.cyksj.model.manage.entity.YhShop;
 import com.cyksj.model.manage.entity.YhShop;
 import com.cyksj.model.manage.entity.YhShopDistributeWaitingSendPoints;
 import com.cyksj.model.manage.entity.YhShopDistributeWaitingSendPoints;
-import com.cyksj.model.request.LoginReq;
 import com.cyksj.model.views.*;
 import com.cyksj.model.views.*;
-import com.cyksj.redis.RedisService;
-import com.cyksj.service.authorization.AuthorizationService;
 import com.cyksj.service.cps.shop.YhShopManageService;
 import com.cyksj.service.cps.shop.YhShopManageService;
-import com.cyksj.service.wechat.WeChatService;
-import com.cyksj.web.util.StpUserUtil;
 import com.cyksj.web.util.StpYhShopManageUser;
 import com.cyksj.web.util.StpYhShopManageUser;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapBuilder;
 import com.ejlchina.searcher.util.MapBuilder;
 import com.ejlchina.searcher.util.MapUtils;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Optional;
 import java.util.Optional;
 
 
 /*
 /*
  *项目名: yhlxj
  *项目名: yhlxj
- *文件名: YhShopController
+ *文件名: YhShopDateController
  *创建者: JavaZou
  *创建者: JavaZou
- *创建时间:2023/9/19 17:34
+ *创建时间:2023/9/20 14:19
  */
  */
 @RestController
 @RestController
-@RequestMapping("/yhShop/manage")
+@RequestMapping("/yhShop/manage/data")
 @RequiredArgsConstructor
 @RequiredArgsConstructor
-public class YhShopLoginController {
+public class YhShopDateController {
 	private final YhShopManageService yhShopManageService;
 	private final YhShopManageService yhShopManageService;
 
 
 	private final BeanSearcher beanSearcher;
 	private final BeanSearcher beanSearcher;
@@ -66,131 +48,7 @@ public class YhShopLoginController {
 
 
 	private final GoodsDonMapper goodsDonMapper;
 	private final GoodsDonMapper goodsDonMapper;
 
 
-	private final RedisService redisService;
-
-	private final static Sequence SEQUENCE = new Sequence(0);
-
-	private final WxOpenPlatYHLXLoginConfig wxOpenPlatYHLXLoginConfig;
-
-	private final AuthorizationService authorizationService;
-
-	private final WeChatService weChatService;
-
-	private final UserMapper userMapper;
-
 	private final YhShopMapper yhShopMapper;
 	private final YhShopMapper yhShopMapper;
-
-	/**
-	 * 获取登录验证码
-	 */
-	@GetMapping("/get/LoginCode")
-	@NoSubmit
-	public Result getLoginCode(@RequestParam(defaultValue = "1") Integer type, String login, Integer cid) {
-		yhShopManageService.getLoginCode(type, login, cid);
-		return GatewayResponse.SUCCESS.newBuilder().toResult();
-	}
-
-	/**
-	 * 跳转店铺后台 是否是店铺主
-	 */
-	@GetMapping("/redirect")
-	public void yhShopManageRedirect(String redirectUrl, HttpServletResponse response) throws IOException {
-		//银河官网token值
-		long userId = StpUserUtil.getLoginIdAsLong();
-		yhShopManageService.yhShopManageRedirect(userId);
-		//校验通过重定向
-		StpYhShopManageUser.login(userId);
-		response.sendRedirect(redirectUrl.contains("?") ? redirectUrl + "&t=" + StpYhShopManageUser.getTokenValue() : redirectUrl + "?t=" + StpYhShopManageUser.getTokenValue());
-	}
-
-
-	/**
-	 * 手机号、邮箱登录
-	 */
-	@PostMapping("/login")
-	public Result login(@RequestBody LoginReq loginReq) {
-		User user = yhShopManageService.login(loginReq.getType(), loginReq.getLogin(), loginReq.getCode());
-		StpYhShopManageUser.login(user.getId());
-		String yhShopToken = StpYhShopManageUser.getTokenValue();
-		JSONObject re = new JSONObject();
-		re.putOpt("satoken-yhShop", yhShopToken);
-		re.putOpt("img", user.getHeadimgurl());
-		re.putOpt("nickname", user.getNickname());
-		return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
-	}
-
-	/**
-	 * 小店后台微信授权登录
-	 */
-	@GetMapping("/wx/authLogin")
-	public Result<CpsAuthDto> wxAuthorize() throws Exception {
-		Object authUrlObj = redisService.get(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("yhShop", wxOpenPlatYHLXLoginConfig.getAppId()));
-		if (authUrlObj != null) {
-			CpsAuthDto cpsAuthDto = Jsons.parseObject(authUrlObj.toString(), CpsAuthDto.class);
-			return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
-		}
-		CpsAuthDto cpsAuthDto = new CpsAuthDto();
-		Long mappingId = SEQUENCE.nextId();
-		String authState = mappingId.toString();
-		redisService.set(authState, authState, 60 * 60 * 24L);
-		AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
-		String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
-		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getYhShopRedirectUri());
-		cpsAuthDto.setAuthUrl(wxAuthUrl);
-		cpsAuthDto.setAuthState(authState);
-		redisService.set(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("yhShop", wxOpenPlatYHLXLoginConfig.getAppId()), Jsons.toJson(cpsAuthDto), RedisService.key.WX_LOGIN_AUTH_URI.getTimeout());
-		return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
-	}
-
-	/**
-	 * 网页微信授权后跳转
-	 */
-	@GetMapping("/wx/authLogin/baseRedirect")
-	public void wxAuthLoginRedirect(String code, String state, HttpServletResponse response) throws Exception {
-		if (StrUtil.isEmpty(state)) throw BusinessRuntimeException.getInstance("授权错误,请重新授权");
-		String json = Codec.DoBase64.custom().setData(state).decodeAsText();
-		AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
-		AuthToken token = weChatService.getAuthToken(code, wxOpenPlatYHLXLoginConfig.getAppId());
-		GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
-		String unionId = userinfo.getUnionid();
-		String openId = userinfo.getOpenid();
-		User user = Optional.ofNullable(
-						userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getUnionid, unionId)
-								.orderByAsc(User::getId)
-								.last("limit 1")))
-				.orElseGet(() -> userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getOpenId, openId)
-						.orderByAsc(User::getId)
-						.last("limit 1")));
-		if (user == null) throw BusinessRuntimeException.getInstance("用户信息不存在");
-		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
-				.eq(YhShop::getVerifyStatus, YhShop.Status.success)
-				.eq(YhShop::getUserId, user.getId()).last("limit 1"));
-		if (yhShop == null) {
-			throw BusinessRuntimeException.getInstance("您不是银河小店店铺主");
-		}
-		JSONObject res = new JSONObject();
-		StpYhShopManageUser.login(user.getId());
-		String cpsToken = StpYhShopManageUser.getTokenValue();
-		res.putOpt("satoken-yhShop", cpsToken);
-		res.putOpt("img", user.getHeadimgurl());
-		res.putOpt("nickname", user.getNickname());
-		redisService.set(RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getNameFormat(re.getMappingId()), res.toString(), RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getTimeout());
-		response.sendRedirect(wxOpenPlatYHLXLoginConfig.getYhShopLoginUrl());
-	}
-
-	/**
-	 * 店铺用户是否已授权
-	 */
-	@GetMapping("/get/userInfo")
-	public Result<String> getCpsUserInfo(String authState) {
-		String key = RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getNameFormat(authState);
-		Object o = redisService.get(key);
-		if (o == null) return GatewayResponse.SUCCESS.newBuilder().toResult();
-		redisService.del(key);
-		return GatewayResponse.SUCCESS.newBuilder().toResult(o.toString());
-	}
-
-
 	/**
 	/**
 	 * 店铺分销平台数据详情
 	 * 店铺分销平台数据详情
 	 */
 	 */

+ 91 - 0
netflix-web/src/main/java/com/cyksj/web/controller/cps/shop/YhShopGoodsController.java

@@ -0,0 +1,91 @@
+package com.cyksj.web.controller.cps.shop;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.model.entity.YhShopGoodsSku;
+import com.cyksj.model.views.YhShopGoodsRateView;
+import com.cyksj.model.views.YhShopGoodsView;
+import com.cyksj.service.shop.YhShopGoodsSkuService;
+import com.cyksj.web.util.StpUserUtil;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
+import com.ejlchina.searcher.util.MapUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/*
+ *项目名: yhlxj
+ *文件名: ShopController
+ *创建者: JavaZou
+ *创建时间:2023/9/20 14:12
+ */
+@Slf4j
+@RestController
+@RequestMapping("/yhShop/manage/goods")
+@RequiredArgsConstructor
+public class YhShopGoodsController {
+	private final BeanSearcher beanSearcher;
+
+	private final YhShopGoodsSkuService yhShopGoodsSkuService;
+	/**
+	 * 新增平台
+	 */
+	@PostMapping("/post")
+	public Result<Void> saveGoods(@RequestBody List<Long> goodsIds){
+		long userId = StpUserUtil.getLoginIdAsLong();
+		yhShopGoodsSkuService.saveGoods(goodsIds, userId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 设置店铺平台价格
+	 */
+	@PutMapping("/put")
+	public Result<Void> updShopGoodsRate(@RequestBody List<YhShopGoodsSku> goodsSkus){
+		goodsSkus.forEach(sku -> {
+			YhShopGoodsRateView.YhShopGoodsSkuRateView yhShopGoodsSkuRateView = beanSearcher.searchFirst(YhShopGoodsRateView.YhShopGoodsSkuRateView.class, MapUtils.builder().field(YhShopGoodsRateView.YhShopGoodsSkuRateView::getSkuId,sku.getSkuId()).build());
+			if (sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMaxPrice()) > 0 || sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMinPrice()) < 0){
+				throw BusinessRuntimeException.getInstance("价格不能超出区间范围");
+			}
+		});
+		yhShopGoodsSkuService.saveOrUpdateBatch(goodsSkus);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 上下架
+	 */
+	@PutMapping("/put/goodsStatus/{goodsId}")
+	public Result<Void> updGoodsStatus(@PathVariable Long goodsId, Boolean status){
+		long userId = StpUserUtil.getLoginIdAsLong();
+		yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getStatus, status));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+
+	/**
+	 * 删除平台
+	 */
+	@PutMapping("/del/{goodsId}")
+	public Result<Void> updGoodsStatus(@PathVariable Long goodsId){
+		long userId = StpUserUtil.getLoginIdAsLong();
+		yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getDeleted, false));
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 查询平台
+	 */
+	@GetMapping("/get")
+	public Result<SearchResult<YhShopGoodsView>> goodsList(){
+		long userId = StpUserUtil.getLoginIdAsLong();
+		SearchResult<YhShopGoodsView> search = beanSearcher.search(YhShopGoodsView.class, MapUtils.builder().field(YhShopGoodsView::getUserId, userId).build());
+		search.getDataList().forEach(e -> e.setList(beanSearcher.searchList(YhShopGoodsView.YhShopGoodsSkuView.class,MapUtils.builder().field(YhShopGoodsView.YhShopGoodsSkuView::getGoodsId,e.getId()).build())));
+		return GatewayResponse.SUCCESS.newBuilder().toResult(search);
+	}
+}

+ 172 - 0
netflix-web/src/main/java/com/cyksj/web/controller/cps/shop/YhShopLoginController.java

@@ -0,0 +1,172 @@
+package com.cyksj.web.controller.cps.shop;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.annotation.NoSubmit;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import com.cyksj.common.snowflake.Sequence;
+import com.cyksj.common.util.Codec;
+import com.cyksj.common.util.Jsons;
+import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
+import com.cyksj.dto.Result;
+import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.UserMapper;
+import com.cyksj.mapper.shop.YhShopMapper;
+import com.cyksj.model.dto.AuthRedirect;
+import com.cyksj.model.dto.AuthToken;
+import com.cyksj.model.dto.CpsAuthDto;
+import com.cyksj.model.dto.GzhOAuth2UserInfo;
+import com.cyksj.model.entity.User;
+import com.cyksj.model.manage.entity.YhShop;
+import com.cyksj.model.request.LoginReq;
+import com.cyksj.redis.RedisService;
+import com.cyksj.service.authorization.AuthorizationService;
+import com.cyksj.service.cps.shop.YhShopManageService;
+import com.cyksj.service.wechat.WeChatService;
+import com.cyksj.web.util.StpUserUtil;
+import com.cyksj.web.util.StpYhShopManageUser;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Optional;
+
+/*
+ *项目名: yhlxj
+ *文件名: YhShopController
+ *创建者: JavaZou
+ *创建时间:2023/9/19 17:34
+ */
+@RestController
+@RequestMapping("/yhShop/manage")
+@RequiredArgsConstructor
+public class YhShopLoginController {
+	private final YhShopManageService yhShopManageService;
+
+	private final RedisService redisService;
+
+	private final static Sequence SEQUENCE = new Sequence(0);
+
+	private final WxOpenPlatYHLXLoginConfig wxOpenPlatYHLXLoginConfig;
+
+	private final AuthorizationService authorizationService;
+
+	private final WeChatService weChatService;
+
+	private final UserMapper userMapper;
+
+	private final YhShopMapper yhShopMapper;
+
+	/**
+	 * 获取登录验证码
+	 */
+	@GetMapping("/get/LoginCode")
+	@NoSubmit
+	public Result getLoginCode(@RequestParam(defaultValue = "1") Integer type, String login, Integer cid) {
+		yhShopManageService.getLoginCode(type, login, cid);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 跳转店铺后台 是否是店铺主
+	 */
+	@GetMapping("/redirect")
+	public void yhShopManageRedirect(String redirectUrl, HttpServletResponse response) throws IOException {
+		//银河官网token值
+		long userId = StpUserUtil.getLoginIdAsLong();
+		yhShopManageService.yhShopManageRedirect(userId);
+		//校验通过重定向
+		StpYhShopManageUser.login(userId);
+		response.sendRedirect(redirectUrl.contains("?") ? redirectUrl + "&t=" + StpYhShopManageUser.getTokenValue() : redirectUrl + "?t=" + StpYhShopManageUser.getTokenValue());
+	}
+
+
+	/**
+	 * 手机号、邮箱登录
+	 */
+	@PostMapping("/login")
+	public Result login(@RequestBody LoginReq loginReq) {
+		User user = yhShopManageService.login(loginReq.getType(), loginReq.getLogin(), loginReq.getCode());
+		StpYhShopManageUser.login(user.getId());
+		String yhShopToken = StpYhShopManageUser.getTokenValue();
+		JSONObject re = new JSONObject();
+		re.putOpt("satoken-yhShop", yhShopToken);
+		re.putOpt("img", user.getHeadimgurl());
+		re.putOpt("nickname", user.getNickname());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
+	}
+
+	/**
+	 * 小店后台微信授权登录
+	 */
+	@GetMapping("/wx/authLogin")
+	public Result<CpsAuthDto> wxAuthorize() throws Exception {
+		Object authUrlObj = redisService.get(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("yhShop", wxOpenPlatYHLXLoginConfig.getAppId()));
+		if (authUrlObj != null) {
+			CpsAuthDto cpsAuthDto = Jsons.parseObject(authUrlObj.toString(), CpsAuthDto.class);
+			return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
+		}
+		CpsAuthDto cpsAuthDto = new CpsAuthDto();
+		Long mappingId = SEQUENCE.nextId();
+		String authState = mappingId.toString();
+		redisService.set(authState, authState, 60 * 60 * 24L);
+		AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
+		String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
+		String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getYhShopRedirectUri());
+		cpsAuthDto.setAuthUrl(wxAuthUrl);
+		cpsAuthDto.setAuthState(authState);
+		redisService.set(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("yhShop", wxOpenPlatYHLXLoginConfig.getAppId()), Jsons.toJson(cpsAuthDto), RedisService.key.WX_LOGIN_AUTH_URI.getTimeout());
+		return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
+	}
+
+	/**
+	 * 网页微信授权后跳转
+	 */
+	@GetMapping("/wx/authLogin/baseRedirect")
+	public void wxAuthLoginRedirect(String code, String state, HttpServletResponse response) throws Exception {
+		if (StrUtil.isEmpty(state)) throw BusinessRuntimeException.getInstance("授权错误,请重新授权");
+		String json = Codec.DoBase64.custom().setData(state).decodeAsText();
+		AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
+		AuthToken token = weChatService.getAuthToken(code, wxOpenPlatYHLXLoginConfig.getAppId());
+		GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
+		String unionId = userinfo.getUnionid();
+		String openId = userinfo.getOpenid();
+		User user = Optional.ofNullable(
+						userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getUnionid, unionId)
+								.orderByAsc(User::getId)
+								.last("limit 1")))
+				.orElseGet(() -> userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getOpenId, openId)
+						.orderByAsc(User::getId)
+						.last("limit 1")));
+		if (user == null) throw BusinessRuntimeException.getInstance("用户信息不存在");
+		YhShop yhShop = yhShopMapper.selectOne(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getVerifyStatus, YhShop.Status.success)
+				.eq(YhShop::getUserId, user.getId()).last("limit 1"));
+		if (yhShop == null) {
+			throw BusinessRuntimeException.getInstance("您不是银河小店店铺主");
+		}
+		JSONObject res = new JSONObject();
+		StpYhShopManageUser.login(user.getId());
+		String cpsToken = StpYhShopManageUser.getTokenValue();
+		res.putOpt("satoken-yhShop", cpsToken);
+		res.putOpt("img", user.getHeadimgurl());
+		res.putOpt("nickname", user.getNickname());
+		redisService.set(RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getNameFormat(re.getMappingId()), res.toString(), RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getTimeout());
+		response.sendRedirect(wxOpenPlatYHLXLoginConfig.getYhShopLoginUrl());
+	}
+
+	/**
+	 * 店铺用户是否已授权
+	 */
+	@GetMapping("/get/userInfo")
+	public Result<String> getCpsUserInfo(String authState) {
+		String key = RedisService.key.YH_SHOP_AUTH_SUCCESS_KEY.getNameFormat(authState);
+		Object o = redisService.get(key);
+		if (o == null) return GatewayResponse.SUCCESS.newBuilder().toResult();
+		redisService.del(key);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(o.toString());
+	}
+}

+ 14 - 70
netflix-web/src/main/java/com/cyksj/web/controller/shop/ShopController.java

@@ -1,22 +1,14 @@
 package com.cyksj.web.controller.shop;
 package com.cyksj.web.controller.shop;
 
 
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.dto.Result;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.enums.GatewayResponse;
-import com.cyksj.model.entity.YhShopGoodsSku;
-import com.cyksj.model.views.YhShopGoodsRateView;
-import com.cyksj.model.views.YhShopGoodsView;
-import com.cyksj.service.shop.YhShopGoodsSkuService;
-import com.cyksj.web.util.StpUserUtil;
-import com.ejlchina.searcher.BeanSearcher;
-import com.ejlchina.searcher.SearchResult;
-import com.ejlchina.searcher.util.MapUtils;
+import com.cyksj.model.dto.YhShopInfo;
+import com.cyksj.service.shop.YhShopFrontService;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 
 /**
 /**
  * @author zwhui
  * @author zwhui
@@ -28,64 +20,16 @@ import java.util.List;
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 public class ShopController {
 public class ShopController {
 
 
-    private final BeanSearcher beanSearcher;
-
-    private final YhShopGoodsSkuService yhShopGoodsSkuService;
-
-    /**
-     * 新增平台
-     */
-    @PostMapping("/post/goods")
-    public Result<Void> saveGoods(@RequestBody List<Long> goodsIds){
-        long userId = StpUserUtil.getLoginIdAsLong();
-        yhShopGoodsSkuService.saveGoods(goodsIds, userId);
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
-
-    /**
-     * 设置店铺平台价格
-     */
-    @PutMapping("/put/goods")
-    public Result<Void> updShopGoodsRate(@RequestBody List<YhShopGoodsSku> goodsSkus){
-        goodsSkus.forEach(sku -> {
-            YhShopGoodsRateView.YhShopGoodsSkuRateView yhShopGoodsSkuRateView = beanSearcher.searchFirst(YhShopGoodsRateView.YhShopGoodsSkuRateView.class, MapUtils.builder().field(YhShopGoodsRateView.YhShopGoodsSkuRateView::getSkuId,sku.getSkuId()).build());
-            if (sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMaxPrice()) > 0 || sku.getPrice().compareTo(yhShopGoodsSkuRateView.getMinPrice()) < 0){
-                throw BusinessRuntimeException.getInstance("价格不能超出区间范围");
-            }
-        });
-        yhShopGoodsSkuService.saveOrUpdateBatch(goodsSkus);
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
-
-    /**
-     * 上下架
-     */
-    @PutMapping("/put/goodsStatus/{goodsId}")
-    public Result<Void> updGoodsStatus(@PathVariable Long goodsId,Boolean status){
-        long userId = StpUserUtil.getLoginIdAsLong();
-        yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getStatus, status));
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
+ private final YhShopFrontService yhShopFrontService;
 
 
 
 
-    /**
-     * 删除平台
-     */
-    @PutMapping("/del/goods/{goodsId}")
-    public Result<Void> updGoodsStatus(@PathVariable Long goodsId){
-        long userId = StpUserUtil.getLoginIdAsLong();
-        yhShopGoodsSkuService.update(Wrappers.lambdaUpdate(YhShopGoodsSku.class).eq(YhShopGoodsSku::getGoodsId, goodsId).eq(YhShopGoodsSku::getUserId, userId).set(YhShopGoodsSku::getDeleted, false));
-        return GatewayResponse.SUCCESS.newBuilder().toResult();
-    }
+ /**
+  * 店铺个人信息
+  */
+ @GetMapping("/get/info")
+ public Result<YhShopInfo> getYhShopInfo(String customId) {
+  YhShopInfo yhShopInfo = yhShopFrontService.getYhShopInfo(customId);
+  return GatewayResponse.SUCCESS.newBuilder().toResult(yhShopInfo);
+ }
 
 
-    /**
-     * 查询平台
-     */
-    @GetMapping("/get/goods")
-    public Result<SearchResult<YhShopGoodsView>> goodsList(){
-        long userId = StpUserUtil.getLoginIdAsLong();
-        SearchResult<YhShopGoodsView> search = beanSearcher.search(YhShopGoodsView.class, MapUtils.builder().field(YhShopGoodsView::getUserId, userId).build());
-        search.getDataList().forEach(e -> e.setList(beanSearcher.searchList(YhShopGoodsView.YhShopGoodsSkuView.class,MapUtils.builder().field(YhShopGoodsView.YhShopGoodsSkuView::getGoodsId,e.getId()).build())));
-        return GatewayResponse.SUCCESS.newBuilder().toResult(search);
-    }
 }
 }