登陆授权修改,数据配置用常量替代,增加获取距离工具类等
This commit is contained in:
@ -14,5 +14,5 @@ CREATE TABLE `yx_system_store_staff` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='门店店员表';
|
||||
|
||||
|
||||
ALTER TABLE `yxshop`.`yx_user_recharge`
|
||||
MODIFY COLUMN `give_price` decimal(8, 2) NULL DEFAULT 0.00 COMMENT '购买赠送金额' AFTER `price`
|
||||
ALTER TABLE `yshop`.`yx_user_recharge`
|
||||
ADD COLUMN `give_price` decimal(8, 2) NULL DEFAULT 0 COMMENT '赠送金额' AFTER `price`
|
@ -14,6 +14,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.annotation.AnonymousAccess;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.web.dto.SeckillConfigDTO;
|
||||
import co.yixiang.modules.activity.web.dto.SeckillTimeDTO;
|
||||
@ -100,7 +101,8 @@ public class StoreSeckillController extends BaseController {
|
||||
//获取秒杀配置
|
||||
AtomicInteger seckillTimeIndex = new AtomicInteger();
|
||||
SeckillConfigDTO seckillConfigDTO = new SeckillConfigDTO();
|
||||
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.list(new QueryWrapper<YxSystemGroupData>().eq("group_name", "routine_seckill_time"));
|
||||
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.list(new QueryWrapper<YxSystemGroupData>()
|
||||
.eq("group_name", ShopConstants.YSHOP_SECKILL_TIME));
|
||||
List<SeckillTimeDTO> list = new ArrayList<>();
|
||||
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
|
||||
yxSystemGroupDataList.forEach(i -> {
|
||||
|
@ -151,6 +151,13 @@ public class AuthController {
|
||||
@RequestParam(value = "spread") String spread,
|
||||
HttpServletRequest request) {
|
||||
|
||||
/**
|
||||
* 公众号与小程序打通说明:
|
||||
* 1、打通方式以UnionId方式,需要去注册微信开放平台
|
||||
* 2、目前登陆授权打通方式适用于新项目(也就是你yx_user、yx_wechat_user都是空的)
|
||||
* 3、如果你以前已经有数据请自行处理
|
||||
*/
|
||||
|
||||
try {
|
||||
WxMpService wxService = WxMpConfiguration.getWxMpService();
|
||||
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxService.oauth2getAccessToken(code);
|
||||
@ -183,6 +190,7 @@ public class AuthController {
|
||||
user.setPwd(passwordEncoder.encode(ShopConstants.YSHOP_DEFAULT_PWD));
|
||||
user.setPhone("");
|
||||
user.setUserType(AppFromEnum.WECHAT.getValue());
|
||||
user.setLoginType(AppFromEnum.WECHAT.getValue());
|
||||
user.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
user.setLastTime(OrderUtil.getSecondTimestampTwo());
|
||||
user.setNickname(nickname);
|
||||
@ -224,9 +232,15 @@ public class AuthController {
|
||||
|
||||
wechatUserService.save(yxWechatUser);
|
||||
|
||||
//jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wxMpUser.getOpenId());
|
||||
}else{
|
||||
username = yxUser.getUsername();
|
||||
if(StrUtil.isNotBlank(wxMpUser.getOpenId()) && StrUtil.isNotBlank(wxMpUser.getUnionId())){
|
||||
YxWechatUser wechatUser = new YxWechatUser();
|
||||
wechatUser.setUid(yxUser.getUid());
|
||||
wechatUser.setUnionid(wxMpUser.getUnionId());
|
||||
|
||||
wechatUserService.updateById(wechatUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -279,6 +293,12 @@ public class AuthController {
|
||||
@ApiOperation(value = "小程序登陆", notes = "小程序登陆")
|
||||
public ApiResult<Object> login(@Validated @RequestBody LoginParam loginParam,
|
||||
HttpServletRequest request) {
|
||||
/**
|
||||
* 公众号与小程序打通说明:
|
||||
* 1、打通方式以UnionId方式,需要去注册微信开放平台
|
||||
* 2、目前登陆授权打通方式适用于新项目(也就是你yx_user、yx_wechat_user都是空的)
|
||||
* 3、如果你以前已经有数据请自行处理
|
||||
*/
|
||||
String code = loginParam.getCode();
|
||||
String encryptedData = loginParam.getEncryptedData();
|
||||
String iv = loginParam.getIv();
|
||||
@ -304,10 +324,6 @@ public class AuthController {
|
||||
|
||||
YxUser yxUser = userService.findByName(openid);
|
||||
String username = "";
|
||||
// JwtUser jwtUser = null;
|
||||
// if (ObjectUtil.isNotNull(yxUser)) {
|
||||
// jwtUser = (JwtUser) userDetailsService.loadUserByUsername(openid);
|
||||
// } else
|
||||
if(ObjectUtil.isNull(yxUser)){
|
||||
|
||||
WxMaUserInfo wxMpUser = wxMaService.getUserService()
|
||||
@ -362,12 +378,18 @@ public class AuthController {
|
||||
|
||||
wechatUserService.save(yxWechatUser);
|
||||
|
||||
//jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wxMpUser.getOpenId());
|
||||
}else{
|
||||
username = yxUser.getUsername();
|
||||
if(StrUtil.isNotBlank(session.getOpenid()) && StrUtil.isNotBlank(session.getUnionid())){
|
||||
YxWechatUser wechatUser = new YxWechatUser();
|
||||
wechatUser.setUid(yxUser.getUid());
|
||||
wechatUser.setUnionid(session.getUnionid());
|
||||
|
||||
wechatUserService.updateById(wechatUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
UsernamePasswordAuthenticationToken authenticationToken =
|
||||
new UsernamePasswordAuthenticationToken(username,
|
||||
ShopConstants.YSHOP_DEFAULT_PWD);
|
||||
|
@ -157,7 +157,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMap
|
||||
|
||||
//门店
|
||||
productDTO.setSystemStore(systemStoreService.getStoreInfo());
|
||||
productDTO.setMapKey(RedisUtil.get("store_self_mention"));
|
||||
productDTO.setMapKey(RedisUtil.get("tengxun_map_key"));
|
||||
|
||||
return productDTO;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import co.yixiang.enums.CommonEnum;
|
||||
import co.yixiang.modules.shop.entity.YxSystemStore;
|
||||
import co.yixiang.modules.shop.mapper.YxSystemStoreMapper;
|
||||
import co.yixiang.modules.shop.mapping.SystemStoreMap;
|
||||
@ -43,8 +44,13 @@ public class YxSystemStoreServiceImpl extends BaseServiceImpl<YxSystemStoreMappe
|
||||
@Override
|
||||
public YxSystemStoreQueryVo getStoreInfo() {
|
||||
YxSystemStore systemStore = new YxSystemStore();
|
||||
systemStore.setIsDel(0);
|
||||
YxSystemStore yxSystemStore = yxSystemStoreMapper.selectOne(Wrappers.query(systemStore));
|
||||
systemStore.setIsDel(CommonEnum.DEL_STATUS_0.getValue());
|
||||
systemStore.setIsShow(CommonEnum.SHOW_STATUS_1.getValue());
|
||||
YxSystemStore yxSystemStore = yxSystemStoreMapper.selectOne(
|
||||
Wrappers
|
||||
.query(systemStore)
|
||||
.orderByDesc("id")
|
||||
.last("limit 1"));
|
||||
if(yxSystemStore == null) return null;
|
||||
String mention = RedisUtil.get("store_self_mention");
|
||||
if(mention == null || Integer.valueOf(mention) == 2) return null;
|
||||
|
@ -57,11 +57,11 @@ public class IndexController {
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
//banner
|
||||
map.put("banner",systemGroupDataService.getDatas("routine_home_banner"));
|
||||
map.put("banner",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_BANNER));
|
||||
//首页按钮
|
||||
map.put("menus",systemGroupDataService.getDatas("routine_home_menus"));
|
||||
map.put("menus",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_MENUS));
|
||||
//首页活动区域图片
|
||||
map.put("activity",systemGroupDataService.getDatas("routine_home_activity"));
|
||||
map.put("activity",new String[]{});
|
||||
|
||||
|
||||
//精品推荐
|
||||
@ -74,7 +74,7 @@ public class IndexController {
|
||||
map.put("likeInfo",storeProductService.getList(1,3,4));
|
||||
|
||||
//滚动
|
||||
map.put("roll",systemGroupDataService.getDatas("routine_home_roll_news"));
|
||||
map.put("roll",systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS));
|
||||
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class IndexController {
|
||||
@GetMapping("/search/keyword")
|
||||
@ApiOperation(value = "热门搜索关键字获取",notes = "热门搜索关键字获取")
|
||||
public ApiResult<List<String>> search(){
|
||||
List<Map<String,Object>> list = systemGroupDataService.getDatas("routine_hot_search");
|
||||
List<Map<String,Object>> list = systemGroupDataService.getDatas(ShopConstants.YSHOP_HOT_SEARCH);
|
||||
List<String> stringList = new ArrayList<>();
|
||||
for (Map<String,Object> map : list) {
|
||||
stringList.add(map.get("title").toString());
|
||||
|
@ -13,6 +13,7 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
@ -67,15 +68,13 @@ public class YxUserSignServiceImpl extends BaseServiceImpl<YxUserSignMapper, YxU
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户签到
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public int sign(int uid) {
|
||||
List<Map<String,Object>> list = systemGroupDataService.getDatas("sign_day_num");
|
||||
List<Map<String,Object>> list = systemGroupDataService.getDatas(ShopConstants.YSHOP_SIGN_DAY_NUM);
|
||||
if(ObjectUtil.isNull(list)) throw new ErrorRequestException("请先配置签到天数");
|
||||
|
||||
YxUserQueryVo userQueryVo = yxUserService.getYxUserById(uid);
|
||||
|
@ -12,6 +12,7 @@ import co.yixiang.annotation.AnonymousAccess;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductRelationService;
|
||||
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
|
||||
@ -85,7 +86,7 @@ public class UserController extends BaseController {
|
||||
@ApiOperation(value = "获取个人中心菜单",notes = "获取个人中心菜单")
|
||||
public ApiResult<Map<String,Object>> userMenu(){
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("routine_my_menus",systemGroupDataService.getDatas("routine_my_menus"));
|
||||
map.put("routine_my_menus",systemGroupDataService.getDatas(ShopConstants.YSHOP_MY_MENUES));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
@ -185,7 +186,7 @@ public class UserController extends BaseController {
|
||||
@GetMapping("/sign/config")
|
||||
@ApiOperation(value = "签到配置",notes = "签到配置")
|
||||
public ApiResult<Object> signConfig(){
|
||||
return ApiResult.ok(systemGroupDataService.getDatas("sign_day_num"));
|
||||
return ApiResult.ok(systemGroupDataService.getDatas(ShopConstants.YSHOP_SIGN_DAY_NUM));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.enums.BillDetailEnum;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
@ -72,7 +73,7 @@ public class UserRechargeController extends BaseController {
|
||||
@ApiOperation(value = "充值方案",notes = "充值方案",response = ApiResult.class)
|
||||
public ApiResult<Object> getWays(){
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("recharge_price_ways",systemGroupDataService.getDatas("recharge_price_ways"));
|
||||
map.put("recharge_price_ways",systemGroupDataService.getDatas(ShopConstants.YSHOP_RECHARGE_PRICE_WAYS));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ jwt:
|
||||
# 必须使用最少88位的Base64对该令牌进行编码
|
||||
base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
|
||||
# 令牌过期时间 此处单位/毫秒 ,默认2小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
|
||||
token-validity-in-seconds: 7200000
|
||||
token-validity-in-seconds: 72000000
|
||||
# 在线用户key
|
||||
online-key: m-online-token
|
||||
|
||||
@ -81,7 +81,7 @@ swagger:
|
||||
enabled: true
|
||||
title: yshop商城移动端API
|
||||
serverUrl: http://localhost:8009
|
||||
version: 2.0
|
||||
version: 2.1
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
|
@ -49,7 +49,7 @@ public interface ShopConstants {
|
||||
/**
|
||||
* 商城默认注册图片
|
||||
*/
|
||||
String YSHOP_DEFAULT_AVATAR = "https://image.dayouqiantu.cn/5dc2c7f3a104c.png";
|
||||
String YSHOP_DEFAULT_AVATAR = "https://image.dayouqiantu.cn/5e79f6cfd33b6.png";
|
||||
|
||||
/**
|
||||
* 腾讯地图地址解析
|
||||
@ -61,6 +61,39 @@ public interface ShopConstants {
|
||||
*/
|
||||
String YSHOP_REDIS_INDEX_KEY = "yshop:index_data";
|
||||
|
||||
/**
|
||||
* 充值方案
|
||||
*/
|
||||
String YSHOP_RECHARGE_PRICE_WAYS = "yshop_recharge_price_ways";
|
||||
/**
|
||||
* 首页banner
|
||||
*/
|
||||
String YSHOP_HOME_BANNER = "yshop_home_banner";
|
||||
/**
|
||||
* 首页菜单
|
||||
*/
|
||||
String YSHOP_HOME_MENUS = "yshop_home_menus";
|
||||
/**
|
||||
* 首页滚动新闻
|
||||
*/
|
||||
String YSHOP_HOME_ROLL_NEWS = "yshop_home_roll_news";
|
||||
/**
|
||||
* 热门搜索
|
||||
*/
|
||||
String YSHOP_HOT_SEARCH = "yshop_hot_search";
|
||||
/**
|
||||
* 个人中心菜单
|
||||
*/
|
||||
String YSHOP_MY_MENUES = "yshop_my_menus";
|
||||
/**
|
||||
* 秒杀时间段
|
||||
*/
|
||||
String YSHOP_SECKILL_TIME = "yshop_seckill_time";
|
||||
/**
|
||||
* 签到天数
|
||||
*/
|
||||
String YSHOP_SIGN_DAY_NUM = "yshop_sign_day_num";
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 应用来源相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 账单明细相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 账单相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
25
yshop-common/src/main/java/co/yixiang/enums/CommonEnum.java
Normal file
25
yshop-common/src/main/java/co/yixiang/enums/CommonEnum.java
Normal file
@ -0,0 +1,25 @@
|
||||
package co.yixiang.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 通用枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CommonEnum {
|
||||
|
||||
DEL_STATUS_0(0,"未删除"),
|
||||
DEL_STATUS_1(1,"已删除"),
|
||||
|
||||
SHOW_STATUS_0(0,"未显示"),
|
||||
SHOW_STATUS_1(1,"显示");
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import lombok.Getter;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 订单相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 支付相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 产品相关枚举
|
||||
*/
|
||||
@Getter
|
||||
|
@ -0,0 +1,37 @@
|
||||
package co.yixiang.utils;
|
||||
|
||||
/**
|
||||
* @ClassName LocationUtils
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2020/3/24
|
||||
**/
|
||||
public class LocationUtils {
|
||||
private static double EARTH_RADIUS = 6378.137;
|
||||
|
||||
private static double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过经纬度获取距离(单位:米)
|
||||
* @param lat1
|
||||
* @param lng1
|
||||
* @param lat2
|
||||
* @param lng2
|
||||
* @return
|
||||
*/
|
||||
public static double getDistance(double lat1, double lng1, double lat2,
|
||||
double lng2) {
|
||||
double radLat1 = rad(lat1);
|
||||
double radLat2 = rad(lat2);
|
||||
double a = radLat1 - radLat2;
|
||||
double b = rad(lng1) - rad(lng2);
|
||||
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
|
||||
+ Math.cos(radLat1) * Math.cos(radLat2)
|
||||
* Math.pow(Math.sin(b / 2), 2)));
|
||||
s = s * EARTH_RADIUS;
|
||||
s = Math.round(s * 10000d) / 10000d;
|
||||
s = s*1000;
|
||||
return s;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package co.yixiang.modules.shop.rest;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.shop.domain.YxSystemStoreStaff;
|
||||
import co.yixiang.modules.shop.service.YxSystemStoreStaffService;
|
||||
import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria;
|
||||
@ -69,6 +71,7 @@ public class SystemStoreStaffController {
|
||||
@PreAuthorize("@el.check('yxSystemStoreStaff:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Integer[] ids) {
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
yxSystemStoreStaffService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ swagger:
|
||||
enabled: true
|
||||
title: yshop商城管理后台API
|
||||
serverUrl: http://localhost:8000
|
||||
version: 2.0
|
||||
version: 2.1
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
|
Reference in New Issue
Block a user