| | |
| | | @ApiImplicitParam(value = "搜索", name = "search", required = true, dataType = "string"), |
| | | }) |
| | | public ResultUtil<List<StoreDetailList>> getStoreListCon(Integer space, String cityCode, String latitude, String longitude, String search) { |
| | | // try { |
| | | return ResultUtil.success(tsService.queryStoreList(space, cityCode, longitude, latitude, search)); |
| | | // }catch (Exception e){ |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | citycodeResp.setLatitude(longitude); |
| | | List<StoreDetailList> queryStoreList = storeClient.getQueryStoreList(citycodeResp); |
| | | if (queryStoreList.size() > 0) { |
| | | |
| | | if (ToolUtil.isEmpty(space) || space ==1) { |
| | | queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList()); |
| | | |
| | | |
| | | } else { |
| | | queryStoreList = queryStoreList.stream() |
| | | .sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed()) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | // if (ToolUtil.isEmpty(space) || space == 2) { |
| | | // queryStoreList = queryStoreList.stream() |
| | | // .sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed()) |
| | | // .collect(Collectors.toList()); |
| | | // |
| | | // } else { |
| | | // queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList()); |
| | | // } |
| | | if (ToolUtil.isNotEmpty(search)) { |
| | | queryStoreList = queryStoreList.stream().filter(o -> o.getStoreName().contains(search)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |
| | | return queryStoreList; |
| | | } |
| | |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | if("[]".equals(code)){ |
| | | throw new Exception("经纬度转行政区划代码失败[" + lon + "," + lan + "]"); |
| | | System.err.println("经纬度转行政区划代码失败[" + lon + "," + lan + "]"); |
| | | return null; |
| | | } |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | |
| | | List<IntegralCommodity> commodity = new ArrayList<>(); |
| | | |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(location.getLon(), location.getLat()); |
| | | if(null == geocode){ |
| | | return new ArrayList<>(); |
| | | } |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | |
| | | |
| | | // if(null != geocode) { |
| | | |
| | | List<Store> stores = storeClient.queryStoreList(new QueryStoreList(provinceCode, cityCode)); |
| | | Store s = null; |
| | | Double d = 0D; |
| | |
| | | d = wgs84; |
| | | } |
| | | } |
| | | // } |
| | | |
| | | // List<PointsMerchandiseCity> cityCode1 = pmdsCityService.list(new QueryWrapper<PointsMerchandiseCity>().eq("cityCode", cityCode)); |
| | | List<Integer> cIds = new ArrayList<>(); |
| | | // for (PointsMerchandiseCity pointsMerchandiseCity : cityCode1) { |
| | | // cIds.add(pointsMerchandiseCity.getPointsMerchandiseId()); |
| | | // } |
| | | |
| | | List<PointsMerchandiseStore> storesids = pointsMerchandiseStoreService.list(new QueryWrapper<PointsMerchandiseStore>().eq("storeId", s.getId())); |
| | | for (PointsMerchandiseStore storesid : storesids) { |
| | | cIds.add(storesid.getPointsMerchandiseId()); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | import com.dsh.activity.entity.TStudent; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.feignclient.account.AppUserClient; |
| | | import com.dsh.activity.feignclient.account.StudentClient; |
| | | import com.dsh.activity.feignclient.account.model.AppUser; |
| | | import com.dsh.activity.feignclient.model.CouponStuAvailableVo; |
| | | import com.dsh.activity.feignclient.model.QueryUserCouponByIdAndUserId; |
| | | import com.dsh.activity.model.CouponListVo; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | @Autowired |
| | | private UserCouponService userCouponService; |
| | | |
| | | |
| | | @Autowired |
| | | private CouponStoreService csServie; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | |
| | | |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); |
| | |
| | | String couponIds = sendCouponReq.getCouponIds(); |
| | | for (String s : couponIds.split(",")) { |
| | | Coupon coupon = couponService.getById(s); |
| | | Integer userId = sendCouponReq.getUserId(); |
| | | if(coupon.getAuditStatus() != 2){ |
| | | continue; |
| | | } |
| | | if(coupon.getStatus() != 2){ |
| | | continue; |
| | | } |
| | | if(coupon.getState() != 1){ |
| | | continue; |
| | | } |
| | | if(coupon.getUserPopulation() == 2){ |
| | | AppUser appUser = appUserClient.queryAppUser(userId); |
| | | if(appUser.getIsVip() == 0){ |
| | | continue; |
| | | } |
| | | } |
| | | if(coupon.getUserPopulation() == 3){ |
| | | List<TStudent> tStudents = studentClient.queryStudentList(userId); |
| | | if(tStudents.size() == 0){ |
| | | continue; |
| | | } |
| | | } |
| | | if (new Date().before(coupon.getStartTime()) && new Date().after(coupon.getEndTime())) { |
| | | continue; |
| | | } |
| | |
| | | if (coupon.getQuantityIssued() <= counts) { |
| | | continue; |
| | | } |
| | | counts = userCouponService.count(new QueryWrapper<UserCoupon>().eq("couponId", s).eq("userId", userId)); |
| | | if (coupon.getPickUpQuantity() <= counts) { |
| | | continue; |
| | | } |
| | | |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(Integer.valueOf(s)); |
| | |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | if("[]".equals(code)){ |
| | | throw new Exception("经纬度转行政区划代码失败[" + lon + "," + lan + "]"); |
| | | System.err.println("经纬度转行政区划代码失败[" + lon + "," + lan + "]"); |
| | | return null; |
| | | } |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | |
| | | <version>2.4</version> |
| | | <classifier>jdk15</classifier> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>aliyun-java-sdk-core</artifactId> |
| | | <version>4.4.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.aliyun.oss</groupId> |
| | | <artifactId>aliyun-sdk-oss</artifactId> |
| | | <version>3.8.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | |
| | | |
| | | /** |
| | | * 根据门店ids获取课包ids 根据课包ids 获取购课记录的用户ids |
| | |
| | | @ResponseBody |
| | | @PostMapping("/coursePackage/updateCoursePackageById") |
| | | public void updateCoursePackageById(@RequestBody TCoursePackage coursePackage) { |
| | | TCoursePackage coursePackage1 = coursePackageService.getById(coursePackage.getId()); |
| | | coursePackageService.updateCoursePackageById(coursePackage); |
| | | //暂停课程后的开课操作(需要检查是否继续排课) |
| | | if(coursePackage1.getStatus() == 4 && coursePackage.getStatus() == 1){ |
| | | coursePackageSchedulingService.startAndScheduleClasses(coursePackage.getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | @Autowired |
| | | private ICoursePackageOrderStudentService coursePackageOrderStudentService; |
| | | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | @Resource |
| | | private AppUserClient appuClient; |
| | | |
| | | |
| | | /** |
| | | * 查询学员入学时间 根据第一次购买课包的时间 |
| | |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId()); |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - paymentDeductionClassHour.getClassHour()); |
| | | coursePackageOrderStudentService.updateById(coursePackageOrderStudent); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | if(3 >= laveClassHours){ |
| | | AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId()); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", ""); |
| | | } |
| | | //判断剩余课时是否已经全部进行排课,如果排课需要删除已经排好的记录 |
| | | List<CoursePackageScheduling> list1 = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("studentId", coursePackageOrderStudent.getStudentId()).eq("status", 1) |
| | |
| | | } |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours()-coursePackage.getNeedNum()); |
| | | orderStudentService.updateById(coursePackageOrderStudent); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | if(3 >= laveClassHours){ |
| | | AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId()); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", ""); |
| | | } |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(coursePackageOrderStudent.getId()); |
| | | courseCounsum.setChangeType(0); |
| | |
| | | .eq(CoursePackageScheduling::getCoursePackageId, tCoursePackage.getId()) |
| | | .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime()) |
| | | ); |
| | | |
| | | if (list3.isEmpty()) { |
| | | detailsListVo.setType(2); |
| | | objects.add(detailsListVo); |
| | |
| | | objects.add(detailsListVo); |
| | | |
| | | } |
| | | //课程暂停 |
| | | if(tCoursePackage.getState() == 4){ |
| | | detailsListVo.setType(4); |
| | | } |
| | | } |
| | | map.put("data", objects); |
| | | |
| | |
| | | import com.dsh.course.entity.dto.*; |
| | | 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.mapper.CoursePackageSchedulingMapper; |
| | | import com.dsh.course.mapper.CoursePackageStudentMapper; |
| | | import com.dsh.course.model.dto.ToClassDto; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.ALiSendSms; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.UUIDUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | |
| | | @Autowired |
| | |
| | | coursePackageOrderStudent.setAppUserId(null); |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours()-toHoliDto.getClassNum()); |
| | | orderStudentService.updateById(coursePackageOrderStudent); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | if(3 >= laveClassHours){ |
| | | AppUser appUser = appUserClient.queryAppUser(coursePackageOrderStudent.getAppUserId()); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", ""); |
| | | } |
| | | |
| | | //上课星期 |
| | | String classWeeks = coursePackage1.getClassWeeks(); |
| | |
| | | * 定时任务过期清零课时及排课数据 |
| | | */ |
| | | void taskOverdueClearing(); |
| | | |
| | | |
| | | /** |
| | | * 课程开课后检查排课 |
| | | */ |
| | | void startAndScheduleClasses(Integer coursePackageId); |
| | | } |
| | |
| | | @Override |
| | | public void taskCoursePackageScheduling() { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | List<TCoursePackage> list2 = coursePackageService.list(new QueryWrapper<TCoursePackage>().eq("status", 2).eq("auditStatus", 2) |
| | | .eq("state", 1).eq("type", 1)); |
| | | List<Integer> collect = list2.stream().map(TCoursePackage::getId).collect(Collectors.toList()); |
| | | if(collect.size() == 0){ |
| | | return; |
| | | } |
| | | List<CoursePackageOrderStudent> list = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>() |
| | | .eq("status", 1) |
| | | .eq("state", 1) |
| | | .gt("useTime", "now()") |
| | | .gt("laveClassHours", 0) |
| | | .in("coursePackageId", collect) |
| | | ); |
| | | |
| | | List<CoursePackageOrder> list1 = coursePackageOrderService.list(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("payStatus", 2) |
| | | .eq("status", 1) |
| | | .eq("state", 1) |
| | | .gt("laveClassHours", 0) |
| | | .orderByAsc("insertTime") |
| | | ); |
| | | |
| | | for (CoursePackageOrderStudent coursePackageOrderStudent : list) { |
| | | CoursePackageScheduling coursePackageScheduling = this.getOne(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", coursePackageOrderStudent.getAppUserId()) |
| | |
| | | coursePackageOrderStudentService.updateBatchById(list); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程开课后检查排课 |
| | | */ |
| | | @Override |
| | | public void startAndScheduleClasses(Integer coursePackageId) { |
| | | List<CoursePackageOrderStudent> list = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>() |
| | | .eq("status", 1) |
| | | .eq("state", 1) |
| | | .gt("useTime", "now()") |
| | | .gt("laveClassHours", 0) |
| | | .eq("coursePackageId", coursePackageId) |
| | | ); |
| | | |
| | | for (CoursePackageOrderStudent coursePackageOrderStudent : list) { |
| | | CoursePackageScheduling coursePackageScheduling = this.getOne(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", coursePackageOrderStudent.getAppUserId()) |
| | | .eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | | .eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()) |
| | | .eq("status", 1) |
| | | .orderByDesc("classDate") |
| | | .last(" limit 0, 1") |
| | | ); |
| | | //当前时间小于最后一次排课时间则交由定时任务排课 |
| | | if(null != coursePackageScheduling && System.currentTimeMillis() <= coursePackageScheduling.getClassDate().getTime()){ |
| | | continue; |
| | | } |
| | | |
| | | //当前时间大于最后一次排课时间,表明已经断开了定时任务的排课逻辑,需要从第二天手动排课。后续的排课还是让定时任务排课 |
| | | Student student = studentClient.queryStudentById(coursePackageScheduling.getStudentId()); |
| | | Date validity = student.getValidity(); |
| | | TCoursePackage coursePackage = coursePackageService.getById(coursePackageScheduling.getCoursePackageId()); |
| | | //上课星期 |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | List<Integer> week = week(classWeeks); |
| | | //新排课的开始日期 |
| | | Calendar start = Calendar.getInstance(); |
| | | start.setTime(new Date()); |
| | | start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + 1); |
| | | //需要排课的天数 |
| | | int day_week = start.get(Calendar.DAY_OF_WEEK); |
| | | day_week = day_week - 1 == 0 ? 7 : day_week - 1; |
| | | Integer num = 8 - day_week + 7; |
| | | |
| | | String classStartTime = coursePackage.getClassStartTime(); |
| | | String classEndTime = coursePackage.getClassEndTime(); |
| | | String[] split = classStartTime.split(","); |
| | | String[] split1 = classEndTime.split(","); |
| | | //有效期 |
| | | Date useTime = coursePackageOrderStudent.getUseTime(); |
| | | //剩余课时(需要扣除已排课但是还未上课的数据) |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | int count = this.count(new QueryWrapper<CoursePackageScheduling>() |
| | | .eq("appUserId", coursePackageOrderStudent.getAppUserId()) |
| | | .eq("studentId", coursePackageOrderStudent.getStudentId()) |
| | | .eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()) |
| | | .eq("status", 1) |
| | | .eq("type", 1) |
| | | ); |
| | | Integer codeTime = coursePackage.getCodeTime(); |
| | | laveClassHours -= count; |
| | | //剩余数量不足以排课 |
| | | if (laveClassHours.compareTo(codeTime) < 0) { |
| | | break; |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | //生成一周的排课数据 |
| | | for (int i = 0; i < num; i++) { |
| | | String s = sdf.format(start.getTime()); |
| | | |
| | | //判断当天是否在排课星期内 |
| | | int day = start.get(Calendar.DAY_OF_WEEK); |
| | | day = day - 1 == 0 ? 7 : day - 1; |
| | | if (!week.contains(day)) { |
| | | start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + 1); |
| | | continue; |
| | | } |
| | | //大于有效期不进行排课 |
| | | if (start.getTimeInMillis() >= validity.getTime()) { |
| | | break; |
| | | } |
| | | for (int j = 0; j < split.length; j++) { |
| | | //剩余数量不足以排课 |
| | | if (laveClassHours.compareTo(codeTime) < 0) { |
| | | break; |
| | | } |
| | | //减少剩余课时数量 |
| | | laveClassHours -= codeTime; |
| | | //开始组装排课数据 |
| | | CoursePackageScheduling packageScheduling = new CoursePackageScheduling(); |
| | | packageScheduling.setType(1); |
| | | packageScheduling.setAppUserId(coursePackageOrderStudent.getAppUserId()); |
| | | packageScheduling.setStudentId(coursePackageOrderStudent.getStudentId()); |
| | | packageScheduling.setCoursePackageId(coursePackage.getId()); |
| | | try { |
| | | Date parse = format.parse(s + " " + split[j]); |
| | | Date parse1 = format.parse(s + " " + split1[j]); |
| | | packageScheduling.setClassDate(parse); |
| | | packageScheduling.setEndDate(parse1); |
| | | packageScheduling.setStatus(1); |
| | | this.save(packageScheduling); |
| | | |
| | | CoursePackageStudent student1 = new CoursePackageStudent(); |
| | | student1.setAppUserId(coursePackageOrderStudent.getAppUserId()); |
| | | student1.setStudentId(coursePackageOrderStudent.getStudentId()); |
| | | student1.setCoursePackageId(coursePackage.getId()); |
| | | student1.setCoursePackagePaymentId(coursePackageOrderStudent.getId()); |
| | | student1.setCoursePackageSchedulingId(packageScheduling.getId()); |
| | | student1.setSignInOrNot(1); |
| | | student1.setReservationStatus(1); |
| | | student1.setInsertTime(new Date()); |
| | | student1.setType(1); |
| | | coursePackageStudentMapper.insert(student1); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | start.set(Calendar.DAY_OF_YEAR, start.get(Calendar.DAY_OF_YEAR) + 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | private TCoursePackageService coursePackageService; |
| | | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - req.getNum()); |
| | | coursePackageOrderStudentService.updateById(coursePackageOrderStudent); |
| | | Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); |
| | | if(3 >= laveClassHours){ |
| | | AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId()); |
| | | //发送短信提醒 |
| | | aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", ""); |
| | | } |
| | | |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
New file |
| | |
| | | package com.dsh.course.util; |
| | | |
| | | |
| | | import com.aliyuncs.CommonRequest; |
| | | import com.aliyuncs.CommonResponse; |
| | | import com.aliyuncs.DefaultAcsClient; |
| | | import com.aliyuncs.IAcsClient; |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.profile.DefaultProfile; |
| | | import com.google.gson.Gson; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 阿里云短信工具类 |
| | | */ |
| | | @Component |
| | | public class ALiSendSms { |
| | | |
| | | // 设置鉴权参数,初始化客户端 |
| | | private DefaultProfile profile = DefaultProfile.getProfile( |
| | | "cn-hangzhou",// 地域ID |
| | | "LTAI5tSWQMMn9HNU9Zatoe1T",// 您的AccessKey ID |
| | | "kSOsRakIMPbvTlgXU19pYfbwmBXBA4");// 您的AccessKey Secret |
| | | private IAcsClient client = new DefaultAcsClient(profile); |
| | | |
| | | private static void log_print(String functionName, Object result) { |
| | | Gson gson = new Gson(); |
| | | System.out.println("-------------------------------" + functionName + "-------------------------------"); |
| | | System.out.println(gson.toJson(result)); |
| | | } |
| | | |
| | | /** |
| | | * 添加短信模板 |
| | | */ |
| | | public String addSmsTemplate() throws ClientException { |
| | | CommonRequest addSmsTemplateRequest = new CommonRequest(); |
| | | addSmsTemplateRequest.setSysDomain("dysmsapi.aliyuncs.com"); |
| | | addSmsTemplateRequest.setSysAction("AddSmsTemplate"); |
| | | addSmsTemplateRequest.setSysVersion("2017-05-25"); |
| | | // 短信类型。0:验证码;1:短信通知;2:推广短信;3:国际/港澳台消息 |
| | | addSmsTemplateRequest.putQueryParameter("TemplateType", "0"); |
| | | // 模板名称,长度为1~30个字符 |
| | | addSmsTemplateRequest.putQueryParameter("TemplateName", "测试短信模板"); |
| | | // 模板内容,长度为1~500个字符 |
| | | addSmsTemplateRequest.putQueryParameter("TemplateContent", "您正在申请手机注册,验证码为:${code},5分钟内有效!"); |
| | | // 短信模板申请说明 |
| | | addSmsTemplateRequest.putQueryParameter("Remark", "测试"); |
| | | CommonResponse addSmsTemplateResponse = client.getCommonResponse(addSmsTemplateRequest); |
| | | String data = addSmsTemplateResponse.getData(); |
| | | // 消除返回文本中的反转义字符 |
| | | String sData = data.replaceAll("'\'", ""); |
| | | log_print("addSmsTemplate", sData); |
| | | Gson gson = new Gson(); |
| | | // 将字符串转换为Map类型,取TemplateCode字段值 |
| | | Map map = gson.fromJson(sData, Map.class); |
| | | Object templateCode = map.get("TemplateCode"); |
| | | return templateCode.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 发送短信 |
| | | */ |
| | | public String sendSms(String phone, String templateCode, String json) { |
| | | try { |
| | | CommonRequest request = new CommonRequest(); |
| | | request.setSysDomain("dysmsapi.aliyuncs.com"); |
| | | request.setSysVersion("2017-05-25"); |
| | | request.setSysAction("SendSms"); |
| | | // 接收短信的手机号码 |
| | | request.putQueryParameter("PhoneNumbers", phone); |
| | | // 短信签名名称。请在控制台签名管理页面签名名称一列查看(必须是已添加、并通过审核的短信签名)。 |
| | | request.putQueryParameter("SignName", "玩湃"); |
| | | // 短信模板ID |
| | | request.putQueryParameter("TemplateCode", templateCode); |
| | | // 短信模板变量对应的实际值,JSON格式。 |
| | | request.putQueryParameter("TemplateParam", json); |
| | | CommonResponse commonResponse = client.getCommonResponse(request); |
| | | String data = commonResponse.getData(); |
| | | String sData = data.replaceAll("'\'", ""); |
| | | log_print("sendSms", sData); |
| | | return sData; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 查询发送详情 |
| | | */ |
| | | private void querySendDetails(String bizId) throws ClientException { |
| | | CommonRequest request = new CommonRequest(); |
| | | request.setSysDomain("dysmsapi.aliyuncs.com"); |
| | | request.setSysVersion("2017-05-25"); |
| | | request.setSysAction("QuerySendDetails"); |
| | | // 接收短信的手机号码 |
| | | request.putQueryParameter("PhoneNumber", "156xxxxxxxx"); |
| | | // 短信发送日期,支持查询最近30天的记录。格式为yyyyMMdd,例如20191010。 |
| | | request.putQueryParameter("SendDate", "20191010"); |
| | | // 分页记录数量 |
| | | request.putQueryParameter("PageSize", "10"); |
| | | // 分页当前页码 |
| | | request.putQueryParameter("CurrentPage", "1"); |
| | | // 发送回执ID,即发送流水号。 |
| | | request.putQueryParameter("BizId", bizId); |
| | | CommonResponse response = client.getCommonResponse(request); |
| | | log_print("querySendDetails", response.getData()); |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // ALiSendSms sendSmsDemo = new ALiSendSms(); |
| | | // try { |
| | | // // 创建短信模板 |
| | | // String templateCode = sendSmsDemo.addSmsTemplate(); |
| | | // // 使用刚创建的短信模板发送短信 |
| | | // String sData = sendSmsDemo.sendSms("156xxxxxxxx", templateCode, "{\"code\":\"8888\"}"); |
| | | // Gson gson = new Gson(); |
| | | // Map map = gson.fromJson(sData, Map.class); |
| | | // String bizId = map.get("BizId").toString(); |
| | | // // 根据短信发送流水号查询短信发送情况 |
| | | // sendSmsDemo.querySendDetails(bizId); |
| | | // } catch (ClientException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | } |
| | |
| | | import com.dsh.other.feignclient.account.AppUserClient; |
| | | import com.dsh.other.feignclient.account.model.AppUser; |
| | | import com.dsh.other.model.QueryMySiteVo; |
| | | import com.dsh.other.service.ISiteLockService; |
| | | import com.dsh.other.service.TGameConfigService; |
| | | import com.dsh.other.service.TGameRecordService; |
| | | import com.dsh.other.service.TGameService; |
| | | import com.dsh.other.model.User; |
| | | import com.dsh.other.service.*; |
| | | import com.dsh.other.util.*; |
| | | import com.dsh.other.util.httpClinet.HttpResult; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Resource |
| | | private CourseRecordClient courseRecordClient; |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private ISiteBookingService siteBookingService; |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | List<TGame> list = gameService.list(new LambdaQueryWrapper<TGame>().eq(TGame::getSiteId, siteId).eq(TGame::getStoreId, storeId).eq(TGame::getState, 0)); |
| | | if (list.size() > 0) { |
| | | Integer id = list.get(0).getId(); |
| | | // tGameConfigs = gameConfigService.list(new LambdaQueryWrapper<TGameConfig>().eq(TGameConfig::getOtherId, id)); |
| | | tGameConfigs = gameConfigService.listJs(id); |
| | | |
| | | } |
| | | List<TGameConfig> filteredList = tGameConfigs.stream() |
| | | .filter(gameConfig -> !gameConfig.getImg().isEmpty()) |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/gameStartupCheck") |
| | | @ApiOperation(value = "扫码启动游戏前的校验(0=不通过,1=通过)", tags = {"用户—游戏"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "三方游戏id", name = "gameId", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<Integer> gameStartupCheck(Integer gameId){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | //判断当前用户是否是员工 |
| | | AppUser appUser1 = appUserClient.queryAppUser(uid); |
| | | User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); |
| | | if (null != one) { |
| | | return ResultUtil.success(1); |
| | | } |
| | | //普通用户校验当前时间是否在预约时间段内 |
| | | TGame game = gameService.getById(gameId); |
| | | Integer siteId = game.getSiteId(); |
| | | SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>() |
| | | .eq("state", 1) |
| | | .in("status", Arrays.asList(1, 2)) |
| | | .eq("appUserId", uid) |
| | | .eq("siteId", siteId) |
| | | .last(" and now() between startTime and endTime") |
| | | ); |
| | | return ResultUtil.success(null == siteBooking ? 0 : 1); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | if (null == uid) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | //判断当前用户是否是员工 |
| | | AppUser appUser1 = appUserClient.queryAppUser(uid); |
| | | User one = userService.getOne(new QueryWrapper<User>().eq("phone", appUser1.getPhone()).eq("status", 1)); |
| | | if (null != one) { |
| | | Integer integer = startGame(uid, gameId, spaceId, sutuId); |
| | | return ResultUtil.success(); |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | TGameConfig config = gameConfigService.getById(configId); |
| | |
| | | tGameRecord.setNumber(code); |
| | | tGameRecord.setTime(new Date()); |
| | | gameRecordService.save(tGameRecord); |
| | | |
| | | if (type == 1) { |
| | | ResultUtil weixinpay = payMoneyUtil.weixinpay("游戏支付", "", code, config.getCash().toString(), "/base/course/weChatPaymentCourseCallback", "APP", ""); |
| | | if (weixinpay.getCode() == 200) { |
| | |
| | | } |
| | | return weixinpay; |
| | | } else if (type == 2) { |
| | | // Integer gameId, Integer configId,Integer type,Integer sutuId,Integer spaceId; |
| | | |
| | | String params = uid + "_" + gameId + "_" + spaceId + "_" + sutuId+"_"+code+"_"+configId; |
| | | |
| | | ResultUtil alipay = payMoneyUtil.alipay("游戏支付", "游戏支付", params, code, config.getCash().toString(), "/base/site/gameCallback"); |
| | | if (alipay.getCode() == 200) { |
| | | new Thread(new Runnable() { |
| | |
| | | * TRADE_SUCCESS(交易支付成功)、 |
| | | * TRADE_FINISHED(交易结束,不可退款) |
| | | */ |
| | | // Map<String, String> data1 = resultUtil.getData(); |
| | | // String s = data1.get("tradeStatus"); |
| | | // String tradeNo = data1.get("tradeNo"); |
| | | String tradeNo = resultUtil.getTradeNo(); |
| | | String s = resultUtil.getTradeStatus(); |
| | | if ("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10) { |
| | |
| | | coursePackagePayment.setOrderNo(tradeNo); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | // courseCounsum.setPaymentId(paymentId); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("智慧球场;" + config.getCash()); |
| | |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | String code = map.get("passback_params"); |
| | | String trade_no = map.get("trade_no"); |
| | | // SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1)); |
| | | // if(siteBooking.getStatus() == 0){ |
| | | // siteBooking.setPayTime(new Date()); |
| | | // siteBooking.setStatus(1); |
| | | // siteBooking.setPayOrderNo(trade_no); |
| | | // siteBookingService.updateById(siteBooking); |
| | | // } |
| | | |
| | | String[] s = code.split("_"); |
| | | Integer i = startGame(Integer.valueOf(s[0]), Integer.valueOf(s[1]), Integer.valueOf(s[2]), Integer.valueOf(s[3])); |
| | | List<TGameRecord> list = gameRecordService.list(new QueryWrapper<TGameRecord>().eq("number", s[4]).eq("payType", 2)); |
| | |
| | | coursePackagePayment.setOrderNo(trade_no); |
| | | |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | // courseCounsum.setPaymentId(paymentId); |
| | | courseCounsum.setChangeType(3); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("智慧球场;" + config.getCash()); |
| | | courseCounsum.setAppUserId(Integer.valueOf(s[0])); |
| | | courseRecordClient.save(courseCounsum); |
| | | |
| | | } |
| | | gameRecordService.updateBatchById(list); |
| | | |
| | | |
| | | |
| | | |
| | | System.err.println("===========游戏回调游戏回调=========" + i); |
| | | PrintWriter out = response.getWriter(); |
| | |
| | | import com.dsh.other.util.GeodesyUtil; |
| | | import com.dsh.other.util.ResultUtil; |
| | | import com.dsh.other.util.ToolUtil; |
| | | import com.sun.javafx.binding.StringFormatter; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | if (citycodeResp.getCityCode() == null) { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(citycodeResp.getLongitude(), citycodeResp.getLatitude()); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | if(null != geocode){ |
| | | String cityCode = geocode.get("cityCode"); |
| | | citycodeResp.setCityCode(cityCode); |
| | | } |
| | | } |
| | | |
| | | List<Store> list = storeService.list(new QueryWrapper<Store>() |
| | | .eq("state", 1) |
| | | .eq("cityCode", citycodeResp.getCityCode())); |
| | | if (list.size() > 0) { |
| | | // if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){ |
| | | // return detailLists; |
| | | // } |
| | | for (Store store : list) { |
| | | String current = citycodeResp.getLongitude() + "," + citycodeResp.getLatitude(); |
| | | String result = store.getLon() + "," + store.getLat(); |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | // long l = Long.parseLong(distanceTOKilometer); |
| | | //// 取5公里范围内的门店 |
| | | // if ( l > 5){ |
| | | // continue; |
| | | // } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(current, result); |
| | | StoreDetailList detailList = new StoreDetailList(); |
| | | detailList.setStoreId(store.getId()); |
| | | detailList.setStoreImg(store.getCoverDrawing()); |
| | | detailList.setStoreName(store.getName()); |
| | | detailList.setStoreAddress(store.getAddress()); |
| | | detailList.setStorePhone(store.getPhone()); |
| | | // detailList.setStoreDistance(l); |
| | | detailList.setStoreTime(store.getStartTime() + "-" + store.getEndTime()); |
| | | detailList.setStoreInfo(store.getIntroduce()); |
| | | detailList.setStoreDistance(Double.valueOf(distanceTOKilometer)); |
| | | detailList.setStoreDistance(null != distance ? Double.valueOf(String.format("%.2f", distance.get("WGS84") / 1000)) : 0D); |
| | | detailLists.add(detailList); |
| | | } |
| | | } |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "门店id", name = "id", dataType = "int", required = true), |
| | | }) |
| | | public ResultUtil<List<TStoreOtherConfigTrue>> queryIndexSet(Integer id) { |
| | | public ResultUtil<List<TStoreOtherVo>> queryIndexSet(Integer id) { |
| | | try { |
| | | List<TStoreOtherConfigTrue> tStoreOtherConfigTrues = new ArrayList<>(); |
| | | |
| | |
| | | if (list.size() > 0) { |
| | | tStoreOtherConfigTrues = tStoreOtherConfigTrueService.list(new LambdaQueryWrapper<TStoreOtherConfigTrue>().in(TStoreOtherConfigTrue::getPid, list.stream().map(TStoreOther::getId).collect(Collectors.toList())).eq(TStoreOtherConfigTrue::getState, 1)); |
| | | } |
| | | for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) { |
| | | List<TStoreOtherVo> list1 = new ArrayList<>(); |
| | | for (TStoreOther tStoreOther : list) { |
| | | TStoreOtherVo storeOtherVo = new TStoreOtherVo(); |
| | | BeanUtils.copyProperties(tStoreOther, storeOtherVo); |
| | | List<TStoreOtherConfigTrue> lists = new ArrayList<>(); |
| | | for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) { |
| | | if (tStoreOtherConfigTrue.getPid() == tStoreOther.getId()) { |
| | | tStoreOtherConfigTrue.setSort(tStoreOther.getSort()); |
| | | lists.add(tStoreOtherConfigTrue); |
| | | } |
| | | } |
| | | storeOtherVo.setList(lists); |
| | | list1.add(storeOtherVo); |
| | | } |
| | | return ResultUtil.success(tStoreOtherConfigTrues); |
| | | return ResultUtil.success(list1); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
New file |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.model.User; |
| | | import com.dsh.other.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2023/12/14 16:25 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class UserController { |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | |
| | | |
| | | @PostMapping("/user/getUserByPhone") |
| | | public User getUserByPhone(@RequestBody String phone){ |
| | | return userService.getOne(new QueryWrapper<User>().eq("phone", phone).eq("status", 1)); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | import com.dsh.other.entity.TStoreOtherConfigTrue; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2023/12/15 18:32 |
| | | */ |
| | | @Data |
| | | public class TStoreOtherVo { |
| | | private Integer id; |
| | | |
| | | private String name; |
| | | |
| | | private Integer storeId; |
| | | |
| | | private Integer sort; |
| | | /** |
| | | * 1开启 2关闭 |
| | | */ |
| | | private Integer state; |
| | | |
| | | private List<TStoreOtherConfigTrue> list; |
| | | } |
| | |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | if("[]".equals(code)){ |
| | | System.err.println("经纬度转行政区划代码失败[" + lon + "," + lan + "]"); |
| | | return null; |
| | | } |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | | map.put("city", city); |