| | |
| | | package com.dsh.course.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | | import com.dsh.course.feignclient.account.StudentClient; |
| | | import com.dsh.course.feignclient.account.model.AppUser; |
| | | import com.dsh.course.feignclient.account.model.Student; |
| | | import com.dsh.course.feignclient.account.model.TCourseInfoRecord; |
| | | import com.dsh.course.feignclient.activity.CouponClient; |
| | | import com.dsh.course.feignclient.activity.UserCouponClient; |
| | | import com.dsh.course.feignclient.activity.model.Coupon; |
| | | import com.dsh.course.feignclient.activity.model.SendCouponReq; |
| | | import com.dsh.course.feignclient.activity.model.UserCoupon; |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.mapper.CoursePackageStudentMapper; |
| | | import com.dsh.course.mapper.TCoursePackageMapper; |
| | | import com.dsh.course.feignclient.model.CourseOfStoreVo; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TCoursePackageServiceImpl extends ServiceImpl<TCoursePackageMapper, TCoursePackage> implements TCoursePackageService { |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService coursePackagePaymentConfigService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService coursePackageDiscountService; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | @Resource |
| | | private UserCouponClient userCouponClient; |
| | | |
| | | @Resource |
| | | private CouponClient couponClient; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | @Resource |
| | | private CoursePackageStudentMapper cpsMapper; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<CourseOfStoreVo> queryStoreOfCourse() { |
| | | return this.baseMapper.queryStoreOfCourse(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课程列表 |
| | | * @param coursePackageList |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CoursePackageListVo> queryCourseList(Integer uid, CoursePackageList coursePackageList) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(coursePackageList.getLon(), coursePackageList.getLat()); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2)) |
| | | .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode); |
| | | if(null != coursePackageList.getCoursePackageTypeId()){ |
| | | wrapper.eq("coursePackageTypeId", coursePackageList.getCoursePackageTypeId()); |
| | | } |
| | | if(null != coursePackageList.getStoreId()){ |
| | | wrapper.eq("storeId", coursePackageList.getStoreId()); |
| | | } |
| | | if(null != coursePackageList.getStoreId()){ |
| | | wrapper.eq("storeId", coursePackageList.getStoreId()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSearch())){ |
| | | wrapper.like("name", coursePackageList.getSearch()); |
| | | List<Store> stores = storeClient.queryStoreListByName(coursePackageList.getSearch()); |
| | | List<Integer> collect = stores.stream().map(Store::getId).collect(Collectors.toList()); |
| | | if(collect.size() > 0){ |
| | | wrapper.or().in("id", collect); |
| | | } |
| | | } |
| | | List<TCoursePackage> list = this.list(wrapper.last(" order by sort, insertTime desc")); |
| | | List<CoursePackageListVo> listVos = new ArrayList<>(); |
| | | for (TCoursePackage coursePackage : list) { |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(coursePackage.getId()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours").last(" limit 0, 1")); |
| | | CoursePackageListVo coursePackageListVo = new CoursePackageListVo(); |
| | | coursePackageListVo.setId(coursePackage.getId()); |
| | | coursePackageListVo.setName(coursePackage.getName()); |
| | | coursePackageListVo.setStoreName(null != store ? store.getName() : ""); |
| | | coursePackageListVo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | |
| | | // 2.0修改 |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split3 = classEndTime.split(","); |
| | | for (int i = 0; i < split.length; i++) { |
| | | String s = split[i] + "-" + split3[i]; |
| | | classTime.add(s); |
| | | } |
| | | coursePackageListVo.setClassStartTime(classTime); |
| | | coursePackageListVo.setType(coursePackage.getType()); |
| | | |
| | | |
| | | |
| | | coursePackageListVo.setApplicantsNumber(integer); |
| | | coursePackageListVo.setPayType(coursePackage.getPayType()); |
| | | coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | |
| | | //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackageListVo.setVipPrice(vipPrice); |
| | | |
| | | Double paymentPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list3) { |
| | | /** |
| | | * [{ |
| | | * "startDate": "2023-01-01 00:00:00", |
| | | * "endDate": "2023-12-31 23:59:59", |
| | | * "startTime": "02:00:00", |
| | | * "endTime": "23:00:00", |
| | | * "weeks": [1, 2, 7], |
| | | * "cashPayment": 100 |
| | | * }] |
| | | */ |
| | | JSONArray jsonArray = JSON.parseArray(coursePackageDiscount.getContent()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | try { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String startDate = jsonObject.getString("startDate"); |
| | | String endDate = jsonObject.getString("endDate"); |
| | | String startTime = jsonObject.getString("startTime"); |
| | | String endTime = jsonObject.getString("endTime"); |
| | | List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); |
| | | Double cashPayment = jsonObject.getDouble("cashPayment"); |
| | | Date startDate_date = sdf.parse(startDate); |
| | | Date endDate_date = sdf.parse(endDate); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | if(timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()){ |
| | | Date date = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int week = calendar.get(Calendar.DAY_OF_WEEK); |
| | | boolean isFirstSunday = (calendar.getFirstDayOfWeek() == Calendar.SUNDAY); |
| | | if(isFirstSunday){ |
| | | week = week - 1; |
| | | if(week == 0){ |
| | | week = 7; |
| | | } |
| | | } |
| | | if(!weeks.contains(week)){ |
| | | continue; |
| | | } |
| | | |
| | | String[] split1 = startTime.split(":"); |
| | | Integer hour1 = Integer.valueOf(split1[0]); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, hour1); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | s.set(Calendar.SECOND, Integer.valueOf(split1[2])); |
| | | |
| | | String[] split2 = endTime.split(":"); |
| | | Integer hour2 = Integer.valueOf(split2[0]); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, hour2); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split2[1])); |
| | | e.set(Calendar.SECOND, Integer.valueOf(split2[2])); |
| | | |
| | | if(hour1 > hour2){ |
| | | if(s.getTimeInMillis() > date.getTime()){ |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) - 1); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, e.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | if(timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment) > 0){ |
| | | paymentPrice = cashPayment; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | coursePackageListVo.setPaymentPrice(paymentPrice); |
| | | }else{ |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackageListVo.setPaymentPrice(vipPrice); |
| | | coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | } |
| | | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(coursePackageList.getLon() + "," + coursePackageList.getLat(), store.getLon() + "," + store.getLat()); |
| | | coursePackageListVo.setDistance(distance.get("WGS84") / 1000); |
| | | listVos.add(coursePackageListVo); |
| | | } |
| | | |
| | | //销量排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Integer.compare(s1.getApplicantsNumber(), s2.getApplicantsNumber()); |
| | | } |
| | | }); |
| | | } |
| | | //距离排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Double.compare(s1.getDistance(), s2.getDistance()); |
| | | } |
| | | }); |
| | | } |
| | | return listVos; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<CoursePackageListVo> queryCourseListOne(CoursePackageList coursePackageList) throws Exception { |
| | | // AppUser appUser = appUserClient.queryAppUser(uid); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(coursePackageList.getLon(), coursePackageList.getLat()); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2)) |
| | | .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode); |
| | | if(null != coursePackageList.getCoursePackageTypeId()){ |
| | | wrapper.eq("coursePackageTypeId", coursePackageList.getCoursePackageTypeId()); |
| | | } |
| | | if(null != coursePackageList.getStoreId()){ |
| | | wrapper.eq("storeId", coursePackageList.getStoreId()); |
| | | } |
| | | if(null != coursePackageList.getStoreId()){ |
| | | wrapper.eq("storeId", coursePackageList.getStoreId()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSearch())){ |
| | | wrapper.like("name", coursePackageList.getSearch()); |
| | | List<Store> stores = storeClient.queryStoreListByName(coursePackageList.getSearch()); |
| | | List<Integer> collect = stores.stream().map(Store::getId).collect(Collectors.toList()); |
| | | if(collect.size() > 0){ |
| | | wrapper.or().in("storeId", collect); |
| | | } |
| | | } |
| | | List<TCoursePackage> list = this.list(wrapper.last(" order by sort, insertTime desc")); |
| | | List<CoursePackageListVo> listVos = new ArrayList<>(); |
| | | for (TCoursePackage coursePackage : list) { |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(coursePackage.getId()); |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", coursePackage.getId()).orderByAsc("classHours").last(" limit 0, 1")); |
| | | CoursePackageListVo coursePackageListVo = new CoursePackageListVo(); |
| | | coursePackageListVo.setId(coursePackage.getId()); |
| | | coursePackageListVo.setName(coursePackage.getName()); |
| | | coursePackageListVo.setStoreName(null != store ? store.getName() : ""); |
| | | coursePackageListVo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | |
| | | // 2.0修改 |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split3 = classEndTime.split(","); |
| | | for (int i = 0; i < split.length; i++) { |
| | | String s = split[i] + "-" + split3[i]; |
| | | classTime.add(s); |
| | | } |
| | | coursePackageListVo.setClassStartTime(classTime); |
| | | coursePackageListVo.setType(coursePackage.getType()); |
| | | |
| | | |
| | | |
| | | coursePackageListVo.setApplicantsNumber(integer); |
| | | coursePackageListVo.setPayType(coursePackage.getPayType()); |
| | | coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | |
| | | //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低) |
| | | if(false){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackageListVo.setVipPrice(vipPrice); |
| | | |
| | | Double paymentPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list3) { |
| | | /** |
| | | * [{ |
| | | * "startDate": "2023-01-01 00:00:00", |
| | | * "endDate": "2023-12-31 23:59:59", |
| | | * "startTime": "02:00:00", |
| | | * "endTime": "23:00:00", |
| | | * "weeks": [1, 2, 7], |
| | | * "cashPayment": 100 |
| | | * }] |
| | | */ |
| | | JSONArray jsonArray = JSON.parseArray(coursePackageDiscount.getContent()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | try { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String startDate = jsonObject.getString("startDate"); |
| | | String endDate = jsonObject.getString("endDate"); |
| | | String startTime = jsonObject.getString("startTime"); |
| | | String endTime = jsonObject.getString("endTime"); |
| | | List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); |
| | | Double cashPayment = jsonObject.getDouble("cashPayment"); |
| | | Date startDate_date = sdf.parse(startDate); |
| | | Date endDate_date = sdf.parse(endDate); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | if(timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()){ |
| | | Date date = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int week = calendar.get(Calendar.DAY_OF_WEEK); |
| | | boolean isFirstSunday = (calendar.getFirstDayOfWeek() == Calendar.SUNDAY); |
| | | if(isFirstSunday){ |
| | | week = week - 1; |
| | | if(week == 0){ |
| | | week = 7; |
| | | } |
| | | } |
| | | if(!weeks.contains(week)){ |
| | | continue; |
| | | } |
| | | |
| | | String[] split1 = startTime.split(":"); |
| | | Integer hour1 = Integer.valueOf(split1[0]); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, hour1); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | s.set(Calendar.SECOND, Integer.valueOf(split1[2])); |
| | | |
| | | String[] split2 = endTime.split(":"); |
| | | Integer hour2 = Integer.valueOf(split2[0]); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, hour2); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split2[1])); |
| | | e.set(Calendar.SECOND, Integer.valueOf(split2[2])); |
| | | |
| | | if(hour1 > hour2){ |
| | | if(s.getTimeInMillis() > date.getTime()){ |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) - 1); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, e.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | if(timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment) > 0){ |
| | | paymentPrice = cashPayment; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | coursePackageListVo.setPaymentPrice(paymentPrice); |
| | | }else{ |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackageListVo.setPaymentPrice(vipPrice); |
| | | coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | } |
| | | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(coursePackageList.getLon() + "," + coursePackageList.getLat(), store.getLon() + "," + store.getLat()); |
| | | coursePackageListVo.setDistance(distance.get("WGS84") / 1000); |
| | | listVos.add(coursePackageListVo); |
| | | } |
| | | |
| | | //销量排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Integer.compare(s1.getApplicantsNumber(), s2.getApplicantsNumber()); |
| | | } |
| | | }); |
| | | } |
| | | //距离排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Double.compare(s1.getDistance(), s2.getDistance()); |
| | | } |
| | | }); |
| | | } |
| | | return listVos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包详情 |
| | | * @param uid |
| | | * @param id |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public CoursePackageInfo queryCourseInfo(Integer uid, Integer id, String lon, String lat) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | TCoursePackage coursePackage = this.getById(id); |
| | | CoursePackageInfo coursePackageInfo = new CoursePackageInfo(); |
| | | coursePackageInfo.setId(id); |
| | | coursePackageInfo.setTime(coursePackage.getStartTime()+"-"+coursePackage.getEndTime()); |
| | | coursePackageInfo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | coursePackageInfo.setName(coursePackage.getName()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | coursePackageInfo.setStoreName(store.getName()); |
| | | coursePackageInfo.setStoreCoverDrawing(store.getCoverDrawing()); |
| | | coursePackageInfo.setStoreAddress(store.getAddress()); |
| | | coursePackageInfo.setLon(store.getLon()); |
| | | coursePackageInfo.setLat(store.getLat()); |
| | | if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){ |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | coursePackageInfo.setDistance(wgs84); |
| | | } |
| | | |
| | | String[] split = coursePackage.getClassWeeks().split(";"); |
| | | coursePackageInfo.setWeeks(Arrays.asList(split)); |
| | | |
| | | // 2.0 |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | ArrayList<String> classTime = new ArrayList<>(); |
| | | String[] split4 = classStartTime.split(","); |
| | | String[] split3 = classEndTime.split(","); |
| | | for (int i = 0; i < split4.length; i++) { |
| | | String s = split4[i] + "-" + split3[i]; |
| | | classTime.add(s); |
| | | } |
| | | coursePackageInfo.setTimes(classTime); |
| | | coursePackageInfo.setType(coursePackage.getType()); |
| | | |
| | | coursePackageInfo.setDetailDrawing(coursePackage.getDetailDrawing()); |
| | | coursePackageInfo.setIntroduceDrawing(coursePackage.getIntroduceDrawing()); |
| | | List<CoursePackagePaymentConfigVo> list = new ArrayList<>(); |
| | | List<CoursePackagePaymentConfig> list1 = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id).orderByAsc("classHours")); |
| | | list1.forEach(coursePackagePaymentConfig -> { |
| | | CoursePackagePaymentConfigVo coursePackagePaymentConfigVo = new CoursePackagePaymentConfigVo(); |
| | | coursePackagePaymentConfigVo.setId(coursePackagePaymentConfig.getId()); |
| | | coursePackagePaymentConfigVo.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType()); |
| | | coursePackagePaymentConfigVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setVipPrice(vipPrice); |
| | | |
| | | Double paymentPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list3) { |
| | | /** |
| | | * [{ |
| | | * "startDate": "2023-01-01 00:00:00", |
| | | * "endDate": "2023-12-31 23:59:59", |
| | | * "startTime": "02:00:00", |
| | | * "endTime": "23:00:00", |
| | | * "weeks": [1, 2, 7], |
| | | * "cashPayment": 100 |
| | | * }] |
| | | */ |
| | | JSONArray jsonArray = JSON.parseArray(coursePackageDiscount.getContent()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | try { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String startDate = jsonObject.getString("startDate"); |
| | | String endDate = jsonObject.getString("endDate"); |
| | | String startTime = jsonObject.getString("startTime"); |
| | | String endTime = jsonObject.getString("endTime"); |
| | | List<Integer> weeks = jsonObject.getJSONArray("weeks").toJavaList(Integer.class); |
| | | Double cashPayment = jsonObject.getDouble("cashPayment"); |
| | | Date startDate_date = sdf.parse(startDate); |
| | | Date endDate_date = sdf.parse(endDate); |
| | | long timeMillis = System.currentTimeMillis(); |
| | | if(timeMillis >= startDate_date.getTime() && timeMillis < endDate_date.getTime()){ |
| | | Date date = new Date(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int week = calendar.get(Calendar.DAY_OF_WEEK); |
| | | boolean isFirstSunday = (calendar.getFirstDayOfWeek() == Calendar.SUNDAY); |
| | | if(isFirstSunday){ |
| | | week = week - 1; |
| | | if(week == 0){ |
| | | week = 7; |
| | | } |
| | | } |
| | | if(!weeks.contains(week)){ |
| | | continue; |
| | | } |
| | | |
| | | String[] split1 = startTime.split(":"); |
| | | Integer hour1 = Integer.valueOf(split1[0]); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, hour1); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | s.set(Calendar.SECOND, Integer.valueOf(split1[2])); |
| | | |
| | | String[] split2 = endTime.split(":"); |
| | | Integer hour2 = Integer.valueOf(split2[0]); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, hour2); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(split2[1])); |
| | | e.set(Calendar.SECOND, Integer.valueOf(split2[2])); |
| | | |
| | | if(hour1 > hour2){ |
| | | if(s.getTimeInMillis() > date.getTime()){ |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) - 1); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, e.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | if(timeMillis >= s.getTimeInMillis() && timeMillis < e.getTimeInMillis() && paymentPrice.compareTo(cashPayment) > 0){ |
| | | paymentPrice = cashPayment; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(paymentPrice); |
| | | }else{ |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | | if(vipPrice.compareTo(num1) > 0){ |
| | | vipPrice = num1; |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(vipPrice); |
| | | coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | } |
| | | list.add(coursePackagePaymentConfigVo); |
| | | }); |
| | | coursePackageInfo.setList(list); |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | StudentVo studentVo = new StudentVo(); |
| | | if(null != student){ |
| | | studentVo.setId(student.getId()); |
| | | studentVo.setPhone(student.getPhone()); |
| | | studentVo.setName(student.getName()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); |
| | | studentVo.setAge(Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(student.getBirthday()))); |
| | | } |
| | | coursePackageInfo.setStudent(studentVo); |
| | | return coursePackageInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程包名支付 |
| | | * @param uid |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil paymentCourse(Integer uid, PaymentCourseVo paymentCourseVo) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | CoursePackageInfo coursePackageInfo = queryCourseInfo(uid, paymentCourseVo.getId(), null, null); |
| | | List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList(); |
| | | |
| | | String[] students = paymentCourseVo.getStudentIds().split(";"); |
| | | for (CoursePackagePaymentConfigVo coursePackagePaymentConfigVo : list) { |
| | | if(paymentCourseVo.getCoursePackagePaymentConfigId().compareTo(coursePackagePaymentConfigVo.getId()) == 0){ |
| | | Integer payType = coursePackagePaymentConfigVo.getPayType(); |
| | | if(payType == 1 && paymentCourseVo.getPayType() == 3){//现金支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | } |
| | | if(payType == 2 && paymentCourseVo.getPayType() != 3){//玩湃币支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | } |
| | | Double paymentPrice = coursePackagePaymentConfigVo.getPaymentPrice();//支付价 |
| | | paymentPrice = new BigDecimal(students.length).multiply(new BigDecimal(paymentPrice)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | Double playPaiCoin = coursePackagePaymentConfigVo.getPlayPaiCoin().doubleValue();//支付币 |
| | | playPaiCoin = new BigDecimal(students.length).multiply(new BigDecimal(playPaiCoin)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | if(payType == 1 && paymentPrice.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | if(payType == 2 && playPaiCoin.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Double price = paymentCourseVo.getPrice();//支付金额 |
| | | |
| | | //校验优惠券 |
| | | Long couponId = paymentCourseVo.getCouponId(); |
| | | if(null != couponId && paymentCourseVo.getPayType() != 3){ |
| | | UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); |
| | | if(userCoupon.getStatus() == 2){ |
| | | return ResultUtil.error("优惠券已被核销"); |
| | | } |
| | | Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); |
| | | long time = coupon.getEndTime().getTime(); |
| | | if(System.currentTimeMillis() >= time){ |
| | | return ResultUtil.error("优惠券已过期"); |
| | | } |
| | | if(coupon.getType() == 1){//满减 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | |
| | | price = new BigDecimal(price).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | if(coupon.getType() == 2){//代金券 |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | return ResultUtil.error("该优惠券无法使用"); |
| | | } |
| | | price = new BigDecimal(price).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | } |
| | | |
| | | if(paymentCourseVo.getPayType() == 1){//微信支付 |
| | | return weChatPaymentCourse(uid, price, paymentCourseVo); |
| | | } |
| | | if(paymentCourseVo.getPayType() == 2){//支付宝支付 |
| | | return aliPaymentCourse(uid, price, paymentCourseVo); |
| | | } |
| | | if(paymentCourseVo.getPayType() == 3){//玩湃币支付 |
| | | if(appUser.getPlayPaiCoins() < price.intValue()){ |
| | | return ResultUtil.error("报名失败,玩湃币不足,请充值!"); |
| | | } |
| | | return playPaiCoinPaymentCourse(appUser, price, paymentCourseVo); |
| | | } |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程微信支付 |
| | | * @param uid |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil weChatPaymentCourse(Integer uid, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(uid); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId()); |
| | | coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice)); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(1); |
| | | coursePackagePayment.setPayUserId(uid); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | } |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | Integer sid=null; |
| | | if(student!=null){ |
| | | sid=student.getId(); |
| | | } |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("购买课程", "", code, paymentPrice.toString(), "/base/course/weChatPaymentCourseCallback", "APP", ""); |
| | | if(weixinpay.getCode() == 200){ |
| | | Integer finalSid = sid; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 1)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, ""); |
| | | if(resultUtil.getCode() == 200 && one.getPayStatus() == 1){ |
| | | /** |
| | | * SUCCESS—支付成功, |
| | | * REFUND—转入退款, |
| | | * NOTPAY—未支付, |
| | | * CLOSED—已关闭, |
| | | * REVOKED—已撤销(刷卡支付), |
| | | * USERPAYING--用户支付中, |
| | | * PAYERROR--支付失败(其他原因,如银行返回失败) |
| | | */ |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("trade_state"); |
| | | String transaction_id = data1.get("transaction_id"); |
| | | if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(3); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("SUCCESS".equals(s)){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(transaction_id); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | // 2.0 |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds())); |
| | | |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId()); |
| | | break; |
| | | } |
| | | if("USERPAYING".equals(s)){ |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return weixinpay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程支付宝支付 |
| | | * @param uid |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil aliPaymentCourse(Integer uid, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(uid); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId()); |
| | | coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice)); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(1); |
| | | coursePackagePayment.setPayUserId(uid); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | } |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | Integer sid=null; |
| | | if(student!=null){ |
| | | sid=student.getId(); |
| | | } |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay("购买课程", "购买课程", "", code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | Integer finalSid = sid; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | int num = 1; |
| | | int wait = 0; |
| | | while (num <= 10){ |
| | | int min = 5000; |
| | | wait += (min * num); |
| | | Thread.sleep(wait); |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 2)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && one.getPayStatus() == 1){ |
| | | /** |
| | | * WAIT_BUYER_PAY(交易创建,等待买家付款)、 |
| | | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | Map<String, String> data1 = resultUtil.getData(); |
| | | String s = data1.get("tradeStatus"); |
| | | String tradeNo = data1.get("tradeNo"); |
| | | if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(3); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | break; |
| | | } |
| | | if("TRADE_SUCCESS".equals(s)){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | |
| | | // 2.0 |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds())); |
| | | |
| | | |
| | | |
| | | if(student!=null){ |
| | | |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId()); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | | num++; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | return alipay; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 玩湃币支付课程 |
| | | * @param appUser |
| | | * @param paymentPrice |
| | | * @param paymentCourseVo |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil playPaiCoinPaymentCourse(AppUser appUser, Double paymentPrice, PaymentCourseVo paymentCourseVo) throws Exception{ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | String[] split = paymentCourseVo.getStudentIds().split(";"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment(); |
| | | coursePackagePayment.setCode(code); |
| | | coursePackagePayment.setAppUserId(appUser.getId()); |
| | | coursePackagePayment.setStudentId(Integer.valueOf(s)); |
| | | coursePackagePayment.setCoursePackageId(paymentCourseVo.getId()); |
| | | coursePackagePayment.setPayType(paymentCourseVo.getPayType()); |
| | | coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue()); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePayment.setAbsencesNumber(0); |
| | | coursePackagePayment.setPayUserType(1); |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setPayUserId(appUser.getId()); |
| | | coursePackagePayment.setStatus(1); |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | Integer sId=null; |
| | | Student student = studentClient.queryDefaultStudent(appUser.getId()); |
| | | if(student!=null){ |
| | | sId=student.getId(); |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(),appUser.getId(),sId,coursePackagePayment.getId()); |
| | | } |
| | | |
| | | Integer playPaiCoins = appUser.getPlayPaiCoins(); |
| | | appUser.setPlayPaiCoins(playPaiCoins - paymentPrice.intValue()); |
| | | appUserClient.updateAppUser(appUser); |
| | | |
| | | // 2.0 |
| | | String couponIds = coursePackagePaymentConfig.getCouponIds(); |
| | | if(ToolUtil.isNotEmpty(couponIds)){ |
| | | // 赠送优惠券 |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(appUser.getId(),couponIds)); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId){ |
| | | // 课包 |
| | | TCoursePackage tCoursePackage = this.baseMapper.selectById(courseId); |
| | | |
| | | |
| | | |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | String[] split = tCoursePackage.getClassStartTime().split(","); |
| | | String[] split1 = tCoursePackage.getClassEndTime().split(","); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // 本周周几 |
| | | int i = DateUtil.dayOfWeek(new Date())-1; |
| | | for (Integer integer : week) { |
| | | if(integer<i){ |
| | | // 找下一周的时间 |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7-(i-integer)); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | try { |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(0); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | }else if(integer>i) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,integer-i); |
| | | Date time1 = instance.getTime(); |
| | | List<Date> list = new ArrayList<>(); |
| | | list.add(time1); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time2 = instance.getTime(); |
| | | list.add(time2); |
| | | for (Date time : list) { |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | try { |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(0); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE,7); |
| | | Date time = instance.getTime(); |
| | | |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | try { |
| | | Date parse = format1.parse(format.format(time) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(time) + " " + split1[i1]); |
| | | coursePackageScheduling.setClassDate(parse); |
| | | coursePackageScheduling.setEndDate(parse1); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageScheduling.setCourseId(tCoursePackage.getId()); |
| | | coursePackageScheduling.setIntegral(0); |
| | | coursePackageScheduling.setCancelClasses(""); |
| | | coursePackageScheduling.setDeductClassHour(0); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(userId); |
| | | student1.setStudentId(sId); |
| | | student1.setCoursePackageId(tCoursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(paymentId); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(0); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(courseId); |
| | | tCourseInfoRecord.setName("报名假期班"); |
| | | tCourseInfoRecord.setNum(tCoursePackage.getNeedNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | | appUserClient.addCourseInfoRecord(tCourseInfoRecord); |
| | | |
| | | |
| | | } |
| | | private List<Integer> week(String week){ |
| | | String[] split = week.split(";"); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | for (String s : split) { |
| | | switch (s){ |
| | | case "周一": |
| | | integers.add(1); |
| | | break; |
| | | case "周二": |
| | | integers.add(2); |
| | | break; |
| | | case "周三": |
| | | integers.add(3); |
| | | break; |
| | | case "周四": |
| | | integers.add(4); |
| | | break; |
| | | case "周五": |
| | | integers.add(5); |
| | | break; |
| | | case "周六": |
| | | integers.add(6); |
| | | break; |
| | | case "周日": |
| | | integers.add(7); |
| | | break; |
| | | } |
| | | } |
| | | return integers; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包管理列表数据 |
| | | * @param queryCoursePackageLists |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryCoursePackageLists(Page<Map<String, Object>> page, QueryCoursePackageLists queryCoursePackageLists) { |
| | | List<Map<String, Object>> list = this.baseMapper.queryCoursePackageLists(page, queryCoursePackageLists); |
| | | for (Map<String, Object> map : list) { |
| | | Integer id = Integer.valueOf(map.get("id").toString()); |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(id); |
| | | map.put("paymentNumber", integer); |
| | | |
| | | boolean cash = false; |
| | | boolean coin = false; |
| | | List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id)); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : coursePackagePaymentConfigs) { |
| | | if(0 != coursePackagePaymentConfig.getCashPayment()){ |
| | | cash = true; |
| | | } |
| | | if(0 != coursePackagePaymentConfig.getPlayPaiCoin()){ |
| | | coin = true; |
| | | } |
| | | } |
| | | map.put("payType", (cash ? "现金支付" : "") + (coin ? cash ? "&玩湃币支付" : "玩湃币支付" : "")); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加课包 |
| | | * @param coursePackage |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer addCoursePackage(TCoursePackage coursePackage) { |
| | | try { |
| | | this.baseMapper.insert(coursePackage); |
| | | //生成排课数据 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date date = sdf1.parse(sdf.format(new Date()) + " 00:00:00"); |
| | | List<String> list = Arrays.asList(coursePackage.getClassWeeks().split(";")); |
| | | String value = coursePackage.getClassStartTime(); |
| | | String value1 = coursePackage.getClassEndTime(); |
| | | |
| | | String[] star = value.split(","); |
| | | String[] end = value1.split(","); |
| | | |
| | | for (int i = 0; i < star.length; i++) { |
| | | |
| | | // int index = star[i].indexOf(","); |
| | | // |
| | | // |
| | | // String result = value.substring(0, index).trim(); |
| | | String classStartTime = star[i]; |
| | | String[] split = classStartTime.split(":"); |
| | | // String value1 = en; |
| | | int index1 = value1.indexOf(","); |
| | | // String result1 = value.substring(0, index1).trim(); |
| | | String classEndTime = end[i]; |
| | | String[] split1 = classEndTime.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | s.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 13); |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | | while (true){ |
| | | int w = s.get(Calendar.DAY_OF_WEEK); |
| | | WeekEnum weekEnum = WeekEnum.getWeekEnum(w); |
| | | if(list.contains(weekEnum.getChineseName())){ |
| | | Calendar classDate = Calendar.getInstance(); |
| | | classDate.setTime(s.getTime()); |
| | | classDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | classDate.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | classDate.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar endDate = Calendar.getInstance(); |
| | | endDate.setTime(s.getTime()); |
| | | endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split1[0])); |
| | | endDate.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | endDate.set(Calendar.SECOND, 0); |
| | | |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(coursePackage.getId()); |
| | | coursePackageScheduling.setClassDate(classDate.getTime()); |
| | | coursePackageScheduling.setEndDate(endDate.getTime()); |
| | | coursePackageScheduling.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling); |
| | | } |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | if(s.getTimeInMillis() > timeInMillis){ |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | return coursePackage.getId(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * @param coursePackage |
| | | */ |
| | | @Override |
| | | public void updateCoursePackageById(TCoursePackage coursePackage) { |
| | | try { |
| | | List<CoursePackageStudent> coursePackageStudents = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("coursePackageId", coursePackage.getId())); |
| | | List<Long> collect = coursePackageStudents.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | QueryWrapper<CoursePackageScheduling> coursePackageSchedulingQueryWrapper = new QueryWrapper<CoursePackageScheduling>().eq("coursePackageId", coursePackage.getId()); |
| | | if(collect.size() > 0){ |
| | | coursePackageSchedulingQueryWrapper.notIn("id", collect); |
| | | } |
| | | coursePackageSchedulingService.remove(coursePackageSchedulingQueryWrapper); |
| | | |
| | | this.baseMapper.updateById(coursePackage); |
| | | //生成排课数据 |
| | | Date date = null; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingService.getOne(new QueryWrapper<CoursePackageScheduling>().eq("coursePackageId", coursePackage.getId()).last(" and classDate > now() order by classDate desc limit 0, 1")); |
| | | if(null != coursePackageScheduling){ |
| | | date = sdf1.parse(sdf.format(coursePackageScheduling.getClassDate()) + " 00:00:00"); |
| | | }else{ |
| | | date = sdf1.parse(sdf.format(new Date()) + " 00:00:00"); |
| | | } |
| | | List<String> list = Arrays.asList(coursePackage.getClassWeeks().split(";")); |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String[] split = classStartTime.split(":"); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | String[] split1 = classEndTime.split(":"); |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | if(null != coursePackageScheduling){ |
| | | long time = sdf1.parse(sdf.format(new Date()) + " 00:00:00").getTime(); |
| | | int d = Long.valueOf(14L - ((s.getTimeInMillis() - time) / 86400000L)).intValue(); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + d); |
| | | }else{ |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 13); |
| | | } |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | | while (true){ |
| | | int w = s.get(Calendar.DAY_OF_WEEK); |
| | | WeekEnum weekEnum = WeekEnum.getWeekEnum(w); |
| | | if(list.contains(weekEnum.getChineseName())){ |
| | | Calendar classDate = Calendar.getInstance(); |
| | | classDate.setTime(s.getTime()); |
| | | classDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0])); |
| | | classDate.set(Calendar.MINUTE, Integer.valueOf(split[1])); |
| | | classDate.set(Calendar.SECOND, 0); |
| | | |
| | | Calendar endDate = Calendar.getInstance(); |
| | | endDate.setTime(s.getTime()); |
| | | endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split1[0])); |
| | | endDate.set(Calendar.MINUTE, Integer.valueOf(split1[1])); |
| | | endDate.set(Calendar.SECOND, 0); |
| | | |
| | | CoursePackageScheduling coursePackageScheduling1 = new CoursePackageScheduling(); |
| | | coursePackageScheduling1.setCoursePackageId(coursePackage.getId()); |
| | | coursePackageScheduling1.setClassDate(classDate.getTime()); |
| | | coursePackageScheduling1.setEndDate(endDate.getTime()); |
| | | coursePackageScheduling1.setStatus(1); |
| | | coursePackageSchedulingService.save(coursePackageScheduling1); |
| | | } |
| | | s.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 1); |
| | | if(s.getTimeInMillis() > timeInMillis){ |
| | | break; |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包审核列表 |
| | | * @param page |
| | | * @param queryExamineCoursePackageLists |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryExamineCoursePackageLists(Page<Map<String, Object>> page, QueryExamineCoursePackageLists queryExamineCoursePackageLists) { |
| | | List<Map<String, Object>> list = this.baseMapper.queryExamineCoursePackageLists(page, queryExamineCoursePackageLists); |
| | | for (Map<String, Object> map : list) { |
| | | Integer id = Integer.valueOf(map.get("id").toString()); |
| | | boolean cash = false; |
| | | boolean coin = false; |
| | | List<CoursePackagePaymentConfig> coursePackagePaymentConfigs = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id)); |
| | | for (CoursePackagePaymentConfig coursePackagePaymentConfig : coursePackagePaymentConfigs) { |
| | | if(0 != coursePackagePaymentConfig.getCashPayment()){ |
| | | cash = true; |
| | | } |
| | | if(0 != coursePackagePaymentConfig.getPlayPaiCoin()){ |
| | | coin = true; |
| | | } |
| | | } |
| | | map.put("payType", (cash ? "现金支付" : "") + (coin ? cash ? "&玩湃币支付" : "玩湃币支付" : "")); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryByConfigId(Integer oneId) { |
| | | return this.baseMapper.queryByConfigId(oneId); |
| | | } |
| | | |
| | | @Override |
| | | public String getHours(Integer coursePackageId) { |
| | | return this.baseMapper.getHours(coursePackageId); |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil paymentCourseCouponList(Integer uid, Integer coursePackagePaymentConfigId) { |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(coursePackagePaymentConfigId); |
| | | if(ToolUtil.isEmpty(coursePackagePaymentConfig.getCouponIds())){ |
| | | coursePackagePaymentConfig.setCouponIds("-1"); |
| | | } |
| | | List<Coupon> coupons = couponClient.getCoupons(coursePackagePaymentConfig.getCouponIds()); |
| | | return ResultUtil.success(coupons); |
| | | } |
| | | } |