123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- package com.ygj.yuemum.service.college;
- import com.ygj.yuemum.component.Constant;
- import com.ygj.yuemum.controller.global.WeChatInfoController;
- import com.ygj.yuemum.dao.college.CollegeUserPointsDao;
- import com.ygj.yuemum.domain.college.*;
- import com.ygj.yuemum.domain.customer.CustomerBooking;
- import com.ygj.yuemum.domain.wxmini.WXMktInfo;
- import com.ygj.yuemum.domain.wxmini.WXUser;
- import com.ygj.yuemum.service.coupon.CouponCreateService;
- import com.ygj.yuemum.service.customer.CustomerBookingService;
- import com.ygj.yuemum.service.wxmini.WXMktInfoService;
- import com.ygj.yuemum.service.wxmini.WXUserService;
- import com.ygj.yuemum.utils.DateUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ygj.yuemum.utils.DistanceUtil;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.LinkedHashMap;
- import java.util.LinkedList;
- import java.util.List;
- @Service
- public class CollegeUserPointsService {
- @Autowired
- private CollegeUserPointsDao collegeUserPointsDao;
- @Autowired
- private WXUserService wxUserService;
- @Autowired
- private CollegePresentCreditService collegePresentCreditService;
- @Autowired
- private CollegeCurriculumCoreService collegeCurriculumCoreService;
- @Autowired
- private CollegeCurriculumPracticeService collegeCurriculumPracticeService;
- @Autowired
- private CollegeCurriculumExperienceService collegeCurriculumExperienceService;
- @Autowired
- private CollegePointsDetailService collegePointsDetailService;
- @Autowired
- private CustomerBookingService customerBookingService;
- @Autowired
- private WeChatInfoController weChatInfoController;
- @Autowired
- private CouponCreateService couponCreateService;
- @Autowired
- private CollegeBookingService collegeBookingService;
- @Autowired
- private CollegeLearningDetailService collegeLearningDetailService;
- @Autowired
- private CollegeScholarshipsDetailService collegeScholarshipsDetailService;
- @Autowired
- private CollegePresentScholarshipsService collegePresentScholarshipsService;
- @Autowired
- private CollegeUserLevelService collegeUserLevelService;
- @Autowired
- private WXMktInfoService wxMktInfoService;
- public Integer LMP = Constant.LMP;
- public Integer AGE = Constant.AGE;
- public List<CollegeUserPoints> getCollegeUserPoints() {
- List<CollegeUserPoints> collegeUserPoints = collegeUserPointsDao.getAll();
- return collegeUserPoints;
- }
- public CollegeUserPoints getCollegeUserPoint(Integer id) {
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.selectByPrimaryKey(id);
- return collegeUserPoints;
- }
- public int addCollegeUserPoints(CollegeUserPoints collegeUserPoints) {
- return collegeUserPointsDao.insertSelective(collegeUserPoints);
- }
- public int deleteCollegeUserPoints(Integer id) {
- return collegeUserPointsDao.deleteByPrimaryKey(id);
- }
- public int updateCollegeUserPoints(CollegeUserPoints collegeUserPoints) {
- return collegeUserPointsDao.updateByPrimaryKeySelective(collegeUserPoints);
- }
- public int updatePointsByTest(CollegePointsDetail collegePointsDetail) {
- return collegeUserPointsDao.updatePointsByTest(collegePointsDetail);
- }
- public int updateScholarships(CollegeUserPoints collegePointsDetail) {
- return collegeUserPointsDao.updateScholarships(collegePointsDetail);
- }
- public CollegeUserPoints queryOneUserPoints(String openid) {
- return collegeUserPointsDao.queryOneUserPoints(openid);
- }
- public LinkedHashMap<String, Object> queryUserPoints(String openid, String city) {
- LinkedHashMap<String, Object> tableData = new LinkedHashMap<>();
- WXUser wxUser = wxUserService.getWXUser(openid);
- tableData.put("stage", null);
- tableData.put("stage_date", null);
- if (wxUser != null && wxUser.getXu_phone() != null) {
- if (wxUser.getXu_content_type() != null && wxUser.getXu_content_date() != null) {
- try {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat ldf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date dateNow = new Date();
- Date getDate = sdf.parse(wxUser.getXu_content_date());
- CollegeCurriculumCore collegeCurriculumCoreQuery = new CollegeCurriculumCore();
- CollegeCurriculumPractice collegeCurriculumPracticeQuery = new CollegeCurriculumPractice();
- CollegeCurriculumExperience collegeCurriculumExperienceQuery = new CollegeCurriculumExperience();
- collegeCurriculumCoreQuery.setOpenid(openid);
- collegeCurriculumPracticeQuery.setOpenid(openid);
- collegeCurriculumExperienceQuery.setOpenid(openid);
- CollegePointsDetail collegePointsDetail = new CollegePointsDetail();
- if (wxUser.getXu_content_type().equals("B01")) { //育儿
- if (dateNow.getTime() < getDate.getTime()) {
- //还没出生
- return tableData;
- } else {
- if (DateUtil.getMonthDiff(dateNow, getDate) + 1 > AGE) {
- return tableData;
- } else {
- tableData.put("stage_step", DateUtil.getMonthDiff(dateNow, getDate) + 1);
- collegeCurriculumCoreQuery.setC_type("B01");
- collegeCurriculumCoreQuery.setC_step(DateUtil.getMonthDiff(dateNow, getDate) + 1);
- collegeCurriculumPracticeQuery.setC_type("B01");
- collegeCurriculumPracticeQuery.setC_step(DateUtil.getMonthDiff(dateNow, getDate) + 1);
- collegeCurriculumExperienceQuery.setC_type("B01");
- collegeCurriculumExperienceQuery.setC_step(DateUtil.getMonthDiff(dateNow, getDate) + 1);
- }
- }
- } else if (wxUser.getXu_content_type().equals("P01")) { //孕周
- if (dateNow.getTime() < getDate.getTime()) {
- if (LMP - DateUtil.getWeekDiff(dateNow, getDate) < 0) {
- return tableData; //还没怀孕
- } else {
- tableData.put("stage_step", LMP - DateUtil.getWeekDiff(dateNow, getDate));
- collegeCurriculumCoreQuery.setC_type("P01");
- collegeCurriculumCoreQuery.setC_step(LMP - DateUtil.getWeekDiff(dateNow, getDate));
- collegeCurriculumPracticeQuery.setC_type("P01");
- collegeCurriculumPracticeQuery.setC_step(LMP - DateUtil.getWeekDiff(dateNow, getDate));
- collegeCurriculumExperienceQuery.setC_type("P01");
- collegeCurriculumExperienceQuery.setC_step(LMP - DateUtil.getWeekDiff(dateNow, getDate));
- }
- } else {
- return tableData;
- }
- } else {
- return tableData;
- }
- tableData.put("stage", wxUser.getXu_content_type());
- tableData.put("stage_date", wxUser.getXu_content_date());
- tableData.put("avatar_url", wxUser.getXu_avatarUrl());
- //查询学分
- int point_available = 0;
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
- if (collegeUserPoints == null) {
- CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
- collegeUserPointsNew.setOpenid(openid);
- collegeUserPointsNew.setCredit_total(0);
- collegeUserPointsNew.setCredit_available(0);
- collegeUserPointsDao.insertSelective(collegeUserPointsNew);
- tableData.put("credit", 0);
- } else {
- tableData.put("credit", collegeUserPoints.getCredit_total());
- point_available = collegeUserPoints.getCredit_total();
- }
- //查询奖学金
- tableData.put("scholarships", collegeUserPoints.getScholarships_available());
- //礼品领取情况
- List<CollegePresentCredit> collegePresentCredits = collegePresentCreditService.queryUserReceived(openid);
- for (CollegePresentCredit collegePresentCredit : collegePresentCredits) {
- if (collegePresentCredit.getReceived() != 1 && point_available >= collegePresentCredit.getValue()) {
- //返回礼品内容
- tableData.put("surprise", "true");
- tableData.put("surprise_type", collegePresentCredit.getType());
- tableData.put("surprise_name", collegePresentCredit.getPresent_name());
- //自动发放礼品
- if (collegePresentCredit.getType() == 1) {
- // 实物生成一条预约信息并发送通知
- CustomerBooking customerBooking = new CustomerBooking();
- customerBooking.setBk_branches_id(Integer.valueOf(city));
- customerBooking.setBk_phone(wxUser.getXu_phone());
- customerBooking.setBk_date(ldf.format(new Date()));
- customerBooking.setBk_type(6);
- customerBooking.setBk_desc(collegePresentCredit.getPresent_name());
- customerBookingService.insertCustomerBooking(customerBooking);
- weChatInfoController.WXSendBookingMessage(customerBooking);
- collegePointsDetail.setContext(collegePresentCredit.getPresent_name());
- } else {
- //优惠券领取接口
- String cb_code = couponCreateService.couponIssue(collegePresentCredit.getCoupon_cid(), wxUser.getXu_phone(),"College");
- collegePointsDetail.setContext(collegePresentCredit.getPresent_name() + ":" + cb_code);
- }
- //保存领取日志
- collegePointsDetail.setOpenid(openid);
- collegePointsDetail.setDate(ldf.format(new Date()));
- collegePointsDetail.setEvent_code(4);
- collegePointsDetail.setCredit(collegePresentCredit.getValue() * -1);
- collegePointsDetail.setRule_id(collegePresentCredit.getId());
- collegePointsDetailService.addCollegePointsDetail(collegePointsDetail);
- //更新学分 学分不减
- // collegeUserPoints.setCredit_available(collegeUserPoints.getCredit_available() - collegePresentRule.getValue());
- // collegeUserPointsDao.updateByPrimaryKeySelective(collegeUserPoints);
- break;
- }
- }
- tableData.put("present_received", collegePresentCredits);
- //常规课
- List<CollegeCurriculumCore> collegeCurriculumCores = collegeCurriculumCoreService.queryCoreByStep(collegeCurriculumCoreQuery);
- for (CollegeCurriculumCore collegeCurriculumCore : collegeCurriculumCores) {
- if (collegeCurriculumCore.getStatus() != null && collegeCurriculumCore.getStatus().equals("9")) { //1-已预约,2-学习中,3-已过期, 9-已完成
- collegeCurriculumCore.setStatus("已完成");
- //获取实际奖学金
- CollegeScholarshipsDetail collegeScholarshipsDetailQuery = new CollegeScholarshipsDetail();
- collegeScholarshipsDetailQuery.setOpenid(openid);
- collegeScholarshipsDetailQuery.setEvent_code(1);
- collegeScholarshipsDetailQuery.setType("learning");
- collegeScholarshipsDetailQuery.setCollege_type("core");
- collegeScholarshipsDetailQuery.setCollege_id(collegeCurriculumCore.getId());
- CollegeScholarshipsDetail collegeScholarshipsDetail = collegeScholarshipsDetailService.queryCollegeScholarships(collegeScholarshipsDetailQuery);
- if(collegeScholarshipsDetail != null) {
- collegeCurriculumCore.setScholarships(String.valueOf(collegeScholarshipsDetail.getScholarships()));
- } else {
- collegeCurriculumCore.setScholarships("0-100");
- }
- } else if (collegeCurriculumCore.getStatus() != null && collegeCurriculumCore.getStatus().equals("2")) {
- collegeCurriculumCore.setStatus("待完成");
- collegeCurriculumCore.setScholarships("0-100");
- } else {
- if (collegeCurriculumCore.getC_step() >= DateUtil.getWeekDiff(dateNow, getDate)) {
- collegeCurriculumCore.setStatus("待完成");
- collegeCurriculumCore.setScholarships("0-100");
- } else {
- collegeCurriculumCore.setStatus("未完成");
- collegeCurriculumCore.setScholarships("0");
- }
- }
- }
- tableData.put("college_core", collegeCurriculumCores);
- //实践课
- collegeCurriculumPracticeQuery.setDeadline(sdf.format(new Date()));
- collegeCurriculumPracticeQuery.setCity(city);
- collegeCurriculumPracticeQuery.setStartdate(sdf.format(new Date()));
- List<CollegeCurriculumPractice> collegeCurriculumPractices = collegeCurriculumPracticeService.queryPracticeByStep(collegeCurriculumPracticeQuery);
- //判断日期
- for (CollegeCurriculumPractice collegeCurriculumPractice : collegeCurriculumPractices) {
- Date deadLine = ldf.parse(collegeCurriculumPractice.getDeadline());
- Date now = new Date();
- if (collegeCurriculumPractice.getLearningStatus() != null && collegeCurriculumPractice.getLearningStatus().equals("9")) {
- //已完成
- collegeCurriculumPractice.setStatus("已完成");
- //已完成
- collegeCurriculumPractice.setLearningStatus("已完成");
- CollegeScholarshipsDetail collegeScholarshipsDetailQuery = new CollegeScholarshipsDetail();
- collegeScholarshipsDetailQuery.setOpenid(openid);
- collegeScholarshipsDetailQuery.setEvent_code(1);
- collegeScholarshipsDetailQuery.setType("learning");
- collegeScholarshipsDetailQuery.setCollege_type("practice");
- collegeScholarshipsDetailQuery.setCollege_id(collegeCurriculumPractice.getId());
- CollegeScholarshipsDetail collegeScholarshipsDetail = collegeScholarshipsDetailService.queryCollegeScholarships(collegeScholarshipsDetailQuery);
- if(collegeScholarshipsDetail != null) {
- collegeCurriculumPractice.setScholarships(String.valueOf(collegeScholarshipsDetail.getScholarships()));
- } else {
- collegeCurriculumPractice.setScholarships("0-100");
- }
- } else if (collegeCurriculumPractice.getLearningStatus() != null && collegeCurriculumPractice.getLearningStatus().equals("1")) {
- if (now.getTime() > deadLine.getTime()) {
- //未完成
- collegeCurriculumPractice.setStatus("未完成");
- //已过期
- collegeCurriculumPractice.setLearningStatus("已过期");
- collegeCurriculumPractice.setScholarships("0");
- } else {
- //待完成
- collegeCurriculumPractice.setStatus("已报名");
- //查看报名
- collegeCurriculumPractice.setLearningStatus("查看报名");
- collegeCurriculumPractice.setScholarships("0-100");
- }
- } else {
- if (now.getTime() > deadLine.getTime()) {
- //未完成
- collegeCurriculumPractice.setStatus("未完成");
- //已过期
- collegeCurriculumPractice.setLearningStatus("已过期");
- collegeCurriculumPractice.setScholarships("0");
- } else if (collegeCurriculumPractice.getPcount() >= 99) {
- //未完成
- collegeCurriculumPractice.setStatus("未完成");
- //已约满
- collegeCurriculumPractice.setLearningStatus("已约满");
- collegeCurriculumPractice.setScholarships("0-100");
- } else {
- //待完成
- collegeCurriculumPractice.setStatus("待完成");
- //立即报名
- collegeCurriculumPractice.setLearningStatus("立即报名");
- collegeCurriculumPractice.setScholarships("0-100");
- }
- }
- }
- tableData.put("college_practice", collegeCurriculumPractices);
- //体验课
- collegeCurriculumExperienceQuery.setCity(city);
- List<CollegeCurriculumExperience> collegeCurriculumExperiences = collegeCurriculumExperienceService.queryExperienceByStep(collegeCurriculumExperienceQuery);
- for (CollegeCurriculumExperience collegeCurriculumExperience : collegeCurriculumExperiences) {
- if (collegeCurriculumExperience.getStatus() != null && collegeCurriculumExperience.getStatus().equals("9")) { //1-已预约,2-学习中,3-已过期, 9-已完成
- collegeCurriculumExperience.setStatus("已完成");
- collegeCurriculumExperience.setLearningStatus("已完成");
- CollegeScholarshipsDetail collegeScholarshipsDetailQuery = new CollegeScholarshipsDetail();
- collegeScholarshipsDetailQuery.setOpenid(openid);
- collegeScholarshipsDetailQuery.setEvent_code(1);
- collegeScholarshipsDetailQuery.setType("learning");
- collegeScholarshipsDetailQuery.setCollege_type("experience");
- collegeScholarshipsDetailQuery.setCollege_id(collegeCurriculumExperience.getId());
- CollegeScholarshipsDetail collegeScholarshipsDetail = collegeScholarshipsDetailService.queryCollegeScholarships(collegeScholarshipsDetailQuery);
- if(collegeScholarshipsDetail != null) {
- collegeCurriculumExperience.setScholarships(String.valueOf(collegeScholarshipsDetail.getScholarships()));
- } else {
- collegeCurriculumExperience.setScholarships("0-100");
- }
- } else if (collegeCurriculumExperience.getStatus() != null && collegeCurriculumExperience.getStatus().equals("1")) {
- collegeCurriculumExperience.setStatus("已预约");
- collegeCurriculumExperience.setLearningStatus("查看预约");
- collegeCurriculumExperience.setScholarships("0-100");
- } else {
- collegeCurriculumExperience.setStatus("未完成");
- collegeCurriculumExperience.setLearningStatus("立即预约");
- collegeCurriculumExperience.setScholarships("0-100");
- }
- }
- tableData.put("college_experience", collegeCurriculumExperiences);
- return tableData;
- } catch (Exception ex) {
- ex.printStackTrace();
- return tableData;
- }
- } else {
- tableData.put("status", "5"); //没有设置日期
- return tableData;
- }
- } else {
- tableData.put("status", "6"); //没有授权手机号
- return tableData;
- }
- }
- public int getPointsByOffline(String openid, String c_code, String lat, String lon) {
- //51-参数错误 52-没有预约 53-不在范围 54-已完成
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String college_type = "";
- Integer id = null;
- if (c_code.indexOf("College") == -1) {
- return 51; //参数错误
- }
- CollegeBooking collegeBooking = new CollegeBooking();
- collegeBooking.setOpenid(openid);
- collegeBooking.setCollege_code(c_code.substring(8, c_code.length()));
- String lat_l, lon_l;
- int credit = 0;
- if (collegeBookingService.checkBooking(collegeBooking) != null) {
- if (c_code.substring(7, 1) == "P") {
- college_type = "practice";
- CollegeCurriculumPractice collegeCurriculumPractice = collegeCurriculumPracticeService.getPracticeByCode(c_code);
- lat_l = collegeCurriculumPractice.getMi_latitude();
- lon_l = collegeCurriculumPractice.getMi_longitude();
- credit = collegeCurriculumPractice.getCredit();
- id = collegeCurriculumPractice.getId();
- } else if (c_code.substring(7, 1) == "E") {
- college_type = "experience";
- CollegeCurriculumExperience collegeCurriculumExperience = collegeCurriculumExperienceService.getExperienceByCode(c_code.substring(8, c_code.length()));
- lat_l = collegeCurriculumExperience.getLatitude();
- lon_l = collegeCurriculumExperience.getLongitude();
- credit = collegeCurriculumExperience.getCredit();
- id = collegeCurriculumExperience.getId();
- } else {
- return 51; //参数错误
- }
- DistanceUtil distanceUtil = new DistanceUtil();
- double distance = distanceUtil.GetDistance(Double.parseDouble(lat_l), Double.parseDouble(lon_l), Double.parseDouble(lat), Double.parseDouble(lon));
- if (distance > 500) {
- return 53; //不在范围内
- } else {
- //判断是否已完成
- CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
- collegeLearningDetail.setOpen_id(openid);
- collegeLearningDetail.setC_code(c_code.substring(8, c_code.length()));
- CollegeLearningDetail collegeLearningDetailC = collegeLearningDetailService.checkCorePositive(collegeLearningDetail);
- if (collegeLearningDetailC.getStatus() != 9) {
- collegeLearningDetailC.setDate(sdf.format(new Date()));
- collegeLearningDetailC.setStatus(9);
- collegeLearningDetailC.setCredit(credit);
- collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetailC);
- } else {
- return 54; //已完成
- }
- //判断是否已经学习 增加学分
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
- if (collegeUserPoints == null) {
- CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
- collegeUserPointsNew.setOpenid(openid);
- collegeUserPointsNew.setCredit_total(credit);
- collegeUserPointsNew.setCredit_available(credit);
- } else {
- CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
- collegeUserPointsNew.setOpenid(openid);
- collegeUserPointsNew.setCredit_total(collegeUserPoints.getCredit_total() + credit);
- collegeUserPointsNew.setCredit_available(collegeUserPoints.getCredit_available() + credit);
- }
- //增加奖学金
- collegeScholarshipsDetailService.addScholarships(openid, "learning",college_type, id, null, null);
- return 1;
- }
- } else {
- return 52; //没有预约
- }
- }
- public LinkedHashMap<String, Object> queryRedeemIndex(String openid) {
- LinkedHashMap<String, Object> userInfo = new LinkedHashMap<>();
- LinkedHashMap<String, Object> returnInfo = new LinkedHashMap<>();
- List<Object> presentInfoTemp = new LinkedList<>();
- WXUser wxUser = wxUserService.getWXUser(openid);
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
- CollegeUserLevel collegeUserLevel;
- if(collegeUserPoints == null) {
- //新增用户
- CollegeUserPoints collegeUserPointsNew = new CollegeUserPoints();
- collegeUserPointsNew.setOpenid(openid);
- collegeUserPointsNew.setCredit_available(0);
- collegeUserPointsNew.setCredit_total(0);
- collegeUserPointsNew.setScholarships_available(0);
- collegeUserPointsNew.setScholarships_total(0);
- collegeUserPointsDao.insertSelective(collegeUserPointsNew);
- collegeUserLevel = collegeUserLevelService.getUserLevel(0);
- collegeUserPoints = collegeUserPointsNew;
- } else {
- collegeUserLevel = collegeUserLevelService.getUserLevel(collegeUserPoints.getCredit_available());
- }
- int level = 0;
- if (collegeUserLevel != null) {
- level = collegeUserLevel.getLevel();
- }
- userInfo.put("name", wxUser.getXu_name());
- userInfo.put("avatarUrl", wxUser.getXu_avatarUrl());
- userInfo.put("Scholarships", collegeUserPoints.getScholarships_available());
- userInfo.put("level", level);
- List<CollegePresentScholarships> collegePresentScholarships = collegePresentScholarshipsService.getCollegePresentScholarships();
- for (CollegePresentScholarships collegePresentScholarship : collegePresentScholarships) {
- LinkedHashMap<String, Object> presents = new LinkedHashMap<>();
- //通过等级判断是否适合商品
- presents.put("id",collegePresentScholarship.getId());
- presents.put("name", collegePresentScholarship.getName());
- presents.put("level", collegePresentScholarship.getLevel());
- presents.put("scholarships", collegePresentScholarship.getScholarships());
- presents.put("list_img_href", collegePresentScholarship.getList_img_href());
- presents.put("count", collegePresentScholarship.getCount());
- if (collegePresentScholarship.getLevel() > level) {
- presents.put("redeem", false);
- } else {
- presents.put("redeem", true);
- }
- presentInfoTemp.add(presents);
- }
- returnInfo.put("userInfo", userInfo);
- returnInfo.put("presentInfo", presentInfoTemp);
- return returnInfo;
- }
- public LinkedHashMap<String, Object> queryRedeem(Integer presentId) {
- LinkedHashMap<String, Object> returnInfo = new LinkedHashMap<>();
- CollegePresentScholarships collegePresentScholarships = collegePresentScholarshipsService.getCollegePresentScholarship(presentId);
- returnInfo.put("detail_img_href",collegePresentScholarships.getDetail_img_href());
- return returnInfo;
- }
- public LinkedHashMap<String, Object> queryRedeemDetail(Integer presentId,String openid) {
- LinkedHashMap<String, Object> returnInfo = new LinkedHashMap<>();
- CollegePresentScholarships collegePresentScholarships = collegePresentScholarshipsService.getCollegePresentScholarship(presentId);
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(openid);
- CollegeUserLevel collegeUserLevelTemp = collegeUserLevelService.getUserLevel(collegeUserPoints.getCredit_available());
- int level = 0;
- if (collegeUserLevelTemp != null) {
- level = collegeUserLevelTemp.getLevel();
- }
- if(collegeUserPoints == null || collegePresentScholarships == null) {
- returnInfo.put("error", "未找到信息");
- } else {
- CollegeUserLevel collegeUserLevel = collegeUserLevelService.getUserLevelDesc(collegePresentScholarships.getLevel());
- returnInfo.put("level",collegePresentScholarships.getLevel());
- returnInfo.put("levelDesc",collegeUserLevel.getDesc());
- returnInfo.put("presentDesc",collegePresentScholarships.getDesc());
- returnInfo.put("presentType",collegePresentScholarships.getType());
- returnInfo.put("presentName",collegePresentScholarships.getName());
- returnInfo.put("presentRedeemImg",collegePresentScholarships.getRedeem_img_href());
- returnInfo.put("presentScholarships",collegePresentScholarships.getScholarships());
- returnInfo.put("userScholarships",collegeUserPoints.getScholarships_available());
- if (collegePresentScholarships.getLevel() > level) {
- returnInfo.put("redeem", false);
- } else {
- returnInfo.put("redeem", true);
- }
- if(collegePresentScholarships.getType() == 2) {
- List<WXMktInfo> wxMktInfo = wxMktInfoService.getMktInfos(null);
- returnInfo.put("mktInfo",wxMktInfo);
- }
- }
- return returnInfo;
- }
- public LinkedHashMap<String, Object> userRedeem(CollegePresentScholarshipsLogs collegePresentScholarshipsLogs) {
- LinkedHashMap<String, Object> returnInfo = new LinkedHashMap<>();
- CollegePresentScholarships collegePresentScholarships = collegePresentScholarshipsService.getCollegePresentScholarship(collegePresentScholarshipsLogs.getPresent_id());
- CollegeUserPoints collegeUserPoints = collegeUserPointsDao.queryOneUserPoints(collegePresentScholarshipsLogs.getOpenid());
- CollegeUserLevel collegeUserLevel = collegeUserLevelService.getUserLevel(collegeUserPoints.getCredit_available());
- int level = 0;
- if (collegeUserLevel != null) {
- level = collegeUserLevel.getLevel();
- }
- //判断等级
- if(level < collegePresentScholarships.getLevel()) {
- returnInfo.put("code","90");
- returnInfo.put("msg","等级未达到");
- return returnInfo;
- }
- //判断奖学金
- if(collegeUserPoints.getScholarships_available() < collegePresentScholarships.getScholarships()) {
- returnInfo.put("code","91");
- returnInfo.put("msg","奖学金不足");
- return returnInfo;
- }
- //subtractScholarships
- if(collegeScholarshipsDetailService.subtractScholarships(collegePresentScholarshipsLogs) == 1){
- returnInfo.put("code","1");
- returnInfo.put("msg","兑换成功");
- return returnInfo;
- } else {
- returnInfo.put("code","99");
- returnInfo.put("msg","系统异常");
- return returnInfo;
- }
- }
- }
|