功能模块迁移 主页模块代码调试

master
xuao 3 months ago
parent f7b1f762be
commit 6dd3848647

@ -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 = "<table width=\"600\" cellspacing=\"0\" cellpadding=\"0\" style=\"border: #dddddd 1px solid; padding: 20px 0;\">" +
"<tbody><tr>" +
"<td>" +
"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" style=\"border-bottom: #ff6600 2px solid; padding-bottom: 12px;\">" +
"<tbody><tr>" +
"<td style=\"line-height: 22px; padding-left: 20px;\"><a target=\"_blank\" title=\"" + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "\"><img width=\"230px\" border=\"0\" height=\"52\" src=\"" + ApplicationListenerImpl.sysConfigureJson.getImgUrl() + "/Images/mail_logo.gif\"></a></td>" +
"<td align=\"right\" style=\"font-size: 12px; padding-right: 20px; padding-top: 30px;\"><a style=\"color: #22aaff; text-decoration: none;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "\">首页</a><b style=\"width: 1px; height: 10px; vertical-align: -1px; font-size: 1px; background: #CACACA; display: inline-block; margin: 0 5px;\"></b>" +
"<a style=\"color: #22aaff; text-decoration: none;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/user/index.html\">我的" + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "</a><b style=\"width: 1px; height: 10px; vertical-align: -1px; font-size: 1px; background: #CACACA; display: inline-block; margin: 0 5px;\"></b><a style=\"color: #22aaff; text-decoration: none;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/help/index.html\">帮助</a></td>" +
"</tr>" +
"</tbody></table>" +
"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" style=\"padding: 0 20px;\">" +
"<tbody><tr>" +
"<td style=\"font-size: 14px; color: #333333; height: 40px; line-height: 40px; padding-top: 10px;\">亲爱的 <b style=\"color: #333333; font-family: Arial;\"><a href=\"mailto:" + mail + "\" target=\"_blank\">" + mail + "</a></b></td>" +
"</tr>" +
"<tr>" +
"<td style=\"font-size: 12px; color: #333333; line-height: 22px;\"><p style=\"text-indent: 2em; padding: 0; margin: 0;\">您好!请点击下面的按钮,重新设置您的密码:</p></td>" +
"</tr>" +
"<tr>" +
"<td style=\"padding-top: 15px; padding-left: 28px;\"><a title=\"重设密码\" style=\"display: inline-block; padding: 0 25px; height: 28px; line-height: 28px; text-align: center; color: #ffffff; background: #ff7700; font-size: 12px; cursor: pointer; border-radius: 2px; text-decoration: none;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/getbackpwd/findreset.html?key=" + key + "\">重设密码</a></td>" +
"</tr>" +
"<tr>" +
"<td width=\"525\" style=\"font-size: 12px; color: #333333; line-height: 22px; padding-top: 20px;\">如果上面按钮不能点击或点击后没有反应,您还可以将以下链接复制到浏览器地址栏中访问完成重设密码。</td>" +
"</tr>" +
"<tr>" +
"<td width=\"525\" style=\"font-size: 12px; padding-top: 5px; word-break: break-all; word-wrap: break-word;\"><a style=\"font-family: Arial; color: #22aaff;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/getbackpwd/findreset.html?key=" + key + "\">" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/getbackpwd/findreset.html?key=" + key + "</a></td>" +
"</tr>" +
"<tr>" +
"<td style=\"font-size:12px; color:#333333; line-height:22px; padding-top:30px;\"><p style=\"text-indent:2em; padding:0; margin:0;\"><b>如果您现在想起了您的密码:</b></p></td>" +
"</tr>" +
"<tr>" +
"<td style=\"font-size:12px; color:#333333; line-height:22px;\"><p style=\"text-indent:2em; padding:0; margin:0;\">可不必重设密码,继续用原来的密码登录。</p></td>" +
"</tr>" +
"</tbody></table>" +
"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" style=\"margin-top: 60px;\">" +
"<tbody><tr>" +
"<td style=\"font-size: 12px; color: #777777; line-height: 22px; border-bottom: #22aaff 2px solid; padding-bottom: 8px; padding-left: 20px;\">此邮件由系统自动发出,请勿回复!</td>" +
"</tr>" +
"<tr>" +
"<td style=\"font-size: 12px; color: #333333; line-height: 22px; padding: 8px 20px 0;\">感谢您对" + ApplicationListenerImpl.sysConfigureJson.getSiteName() + "<a style=\"color: #22aaff; font-family: Arial;\" target=\"_blank\" href=\"" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "\">" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "</a>)的支持,祝您好运!</td>" +
"</tr>" +
"</tbody></table>" +
"</td>" +
"</tr>" +
"</tbody></table>" +
"<table width=\"600\" cellspacing=\"0\" cellpadding=\"0\">" +
"<tbody><tr>" +
"<td align=\"center\" style=\"font-size:12px; color:#bbbbbb; padding-top:10px;\"><span style=\"font-family:Arial;\">" + ApplicationListenerImpl.sysConfigureJson.getDomain() + "</span> " + ApplicationListenerImpl.sysConfigureJson.getIcp() + "</td>" +
"</tr>" +
"</tbody></table>";
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;
}
}
}

