新增服务器时间访问接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.gxwebsoft.booking.controller;
|
package com.gxwebsoft.booking.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
import com.gxwebsoft.booking.service.PeriodService;
|
import com.gxwebsoft.booking.service.PeriodService;
|
||||||
import com.gxwebsoft.booking.entity.Period;
|
import com.gxwebsoft.booking.entity.Period;
|
||||||
@@ -41,7 +42,13 @@ public class PeriodController extends BaseController {
|
|||||||
@ApiOperation("查询全部场地时段")
|
@ApiOperation("查询全部场地时段")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public ApiResult<List<Period>> list(PeriodParam param) {
|
public ApiResult<List<Period>> list(PeriodParam param) {
|
||||||
// 使用关联查询
|
// 采用服务器时间
|
||||||
|
if (param.getStartTime() != null) {
|
||||||
|
final int hour = DateUtil.hour(DateUtil.date(), true);
|
||||||
|
final int minute = DateUtil.minute(DateUtil.date());
|
||||||
|
final String startTime = String.format("%02d", hour).concat(String.format("%02d", minute));
|
||||||
|
param.setStartTime(startTime);
|
||||||
|
}
|
||||||
return success(periodService.listRel(param));
|
return success(periodService.listRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
AND a.is_free = #{param.isFree}
|
AND a.is_free = #{param.isFree}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.startTime != null">
|
<if test="param.startTime != null">
|
||||||
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
|
AND a.start_time >= #{param.startTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.comments != null">
|
<if test="param.comments != null">
|
||||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||||
|
|||||||
@@ -31,23 +31,23 @@ public class FieldParam extends BaseParam {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "是否有卫生间,1有,2没有")
|
@ApiModelProperty(value = "是否有卫生间,1有,2没有")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean isToilet;
|
private Integer isToilet;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否关闭,1开启,2关闭")
|
@ApiModelProperty(value = "是否关闭,1开启,2关闭")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean isStatus;
|
private Integer isStatus;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否重复预订,1可以,2不可以")
|
@ApiModelProperty(value = "是否重复预订,1可以,2不可以")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean isRepeat;
|
private Integer isRepeat;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否可预定半场,1可以,2不可以")
|
@ApiModelProperty(value = "是否可预定半场,1可以,2不可以")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean isHalf;
|
private Integer isHalf;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否支持儿童价:1支持,2不支持")
|
@ApiModelProperty(value = "是否支持儿童价:1支持,2不支持")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean isChildren;
|
private Integer isChildren;
|
||||||
|
|
||||||
@ApiModelProperty(value = "可重复预订次数")
|
@ApiModelProperty(value = "可重复预订次数")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
@@ -55,7 +55,7 @@ public class FieldParam extends BaseParam {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "显示在第几行")
|
@ApiModelProperty(value = "显示在第几行")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Boolean row;
|
private Integer row;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商户ID")
|
@ApiModelProperty(value = "商户ID")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gxwebsoft.cms.controller;
|
package com.gxwebsoft.cms.controller;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
@@ -23,14 +24,21 @@ import com.gxwebsoft.shop.service.MerchantAccountService;
|
|||||||
import com.gxwebsoft.shop.service.MerchantService;
|
import com.gxwebsoft.shop.service.MerchantService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.text.DateFormat;
|
||||||
import java.util.List;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网站信息记录表控制器
|
* 网站信息记录表控制器
|
||||||
@@ -77,7 +85,9 @@ public class WebsiteController extends BaseController {
|
|||||||
final String siteInfo = redisUtil.get(key);
|
final String siteInfo = redisUtil.get(key);
|
||||||
String access_token = JwtUtil.getAccessToken(request);
|
String access_token = JwtUtil.getAccessToken(request);
|
||||||
System.out.println("access_token = " + access_token);
|
System.out.println("access_token = " + access_token);
|
||||||
|
redisUtil.set("Domain:ffai.cn",10157);
|
||||||
|
redisUtil.set("Domain:www.xn--15qx69a6lbn8t0tlmve.com",10157);
|
||||||
|
redisUtil.set("Domain:xn--15qx69a6lbn8t0tlmve.com",10157);
|
||||||
// 从缓存读取信息
|
// 从缓存读取信息
|
||||||
if(StrUtil.isNotBlank(siteInfo)){
|
if(StrUtil.isNotBlank(siteInfo)){
|
||||||
return success(JSONObject.parseObject(siteInfo,Website.class));
|
return success(JSONObject.parseObject(siteInfo,Website.class));
|
||||||
@@ -257,7 +267,6 @@ public class WebsiteController extends BaseController {
|
|||||||
website.setUserInfo(user);
|
website.setUserInfo(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 授权信息
|
// 授权信息
|
||||||
HashMap<String, Object> config = new HashMap<>();
|
HashMap<String, Object> config = new HashMap<>();
|
||||||
config.put("LICENSE_CODE", "");
|
config.put("LICENSE_CODE", "");
|
||||||
@@ -289,6 +298,68 @@ public class WebsiteController extends BaseController {
|
|||||||
return success(website);
|
return success(website);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取服务器时间")
|
||||||
|
@GetMapping("/getServerTime")
|
||||||
|
public ApiResult<?> getServerTime(){
|
||||||
|
// 服务器时间
|
||||||
|
final ServerTimeVO vo = new ServerTimeVO();
|
||||||
|
final int hour = DateUtil.hour(DateUtil.date(), true);
|
||||||
|
final int minute = DateUtil.minute(DateUtil.date());
|
||||||
|
vo.setDate(DateUtil.date());
|
||||||
|
vo.setToday(DateUtil.today());
|
||||||
|
vo.setHour(hour);
|
||||||
|
vo.setMinute(minute);
|
||||||
|
vo.setHourMinute(String.format("%02d", hour).concat(String.format("%02d", minute)));
|
||||||
|
final int compare = Integer.compare(Integer.valueOf(vo.getHourMinute()), 900);
|
||||||
|
vo.setIsAfter(compare);
|
||||||
|
// vo.setHourMinute(String.valueOf(hour).concat(String.valueOf(minute)));
|
||||||
|
System.out.println("hour = " + hour);
|
||||||
|
// DateUtil.between(DateUtil.date(), , DateUnit.DAY);
|
||||||
|
|
||||||
|
// HashMap<String, Object> serverTime = new HashMap<>();
|
||||||
|
// // 今天日期
|
||||||
|
// DateTime date = DateUtil.date();
|
||||||
|
// String today= DateUtil.today();
|
||||||
|
// // 明天日期
|
||||||
|
// final DateTime dateTime = DateUtil.tomorrow();
|
||||||
|
// String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd");
|
||||||
|
// // 后天日期
|
||||||
|
// final DateTime dateTime2 = DateUtil.offsetDay(date, 2);
|
||||||
|
// final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd");
|
||||||
|
// // 今天星期几
|
||||||
|
// final int week = DateUtil.thisDayOfWeek();
|
||||||
|
// final DateTime nextWeek = DateUtil.nextWeek();
|
||||||
|
// serverTime.put("now",DateUtil.now());
|
||||||
|
// serverTime.put("today",today);
|
||||||
|
// serverTime.put("tomorrow",tomorrow);
|
||||||
|
// serverTime.put("afterDay",afterDay);
|
||||||
|
// serverTime.put("week",week);
|
||||||
|
// serverTime.put("nextWeek",nextWeek);
|
||||||
|
return success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取未来一周的日期")
|
||||||
|
@GetMapping("/getNext7day")
|
||||||
|
public ApiResult<?> getNext7day(){
|
||||||
|
List<Next7dayVO> dateList = new ArrayList<>();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd");
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
Date date = DateUtils.addDays(new Date(), +i);
|
||||||
|
String formatDate = sdf.format(date);
|
||||||
|
String dateTime = sdf2.format(date);
|
||||||
|
final Next7dayVO vo = new Next7dayVO();
|
||||||
|
vo.setDate(dateTime);
|
||||||
|
vo.setDateTime(formatDate);
|
||||||
|
final DateTime parse = DateUtil.parse(formatDate);
|
||||||
|
int dayOfWeek = DateUtil.dayOfWeek(parse);
|
||||||
|
vo.setWeek(dayOfWeek - 1);
|
||||||
|
dateList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(dateList);
|
||||||
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('cms:website:remove')")
|
@PreAuthorize("hasAuthority('cms:website:remove')")
|
||||||
@ApiOperation("清除缓存")
|
@ApiOperation("清除缓存")
|
||||||
@DeleteMapping("/clearSiteInfo/{key}")
|
@DeleteMapping("/clearSiteInfo/{key}")
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.gxwebsoft.cms.entity;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未来7天
|
||||||
|
*
|
||||||
|
* @author 科技小王子
|
||||||
|
* @since 2024-05-02 12:22:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value = "未来7天", description = "未来7天")
|
||||||
|
public class Next7dayVO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "星期")
|
||||||
|
private Integer week;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "日期(月日)")
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "日期(年月日)")
|
||||||
|
private String dateTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.gxwebsoft.cms.entity;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器时间
|
||||||
|
*
|
||||||
|
* @author 科技小王子
|
||||||
|
* @since 2024-05-02 12:22:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiModel(value = "服务器时间", description = "服务器当前时间及日期")
|
||||||
|
public class ServerTimeVO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "今天日期")
|
||||||
|
private String today;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "今天是周几")
|
||||||
|
private DateTime date;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "当前时间(时)")
|
||||||
|
private Integer hour;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "当前时间(分)")
|
||||||
|
private Integer minute;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "当期时间(时分)")
|
||||||
|
private String hourMinute;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否已过时间")
|
||||||
|
private Integer isAfter;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.gxwebsoft.shop.controller;
|
package com.gxwebsoft.shop.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
|
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||||
|
import com.gxwebsoft.shop.service.OrderInfoService;
|
||||||
import com.gxwebsoft.shop.service.OrderService;
|
import com.gxwebsoft.shop.service.OrderService;
|
||||||
import com.gxwebsoft.shop.entity.Order;
|
import com.gxwebsoft.shop.entity.Order;
|
||||||
import com.gxwebsoft.shop.param.OrderParam;
|
import com.gxwebsoft.shop.param.OrderParam;
|
||||||
@@ -10,12 +16,21 @@ import com.gxwebsoft.common.core.web.PageParam;
|
|||||||
import com.gxwebsoft.common.core.web.BatchParam;
|
import com.gxwebsoft.common.core.web.BatchParam;
|
||||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
|
import com.wechat.pay.java.core.Config;
|
||||||
|
import com.wechat.pay.java.core.RSAConfig;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,89 +43,110 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/shop/order")
|
@RequestMapping("/api/shop/order")
|
||||||
public class OrderController extends BaseController {
|
public class OrderController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
@Resource
|
||||||
|
private OrderInfoService orderInfoService;
|
||||||
|
|
||||||
@ApiOperation("分页查询预约订单")
|
@ApiOperation("分页查询预约订单")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public ApiResult<PageResult<Order>> page(OrderParam param) {
|
public ApiResult<PageResult<Order>> page(OrderParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(orderService.pageRel(param));
|
return success(orderService.pageRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||||
@ApiOperation("查询全部预约订单")
|
@ApiOperation("查询全部预约订单")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public ApiResult<List<Order>> list(OrderParam param) {
|
public ApiResult<List<Order>> list(OrderParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(orderService.listRel(param));
|
return success(orderService.listRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||||
@ApiOperation("根据id查询预约订单")
|
@ApiOperation("根据id查询预约订单")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(orderService.getByIdRel(id));
|
return success(orderService.getByIdRel(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("添加预约订单")
|
@ApiOperation("添加预约订单")
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public ApiResult<?> save(@RequestBody Order order) {
|
public ApiResult<?> save(@RequestBody Order order) {
|
||||||
// 记录当前登录用户id
|
// 记录当前登录用户id
|
||||||
// User loginUser = getLoginUser();
|
User loginUser = getLoginUser();
|
||||||
// if (loginUser != null) {
|
long timeMillis = System.currentTimeMillis();
|
||||||
// order.setUserId(loginUser.getUserId());
|
long orderNo = IdUtil.getSnowflakeNextId();
|
||||||
// }
|
if (loginUser != null) {
|
||||||
if (orderService.save(order)) {
|
order.setUserId(loginUser.getUserId());
|
||||||
return success("添加成功");
|
order.setOpenid(loginUser.getOpenid());
|
||||||
}
|
|
||||||
return fail("添加失败");
|
|
||||||
}
|
}
|
||||||
|
order.setOrderNo(Long.toString(orderNo));
|
||||||
|
order.setName(loginUser.getRealName());
|
||||||
|
order.setStartTime(timeMillis / 1000);
|
||||||
|
order.setAddTime(timeMillis / 1000);
|
||||||
|
order.setPhone(loginUser.getPhone());
|
||||||
|
order.setVersion(10);
|
||||||
|
if (orderService.save(order)) {
|
||||||
|
order.getOrderInfoList().forEach(d -> {
|
||||||
|
d.setOid(order.getOrderId());
|
||||||
|
d.setTimeFlag(timeMillis);
|
||||||
|
d.setVersion(10);
|
||||||
|
d.setOrderTime(timeMillis / 1000);
|
||||||
|
});
|
||||||
|
orderInfoService.saveBatch(order.getOrderInfoList());
|
||||||
|
// 创建微信订单
|
||||||
|
if (order.getPayType().equals(1)) {
|
||||||
|
return success("下单成功",orderService.createWxOrder(order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fail("下单失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("修改预约订单")
|
@ApiOperation("修改预约订单")
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public ApiResult<?> update(@RequestBody Order order) {
|
public ApiResult<?> update(@RequestBody Order order) {
|
||||||
if (orderService.updateById(order)) {
|
if (orderService.updateById(order)) {
|
||||||
return success("修改成功");
|
return success("修改成功");
|
||||||
}
|
|
||||||
return fail("修改失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("删除预约订单")
|
@ApiOperation("删除预约订单")
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||||
if (orderService.removeById(id)) {
|
if (orderService.removeById(id)) {
|
||||||
return success("删除成功");
|
return success("删除成功");
|
||||||
}
|
|
||||||
return fail("删除失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量添加预约订单")
|
@ApiOperation("批量添加预约订单")
|
||||||
@PostMapping("/batch")
|
@PostMapping("/batch")
|
||||||
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
||||||
if (orderService.saveBatch(list)) {
|
if (orderService.saveBatch(list)) {
|
||||||
return success("添加成功");
|
return success("添加成功");
|
||||||
}
|
|
||||||
return fail("添加失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量修改预约订单")
|
@ApiOperation("批量修改预约订单")
|
||||||
@PutMapping("/batch")
|
@PutMapping("/batch")
|
||||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||||
if (batchParam.update(orderService, "order_id")) {
|
if (batchParam.update(orderService, "order_id")) {
|
||||||
return success("修改成功");
|
return success("修改成功");
|
||||||
}
|
|
||||||
return fail("修改失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("批量删除预约订单")
|
@ApiOperation("批量删除预约订单")
|
||||||
@DeleteMapping("/batch")
|
@DeleteMapping("/batch")
|
||||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||||
if (orderService.removeByIds(ids)) {
|
if (orderService.removeByIds(ids)) {
|
||||||
return success("删除成功");
|
return success("删除成功");
|
||||||
}
|
|
||||||
return fail("删除失败");
|
|
||||||
}
|
}
|
||||||
|
return fail("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
|
|||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@@ -114,13 +115,13 @@ public class Order implements Serializable {
|
|||||||
private BigDecimal returnMoney;
|
private BigDecimal returnMoney;
|
||||||
|
|
||||||
@ApiModelProperty(value = "预约详情开始时间数组")
|
@ApiModelProperty(value = "预约详情开始时间数组")
|
||||||
private String startTime;
|
private Long startTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票,3不能开具发票")
|
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票,3不能开具发票")
|
||||||
private Integer isInvoice;
|
private Integer isInvoice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "下单时间")
|
@ApiModelProperty(value = "下单时间")
|
||||||
private Integer createTime;
|
private Long addTime;
|
||||||
|
|
||||||
private Integer updateTime;
|
private Integer updateTime;
|
||||||
|
|
||||||
@@ -136,6 +137,9 @@ public class Order implements Serializable {
|
|||||||
@ApiModelProperty(value = "对账情况:1=已对账;2=未对账;3=已对账,金额对不上;4=未查询到该订单")
|
@ApiModelProperty(value = "对账情况:1=已对账;2=未对账;3=已对账,金额对不上;4=未查询到该订单")
|
||||||
private Integer checkBill;
|
private Integer checkBill;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "系统版本")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
@@ -143,6 +147,9 @@ public class Order implements Serializable {
|
|||||||
@TableLogic
|
@TableLogic
|
||||||
private Integer deleted;
|
private Integer deleted;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "租户id")
|
@ApiModelProperty(value = "租户id")
|
||||||
private Integer tenantId;
|
private Integer tenantId;
|
||||||
|
|
||||||
@@ -154,6 +161,10 @@ public class Order implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String merchantAvatar;
|
private String merchantAvatar;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "微信OPENID,用于微信支付")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String openid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "订单详情")
|
@ApiModelProperty(value = "订单详情")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<OrderInfo> orderInfoList;
|
private List<OrderInfo> orderInfoList;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-05-03 11:14:47
|
* @since 2024-05-03 11:14:47
|
||||||
@@ -72,14 +72,17 @@ public class OrderInfo implements Serializable {
|
|||||||
private String mergeData;
|
private String mergeData;
|
||||||
|
|
||||||
@ApiModelProperty(value = "开场时间")
|
@ApiModelProperty(value = "开场时间")
|
||||||
private Integer startTime;
|
private Long startTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "下单时间")
|
@ApiModelProperty(value = "下单时间")
|
||||||
private Integer orderTime;
|
private Long orderTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "毫秒时间戳")
|
@ApiModelProperty(value = "毫秒时间戳")
|
||||||
private Long timeFlag;
|
private Long timeFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "系统版本")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
@ApiModelProperty(value = "租户id")
|
@ApiModelProperty(value = "租户id")
|
||||||
private Integer tenantId;
|
private Integer tenantId;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.gxwebsoft.common.core.web.PageResult;
|
|||||||
import com.gxwebsoft.shop.entity.Order;
|
import com.gxwebsoft.shop.entity.Order;
|
||||||
import com.gxwebsoft.shop.param.OrderParam;
|
import com.gxwebsoft.shop.param.OrderParam;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,4 +40,5 @@ public interface OrderService extends IService<Order> {
|
|||||||
*/
|
*/
|
||||||
Order getByIdRel(Integer orderId);
|
Order getByIdRel(Integer orderId);
|
||||||
|
|
||||||
|
HashMap<String, String> createWxOrder(Order order);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.gxwebsoft.shop.service.impl;
|
package com.gxwebsoft.shop.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||||
|
import com.gxwebsoft.common.system.service.SettingService;
|
||||||
import com.gxwebsoft.shop.entity.OrderInfo;
|
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||||
import com.gxwebsoft.shop.mapper.OrderMapper;
|
import com.gxwebsoft.shop.mapper.OrderMapper;
|
||||||
import com.gxwebsoft.shop.param.OrderInfoParam;
|
import com.gxwebsoft.shop.param.OrderInfoParam;
|
||||||
@@ -11,10 +14,19 @@ import com.gxwebsoft.shop.entity.Order;
|
|||||||
import com.gxwebsoft.shop.param.OrderParam;
|
import com.gxwebsoft.shop.param.OrderParam;
|
||||||
import com.gxwebsoft.common.core.web.PageParam;
|
import com.gxwebsoft.common.core.web.PageParam;
|
||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
|
import com.wechat.pay.java.core.Config;
|
||||||
|
import com.wechat.pay.java.core.RSAConfig;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,43 +43,119 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OrderInfoService orderInfoService;
|
private OrderInfoService orderInfoService;
|
||||||
|
@Resource
|
||||||
|
private ConfigProperties config;
|
||||||
|
@Resource
|
||||||
|
private SettingService settingService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<Order> pageRel(OrderParam param) {
|
public PageResult<Order> pageRel(OrderParam param) {
|
||||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||||
List<Order> list = baseMapper.selectPageRel(page, param);
|
List<Order> list = baseMapper.selectPageRel(page, param);
|
||||||
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||||
// 查询订单信息表
|
// 查询订单信息表
|
||||||
if (!CollectionUtils.isEmpty(orderIds)) {
|
if (!CollectionUtils.isEmpty(orderIds)) {
|
||||||
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOid, orderIds));
|
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOid, orderIds));
|
||||||
final Map<Integer, List<OrderInfo>> orderInfo = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOid));
|
final Map<Integer, List<OrderInfo>> orderInfo = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOid));
|
||||||
list.forEach(d -> {
|
list.forEach(d -> {
|
||||||
if (!orderInfo.isEmpty()) {
|
if (!orderInfo.isEmpty()) {
|
||||||
final List<OrderInfo> orderInfos = orderInfo.get(d.getOrderId());
|
final List<OrderInfo> orderInfos = orderInfo.get(d.getOrderId());
|
||||||
if (!orderInfos.isEmpty()) {
|
if (!CollectionUtils.isEmpty(orderInfos)) {
|
||||||
d.setOrderInfoList(orderInfos);
|
d.setOrderInfoList(orderInfos);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return new PageResult<>(list, page.getTotal());
|
});
|
||||||
}
|
}
|
||||||
|
return new PageResult<>(list, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Order> listRel(OrderParam param) {
|
public List<Order> listRel(OrderParam param) {
|
||||||
List<Order> list = baseMapper.selectListRel(param);
|
List<Order> list = baseMapper.selectListRel(param);
|
||||||
// 排序
|
// 排序
|
||||||
PageParam<Order, OrderParam> page = new PageParam<>();
|
PageParam<Order, OrderParam> page = new PageParam<>();
|
||||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||||
return page.sortRecords(list);
|
return page.sortRecords(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getByIdRel(Integer orderId) {
|
public Order getByIdRel(Integer orderId) {
|
||||||
OrderParam param = new OrderParam();
|
OrderParam param = new OrderParam();
|
||||||
param.setOrderId(orderId);
|
param.setOrderId(orderId);
|
||||||
return param.getOne(baseMapper.selectListRel(param));
|
return param.getOne(baseMapper.selectListRel(param));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建微信支付
|
||||||
|
* @param order
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> createWxOrder(Order order) {
|
||||||
|
final String uploadPath = config.getUploadPath(); // 服务器本地路径
|
||||||
|
final HashMap<String, String> orderInfo = new HashMap<>();
|
||||||
|
// 微信小程序(微信支付)
|
||||||
|
final JSONObject mpWx = settingService.getBySettingKey("mp-weixin");
|
||||||
|
final JSONObject payment = settingService.getBySettingKey("payment");
|
||||||
|
|
||||||
|
// 计算金额
|
||||||
|
BigDecimal decimal = order.getTotalPrice();
|
||||||
|
final BigDecimal multiply = decimal.multiply(new BigDecimal(100));
|
||||||
|
// 将 BigDecimal 转换为 Integer
|
||||||
|
Integer money = multiply.intValue();
|
||||||
|
|
||||||
|
final String appId = mpWx.getString("appId");
|
||||||
|
final String mchId = payment.getString("mchId");
|
||||||
|
final String openid = order.getOpenid(); // openid
|
||||||
|
final String notifyUrl = config.getServerUrl() + "/love/user-plan-log/wx-pay/notify/" + order.getTenantId(); // 异步通知地址
|
||||||
|
final String privateKey = uploadPath.concat("file").concat(payment.getString("apiclientKey")); // 秘钥证书
|
||||||
|
final String apiclientCert = uploadPath.concat("file").concat(payment.getString("apiclientCert"));
|
||||||
|
final String merchantSerialNumber = payment.getString("merchantSerialNumber"); // 证书序列号
|
||||||
|
final String apiV3key = payment.getString("wechatApiKey");
|
||||||
|
|
||||||
|
System.out.println("privateKey = " + privateKey);
|
||||||
|
System.out.println("apiclientCert = " + apiclientCert);
|
||||||
|
System.out.println("merchantSerialNumber = " + merchantSerialNumber);
|
||||||
|
System.out.println("apiV3key = " + apiV3key);
|
||||||
|
System.out.println("mchId = " + mchId);
|
||||||
|
System.out.println("appId = " + appId);
|
||||||
|
|
||||||
|
Config config =
|
||||||
|
new RSAConfig.Builder()
|
||||||
|
.merchantId(mchId)
|
||||||
|
.privateKeyFromPath(privateKey)
|
||||||
|
.merchantSerialNumber(merchantSerialNumber)
|
||||||
|
.wechatPayCertificatesFromPath(apiclientCert)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 构建service
|
||||||
|
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build();
|
||||||
|
// 跟之前下单示例一样,填充预下单参数
|
||||||
|
PrepayRequest request = new PrepayRequest();
|
||||||
|
Amount amount = new Amount();
|
||||||
|
amount.setTotal(money);
|
||||||
|
amount.setCurrency("CNY");
|
||||||
|
request.setAmount(amount);
|
||||||
|
request.setAppid(appId);
|
||||||
|
request.setMchid(mchId);
|
||||||
|
request.setDescription(order.getComments());
|
||||||
|
request.setNotifyUrl(notifyUrl);
|
||||||
|
request.setOutTradeNo(order.getOrderNo());
|
||||||
|
request.setAttach(order.getTenantId().toString());
|
||||||
|
final Payer payer = new Payer();
|
||||||
|
payer.setOpenid(openid);
|
||||||
|
request.setPayer(payer);
|
||||||
|
|
||||||
|
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
||||||
|
System.out.println("response = " + response);
|
||||||
|
orderInfo.put("provider", "wxpay");
|
||||||
|
orderInfo.put("timeStamp", response.getTimeStamp());
|
||||||
|
orderInfo.put("nonceStr", response.getNonceStr());
|
||||||
|
orderInfo.put("package", response.getPackageVal());
|
||||||
|
orderInfo.put("signType", "RSA");
|
||||||
|
orderInfo.put("paySign", response.getPaySign());
|
||||||
|
return orderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user