diff --git a/mallinkAdmin/src/main/java/com/simple/config/CorsConfig.java b/mallinkAdmin/src/main/java/com/simple/config/CorsConfig.java new file mode 100644 index 000000000..9fd07bf4e --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/config/CorsConfig.java @@ -0,0 +1,22 @@ +package com.simple.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +/** + * Created by Administrator on 2017/8/9. + */ +@Configuration +public class CorsConfig extends WebMvcConfigurerAdapter { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowCredentials(true) + .allowedMethods("GET", "POST", "DELETE", "PUT") + .maxAge(3600); + } + +} diff --git a/mallinkAdmin/src/main/java/com/simple/config/KaptchaConfig.java b/mallinkAdmin/src/main/java/com/simple/config/KaptchaConfig.java new file mode 100644 index 000000000..39a36e9c6 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/config/KaptchaConfig.java @@ -0,0 +1,32 @@ +package com.simple.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + + +/** + * 生成验证码配置 + * + * @author stormeye.wu + * @email wugq@mippoint.com + * @date 2017-04-20 19:22 + */ +@Configuration +public class KaptchaConfig { + + @Bean + public DefaultKaptcha producer() { + Properties properties = new Properties(); + properties.put("kaptcha.border", "no"); + properties.put("kaptcha.textproducer.font.color", "black"); + properties.put("kaptcha.textproducer.char.space", "5"); + Config config = new Config(properties); + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/mallinkAdmin/src/main/java/com/simple/config/ShiroConfig.java b/mallinkAdmin/src/main/java/com/simple/config/ShiroConfig.java index 70edeaaf7..948d3b637 100644 --- a/mallinkAdmin/src/main/java/com/simple/config/ShiroConfig.java +++ b/mallinkAdmin/src/main/java/com/simple/config/ShiroConfig.java @@ -120,6 +120,7 @@ public class ShiroConfig { filterChainDefinitionMap.put("/carCallback/**","anon"); filterChainDefinitionMap.put("/wxMallApply/add","anon"); filterChainDefinitionMap.put("/wxMallApply/sendvalidationcode","anon"); + filterChainDefinitionMap.put("/captcha.jpg", "anon"); // filterChainDefinitionMap.put("/role/**", "corsFilter,token"); filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); // filterChainDefinitionMap.put("/**", "anon"); diff --git a/mallinkAdmin/src/main/java/com/simple/controller/HomeController.java b/mallinkAdmin/src/main/java/com/simple/controller/HomeController.java index d737fa627..e44428563 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/HomeController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/HomeController.java @@ -1,6 +1,9 @@ package com.simple.controller; import com.github.pagehelper.PageInfo; +import com.google.code.kaptcha.Constants; +import com.google.code.kaptcha.Producer; +import com.simple.common.ErrorCode; import com.simple.common.ResultData; import com.simple.domain.po.MallRolePermission; import com.simple.domain.po.MallUserInfo; @@ -8,8 +11,10 @@ import com.simple.domain.po.MallUserRole; import com.simple.service.MallRolePermissionService; import com.simple.service.MallUserRoleService; import com.simple.shiro.UserSession; +import com.simple.utils.ShiroUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.io.IOUtils; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.Subject; @@ -17,10 +22,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.imageio.ImageIO; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; @RestController @@ -28,15 +37,43 @@ import org.springframework.web.bind.annotation.RestController; public class HomeController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private Producer producer; + @Autowired private MallUserRoleService mallUserRoleService; @Autowired private MallRolePermissionService mallRolePermissionService; + @RequestMapping("/captcha.jpg") + public void captcha(HttpServletResponse response)throws ServletException, IOException { + response.setHeader("Cache-Control", "no-store, no-cache"); + response.setContentType("image/jpeg"); + + //生成文字验证码 + String text = producer.createText(); + //生成图片验证码 + BufferedImage image = producer.createImage(text); + //保存到shiro session + ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); + + ServletOutputStream out = response.getOutputStream(); + ImageIO.write(image, "jpg", out); + IOUtils.closeQuietly(out); + } + @ApiOperation("登录") @PostMapping("/doLogin") - public ResultData login(@RequestBody MallUserInfo user) { + public ResultData login(@RequestBody MallUserInfo user, String captcha) { + if (captcha != null) { + String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); + if(!captcha.equalsIgnoreCase(kaptcha)){ + return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); + } + } + ResultData data = new ResultData(); if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPassword())) { // throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java index 96330a6da..a10e4a5f4 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java @@ -56,30 +56,22 @@ public class WxCUserBasicInfoController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) - public ResultData list(@ModelAttribute WxCUserBasicInfoDto wxCUserBasicInfo, Integer pageNum, Integer pageSize) { - if (null == wxCUserBasicInfo) wxCUserBasicInfo = new WxCUserBasicInfoDto(); + public ResultData list(@ModelAttribute WxCUserBasicInfo wxCUserBasicInfo, Integer pageNum, Integer pageSize) { + if (null == wxCUserBasicInfo) wxCUserBasicInfo = new WxCUserBasicInfo(); String tenantId = getTenantId(); wxCUserBasicInfo.setTenantId(tenantId); - PageInfo> page = wxCUserBasicInfoService.queryListMap(wxCUserBasicInfo, pageNum, pageSize); -// PageInfo page = wxCUserBasicInfoService.list(wxCUserBasicInfo, pageNum, pageSize); -// if (page.getSize() == 0 && StringUtils.isNotBlank(wxCUserBasicInfo.getPhone()) -// && wxCUserBasicInfo.getEndTime() == null && wxCUserBasicInfo.getStartTime() == null -// && StringUtils.isBlank(wxCUserBasicInfo.getName()) -// ) {//当只有手机号查询并且查不到数据 ,新增 -// WxCUser cUser = new WxCUser(); -// cUser.setTenantId(tenantId); -// cUser.setPhone(wxCUserBasicInfo.getPhone()); -// PageInfo cUsers = wxCUserService.listAsPage(cUser, 1, 1); -// if (cUsers.getSize() > 0) { -// createUserBasicInfo(cUsers.getList().get(0)); -// page = wxCUserBasicInfoService.list(wxCUserBasicInfo, pageNum, pageSize); -// } -// } + PageInfo page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); return new ResultData(page); } private void createUserBasicInfo(WxCUser wxCUser) { + String phone = wxCUser.getPhone(); + if (phone != null && phone.contains("*")) { + phone = wxCUser.getVerifyCodePhone(); + } + if (StringUtils.isBlank(phone)) + return; WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); wxCUserBasicInfo.setId(wxCUser.getId()); wxCUserBasicInfo.setPhone(wxCUser.getPhone()); @@ -138,29 +130,31 @@ public class WxCUserBasicInfoController extends BaseController { @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) public ResultData findById(Long id) { WxCUserBasicInfo info = wxCUserBasicInfoService.getById(id); - if (info != null && info.getTagId() != null) { - WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); - if (StringUtils.isNotBlank(uTag.getTags())) { - List ids = JSONObject.parseArray(uTag.getTags(), Long.class); - WxTags wxTags = new WxTags(); - wxTags.setIds(ids); - PageInfo page = wxTagsService.listAsPage(wxTags, 1, 5000); - String tagNames = ""; - String tagIds = ""; - List tagIdList = new ArrayList<>(); - for (WxTags wt : page.getList()) { - tagNames += wt.getName() + "/"; - tagIds += wt.getId() + ","; - tagIdList.add(wt.getId()); - } - if (StringUtils.isNotBlank(tagNames)) { - info.setTagNames(tagNames.substring(0, tagNames.length() - 1)); - } - if (StringUtils.isNoneBlank(tagIds)) { - info.setTagIds(tagIds.substring(0, tagIds.length() - 1)); + if (info != null) { + if (info.getTagId() != null) { + WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); + if (StringUtils.isNotBlank(uTag.getTags())) { + List ids = JSONObject.parseArray(uTag.getTags(), Long.class); + WxTags wxTags = new WxTags(); + wxTags.setIds(ids); + PageInfo page = wxTagsService.listAsPage(wxTags, 1, 5000); + String tagNames = ""; + String tagIds = ""; + List tagIdList = new ArrayList<>(); + for (WxTags wt : page.getList()) { + tagNames += wt.getName() + "/"; + tagIds += wt.getId() + ","; + tagIdList.add(wt.getId()); + } + if (StringUtils.isNotBlank(tagNames)) { + info.setTagNames(tagNames.substring(0, tagNames.length() - 1)); + } + if (StringUtils.isNoneBlank(tagIds)) { + info.setTagIds(tagIds.substring(0, tagIds.length() - 1)); + } + long count = wxCUserTagsService.findCountByTag(tagIdList); + info.setCount(count); } - long count = wxCUserTagsService.findCountByTag(tagIdList); - info.setCount(count); } } else { info = new WxCUserBasicInfo(); diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxMallApplyController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxMallApplyController.java index edfbd6b0b..3d18d367b 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxMallApplyController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxMallApplyController.java @@ -35,14 +35,13 @@ public class WxMallApplyController extends BaseController { public ResultData add(@RequestBody WxMallApply wxMallApply) { //Assert.notNull(wxMallApply.getName(), "角色名不能为空"); //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); - wxMallApplyService.saveOrUpdate(wxMallApply); - return new ResultData(); + return wxMallApplyService.saveOrUpdate(wxMallApply); + } @PostMapping("update") public ResultData update(@RequestBody WxMallApply wxMallApply) { - wxMallApplyService.saveOrUpdate(wxMallApply); - return new ResultData(); + return wxMallApplyService.saveOrUpdate(wxMallApply); } @GetMapping("/del") @@ -59,7 +58,7 @@ public class WxMallApplyController extends BaseController { } - @GetMapping("sendvalidationcode") + @GetMapping("/sendvalidationcode") @ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "type", value = "场景", dataType = "Integer", paramType = "query", required = true)}) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxMsgCallbackController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxMsgCallbackController.java index 8fd4a8026..087048924 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxMsgCallbackController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxMsgCallbackController.java @@ -68,27 +68,29 @@ public class WxMsgCallbackController extends BaseController { } - @RequestMapping(value = "/receivemsg/{bid}") - public void receivemsg(@PathVariable String bid, @RequestParam Map param) { + @PostMapping(value = "/receivemsg/{tenantId}") + public void receivemsg(@PathVariable String tenantId, @RequestParam Map param) { + logger.info(param.toString()); //解析param数据插入数据库中 String item = param.get("item"); String sign = param.get("sign"); - String tenantId = getTenantId(); - wxMsgCallbackService.saveOrUpdate(tenantId, bid, item, sign); + wxMsgCallbackService.saveOrUpdate(tenantId, item, sign); } - @RequestMapping(value = "/receivemodel/{bid}") - public void receivemodel(@PathVariable String bid, @RequestParam Map param) { + @RequestMapping(value = "/receivemodel/{tenantId}") + public void receivemodel(@PathVariable String tenantId, @RequestParam Map param) { + logger.info(param.toString()); //解析param数据插入数据库中 - wxMsgCallbackService.receivemodel(getTenantId(), bid, param); + wxMsgCallbackService.receivemodel(tenantId, param); } - @RequestMapping(value = "/receiveverifymodel/{bid}") - public void receiveverifymodel(@PathVariable String bid, @RequestParam Map param) { + @RequestMapping(value = "/receiveverifymodel/{tenantId}") + public void receiveverifymodel(@PathVariable String tenantId, @RequestParam Map param) { + logger.info(param.toString()); //解析param数据插入数据库中 - wxMsgCallbackService.receiveverifymodel(bid, param); + wxMsgCallbackService.receiveverifymodel(tenantId, param); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java index 3b0769e14..bf78e68a0 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java @@ -83,5 +83,16 @@ public class WxShopController extends BaseController { return wxShopService.getMerchantShopByShopId(getTenantId(), shopId); } + @ApiOperation("查询商铺号是否存在") + @GetMapping("hasShopNumber") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true), + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")}) + public ResultData hasShopNumber(String shopNumber,Long id) { + return wxShopService.hasShopNumber(getTenantId(), shopNumber,id); + } + + } diff --git a/mallinkAdmin/src/main/java/com/simple/utils/ShiroUtils.java b/mallinkAdmin/src/main/java/com/simple/utils/ShiroUtils.java new file mode 100644 index 000000000..810ba5eb2 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/utils/ShiroUtils.java @@ -0,0 +1,61 @@ +package com.simple.utils; + +import com.simple.common.ErrorCode; +import com.simple.domain.po.MallUserInfo; +import com.simple.exception.MallinkException; +import com.simple.shiro.UserSession; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; + +/** + * Shiro工具类 + * + * @author stormeye.wu + * @email wugq@mippoint.com + * @date 2016年11月12日 上午9:49:19 + */ +public class ShiroUtils { + + public static Session getSession() { + return SecurityUtils.getSubject().getSession(); + } + + public static Subject getSubject() { + return SecurityUtils.getSubject(); + } + + public static MallUserInfo getUserInfo() { + return (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); + } + + public static Long getUserId() { + return getUserInfo().getId(); + } + + public static void setSessionAttribute(Object key, Object value) { + getSession().setAttribute(key, value); + } + + public static Object getSessionAttribute(Object key) { + return getSession().getAttribute(key); + } + + public static boolean isLogin() { + return SecurityUtils.getSubject().getPrincipal() != null; + } + + public static void logout() { + SecurityUtils.getSubject().logout(); + } + + public static String getKaptcha(String key) { + Object kaptcha = getSessionAttribute(key); + if (kaptcha == null) { + throw new MallinkException(ErrorCode.KAPCHA_NOT_VALID); + } + getSession().removeAttribute(key); + return kaptcha.toString(); + } + +} diff --git a/mallinkBApi/src/main/java/com/simple/controller/WxMallController.java b/mallinkBApi/src/main/java/com/simple/controller/WxMallController.java index c09ce7b34..a60032b66 100644 --- a/mallinkBApi/src/main/java/com/simple/controller/WxMallController.java +++ b/mallinkBApi/src/main/java/com/simple/controller/WxMallController.java @@ -16,8 +16,13 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; @@ -69,4 +74,34 @@ public class WxMallController extends BaseController { } + /** + * 微信消息服务验证 + * @param response + * @param request + * @throws IOException + */ + @AuthIgnore + @RequestMapping(value = "/signature") + @ResponseBody + public void signature(HttpServletResponse response, HttpServletRequest request) throws IOException { + + + String signature = request.getParameter("signature"); + String timestamp = request.getParameter("timestamp"); + String nonce = request.getParameter("nonce"); + String echostr = request.getParameter("echostr"); + + logger.warn("收到的微信服务验证信息:"+signature+"\n"+timestamp+"\n"+nonce+"\n"+echostr); + PrintWriter out = response.getWriter(); + // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 + // 当前无法确定此消息的appId及token, 所以直接返回echostr + //if (CheckUtil.checkSignature(wp.getToken(), signature, timestamp, nonce)) { + out.print(echostr); + logger.warn("微信服务验证成功===================="+echostr); + System.out.println("微信服务验证成功!"); + //} + out.close(); + } + + } diff --git a/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java b/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java index 0528c0bb5..44a084267 100644 --- a/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java +++ b/mallinkBApi/src/main/java/com/simple/controller/WxRefundOrderController.java @@ -10,9 +10,6 @@ import com.simple.domain.po.WxMerchantBUser; import com.simple.domain.po.WxRefundOrder; import com.simple.enums.EnumRefundWay; import com.simple.exception.MallinkException; -import com.simple.service.WxCouponOrderService; -import com.simple.service.WxOrderService; -import com.simple.service.WxPayOrderService; import com.simple.service.WxRefundOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -35,15 +32,6 @@ public class WxRefundOrderController extends BaseController { @Autowired private PayProperty payProperty; - @Autowired - private WxCouponOrderService wxCouponOrderService; - - @Autowired - private WxOrderService wxOrderService; - - @Autowired - private WxPayOrderService wxPayOrderService; - @Autowired private WxRefundOrderService wxRefundOrderService; @@ -69,8 +57,8 @@ public class WxRefundOrderController extends BaseController { WxMerchantBUser bUser = getUser(); WxAppinfo appinfo = getAppInfo(bUser.getAppId()); try { - wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumRefundWay.B, bUser.getId()); - return new ResultData(); + ResultData rd = wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumRefundWay.B, bUser.getId()); + return rd; } catch (MallinkException e) { logger.error(e.getMessage()); return new ResultData(e.getErrorCode(), e.getMessage()); diff --git a/mallinkCApi/src/main/java/com/simple/controller/BaseController.java b/mallinkCApi/src/main/java/com/simple/controller/BaseController.java index 74687a3fc..f6b92ac74 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/BaseController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/BaseController.java @@ -1,22 +1,17 @@ package com.simple.controller; -import java.beans.PropertyEditorSupport; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; -import cn.binarywang.wx.miniapp.config.WxMaInMemoryConfig; -import com.simple.annotation.AuthIgnore; import com.simple.common.ErrorCode; import com.simple.domain.po.WxAppinfo; import com.simple.domain.po.WxCUser; +import com.simple.domain.po.WxCUserBasicInfo; import com.simple.exception.MallinkException; import com.simple.interceptor.AuthorizationInterceptor; import com.simple.service.WxAppinfoService; +import com.simple.service.WxCUserBasicInfoService; import com.simple.service.WxCUserService; import com.simple.utils.MaUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -25,6 +20,11 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.beans.PropertyEditorSupport; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; @RestController public class BaseController { @@ -34,6 +34,9 @@ public class BaseController { @Autowired private WxAppinfoService wxAppinfoService; + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + @InitBinder public void InitBinder(WebDataBinder dataBinder) { dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @@ -56,7 +59,7 @@ public class BaseController { }); } - public WxCUser getUser(){ + public WxCUser getUser() { Long cUserId = getUserId(); WxCUser user = wxCUserService.getById(cUserId); if (user == null) @@ -65,12 +68,12 @@ public class BaseController { } public Long getUserId() { - HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); - Long cUserId = (Long)request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + Long cUserId = (Long) request.getAttribute(AuthorizationInterceptor.LOGIN_USER_KEY); return cUserId; } - public String getTenantId(){ + public String getTenantId() { Long cUserId = getUserId(); WxCUser user = wxCUserService.getById(cUserId); if (user == null) @@ -92,4 +95,43 @@ public class BaseController { WxMaService service = MaUtil.getWeappService(appinfo); return service; } + + + public void saveToBasicInfo(WxCUser user) { + String phone = user.getPhone(); + if (phone != null && phone.contains("*")) { + phone = user.getVerifyCodePhone(); + } + if (StringUtils.isBlank(phone)) + return; + + List list = wxCUserBasicInfoService.findByPhone(user.getTenantId(), phone); + if (list.size() > 0) { + WxCUserBasicInfo basicInfo = list.get(0); + // 微信名称 + if (basicInfo.getNickName() == null || basicInfo.getNickName().equals(user.getNickName())) { + basicInfo.setNickName(user.getNickName()); + } + // 性别 + if (basicInfo.getSex() == null) { + basicInfo.setSex(user.getGender()); + } + // 成长值 + if (basicInfo.getPoins() == null) { + basicInfo.setPoins(user.getScore()); + } + wxCUserBasicInfoService.saveOrUpdate(basicInfo); + } else { + Date cur = new Date(); + WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); + basicInfo.setTenantId(user.getTenantId()); + basicInfo.setPhone(phone); + basicInfo.setNickName(user.getNickName()); + basicInfo.setSex(user.getGender()); + basicInfo.setPoins(user.getScore()); + basicInfo.setCreateDate(cur); + basicInfo.setUpdateDate(cur); + wxCUserBasicInfoService.saveOrUpdate(basicInfo); + } + } } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java b/mallinkCApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java index 108ad066a..93c3c47eb 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxMsgValidationcodeController.java @@ -1,8 +1,10 @@ package com.simple.controller; +import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxMsgValidationcode; +import com.simple.service.WxCUserService; import com.simple.service.WxMerchantBUserService; import com.simple.service.WxMerchantService; import com.simple.service.WxMsgValidationcodeService; @@ -16,6 +18,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; + @RestController @RequestMapping("/api/wxMsgValidationcode") @Api(description = "短信验证相关接口") @@ -31,6 +35,9 @@ public class WxMsgValidationcodeController extends BaseController { @Autowired private WxMerchantService wxMerchantService; + @Autowired + private WxCUserService wxCUserService; + @GetMapping("sendvalidationcode") @ApiImplicitParams({ @@ -59,7 +66,17 @@ public class WxMsgValidationcodeController extends BaseController { wxMsgValidationcode.setType(type); wxMsgValidationcode.setCode(code); wxMsgValidationcode.setAppid(user.getAppId()); - return wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); + ResultData rd = wxMsgValidationcodeService.hasvalidationcode(wxMsgValidationcode); + if (rd.code == Result.SUCCESS) { + // 更新 WxCUser + user.setVerifyCodePhone(phone); + user.setUpdateDate(new Date()); + wxCUserService.saveOrUpdate(user); + + // 更新到basicinfo + saveToBasicInfo(user); + } + return rd; } diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java b/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java index e1be4ca28..51f4ea58c 100755 --- a/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java @@ -14,8 +14,10 @@ import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxAppinfo; import com.simple.domain.po.WxCUser; +import com.simple.domain.po.WxCUserBasicInfo; import com.simple.domain.po.WxCUserCar; import com.simple.service.WxAppinfoService; +import com.simple.service.WxCUserBasicInfoService; import com.simple.service.WxCUserCarService; import com.simple.service.WxCUserService; import com.simple.utils.CheckUtil; @@ -121,7 +123,6 @@ public class WxUserGrantController extends BaseController { user.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); if (!StringUtils.isBlank(latitude)) user.setLatitude(BigDecimal.valueOf(Double.valueOf(latitude))); - // TODO 成长值 wxCUserService.saveOrUpdate(user1); resultMap.put("token", token); } else { @@ -136,7 +137,6 @@ public class WxUserGrantController extends BaseController { user.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); if (!StringUtils.isBlank(latitude)) user.setLatitude(BigDecimal.valueOf(Double.valueOf(latitude))); - // TODO 成长值 wxCUserService.saveOrUpdate(user); resultMap.put("token", token); } @@ -144,6 +144,14 @@ public class WxUserGrantController extends BaseController { logger.error(e.getMessage()); return new ResultData(ErrorCode.DB_FAIL.getCode(), "wx_c_user数据库保存出错", resultMap); } + + // 成长值 + try { + wxCUserService.scoreCalculate(user.getTenantId(), user.getId()); + } catch (Exception e) { + logger.error(e.getMessage()); + } + return new ResultData(resultMap); } @@ -243,7 +251,6 @@ public class WxUserGrantController extends BaseController { wxCUserService.saveOrUpdate(user); resultMap.put("msg","授权手机成功!"); resultMap.put("phone",phoneNoInfo.getPhoneNumber()); - return new ResultData(resultMap); } else { return new ResultData(ErrorCode.PHONE_DECODE_ERR, resultMap); } @@ -251,6 +258,13 @@ public class WxUserGrantController extends BaseController { this.logger.error(e.getMessage(), e); return new ResultData(ErrorCode.DB_FAIL.getCode(), "解密并保存出错", resultMap); } + + if (!user.getPhone().contains("*")) { // 用户手机非加密 + // 更新到basicinfo + saveToBasicInfo(user); + } + + return new ResultData(resultMap); } /** diff --git a/mallinkService/src/main/java/com/simple/common/ErrorCode.java b/mallinkService/src/main/java/com/simple/common/ErrorCode.java index ee67b0594..c7d0cf2be 100644 --- a/mallinkService/src/main/java/com/simple/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/simple/common/ErrorCode.java @@ -54,6 +54,8 @@ public enum ErrorCode{ USER_IS_LOCKED(2003, "用户已经被锁定不能登录,请与管理员联系"), NEW_USER_FAILD(2004, "创建新用户失败"), BUSER_NOT_IN_APP(2005, "用户不是此app用户"), + KAPCHA_NOT_VALID(2006, "验证码已失效"), + KAPCHA_NOT_EQUAL(2007, "验证码不正确"), /** * 商场/商户 @@ -186,8 +188,16 @@ public enum ErrorCode{ MSG_TEMPLATE_REPEAT(12101,"您添加的短信模板已存在"), MSG_SIGNATURE_CONTENT_ERROR(12102,"短信签名或内容错误"), MSG_TEMPLATE_CREATE_ERROR(12103,"创建模板失败"), + MSG_VERIFY_CODE_NOT_FOUND(12104,"短信验证码不存在或失效"), + MSG_TEMPLATE_NOT_FOUND(12105,"短信模板不存在"), + MSG_REQUEST_PARAMS_ERROR(12106,"参数错误"), + MSG_SEND_ERROR(12107,"发送短信失败"), + MSG_METHOD_REQUEST_ERROR(12108,"接口请求错误"), - + /** + * 会员 + */ + MEM_IMPORT_ERR(13000, "模板导入失败") ; private int code; diff --git a/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java b/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java index 86c5aa8a3..4f2fb9ef9 100644 --- a/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java +++ b/mallinkService/src/main/java/com/simple/domain/dto/MarkingCouponDataReportDto.java @@ -10,6 +10,7 @@ public class MarkingCouponDataReportDto { private Date startTime; private Date endTime; private Integer type; + private Integer couponType; public Integer getType() { return type; @@ -34,4 +35,12 @@ public class MarkingCouponDataReportDto { public void setEndTime(Date endTime) { this.endTime = endTime; } + + public Integer getCouponType() { + return couponType; + } + + public void setCouponType(Integer couponType) { + this.couponType = couponType; + } } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java b/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java index 72c9c9ad4..196d09c45 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCUser.java @@ -122,6 +122,9 @@ public class WxCUser implements Serializable { /*纬度**/ @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") private BigDecimal latitude; + /*登录次数**/ + @io.swagger.annotations.ApiModelProperty(value="登录次数",name="loginCount") + private Integer loginCount; //渠道名称 @Transient @@ -297,6 +300,14 @@ public class WxCUser implements Serializable { this.latitude = latitude; } + public Integer getLoginCount() { + return loginCount; + } + + public void setLoginCount(Integer loginCount) { + this.loginCount = loginCount; + } + public static enum Field { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java b/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java index 180948877..9778c5564 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxCUserBasicInfo.java @@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; import java.util.List; @@ -41,58 +42,66 @@ public class WxCUserBasicInfo implements Serializable { this.ids = ids; } - - - /*微信用户绑定的手机号**/ - @Excel(name="手机",width = 20,orderNum = "2") + + /**微信用户绑定的手机号**/ + @Excel(name="手机号",width = 20,orderNum = "3") @io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone") + @NotNull private String phone; - /*出生日期**/ - @Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "3") + /**出生日期**/ + @Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "6") + @NotNull @io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate") private Date birthdate; - /*学历**/ - @Excel(name="学历",width = 20,orderNum = "4") + /**学历**/ + @Excel(name="学历",width = 20,orderNum = "5") + @NotNull @io.swagger.annotations.ApiModelProperty(value="学历",name="education") private String education; - /*性别:0:保密 1.男 2女**/ + /**性别:0:保密 1.男 2女**/ @Excel(name="性别",width = 20,replace = { "保密_0", "男_1","女_2"},orderNum = "2") + @NotNull @io.swagger.annotations.ApiModelProperty(value="性别:0:保密 1.男 2女",name="sex") private Integer sex; - /*邮箱**/ + /**邮箱**/ @io.swagger.annotations.ApiModelProperty(value="邮箱",name="email") private String email; - /*地址**/ + /**地址**/ + @Excel(name="地址",width = 20,orderNum = "7") @io.swagger.annotations.ApiModelProperty(value="地址",name="address") private String address; - /*积分**/ + /**积分**/ @io.swagger.annotations.ApiModelProperty(value="积分",name="poins") private Integer poins; - /*标签**/ - @io.swagger.annotations.ApiModelProperty(value="标签",name="tagId") + /**用户标签**/ + @io.swagger.annotations.ApiModelProperty(value="用户标签",name="tagId") private Long tagId; - /*创建时间**/ + /**创建时间**/ + @Excel(name="注册时间",width = 20,format="yyyy-MM-dd", orderNum = "9") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") private Date createDate; - /*更新时间**/ + /**更新时间**/ + @Excel(name="上次活跃时间",width = 20,format="yyyy-MM-dd", orderNum = "8") @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") private Date updateDate; - /*租户id**/ + /**租户id**/ @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") private String tenantId; - /*用户姓名**/ - @Excel(name="姓名",width = 20) + /**用户姓名**/ + @Excel(name="姓名",width = 20,orderNum = "1") + @NotNull @io.swagger.annotations.ApiModelProperty(value="用户姓名",name="name") private String name; - - /*会员等级**/ + + /**会员等级**/ @io.swagger.annotations.ApiModelProperty(value="会员等级",name="level") private String level; - /*用户昵称**/ + /**用户昵称**/ + @Excel(name="微信昵称",width = 20,orderNum = "4") @io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName") private String nickName; - + @Transient private String tagIds; @Transient @@ -132,7 +141,7 @@ public class WxCUserBasicInfo implements Serializable { this.tagNames = tagNames; } - + public String getTagIds() { return tagIds; } diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxMallApply.java b/mallinkService/src/main/java/com/simple/domain/po/WxMallApply.java index 23b14b565..41934897e 100644 --- a/mallinkService/src/main/java/com/simple/domain/po/WxMallApply.java +++ b/mallinkService/src/main/java/com/simple/domain/po/WxMallApply.java @@ -36,8 +36,9 @@ public class WxMallApply implements Serializable { public void setIds(List ids) { this.ids = ids; } - - + + @Transient + protected String verifyCode; /*购物中心名称**/ @io.swagger.annotations.ApiModelProperty(value="购物中心名称",name="mallName") @@ -76,7 +77,13 @@ public class WxMallApply implements Serializable { applyDate = _applyDate; } + public String getVerifyCode() { + return verifyCode; + } + public void setVerifyCode(String verifyCode) { + this.verifyCode = verifyCode; + } public static enum Field { diff --git a/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java b/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java new file mode 100644 index 000000000..e7693f1ec --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java @@ -0,0 +1,20 @@ +package com.simple.domain.vo; + + +import com.simple.domain.po.WxCUserBasicInfo; + +/** + * Created by syf on 2018/8/30. + */ +public class CUserBaseVo extends WxCUserBasicInfo { + + private Long newId; + + public Long getNewId() { + return newId; + } + + public void setNewId(Long newId) { + this.newId = newId; + } +} diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderBVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderBVo.java index a26dfe9f7..a2e98de72 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderBVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderBVo.java @@ -69,7 +69,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{ @io.swagger.annotations.ApiModelProperty(value = "状态:0,待使用 1,已核销 2,已过期 3,已作废 ", name = "couponOrderStatus") private Integer couponOrderStatus; /***/ - @Excel(name="交易时间",width = 20,exportFormat="yyyy-MM-dd",orderNum = "3") + @Excel(name="交易时间",width = 20,exportFormat="yyyy-MM-dd HH:mm:ss",orderNum = "3") @io.swagger.annotations.ApiModelProperty(value = "", name = "createDate") private Date createDate; /***/ @@ -218,26 +218,26 @@ public class WxCouponOrderBVo extends WxCouponOrder{ public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), - TenantId_ASC("`tenantId` ASC"), - TenantId_DESC("`tenantId` DESC"), - CouponId_ASC("`couponId` ASC"), - CouponId_DESC("`couponId` DESC"), - CUserId_ASC("`cUserId` ASC"), - CUserId_DESC("`cUserId` DESC"), - BUserId_ASC("`bUserId` ASC"), - BUserId_DESC("`bUserId` DESC"), - OrderId_ASC("`orderId` ASC"), - OrderId_DESC("`orderId` DESC"), - ExpiredTime_ASC("`expiredTime` ASC"), - ExpiredTime_DESC("`expiredTime` DESC"), - CouponOrderStatus_ASC("`couponOrderStatus` ASC"), - CouponOrderStatus_DESC("`couponOrderStatus` DESC"), - CreateDate_ASC("`createDate` ASC"), - CreateDate_DESC("`createDate` DESC"), - UpdateDate_ASC("`updateDate` ASC"), - UpdateDate_DESC("`updateDate` DESC"), - CouponPrice_ASC("`couponPrice` ASC"), - CouponPrice_DESC("`couponPrice` DESC"); + TenantId_ASC("`tenant_id` ASC"), + TenantId_DESC("`tenant_id` DESC"), + CouponId_ASC("`coupon_id` ASC"), + CouponId_DESC("`coupon_id` DESC"), + CUserId_ASC("`c_user_id` ASC"), + CUserId_DESC("`c_user_id` DESC"), + BUserId_ASC("`b_user_id` ASC"), + BUserId_DESC("`b_user_id` DESC"), + OrderId_ASC("`order_id` ASC"), + OrderId_DESC("`order_id` DESC"), + ExpiredTime_ASC("`expired_time` ASC"), + ExpiredTime_DESC("`expired_time` DESC"), + CouponOrderStatus_ASC("`coupon_order_status` ASC"), + CouponOrderStatus_DESC("`coupon_order_status` DESC"), + CreateDate_ASC("`create_date` ASC"), + CreateDate_DESC("`create_date` DESC"), + UpdateDate_ASC("`update_date` ASC"), + UpdateDate_DESC("`update_date` DESC"), + CouponPrice_ASC("`coupon_price` ASC"), + CouponPrice_DESC("`coupon_price` DESC"); private String value; Field(String value) { @@ -273,6 +273,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{ sb.append(fields[k].toString()); } + this.sortColumns = sb.toString(); } public void setSortColumns(String sortColumns) { diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderCVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderCVo.java index 28c7e2a19..ff70154ef 100644 --- a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderCVo.java +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponOrderCVo.java @@ -321,26 +321,26 @@ public class WxCouponOrderCVo extends WxCouponOrder{ public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), - TenantId_ASC("`tenantId` ASC"), - TenantId_DESC("`tenantId` DESC"), - CouponId_ASC("`couponId` ASC"), - CouponId_DESC("`couponId` DESC"), - CUserId_ASC("`cUserId` ASC"), - CUserId_DESC("`cUserId` DESC"), - BUserId_ASC("`bUserId` ASC"), - BUserId_DESC("`bUserId` DESC"), - OrderId_ASC("`orderId` ASC"), - OrderId_DESC("`orderId` DESC"), - ExpiredTime_ASC("`expiredTime` ASC"), - ExpiredTime_DESC("`expiredTime` DESC"), - CouponOrderStatus_ASC("`couponOrderStatus` ASC"), - CouponOrderStatus_DESC("`couponOrderStatus` DESC"), - CreateDate_ASC("`createDate` ASC"), - CreateDate_DESC("`createDate` DESC"), - UpdateDate_ASC("`updateDate` ASC"), - UpdateDate_DESC("`updateDate` DESC"), - CouponPrice_ASC("`couponPrice` ASC"), - CouponPrice_DESC("`couponPrice` DESC"); + TenantId_ASC("`tenant_id` ASC"), + TenantId_DESC("`tenant_id` DESC"), + CouponId_ASC("`coupon_id` ASC"), + CouponId_DESC("`coupon_id` DESC"), + CUserId_ASC("`c_user_id` ASC"), + CUserId_DESC("`c_user_id` DESC"), + BUserId_ASC("`b_user_id` ASC"), + BUserId_DESC("`b_user_id` DESC"), + OrderId_ASC("`order_id` ASC"), + OrderId_DESC("`order_id` DESC"), + ExpiredTime_ASC("`expired_time` ASC"), + ExpiredTime_DESC("`expired_time` DESC"), + CouponOrderStatus_ASC("`coupon_order_status` ASC"), + CouponOrderStatus_DESC("`coupon_order_status` DESC"), + CreateDate_ASC("`create_date` ASC"), + CreateDate_DESC("`create_date` DESC"), + UpdateDate_ASC("`update_date` ASC"), + UpdateDate_DESC("`update_date` DESC"), + CouponPrice_ASC("`coupon_price` ASC"), + CouponPrice_DESC("`coupon_price` DESC"); private String value; Field(String value) { @@ -376,6 +376,7 @@ public class WxCouponOrderCVo extends WxCouponOrder{ sb.append(fields[k].toString()); } + this.sortColumns = sb.toString(); } public void setSortColumns(String sortColumns) { diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java index 11c5ef83f..4705fc127 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java @@ -3,6 +3,7 @@ package com.simple.mapper; import com.simple.common.CommonMapper; import com.simple.domain.dto.WxCUserBasicInfoDto; import com.simple.domain.po.WxCUserBasicInfo; +import com.simple.domain.vo.CUserBaseVo; import java.util.List; import java.util.Map; @@ -10,17 +11,13 @@ import java.util.Map; public interface WxCUserBasicInfoMapper extends CommonMapper { List findList(WxCUserBasicInfo wxCUserBasicInfo); - - - - List list(WxCUserBasicInfoDto record); void updateScore(WxCUserBasicInfo record); + + void updateNewId(CUserBaseVo record); long findCountBySex(WxCUserBasicInfoDto dto); long findCountByAge(WxCUserBasicInfoDto dto); - List> findListMap(WxCUserBasicInfoDto record); - } diff --git a/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java index b8adeacbd..2a680a346 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java @@ -8,68 +8,74 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; public interface WxCUserBasicInfoService { - /** + /** * 根据实体查询分页列表 * * @param record - * @param offset - * @param limit + * @param pageIndex + * @param pageSize * @return */ - PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); - - /** + PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); + + /** * 根据Id获得实体 * * @param id * @return */ WxCUserBasicInfo getById(Long id); - - /** + + /** * 保存或更新实体 * * @param record */ void saveOrUpdate(WxCUserBasicInfo record); + /** + * 保存或更新实体 + * + * @param record + */ + void updateObj(WxCUserBasicInfo record, Long newId); + /** * 根据Id删除实体 * * @param id */ void deleteById(Long id); - - - - PageInfo list(WxCUserBasicInfoDto record, Integer pageIndex, Integer pageSize); + + List findByPhone(String tenantId, String phone); /** * 修改会员积分 + * * @param record */ void updateScore(WxCUserBasicInfo record); /** - * 根据性别查询数量 - * @param sex + * 根据性别查询数量 + * + * @param dto * @return */ long findCountBySex(WxCUserBasicInfoDto dto); /** * 根据年龄查询数量 + * * @param dto * @return */ - long findCountByAge(WxCUserBasicInfoDto dto); - - - PageInfo> queryListMap(WxCUserBasicInfoDto wxCUserBasicInfo, Integer pageNum, Integer pageSize); + long findCountByAge(WxCUserBasicInfoDto dto); void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId); diff --git a/mallinkService/src/main/java/com/simple/service/WxCUserService.java b/mallinkService/src/main/java/com/simple/service/WxCUserService.java index 4a811283c..067d49d58 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCUserService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCUserService.java @@ -66,11 +66,16 @@ public interface WxCUserService { /** * 通过渠道获取会员信息 - * @param channel + * @param sceneList * @param pageIndex * @param pageSize * @return */ PageInfo listByChannel(List sceneList, Integer pageIndex, Integer pageSize); + + /** + * 计算当前用户成长值 + */ + void scoreCalculate(String tenantId, Long cUserId); } diff --git a/mallinkService/src/main/java/com/simple/service/WxMallApplyService.java b/mallinkService/src/main/java/com/simple/service/WxMallApplyService.java index 0036d6dbb..c18d62c70 100644 --- a/mallinkService/src/main/java/com/simple/service/WxMallApplyService.java +++ b/mallinkService/src/main/java/com/simple/service/WxMallApplyService.java @@ -28,9 +28,9 @@ public interface WxMallApplyService { /** * 保存或更新实体 * - * @param record - */ - void saveOrUpdate(WxMallApply record); + * @param record + */ + ResultData saveOrUpdate(WxMallApply record); /** * 根据Id删除实体 diff --git a/mallinkService/src/main/java/com/simple/service/WxMsgCallbackService.java b/mallinkService/src/main/java/com/simple/service/WxMsgCallbackService.java index f60d823e5..0414a7164 100644 --- a/mallinkService/src/main/java/com/simple/service/WxMsgCallbackService.java +++ b/mallinkService/src/main/java/com/simple/service/WxMsgCallbackService.java @@ -39,9 +39,9 @@ public interface WxMsgCallbackService { void deleteById(Long id); - void saveOrUpdate(String tenantId, String bid, String item, String sign); + void saveOrUpdate(String bid, String item, String sign); - void receivemodel(String tenantId, String bid, Map param); + void receivemodel(String bid, Map param); void receiveverifymodel(String bid, Map param); diff --git a/mallinkService/src/main/java/com/simple/service/WxShopService.java b/mallinkService/src/main/java/com/simple/service/WxShopService.java index bdca3d1b8..827c88560 100644 --- a/mallinkService/src/main/java/com/simple/service/WxShopService.java +++ b/mallinkService/src/main/java/com/simple/service/WxShopService.java @@ -46,4 +46,6 @@ public interface WxShopService { ResultData getMerchantShopByShopId(String tenantId, String shopId); + ResultData hasShopNumber(String tenantId, String shopNumber, Long id); + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java index 3e80e330a..b6738057a 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/DataTowerServiceImpl.java @@ -93,8 +93,8 @@ public class DataTowerServiceImpl implements DataTowerService { if(payinfo!=null){ BigDecimal receivepay = (BigDecimal) payinfo.get("receivepay"); BigDecimal pay = (BigDecimal) payinfo.get("pay"); - BigDecimal divide = receivepay.divide(pay); - double zjcjl = divide.doubleValue()*100; + BigDecimal divide = receivepay.divide(pay,2, BigDecimal.ROUND_HALF_UP); + double zjcjl = divide.multiply(new BigDecimal(100)).doubleValue(); datamap.put("ysje",receivepay); datamap.put("ssje",pay); datamap.put("zjsjl",zjcjl+"%"); diff --git a/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java index ef10a7758..07659fa57 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/MarkingDataReportServiceImpl.java @@ -195,6 +195,10 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { params.put("tenantId", tenantId); params.put("startTime", convertDate(markingCouponDataReportDto.getStartTime())); params.put("endTime", convertDateAndAdd(convertDate(markingCouponDataReportDto.getEndTime()), 1)); + if(markingCouponDataReportDto.getCouponType()!=null){ + params.put("couponType", markingCouponDataReportDto.getCouponType()); + } + PageHelper.startPage(pageIndex, pageSize); List couponDatalist = wxCouponOrderMapper.couponDataList(params); if(couponDatalist.isEmpty()){ diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java index 228614175..6b556183b 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java @@ -4,17 +4,20 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ImportParams; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.ErrorCode; import com.simple.common.IdWorker; import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.dto.WxCUserBasicInfoDto; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxCUserBasicInfo; +import com.simple.domain.vo.CUserBaseVo; import com.simple.exception.MallinkException; import com.simple.mapper.WxCUserBasicInfoMapper; import com.simple.mapper.WxCUserMapper; import com.simple.service.WxCUserBasicInfoService; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; @@ -26,14 +29,16 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.UUID; @Service public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { - - @Autowired + + @Autowired WxCUserBasicInfoMapper wxCUserBasicInfoMapper; @Autowired @@ -43,21 +48,19 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { public PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); } - - @Override - public PageInfo list(WxCUserBasicInfoDto record, Integer pageIndex, Integer pageSize) { - return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.list(record)); - } + public List findByPhone(String tenantId, String phone) { + WxCUserBasicInfo basicQ = new WxCUserBasicInfo(); + basicQ.setTenantId(tenantId); + basicQ.setPhone(phone); + return wxCUserBasicInfoMapper.select(basicQ); + } @Override public void updateScore(WxCUserBasicInfo record) { wxCUserBasicInfoMapper.updateScore(record); - } - - @Override public WxCUserBasicInfo getById(Long id) { @@ -69,144 +72,108 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + record.setId(idWorker.nextId()); wxCUserBasicInfoMapper.insertSelective(record); } else { wxCUserBasicInfoMapper.updateByPrimaryKeySelective(record); } } + @Override + public void updateObj(WxCUserBasicInfo record, Long newId) { + CUserBaseVo userBaseVo = new CUserBaseVo(); + org.springframework.beans.BeanUtils.copyProperties(record, userBaseVo); + userBaseVo.setNewId(newId); + wxCUserBasicInfoMapper.updateNewId(userBaseVo); + } + @Override public void deleteById(Long id) { wxCUserBasicInfoMapper.deleteByPrimaryKey(id); } + @Override + public long findCountBySex(WxCUserBasicInfoDto dto) { + return wxCUserBasicInfoMapper.findCountBySex(dto); + } - @Override - public long findCountBySex(WxCUserBasicInfoDto dto) { - - return wxCUserBasicInfoMapper.findCountBySex(dto); - } - - - - @Override - public long findCountByAge(WxCUserBasicInfoDto dto) { - return wxCUserBasicInfoMapper.findCountByAge(dto); - } @Override - public PageInfo> queryListMap(WxCUserBasicInfoDto record, Integer pageNum, Integer pageSize) { - return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findListMap(record)); + public long findCountByAge(WxCUserBasicInfoDto dto) { + return wxCUserBasicInfoMapper.findCountByAge(dto); } @Override public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { - - - WxCUser wxCUser = new WxCUser(); - wxCUser.setTenantId(tenantId); - List userlist = wxCUserMapper.findList(wxCUser); - - WxCUserBasicInfoDto basicInfoDto = new WxCUserBasicInfoDto(); - basicInfoDto.setTenantId(tenantId); - List memberlist = wxCUserBasicInfoMapper.list(basicInfoDto); - + WxCUserBasicInfo basicInfoQ = new WxCUserBasicInfo(); + basicInfoQ.setTenantId(tenantId); + List memberlist = wxCUserBasicInfoMapper.findList(basicInfoQ); XSSFWorkbook workbook; - String filepath="./uploads/"; + String filepath = "./uploads/"; File savefile = new File(filepath); if (!savefile.exists()) { savefile.mkdirs(); } - String filename=UUID.randomUUID()+".xlsx"; - filepath=filepath+filename; - try { - File file=new File(filepath); - workbook=new XSSFWorkbook(); - XSSFSheet sheetOne = workbook.createSheet("微信关注用户"); - Row row = sheetOne.createRow(0); - Cell openIdCell = row.createCell(0); - Cell nickNameCell = row.createCell(1); - Cell phoneCell = row.createCell(2); - Cell genderCell = row.createCell(3); - Cell cityCell = row.createCell(4); - Cell provinceCell = row.createCell(5); - Cell languageCell = row.createCell(6); - Cell countryCodeCell = row.createCell(7); - Cell registerIpCell = row.createCell(8); - Cell sceneadressCell = row.createCell(9); - - openIdCell.setCellValue("openId"); - nickNameCell.setCellValue("昵称"); - phoneCell.setCellValue("手机"); - genderCell.setCellValue("性别"); - cityCell.setCellValue("城市"); - provinceCell.setCellValue("省份"); - languageCell.setCellValue("语言"); - countryCodeCell.setCellValue("国家代码"); - registerIpCell.setCellValue("注册IP"); - sceneadressCell.setCellValue("场景值"); - - - for(int i=0;i datalist = ExcelImportUtil.importExcel(file.getInputStream(),WxCUserBasicInfo.class, params); - WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); - wxCUserBasicInfo.setTenantId(tenantId); - List list = wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); + List datalist = ExcelImportUtil.importExcel(file.getInputStream(), WxCUserBasicInfo.class, params); + final IdWorker idWorker = IdWorker.get(); - for(WxCUserBasicInfo user:datalist){ - WxCUserBasicInfo tempuser = list.stream().filter(u -> u.getPhone().equals(user.getPhone())).findFirst().get(); - if(tempuser!=null){ - tempuser.setSex(user.getSex()); - tempuser.setEducation(user.getEducation()); - tempuser.setBirthdate(user.getBirthdate()); - tempuser.setName(user.getName()); - wxCUserBasicInfoMapper.updateByPrimaryKeySelective(tempuser); + for (WxCUserBasicInfo userBase : datalist) { + Date curDate = new Date(); + if (StringUtils.isBlank(userBase.getPhone())) + continue; + WxCUserBasicInfo oldUserBase = null; + WxCUserBasicInfo userBaseQ = new WxCUserBasicInfo(); + userBaseQ.setTenantId(tenantId); + userBaseQ.setPhone(userBase.getPhone()); + List userBList = wxCUserBasicInfoMapper.select(userBaseQ); + if (userBList.size() > 0) { + oldUserBase = userBList.get(0); + } + + if (oldUserBase != null) { + oldUserBase.setTenantId(tenantId); + oldUserBase.setName(userBase.getName()); + oldUserBase.setSex(userBase.getSex()); + oldUserBase.setNickName(userBase.getNickName()); + oldUserBase.setEducation(userBase.getEducation()); + oldUserBase.setBirthdate(userBase.getBirthdate()); + oldUserBase.setAddress(userBase.getAddress()); + oldUserBase.setUpdateDate(userBase.getUpdateDate()); + oldUserBase.setCreateDate(userBase.getCreateDate()); } else { - user.setId(idWorker.nextId()); - wxCUserBasicInfoMapper.insertSelective(user); + userBase.setId(idWorker.nextId()); + userBase.setTenantId(tenantId); + } + + // update 昵称 + WxCUser cUserQ = new WxCUser(); + cUserQ.setTenantId(tenantId); + cUserQ.setPhone(userBase.getPhone()); + List userList = wxCUserMapper.select(cUserQ); + if (userList.size() > 0) { + WxCUser user = userList.get(0); + if (user != null) { + if (user.getNickName() != null) { + if (oldUserBase != null) { + oldUserBase.setNickName(user.getNickName()); + } else { + userBase.setNickName(user.getNickName()); + } + } + } + } + if (oldUserBase != null) { + wxCUserBasicInfoMapper.updateByPrimaryKeySelective(oldUserBase); + } else { + wxCUserBasicInfoMapper.insertSelective(userBase); } } } catch (Exception e) { - throw new MallinkException(500,"模板导入失败"); + throw new MallinkException(ErrorCode.MEM_IMPORT_ERR.getCode(), e.getMessage()); } - return new ResultData(Result.SUCCESS,"导入成功"); + return new ResultData(Result.SUCCESS, "导入成功"); } - } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java index 70f37bc97..758613089 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCUserServiceImpl.java @@ -5,7 +5,11 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.simple.domain.dto.WxCUserBasicInfoDto; import com.simple.domain.po.WxCUser; +import com.simple.domain.po.WxCouponOrder; +import com.simple.domain.po.WxScoreRules; import com.simple.mapper.WxCUserMapper; +import com.simple.mapper.WxCouponOrderMapper; +import com.simple.mapper.WxScoreRulesMapper; import com.simple.service.WxCUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -17,6 +21,12 @@ public class WxCUserServiceImpl implements WxCUserService { @Autowired WxCUserMapper wxCUserMapper; + @Autowired + WxCouponOrderMapper wxCouponOrderMapper; + + @Autowired + WxScoreRulesMapper wxScoreRulesMapper; + @Override public PageInfo listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { @@ -46,10 +56,12 @@ public class WxCUserServiceImpl implements WxCUserService { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); user.setId(idWorker.nextId()); + user.setLoginCount(1); user.setCreateDate(curr); user.setUpdateDate(curr); ret = wxCUserMapper.insertSelective(user); } else { + user.setLoginCount(user.getLoginCount() + 1); user.setUpdateDate(curr); ret =wxCUserMapper.updateByPrimaryKeySelective(user); } @@ -73,7 +85,39 @@ public class WxCUserServiceImpl implements WxCUserService { } - + @Override + public void scoreCalculate(String tenantId, Long cUserId) { + + WxCUser user = wxCUserMapper.selectByPrimaryKey(cUserId); + if (user == null) { + return; + } + // 登录次数 + // login count + int login_count = user.getLoginCount(); + + // coupon order + WxCouponOrder couponOrder = new WxCouponOrder(); + couponOrder.setTenantId(tenantId); + couponOrder.setCUserId(cUserId); + int counponCount = wxCouponOrderMapper.selectCount(couponOrder); + + // score rule + WxScoreRules scoreRuleQ = new WxScoreRules(); + scoreRuleQ.setTenantId(tenantId); + WxScoreRules scoreRules = wxScoreRulesMapper.selectOne(scoreRuleQ); + if (scoreRules != null) { + Integer score = + (login_count / scoreRules.getLoginCount()) * scoreRules.getLoginScoreNumber() + + (counponCount / scoreRules.getConsumptionScoreNumber()) * scoreRules.getConsumptionAmount(); + if (user != null) { + user.setScore(score); + user.setUpdateDate(new Date()); + wxCUserMapper.updateByPrimaryKeySelective(user); + } + } + + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMallApplyServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMallApplyServiceImpl.java index e9b3a5a51..54771c44c 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMallApplyServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMallApplyServiceImpl.java @@ -53,7 +53,18 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { } @Override - public void saveOrUpdate(WxMallApply record) { + public ResultData saveOrUpdate(WxMallApply record) { + + WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); + wxMsgValidationcode.setTenantId("1"); + wxMsgValidationcode.setCode(record.getVerifyCode()); + wxMsgValidationcode.setPhone(record.getPhone()); + List wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); + Date currentdate = new Date(); + wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> + validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); + if(wxmsgvalidationcodelist.size()==0) return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND.getCode(),ErrorCode.MSG_VERIFY_CODE_NOT_FOUND.getMessage(),true); + if (record.getId() == null) { final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); @@ -62,6 +73,7 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { } else { wxMallApplyMapper.updateByPrimaryKeySelective(record); } + return new ResultData(200,"操作成功",true); } @Override diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java index 70a0ff781..93f409437 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java @@ -334,6 +334,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { if(paycount==1){//12 WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setId(idWorker.nextId()); + wxBillRent.setShopId(wxshop.getId()); wxBillRent.setPayStatus(0); wxBillRent.setPay(new BigDecimal(0)); wxBillRent.setTenantId(wxshop.getTenantId()); @@ -365,6 +366,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setId(idWorker.nextId()); + wxBillRent.setShopId(wxshop.getId()); wxBillRent.setPayStatus(0); wxBillRent.setPay(new BigDecimal(0)); wxBillRent.setTenantId(wxshop.getTenantId()); @@ -397,6 +399,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setId(idWorker.nextId()); + wxBillRent.setShopId(wxshop.getId()); wxBillRent.setPayStatus(0); wxBillRent.setPay(new BigDecimal(0)); wxBillRent.setTenantId(wxshop.getTenantId()); @@ -428,6 +431,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setId(idWorker.nextId()); + wxBillRent.setShopId(wxshop.getId()); wxBillRent.setPayStatus(0); wxBillRent.setPay(new BigDecimal(0)); wxBillRent.setTenantId(wxshop.getTenantId()); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgCallbackServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgCallbackServiceImpl.java index beb9fe8c1..f8afbcb90 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgCallbackServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgCallbackServiceImpl.java @@ -63,58 +63,49 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { } @Override - public void saveOrUpdate(String tenantId,String bid, String item, String sign) { + public void saveOrUpdate(String tenantId, String item, String sign) { WxMsgConfig wxMsgConfig = new WxMsgConfig(); wxMsgConfig.setTenantId(tenantId); - wxMsgConfig.setBid(bid); List list = wxMsgConfigMapper.findList(wxMsgConfig); - if(list.size()==1) { - List wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); - wxMsgConfig = list.get(0); - wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size()); - wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); - - for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { - wxMsgCallback.setTenantId(wxMsgConfig.getTenantId()); - wxMsgCallback.setSign(sign); - wxMsgCallback.setCreatetime(new Date()); - wxMsgCallbackMapper.insertSelective(wxMsgCallback); - } + List wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); + wxMsgConfig = list.get(0); + wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size()); + wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); + + for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { + wxMsgCallback.setTenantId(wxMsgConfig.getTenantId()); + wxMsgCallback.setSign(sign); + wxMsgCallback.setCreatetime(new Date()); + wxMsgCallbackMapper.insertSelective(wxMsgCallback); } + } @Override - public void receivemodel(String tenantId, String bid, Map param) { - WxMsgConfig wxMsgConfig = new WxMsgConfig(); - wxMsgConfig.setTenantId(tenantId); - wxMsgConfig.setBid(bid); - List list = wxMsgConfigMapper.findList(wxMsgConfig); - if(list.size()==1) { + public void receivemodel(String tenantId, Map param) { + + WxMsgModel wxMsgModel = new WxMsgModel(); + wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); + wxMsgModel.setTenantId(tenantId); + wxMsgModel = wxMsgModelMapper.findList(wxMsgModel).get(0); + wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); + wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); - WxMsgModel wxMsgModel = new WxMsgModel(); - wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); - wxMsgModel = wxMsgModelMapper.findList(wxMsgModel).get(0); - wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); - wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); - } } @Override - public void receiveverifymodel(String bid, Map param) { - WxMsgConfig wxMsgConfig = new WxMsgConfig(); - wxMsgConfig.setBid(bid); - List list = wxMsgConfigMapper.findList(wxMsgConfig); - if(list.size()==1) { + public void receiveverifymodel(String tenantId, Map param) { + + WxMsgValidationcodeModel wxMsgModel = new WxMsgValidationcodeModel(); + wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); + wxMsgModel.setTenantId(tenantId); + wxMsgModel = wxMsgValidationcodeModelMapper.findList(wxMsgModel).get(0); + wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); + wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); - WxMsgValidationcodeModel wxMsgModel = new WxMsgValidationcodeModel(); - wxMsgModel.setModelId(Integer.valueOf(param.get("id"))); - wxMsgModel = wxMsgValidationcodeModelMapper.findList(wxMsgModel).get(0); - wxMsgModel.setStatus(param.get("status").equals("1")?Integer.valueOf(param.get("status")):0); - wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); - } } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgModelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgModelServiceImpl.java index 65ac98651..f49628b3f 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgModelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgModelServiceImpl.java @@ -23,8 +23,8 @@ import java.util.*; @Service public class WxMsgModelServiceImpl implements WxMsgModelService { - - @Autowired + + @Autowired WxMsgModelMapper wxMsgModelMapper; @Autowired @@ -47,11 +47,13 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { WxMsgConfig wxMsgConfig = new WxMsgConfig(); wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); List wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); - if(wxMsgConfigs.size()==0)return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); + if (wxMsgConfigs.size() == 0) + return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); wxMsgConfig = wxMsgConfigs.get(0); String secret = wxMsgConfig.getSecret(); String bid = wxMsgConfig.getBid(); + String signature = wxMsgModel.getSignature(); String content = wxMsgModel.getContent(); //查看用户最新数据是否存在 @@ -61,7 +63,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { } if (wxMsgModel.getId() != null && wxMsgModels.size() == 1) { WxMsgModel wxmsgmodel = wxMsgModels.get(0); - if(wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { + if (wxmsgmodel.getContent().equals(wxMsgModel.getContent()) && wxmsgmodel.getSignature().equals(wxMsgModel.getSignature())) { return new ResultData(ResultData.SUCCESS, "修改成功"); } } @@ -71,7 +73,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { message.put("bid", bid); message.put("signature", signature); message.put("content", content); - message.put("notify_url",wxMsgConfig.getModelnotifyurl()); + message.put("notify_url", wxMsgConfig.getModelnotifyurl()); StringBuilder sb = new StringBuilder(); Set> entries = message.entrySet(); @@ -94,7 +96,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { params.put("data", data); params.put("sc", sc); } catch (Exception e) { - e.printStackTrace(); + throw new RuntimeException("创建模板失败"); } String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; @@ -115,21 +117,27 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); } return new ResultData(Result.SUCCESS, "创建模板成功"); - }else if(ret.equals("-6")){ + } else if (ret.equals("-6")) { if (wxMsgModel.getId() == null) { final IdWorker idWorker = IdWorker.get(); wxMsgModel.setId(idWorker.nextId()); wxMsgModel.setTenantId(wxMsgModel.getTenantId()); - String data = jsonObjectResult.get("data").toString(); - wxMsgModel.setModelId(Integer.valueOf(data)); wxMsgModel.setCreatetime(new Date()); wxMsgModel.setStatus(1); wxMsgModelMapper.insertSelective(wxMsgModel); } else { wxMsgModelMapper.updateByPrimaryKeySelective(wxMsgModel); } - }else if (ret == "-4") { + } else if (ret.equals("-4")) { return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); + } else if (ret.equals("-5")) { + return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); + } else if (ret.equals("-3")) { + return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); + } else if (ret.equals("-2")) { + return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); + } else if (ret.equals("-1")) { + return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); } return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgServiceImpl.java index 42250e008..934fe1c61 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.ErrorCode; import com.simple.common.IdWorker; import com.simple.common.Result; import com.simple.common.ResultData; @@ -196,7 +197,7 @@ public class WxMsgServiceImpl implements WxMsgService { params.put("data", data); params.put("sc", sc); } catch (Exception e) { - e.printStackTrace(); + throw new RuntimeException("发送短信失败"); } String requestUrl = "https://webapp.wiwide.com/apisms/send"; @@ -222,7 +223,7 @@ public class WxMsgServiceImpl implements WxMsgService { if (ret.equals("1")) { return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态"); } else { - return new ResultData(Result.SUCCESS, "短信发送发败"); + return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "短信发送发败"); } } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeModelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeModelServiceImpl.java index 16331569c..52642c936 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeModelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeModelServiceImpl.java @@ -54,6 +54,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM String secret = wxMsgConfig.getSecret(); String bid = wxMsgConfig.getBid(); + String signature = wxMsgModel.getSignature(); String content = wxMsgModel.getContent(); //查看用户最新数据是否存在 @@ -100,7 +101,7 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM params.put("data", data); params.put("sc", sc); } catch (Exception e) { - e.printStackTrace(); + throw new RuntimeException("创建模板失败"); } String requestUrl = "https://webapp.wiwide.com/apisms/addtemplate"; @@ -126,16 +127,22 @@ public class WxMsgValidationcodeModelServiceImpl implements WxMsgValidationcodeM final IdWorker idWorker = IdWorker.get(); wxMsgModel.setId(idWorker.nextId()); wxMsgModel.setTenantId(wxMsgModel.getTenantId()); - String data = jsonObjectResult.get("data").toString(); - wxMsgModel.setModelId(Integer.valueOf(data)); wxMsgModel.setCreatetime(new Date()); wxMsgModel.setStatus(1); wxMsgValidationcodeModelMapper.insertSelective(wxMsgModel); } else { wxMsgValidationcodeModelMapper.updateByPrimaryKeySelective(wxMsgModel); } - }else if (ret == "-4") { + }else if (ret.equals("-4")) { return new ResultData(ErrorCode.MSG_SIGNATURE_CONTENT_ERROR.getCode(), "短信签名或内容错误"); + }else if (ret.equals("-5")) { + return new ResultData(ErrorCode.MSG_TEMPLATE_NOT_FOUND.getCode(), "短信模板不存在"); + }else if (ret.equals("-3")) { + return new ResultData(ErrorCode.MSG_REQUEST_PARAMS_ERROR.getCode(), "参数错误"); + }else if (ret.equals("-2")) { + return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "发送短信失败"); + }else if (ret.equals("-1")) { + return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(), "接口请求错误"); } return new ResultData(ErrorCode.MSG_TEMPLATE_CREATE_ERROR.getCode(), "创建模板失败"); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java index 4993446e2..851c47822 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMsgValidationcodeServiceImpl.java @@ -97,7 +97,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic WxMsgConfig wxMsgConfig = new WxMsgConfig(); wxMsgConfig.setAppid(wxMsgValidationcode.getAppid()); List wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); - if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); + if (wxMsgConfigs.size() == 0) new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); wxMsgConfig = wxMsgConfigs.get(0); WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); @@ -150,7 +150,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic params.put("data", data); params.put("sc", sc); } catch (Exception e) { - throw new RuntimeException("发送失败"); + throw new RuntimeException("发送验证码失败"); } String requestUrl = "https://webapp.wiwide.com/apisms/send"; @@ -171,7 +171,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); return new ResultData(Result.SUCCESS,"发送成功"); } - return new ResultData(500,"发送失败"); + return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); } @@ -183,9 +183,9 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic Date currentdate = new Date(); wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); - if(wxmsgvalidationcodelist.size()>0) return new ResultData(200,"验证码存在",true); + if(wxmsgvalidationcodelist.size()>0) return new ResultData(Result.SUCCESS,"验证码存在",true); - return new ResultData(500,"验证码不存在或过期",false); + return new ResultData(Result.ERROR,"验证码不存在或过期",false); } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java index 2aac9638d..435146565 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxOrderServiceImpl.java @@ -12,6 +12,7 @@ import com.simple.domain.vo.WxOrderCVo; import com.simple.enums.*; import com.simple.exception.MallinkException; import com.simple.mapper.*; +import com.simple.service.WxCUserService; import com.simple.service.WxOrderService; import com.simple.utils.RedisLock; import org.apache.log4j.Logger; @@ -56,6 +57,9 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxCouponOrderMapper wxCouponOrderMapper; + @Autowired + WxCUserService wxCUserService; + @Override public PageInfo listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.findList(record)); @@ -497,6 +501,13 @@ public class WxOrderServiceImpl implements WxOrderService { logger.error("保存订单:" + e.getMessage()); throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); } + + // 成长值 计算 + try { + wxCUserService.scoreCalculate(user.getTenantId(), user.getId()); + } catch (Exception e) { + logger.error("成长值:" + e.getMessage()); + } return ret; } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java index a2b8972e0..4f446d2b9 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxRefundOrderServiceImpl.java @@ -479,7 +479,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { } record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_FAIL.getCode()); wxRefundOrderMapper.updateByPrimaryKey(record); - return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); + return new ResultData(ErrorCode.REFUND_ORDER_ERROR.getCode(), errMsg, returnMap); } } else { // 服务商模式 @@ -543,7 +543,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { return new ResultData(Result.SUCCESS, "退款订单申请成功", returnMap); } catch (Exception e) { logger.error("微信退款订单更新入库出错: " + e.getMessage() + ", record: " + record.toString()); - throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR); + throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), "订单状态更新失败"); } } else { logger.error("微信退款订单申请失败: " + response); @@ -558,7 +558,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { } record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_FAIL.getCode()); wxRefundOrderMapper.updateByPrimaryKey(record); - return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); + throw new MallinkException(ErrorCode.REFUND_ORDER_ERROR.getCode(), errMsg); } } } else { diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java index 97fe036d3..fd662b574 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java @@ -1,6 +1,8 @@ package com.simple.service.impl; import java.util.*; +import java.util.stream.Collectors; + import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.simple.common.ResultData; @@ -41,7 +43,6 @@ public class WxShopServiceImpl implements WxShopService { public void saveOrUpdate(WxShop record) { if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); record.setStatus(0); @@ -78,5 +79,19 @@ public class WxShopServiceImpl implements WxShopService { return new ResultData(ResultData.SUCCESS,"",map); } + @Override + public ResultData hasShopNumber(String tenantId, String shopNumber, Long id) { + WxShop wxShop = new WxShop(); + wxShop.setTenantId(tenantId); + wxShop.setShopNumber(shopNumber); + List list = wxShopMapper.findList(wxShop); + if(id!=null){ + List collect = list.stream().filter(s -> !s.getId().equals(id)?true:false).collect(Collectors.toList()); + return new ResultData(ResultData.SUCCESS,"查询成功",collect.size()>0?true:false); + } + + return new ResultData(ResultData.SUCCESS,"查询成功",list.size()>0?true:false); + } + } diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index d4cefec11..779cf9770 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -21,7 +21,7 @@ `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, - `create_date`,`update_date`,`tenant_id`,`name`,level,nick_name + `create_date`,`update_date`,`tenant_id`,`name`, level, nick_name @@ -32,7 +32,7 @@ - and c.`tenant_id` like concat('%', #{tenantId},'%') + and `tenant_id` = #{tenantId} @@ -67,20 +67,16 @@ and `tag_id` = #{tagId} - - and `c_user_id` = #{cUserId} - - - and c.`create_date` = #{createDate} + and `create_date` = #{createDate} - and c.`update_date` = #{updateDate} + and `update_date` = #{updateDate} - and c.`name` like concat('%', #{name},'%') + and `name` like concat('%', #{name},'%') and id in @@ -103,38 +99,14 @@ cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.level,cb.nick_name - - update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId} - and c_user_id=#{cUserId} + and id=#{cUserId} + + + update wx_c_user_basic_info set id=#{newId} where tenant_id=#{tenantId} + and id = #{id} - - - diff --git a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml index 6980fb8a8..a8f730304 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserMapper.xml @@ -1,214 +1,203 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,`city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,`qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,`update_date`,`create_date`,`app_id`,`token`,`expire_time` - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `open_id` like concat('%', #{openId},'%') - - - - - and `union_id` like concat('%', #{unionId},'%') - - - - - and `nick_name` like concat('%', #{nickName},'%') - - - - - and `gender` = #{gender} - - - - - and `avatar_url` like concat('%', #{avatarUrl},'%') - - - - - and `phone` like concat('%', #{phone},'%') - - - - - and `pure_phone` like concat('%', #{purePhone},'%') - - - - - and `city` like concat('%', #{city},'%') - - - - - and `province` like concat('%', #{province},'%') - - - - - and `language` like concat('%', #{language},'%') - - - - - and `country_code` like concat('%', #{countryCode},'%') - - - - - and `register_ip` like concat('%', #{registerIp},'%') - - - - - and `verify_code_phone` like concat('%', #{verifyCodePhone},'%') - - - - - and `qrcode_source` like concat('%', #{qrcodeSource},'%') - - - - - and `scene` like concat('%', #{scene},'%') - - - - - and `scene_address` like concat('%', #{sceneAddress},'%') - - - - - and `session_key` like concat('%', #{sessionKey},'%') - - - - - and `score` = #{score} - - - - - and `update_date` = #{updateDate} - - - - - and `create_date` = #{createDate} - - - - - and `app_id` like concat('%', #{appId},'%') - - - - - and `token` like concat('%', #{token},'%') - - - - - and `expire_time` = #{expireTime} - - - - and id in - - #{idItem} - - - order by ${sortColumns} + + `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,`city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,`qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,`update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, `login_count` - - - + select + + from wx_c_user + + + + - select * from wx_c_user where `token` = #{token} - - - - - - + + + + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index d5a77dca8..945ee2207 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -27,71 +27,61 @@ and `id` = #{id} - and `tenant_id` like concat('%', #{tenantId},'%') - and `merchant_id` = #{merchantId} - and `coupon_id` = #{couponId} - and `type` = #{type} - and `title` like concat('%', #{title},'%') - and `target_ad` = #{targetAd} - - - and `business` like concat('%', #{business},'%') + + and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) + + + and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business})))) and `begin_time` = #{beginTime} - and `end_time` = #{endTime} - and `status` = #{status} - and `create_date` = #{createDate} - and `update_date` = #{updateDate} - and `sub_target_id` = #{subTargetId} - and id in diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 6e8b40a1b..58e3336e5 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -1,238 +1,214 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `merchant_id` = #{merchantId} - - - - - and `type` = #{type} - - - - - and `cover_img` like concat('%', #{coverImg},'%') - - - - - and `title` like concat('%', #{title},'%') - - - - - and `sub_title` like concat('%', #{subTitle},'%') - - - - - and `sale_price` = #{salePrice} - - - - - and `use_price` = #{usePrice} - - - - - and `use_limit_quantity` = #{useLimitQuantity} - - - - - and `target_ad` = #{targetAd} - - - - - and `send_type` = #{sendType} - - - - - - - and `valid_type` = #{validType} - - - - - and `valid_start_date` = #{validStartDate} - - - - - and `valid_end_date` = #{validEndDate} - - - - - and `valid_days` = #{validDays} - - - - - and `detail` like concat('%', #{detail},'%') - - - - - and `price` = #{price} - - - - - and `unit` = #{unit} - - - - - and `remain_inventory` = #{remainInventory} - - - - - and `inventory` = #{inventory} - - - - - and `remark` like concat('%', #{remark},'%') - - - - - and `status` = #{status} - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - - and `business` like concat('%', #{business},'%') - - - - and id in - - #{idItem} - - - order by ${sortColumns} - + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + + and `merchant_id` = #{merchantId} + + + + and `type` = #{type} + + + + and `cover_img` like concat('%', #{coverImg},'%') + + + + and `title` like concat('%', #{title},'%') + + + + and `sub_title` like concat('%', #{subTitle},'%') + + + + and `sale_price` = #{salePrice} + + + + and `use_price` = #{usePrice} + + + + and `use_limit_quantity` = #{useLimitQuantity} + + + + and `target_ad` = #{targetAd} + + + + and `send_type` = #{sendType} + + + + + and `valid_type` = #{validType} + + + + and `valid_start_date` = #{validStartDate} + + + + and `valid_end_date` = #{validEndDate} + + + + and `valid_days` = #{validDays} + + + + and `detail` like concat('%', #{detail},'%') + + + and `price` = #{price} + + + and `unit` = #{unit} + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + and `remain_inventory` = #{remainInventory} + + + + and `inventory` = #{inventory} + + + + and `remark` like concat('%', #{remark},'%') + + + + and `status` = #{status} + + + + and `create_date` = #{createDate} + + + + and `update_date` = #{updateDate} + + + + and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) + + + and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business})))) + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, m.img_url,m.name,m.link_phone,m.status, s.addr,s.shop_number,s.baidu_poi, @@ -241,57 +217,58 @@ - - - - - + + + + c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, m.img_url,m.name,m.link_phone,m.status, s.addr,s.shop_number,s.baidu_poi, mb.building_name,mf.floor_name - - - + + + update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 5aca80900..8ecfc2755 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -387,11 +387,17 @@