diff --git a/pom.xml b/pom.xml index 14c2a87..c8f5a57 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,11 @@ org.projectlombok lombok + + com.aliyun + dysmsapi20170525 + 2.0.21 + org.apache.commons diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java new file mode 100644 index 0000000..8960af6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java @@ -0,0 +1,130 @@ +package com.chaozhanggui.system.cashierservice.auth; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.redis.RedisCst; +import com.chaozhanggui.system.cashierservice.redis.RedisUtil; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.TokenUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +/** + * 登录的拦截器 + * 目前仅限APP使用 + */ +@Slf4j +@Component +@WebFilter(filterName = "LoginFilter", urlPatterns = "/*") +public class LoginFilter implements Filter { + + /** + * 不登录就可以访问的接口 + */ + private static final List NOT_LOGIN_URL = Arrays.asList( + // 忽略静态资源 + "css/**", + "js/**", + "cashierService/phoneValidateCode",//验证码 + "cashierService/location/**",// + "cashierService/home/homePageUp",//首页上半 + "cashierService/home",//首页 + "cashierService/login/**"//登录部分接口不校验 + ); + + @Autowired + private RedisUtil redisUtil; + + /** + * 登陆过滤器具体实现 + */ + @Override + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) req; + HttpServletResponse response = (HttpServletResponse) resp; + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json; charset=utf-8"); + // OPTIONS请求类型不做校验 + if (request.getMethod().equalsIgnoreCase("OPTIONS")) { + chain.doFilter(req, resp); + return; + } + // 获取请求地址 + String url = request.getRequestURI(); + // 不需要授权的接口直接访问的地址 + if (containsUrl(NOT_LOGIN_URL, url)) { + chain.doFilter(req, resp); + return; + } + String environment = request.getHeader("environment"); + //token校验目前只对app生效 + if (StringUtils.isNotBlank(environment) || !environment.equals("app")) { + chain.doFilter(req, resp); + return; + } + // 判断用户TOKEN是否存在 + String token = request.getHeader("token"); + if (StringUtils.isBlank(token)) { + Result result = new Result(CodeEnum.TOKEN_EXEIST); + String jsonString = JSONObject.toJSONString(result); + JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class); + response.getWriter().print(jsonObject); + response.getWriter().flush();//流里边的缓存刷出 + return; + } + //获取当前登录人的用户id + String loginName = TokenUtil.parseParamFromToken(token, "userId").toString(); + //获取redis中的token + String message = redisUtil.getMessage(RedisCst.ONLINE_APP_USER.concat(loginName)); + if (StringUtils.isBlank(message)) { + Result result = new Result(CodeEnum.TOKEN_EXPIRED); + String jsonString = JSONObject.toJSONString(result); + JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class); + response.getWriter().print(jsonObject); + response.getWriter().flush();//流里边的缓存刷出 + return; + } + String redisToken = JSON.parseObject(message).getString("token"); + if (!token.equals(redisToken)) { + Result result = new Result(CodeEnum.TOKEN_EXPIRED); + String jsonString = JSONObject.toJSONString(result); + JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class); + response.getWriter().print(jsonObject); + response.getWriter().flush();//流里边的缓存刷出 + return; + } + chain.doFilter(req, resp); + } + + /** + * 判断url请求是否配置在urls列表中 + */ + private boolean containsUrl(List urls, String url) { + if (urls == null || urls.isEmpty()) { + return false; + } + for (String s : urls) { + if (s.endsWith("**")) { + if (url.startsWith("/" + s.substring(0, s.length() - 2))) { + return true; + } + } else { + if (url.equals("/" + s)) { + return true; + } + } + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/AppApiMethodAspect.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/AppApiMethodAspect.java new file mode 100644 index 0000000..5a08f2f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/AppApiMethodAspect.java @@ -0,0 +1,61 @@ +package com.chaozhanggui.system.cashierservice.config; + +import com.chaozhanggui.system.cashierservice.redis.RedisCst; +import com.chaozhanggui.system.cashierservice.redis.RedisUtil; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; + +/** + * 方法调用统一切面处理 + */ +@Aspect +@Component +@Slf4j +public class AppApiMethodAspect { + + @Autowired + RedisUtil redisUtil; + + @Pointcut("execution(public * (" + + "com.chaozhanggui.system.cashierservice.controller.* " + + ").*(..))") + public void pkg() { + } + + @Around("pkg()") + public Object around(ProceedingJoinPoint pjp) throws Throwable { + HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + HttpServletRequest req = request; + //version:版本号 + //type: ios; android; + //environment:app;wx + String environment = req.getHeader("environment"); + if (StringUtils.isNotBlank(environment) && environment.equals("app")) { + String type = req.getHeader("type"); + String version = req.getHeader("version"); + //LDBL_APP_VERSION:ios:version 存在即需要强制更新 + String message = redisUtil.getMessage(RedisCst.LDBL_APP_VERSION + type + ":" + version); + if (StringUtils.isNotBlank(message)) { + return Result.success(CodeEnum.UPGRADE_REQUIRED, message); + } + } + + // 执行被拦截的方法 + Object result = pjp.proceed(); + return result; + + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java new file mode 100644 index 0000000..31e33e6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/config/CorsFilter.java @@ -0,0 +1,35 @@ +package com.chaozhanggui.system.cashierservice.config; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 跨域过滤器 + */ +@Slf4j +@Component +@Order(1) +@WebFilter(filterName = "CorsFilter", urlPatterns = "/*") +public class CorsFilter implements Filter { + + @Override + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) + throws IOException, ServletException { + HttpServletResponse response = (HttpServletResponse) resp; + HttpServletRequest reqs = (HttpServletRequest) req; + String curOrigin = reqs.getHeader("Origin"); + response.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin); + response.setHeader("Access-Control-Allow-Methods", "*"); + response.setHeader("Access-Control-Max-Age", "3600"); + response.setHeader("Access-Control-Allow-Headers", "x-requested-with,signature"); + response.setHeader("Access-Control-Allow-Credentials", "true"); + chain.doFilter(req, resp); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java new file mode 100644 index 0000000..31409a7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/HomeController.java @@ -0,0 +1,31 @@ +package com.chaozhanggui.system.cashierservice.controller; + + +import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto; +import com.chaozhanggui.system.cashierservice.service.HomePageService; +import com.chaozhanggui.system.cashierservice.sign.Result; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * @author lyf + */ +@RestController +@RequestMapping("/home") +@RequiredArgsConstructor +public class HomeController { + + @Resource + private HomePageService homePageService; + + @PostMapping + public Result homePage(@RequestBody HomeDto homeDto){ + return homePageService.homePage(homeDto); + } + @PostMapping("/homePageUp") + public Result homePageUp(@RequestHeader("environment") String environment){ + return homePageService.homePageUp(environment); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LocationController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LocationController.java new file mode 100644 index 0000000..0f4be0a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LocationController.java @@ -0,0 +1,37 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.LocationUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +@CrossOrigin(origins = "*") +@RestController +@Slf4j +@RequestMapping("/location") +public class LocationController { + + + /** + * 行政区域查询 + * + * @param keywords citycode市、adcode区 + * @return + */ + @GetMapping("/district") + public Result createOrder(String keywords) throws JsonProcessingException { + String district = LocationUtils.district(keywords); + ObjectMapper mapper = new ObjectMapper(); + // 将 JSON 字符串解析为 JsonNode 对象 + JsonNode jsonNode = mapper.readTree(district); + JsonNode districts = jsonNode.get("districts"); + + + return Result.success(CodeEnum.SUCCESS, districts); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java index 4ab596e..a5e2af1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/LoginContoller.java @@ -1,9 +1,5 @@ package com.chaozhanggui.system.cashierservice.controller; - -import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; @@ -12,17 +8,20 @@ import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper; import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount; import com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto; import com.chaozhanggui.system.cashierservice.entity.dto.OnlineUserDto; +import com.chaozhanggui.system.cashierservice.redis.RedisCst; +import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.service.LoginService; import com.chaozhanggui.system.cashierservice.service.OnlineUserService; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.util.IpUtil; -import com.chaozhanggui.system.cashierservice.util.JSONUtil; import com.chaozhanggui.system.cashierservice.util.MD5Utils; import com.chaozhanggui.system.cashierservice.util.StringUtil; +import com.chaozhanggui.system.cashierservice.util.TokenUtil; import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -58,6 +57,8 @@ public class LoginContoller { @Resource TbMerchantAccountMapper merchantAccountMapper; + @Autowired + RedisUtil redisUtil; @RequestMapping("/wx/business/login") @@ -89,11 +90,6 @@ public class LoginContoller { } - - - - - @RequestMapping("/wx/custom/login") public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map map // , @@ -102,23 +98,23 @@ public class LoginContoller { ) { - if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map)||!map.containsKey("code")||ObjectUtil.isEmpty(map.get("code"))) { + if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { Result.fail("code不能为空"); } - String code=map.get("code").toString(); + String code = map.get("code").toString(); - String qrCode=map.get("qrCode"); + String qrCode = map.get("qrCode"); - String rawData=map.get("rawData"); + String rawData = map.get("rawData"); - String signature=map.get("signature"); + String signature = map.get("signature"); - String encryptedData=map.get("encryptedData"); + String encryptedData = map.get("encryptedData"); - String ivStr=map.get("iv"); + String ivStr = map.get("iv"); - String phone=map.get("phone"); + String phone = map.get("phone"); // 用户非敏感信息:rawData // 签名:signature @@ -136,11 +132,11 @@ public class LoginContoller { return Result.fail("签名校验失败"); } - String nickName = rawDataJson.getString( "nickName"); - String avatarUrl = rawDataJson.getString( "avatarUrl"); + String nickName = rawDataJson.getString("nickName"); + String avatarUrl = rawDataJson.getString("avatarUrl"); try { - return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone,qrCode, IpUtil.getIpAddr(request)); + return loginService.wxCustomLogin(openid, avatarUrl, nickName, phone, qrCode, IpUtil.getIpAddr(request)); } catch (Exception e) { e.printStackTrace(); } @@ -151,16 +147,16 @@ public class LoginContoller { @RequestMapping("getPhoneNumber") - public Result getPhoneNumber(@RequestBody Map map){ + public Result getPhoneNumber(@RequestBody Map map) { - if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map)||!map.containsKey("code")||ObjectUtil.isEmpty(map.get("code"))) { + if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) { Result.fail("code不能为空"); } - String code=map.get("code").toString(); + String code = map.get("code").toString(); - String encryptedData=map.get("encryptedData"); + String encryptedData = map.get("encryptedData"); - String ivStr=map.get("iv"); + String ivStr = map.get("iv"); JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete); @@ -168,11 +164,11 @@ public class LoginContoller { String openid = SessionKeyOpenId.getString("openid"); String sessionKey = SessionKeyOpenId.getString("session_key"); - String data= WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); - if(ObjectUtil.isNotEmpty(data)&&JSONObject.parseObject(data).containsKey("phoneNumber")){ + String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr); + if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) { return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber")); } - return Result.fail("获取手机号失败"); + return Result.fail("获取手机号失败"); } @@ -196,34 +192,92 @@ public class LoginContoller { //生成token String token = StringUtil.genRandomNum(6) + StringUtil.getBillno() + StringUtil.genRandomNum(6); //存入redis - OnlineUserDto jwtUserDto = onlineUserService.save(merchantAccount.getName(), merchantAccount.getAccount(), Integer.valueOf(merchantAccount.getShopId()), token,merchantAccount.getStatus()); + OnlineUserDto jwtUserDto = onlineUserService.save(merchantAccount.getName(), merchantAccount.getAccount(), Integer.valueOf(merchantAccount.getShopId()), token, merchantAccount.getStatus()); //组装登录数据 Map authInfo = new HashMap(2) {{ - put("token", token); + put("token", token); put("user", jwtUserDto); }}; - return Result.success(CodeEnum.ENCRYPT,authInfo); + return Result.success(CodeEnum.ENCRYPT, authInfo); } /** * 获取会员码 + * * @param openId * @param token * @param id * @return */ @RequestMapping("createCardNo") - public Result createCardNo(@RequestHeader("openId") String openId,@RequestHeader("token") String token,@RequestHeader("id") String id){ - return loginService.createCardNo(id,openId); + public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id) { + return loginService.createCardNo(id, openId); } @GetMapping("/wx/userInfo") - public Result userInfo(@RequestParam("userId") Integer userId,@RequestParam("shopId") String shopId ){ - return loginService.userInfo(userId,shopId); + public Result userInfo(@RequestParam("userId") Integer userId, @RequestParam("shopId") String shopId) { + return loginService.userInfo(userId, shopId); } + /** + * 用户注册 + * phone 手机号 + * nickName 用户昵称 + * password 密码 + * code 验证码 + * @return + */ +// @PostMapping("register") +// public Result register(@RequestBody TbUserInfo userInfo) { +// boolean tf = loginService.validate(userInfo.getCode(), userInfo.getTelephone()); +// if (tf) { +// return loginService.register(userInfo.getTelephone(), userInfo.getPassword(), userInfo.getNickName()); +// } else { +// return Result.fail("验证码校验失败"); +// } +// } + + + /** + * App登录用户端的请求接口 登录即注册 + * 查看 {@link com.chaozhanggui.system.cashierservice.entity.dto.AuthUserDto} + * username 手机号 + * password 密码登录时使用 + * code 验证码登录时使用 + * @return + */ + @PostMapping("/app/login") + public Result applogin(@RequestBody AuthUserDto authUserDto) { + if (ObjectUtil.isNull(authUserDto.getCode())) { + if(StringUtils.isBlank(authUserDto.getPassword())){ + return Result.fail("请输入密码,或使用验证码登录"); + } + //验证密码 + String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8"); + return loginService.appLogin(authUserDto.getUsername(), mdPasswordString); + } else { + boolean tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername()); + if (tf) { + return loginService.appLogin(authUserDto.getUsername(), null); + } else { + return Result.fail("验证码输入有误"); + } + } + } + + + //退出登录的接口 + @PostMapping("/loginOut") + public Result loginOut(HttpServletRequest request) { + String token = request.getHeader("token"); + //获取当前登录人的账号 + String userId = TokenUtil.parseParamFromToken(token, "userId").toString(); + redisUtil.deleteByKey(RedisCst.ONLINE_APP_USER.concat(userId)); + return Result.success(CodeEnum.SUCCESS); + } + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/PhoneValidateCodeController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PhoneValidateCodeController.java new file mode 100644 index 0000000..b37cd13 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/PhoneValidateCodeController.java @@ -0,0 +1,55 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.RedisUtils; +import com.chaozhanggui.system.cashierservice.util.StringUtil; +import com.chaozhanggui.system.cashierservice.util.ValidateCodeUtil; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.concurrent.TimeUnit; + +/** + * @author lyf + */ +@RestController +@RequestMapping("/phoneValidateCode") +@RequiredArgsConstructor +public class PhoneValidateCodeController { + + private final ValidateCodeUtil validateCodeUtil; + @Resource + private RedisUtils redisUtils; + /** + * 一分钟 + */ + protected static final long ONE_MINUTE = 60; + + /** + * 发送短信验证码 + * @param phone + * @return + */ + @GetMapping + public Result verifyPhoneIsExist(@RequestParam String phone) { + if (StringUtils.isBlank(phone)) { + return Result.fail("手机号不可为空!"); + } + String random = StringUtil.random(6); + validateCodeUtil.requestValidateCodeAli(phone, random); + //存入缓存 + try { + redisUtils.set(phone,random,ONE_MINUTE,TimeUnit.SECONDS); + }catch (Exception e){ + throw new MsgException("验证码发送失败"); + } + return Result.success(CodeEnum.SUCCESS); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java new file mode 100644 index 0000000..fa1ce5b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbPlatformDictMapper.java @@ -0,0 +1,85 @@ +package com.chaozhanggui.system.cashierservice.dao; + + +import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; +import java.util.List; + +/** + * (TbPlatformDict)表数据库访问层 + * + * @author lyf + * @since 2024-04-01 14:38:09 + */ +public interface TbPlatformDictMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbPlatformDict queryById(Integer id); + + /** + * 查询指定行数据 + * + * @param tbPlatformDict 查询条件 + * @param pageable 分页对象 + * @return 对象列表 + */ + List queryAllByLimit(TbPlatformDict tbPlatformDict, @Param("pageable") Pageable pageable); + + List queryAllByType(@Param("type") String type,@Param("environment") String environment); + /** + * 统计总行数 + * + * @param tbPlatformDict 查询条件 + * @return 总行数 + */ + long count(TbPlatformDict tbPlatformDict); + + /** + * 新增数据 + * + * @param tbPlatformDict 实例对象 + * @return 影响行数 + */ + int insert(TbPlatformDict tbPlatformDict); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbPlatformDict 实例对象 + * @return 影响行数 + */ + int update(TbPlatformDict tbPlatformDict); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java index 8409119..aaeecbb 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductSkuMapper.java @@ -31,4 +31,6 @@ public interface TbProductSkuMapper { void updateAddStockById(@Param("skuId") String skuId, @Param("num") Integer num); List selectAll(); + + List selectDownSku(@Param("list") List productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java index 42f5b48..66d027e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopInfoMapper.java @@ -1,9 +1,14 @@ package com.chaozhanggui.system.cashierservice.dao; import com.chaozhanggui.system.cashierservice.entity.TbShopInfo; +import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO; +import com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; +import java.util.List; + @Component @Mapper public interface TbShopInfoMapper { @@ -24,4 +29,8 @@ public interface TbShopInfoMapper { TbShopInfo selectByQrCode(String qrcode); TbShopInfo selectByPhone(String phone); + + List selectShopInfo(@Param("page")Integer page, @Param("size")Integer size); + + List searchUserDutyDetail(@Param("list") List productId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java index ba138d6..841dfa6 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbUserInfoMapper.java @@ -22,5 +22,20 @@ public interface TbUserInfoMapper { TbUserInfo selectByOpenId(String openId); + /** + * 通过手机号查询 + * @param phone + * @param source 公众号 WECHAT 小程序 WECHAT-APP 手机注册 TELEPHONE 移动端 APP + * @return + */ + TbUserInfo selectUserByPhone(String phone,String source); + + /** + * 查询来源为APP 未绑定微信用户的 用户数据 + * @param phone + * @return + */ + TbUserInfo selectByPhone(String phone); + } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java new file mode 100644 index 0000000..55e42cf --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbPlatformDict.java @@ -0,0 +1,194 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; + +/** + * (TbPlatformDict)实体类 + * + * @author lyf + * @since 2024-04-01 14:42:50 + */ +public class TbPlatformDict implements Serializable { + private static final long serialVersionUID = -34581903392247717L; + + private Integer id; + /** + * 描述 同类型下 name唯一 + */ + private String name; + /** + * homeDistrict--金刚区(首页) carousel--轮播图 tag--标签 + */ + private String type; + /** + * 封面图 + */ + private String coverImg; + /** + * 分享图 + */ + private String shareImg; + /** + * 视频URL地址 + */ + private String video; + /** + * 视频封面图 + */ + private String videoCoverImg; + /** + * 相对跳转地址 + */ + private String relUrl; + /** + * 绝对跳转地址 + */ + private String absUrl; + /** + * 创建时间 + */ + private Long createdAt; + /** + * 更新时间 + */ + private Long updatedAt; + /** + * 收银端展示 0:不展示 1:展示 + */ + private Integer isShowCash; + /** + * 小程序端展示 0:不展示 1:展示 + */ + private Integer isShowMall; + /** + * APP端展示 0:不展示 1:展示 + */ + private Integer isShowApp; + /** + * 排序 + */ + private Integer sort; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCoverImg() { + return coverImg; + } + + public void setCoverImg(String coverImg) { + this.coverImg = coverImg; + } + + public String getShareImg() { + return shareImg; + } + + public void setShareImg(String shareImg) { + this.shareImg = shareImg; + } + + public String getVideo() { + return video; + } + + public void setVideo(String video) { + this.video = video; + } + + public String getVideoCoverImg() { + return videoCoverImg; + } + + public void setVideoCoverImg(String videoCoverImg) { + this.videoCoverImg = videoCoverImg; + } + + public String getRelUrl() { + return relUrl; + } + + public void setRelUrl(String relUrl) { + this.relUrl = relUrl; + } + + public String getAbsUrl() { + return absUrl; + } + + public void setAbsUrl(String absUrl) { + this.absUrl = absUrl; + } + + public Long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Long updatedAt) { + this.updatedAt = updatedAt; + } + + public Integer getIsShowCash() { + return isShowCash; + } + + public void setIsShowCash(Integer isShowCash) { + this.isShowCash = isShowCash; + } + + public Integer getIsShowMall() { + return isShowMall; + } + + public void setIsShowMall(Integer isShowMall) { + this.isShowMall = isShowMall; + } + + public Integer getIsShowApp() { + return isShowApp; + } + + public void setIsShowApp(Integer isShowApp) { + this.isShowApp = isShowApp; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java index 63acc56..fab566b 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbUserInfo.java @@ -5,6 +5,7 @@ import java.math.BigDecimal; public class TbUserInfo implements Serializable { private Integer id; + private Integer userId; private BigDecimal amount; @@ -93,6 +94,7 @@ public class TbUserInfo implements Serializable { private Long bindParentAt; private String grandParentId; + private String password; private String avatar = ""; @@ -475,4 +477,20 @@ public class TbUserInfo implements Serializable { public void setGrandParentId(String grandParentId) { this.grandParentId = grandParentId == null ? null : grandParentId.trim(); } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java new file mode 100644 index 0000000..caaf363 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/HomeDto.java @@ -0,0 +1,76 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +/** + * @author 12847 + */ +public class HomeDto { + /** + * 地址 + */ + private String address; + /** + * 品类 + */ + private String type; + + /** + * 1.理我最近 2.销量优先 3.价格优先 + */ + private Integer orderBy; + /** + * 附近1KM 1 0 + */ + private Integer distance; + + private Integer page; + + private Integer size; + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getOrderBy() { + return orderBy; + } + + public void setOrderBy(Integer orderBy) { + this.orderBy = orderBy; + } + + public Integer getDistance() { + return distance; + } + + public void setDistance(Integer distance) { + this.distance = distance; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DistrictVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DistrictVO.java new file mode 100644 index 0000000..aff7937 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/DistrictVO.java @@ -0,0 +1,19 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +/** + * @author lyf + */ +public class DistrictVO { + /** + * 图片 + */ + private String icon; + /** + * 菜单名 + */ + private String name; + /** + * 跳转地址 + */ + private String relUrl; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java new file mode 100644 index 0000000..0d45eac --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeUpVO.java @@ -0,0 +1,22 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; +import lombok.Data; + +import java.util.List; + +/** + * @author lyf + */ +@Data +public class HomeUpVO { + /** + * 轮播图 + */ + List carousel; + /** + * 金刚区 + */ + List district; + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java new file mode 100644 index 0000000..de2d5fb --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/HomeVO.java @@ -0,0 +1,128 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import java.math.BigDecimal; + +/** + * @author lyf + */ +public class HomeVO { + /** + * 店铺名称 + */ + private String shopName; + /** + * 距离 + */ + private String distance; + /** + * 商品名称 + */ + private String productName; + /** + * 商品图片 + */ + private String image; + /** + * 原价 + */ + private BigDecimal originPrice; + /** + * 现价 + */ + private BigDecimal salePrice; + /** + * 折扣 + */ + private BigDecimal discount; + /** + * 共省金额 + */ + private BigDecimal save; + + /** + * 销量 + */ + private BigDecimal realSalesNumber; + + private Integer productId; + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public String getShopName() { + return shopName; + } + + public void setShopName(String shopName) { + this.shopName = shopName; + } + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public BigDecimal getOriginPrice() { + return originPrice; + } + + public void setOriginPrice(BigDecimal originPrice) { + this.originPrice = originPrice; + } + + public BigDecimal getSalePrice() { + return salePrice; + } + + public void setSalePrice(BigDecimal salePrice) { + this.salePrice = salePrice; + } + + public BigDecimal getDiscount() { + return discount; + } + + public void setDiscount(BigDecimal discount) { + this.discount = discount; + } + + public BigDecimal getSave() { + return save; + } + + public void setSave(BigDecimal save) { + this.save = save; + } + + public BigDecimal getRealSalesNumber() { + return realSalesNumber; + } + + public void setRealSalesNumber(BigDecimal realSalesNumber) { + this.realSalesNumber = realSalesNumber; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserDutyVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserDutyVo.java new file mode 100644 index 0000000..c81205b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/UserDutyVo.java @@ -0,0 +1,29 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import java.math.BigDecimal; + +/** + * @author lyf + */ +public class UserDutyVo { + + private BigDecimal number; + + private Integer productId; + + public BigDecimal getNumber() { + return number; + } + + public void setNumber(BigDecimal number) { + this.number = number; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/carouselVO.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/carouselVO.java new file mode 100644 index 0000000..d7cffc7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/carouselVO.java @@ -0,0 +1,16 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +/** + * 轮播图 + * @author lyf + */ +public class carouselVO { + /** + * 封面图 + */ + private String coverImg; + /** + * 跳转地址 + */ + private String relUrl; +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java index 44b2ed2..00513a8 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/redis/RedisCst.java @@ -10,6 +10,8 @@ public class RedisCst { //在线用户 public static final String ONLINE_USER = "ONLINE_USER:"; + public static final String ONLINE_APP_USER = "ONLINE_APP_USER:"; + public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:"; public static final String TABLE_CART = "TABLE:CART:"; public static final String PRODUCT = "PRODUCT:"; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java new file mode 100644 index 0000000..1478255 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/HomePageService.java @@ -0,0 +1,93 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper; +import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper; +import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; +import com.chaozhanggui.system.cashierservice.entity.TbProductSku; +import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto; +import com.chaozhanggui.system.cashierservice.entity.vo.HomeUpVO; +import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO; +import com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.ArrayList; +import java.util.List; + +/** + * @author lyf + */ +@Service +@Slf4j +public class HomePageService { + @Resource + private TbShopInfoMapper shopInfoMapper; + @Resource + private TbProductSkuMapper productSkuMapper; + @Resource + private TbPlatformDictMapper platformDictMapper; + + + public Result homePage(HomeDto homeDto){ + int beginNo; + if(homeDto.getPage() <=0){ + beginNo = 0; + }else{ + beginNo = (homeDto.getPage() - 1) * homeDto.getSize(); + } + List homeVO = shopInfoMapper.selectShopInfo(beginNo,homeDto.getSize()); + List objects = new ArrayList<>(); + for (HomeVO o :homeVO) { + objects.add(o.getProductId()); + } + //原价现价 + List tbProductSkus = productSkuMapper.selectDownSku(objects); + //销量 + List userDutyVos = shopInfoMapper.searchUserDutyDetail(objects); + //组装数据 + for (HomeVO o :homeVO) { + for (TbProductSku sku :tbProductSkus) { + if (o.getProductId().toString().equals(sku.getProductId())){ + o.setOriginPrice(sku.getOriginPrice() == null?BigDecimal.ZERO:sku.getOriginPrice()); + o.setSalePrice(sku.getSalePrice() == null?BigDecimal.ZERO:sku.getSalePrice()); + } + } + if (userDutyVos == null){ + o.setRealSalesNumber(BigDecimal.ZERO); + }else { + for (UserDutyVo duty : userDutyVos) { + if (o.getProductId().equals(duty.getProductId())) { + o.setRealSalesNumber(duty.getNumber()); + }else { + o.setRealSalesNumber(BigDecimal.ZERO); + } + } + } + //共省金额 + o.setSave(o.getOriginPrice().subtract(o.getSalePrice())); + if (o.getOriginPrice().compareTo(BigDecimal.ZERO) == 0){ + o.setDiscount(null); + }else { + o.setDiscount(o.getSalePrice().divide(o.getOriginPrice(), 2, RoundingMode.DOWN).multiply(new BigDecimal("10"))); + } + } + return Result.success(CodeEnum.SUCCESS,homeVO); + } + + public Result homePageUp(String environment){ + HomeUpVO homeUpVO = new HomeUpVO(); + //轮播图 + List carouselList = platformDictMapper.queryAllByType("carousel",environment); + homeUpVO.setCarousel(carouselList); + //金刚区 + List districtList = platformDictMapper.queryAllByType("homeDistrict",environment); + homeUpVO.setDistrict(districtList); + return Result.success(CodeEnum.SUCCESS,homeUpVO); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index 0731369..0e9532c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -9,17 +9,16 @@ import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.sign.CodeEnum; import com.chaozhanggui.system.cashierservice.sign.Result; +import com.chaozhanggui.system.cashierservice.util.MD5Utils; import com.chaozhanggui.system.cashierservice.util.TokenUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; @Service public class LoginService { @@ -46,17 +45,16 @@ public class LoginService { TbTokenMapper tbTokenMapper; - @Autowired RedisUtil redisUtil; @Transactional(rollbackFor = Exception.class) - public Result wxCustomLogin(String openId,String headImage,String nickName,String telephone,String qrCode,String ip) throws Exception { + public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String qrCode, String ip) throws Exception { - TbUserInfo userInfo= tbUserInfoMapper.selectByOpenId(openId); - if(ObjectUtil.isNull(userInfo)){ - userInfo=new TbUserInfo(); + TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId); + if (ObjectUtil.isNull(userInfo)) { + userInfo = new TbUserInfo(); userInfo.setAmount(BigDecimal.ZERO); userInfo.setChargeAmount(BigDecimal.ZERO); @@ -65,9 +63,9 @@ public class LoginService { userInfo.setConsumeAmount(BigDecimal.ZERO); userInfo.setTotalScore(0); userInfo.setLockScore(0); - userInfo.setHeadImg(ObjectUtil.isNotNull(headImage)?headImage:""); - userInfo.setNickName(ObjectUtil.isNotNull(nickName)?nickName:"微信用户"); - userInfo.setTelephone(ObjectUtil.isNotNull(telephone)?telephone:""); + userInfo.setHeadImg(ObjectUtil.isNotNull(headImage) ? headImage : ""); + userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户"); + userInfo.setTelephone(ObjectUtil.isNotNull(telephone) ? telephone : ""); userInfo.setMiniAppOpenId(openId); userInfo.setStatus(Byte.parseByte("1")); userInfo.setParentType("PERSON"); @@ -82,31 +80,39 @@ public class LoginService { userInfo.setUpdatedAt(System.currentTimeMillis()); tbUserInfoMapper.insert(userInfo); - }else { - userInfo.setHeadImg(ObjectUtil.isNotNull(headImage)?headImage:""); - userInfo.setNickName(ObjectUtil.isNotNull(nickName)?nickName:"微信用户"); - userInfo.setTelephone(ObjectUtil.isNotNull(telephone)?telephone:""); + } else { + userInfo.setHeadImg(ObjectUtil.isNotNull(headImage) ? headImage : ""); + userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户"); + userInfo.setTelephone(ObjectUtil.isNotNull(telephone) ? telephone : ""); tbUserInfoMapper.updateByPrimaryKeySelective(userInfo); } + //app与微信用户 互相关联 + if (ObjectUtil.isNotNull(telephone)) { + TbUserInfo appUser = tbUserInfoMapper.selectByPhone(telephone); + if (appUser != null) { + TbUserInfo wechatUser = tbUserInfoMapper.selectByOpenId(openId); + appUser.setUserId(wechatUser.getId()); + tbUserInfoMapper.updateByPrimaryKey(appUser); + wechatUser.setUserId(appUser.getId()); + tbUserInfoMapper.updateByPrimaryKey(wechatUser); + } + } + TbShopInfo tbShopInfo = null; + if (ObjectUtil.isEmpty(qrCode)) { + tbShopInfo = tbShopInfoMapper.selectByPhone(defaultPhone); - TbShopInfo tbShopInfo=null; - if(ObjectUtil.isEmpty(qrCode)){ - tbShopInfo=tbShopInfoMapper.selectByPhone(defaultPhone); - - - }else { - tbShopInfo= tbShopInfoMapper.selectByQrCode(qrCode); + } else { + tbShopInfo = tbShopInfoMapper.selectByQrCode(qrCode); } - - TbShopUser tbShopUser=null; - Map shopMap=new HashMap<>(); - if(ObjectUtil.isNotEmpty(tbShopInfo)){ - tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(),tbShopInfo.getId().toString()); - if(ObjectUtil.isEmpty(tbShopUser)){ - tbShopUser=new TbShopUser(); + TbShopUser tbShopUser = null; + Map shopMap = new HashMap<>(); + if (ObjectUtil.isNotEmpty(tbShopInfo)) { + tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userInfo.getId().toString(), tbShopInfo.getId().toString()); + if (ObjectUtil.isEmpty(tbShopUser)) { + tbShopUser = new TbShopUser(); tbShopUser.setAmount(BigDecimal.ZERO); tbShopUser.setCreditAmount(BigDecimal.ZERO); tbShopUser.setConsumeAmount(BigDecimal.ZERO); @@ -119,32 +125,31 @@ public class LoginService { tbShopUser.setCreatedAt(System.currentTimeMillis()); tbShopUserMapper.insert(tbShopUser); } - shopMap.put("shopId",tbShopUser.getShopId()); - shopMap.put("name",tbShopInfo.getShopName()); - shopMap.put("amount",BigDecimal.ZERO.toPlainString()); - shopMap.put("levelConsume",BigDecimal.ZERO.toPlainString()); + shopMap.put("shopId", tbShopUser.getShopId()); + shopMap.put("name", tbShopInfo.getShopName()); + shopMap.put("amount", BigDecimal.ZERO.toPlainString()); + shopMap.put("levelConsume", BigDecimal.ZERO.toPlainString()); } //生成token 信息 - String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(),userInfo.getNickName()); + String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName()); //存储登录记录 - TbToken tbToken = new TbToken(tbShopInfo.getId(), userInfo.getId(),"wx_lite", token, ip, "1", new Date()); + TbToken tbToken = new TbToken(tbShopInfo.getId(), userInfo.getId(), "wx_lite", token, ip, "1", new Date()); tbTokenMapper.insert(tbToken); - - Map map=new HashMap<>(); + Map map = new HashMap<>(); try { - map.put("token",token); - map.put("userInfo",userInfo); - map.put("shopUser",shopMap); - map.put("shopInfo",tbShopInfo); + map.put("token", token); + map.put("userInfo", userInfo); + map.put("shopUser", shopMap); + map.put("shopInfo", tbShopInfo); redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map)); - return Result.success(CodeEnum.SUCCESS,map); + return Result.success(CodeEnum.SUCCESS, map); } catch (Exception e) { e.printStackTrace(); @@ -152,67 +157,155 @@ public class LoginService { return Result.fail("登录失败"); } + public TbUserInfo register(String phone, String password, String nickName) { + TbUserInfo userInfo = new TbUserInfo(); + userInfo.setAmount(BigDecimal.ZERO); + userInfo.setChargeAmount(BigDecimal.ZERO); + userInfo.setLineOfCredit(BigDecimal.ZERO); + userInfo.setConsumeNumber(0); + userInfo.setConsumeAmount(BigDecimal.ZERO); + userInfo.setTotalScore(0); + userInfo.setLockScore(0); + userInfo.setHeadImg(""); + userInfo.setNickName(nickName); + userInfo.setTelephone(phone); + userInfo.setStatus(Byte.parseByte("1")); + userInfo.setParentType("PERSON"); + userInfo.setIsResource(Byte.parseByte("0")); + userInfo.setIsOnline(Byte.parseByte("0")); + userInfo.setIsVip(Byte.parseByte("0")); + userInfo.setSourcePath("APP"); + userInfo.setIsAttentionMp(Byte.parseByte("0")); + userInfo.setSearchWord("||移动端用户"); + userInfo.setLastLogInAt(System.currentTimeMillis()); + userInfo.setCreatedAt(System.currentTimeMillis()); + userInfo.setUpdatedAt(System.currentTimeMillis()); + if(StringUtils.isNotBlank(password)){ + userInfo.setPassword(MD5Utils.MD5Encode(password, "UTF-8")); + } + tbUserInfoMapper.insert(userInfo); + //注册时 app与微信小程序用户关联 + TbUserInfo wechatUser = tbUserInfoMapper.selectUserByPhone(phone, "WECHAT-APP"); + TbUserInfo appUser = tbUserInfoMapper.selectByPhone(phone); + if (wechatUser != null) { + appUser.setUserId(wechatUser.getId()); + tbUserInfoMapper.updateByPrimaryKey(appUser); + wechatUser.setUserId(appUser.getId()); + tbUserInfoMapper.updateByPrimaryKey(wechatUser); + } + return appUser; + } - public Result createCardNo(String id,String openId){ - if(ObjectUtil.isEmpty(id)||ObjectUtil.isEmpty(openId)){ + /** + * 手机号 短信验证码 校验 + * + * @param code + * @param phone + * @return + */ + public boolean validate(String code, String phone) { + if (StringUtils.isNotBlank(code)) { + String message = redisUtil.getMessage(phone); + boolean tf = Objects.equals(code, message); + if (tf) { + redisUtil.deleteByKey(phone); + return true; + } + } + return false; + } + + @Transactional(rollbackFor = Exception.class) + public Result appLogin(String username, String password) { + TbUserInfo userInfo = tbUserInfoMapper.selectUserByPhone(username, "APP"); + if (ObjectUtil.isNull(userInfo)) { + //注册 + userInfo=register(username, password, username); + } + if (StringUtils.isNotBlank(password) && !password.equalsIgnoreCase(userInfo.getPassword())) { + return Result.fail("密码错误"); + } + //生成token 信息 + String token = null; + try { + token = TokenUtil.generateToken(userInfo.getId(), null, userInfo.getTelephone(), userInfo.getNickName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + Map map = new HashMap<>(); + try { + map.put("token", token); + map.put("userInfo", userInfo); + redisUtil.saveMessage(RedisCst.ONLINE_APP_USER.concat(userInfo.getId() + ""), JSON.toJSONString(map)); + return Result.success(CodeEnum.SUCCESS, map); + } catch (Exception e) { + e.printStackTrace(); + + } + return Result.fail("登录失败"); + } + + public Result createCardNo(String id, String openId) { + if (ObjectUtil.isEmpty(id) || ObjectUtil.isEmpty(openId)) { return Result.fail("head 信息不允许为空"); } - TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(id)); - if(userInfo==null||ObjectUtil.isEmpty(userInfo)){ - userInfo=tbUserInfoMapper.selectByOpenId(openId); + TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(id)); + if (userInfo == null || ObjectUtil.isEmpty(userInfo)) { + userInfo = tbUserInfoMapper.selectByOpenId(openId); } - if(userInfo==null||ObjectUtil.isEmpty(userInfo)){ + if (userInfo == null || ObjectUtil.isEmpty(userInfo)) { return Result.fail("用户信息不存在"); } - String cardNo= RandomUtil.randomNumbers(10); + String cardNo = RandomUtil.randomNumbers(10); userInfo.setCardNo(cardNo); userInfo.setUpdatedAt(System.currentTimeMillis()); tbUserInfoMapper.updateByPrimaryKeySelective(userInfo); - return Result.success(CodeEnum.SUCCESS,cardNo) ; + return Result.success(CodeEnum.SUCCESS, cardNo); } - public Result userInfo(Integer userId,String shopId){ + public Result userInfo(Integer userId, String shopId) { TbUserInfo tbUserInfo = tbUserInfoMapper.selectByPrimaryKey(userId); - if (tbUserInfo == null){ - return Result.success(CodeEnum.ENCRYPT,new ArrayList()); + if (tbUserInfo == null) { + return Result.success(CodeEnum.ENCRYPT, new ArrayList()); } - TbShopInfo tbShopInfo=null; - if(ObjectUtil.isEmpty(shopId)){ - tbShopInfo=tbShopInfoMapper.selectByPhone(defaultPhone); - }else { - tbShopInfo=tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); + TbShopInfo tbShopInfo = null; + if (ObjectUtil.isEmpty(shopId)) { + tbShopInfo = tbShopInfoMapper.selectByPhone(defaultPhone); + } else { + tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId)); } - TbShopUser tbShopUser=null; - Map shopMap=new HashMap<>(); - if(ObjectUtil.isNotEmpty(tbShopInfo)){ - tbShopUser= tbShopUserMapper.selectByUserIdAndShopId(tbUserInfo.getId().toString(),tbShopInfo.getId().toString()); - shopMap.put("shopId",tbShopUser.getShopId()); - shopMap.put("name",tbShopInfo.getShopName()); - shopMap.put("amount",BigDecimal.ZERO.toPlainString()); - shopMap.put("levelConsume",BigDecimal.ZERO.toPlainString()); + TbShopUser tbShopUser = null; + Map shopMap = new HashMap<>(); + if (ObjectUtil.isNotEmpty(tbShopInfo)) { + tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(tbUserInfo.getId().toString(), tbShopInfo.getId().toString()); + shopMap.put("shopId", tbShopUser.getShopId()); + shopMap.put("name", tbShopInfo.getShopName()); + shopMap.put("amount", BigDecimal.ZERO.toPlainString()); + shopMap.put("levelConsume", BigDecimal.ZERO.toPlainString()); } - Map map=new HashMap<>(); - map.put("userInfo",tbUserInfo); - map.put("shopUser",shopMap); - map.put("shopInfo",tbShopInfo); + Map map = new HashMap<>(); + map.put("userInfo", tbUserInfo); + map.put("shopUser", shopMap); + map.put("shopInfo", tbShopInfo); - return Result.success(CodeEnum.ENCRYPT,map); + return Result.success(CodeEnum.ENCRYPT, map); } - public static void main(String[] args){ - for(int i =0;i<10;i++){ + + public static void main(String[] args) { + for (int i = 0; i < 10; i++) { System.out.println(RandomUtil.randomNumbers(10)); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OnlineUserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OnlineUserService.java index 704010f..d9300d0 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OnlineUserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OnlineUserService.java @@ -38,7 +38,7 @@ public class OnlineUserService { onlineUserDto.setLoginTime(new Date()); onlineUserDto.setShopId(shopId); try { - redisUtils.set("online-token-"+token, onlineUserDto, MILLIS_MINUTE); + redisUtils.set("online-token-"+token, onlineUserDto, MILLIS_MINUTE);//30分钟 }catch (Exception e){ throw new MsgException("登录错误"); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java b/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java index b8f92de..0eda53e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/sign/CodeEnum.java @@ -5,8 +5,11 @@ public enum CodeEnum { //系统编码 SYS_EXCEPTION("999",false,"系统异常","fail"), SUCCESS("0",false,"成功","success"), + UPGRADE_REQUIRED("426",true,"成功","success"), ENCRYPT("0",true,"成功","success"), FAIL("1",false,"失败","fail"), + TOKEN_EXEIST("-2",false,"token不能为空","fail"), + TOKEN_EXPIRED("-4",false,"账号已过期,请重新登陆","fail"), SIGN_FAIL("100013",false,"签名不正确","fail"), ORGAN_NO_EXEIST("100010",false,"机构代码不存在或状态异常,请联系服务商","fail"), diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java new file mode 100644 index 0000000..ad4ccb9 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/LocationUtils.java @@ -0,0 +1,69 @@ +package com.chaozhanggui.system.cashierservice.util; + +import java.util.HashMap; +import java.util.Map; + +import static java.lang.Math.*; +import static java.lang.Math.sin; + +public class LocationUtils { + + public static String district(String keywords) { + Map param=new HashMap<>(); + //超掌柜生活-用户端 + param.put("key","7a7f2e4790ea222660a027352ee3af39"); + param.put("keywords",keywords); + param.put("subdistrict","1"); + param.put("extensions","base"); + String s = HttpClientUtil.doGet("https://restapi.amap.com/v3/config/district", param); + return s; + } + + /** + * 将角度转化为弧度 + */ + public static double radians(double d) { + return d * Math.PI / 180.0; + } + /** + * 根据两点经纬度坐标计算直线距离 + *

+ * S = 2arcsin√sin²(a/2)+cos(lat1)*cos(lat2)*sin²(b/2) ̄*6378.137 + *

+ * 1. lng1 lat1 表示A点经纬度,lng2 lat2 表示B点经纬度;
+ * 2. a=lat1 – lat2 为两点纬度之差 b=lng1 -lng2 为两点经度之差;
+ * 3. 6378.137为地球赤道半径,单位为千米; + * + * @param lng1 点1经度 + * @param lat1 点1纬度 + * @param lng2 点2经度 + * @param lat2 点2纬度 + * @return 距离,单位千米(KM) + * @see 半正矢(Haversine)公式 + */ + public static double getDistanceFrom2LngLat(double lng1, double lat1, double lng2, double lat2) { + //将角度转化为弧度 + double radLng1 = radians(lng1); + double radLat1 = radians(lat1); + double radLng2 = radians(lng2); + double radLat2 = radians(lat2); + + double a = radLat1 - radLat2; + double b = radLng1 - radLng2; + + return 2 * asin(sqrt(sin(a / 2) * sin(a / 2) + cos(radLat1) * cos(radLat2) * sin(b / 2) * sin(b / 2))) * 6378.137; + } + +// public static void main(String[] args) { +// // 示例经纬度坐标 +// double lat1 = 108.954398; +// double lon1 = 34.308687; +// +// double lat2 = 108.953555; +// double lon2 = 34.276169; +// +// // 计算距离 +// double distance = getDistanceFrom2LngLat(lat1, lon1, lat2, lon2); +// System.out.println("Distance between the two points is: " + distance + " km"); +// } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java index d2edcde..01261dc 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/RedisUtils.java @@ -294,10 +294,10 @@ public class RedisUtils { * @param timeUnit 类型 * @return true成功 false 失败 */ - public boolean set(String key, Object value, long time, TimeUnit timeUnit) { + public boolean set(String key, String value, long time, TimeUnit timeUnit) { try { if (time > 0) { - redisTemplate.opsForValue().set(key, value, time, timeUnit); + stringRedisTemplate.opsForValue().set(key, value, time, timeUnit); } else { set(key, value); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java index f049832..922be6c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/StringUtil.java @@ -51,4 +51,14 @@ public class StringUtil { return JSON.parseArray(listString); } + + public static String random(int length) { + Random random = new Random(); + String result = ""; + for (int i = 0; i < length; i++) { + result += random.nextInt(10); + } + return result; + } + } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java new file mode 100644 index 0000000..75189f0 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java @@ -0,0 +1,85 @@ +package com.chaozhanggui.system.cashierservice.util; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.dysmsapi20170525.Client; +import com.aliyun.teaopenapi.models.Config; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS; + +/** + * 获取验证码相关工具 + * @author 12847 + */ +@Component +public class ValidateCodeUtil { + /** + * 阿里云key + */ + @Value("${aliyun.keyid}") + private String ACCESSKEYID; + /** + * 阿里云secret + */ + @Value("${aliyun.keysecret}") + private String ACCESSKEYSECRET; + /** + * 十小时 + */ + protected static final long MILLIS_MINUTE = 10 *60 * 60 *1000; + + @Autowired + private HttpServletRequest request; + + + /** + * 获取验证码(阿里云) + */ + public Result requestValidateCodeAli(String phone, String checkCode) { + Client client = null; + try { + client = createClient(); + } catch (Exception e) { + e.printStackTrace(); + } + // 1.发送短信 + com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest() + .setSignName("银收客") + .setTemplateCode("SMS_244665149") + .setTemplateParam("{\"code\":" +"'"+checkCode +"'"+"}") + .setPhoneNumbers(phone); + com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); + try { + assert client != null; + return Result.success(SUCCESS,client.sendSmsWithOptions(sendSmsRequest, runtime)); + } catch (Exception e) { + return Result.fail(e.getMessage()); + } + + } + /** + * 发送短信(阿里云) + * + * @return + * @throws Exception + */ + public Client createClient() throws Exception { + Config config = new Config(); + config.accessKeyId = ACCESSKEYID; + config.accessKeySecret = ACCESSKEYSECRET; + return new com.aliyun.dysmsapi20170525.Client(config); + } + + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d5c4870..4f818e0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,7 +13,7 @@ wx: # spring: profiles: - active: prod + active: dev websocket: port: 6001 action: ws://127.0.0.1 @@ -47,3 +47,7 @@ logging: # 如果是压缩包,里面会多一个名log/ota.2021-11-05.0的日志文件 # 如下面的例子,打包之后为: log/2021-11/cashier-client.2020-11-5.0.log,这是一个日志文件 file-name-pattern: log/%d{yyyy-MM}/cashierService.%d{yyyy-MM-dd}.%i.log +#阿里云相关配置 +aliyun: + keyid: LTAI5tPdEfYSZcqHbjCrtPRD + keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy \ No newline at end of file diff --git a/src/main/resources/mapper/TbPlatformDictMapper.xml b/src/main/resources/mapper/TbPlatformDictMapper.xml new file mode 100644 index 0000000..fa4182b --- /dev/null +++ b/src/main/resources/mapper/TbPlatformDictMapper.xml @@ -0,0 +1,248 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) + values (#{name}, #{type}, #{coverImg}, #{shareImg}, #{video}, #{videoCoverImg}, #{relUrl}, #{absUrl}, #{createdAt}, #{updatedAt}, #{isShowCash}, #{isShowMall}, #{isShowApp}, #{sort}) + + + + insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) + values + + (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort}) + + + + + insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort) + values + + (#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort}) + + on duplicate key update + name = values(name), + type = values(type), + cover_img = values(cover_img), + share_img = values(share_img), + video = values(video), + video_cover_img = values(video_cover_img), + rel_url = values(rel_url), + abs_url = values(abs_url), + created_at = values(created_at), + updated_at = values(updated_at), + is_show_cash = values(is_show_cash), + is_show_mall = values(is_show_mall), + is_show_app = values(is_show_app), + sort = values(sort) + + + + + update tb_platform_dict + + + name = #{name}, + + + type = #{type}, + + + cover_img = #{coverImg}, + + + share_img = #{shareImg}, + + + video = #{video}, + + + video_cover_img = #{videoCoverImg}, + + + rel_url = #{relUrl}, + + + abs_url = #{absUrl}, + + + created_at = #{createdAt}, + + + updated_at = #{updatedAt}, + + + is_show_cash = #{isShowCash}, + + + is_show_mall = #{isShowMall}, + + + is_show_app = #{isShowApp}, + + + sort = #{sort}, + + + where id = #{id} + + + + + delete from tb_platform_dict where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml index 6ba93af..969e918 100644 --- a/src/main/resources/mapper/TbProductSkuMapper.xml +++ b/src/main/resources/mapper/TbProductSkuMapper.xml @@ -355,4 +355,19 @@ + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbShopInfoMapper.xml b/src/main/resources/mapper/TbShopInfoMapper.xml index bad0fbf..0634beb 100644 --- a/src/main/resources/mapper/TbShopInfoMapper.xml +++ b/src/main/resources/mapper/TbShopInfoMapper.xml @@ -617,4 +617,31 @@ + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbUserInfoMapper.xml b/src/main/resources/mapper/TbUserInfoMapper.xml index a52332a..4e494b9 100644 --- a/src/main/resources/mapper/TbUserInfoMapper.xml +++ b/src/main/resources/mapper/TbUserInfoMapper.xml @@ -3,6 +3,7 @@ + @@ -47,15 +48,16 @@ + - id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score, + id,user_id, amount, charge_amount, line_of_credit, consume_amount, consume_number, total_score, lock_score, card_no, card_password, level_id, head_img, nick_name, telephone, wx_ma_app_id, birth_day, sex, mini_app_open_id, open_id, union_id, code, type, identify, status, parent_id, parent_level, parent_type, project_id, merchant_id, is_resource, is_online, is_vip, vip_effect_at, tips, source_path, is_sales_person, is_attention_mp, city, search_word, last_log_in_at, last_leave_at, created_at, updated_at, bind_parent_at, - grand_parent_id + grand_parent_id,password select * from tb_user_info where mini_app_open_id=#{openId} - + + + + + \ No newline at end of file