From 6dd38486472dd96dc060f0ce940b2544664bd767 Mon Sep 17 00:00:00 2001 From: xuao Date: Tue, 9 Sep 2025 05:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=20=20=E4=B8=BB=E9=A1=B5=E6=A8=A1=E5=9D=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GetBackPwdController.java | 342 ++++++++ .../me/mofun/controller/IndexController.java | 329 ++++---- .../me/mofun/controller/ListController.java | 227 +++--- .../entity/dto/ProductSpellbuyproductDTO.java | 13 + .../dto/UserSpellbuyproductRecordDTO.java | 14 + src/main/resources/mapper/ShareinfoMapper.xml | 4 +- .../mapper/SpellbuyproductMapper.xml | 479 ++++++++++- .../resources/mapper/SpellbuyrecordMapper.xml | 768 +++++++++++++----- 8 files changed, 1718 insertions(+), 458 deletions(-) create mode 100644 src/main/java/me/mofun/controller/GetBackPwdController.java create mode 100644 src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java create mode 100644 src/main/java/me/mofun/entity/dto/UserSpellbuyproductRecordDTO.java diff --git a/src/main/java/me/mofun/controller/GetBackPwdController.java b/src/main/java/me/mofun/controller/GetBackPwdController.java new file mode 100644 index 0000000..2153186 --- /dev/null +++ b/src/main/java/me/mofun/controller/GetBackPwdController.java @@ -0,0 +1,342 @@ +package me.mofun.controller; + + +import me.mofun.entity.User; +import me.mofun.service.IUserService; +import me.mofun.util.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.util.Random; + +@Controller +public class GetBackPwdController { + + @Autowired + private IUserService userService; + + /** + * 跳转到找回密码首页 + */ + @GetMapping("/getbackpwd/index") + public String index() { + return "index"; + } + + /** + * 验证找回密码信息 + */ + @PostMapping("/getbackpwd/getBackPwd") + public void getBackPwd(HttpServletRequest request, HttpServletResponse response, + @RequestParam String rnd, @RequestParam String mail) throws IOException { + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + Cookie[] cookies = request.getCookies(); + if (request.isRequestedSessionIdFromCookie() && cookies != null) { + for (Cookie cookie : cookies) { + if ("rndCode".equals(cookie.getName())) { + String rndCode = cookie.getValue(); + if (rnd.trim().equalsIgnoreCase(rndCode)) { + User user = userService.userByName(mail); + if (user == null) { + out.print("false"); + } else { + out.print("1"); + } + } else { + out.print("3"); + } + break; + } + } + } + out.flush(); + out.close(); + } + + /** + * 生成随机验证码图片 + */ + @GetMapping("/getbackpwd/getRandomCode") + public void getRandomCode(HttpServletRequest request, HttpServletResponse response) { + response.setContentType("image/jpeg");//设置相应类型,告诉浏览器输出的内容为图片 + response.setHeader("Pragma", "No-cache");//设置响应头信息,告诉浏览器不要缓存此内容 + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expire", 0); + RandomValidateCode randomValidateCode = new RandomValidateCode(); + try { + randomValidateCode.getRandcode(request, response);//输出图片方法 + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 跳转到邮箱验证页面 + */ + @GetMapping("/getbackpwd/findemailcheck") + public String findemailcheck() { + return "findemailcheck"; + } + + /** + * 跳转到手机验证页面并发送验证码 + */ + @GetMapping("/getbackpwd/findmobilecheck") + public String findmobilecheck(@RequestParam String mail) { + String key = MD5Util.encode(mail) + MD5Util.encode(DateUtil.dateTimeToStr(new Date())) + Base64.getEncode(mail); + try { + SendFindPwdCode(mail); + } catch (Exception ex) { + ex.printStackTrace(); + } + return "findmobilecheck"; + } + + /** + * 发送找回密码邮件 + */ + @PostMapping("/getbackpwd/sendFindPwdMail") + public void sendFindPwdMail(HttpServletRequest request, HttpServletResponse response, + @RequestParam String rnd, @RequestParam String mail) throws IOException { + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + String key = MD5Util.encode(mail) + MD5Util.encode(DateUtil.dateTimeToStr(new Date())) + Base64.getEncode(mail); + String html = "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "
首页" + + "我的" + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "帮助
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
亲爱的 " + mail + "

您好!请点击下面的按钮,重新设置您的密码:

重设密码
如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成重设密码。
" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/getbackpwd/findreset.html?key=" + key + "

如果您现在想起了您的密码:

可不必重设密码,继续用原来的密码登录。

" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
此邮件由系统自动发出,请勿回复!
感谢您对" + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "(" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + ")的支持,祝您好运!
" + + "
" + + "" + + "" + + "" + + "" + + "
" + ApplicationListenerImpl.sysConfigureJson.getDomain() + " " + ApplicationListenerImpl.sysConfigureJson.getIcp() + "
"; + + Cookie[] cookies = request.getCookies(); + if (request.isRequestedSessionIdFromCookie() && cookies != null) { + for (Cookie cookie : cookies) { + if ("rndCode".equals(cookie.getName())) { + String rndCode = cookie.getValue(); + if (rnd.trim().equalsIgnoreCase(rndCode)) { + if (MemCachedClientHelp.getIMemcachedCache().get(MD5Util.encode(mail)) == null) { + boolean flag = EmailUtil.sendEmailOverSSL( + ApplicationListenerImpl.sysConfigureJson.getMailName(), + ApplicationListenerImpl.sysConfigureJson.getMailPwd(), + mail, + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "取回密码", + html); + if (flag) { + MemCachedClientHelp.getIMemcachedCache().put(MD5Util.encode(mail), mail, new Date(10 * 60 * 1000)); + out.print("0"); + } else { + out.print("false"); + } + } else { + out.print("3"); + } + } else { + out.print("2"); + } + break; + } + } + } + out.flush(); + out.close(); + } + + /** + * 跳转到密码重置页面 + */ + @GetMapping("/getbackpwd/findreset") + public String findreset(@RequestParam String key, HttpServletRequest request) throws UnsupportedEncodingException { + if (StringUtil.isNotBlank(key)) { + key = key.substring(64); + String mail = Base64.getDecode(key); + if (StringUtil.isNotBlank(mail)) { + User user = userService.userByName(mail); + if (user != null) { + request.setAttribute("user", user); + request.setAttribute("mail", mail); + return "findreset"; + } + } + } + return "index_index"; + } + + /** + * 验证手机短信验证码 + */ + @PostMapping("/getbackpwd/findMobileReset") + public void findMobileReset(HttpServletRequest request, HttpServletResponse response, + @RequestParam String rnd, @RequestParam String mail) throws IOException { + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + String phone = null; + if (mail.matches("^1[0-9]{10}$")) { + phone = mail; + } + try { + Object validateCodeObj = MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone)); + if (validateCodeObj != null && validateCodeObj.toString().equals(rnd)) { + out.print("0"); + } else { + out.print("-1"); + } + } catch (Exception ex) { + out.print("-1"); + ex.printStackTrace(); + } + out.flush(); + out.close(); + } + + /** + * 更新密码 + */ + @PostMapping("/getbackpwd/updatePwd") + public void updatePwd(HttpServletResponse response, + @RequestParam String mail, @RequestParam String newPwd) throws IOException { + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + User user = userService.userByName(mail); + if (user != null) { + user.setUserPwd(newPwd); + userService.add(user); + out.print("0"); + } else { + out.print("false"); + } + out.flush(); + out.close(); + } + + /** + * 跳转到找回密码成功页面 + */ + @GetMapping("/getbackpwd/findok") + public String findok() { + return "findok"; + } + + /** + * 发送手机短信验证码 + */ + @PostMapping("/getbackpwd/regSendMes") + public void regSendMes(HttpServletResponse response, @RequestParam String mail) throws IOException { + response.setContentType("text/plain;charset=UTF-8"); + PrintWriter out = response.getWriter(); + + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if (mail.matches("^1[0-9]{10}$")) { + String phone = mail; + if (MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone)) == null) { + try { + boolean result = SendSMS.sendSMS(phone, ran); + if (!result) { + out.print("false"); + out.flush(); + out.close(); + return; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran, new Date(2 * 60 * 1000)); + out.print("0"); + } catch (Exception e) { + e.printStackTrace(); + out.print("error"); + } + } else { + out.print("2"); + } + } else { + out.print("error"); + } + out.flush(); + out.close(); + } + + /** + * 发送找回密码时的手机短信验证码 + */ + private boolean SendFindPwdCode(String mail) throws Exception { + Random random = new Random(); + String ran = ""; + for (int i = 0; i < 6; i++) { + ran += random.nextInt(9); + } + if (mail.matches("^1[0-9]{10}$")) { + String phone = mail; + if (MemCachedClientHelp.getIMemcachedCache().get(Base64.getEncode(phone)) == null) { + boolean result = SendSMS.sendSMS(phone, ran); + if (!result) { + return false; + } + MemCachedClientHelp.getIMemcachedCache().put(Base64.getEncode(phone), ran, new Date(2 * 60 * 1000)); + return true; + } else { + return false; + } + } else { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/controller/IndexController.java b/src/main/java/me/mofun/controller/IndexController.java index d69bd47..d7926ef 100644 --- a/src/main/java/me/mofun/controller/IndexController.java +++ b/src/main/java/me/mofun/controller/IndexController.java @@ -1,12 +1,15 @@ package me.mofun.controller; import me.mofun.entity.*; +import me.mofun.entity.dto.ProductSpellbuyproductDTO; import me.mofun.entity.pojo.BuyHistoryJSON; import me.mofun.entity.pojo.ProductJSON; import me.mofun.entity.pojo.UserJSON; import me.mofun.entity.vo.Pagination; import me.mofun.service.*; -import me.mofun.util.*; +import me.mofun.util.ApplicationListenerImpl; +import me.mofun.util.MemCachedClientHelp; +import me.mofun.util.UserNameUtil; import me.mofun.utils.ViewUtils; import net.sf.json.JSONArray; import org.springframework.beans.factory.annotation.Autowired; @@ -22,25 +25,25 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.util.ArrayList; import java.util.Date; import java.util.List; /** * 首页控制器 + * 从Struts2 Action改造为Spring MVC Controller */ @Controller @RequestMapping("/") public class IndexController { - // 常量定义:分页大小、缓存时间(毫秒)等 + // 常量定义 private static final int PAGE_SIZE_SMALL = 2; private static final int PAGE_SIZE_MEDIUM = 5; private static final int PAGE_SIZE_LARGE = 8; private static final int PAGE_SIZE_XLARGE = 10; private static final int PAGE_SIZE_XXLARGE = 100; - private static final long CACHE_EXPIRE_MS = 5000; // 缓存过期时间:5秒 + private static final long CACHE_EXPIRE_MS = 5000; // 用户等级经验值常量 private static final int LEVEL_1_EXP = 10000; @@ -52,7 +55,7 @@ public class IndexController { private static final int LEVEL_7_EXP = 5000000; private static final int LEVEL_8_EXP = 10000000; - // 服务依赖(构造器注入) + // 服务依赖 private final ISpellbuyrecordService spellbuyrecordService; private final ILatestlotteryService latestlotteryService; private final ISpellbuyproductService spellbuyproductService; @@ -60,7 +63,7 @@ public class IndexController { private final IRecommendService recommendService; private final IUserService userService; - // 静态缓存(需注意线程安全,使用volatile保证可见性) + // 静态缓存 private static volatile List nowBuyProductList; private static volatile List newRecordList; private static volatile Long allBuyCount; @@ -70,9 +73,8 @@ public class IndexController { private static volatile Long beginDateByNowBuyProduct; private static volatile Long nowDateByNewRecord = System.currentTimeMillis(); private static volatile Long beginDateByNewRecord; - private static volatile List newsList; // 新闻缓存 + private static volatile List newsList; - // 构造器注入 @Autowired public IndexController(ISpellbuyrecordService spellbuyrecordService, ILatestlotteryService latestlotteryService, @@ -92,69 +94,44 @@ public class IndexController { private ViewUtils viewUtils; private final String module = "index"; - @GetMapping("/show") - public String show() { - return null; - } - /** - * 首页入口(改造后) + * 首页 */ - @GetMapping("/index") - public ModelAndView index(Model model) { - - - // 1. 首页广告位下方推荐(取2条最新商品) - Pagination phoneDigitalPage = spellbuyrecordService.indexNewProductList(0, 2); - List newProductList = convertToProductJSONList((List) phoneDigitalPage.getList(), true); - model.addAttribute("newProductList", newProductList); - - // 2. 最新揭晓列表 - List objList = latestlotteryService.indexWinningScroll(); - List latestlotteryList = new ArrayList<>(); - for (Latestlottery lottery : objList) { - Latestlottery item = new Latestlottery(); - item = lottery; // 实际项目建议使用BeanUtils.copyProperties - String userName = getMaskedUserName(lottery.getUserName(), lottery.getBuyUser()); - item.setBuyUser(userName); - latestlotteryList.add(item); - } - model.addAttribute("latestlotteryList", latestlotteryList); - - // 3. 每日推荐商品 - List objectList = recommendService.getRecommend(); - ProductJSON recommendJSON = null; - if (objectList != null && !objectList.isEmpty()) { - recommendJSON = convertToRecommendProduct(objectList.get(0)); + @GetMapping("/") + public String index(Model model) { + // 检查系统授权 + if (!ApplicationListenerImpl.sysConfigureAuth) { + model.addAttribute("errorMsg", "该系统授权已过期,请联系管理员重新授权!谢谢合作。"); + return "error/authorization"; } - model.addAttribute("recommendJSON", recommendJSON); - // 4. 新闻列表(缓存处理) - if (newsList == null) { - newsList = newsService.indexNews(10, 3); // 10: 新闻公告类型(参考NewsType表) - } - model.addAttribute("newsList", newsList); + // 初始化首页数据 + initNewProductList(model); + initLatestLotteryList(model); + initRecommendProduct(model); + initNewsList(model); + initIndexImgList(model); +// initUpcomingProducts(model); - // 5. 首页图片列表 - List indexImgList = JSONArray.fromObject(ApplicationListenerImpl.indexImgAll); - model.addAttribute("indexImgList", indexImgList); - - // 6. 即将揭晓商品(取5条) - Pagination datePage = spellbuyproductService.upcomingAnnounced(0, 5); - List productList = convertToProductJSONList((List) datePage.getList(), false); - model.addAttribute("productList", productList); - - return viewUtils.create(module,"index") ; + return "WEB-INF/template/my/index/index-new"; } /** * 热门推荐商品 */ - @GetMapping("/getIndexHotProductLista") + @GetMapping("/getIndexHotProductList") @ResponseBody public List getIndexHotProductList() { Pagination hotPage = spellbuyrecordService.findHotProductList(1, PAGE_SIZE_LARGE); - return convertToProductJSONList((List) hotPage.getList(), false); + List hotList = (List) hotPage.getList(); + List hotProductList = new ArrayList<>(); + + for (ProductSpellbuyproductDTO dto : hotList) { + ProductJSON productJSON = convertToProductJSON(dto.getProduct(), dto.getSpellbuyproduct(), false); + hotProductList.add(productJSON); + } + + return hotProductList; } /** @@ -162,9 +139,21 @@ public class IndexController { */ @GetMapping("/getIndexNewProductList") @ResponseBody - public List getIndexNewProductList() { - Pagination newPage = spellbuyrecordService.indexNewProductList(0, PAGE_SIZE_XLARGE); - return newPage != null ? convertToProductJSONList((List) newPage.getList(), true) : new ArrayList<>(); + public List getIndexNewProductList(@RequestParam(defaultValue = "0") int pageNo) { + Pagination newPage = spellbuyrecordService.indexNewProductList(pageNo, PAGE_SIZE_XLARGE); + if (newPage == null) { + return new ArrayList<>(); + } + + List newList = (List) newPage.getList(); + List newProductList = new ArrayList<>(); + + for (ProductSpellbuyproductDTO dto : newList) { + ProductJSON productJSON = convertToProductJSON(dto.getProduct(), dto.getSpellbuyproduct(), true); + newProductList.add(productJSON); + } + + return newProductList; } /** @@ -172,9 +161,17 @@ public class IndexController { */ @GetMapping("/getIndexPopProductList") @ResponseBody - public List getIndexPopProductList() { - Pagination popPage = spellbuyrecordService.indexHotProductList(0, PAGE_SIZE_MEDIUM); - return convertToProductJSONList((List) popPage.getList(), false); + public List getIndexPopProductList(@RequestParam(defaultValue = "0") int pageNo) { + Pagination popPage = spellbuyrecordService.indexHotProductList(pageNo, PAGE_SIZE_MEDIUM); + List popList = (List) popPage.getList(); + List popProductList = new ArrayList<>(); + + for (ProductSpellbuyproductDTO dto : popList) { + ProductJSON productJSON = convertToProductJSON(dto.getProduct(), dto.getSpellbuyproduct(), false); + popProductList.add(productJSON); + } + + return popProductList; } /** @@ -211,7 +208,8 @@ public class IndexController { if (isCacheExpired(beginDateByNowBuyProduct, nowDateByNowBuyProduct)) { beginDateByNowBuyProduct = System.currentTimeMillis(); Pagination page = spellbuyrecordService.getNowBuyList(0, PAGE_SIZE_XXLARGE); - nowBuyProductList = convertToNowBuyProductList((List) page.getList()); + List nowBuyList = (List) page.getList(); + nowBuyProductList = convertToNowBuyProductList(nowBuyList); } return nowBuyProductList; } @@ -231,7 +229,7 @@ public class IndexController { @GetMapping("/referAuth") public String referAuth(HttpServletRequest request, Model model) { String uid = getUidFromCookie(request.getCookies()); - model.addAttribute("uid", uid); // 传递uid到视图 + model.addAttribute("uid", uid); return "referAuthLogin"; } @@ -260,13 +258,13 @@ public class IndexController { // 设置邀请Cookie if (request.isRequestedSessionIdFromCookie()) { Cookie cookie = new Cookie("inviteId", uid); - cookie.setMaxAge(12 * 60 * 60); // 12小时 + cookie.setMaxAge(12 * 60 * 60); cookie.setPath("/"); cookie.setDomain(ApplicationListenerImpl.sysConfigureJson.getDomain()); response.addCookie(cookie); } - // 处理邀请奖励(避免重复奖励) + // 处理邀请奖励 String ip = request.getHeader("X-Real-IP") == null ? "127.0.0.1" : request.getHeader("X-Real-IP"); if (MemCachedClientHelp.getIMemcachedCache().get(uid) == null) { User user = userService.findById(uid); @@ -301,7 +299,8 @@ public class IndexController { @GetMapping("/getNewRecord") public String getNewRecord(Model model) { Pagination page = spellbuyrecordService.getNowBuyList(0, PAGE_SIZE_XXLARGE); - List productList = convertToNewRecordProductList((List) page.getList()); + List nowBuyList = (List) page.getList(); + List productList = convertToNewRecordProductList(nowBuyList); model.addAttribute("productList", productList); return "newRecord"; } @@ -316,7 +315,8 @@ public class IndexController { if (isCacheExpired(beginDateByNewRecord, nowDateByNewRecord)) { beginDateByNewRecord = System.currentTimeMillis(); Pagination page = spellbuyrecordService.getNowBuyAjaxList(0, PAGE_SIZE_XXLARGE, Integer.parseInt(id)); - newRecordList = convertToNewRecordProductList((List) page.getList()); + List nowBuyList = (List) page.getList(); + newRecordList = convertToNewRecordProductList(nowBuyList); } return newRecordList; } @@ -330,7 +330,8 @@ public class IndexController { @RequestParam(required = false) String endDate, @RequestParam(defaultValue = "0") int pageNo) { Pagination datePage = spellbuyrecordService.getAllBuyRecord(startDate, endDate, pageNo, PAGE_SIZE_XXLARGE); - List historyList = convertToBuyHistoryList((List) datePage.getList()); + List dataList = (List) datePage.getList(); + List historyList = convertToBuyHistoryList(dataList); model.addAttribute("buyHistoryJSONList", historyList); return "allBuyRecord"; } @@ -340,15 +341,19 @@ public class IndexController { return "forward:/group/" + action + ".action"; } - - - /** * 初始化首页新品列表 */ private void initNewProductList(Model model) { Pagination page = spellbuyrecordService.indexNewProductList(0, PAGE_SIZE_SMALL); - List newProductList = convertToProductJSONList((List) page.getList(), true); + List newList = (List) page.getList(); + List newProductList = new ArrayList<>(); + + for (ProductSpellbuyproductDTO dto : newList) { + ProductJSON productJSON = convertToProductJSON(dto.getProduct(), dto.getSpellbuyproduct(), true); + newProductList.add(productJSON); + } + model.addAttribute("newProductList", newProductList); } @@ -360,7 +365,16 @@ public class IndexController { List latestlotteryList = new ArrayList<>(); for (Latestlottery lottery : objList) { Latestlottery item = new Latestlottery(); - item = lottery; // 拷贝属性(实际项目建议用BeanUtils) + // 拷贝属性(实际项目建议用BeanUtils) + item.setId(lottery.getId()); + item.setSpellbuyProductId(lottery.getSpellbuyProductId()); + item.setBuyUser(lottery.getBuyUser()); + item.setBuyNumberCount(lottery.getBuyNumberCount()); + item.setBuyTime(lottery.getBuyTime()); + item.setAnnouncedTime(lottery.getAnnouncedTime()); + item.setRandomNumber(lottery.getRandomNumber()); + item.setUserName(lottery.getUserName()); + String userName = getMaskedUserName(lottery.getUserName(), lottery.getBuyUser()); item.setBuyUser(userName); latestlotteryList.add(item); @@ -375,7 +389,10 @@ public class IndexController { List objectList = recommendService.getRecommend(); ProductJSON recommendJSON = null; if (objectList != null && !objectList.isEmpty()) { - recommendJSON = convertToRecommendProduct(objectList.get(0)); + // 推荐服务返回的是Object[],不是DTO + Product product = (Product) objectList.get(0)[0]; + Spellbuyproduct spellbuyproduct = (Spellbuyproduct) objectList.get(0)[1]; + recommendJSON = convertToProductJSON(product, spellbuyproduct, false); } model.addAttribute("recommendJSON", recommendJSON); } @@ -403,61 +420,54 @@ public class IndexController { */ private void initUpcomingProducts(Model model) { Pagination page = spellbuyproductService.upcomingAnnounced(0, PAGE_SIZE_MEDIUM); - List productList = convertToProductJSONList((List) page.getList(), false); + List upcomingList = (List) page.getList(); + List productList = new ArrayList<>(); + + for (ProductSpellbuyproductDTO dto : upcomingList) { + ProductJSON productJSON = convertToProductJSON(dto.getProduct(), dto.getSpellbuyproduct(), false); + productList.add(productJSON); + } + model.addAttribute("productList", productList); } /** - * 转换Object[]列表为ProductJSON列表(通用转换) - * @param includeMarketPrice 是否包含市场价等字段 + * 转换为ProductJSON对象 */ - private List convertToProductJSONList(List objectList, boolean includeMarketPrice) { - List result = new ArrayList<>(); - if (objectList == null) { - return result; - } - for (Object[] obj : objectList) { - Spellbuyproduct spellbuyproduct = (Spellbuyproduct) obj[0]; - Product product = (Product) obj[1]; - ProductJSON json = new ProductJSON(); - json.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); - json.setHeadImage(product.getHeadImage()); - json.setProductId(spellbuyproduct.getFkProductId()); - json.setProductName(product.getProductName()); - json.setProductPrice(spellbuyproduct.getSpellbuyPrice()); - json.setProductTitle(product.getProductTitle()); - json.setProductStyle(product.getStyle()); - - if (includeMarketPrice) { - json.setMarketPrice(spellbuyproduct.getMarketPrice().floatValue()); - json.setSinglePrice(spellbuyproduct.getSpSinglePrice()); - json.setActionName(spellbuyproduct.getActionName()); - } - result.add(json); + private ProductJSON convertToProductJSON(Product product, Spellbuyproduct spellbuyproduct, boolean includeMarketPrice) { + ProductJSON json = new ProductJSON(); + json.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + json.setHeadImage(product.getHeadImage()); + json.setProductId(spellbuyproduct.getFkProductId()); + json.setProductName(product.getProductName()); + json.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + json.setProductTitle(product.getProductTitle()); + json.setProductStyle(product.getStyle()); + + if (includeMarketPrice) { + json.setMarketPrice(spellbuyproduct.getMarketPrice().floatValue()); + json.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + json.setActionName(spellbuyproduct.getActionName()); } - return result; + return json; } /** * 转换为"正在拍购"商品列表 */ - private List convertToNowBuyProductList(List objectList) { + private List convertToNowBuyProductList(List dtoList) { List result = new ArrayList<>(); - if (objectList == null) { + if (dtoList == null) { return result; } - for (Object[] obj : objectList) { - Product product = (Product) obj[0]; - User user = (User) obj[2]; - Spellbuyproduct spellbuyproduct = (Spellbuyproduct) obj[3]; - + for (ProductSpellbuyproductDTO dto : dtoList) { ProductJSON json = new ProductJSON(); - json.setBuyer(UserNameUtil.userName(user)); - json.setUserId(String.valueOf(user.getUserId())); - json.setHeadImage(user.getFaceImg()); - json.setProductId(spellbuyproduct.getSpellbuyProductId()); - json.setProductName(product.getProductName()); - json.setProductTitle(product.getProductTitle()); + json.setBuyer(UserNameUtil.userName(dto.getUser())); + json.setUserId(String.valueOf(dto.getUser().getUserId())); + json.setHeadImage(dto.getUser().getFaceImg()); + json.setProductId(dto.getSpellbuyproduct().getSpellbuyProductId()); + json.setProductName(dto.getProduct().getProductName()); + json.setProductTitle(dto.getProduct().getProductTitle()); result.add(json); } return result; @@ -466,29 +476,29 @@ public class IndexController { /** * 转换为最新拍购记录商品列表 */ - private List convertToNewRecordProductList(List objectList) { + private List convertToNewRecordProductList(List dtoList) { List result = new ArrayList<>(); - if (objectList == null) { + if (dtoList == null) { return result; } - for (Object[] obj : objectList) { - Product product = (Product) obj[0]; - Spellbuyrecord record = (Spellbuyrecord) obj[1]; - User user = (User) obj[2]; - Spellbuyproduct productInfo = (Spellbuyproduct) obj[3]; - + for (ProductSpellbuyproductDTO dto : dtoList) { ProductJSON json = new ProductJSON(); - json.setBuyer(UserNameUtil.userName(user)); - json.setUserId(String.valueOf(user.getUserId())); - json.setProductId(productInfo.getSpellbuyProductId()); + json.setBuyer(UserNameUtil.userName(dto.getUser())); + json.setUserId(String.valueOf(dto.getUser().getUserId())); + json.setProductId(dto.getSpellbuyproduct().getSpellbuyProductId()); + // 商品名过长截断 - String productName = product.getProductName(); + String productName = dto.getProduct().getProductName(); json.setProductName(productName.length() > 35 ? productName.substring(0, 35) + "..." : productName); - json.setProductPeriod(productInfo.getProductPeriod()); - json.setBuyCount(record.getBuyPrice()); - json.setProductTitle(product.getProductTitle()); - json.setBuyDate(record.getBuyDate()); - json.setProductStyle(String.valueOf(record.getSpellbuyRecordId())); + + json.setProductPeriod(dto.getSpellbuyproduct().getProductPeriod()); +// json.setBuyCount(dto.getSpellbuyrecord().getBuyPrice()); + json.setBuyCount(1); + json.setProductTitle(dto.getProduct().getProductTitle()); +// json.setBuyDate(dto.getSpellbuyrecord().getBuyDate()); + json.setBuyDate(String.valueOf(new Date())); +// json.setProductStyle(String.valueOf(dto.getSpellbuyrecord().getSpellbuyRecordId())); + json.setProductStyle(String.valueOf(1)); result.add(json); } return result; @@ -497,30 +507,27 @@ public class IndexController { /** * 转换为购买历史列表 */ - private List convertToBuyHistoryList(List objectList) { + private List convertToBuyHistoryList(List dtoList) { List result = new ArrayList<>(); - if (objectList == null) { + if (dtoList == null) { return result; } - for (Object[] obj : objectList) { - Product product = (Product) obj[0]; - Spellbuyrecord record = (Spellbuyrecord) obj[1]; - User user = (User) obj[2]; - Spellbuyproduct productInfo = (Spellbuyproduct) obj[3]; - + for (ProductSpellbuyproductDTO dto : dtoList) { BuyHistoryJSON json = new BuyHistoryJSON(); - json.setBuyCount(Long.parseLong(String.valueOf(record.getBuyPrice()))); - json.setBuyStatus(productInfo.getSpStatus()); - json.setHistoryId(record.getSpellbuyRecordId()); - json.setProductId(productInfo.getSpellbuyProductId()); - json.setProductImg(product.getHeadImage()); - json.setProductName(product.getProductName()); - json.setProductPeriod(productInfo.getProductPeriod()); - json.setProductTitle(product.getProductTitle()); +// json.setBuyCount(Long.parseLong(String.valueOf(dto.getSpellbuyrecord().getBuyPrice()))); + json.setBuyCount(Long.parseLong(String.valueOf(1))); + json.setBuyStatus(dto.getSpellbuyproduct().getSpStatus()); +// json.setHistoryId(dto.getSpellbuyrecord().getSpellbuyRecordId()); + json.setHistoryId(1); + json.setProductId(dto.getSpellbuyproduct().getSpellbuyProductId()); + json.setProductImg(dto.getProduct().getHeadImage()); + json.setProductName(dto.getProduct().getProductName()); + json.setProductPeriod(dto.getSpellbuyproduct().getProductPeriod()); + json.setProductTitle(dto.getProduct().getProductTitle()); // 处理已揭晓状态的额外信息 - if (productInfo.getSpStatus() == 1) { - List lotteryList = latestlotteryService.getBuyHistoryByDetail(productInfo.getSpellbuyProductId()); + if (dto.getSpellbuyproduct().getSpStatus() == 1) { + List lotteryList = latestlotteryService.getBuyHistoryByDetail(dto.getSpellbuyproduct().getSpellbuyProductId()); if (!lotteryList.isEmpty()) { Latestlottery lottery = (Latestlottery) lotteryList.get(0); json.setWinDate(lottery.getAnnouncedTime()); @@ -534,22 +541,6 @@ public class IndexController { return result; } - /** - * 转换为推荐商品 - */ - private ProductJSON convertToRecommendProduct(Object[] obj) { - Product product = (Product) obj[0]; - Spellbuyproduct spellbuyproduct = (Spellbuyproduct) obj[1]; - ProductJSON json = new ProductJSON(); - json.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); - json.setHeadImage(product.getHeadImage()); - json.setProductId(spellbuyproduct.getSpellbuyProductId()); - json.setProductName(product.getProductName()); - json.setProductPrice(spellbuyproduct.getSpellbuyPrice()); - json.setProductTitle(product.getProductTitle()); - return json; - } - /** * 处理用户名脱敏 */ @@ -622,6 +613,4 @@ public class IndexController { private boolean isCacheExpired(Long beginTime, Long nowTime) { return beginTime == null || (nowTime - beginTime) >= CACHE_EXPIRE_MS; } - - } \ No newline at end of file diff --git a/src/main/java/me/mofun/controller/ListController.java b/src/main/java/me/mofun/controller/ListController.java index a31f17a..0a5de4a 100644 --- a/src/main/java/me/mofun/controller/ListController.java +++ b/src/main/java/me/mofun/controller/ListController.java @@ -13,8 +13,7 @@ import me.mofun.test.tree.MenuNode; import me.mofun.util.ApplicationListenerImpl; import me.mofun.util.PaginationUtil; import me.mofun.util.StringUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -30,46 +29,50 @@ import java.util.List; @Controller @RequestMapping("/list") public class ListController { - private static final Logger logger = LoggerFactory.getLogger(ListController.class); - private static final int PAGE_SIZE = 20; // 常量定义为局部常量更合适 + + private static final long serialVersionUID = 8452833122481904678L; @Autowired private ISpellbuyrecordService spellbuyrecordService; + @Autowired private ISpellbuyproductService spellbuyproductService; + @Autowired private IProducttypeService productTypeService; + private static IProducttypeService theProductTypeService; - /** - * 首页产品列表展示 - */ + private Logger logger = Logger.getLogger(this.getClass()); + @GetMapping("/index") public String index( - @RequestParam(required = false) String id, - @RequestParam(required = false) String typeId, - @RequestParam(required = false) String pages, - @RequestParam(required = false, defaultValue = "1") Integer pageNo, + @RequestParam(value = "id", required = false) String id, + @RequestParam(value = "typeId", required = false) String typeId, + @RequestParam(value = "pages", required = false) String pages, + @RequestParam(value = "pageNo", defaultValue = "1") int pageNo, Model model) { - // 处理分页参数 + // 处理页码 if (pages != null) { pageNo = Integer.parseInt(pages.split("_")[1]); } - // 处理分类和品牌参数 String tId = null; String brandId = null; String typeName = null; String brandName = null; + // 处理类型和品牌ID if (StringUtil.isNotBlank(typeId)) { if (typeId.indexOf("b") != -1) { brandId = typeId.split("b")[1]; tId = typeId.split("b")[0]; - typeName = StringUtil.isNotBlank(tId) ? - productTypeService.getById(tId).getTypeName() : - productTypeService.getById("1000").getTypeName(); + if (StringUtil.isNotBlank(tId)) { + typeName = productTypeService.getById(tId).getTypeName(); + } else { + typeName = productTypeService.getById("1000").getTypeName(); + } brandName = productTypeService.findBrandById(brandId).getTypeName(); } else { tId = typeId; @@ -79,91 +82,153 @@ public class ListController { typeName = productTypeService.getById("1000").getTypeName(); } - // 处理品牌列表 + // 处理产品类型列表 List producttyList = productTypeService.listByProductList(); + model.addAttribute("producttyList", producttyList); + + // 处理品牌列表 List tList = productTypeService.listByBrand(tId); - List brandList; int j = 0; - for (int i = 0; i < tList.size(); i++) { - if (StringUtil.isNotBlank(brandId) && - Integer.parseInt(brandId) == tList.get(i).getTypeId()) { - j = i; + if (StringUtil.isNotBlank(brandId)) { + if (Integer.parseInt(brandId) == tList.get(i).getTypeId()) { + j = i; + } } } - if (j > 16 && StringUtil.isNotBlank(brandId)) { - brandList = new ArrayList<>(); - for (Producttype type : tList) { - if (Integer.parseInt(brandId) == type.getTypeId()) { - brandList.add(type); + List brandList; + if (j > 16) { + if (StringUtil.isNotBlank(brandId)) { + brandList = new ArrayList<>(); + for (Producttype type : tList) { + if (Integer.parseInt(brandId) == type.getTypeId()) { + brandList.add(type); + } } - } - for (Producttype type : tList) { - if (Integer.parseInt(brandId) != type.getTypeId()) { - brandList.add(type); + for (Producttype type : tList) { + if (Integer.parseInt(brandId) != type.getTypeId()) { + brandList.add(type); + } } + } else { + brandList = productTypeService.listByBrand(tId); } } else { brandList = productTypeService.listByBrand(tId); } + model.addAttribute("brandList", brandList); // 处理产品列表数据 List productList = new ArrayList<>(); - String pageString = ""; int resultCount = 0; + String pageString = ""; + int pageSize = 20; if ("hot20".equals(id)) { - Pagination hotPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "hot", pageNo, PAGE_SIZE); + Pagination hotPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "hot", pageNo, pageSize); + List hotList = (List) hotPage.getList(); + productList = buildProductJSONList(hotList); resultCount = hotPage.getResultCount(); - productList = convertToProductJSON((List) hotPage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } else if ("date20".equals(id)) { - Pagination datePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "date", pageNo, PAGE_SIZE); + Pagination datePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "date", pageNo, pageSize); + List dateList = (List) datePage.getList(); + productList = buildProductJSONList(dateList); resultCount = datePage.getResultCount(); - productList = convertToProductJSON((List) datePage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } else if ("price20".equals(id)) { - Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "price", pageNo, PAGE_SIZE); + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "price", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + productList = buildProductJSONList(priceList); resultCount = pricePage.getResultCount(); - productList = convertToProductJSON((List) pricePage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } else if ("priceAsc20".equals(id)) { - Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "priceAsc", pageNo, PAGE_SIZE); + Pagination pricePage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "priceAsc", pageNo, pageSize); + List priceList = (List) pricePage.getList(); + productList = buildProductJSONList(priceList); resultCount = pricePage.getResultCount(); - productList = convertToProductJSON((List) pricePage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } else if ("about20".equals(id)) { - Pagination aboutPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "about", pageNo, PAGE_SIZE); + Pagination aboutPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "about", pageNo, pageSize); + List aboutList = (List) aboutPage.getList(); + productList = buildProductJSONList(aboutList); resultCount = aboutPage.getResultCount(); - productList = convertToProductJSON((List) aboutPage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } else if ("surplus20".equals(id)) { - Pagination surplusPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "surplus", pageNo, PAGE_SIZE); + Pagination surplusPage = spellbuyrecordService.ProductByTypeIdList(tId, brandId, "surplus", pageNo, pageSize); + List surplusList = (List) surplusPage.getList(); + productList = buildProductJSONList(surplusList); resultCount = surplusPage.getResultCount(); - productList = convertToProductJSON((List) surplusPage.getList()); - pageString = buildPageString(resultCount, pageNo, id, tId); + pageString = buildPageString(resultCount, pageSize, pageNo, id, tId); } - // 向视图传递数据 + // 将数据添加到模型 model.addAttribute("productList", productList); - model.addAttribute("producttyList", producttyList); - model.addAttribute("brandList", brandList); + model.addAttribute("resultCount", resultCount); + model.addAttribute("pageString", pageString); model.addAttribute("typeName", typeName); model.addAttribute("brandName", brandName); - model.addAttribute("pageString", pageString); - model.addAttribute("resultCount", resultCount); + model.addAttribute("tId", tId); + model.addAttribute("brandId", brandId); return "index"; } /** - * 检查商品状态接口 + * 构建产品JSON列表 + */ + private List buildProductJSONList(List objectList) { + List productList = new ArrayList<>(); + for (Object[] obj : objectList) { + ProductJSON productJSON = new ProductJSON(); + Product product; + Spellbuyproduct spellbuyproduct; + + // 根据原代码逻辑处理对象转换(兼容jdk1.8的调整) + if ("hot20".equals(2) || "date20".equals(1)) { + product = (Product) obj[1]; + spellbuyproduct = (Spellbuyproduct) obj[0]; + } else { + product = (Product) obj[0]; + spellbuyproduct = (Spellbuyproduct) obj[1]; + } + + productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); + productJSON.setHeadImage(product.getHeadImage()); + productJSON.setProductId(spellbuyproduct.getFkProductId()); + productJSON.setProductName(product.getProductName()); + productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); + productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); + productJSON.setLogicURL(product.getLogicURL()); + productJSON.setProductTitle(product.getProductTitle()); + productJSON.setProductStyle(product.getStyle()); + + productList.add(productJSON); + } + return productList; + } + + /** + * 构建分页字符串 + */ + private String buildPageString(int resultCount, int pageSize, int pageNo, String id, String tId) { + String baseUrl = ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/list/" + id; + if (tId != null && !tId.isEmpty()) { + baseUrl += "/" + tId; + } + return PaginationUtil.getPaginationHtml(resultCount, pageSize, pageNo, 2, 5, baseUrl + "/p_"); + } + + /** + * 查询商品是否满员 + * 请求地址: /list/isStatus?id=xxx */ @GetMapping("/isStatus") @ResponseBody - public String isStatus(@RequestParam String id) { - Spellbuyproduct spellbuyproduct = spellbuyproductService.findByFKProductId(id); + public String isStatus(@RequestParam("id") String productId) { + Spellbuyproduct spellbuyproduct = spellbuyproductService.findByFKProductId(productId); + if (spellbuyproduct.getSpStatus() == 1) { return "false"; } else { @@ -173,7 +238,7 @@ public class ListController { } /** - * 获取首页左侧产品类目树 + * 首页左侧产品类目列表 */ @GetMapping("/getProductTypeSubList") public String getProductTypeSubList(Model model) { @@ -183,9 +248,6 @@ public class ListController { return "getMenuList"; } - /** - * 初始化静态Service引用 - */ @PostConstruct public void init() { if (this.productTypeService != null) { @@ -193,47 +255,12 @@ public class ListController { } } - /** - * 静态方法获取产品类型列表 - */ public static List getTypeSubList() { return theProductTypeService.getAllProductTypeTree(); } - /** - * 转换对象数组为ProductJSON列表 - */ - private List convertToProductJSON(List sourceList) { - List result = new ArrayList<>(); - for (Object[] item : sourceList) { - ProductJSON productJSON = new ProductJSON(); - // 根据原代码逻辑,不同排序类型的数组元素顺序可能不同 - Spellbuyproduct spellbuyproduct = (Spellbuyproduct) item[0]; - Product product = (Product) item[1]; - - productJSON.setCurrentBuyCount(spellbuyproduct.getSpellbuyCount()); - productJSON.setHeadImage(product.getHeadImage()); - productJSON.setProductId(spellbuyproduct.getFkProductId()); - productJSON.setProductName(product.getProductName()); - productJSON.setProductPrice(spellbuyproduct.getSpellbuyPrice()); - productJSON.setSinglePrice(spellbuyproduct.getSpSinglePrice()); - productJSON.setLogicURL(product.getLogicURL()); - productJSON.setProductTitle(product.getProductTitle()); - productJSON.setProductStyle(product.getStyle()); - - result.add(productJSON); - } - return result; - } - - /** - * 构建分页HTML字符串 - */ - private String buildPageString(int resultCount, int pageNo, String id, String tId) { - String baseUrl = ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/list/" + id; - if (tId != null && !tId.isEmpty()) { - baseUrl += "/" + tId; - } - return PaginationUtil.getPaginationHtml(resultCount, PAGE_SIZE, pageNo, 2, 5, baseUrl + "/p_"); + // 仅保留服务类的getter(如果有外部依赖) + public IProducttypeService getTheProductTypeService() { + return theProductTypeService; } } \ No newline at end of file diff --git a/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java b/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java new file mode 100644 index 0000000..74ab90e --- /dev/null +++ b/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java @@ -0,0 +1,13 @@ +package me.mofun.entity.dto; + +import me.mofun.entity.Product; +import me.mofun.entity.Spellbuyproduct; +import lombok.Data; +import me.mofun.entity.User; + +@Data +public class ProductSpellbuyproductDTO { + private Product product; + private Spellbuyproduct spellbuyproduct; + private User user; +} \ No newline at end of file diff --git a/src/main/java/me/mofun/entity/dto/UserSpellbuyproductRecordDTO.java b/src/main/java/me/mofun/entity/dto/UserSpellbuyproductRecordDTO.java new file mode 100644 index 0000000..086ba33 --- /dev/null +++ b/src/main/java/me/mofun/entity/dto/UserSpellbuyproductRecordDTO.java @@ -0,0 +1,14 @@ +package me.mofun.entity.dto; + +import lombok.Data; +import me.mofun.entity.Spellbuyproduct; +import me.mofun.entity.Spellbuyrecord; +import me.mofun.entity.User; + +@Data +public class UserSpellbuyproductRecordDTO { + private Spellbuyproduct spellbuyproduct; + private Spellbuyrecord spellbuyrecord; + private User user; + private Integer buyPriceSum; // 购买的总额 +} \ No newline at end of file diff --git a/src/main/resources/mapper/ShareinfoMapper.xml b/src/main/resources/mapper/ShareinfoMapper.xml index 2058282..534438b 100644 --- a/src/main/resources/mapper/ShareinfoMapper.xml +++ b/src/main/resources/mapper/ShareinfoMapper.xml @@ -240,7 +240,7 @@ and so.shareDate >= #{startDate} - and so.shareDate <= #{endDate} + and so.shareDate <= #{endDate} group by so.uid order by so.shareDate desc @@ -257,7 +257,7 @@ and so.shareDate >= #{startDate} - and so.shareDate <= #{endDate} + and so.shareDate <= #{endDate} diff --git a/src/main/resources/mapper/SpellbuyproductMapper.xml b/src/main/resources/mapper/SpellbuyproductMapper.xml index 4a87e8b..aa3c5f8 100644 --- a/src/main/resources/mapper/SpellbuyproductMapper.xml +++ b/src/main/resources/mapper/SpellbuyproductMapper.xml @@ -2,7 +2,7 @@ - + @@ -17,8 +17,479 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/SpellbuyrecordMapper.xml b/src/main/resources/mapper/SpellbuyrecordMapper.xml index cd0e6c1..4249fa7 100644 --- a/src/main/resources/mapper/SpellbuyrecordMapper.xml +++ b/src/main/resources/mapper/SpellbuyrecordMapper.xml @@ -2,237 +2,641 @@ - - + SELECT + pt.productId as pt_productId, + pt.productName as pt_productName, + pt.productPrice as pt_productPrice, + pt.marketPrice as pt_marketPrice, + pt.singlePrice as pt_singlePrice, + pt.productLimit as pt_productLimit, + pt.productRealPrice as pt_productRealPrice, + pt.productTitle as pt_productTitle, + pt.productDetail as pt_productDetail, + pt.productType as pt_productType, + pt.productBrand as pt_productBrand, + pt.headImage as pt_headImage, + pt.status as pt_status, + pt.isShow as pt_isShow, + pt.isVirtual as pt_isVirtual, + pt.isNeedLogic as pt_isNeedLogic, + pt.logicURL as pt_logicURL, + pt.shopId as pt_shopId, + pt.authorId as pt_authorId, + pt.style as pt_style, + pt.Attribute_71 as pt_attribute71, + + st.spellbuyProductId as st_spellbuyProductId, + st.fkProductId as st_fkProductId, + st.spellbuyStartDate as st_spellbuyStartDate, + st.spellbuyEndDate as st_spellbuyEndDate, + st.spellbuyCount as st_spellbuyCount, + st.spellbuyPrice as st_spellbuyPrice, + st.marketPrice as st_marketPrice, + st.actionName as st_actionName, + st.spSinglePrice as st_spSinglePrice, + st.productPeriod as st_productPeriod, + st.spellbuyLimit as st_spellbuyLimit, + st.spStatus as st_spStatus, + st.spellbuyType as st_spellbuyType, + st.Attribute_64 as st_attribute64, + st.Attribute_65 as st_attribute65 + FROM product pt, spellbuyproduct st + WHERE st.fkProductId = pt.productId AND st.spStatus <> 1 + GROUP BY pt.productId + ORDER BY st.spellbuyCount DESC - + SELECT + pt.productId as pt_productId, + pt.productName as pt_productName, + pt.productPrice as pt_productPrice, + pt.marketPrice as pt_marketPrice, + pt.singlePrice as pt_singlePrice, + pt.productLimit as pt_productLimit, + pt.productRealPrice as pt_productRealPrice, + pt.productTitle as pt_productTitle, + pt.productDetail as pt_productDetail, + pt.productType as pt_productType, + pt.productBrand as pt_productBrand, + pt.headImage as pt_headImage, + pt.status as pt_status, + pt.isShow as pt_isShow, + pt.isVirtual as pt_isVirtual, + pt.isNeedLogic as pt_isNeedLogic, + pt.logicURL as pt_logicURL, + pt.shopId as pt_shopId, + pt.authorId as pt_authorId, + pt.style as pt_style, + pt.Attribute_71 as pt_attribute71, + + st.spellbuyProductId as st_spellbuyProductId, + st.fkProductId as st_fkProductId, + st.spellbuyStartDate as st_spellbuyStartDate, + st.spellbuyEndDate as st_spellbuyEndDate, + st.spellbuyCount as st_spellbuyCount, + st.spellbuyPrice as st_spellbuyPrice, + st.marketPrice as st_marketPrice, + st.actionName as st_actionName, + st.spSinglePrice as st_spSinglePrice, + st.productPeriod as st_productPeriod, + st.spellbuyLimit as st_spellbuyLimit, + st.spStatus as st_spStatus, + st.spellbuyType as st_spellbuyType, + st.Attribute_64 as st_attribute64, + st.Attribute_65 as st_attribute65 + FROM product pt, spellbuyproduct st + WHERE pt.status = 1 AND pt.isShow = 1 AND st.fkProductId = pt.productId AND st.spStatus <> 1 + GROUP BY pt.productId + ORDER BY st.spellbuyStartDate DESC - - - - - - + + + + + + - + - - + SELECT + pt.*, + st.* + FROM product pt, spellbuyproduct st + WHERE pt.status = 1 AND pt.isShow = 1 AND pt.shopId = #{shopId} AND st.fkProductId = pt.productId AND st.spStatus <> 1 - and (1=2 - or (1=1 and pt.productType= #{typeId}) - - or (1=1 and pt.productType= #{childTypeId}) - + AND (1=2 + OR pt.productType = #{typeId} + + OR pt.productType IN + + #{childTypeId} + + ) - and pt.productBrand=#{brandId} - - - GROUP by st.spellbuyProductId - order by st.spellbuyCount desc - - - GROUP by st.spellbuyProductId - order by st.spellbuyStartDate desc - - - GROUP by st.spellbuyProductId - order by pt.productPrice desc - - - GROUP by st.spellbuyProductId - order by pt.productPrice asc - - - and (st.spellbuyCount > (pt.productPrice/1.5)) - GROUP by pt.productId - order by st.spellbuyCount desc - - - GROUP by pt.productId - order by (pt.productPrice - st.spellbuyCount) asc + AND pt.productBrand = #{brandId} + + + GROUP BY st.spellbuyProductId ORDER BY st.spellbuyCount DESC + + + GROUP BY st.spellbuyProductId ORDER BY st.spellbuyStartDate DESC + + + GROUP BY st.spellbuyProductId ORDER BY pt.productPrice DESC + + + GROUP BY st.spellbuyProductId ORDER BY pt.productPrice ASC + + + AND (st.spellbuyCount > (pt.productPrice/1.5)) GROUP BY pt.productId ORDER BY st.spellbuyCount DESC + + + GROUP BY pt.productId ORDER BY (pt.productPrice - st.spellbuyCount) ASC + + + GROUP BY st.spellbuyProductId + + - + SELECT + pt.*, + st.* + FROM product pt, spellbuyproduct st + WHERE st.fkProductId = pt.productId AND st.spStatus <> 1 AND pt.productName LIKE CONCAT('%', #{keyword}, '%') + + + GROUP BY st.spellbuyProductId ORDER BY st.spellbuyCount DESC + + + GROUP BY st.spellbuyProductId ORDER BY st.spellbuyStartDate DESC + + + GROUP BY st.spellbuyProductId ORDER BY pt.productPrice DESC + + + GROUP BY st.spellbuyProductId ORDER BY pt.productPrice ASC + + + AND (st.spellbuyCount > (pt.productPrice/1.5)) GROUP BY pt.productId ORDER BY st.spellbuyCount DESC + + + GROUP BY pt.productId ORDER BY (pt.productPrice - st.spellbuyCount) ASC + + + GROUP BY st.spellbuyProductId + + - + + + + - + SELECT * + FROM randomnumber rr + WHERE rr.productId = #{spellbuyProductId} AND rr.userId = #{userId} + ORDER BY rr.buyDate DESC - + SELECT + st.spellbuyProductId as productId, pt.productName as productName, pt.productTitle as productTitle, pt.headImage as productImg, st.productPeriod as productPeriod, st.spStatus as buyStatus, sd.buyDate as buyTime, - sum(sd.buyPrice) as buyCount, + SUM(sd.buyPrice) as buyCount, sd.spellbuyRecordId as historyId, st.spellbuyCount as spellbuyCount, st.spellbuyPrice as productPrice - from spellbuyrecord sd,spellbuyproduct st,product pt,user ur - where sd.fkSpellbuyProductId=st.spellbuyProductId - and st.fkProductId=pt.productId - and sd.buyer=ur.userId - and sd.buyer=#{userId} + FROM spellbuyrecord sd, spellbuyproduct st, product pt, user ur + WHERE sd.fkSpellbuyProductId = st.spellbuyProductId + AND st.fkProductId = pt.productId + AND sd.buyer = ur.userId + AND sd.buyer = #{userId} + + AND sd.buyDate >= #{startDate} + + + AND sd.buyDate <= #{endDate} + + GROUP BY st.spellbuyProductId + ORDER BY sd.buyDate DESC + + + + + + + + + + + + + + + \ No newline at end of file