update

1 个父辈 fd340ce7
......@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -25,15 +26,18 @@ import org.theyeasy.weixin.util.WxMiniUtil;
import com.beust.jcommander.internal.Maps;
import com.w1hd.zzhnc.controller.pc.BaseController;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.LotteryLogDao;
import com.w1hd.zzhnc.model.Articles;
import com.w1hd.zzhnc.model.Banner;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Goods;
import com.w1hd.zzhnc.model.Lotterylog;
import com.w1hd.zzhnc.service.ActivityService;
import com.w1hd.zzhnc.service.ArticleService;
import com.w1hd.zzhnc.service.BannerService;
import com.w1hd.zzhnc.service.FansService;
import com.w1hd.zzhnc.service.GoodsService;
import com.w1hd.zzhnc.service.PrizeService;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.MiniHomeVO;
......@@ -55,9 +59,9 @@ public class WxMiniController extends BaseController {
ActivityService activityService;
@Autowired
FansDao fansDao;
PrizeService prizeService;
@RequestMapping(value="/wxmsg",method=RequestMethod.GET)
@RequestMapping(value = "/wxmsg", method = RequestMethod.GET)
public void WxMsg(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
......@@ -95,7 +99,7 @@ public class WxMiniController extends BaseController {
}
@RequestMapping(value="/login",method=RequestMethod.GET) // 购房助手登录 double lng,double lat
@RequestMapping(value = "/login", method = RequestMethod.GET) // 购房助手登录 double lng,double lat
public @ResponseBody Vo_msg login(@RequestParam(value = "code") String code,
@RequestParam(value = "shareId") Integer shareId, @RequestParam(value = "nickname") String nickname,
@RequestParam(value = "logo") String logo, @RequestParam(value = "lng") double lng,
......@@ -142,7 +146,7 @@ public class WxMiniController extends BaseController {
}
// 强制刷新Token
@RequestMapping(value = "/refresh_token",method = RequestMethod.POST)
@RequestMapping(value = "/refresh_token", method = RequestMethod.POST)
public @ResponseBody String refreshToken(String pwd) {
if (!pwd.equals("nmdzpsmhs"))
return "error pwd";
......@@ -150,7 +154,7 @@ public class WxMiniController extends BaseController {
}
// 文章列表
@RequestMapping(value = "/getArticlesList",method = RequestMethod.GET)
@RequestMapping(value = "/getArticlesList", method = RequestMethod.GET)
@ResponseBody
public Object getArticlesList(Integer page, Integer pagesize) {
......@@ -158,7 +162,7 @@ public class WxMiniController extends BaseController {
}
// 增加文章浏览数
@RequestMapping(value = "/addArticleViewCount",method = RequestMethod.GET)
@RequestMapping(value = "/addArticleViewCount", method = RequestMethod.GET)
@ResponseBody
public Object addArticleViewCount(Integer id) {
articleService.addArticleViewCount(id);
......@@ -166,7 +170,7 @@ public class WxMiniController extends BaseController {
}
// 获取
@RequestMapping(value = "/getArticle",method=RequestMethod.GET)
@RequestMapping(value = "/getArticle", method = RequestMethod.GET)
@ResponseBody
public Object getArticle(Integer id) {
Articles article = articleService.getArticle(id);
......@@ -238,7 +242,7 @@ public class WxMiniController extends BaseController {
// }
//
// 清除小程序卡片的media_id的方法
@RequestMapping(value = "/cleanProgramMedia",method=RequestMethod.GET)
@RequestMapping(value = "/cleanProgramMedia", method = RequestMethod.GET)
@ResponseBody
public String cleanProgramMedia(@RequestParam(value = "code") String code) {
if (!code.equals("nmdzpsmhs"))
......@@ -254,7 +258,7 @@ public class WxMiniController extends BaseController {
@Autowired
GoodsService goodsService;
@RequestMapping(value = "/index",method=RequestMethod.GET)
@RequestMapping(value = "/index", method = RequestMethod.GET)
@ResponseBody
public Object index(@RequestParam("openId") String openId) {
try {
......@@ -262,27 +266,26 @@ public class WxMiniController extends BaseController {
List<Banner> bannerList = bannerService.getAll();
List<Articles> homeData = articleService.getHomeData();
List<Goods> homeData2 = goodsService.getHomeData();
result.put("banner", bannerList);
List<MiniHomeVO> data = MiniHomeVO.getData(homeData, homeData2);
result.put("data", data);
result.put("bannerList", bannerList);
result.put("articlesList", homeData);
result.put("goodsList", homeData2);
return new Vo_msg(0, result);
} catch (Exception e) {
return new Vo_msg(-1, "系统繁忙");
}
}
@RequestMapping(value = "/second",method=RequestMethod.GET)
@RequestMapping(value = "/second", method = RequestMethod.GET)
@ResponseBody
public Object second(
@RequestParam(value="openId") String openId,
@RequestParam(value="key",defaultValue = "",required=false)String key,
@RequestParam(value="page",defaultValue = "1",required=false)Integer page,
@RequestParam(value="size",defaultValue = "20",required=false)Integer size) {
public Object second(@RequestParam(value = "openId") String openId,
@RequestParam(value = "key", defaultValue = "", required = false) String key,
@RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
@RequestParam(value = "size", defaultValue = "20", required = false) Integer size) {
try {
Map<String, Object> result = Maps.newHashMap();
List<Banner> bannerList = bannerService.getAll();
PageResults<Goods> seacrh = goodsService.seacrh(null, key, null, page, size);
List<Goods> rows = seacrh.getRows();
PageResults<Goods> seacrh = goodsService.seacrh(null, key, null, page, size);
List<Goods> rows = seacrh.getRows();
result.put("banner", bannerList);
result.put("data", rows);
return new Vo_msg(0, result);
......@@ -291,4 +294,19 @@ public class WxMiniController extends BaseController {
}
}
@RequestMapping(value = "/prizes", method = RequestMethod.GET)
@ResponseBody
public Object prizes(@RequestParam(value = "openId") String openId) {
Fans fans = fansService.getFansByMiniOpenid(openId);
List<Lotterylog> list = prizeService.getMyLotteryLog(fans.getId());
return new Vo_msg(0, list);
}
@RequestMapping(value = "/prizes/{id}", method = RequestMethod.GET)
@ResponseBody
public Object prizes(@RequestParam(value = "openId") String openId, @PathVariable(value = "id") Integer id) {
Fans fans = fansService.getFansByMiniOpenid(openId);
return prizeService.updateLotteryLog(id, fans.getId());
}
}
......@@ -30,141 +30,45 @@ public class Lotterylog {
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.id
*
* @param id
* the value for lotterylog.id
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column lotterylog.fansid
*
* @return the value of lotterylog.fansid
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public Integer getFansid() {
return fansid;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.fansid
*
* @param fansid
* the value for lotterylog.fansid
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setFansid(Integer fansid) {
this.fansid = fansid;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column lotterylog.mny
*
* @return the value of lotterylog.mny
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public BigDecimal getMny() {
return mny;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.mny
*
* @param mny
* the value for lotterylog.mny
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setMny(BigDecimal mny) {
this.mny = mny;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column lotterylog.status
*
* @return the value of lotterylog.status
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public Integer getStatus() {
return status;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.status
*
* @param status
* the value for lotterylog.status
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column lotterylog.turn
*
* @return the value of lotterylog.turn
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public Integer getTurn() {
return turn;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.turn
*
* @param turn
* the value for lotterylog.turn
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setTurn(Integer turn) {
this.turn = turn;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column lotterylog.createdtime
*
* @return the value of lotterylog.createdtime
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public Date getCreatedtime() {
return createdtime;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column lotterylog.createdtime
*
* @param createdtime
* the value for lotterylog.createdtime
*
* @mbggenerated Thu Nov 30 17:43:59 CST 2017
*/
public void setCreatedtime(Date createdtime) {
this.createdtime = createdtime;
}
......
......@@ -24,7 +24,7 @@ public class GoodsService {
@Autowired
GoodsDao goodsDao;
final String GOODSID_ = RedisUtil.PROJECTNAME.concat("_").concat("goods");// 娲诲姩璁剧疆淇濆瓨key
final String GOODSID_ = RedisUtil.PROJECTNAME.concat("_").concat("goods");
public List<Goods> getHomeData() {
Example ex = new Example(Goods.class);
......
......@@ -7,10 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.testng.util.Strings;
import com.w1hd.zzhnc.dao.LotteryLogDao;
import com.w1hd.zzhnc.dao.PrizeDao;
import com.w1hd.zzhnc.model.Goods;
import com.w1hd.zzhnc.model.Lotterylog;
import com.w1hd.zzhnc.model.Prize;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.Lotterylog_Vo;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
......@@ -18,8 +22,13 @@ import tk.mybatis.mapper.entity.Example.Criteria;
@Service
public class PrizeService {
final String LotteryLogID_ = RedisUtil.PROJECTNAME.concat("_").concat("lotteryLog_");//中奖记里
@Autowired
PrizeDao prizeDao;
@Autowired
LotteryLogDao lotteryLogDao;
public boolean add(Prize prize) {
return prizeDao.insert(prize) > 0;
......@@ -51,5 +60,25 @@ public class PrizeService {
public boolean delete(String id) {
return prizeDao.deleteByPrimaryKey(id) > 0;
}
/**获取我的奖品*/
public List<Lotterylog> getMyLotteryLog(Integer fansId){
Example ex = new Example(Lotterylog.class);
Criteria c = ex.createCriteria();
c.andEqualTo("fansid",fansId);
List<Lotterylog> list = lotteryLogDao.selectByExample(ex);
return list;
}
/**核销一个奖品记录*/
public Lotterylog updateLotteryLog(Integer id, Integer fansId) {
Lotterylog lotterylog = lotteryLogDao.selectByPrimaryKey(id);
lotterylog.setStatus(2);
lotteryLogDao.updateByPrimaryKey(lotterylog);
return lotterylog;
}
}
Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
请先完成此消息的编辑!