@ -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 ActionSpring 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<ProductJSON> nowBuyProductList;
private static volatile List<ProductJSON> 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<News> newsList; // 新闻缓存
private static volatile List<News> 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<ProductJSON> newProductList = convertToProductJSONList((List<Object[]>) phoneDigitalPage.getList(), true);
model.addAttribute("newProductList", newProductList);
// 2. 最新揭晓列表
List<Latestlottery> objList = latestlotteryService.indexWinningScroll();
List<Latestlottery> 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<Object[]> 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<IndexImg> indexImgList = JSONArray.fromObject(ApplicationListenerImpl.indexImgAll);
model.addAttribute("indexImgList", indexImgList);
// 6. 即将揭晓商品取5条
Pagination datePage = spellbuyproductService.upcomingAnnounced(0, 5);
List<ProductJSON> productList = convertToProductJSONList((List<Object[]>) 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<ProductJSON> getIndexHotProductList() {
Pagination hotPage = spellbuyrecordService.findHotProductList(1, PAGE_SIZE_LARGE);
return convertToProductJSONList((List<Object[]>) hotPage.getList(), false);
List<ProductSpellbuyproductDTO> hotList = (List<ProductSpellbuyproductDTO>) hotPage.getList();
List<ProductJSON> 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<ProductJSON> getIndexNewProductList() {
Pagination newPage = spellbuyrecordService.indexNewProductList(0, PAGE_SIZE_XLARGE);
return newPage != null ? convertToProductJSONList((List<Object[]>) newPage.getList(), true) : new ArrayList<>();
public List<ProductJSON> getIndexNewProductList(@RequestParam(defaultValue = "0") int pageNo) {
Pagination newPage = spellbuyrecordService.indexNewProductList(pageNo, PAGE_SIZE_XLARGE);
if (newPage == null) {
return new ArrayList<>();
}
List<ProductSpellbuyproductDTO> newList = (List<ProductSpellbuyproductDTO>) newPage.getList();
List<ProductJSON> 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<ProductJSON> getIndexPopProductList() {
Pagination popPage = spellbuyrecordService.indexHotProductList(0, PAGE_SIZE_MEDIUM);
return convertToProductJSONList((List<Object[]>) popPage.getList(), false);
public List<ProductJSON> getIndexPopProductList(@RequestParam(defaultValue = "0") int pageNo) {
Pagination popPage = spellbuyrecordService.indexHotProductList(pageNo, PAGE_SIZE_MEDIUM);
List<ProductSpellbuyproductDTO> popList = (List<ProductSpellbuyproductDTO>) popPage.getList();
List<ProductJSON> 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<Object[]>) page.getList());
List<ProductSpellbuyproductDTO> nowBuyList = (List<ProductSpellbuyproductDTO>) 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<ProductJSON> productList = convertToNewRecordProductList((List<Object[]>) page.getList());
List<ProductSpellbuyproductDTO> nowBuyList = (List<ProductSpellbuyproductDTO>) page.getList();
List<ProductJSON> 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<Object[]>) page.getList());
List<ProductSpellbuyproductDTO> nowBuyList = (List<ProductSpellbuyproductDTO>) 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<BuyHistoryJSON> historyList = convertToBuyHistoryList((List<Object[]>) datePage.getList());
List<ProductSpellbuyproductDTO> dataList = (List<ProductSpellbuyproductDTO>) datePage.getList();
List<BuyHistoryJSON> 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<ProductJSON> newProductList = convertToProductJSONList((List<Object[]>) page.getList(), true);
List<ProductSpellbuyproductDTO> newList = (List<ProductSpellbuyproductDTO>) page.getList();
List<ProductJSON> 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<Latestlottery> 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<Object[]> 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<ProductJSON> productList = convertToProductJSONList((List<Object[]>) page.getList(), false);
List<ProductSpellbuyproductDTO> upcomingList = (List<ProductSpellbuyproductDTO>) page.getList();
List<ProductJSON> 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<ProductJSON> convertToProductJSONList(List<Object[]> objectList, boolean includeMarketPrice) {
List<ProductJSON> 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<ProductJSON> convertToNowBuyProductList(List<Object[]> objectList) {
private List<ProductJSON> convertToNowBuyProductList(List<ProductSpellbuyproductDTO> dtoList) {
List<ProductJSON> 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<ProductJSON> convertToNewRecordProductList(List<Object[]> objectList) {
private List<ProductJSON> convertToNewRecordProductList(List<ProductSpellbuyproductDTO> dtoList) {
List<ProductJSON> 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<BuyHistoryJSON> convertToBuyHistoryList(List<Object[]> objectList) {
private List<BuyHistoryJSON> convertToBuyHistoryList(List<ProductSpellbuyproductDTO> dtoList) {
List<BuyHistoryJSON> 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;
}
}

@ -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<Producttype> producttyList = productTypeService.listByProductList();
model.addAttribute("producttyList", producttyList);
// 处理品牌列表
List<Producttype> tList = productTypeService.listByBrand(tId);
List<Producttype> 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<Producttype> 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<ProductJSON> 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<Object[]> hotList = (List<Object[]>) hotPage.getList();
productList = buildProductJSONList(hotList);
resultCount = hotPage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<Object[]> dateList = (List<Object[]>) datePage.getList();
productList = buildProductJSONList(dateList);
resultCount = datePage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<Object[]> priceList = (List<Object[]>) pricePage.getList();
productList = buildProductJSONList(priceList);
resultCount = pricePage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<Object[]> priceList = (List<Object[]>) pricePage.getList();
productList = buildProductJSONList(priceList);
resultCount = pricePage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<Object[]> aboutList = (List<Object[]>) aboutPage.getList();
productList = buildProductJSONList(aboutList);
resultCount = aboutPage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<Object[]> surplusList = (List<Object[]>) surplusPage.getList();
productList = buildProductJSONList(surplusList);
resultCount = surplusPage.getResultCount();
productList = convertToProductJSON((List<Object[]>) 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<ProductJSON> buildProductJSONList(List<Object[]> objectList) {
List<ProductJSON> 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<MenuNode> getTypeSubList() {
return theProductTypeService.getAllProductTypeTree();
}
/**
* ProductJSON
*/
private List<ProductJSON> convertToProductJSON(List<Object[]> sourceList) {
List<ProductJSON> 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;
}
}

@ -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;
}

@ -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; // 购买的总额
}

@ -240,7 +240,7 @@
and so.shareDate >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and so.shareDate <= #{endDate}
and so.shareDate &lt;= #{endDate}
</if>
group by so.uid
order by so.shareDate desc
@ -257,7 +257,7 @@
and so.shareDate >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and so.shareDate <= #{endDate}
and so.shareDate &lt;= #{endDate}
</if>
</select>

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="me.mofun.mapper.SpellbuyproductMapper">
<!-- 通用查询映射结果 -->
<!-- 基础结果映射 -->
<resultMap id="BaseResultMap" type="me.mofun.entity.Spellbuyproduct">
<id column="spellbuyProductId" property="spellbuyProductId" />
<result column="fkProductId" property="fkProductId" />
@ -17,8 +17,479 @@
<result column="spellbuyLimit" property="spellbuyLimit" />
<result column="spStatus" property="spStatus" />
<result column="spellbuyType" property="spellbuyType" />
<result column="Attribute_64" property="attribute64" />
<result column="Attribute_65" property="attribute65" />
<result column="attribute64" property="attribute64" />
<result column="attribute65" property="attribute65" />
</resultMap>
</mapper>
<!-- Product 结果映射 -->
<resultMap id="ProductResultMap" type="me.mofun.entity.Product">
<id column="productId" property="productId" />
<result column="productName" property="productName" />
<result column="productPrice" property="productPrice" />
<result column="marketPrice" property="marketPrice" />
<result column="singlePrice" property="singlePrice" />
<result column="productLimit" property="productLimit" />
<result column="productRealPrice" property="productRealPrice" />
<result column="productTitle" property="productTitle" />
<result column="productDetail" property="productDetail" />
<result column="productType" property="productType" />
<result column="productBrand" property="productBrand" />
<result column="headImage" property="headImage" />
<result column="status" property="status" />
<result column="isShow" property="isShow" />
<result column="isVirtual" property="isVirtual" />
<result column="isNeedLogic" property="isNeedLogic" />
<result column="logicURL" property="logicURL" />
<result column="shopId" property="shopId" />
<result column="authorId" property="authorId" />
<result column="style" property="style" />
<result column="attribute71" property="attribute71" />
</resultMap>
<!-- Spellbuyrecord 结果映射 -->
<resultMap id="SpellbuyrecordResultMap" type="me.mofun.entity.Spellbuyrecord">
<id column="spellbuyRecordId" property="spellbuyRecordId" />
<result column="fkSpellbuyProductId" property="fkSpellbuyProductId" />
<result column="buyer" property="buyer" />
<result column="buyPrice" property="buyPrice" />
<result column="buyDate" property="buyDate" />
<result column="spRandomNo" property="spRandomNo" />
<result column="spWinningStatus" property="spWinningStatus" />
<result column="buyStatus" property="buyStatus" />
<result column="buyIp" property="buyIp" />
<result column="buyLocal" property="buyLocal" />
<result column="buySource" property="buySource" />
<result column="attribute66" property="attribute66" />
<result column="attribute67" property="attribute67" />
</resultMap>
<!-- User 结果映射 -->
<resultMap id="UserResultMap" type="me.mofun.entity.User">
<id column="userId" property="userId" />
<result column="userName" property="userName" />
<result column="userPwd" property="userPwd" />
<result column="changePwdNo" property="changePwdNo" />
<result column="changePwdTime" property="changePwdTime" />
<result column="realName" property="realName" />
<result column="cardNo" property="cardNo" />
<result column="mobilePhone" property="mobilePhone" />
<result column="mobileCheck" property="mobileCheck" />
<result column="phone" property="phone" />
<result column="groupIdList" property="groupIdList" />
<result column="qq" property="qq" />
<result column="qqOpenId" property="qqOpenId" />
<result column="mail" property="mail" />
<result column="mailCheck" property="mailCheck" />
<result column="mailKey" property="mailKey" />
<result column="smsKey" property="smsKey" />
<result column="sex" property="sex" />
<result column="birthday" property="birthday" />
<result column="faceImg" property="faceImg" />
<result column="location" property="location" />
<result column="postNo" property="postNo" />
<result column="ipAddress" property="ipAddress" />
<result column="ipLocation" property="ipLocation" />
<result column="oldIpAddress" property="oldIpAddress" />
<result column="maritalStatus" property="maritalStatus" />
<result column="monthlyIncome" property="monthlyIncome" />
<result column="Interests" property="Interests" />
<result column="attribute22" property="attribute22" />
<result column="oldDate" property="oldDate" />
<result column="newDate" property="newDate" />
<result column="balance" property="balance" />
<result column="userType" property="userType" />
<result column="experience" property="experience" />
<result column="signature" property="signature" />
<result column="invite" property="invite" />
<result column="inviteShortURL" property="inviteShortURL" />
<result column="commissionCount" property="commissionCount" />
<result column="commissionBalance" property="commissionBalance" />
<result column="commissionMention" property="commissionMention" />
<result column="commissionPoints" property="commissionPoints" />
<result column="shopId" property="shopId" />
<result column="creatorId" property="creatorId" />
<result column="jobTags" property="jobTags" />
<result column="roleName" property="roleName" />
<result column="jobName" property="jobName" />
</resultMap>
<!-- 用户、拍购商品和记录联合映射 -->
<resultMap id="UserSpellbuyproductRecordDTOMap" type="me.mofun.entity.dto.UserSpellbuyproductRecordDTO">
<result column="buyPriceSum" property="buyPriceSum" />
<association property="spellbuyproduct" resultMap="BaseResultMap" />
<association property="spellbuyrecord" resultMap="SpellbuyrecordResultMap" />
<association property="user" resultMap="UserResultMap" />
</resultMap>
<!-- 根据外键产品ID返回最新一个该商品的最新拍购对象 -->
<select id="findByFKProductId" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE fkProductId = #{fkProductId}
ORDER BY spellbuyProductId DESC
LIMIT 1
</select>
<!-- 根据商品的拍购ID获取拍购商品相关属性 -->
<select id="findBySpellbuyProductId" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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 spellbuyproduct st, product pt
WHERE pt.productId = st.fkProductId
AND st.spellbuyProductId = #{spellbuyProductId}
</select>
<!-- 根据商品ID获取拍购商品相关属性 -->
<select id="findByFKProductIdList" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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 spellbuyproduct st, product pt
WHERE pt.productId = st.fkProductId
AND st.fkProductId = #{fkProductId}
ORDER BY st.spellbuyProductId DESC
</select>
<!-- 即将揭晓商品 -->
<select id="upcomingAnnounced" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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.spellbuyCount > (pt.productPrice / 1.5))
AND st.spStatus != 1
GROUP BY pt.productId
ORDER BY st.spellbuyCount DESC
</select>
<!-- 人气TOP榜 -->
<select id="upcomingAnnouncedByTop" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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.isShow = 1
AND st.fkProductId = pt.productId
AND st.spStatus != 1
GROUP BY pt.productId
ORDER BY st.spellbuyCount DESC
</select>
<!-- 商品期数列表 -->
<select id="productPeriodList" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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 spellbuyproduct st, product pt
WHERE st.fkProductId = pt.productId
AND pt.productId = #{productId}
ORDER BY st.productPeriod DESC
</select>
<!-- 根据产品ID获取最新期数 -->
<select id="findSpellbuyproductLastPeriod" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE fkProductId = #{productId}
ORDER BY productPeriod DESC
LIMIT 1
</select>
<!-- 根据产品ID和状态查找 -->
<select id="findSpellbuyproductByStatus" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE fkProductId = #{productId}
AND spStatus = 0
</select>
<!-- 已揭晓商品 -->
<select id="announcedProduct" resultType="me.mofun.entity.dto.ProductSpellbuyproductDTO">
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
</select>
<!-- 按类型加载所有 -->
<select id="loadAllByType" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE spStatus != 1
AND spellbuyType = 8
</select>
<!-- 加载所有 -->
<select id="loadAll" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE spStatus != 1
</select>
<!-- 获取最新开奖商品 -->
<select id="updateLatestlotteryGetList" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE spStatus = 1
</select>
<!-- 根据产品ID和状态查找列表 -->
<select id="findSpellbuyproductByProductIdIsStatus" resultMap="BaseResultMap">
SELECT *
FROM spellbuyproduct
WHERE fkProductId = #{productId}
AND spStatus = 0
</select>
<!-- 检查用户限购情况 -->
<select id="checkUserLimitBuy" resultMap="UserSpellbuyproductRecordDTOMap">
<choose>
<when test="userId != null and userId != ''">
SELECT DISTINCT
p.*,
u.*,
r.spellbuyRecordId,
r.fkSpellbuyProductId,
r.buyer,
SUM(r.buyPrice) as buyPriceSum,
r.buyDate,
r.buyIp,
r.buyLocal,
r.buySource,
r.buyStatus,
r.spRandomNo,
r.spWinningStatus,
r.attribute66,
r.attribute67
FROM spellbuyproduct p, spellbuyrecord r, user u
WHERE r.fkSpellbuyProductId = p.spellbuyProductId
AND r.buyer = u.userId
AND r.fkSpellbuyProductId = #{spellbuyId}
AND u.userId = #{userId}
</when>
<otherwise>
SELECT *
FROM spellbuyproduct p
WHERE p.spellbuyProductId = #{spellbuyId}
</otherwise>
</choose>
</select>
</mapper>

@ -2,237 +2,641 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="me.mofun.mapper.SpellbuyrecordMapper">
<!-- 热门商品查询 -->
<select id="findHotProductList" resultType="java.util.Map">
select pt.*, st.*
from product pt, spellbuyproduct st
where 1=1
and st.fkProductId=pt.productId
and st.spStatus <> 1
GROUP by pt.productId
order by st.spellbuyCount desc
<resultMap id="BaseResultMap" type="me.mofun.entity.Spellbuyrecord">
<id column="spellbuyRecordId" property="spellbuyRecordId" />
<result column="fkSpellbuyProductId" property="fkSpellbuyProductId" />
<result column="buyer" property="buyer" />
<result column="buyPrice" property="buyPrice" />
<result column="buyDate" property="buyDate" />
<result column="spRandomNo" property="spRandomNo" />
<result column="spWinningStatus" property="spWinningStatus" />
<result column="buyStatus" property="buyStatus" />
<result column="buyIp" property="buyIp" />
<result column="buyLocal" property="buyLocal" />
<result column="buySource" property="buySource" />
<result column="attribute66" property="attribute66" />
<result column="attribute67" property="attribute67" />
</resultMap>
<!-- 定义结果映射 -->
<resultMap id="ProductSpellbuyproductMap" type="me.mofun.entity.dto.ProductSpellbuyproductDTO">
<association property="product" javaType="me.mofun.entity.Product">
<id property="productId" column="pt_productId" />
<result property="productName" column="pt_productName" />
<result property="productPrice" column="pt_productPrice" />
<result property="marketPrice" column="pt_marketPrice" />
<result property="singlePrice" column="pt_singlePrice" />
<result property="productLimit" column="pt_productLimit" />
<result property="productRealPrice" column="pt_productRealPrice" />
<result property="productTitle" column="pt_productTitle" />
<result property="productDetail" column="pt_productDetail" />
<result property="productType" column="pt_productType" />
<result property="productBrand" column="pt_productBrand" />
<result property="headImage" column="pt_headImage" />
<result property="status" column="pt_status" />
<result property="isShow" column="pt_isShow" />
<result property="isVirtual" column="pt_isVirtual" />
<result property="isNeedLogic" column="pt_isNeedLogic" />
<result property="logicURL" column="pt_logicURL" />
<result property="shopId" column="pt_shopId" />
<result property="authorId" column="pt_authorId" />
<result property="style" column="pt_style" />
<result property="attribute71" column="pt_attribute71" />
</association>
<association property="spellbuyproduct" javaType="me.mofun.entity.Spellbuyproduct">
<id property="spellbuyProductId" column="st_spellbuyProductId" />
<result property="fkProductId" column="st_fkProductId" />
<result property="spellbuyStartDate" column="st_spellbuyStartDate" />
<result property="spellbuyEndDate" column="st_spellbuyEndDate" />
<result property="spellbuyCount" column="st_spellbuyCount" />
<result property="spellbuyPrice" column="st_spellbuyPrice" />
<result property="marketPrice" column="st_marketPrice" />
<result property="actionName" column="st_actionName" />
<result property="spSinglePrice" column="st_spSinglePrice" />
<result property="productPeriod" column="st_productPeriod" />
<result property="spellbuyLimit" column="st_spellbuyLimit" />
<result property="spStatus" column="st_spStatus" />
<result property="spellbuyType" column="st_spellbuyType" />
<result property="attribute64" column="st_attribute64" />
<result property="attribute65" column="st_attribute65" />
</association>
</resultMap>
<resultMap id="SpellbuyrecordDTOMap" type="me.mofun.entity.dto.SpellbuyrecordDTO">
<association property="product" javaType="me.mofun.entity.Product">
<id column="pt_productId" property="productId" />
<result column="pt_productName" property="productName" />
<result column="pt_productPrice" property="productPrice" />
<result column="pt_marketPrice" property="marketPrice" />
<result column="pt_singlePrice" property="singlePrice" />
<result column="pt_productLimit" property="productLimit" />
<result column="pt_productRealPrice" property="productRealPrice" />
<result column="pt_productTitle" property="productTitle" />
<result column="pt_productDetail" property="productDetail" />
<result column="pt_productType" property="productType" />
<result column="pt_productBrand" property="productBrand" />
<result column="pt_headImage" property="headImage" />
<result column="pt_status" property="status" />
<result column="pt_isShow" property="isShow" />
<result column="pt_isVirtual" property="isVirtual" />
<result column="pt_isNeedLogic" property="isNeedLogic" />
<result column="pt_logicURL" property="logicURL" />
<result column="pt_shopId" property="shopId" />
<result column="pt_authorId" property="authorId" />
<result column="pt_style" property="style" />
<result column="pt_attribute71" property="attribute71" />
</association>
<association property="user" javaType="me.mofun.entity.User">
<id column="ur_userId" property="userId" />
<result column="ur_userName" property="userName" />
<result column="ur_userPwd" property="userPwd" />
<result column="ur_changePwdNo" property="changePwdNo" />
<result column="ur_changePwdTime" property="changePwdTime" />
<result column="ur_realName" property="realName" />
<result column="ur_cardNo" property="cardNo" />
<result column="ur_mobilePhone" property="mobilePhone" />
<result column="ur_mobileCheck" property="mobileCheck" />
<result column="ur_phone" property="phone" />
<result column="ur_groupIdList" property="groupIdList" />
<result column="ur_qq" property="qq" />
<result column="ur_qqOpenId" property="qqOpenId" />
<result column="ur_mail" property="mail" />
<result column="ur_mailCheck" property="mailCheck" />
<result column="ur_mailKey" property="mailKey" />
<result column="ur_smsKey" property="smsKey" />
<result column="ur_sex" property="sex" />
<result column="ur_birthday" property="birthday" />
<result column="ur_faceImg" property="faceImg" />
<result column="ur_location" property="location" />
<result column="ur_postNo" property="postNo" />
<result column="ur_ipAddress" property="ipAddress" />
<result column="ur_ipLocation" property="ipLocation" />
<result column="ur_oldIpAddress" property="oldIpAddress" />
<result column="ur_maritalStatus" property="maritalStatus" />
<result column="ur_monthlyIncome" property="monthlyIncome" />
<result column="ur_Interests" property="Interests" />
<result column="ur_attribute22" property="attribute22" />
<result column="ur_oldDate" property="oldDate" />
<result column="ur_newDate" property="newDate" />
<result column="ur_balance" property="balance" />
<result column="ur_userType" property="userType" />
<result column="ur_experience" property="experience" />
<result column="ur_signature" property="signature" />
<result column="ur_invite" property="invite" />
<result column="ur_inviteShortURL" property="inviteShortURL" />
<result column="ur_commissionCount" property="commissionCount" />
<result column="ur_commissionBalance" property="commissionBalance" />
<result column="ur_commissionMention" property="commissionMention" />
<result column="ur_commissionPoints" property="commissionPoints" />
<result column="ur_shopId" property="shopId" />
<result column="ur_creatorId" property="creatorId" />
<result column="ur_jobTags" property="jobTags" />
<result column="ur_roleName" property="roleName" />
<result column="ur_jobName" property="jobName" />
</association>
<association property="spellbuyproduct" javaType="me.mofun.entity.Spellbuyproduct">
<id column="st_spellbuyProductId" property="spellbuyProductId" />
<result column="st_fkProductId" property="fkProductId" />
<result column="st_spellbuyStartDate" property="spellbuyStartDate" />
<result column="st_spellbuyEndDate" property="spellbuyEndDate" />
<result column="st_spellbuyCount" property="spellbuyCount" />
<result column="st_spellbuyPrice" property="spellbuyPrice" />
<result column="st_marketPrice" property="marketPrice" />
<result column="st_actionName" property="actionName" />
<result column="st_spSinglePrice" property="spSinglePrice" />
<result column="st_productPeriod" property="productPeriod" />
<result column="st_spellbuyLimit" property="spellbuyLimit" />
<result column="st_spStatus" property="spStatus" />
<result column="st_spellbuyType" property="spellbuyType" />
<result column="st_attribute64" property="attribute64" />
<result column="st_attribute65" property="attribute65" />
</association>
<association property="spellbuyrecord" javaType="me.mofun.entity.Spellbuyrecord">
<id column="sd_spellbuyRecordId" property="spellbuyRecordId" />
<result column="sd_fkSpellbuyProductId" property="fkSpellbuyProductId" />
<result column="sd_buyer" property="buyer" />
<result column="sd_buyPrice" property="buyPrice" />
<result column="sd_buyDate" property="buyDate" />
<result column="sd_spRandomNo" property="spRandomNo" />
<result column="sd_spWinningStatus" property="spWinningStatus" />
<result column="sd_buyStatus" property="buyStatus" />
<result column="sd_buyIp" property="buyIp" />
<result column="sd_buyLocal" property="buyLocal" />
<result column="sd_buySource" property="buySource" />
<result column="sd_attribute66" property="attribute66" />
<result column="sd_attribute67" property="attribute67" />
</association>
</resultMap>
<resultMap id="SpellbuyrecordExtMap" type="me.mofun.entity.Spellbuyrecord">
<id column="spellbuyRecordId" property="spellbuyRecordId" />
<result column="fkSpellbuyProductId" property="fkSpellbuyProductId" />
<result column="buyer" property="buyer" />
<result column="buyPrice" property="buyPrice" />
<result column="buyDate" property="buyDate" />
<result column="spRandomNo" property="spRandomNo" />
<result column="spWinningStatus" property="spWinningStatus" />
<result column="buyStatus" property="buyStatus" />
<result column="buyIp" property="buyIp" />
<result column="buyLocal" property="buyLocal" />
<result column="buySource" property="buySource" />
<result column="attribute66" property="attribute66" />
<result column="attribute67" property="attribute67" />
<result column="spSinglePrice" property="spSinglePrice" />
</resultMap>
<!-- 首页最热门商品 -->
<select id="findHotProductList" resultMap="ProductSpellbuyproductMap">
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 &lt;&gt; 1
GROUP BY pt.productId
ORDER BY st.spellbuyCount DESC
</select>
<!-- 首页最新上架商品 -->
<select id="indexNewProductList" resultType="java.util.Map">
select pt.*, st.*
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 id="indexNewProductList" resultMap="ProductSpellbuyproductMap">
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 &lt;&gt; 1
GROUP BY pt.productId
ORDER BY st.spellbuyStartDate DESC
</select>
<!-- 首页人气排行商品 -->
<select id="indexHotProductList" resultType="java.util.Map">
select pt.*, st.*
from product pt, spellbuyproduct st
where 1=1
and st.fkProductId=pt.productId
and st.spStatus <> 1
GROUP by pt.productId
order by st.productPeriod desc
</select>
<!-- 正在购买列表 -->
<select id="getNowBuyList" resultType="me.mofun.entity.dto.SpellbuyrecordDTO">
select ur.*, sd.*, pt.*, st.*
from User ur, spellbuyrecord sd, Product pt, spellbuyproduct st
where 1=1
and sd.buyer=ur.userId
and sd.fkSpellbuyProductId=st.spellbuyProductId
and st.fkProductId=pt.productId
order by sd.buyDate desc
</select>
<!-- 按商品类型查询商品 -->
<select id="indexHotProductList" resultMap="ProductSpellbuyproductMap">
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 &lt;&gt; 1
GROUP BY pt.productId
ORDER BY st.productPeriod DESC
</select>
<!-- 他们正在购买 -->
<select id="getNowBuyList" resultMap="SpellbuyrecordDTOMap">
SELECT
ur.userId as ur_userId, ur.userName as ur_userName, ur.userPwd as ur_userPwd,
ur.changePwdNo as ur_changePwdNo, ur.changePwdTime as ur_changePwdTime,
ur.realName as ur_realName, ur.cardNo as ur_cardNo, ur.mobilePhone as ur_mobilePhone,
ur.mobileCheck as ur_mobileCheck, ur.phone as ur_phone, ur.groupIdList as ur_groupIdList,
ur.qq as ur_qq, ur.qqOpenId as ur_qqOpenId, ur.mail as ur_mail, ur.mailCheck as ur_mailCheck,
ur.mailKey as ur_mailKey, ur.smsKey as ur_smsKey, ur.sex as ur_sex, ur.birthday as ur_birthday,
ur.faceImg as ur_faceImg, ur.location as ur_location, ur.postNo as ur_postNo,
ur.ip_address as ur_ipAddress, ur.ip_location as ur_ipLocation, ur.oldIpAddress as ur_oldIpAddress,
ur.marital_status as ur_maritalStatus, ur.Monthly_income as ur_monthlyIncome,
ur.Interests as ur_Interests, ur.Attribute_22 as ur_attribute22, ur.oldDate as ur_oldDate,
ur.newDate as ur_newDate, ur.balance as ur_balance, ur.userType as ur_userType,
ur.experience as ur_experience, ur.signature as ur_signature, ur.invite as ur_invite,
ur.inviteShortURL as ur_inviteShortURL, ur.commissionCount as ur_commissionCount,
ur.commissionBalance as ur_commissionBalance, ur.commissionMention as ur_commissionMention,
ur.commissionPoints as ur_commissionPoints, ur.shopId as ur_shopId, ur.creatorId as ur_creatorId,
ur.jobTags as ur_jobTags, ur.roleName as ur_roleName, ur.jobName as ur_jobName,
sd.spellbuyRecordId as sd_spellbuyRecordId, sd.fkSpellbuyProductId as sd_fkSpellbuyProductId,
sd.buyer as sd_buyer, sd.buyPrice as sd_buyPrice, sd.buyDate as sd_buyDate,
sd.spRandomNo as sd_spRandomNo, sd.spWinningStatus as sd_spWinningStatus,
sd.buyStatus as sd_buyStatus, sd.buyIp as sd_buyIp, sd.buyLocal as sd_buyLocal,
sd.buySource as sd_buySource, sd.Attribute_66 as sd_attribute66, sd.Attribute_67 as sd_attribute67,
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 user ur, spellbuyrecord sd, product pt, spellbuyproduct st
WHERE sd.buyer = ur.userId AND sd.fkSpellbuyProductId = st.spellbuyProductId AND st.fkProductId = pt.productId
ORDER BY sd.buyDate DESC
</select>
<!-- 首页按商品类型查询商品 -->
<select id="findProductByTypeId" resultType="java.util.Map">
select pt.*, st.*
from product pt, spellbuyproduct st
where st.fkProductId=pt.productId
and st.spStatus <> 1
SELECT
pt.*,
st.*
FROM product pt, spellbuyproduct st
WHERE st.fkProductId = pt.productId AND st.spStatus &lt;&gt; 1
<if test="typeId != null and typeId != ''">
and (1=2
or (1=1 and pt.productType= #{typeId})
<foreach collection="childTypeIds" item="childTypeId" separator="or">
or (1=1 and pt.productType= #{childTypeId})
</foreach>
AND (1=2
OR pt.productType = #{typeId}
<if test="childTypeIds != null and childTypeIds.size() > 0">
OR pt.productType IN
<foreach collection="childTypeIds" item="childTypeId" open="(" separator="," close=")">
#{childTypeId}
</foreach>
</if>
)
</if>
GROUP by pt.productId
GROUP BY pt.productId
</select>
<!-- 商品页按商品类型查询 -->
<!-- 商品页按商品类型查询商品 -->
<select id="productByTypeIdList" resultType="java.util.Map">
select pt.*, st.*
from product pt, spellbuyproduct st
where pt.status=1
and pt.isShow=1
and st.fkProductId=pt.productId
and st.spStatus <> 1
SELECT
pt.*,
st.*
FROM product pt, spellbuyproduct st
WHERE pt.status = 1 AND pt.isShow = 1 AND st.fkProductId = pt.productId AND st.spStatus &lt;&gt; 1
<if test="typeId != null and typeId != ''">
and (1=2
or (1=1 and pt.productType= #{typeId})
<foreach collection="childTypeIds" item="childTypeId" separator="or">
or (1=1 and pt.productType= #{childTypeId})
</foreach>
AND (1=2
OR pt.productType = #{typeId}
<if test="childTypeIds != null and childTypeIds.size() > 0">
OR pt.productType IN
<foreach collection="childTypeIds" item="childTypeId" open="(" separator="," close=")">
#{childTypeId}
</foreach>
</if>
)
</if>
<if test="brandId != null and brandId != ''">
and pt.productBrand=#{brandId}
</if>
<if test="orderName == 'hot'">
GROUP by st.spellbuyProductId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'date'">
GROUP by st.spellbuyProductId
order by st.spellbuyStartDate desc
</if>
<if test="orderName == 'price'">
GROUP by st.spellbuyProductId
order by pt.productPrice desc
</if>
<if test="orderName == 'priceAsc'">
GROUP by st.spellbuyProductId
order by pt.productPrice asc
</if>
<if test="orderName == 'about'">
and (st.spellbuyCount > (pt.productPrice/1.5))
GROUP by pt.productId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'surplus'">
GROUP by pt.productId
order by (pt.productPrice - st.spellbuyCount) asc
AND pt.productBrand = #{brandId}
</if>
<choose>
<when test="orderName == 'hot'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'date'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyStartDate DESC
</when>
<when test="orderName == 'price'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice DESC
</when>
<when test="orderName == 'priceAsc'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice ASC
</when>
<when test="orderName == 'about'">
AND (st.spellbuyCount > (pt.productPrice/1.5)) GROUP BY pt.productId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'surplus'">
GROUP BY pt.productId ORDER BY (pt.productPrice - st.spellbuyCount) ASC
</when>
<otherwise>
GROUP BY st.spellbuyProductId
</otherwise>
</choose>
</select>
<!-- 商品页按商品类型及所属用户查询 -->
<select id="productByTypeIdListAndShopId" resultType="java.util.Map">
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
<!-- 商品页按商品类型及所属用户查询商品 -->
<select id="productByTypeIdListAndShopId" resultMap="ProductSpellbuyproductMap">
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 &lt;&gt; 1
<if test="typeId != null and typeId != ''">
and (1=2
or (1=1 and pt.productType= #{typeId})
<foreach collection="childTypeIds" item="childTypeId" separator="or">
or (1=1 and pt.productType= #{childTypeId})
</foreach>
AND (1=2
OR pt.productType = #{typeId}
<if test="childTypeIds != null and childTypeIds.size() > 0">
OR pt.productType IN
<foreach collection="childTypeIds" item="childTypeId" open="(" separator="," close=")">
#{childTypeId}
</foreach>
</if>
)
</if>
<if test="brandId != null and brandId != ''">
and pt.productBrand=#{brandId}
</if>
<if test="orderName == 'hot'">
GROUP by st.spellbuyProductId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'date'">
GROUP by st.spellbuyProductId
order by st.spellbuyStartDate desc
</if>
<if test="orderName == 'price'">
GROUP by st.spellbuyProductId
order by pt.productPrice desc
</if>
<if test="orderName == 'priceAsc'">
GROUP by st.spellbuyProductId
order by pt.productPrice asc
</if>
<if test="orderName == 'about'">
and (st.spellbuyCount > (pt.productPrice/1.5))
GROUP by pt.productId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'surplus'">
GROUP by pt.productId
order by (pt.productPrice - st.spellbuyCount) asc
AND pt.productBrand = #{brandId}
</if>
<choose>
<when test="orderName == 'hot'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'date'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyStartDate DESC
</when>
<when test="orderName == 'price'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice DESC
</when>
<when test="orderName == 'priceAsc'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice ASC
</when>
<when test="orderName == 'about'">
AND (st.spellbuyCount > (pt.productPrice/1.5)) GROUP BY pt.productId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'surplus'">
GROUP BY pt.productId ORDER BY (pt.productPrice - st.spellbuyCount) ASC
</when>
<otherwise>
GROUP BY st.spellbuyProductId
</otherwise>
</choose>
</select>
<!-- 搜索商品 -->
<select id="searchProduct" resultType="java.util.Map">
select pt.*, st.*
from product pt, spellbuyproduct st
where st.fkProductId=pt.productId
and st.spStatus <> 1
and pt.productName like CONCAT('%', #{keyword}, '%')
<if test="orderName == 'hot'">
GROUP by st.spellbuyProductId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'date'">
GROUP by st.spellbuyProductId
order by st.spellbuyStartDate desc
</if>
<if test="orderName == 'price'">
GROUP by st.spellbuyProductId
order by pt.productPrice desc
</if>
<if test="orderName == 'priceAsc'">
GROUP by st.spellbuyProductId
order by pt.productPrice asc
</if>
<if test="orderName == 'about'">
and (st.spellbuyCount > (pt.productPrice/1.5))
GROUP by pt.productId
order by st.spellbuyCount desc
</if>
<if test="orderName == 'surplus'">
GROUP by pt.productId
order by (pt.productPrice - st.spellbuyCount) asc
</if>
<select id="searchProduct" resultMap="ProductSpellbuyproductMap">
SELECT
pt.*,
st.*
FROM product pt, spellbuyproduct st
WHERE st.fkProductId = pt.productId AND st.spStatus &lt;&gt; 1 AND pt.productName LIKE CONCAT('%', #{keyword}, '%')
<choose>
<when test="orderName == 'hot'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'date'">
GROUP BY st.spellbuyProductId ORDER BY st.spellbuyStartDate DESC
</when>
<when test="orderName == 'price'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice DESC
</when>
<when test="orderName == 'priceAsc'">
GROUP BY st.spellbuyProductId ORDER BY pt.productPrice ASC
</when>
<when test="orderName == 'about'">
AND (st.spellbuyCount > (pt.productPrice/1.5)) GROUP BY pt.productId ORDER BY st.spellbuyCount DESC
</when>
<when test="orderName == 'surplus'">
GROUP BY pt.productId ORDER BY (pt.productPrice - st.spellbuyCount) ASC
</when>
<otherwise>
GROUP BY st.spellbuyProductId
</otherwise>
</choose>
</select>
<!-- 其他方法的SQL映射... -->
<!-- 最新参与 -->
<select id="latestParticipate" resultType="java.util.Map">
select ur.*, sd.*
from user ur, spellbuyrecord sd
where sd.buyer=ur.userId
and sd.fkSpellbuyProductId = #{spellbuyProductId}
order by sd.buyDate desc
SELECT
ur.*,
sd.*
FROM user ur, spellbuyrecord sd
WHERE sd.buyer = ur.userId AND sd.fkSpellbuyProductId = #{spellbuyProductId}
ORDER BY sd.buyDate DESC
</select>
<!-- 获取某商品最新参与人数 -->
<select id="latestParticipateByCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM user ur, spellbuyrecord sd
WHERE sd.buyer = ur.userId AND sd.fkSpellbuyProductId = #{spellbuyProductId}
</select>
<select id="getRandomNumberListPage" resultType="me.mofun.pojo.Randomnumber">
SELECT * from randomnumber rr
where rr.productId = #{spellbuyProductId}
and rr.userId = #{userId}
order by rr.buyDate desc
<!-- 得到某条购买记录的随机码(详细页面) -->
<select id="getRandomNumberListPage" resultType="java.util.Map">
SELECT *
FROM randomnumber rr
WHERE rr.productId = #{spellbuyProductId} AND rr.userId = #{userId}
ORDER BY rr.buyDate DESC
</select>
<select id="buyHistoryByUser" resultType="me.mofun.pojo.BuyHistoryJSON">
select st.spellbuyProductId as productId,
<!-- 查询某用户的购买记录 -->
<select id="buyHistoryByUser" resultType="me.mofun.entity.pojo.BuyHistoryJSON">
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}
<if test="startDate != null and startDate != ''">
AND sd.buyDate &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND sd.buyDate &lt;= #{endDate}
</if>
GROUP BY st.spellbuyProductId
ORDER BY sd.buyDate DESC
</select>
<!-- 查询某用户购买记录详情 -->
<select id="getBuyHistoryByDetail" resultType="me.mofun.entity.pojo.BuyHistoryJSON">
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,
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}
AND st.spellbuyProductId = #{productId}
</select>
<!-- 获取登录用户自己的历史购买记录 -->
<select id="getUserByHistory" resultMap="SpellbuyrecordExtMap">
SELECT
sd.*,
sp.spSinglePrice
FROM spellbuyrecord sd, spellbuyproduct sp
WHERE sd.buyer = #{userId}
AND sd.fkSpellbuyProductId = #{fkSpellbuyProductId}
AND sd.fkSpellbuyProductId = sp.spellbuyProductId
ORDER BY sd.buyDate DESC
LIMIT 8
</select>
<!-- 统计方法 -->
<select id="getAllByCount" resultType="java.math.BigDecimal">
SELECT SUM(buyPrice) FROM spellbuyrecord
</select>
<select id="findSumByBuyPriceByUserId" resultType="java.math.BigDecimal">
SELECT SUM(buyPrice) FROM spellbuyrecord WHERE buyer = #{userId}
</select>
<select id="buyHistoryByUserByCount" resultType="java.lang.Integer">
SELECT COUNT(*) FROM (
SELECT COUNT(*)
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}
<if test="startDate != null and startDate != ''">
and sd.buyDate &gt;= #{startDate}
AND sd.buyDate &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and sd.buyDate &lt;= #{endDate}
AND sd.buyDate &lt;= #{endDate}
</if>
group by st.spellbuyProductId
order by sd.buyDate desc
GROUP BY st.spellbuyProductId
) as counts
</select>
<select id="getRandomNumberListPageByCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM randomnumber rr
WHERE rr.productId = #{spellbuyProductId} AND rr.userId = #{userId}
</select>
</mapper>
Loading…
Cancel
Save