| | |
| | | package com.dsh.course.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.domain.*; |
| | | import com.alipay.api.request.AlipayTradeOrderSettleRequest; |
| | | import com.alipay.api.request.AlipayTradeRoyaltyRelationBindRequest; |
| | | import com.alipay.api.response.AlipayTradeOrderSettleResponse; |
| | | import com.alipay.api.response.AlipayTradeQueryResponse; |
| | | import com.alipay.api.response.AlipayTradeRoyaltyRelationBindResponse; |
| | | 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.model.*; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import io.vertx.core.json.Json; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.Resource; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private CoursePackageStudentMapper cpsMapper; |
| | | |
| | | |
| | | private String aliAppid = "2021004105665036";//支付宝appid |
| | | |
| | | private String appPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA==";//支付宝开发者应用私钥 |
| | | |
| | | private String alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAouYvZ1v4RiydwNOnGcU0Hb4hQu0x6XUooaE2Bi6/atNOobtFdunnATGP6OMOW7yF9DpP8qH5mbFXAiaQD721y/7qlayI50UcV4mngRU4ZcaAVE3bp721Eg2H85RISa+Tb1CiOh+pc9p4l5UBseKsvB2ruHHForfZDPI8FL7AVUKBYCQPsa4zL6KAO2C6KULaTg/lCa+bYQKU0n9ca569VtdsqJUyxB9eSZjVd+9nKl62FLqp2NELGj7cXqiVBgDnBnVS5ZUO3mrBM5z/AxQbw3RwE3JqdkhzUA1BFjejAlT2zIGNOjUFagF8ao0wGElYfuk0bum6Hz5qWAt02QdNNwIDAQAB";//支付宝应用公钥 |
| | | |
| | | private String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB";//支付宝支付公钥 |
| | | |
| | | |
| | | @Override |
| | | public List<CourseOfStoreVo> queryStoreOfCourse() { |
| | |
| | | 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); |
| | | |
| | | QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2)) |
| | | .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode); |
| | | .eq("auditStatus", 2).eq("state", 1); |
| | | if(null != coursePackageList.getCoursePackageTypeId()){ |
| | | wrapper.eq("coursePackageTypeId", coursePackageList.getCoursePackageTypeId()); |
| | | } |
| | |
| | | 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); |
| | | wrapper.or().in("storeId", collect); |
| | | } |
| | | } |
| | | List<TCoursePackage> list = this.list(wrapper.last(" order by sort, insertTime desc")); |
| | | List<TCoursePackage> list1 = this.list(wrapper.last(" order by sort desc, insertTime desc")); |
| | | Date currentTime = new Date(); |
| | | |
| | | // Filter the list based on the conditions |
| | | List<TCoursePackage> list = list1.stream() |
| | | .filter(coursePackage -> coursePackage.getType() != 2 || currentTime.before(coursePackage.getEndTime())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<CoursePackageListVo> listVos = new ArrayList<>(); |
| | | for (TCoursePackage coursePackage : list) { |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | |
| | | 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); |
| | | if(ToolUtil.isNotEmpty(classStartTime)) { |
| | | for (int i = 0; i < split.length; i++) { |
| | | String s = split[i].substring(0,5) + "-" + split3[i].substring(0,5); |
| | | classTime.add(s); |
| | | } |
| | | } |
| | | coursePackageListVo.setClassStartTime(classTime); |
| | | coursePackageListVo.setType(coursePackage.getType()); |
| | |
| | | |
| | | |
| | | coursePackageListVo.setApplicantsNumber(integer); |
| | | coursePackageListVo.setPayType(coursePackage.getPayType()); |
| | | coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | Double cashPayment1 = coursePackagePaymentConfig.getCashPayment(); |
| | | Integer playPaiCoin = coursePackagePaymentConfig.getPlayPaiCoin(); |
| | | if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0 && ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){ |
| | | coursePackageListVo.setPayType(3); |
| | | }else if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0){ |
| | | coursePackageListVo.setPayType(1); |
| | | }else if(ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){ |
| | | coursePackageListVo.setPayType(2); |
| | | } |
| | | |
| | | |
| | | |
| | | if (coursePackagePaymentConfig!=null) { |
| | | coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin()); |
| | | } |
| | | //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | // if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | .eq("type", 1).eq("auditStatus", 2).eq("status",1)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list2) { |
| | | Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember"); |
| | |
| | | } |
| | | } |
| | | coursePackageListVo.setVipPrice(vipPrice); |
| | | coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | |
| | | Double paymentPrice = coursePackagePaymentConfig.getCashPayment(); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2)); |
| | | List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 3).eq("auditStatus", 2).eq("status",1)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TCoursePackageDiscount coursePackageDiscount : list3) { |
| | | /** |
| | |
| | | } |
| | | } |
| | | 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()); |
| | | } |
| | | |
| | | double vipPrice1 = coursePackageListVo.getVipPrice(); |
| | | double originalPrice1 = coursePackageListVo.getOriginalPrice(); |
| | | double paymentPrice1 = coursePackageListVo.getPaymentPrice(); |
| | | |
| | | double minPrice = Math.min(vipPrice1, Math.min(originalPrice1, paymentPrice1)); |
| | | double maxPrice = Math.max(vipPrice1, Math.max(originalPrice1, paymentPrice1)); |
| | | coursePackageListVo.setPaymentPrice(minPrice); |
| | | coursePackageListVo.setOriginalPrice(maxPrice); |
| | | System.out.println("Minimum price: " + minPrice); |
| | | System.out.println("Maximum price: " + maxPrice); |
| | | // } |
| | | // else{ |
| | | // List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | // .eq("type", 1).eq("auditStatus", 2).eq("status",1)); |
| | | // 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); |
| | |
| | | } |
| | | |
| | | //销量排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())){ |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())&&coursePackageList.getSalesRanking().equals("asc")){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Integer.compare(s1.getApplicantsNumber(), s2.getApplicantsNumber()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())&&coursePackageList.getSalesRanking().equals("desc")){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Integer.compare(s2.getApplicantsNumber(), s1.getApplicantsNumber()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | //距离排行 |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())){ |
| | | if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())&&coursePackageList.getDistanceSort().equals("asc")){ |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Double.compare(s1.getDistance(), s2.getDistance()); |
| | | } |
| | | }); |
| | | } |
| | | if (ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())&&coursePackageList.getDistanceSort().equals("desc")) { |
| | | Collections.sort(listVos, new Comparator<CoursePackageListVo>() { |
| | | public int compare(CoursePackageListVo s1, CoursePackageListVo s2) { |
| | | return Double.compare(s2.getDistance(), s1.getDistance()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | return listVos; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | coursePackageListVo.setId(coursePackage.getId()); |
| | | coursePackageListVo.setName(coursePackage.getName()); |
| | | coursePackageListVo.setStoreName(null != store ? store.getName() : ""); |
| | | // coursePackageListVo.setPayType(); |
| | | coursePackageListVo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | |
| | | Double cashPayment1 = coursePackagePaymentConfig.getCashPayment(); |
| | | Integer playPaiCoin = coursePackagePaymentConfig.getPlayPaiCoin(); |
| | | if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0 && ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){ |
| | | coursePackageListVo.setPayType(3); |
| | | }else if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0){ |
| | | coursePackageListVo.setPayType(1); |
| | | }else if(ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){ |
| | | coursePackageListVo.setPayType(2); |
| | | } |
| | | |
| | | // 2.0修改 |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | TCoursePackage coursePackage = this.getById(id); |
| | | CoursePackageInfo coursePackageInfo = new CoursePackageInfo(); |
| | | coursePackageInfo.setIsVip(appUser.getIsVip()); |
| | | coursePackageInfo.setId(id); |
| | | coursePackageInfo.setTime(coursePackage.getStartTime()+"-"+coursePackage.getEndTime()); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); |
| | | if(coursePackage.getType()==2){ |
| | | |
| | | coursePackageInfo.setTime(format.format(coursePackage.getStartTime())+"-"+format.format(coursePackage.getEndTime())); |
| | | } |
| | | coursePackageInfo.setCoverDrawing(coursePackage.getCoverDrawing()); |
| | | |
| | | coursePackageInfo.setName(coursePackage.getName()); |
| | | Store store = storeClient.queryStoreById(coursePackage.getStoreId()); |
| | | coursePackageInfo.setStoreName(store.getName()); |
| | |
| | | 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); |
| | | if(ToolUtil.isNotEmpty(classStartTime)){ |
| | | for (int i = 0; i < split4.length; i++) { |
| | | String s = split4[i].substring(0,5) + "-" + split3[i].substring(0,5); |
| | | 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(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0 && ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | coursePackagePaymentConfigVo.setPayType(3); |
| | | }else if(ToolUtil.isNotEmpty(coursePackagePaymentConfig.getCashPayment()) && coursePackagePaymentConfig.getCashPayment()>0){ |
| | | coursePackagePaymentConfigVo.setPayType(1); |
| | | }else if( ToolUtil.isNotEmpty(coursePackagePaymentConfig.getPlayPaiCoin()) && coursePackagePaymentConfig.getPlayPaiCoin()>0 ){ |
| | | coursePackagePaymentConfigVo.setPayType(2); |
| | | } |
| | | |
| | | // coursePackagePaymentConfigVo.setPayType(coursePackage.getPayType()); |
| | | //会员显示原价和支付价(会员价)。非会员显示会员价和支付价(最低) |
| | | if(appUser.getIsVip() == 0){//非会员 |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | |
| | | } |
| | | } |
| | | 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)); |
| | |
| | | } |
| | | } |
| | | coursePackagePaymentConfigVo.setPaymentPrice(paymentPrice); |
| | | }else{ |
| | | |
| | | if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){ |
| | | coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment()); |
| | | coursePackagePaymentConfigVo.setVipPrice(null); |
| | | } |
| | | |
| | | } |
| | | else{ |
| | | List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId()) |
| | | .eq("type", 1).eq("auditStatus", 2)); |
| | | Double vipPrice = coursePackagePaymentConfig.getCashPayment(); |
| | |
| | | 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(); |
| | | //校验是否已经报满 |
| | | Integer integer = coursePackagePaymentService.queryCountNumber(paymentCourseVo.getId()); |
| | | TCoursePackage course = coursePackageService.getById(paymentCourseVo.getId()); |
| | | if (course.getType()!=3) { |
| | | |
| | | if (integer + paymentCourseVo.getStudentIds().split(";").length > course.getMaxSubscribeNumber()) { |
| | | return ResultUtil.error("报名失败,已达最大报名人数"); |
| | | } |
| | | } |
| | | List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList(); |
| | | String[] students = paymentCourseVo.getStudentIds().split(";"); |
| | | for (CoursePackagePaymentConfigVo coursePackagePaymentConfigVo : list) { |
| | | if(paymentCourseVo.getCoursePackagePaymentConfigId().compareTo(coursePackagePaymentConfigVo.getId()) == 0){ |
| | | CoursePackagePaymentConfig byId = coursePackagePaymentConfigService.getById(paymentCourseVo.getCoursePackagePaymentConfigId()); |
| | | Double cashPayment = byId.getCashPayment(); |
| | | Integer payType = coursePackagePaymentConfigVo.getPayType(); |
| | | if(payType == 1 && paymentCourseVo.getPayType() == 3){//现金支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | Integer playPaiCoin1 = byId.getPlayPaiCoin(); |
| | | if(cashPayment!=null || cashPayment>0){ |
| | | payType=1; |
| | | } |
| | | if(payType == 2 && paymentCourseVo.getPayType() != 3){//玩湃币支付 |
| | | return ResultUtil.error("支付方式错误,请刷新后重试"); |
| | | if(playPaiCoin1!=null || playPaiCoin1>0){ |
| | | payType=2; |
| | | } |
| | | if((cashPayment!=null || cashPayment>0) &&(playPaiCoin1!=null || playPaiCoin1>0)){ |
| | | payType=3; |
| | | } |
| | | if(cashPayment!=null && cashPayment>0 && playPaiCoin1 !=null && playPaiCoin1>0){ |
| | | }else { |
| | | 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){ |
| | | if(paymentCourseVo.getPayType() != 3 && paymentPrice.compareTo(paymentCourseVo.getPrice()) != 0&&paymentCourseVo.getCouponId()!=null){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | if(payType == 2 && playPaiCoin.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | if(paymentCourseVo.getPayType() == 3 && playPaiCoin.compareTo(paymentCourseVo.getPrice()) != 0){ |
| | | return ResultUtil.error("支付金额异常,请刷新后重试"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Double price = paymentCourseVo.getPrice();//支付金额 |
| | | |
| | | //校验优惠券 |
| | | Long couponId = paymentCourseVo.getCouponId(); |
| | | if(null != couponId && paymentCourseVo.getPayType() != 3){ |
| | |
| | | coursePackagePayment.setState(1); |
| | | coursePackagePayment.setInsertTime(new Date()); |
| | | coursePackagePaymentService.save(coursePackagePayment); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("购买课包"); |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | |
| | | // 2.0 |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds())); |
| | | |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId()); |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId(),null); |
| | | break; |
| | | } |
| | | if("USERPAYING".equals(s)){ |
| | |
| | | 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); |
| | | // 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); |
| | | // |
| | | // |
| | | // CourseCounsum courseCounsum = new CourseCounsum(); |
| | | // courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | // courseCounsum.setChangeType(1); |
| | | // courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | // courseCounsum.setInsertTime(new Date()); |
| | | // courseCounsum.setReason("购买课包"); |
| | | // courseCounsumService.save(courseCounsum); |
| | | |
| | | TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId())); |
| | | |
| | | if (coursePackagePaymentServiceOne==null) { |
| | | 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.setPlayPaiCoin(paymentPrice.intValue()); |
| | | 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); |
| | | Integer sId = null; |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | if (student != null) { |
| | | sId = student.getId(); |
| | | } |
| | | |
| | | // coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue()); |
| | | |
| | | // addPackageStudent(paymentCourseVo.getId(), uid, Integer.valueOf(s), coursePackagePayment.getId()); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("购买课包"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | }else { |
| | | // coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | // coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice()+paymentCourseVo.getPrice()); |
| | | // coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue()); |
| | | // coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | // coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | // coursePackagePaymentServiceOne.setCode(code); |
| | | // |
| | | // coursePackagePaymentServiceOne.setAppUserId(null); |
| | | // coursePackagePaymentServiceOne.setPayStatus(2); |
| | | // coursePackagePaymentService.updateById(coursePackagePaymentServiceOne); |
| | | // |
| | | // Integer sId = null; |
| | | // Student student = studentClient.queryDefaultStudent(uid); |
| | | // if (student != null) { |
| | | // sId = student.getId(); |
| | | // } |
| | | // coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue()); |
| | | // |
| | | // |
| | | // CourseCounsum courseCounsum = new CourseCounsum(); |
| | | // courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId()); |
| | | // courseCounsum.setChangeType(1); |
| | | // courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | // courseCounsum.setInsertTime(new Date()); |
| | | // courseCounsum.setReason("续课"); |
| | | // courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | |
| | | sid=student.getId(); |
| | | } |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay("购买课程", "购买课程", "", code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback"); |
| | | ResultUtil alipay = payMoneyUtil.alipay("购买课程", "购买课程", student.getId().toString(), code, paymentPrice.toString(), "/base/course/aliPaymentCourseCallback"); |
| | | if(alipay.getCode() == 200){ |
| | | Integer finalSid = sid; |
| | | new Thread(new Runnable() { |
| | |
| | | if(one.getPayStatus() == 2){ |
| | | break; |
| | | } |
| | | ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); |
| | | if(resultUtil.getCode() == 200 && one.getPayStatus() == 1){ |
| | | AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); |
| | | if( 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"); |
| | | String s = alipayTradeQueryResponse.getTradeStatus(); |
| | | |
| | | String tradeNo = alipayTradeQueryResponse.getTradeNo(); |
| | | if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setStatus(3); |
| | |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(tradeNo); |
| | | coursePackagePayment.setAppUserId(null); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | |
| | | for (String s1 : split) { |
| | | TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId())); |
| | | if (coursePackagePaymentServiceOne!=null) { |
| | | coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice()+paymentCourseVo.getPrice()); |
| | | coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue()); |
| | | coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours()); |
| | | coursePackagePaymentServiceOne.setCode(code); |
| | | |
| | | coursePackagePaymentServiceOne.setAppUserId(null); |
| | | coursePackagePaymentServiceOne.setPayStatus(2); |
| | | coursePackagePaymentService.updateById(coursePackagePaymentServiceOne); |
| | | |
| | | Integer sId = null; |
| | | Student student = studentClient.queryDefaultStudent(uid); |
| | | if (student != null) { |
| | | sId = student.getId(); |
| | | } |
| | | coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue()); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("续课"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | System.out.println("===========到达支付"); |
| | | // 2.0 |
| | | String[] coupons = coursePackagePaymentConfig.getCouponIds().split(","); |
| | | |
| | | |
| | | |
| | | userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds())); |
| | | |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,coursePackagePayment.getId(),paymentCourseVo.getPrice()); |
| | | |
| | | |
| | | } |
| | | |
| | | moneyOut(tradeNo,tradeNo); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if(student!=null){ |
| | | |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId()); |
| | | break; |
| | | } |
| | | if("WAIT_BUYER_PAY".equals(s)){ |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | public void moneyOut(String outNum,String tradeNo) throws AlipayApiException { |
| | | AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", aliAppid, appPrivateKey, "json", "UTF-8", alipay_public_key, "RSA2"); |
| | | AlipayTradeOrderSettleRequest request = new AlipayTradeOrderSettleRequest(); |
| | | AlipayTradeOrderSettleModel model = new AlipayTradeOrderSettleModel(); |
| | | model.setOutRequestNo(outNum); |
| | | model.setTradeNo(tradeNo); |
| | | List<RoyaltyDetailInfos> royaltyDetailInfos = new ArrayList<>(); |
| | | // |
| | | |
| | | AlipayTradeRoyaltyRelationBindRequest request1 = new AlipayTradeRoyaltyRelationBindRequest(); |
| | | AlipayTradeRoyaltyRelationBindModel bindModel = new AlipayTradeRoyaltyRelationBindModel(); |
| | | |
| | | |
| | | request1.setBizContent("{" + |
| | | " \"receiver_list\":[" + |
| | | " {" + |
| | | " \"type\":\"loginName\"," + |
| | | " \"account\":\"19522115070\"," + |
| | | " \"name\":\"罗易胜\"," + |
| | | " \"memo\":\"分账给测试商户\"," + |
| | | " }" + |
| | | " ]," + |
| | | " \"out_request_no\":\""+tradeNo+"\"" + |
| | | "}"); |
| | | AlipayTradeRoyaltyRelationBindResponse response = alipayClient.execute(request1); |
| | | if(response.isSuccess()){ |
| | | System.out.println("绑定调用成功"); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | // RoyaltyDetailInfos royaltyDetailInfos1 = new RoyaltyDetailInfos(); |
| | | // royaltyDetailInfos1.setTransOutType("loginName"); |
| | | // royaltyDetailInfos1.setTransOut("happysports@weparklife.com"); |
| | | // royaltyDetailInfos1.setTransInType("loginName"); |
| | | // royaltyDetailInfos1.setTransIn("19522115070"); |
| | | //// royaltyDetailInfos1.setAmount("0.01"); |
| | | // royaltyDetailInfos1.setAmountPercentage("100"); |
| | | |
| | | // royaltyDetailInfos.add(royaltyDetailInfos1); |
| | | |
| | | TCoursePackagePayment one = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("code", outNum)); |
| | | TCoursePackage byId = coursePackageService.getById(one.getCoursePackageId()); |
| | | OperatorUser operatorUser = storeClient.queryByStoreId(byId.getStoreId()); |
| | | |
| | | |
| | | |
| | | // Integer paymentCompetitions = competitionsClient.queryByCode(outTradeNo); |
| | | // Integer siteBookings = siteClient.queryByCode(outTradeNo); |
| | | // List<Integer> stores = new ArrayList<>(); |
| | | // stores.add(coursePackagePayments); |
| | | // stores.add(paymentCompetitions); |
| | | // stores.add(siteBookings); |
| | | // OperatorUser operatorUser = siteClient.queryOperator(stores); |
| | | |
| | | |
| | | |
| | | |
| | | OpenApiRoyaltyDetailInfoPojo op = new OpenApiRoyaltyDetailInfoPojo(); |
| | | op.setTransOutType("loginName"); |
| | | op.setTransOut("happysports@weparklife.com"); |
| | | op.setTransInType("userId"); |
| | | op.setTransIn(operatorUser.getAlipayNum()); |
| | | op.setAmountPercentage(Long.valueOf(operatorUser.getAlipayProportion())); |
| | | |
| | | List<OpenApiRoyaltyDetailInfoPojo> ops = new ArrayList<>(); |
| | | ops.add(op); |
| | | model.setRoyaltyParameters(ops); |
| | | |
| | | request.setBizModel(model); |
| | | |
| | | |
| | | AlipayTradeOrderSettleResponse response1 = alipayClient.execute(request); |
| | | if(response1.isSuccess()){ |
| | | System.out.println("调用成功"); |
| | | } else { |
| | | System.out.println("调用失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 玩湃币支付课程 |
| | | * @param appUser |
| | |
| | | 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(); |
| | | |
| | | |
| | | //赠送课时 |
| | | int weekday = DateUtil.dayOfWeek(new Date()) - 1; |
| | | TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("type",4).eq("coursePackageId", paymentCourseVo.getId()).last("limit 1")); |
| | | |
| | | Integer hour = 0; |
| | | if (discount!=null) { |
| | | JSONArray objects = JSONObject.parseArray(discount.getContent()); |
| | | JSONObject parse = JSONObject.parseObject(JSONObject.toJSONString(objects.get(0))); |
| | | hour = parse.getInteger("hour"); |
| | | if (hour == null) { |
| | | hour = 0; |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(),appUser.getId(),sId,coursePackagePayment.getId()); |
| | | } |
| | | |
| | | for (String s : split) { |
| | | TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId())); |
| | | |
| | | |
| | | |
| | | if (coursePackagePaymentServiceOne==null) { |
| | | 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()+hour); |
| | | coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue()); |
| | | coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()+hour); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()+hour); |
| | | 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(), Integer.valueOf(s), coursePackagePayment.getId(),null); |
| | | |
| | | //课时记录 |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePayment.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("购买课包"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | }else{ |
| | | coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours()+hour); |
| | | if (coursePackagePaymentServiceOne.getOriginalPrice()!=null) { |
| | | coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice() + paymentCourseVo.getPrice()); |
| | | }else { |
| | | coursePackagePaymentServiceOne.setOriginalPrice(paymentCourseVo.getPrice()); |
| | | } |
| | | if (coursePackagePaymentServiceOne.getPlayPaiCoin()==null){ |
| | | coursePackagePaymentServiceOne.setPlayPaiCoin(paymentPrice.intValue()); |
| | | |
| | | }else { |
| | | coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());} |
| | | coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours()+hour); |
| | | coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours()+hour); |
| | | coursePackagePaymentServiceOne.setAppUserId(null); |
| | | coursePackagePaymentService.updateById(coursePackagePaymentServiceOne); |
| | | |
| | | // coursePackagePaymentService.save(coursePackagePayment); |
| | | Integer sId = null; |
| | | Student student = studentClient.queryDefaultStudent(appUser.getId()); |
| | | if (student != null) { |
| | | sId = student.getId(); |
| | | } |
| | | addPackageStudent(paymentCourseVo.getId(), appUser.getId(), Integer.valueOf(s), coursePackagePaymentServiceOne.getId(),null); |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId()); |
| | | courseCounsum.setChangeType(1); |
| | | courseCounsum.setNum(coursePackagePaymentConfig.getClassHours()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("续课"); |
| | | courseCounsumService.save(courseCounsum); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | Integer playPaiCoins = appUser.getPlayPaiCoins(); |
| | |
| | | } |
| | | |
| | | |
| | | private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId){ |
| | | |
| | | |
| | | |
| | | private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId,Double price) throws ParseException { |
| | | // 课包 |
| | | TCoursePackage tCoursePackage = this.baseMapper.selectById(courseId); |
| | | |
| | | if (tCoursePackage.getType()==1) { |
| | | 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"); |
| | | |
| | | //查出当前用户当前学员当前课包最后一天的排课数据 |
| | | List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId)); |
| | | List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList()); |
| | | |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | //拿到最后一天的排课记录 |
| | | if (collect.size() > 0){ |
| | | coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id", collect)); |
| | | coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId)); |
| | | if (price!=null) { |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(paymentId); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("续课;" + price); |
| | | courseCounsum.setAppUserId(userId); |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | |
| | | }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]); |
| | | if (price!=null) { |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(paymentId); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("报名课程;" + price); |
| | | courseCounsum.setAppUserId(userId); |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | } |
| | | Date today = new Date(); |
| | | TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId); |
| | | Integer laveClassHours = pay.getLaveClassHours(); |
| | | Integer codeTime = tCoursePackage.getCodeTime(); |
| | | Integer can = 0; |
| | | int count = 0; |
| | | // 本周周几 |
| | | Date[] dates = generateDateArray(14, today); |
| | | if (tCoursePackage.getType() == 1) { |
| | | can = laveClassHours / codeTime; |
| | | } |
| | | if (tCoursePackage.getType() == 2) { |
| | | Date startDate = tCoursePackage.getStartTime(); |
| | | Date endDate = tCoursePackage.getEndTime(); |
| | | dates = generateDateArray1(startDate, endDate); |
| | | can = 999; |
| | | } |
| | | for (Date date : dates) { |
| | | if (count == can) { |
| | | break; |
| | | } |
| | | int wei = DateUtil.dayOfWeek(date); |
| | | if (week.contains(wei)) { |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | if (count == can) { |
| | | break; |
| | | } |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(date) + " " + 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.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else if (tCoursePackage.getType()==2){ |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | |
| | | Date today = new Date(); |
| | | |
| | | Date startTime = tCoursePackage.getStartTime(); |
| | | Date endTime = tCoursePackage.getEndTime(); |
| | | LocalDate startDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate endDate = endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | Period period = Period.between(startDate, endDate); |
| | | int days = period.getDays() + 1; |
| | | Integer can =999; |
| | | int count = 0; |
| | | 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"); |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | |
| | | TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId); |
| | | |
| | | |
| | | Date[] dates = generateDateArray(days,calendar.getTime()); |
| | | for (Date date : dates) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | int wei = cn.hutool.core.date.DateUtil.dayOfWeek(date)-1; |
| | | if (wei == 0){ |
| | | wei =7; |
| | | } |
| | | if (week.contains(wei)){ |
| | | for (int i1 = 0; i1 < split.length; i1++) { |
| | | if (count==can){ |
| | | break; |
| | | } |
| | | CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling(); |
| | | coursePackageScheduling.setCoursePackageId(tCoursePackage.getId()); |
| | | Date parse = format1.parse(format.format(date) + " " + split[i1]); |
| | | Date parse1 = format1.parse(format.format(date) + " " + 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(pay.getId()); |
| | | student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | cpsMapper.insert(student1); |
| | | count++; |
| | | } |
| | | } |
| | | } |
| | | }else if (tCoursePackage.getType()==3){ |
| | | |
| | | if (price!=null) { |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(paymentId); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("购买体验课;" + price); |
| | | courseCounsum.setAppUserId(userId); |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | |
| | | |
| | | //生成当天的排课记录 |
| | | |
| | | //生成学员的上课表 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | // 2.0 |
| | | TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord(); |
| | | tCourseInfoRecord.setUserId(userId); |
| | | tCourseInfoRecord.setCourseId(courseId); |
| | | tCourseInfoRecord.setName("报名假期班"); |
| | | tCourseInfoRecord.setName("报名运动营"); |
| | | tCourseInfoRecord.setNum(tCoursePackage.getNeedNum()); |
| | | tCourseInfoRecord.setTime(new Date()); |
| | | tCourseInfoRecord.setType(2); |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public static Date[] generateDateArray1(Date startDate, Date endDate) { |
| | | List<Date> dateList = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startDate); |
| | | |
| | | while (!calendar.getTime().after(endDate)) { |
| | | Date currentDate = calendar.getTime(); |
| | | dateList.add(currentDate); |
| | | calendar.add(Calendar.DAY_OF_MONTH, 1); |
| | | } |
| | | |
| | | return dateList.toArray(new Date[0]); |
| | | } |
| | | |
| | | public static Date createDate1(int year, int month, int day) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(year, month - 1, day); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | private List<Integer> week(String week){ |
| | | String[] split = week.split(";"); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public static Date[] generateDateArray(int numDays,Date date) { |
| | | // LocalDate tomorrow = LocalDate.now().plusDays(1); |
| | | LocalDate tomorrow = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1); |
| | | |
| | | Date[] dates = new Date[numDays]; |
| | | |
| | | for (int i = 0; i < numDays; i++) { |
| | | LocalDate currentDate = tomorrow.plusDays(i); |
| | | dates[i] = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | return dates; |
| | | } |
| | | /** |
| | | * 获取课包管理列表数据 |
| | | * @param queryCoursePackageLists |
| | |
| | | @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(","); |
| | | if (coursePackage.getClassStartTime()!=null&&coursePackage.getClassStartTime()!="") { |
| | | //生成排课数据 |
| | | 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().trim(); |
| | | |
| | | for (int i = 0; i < star.length; i++) { |
| | | 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 classStartTime = star[i]; |
| | | String[] split = classStartTime.split(":"); |
| | | // String value1 = en; |
| | | int index1 = value1.indexOf(","); |
| | | 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); |
| | | } |
| | | 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); |
| | | if(s.getTimeInMillis() > timeInMillis){ |
| | | break; |
| | | 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) + 14); |
| | | 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){ |
| | |
| | | coursePackageSchedulingService.remove(coursePackageSchedulingQueryWrapper); |
| | | |
| | | this.baseMapper.updateById(coursePackage); |
| | | |
| | | //生成排课数据 |
| | | Date date = null; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | |
| | | 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); |
| | | e.set(Calendar.DAY_OF_YEAR, s.get(Calendar.DAY_OF_YEAR) + 14); |
| | | } |
| | | long timeInMillis = e.getTimeInMillis(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getHours(Integer coursePackageId) { |
| | | public List<Integer> 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"); |
| | | // CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(coursePackagePaymentConfigId); |
| | | // if(ToolUtil.isEmpty(coursePackagePaymentConfig.getCouponIds())){ |
| | | // coursePackagePaymentConfig.setCouponIds("-1"); |
| | | // } |
| | | // List<Coupon> coupons = couponClient.getCoupons(coursePackagePaymentConfig.getCouponIds()); |
| | | |
| | | List<Coupon> coupons = couponClient.queryCouponByUid(uid); |
| | | |
| | | |
| | | if (CollectionUtil.isNotEmpty(coupons)) { |
| | | for (Coupon coupon : coupons){ |
| | | Date date1 = coupon.getStartTime(); // 2023-10-01 00:00:00 |
| | | Date date2 = coupon.getEndTime(); // 2023-10-12 00:00:00 |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); |
| | | String dateString1 = sdf.format(date1); |
| | | String dateString2 = sdf.format(date2); |
| | | |
| | | String result = dateString1 + "-" + dateString2; |
| | | coupon.setTimePeriod(result); |
| | | } |
| | | } |
| | | List<Coupon> coupons = couponClient.getCoupons(coursePackagePaymentConfig.getCouponIds()); |
| | | return ResultUtil.success(coupons); |
| | | } |
| | | } |