app后台----下订单--完成.

app后台----支付回调--初步完成.
This commit is contained in:
haotianmingyue 2024-12-24 10:38:17 +08:00
parent 183be624de
commit ed2c6dfc30
14 changed files with 222 additions and 128 deletions

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.app;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils;
@ -43,6 +44,7 @@ import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -884,6 +886,7 @@ public class AppSystemController {
}
// 发布用户作品-------新版
// 由于APP前端不支持预订时间-----startTime一定是从明天开始
@Transactional
@PostMapping("/publishUserWorkNew")
public AjaxResult publishUserWorkNew(@RequestBody List<PublishUserWorkDto> publishUserWorkDtoList)
@ -897,6 +900,8 @@ public class AppSystemController {
// 订单信息缓存
List<OrderCacheVo> orderCacheVoList = new ArrayList<>();
LocalDate tomorrow = LocalDate.now().plusDays(1);
// 获取订单数据
@ -917,6 +922,12 @@ public class AppSystemController {
LocalDate startTime = publishUserWorkDto.getStartTime();
if(!startTime.isEqual(tomorrow)){
return error("非法时间, 以记录ip");
}
LocalDate endTime = startTime;
// 根据资源位查看价格和时间
@ -1017,6 +1028,7 @@ public class AppSystemController {
orderCacheVo.setSourceId(sourceId);
orderCacheVo.setStartTime(startTime);
orderCacheVo.setUserId(userId);
orderCacheVo.setWorkId(workId);
orderCacheVo.setWay("微信支付");
orderCacheVoList.add(orderCacheVo);
@ -1049,6 +1061,42 @@ public class AppSystemController {
return AjaxResult.success(mchOrderNo);
}
// 获取系统资源位列表, 附带搜索功能
@GetMapping("/getAllSource")
public AjaxResult getAllSource(SysSource sysSource) {
List<SourceListDto> sysSourceList = sysSourceService.getSysSourceList(sysSource);
for(SourceListDto sourceListDto : sysSourceList){
LocalDate startTime = sourceListDto.getStartTime();
LocalDate endTime = sourceListDto.getEndTime();
if (sourceListDto.getStartTime()!=null && sourceListDto.getEndTime()!=null)
{
sourceListDto.setTime(sourceListDto.getStartTime() + "~" + sourceListDto.getEndTime());
long daysBetween = ChronoUnit.DAYS.between(startTime, endTime);
// 展示天数
sourceListDto.setpDay(daysBetween);
// 剩余天数, 这里先置为0
sourceListDto.setrDay(0L);
}
// 新版价格
sourceListDto.setPriceList(GsonUtils.fromJson(sourceListDto.getPrice(), List.class));
}
return success(sysSourceList);
}
// 新增关注

View File

@ -3,7 +3,12 @@ package com.ruoyi.web.controller.app.pay;
import com.jeequan.jeepay.util.JeepayKit;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.OrderInfo;
import com.ruoyi.system.domain.SysOrder;
import com.ruoyi.system.domain.vo.OrderCacheVo;
import com.ruoyi.system.service.IOrderInfoService;
import com.ruoyi.system.service.ISysOrderService;
import com.ruoyi.web.controller.app.baidu.GsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -24,6 +29,12 @@ public class PayBackController {
@Autowired
private RedisCache redisCache;
@Autowired
private IOrderInfoService orderInfoService;
@Autowired
private ISysOrderService sysOrderService;
@Transactional
@PostMapping("/wxRechargeCallback/{mchOrderNo}")
public String wxRechargeCallback(HttpServletRequest req, @PathVariable String mchOrderNo){
@ -51,10 +62,34 @@ public class PayBackController {
// 获取缓存中的订单信息
List<OrderCacheVo> list = redisCache.getCacheObject(mchOrderNo);
for(OrderCacheVo orderCacheVo:list){
for(OrderCacheVo orderCacheVo : list){
// System.out.println(orderCacheVo);
OrderInfo orderInfo = new OrderInfo();
orderInfo.setOrderInfoId(mchOrderNo);
orderInfo.setSourceId(orderCacheVo.getSourceId());
orderInfo.setWorkId(orderCacheVo.getWorkId());
orderInfo.setStatus("0");
// 插入订单详情表 order_info
orderInfoService.insertOrderInfo(orderInfo);
}
SysOrder sysOrder = new SysOrder();
sysOrder.setOrderInfoId(mchOrderNo);
sysOrder.setStatus("0");
sysOrder.setCreateTime(DateUtils.getNowDate());
sysOrder.setUserId(list.get(0).getUserId());
// sysOrder.setRefund(0L);
sysOrder.setMoney(list.get(0).getMoney());
sysOrder.setStartTime(list.get(0).getStartTime());
sysOrder.setEndTime(list.get(0).getEndTime());
sysOrder.setSourceId(list.get(0).getSourceId());
sysOrder.setWay(list.get(0).getWay());
// 插入系统订单表
sysOrderService.insertSysOrder(sysOrder);
System.out.println(list);
return "";

View File

@ -127,7 +127,7 @@ public class SysMarketController extends BaseController {
// 根据 order_info_id 查看订单所有的资源位
for(OrderListDto orderListDto: orderListDtoList){
Long orderInfoId = orderListDto.getOrderInfoId();
String orderInfoId = orderListDto.getOrderInfoId();
List<OrderInfoDto> orderInfoList = orderInfoService.getOrderInfoDtoList(orderInfoId);

View File

@ -1,104 +1,104 @@
package com.ruoyi.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OrderInfo;
import com.ruoyi.system.service.IOrderInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 订单信息若一个订单存在购买多个资源位则添加多条数据Controller
*
* @author haotian
* @date 2024-12-17
*/
@RestController
@RequestMapping("/system/info")
public class OrderInfoController extends BaseController
{
@Autowired
private IOrderInfoService orderInfoService;
/**
* 查询订单信息若一个订单存在购买多个资源位则添加多条数据列表
*/
@PreAuthorize("@ss.hasPermi('system:info:list')")
@GetMapping("/list")
public TableDataInfo list(OrderInfo orderInfo)
{
startPage();
List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderInfo);
return getDataTable(list);
}
/**
* 导出订单信息若一个订单存在购买多个资源位则添加多条数据列表
*/
@PreAuthorize("@ss.hasPermi('system:info:export')")
@Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, OrderInfo orderInfo)
{
List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderInfo);
ExcelUtil<OrderInfo> util = new ExcelUtil<OrderInfo>(OrderInfo.class);
util.exportExcel(response, list, "订单信息,若一个订单存在购买多个资源位,则添加多条数据数据");
}
/**
* 获取订单信息若一个订单存在购买多个资源位则添加多条数据详细信息
*/
@PreAuthorize("@ss.hasPermi('system:info:query')")
@GetMapping(value = "/{orderInfoId}")
public AjaxResult getInfo(@PathVariable("orderInfoId") Long orderInfoId)
{
return success(orderInfoService.selectOrderInfoByOrderInfoId(orderInfoId));
}
/**
* 新增订单信息若一个订单存在购买多个资源位则添加多条数据
*/
@PreAuthorize("@ss.hasPermi('system:info:add')")
@Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody OrderInfo orderInfo)
{
return toAjax(orderInfoService.insertOrderInfo(orderInfo));
}
/**
* 修改订单信息若一个订单存在购买多个资源位则添加多条数据
*/
@PreAuthorize("@ss.hasPermi('system:info:edit')")
@Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody OrderInfo orderInfo)
{
return toAjax(orderInfoService.updateOrderInfo(orderInfo));
}
/**
* 删除订单信息若一个订单存在购买多个资源位则添加多条数据
*/
@PreAuthorize("@ss.hasPermi('system:info:remove')")
@Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{orderInfoIds}")
public AjaxResult remove(@PathVariable Long[] orderInfoIds)
{
return toAjax(orderInfoService.deleteOrderInfoByOrderInfoIds(orderInfoIds));
}
}
//package com.ruoyi.system.controller;
//
//import java.util.List;
//import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import com.ruoyi.common.annotation.Log;
//import com.ruoyi.common.core.controller.BaseController;
//import com.ruoyi.common.core.domain.AjaxResult;
//import com.ruoyi.common.enums.BusinessType;
//import com.ruoyi.system.domain.OrderInfo;
//import com.ruoyi.system.service.IOrderInfoService;
//import com.ruoyi.common.utils.poi.ExcelUtil;
//import com.ruoyi.common.core.page.TableDataInfo;
//
///**
// * 订单信息若一个订单存在购买多个资源位则添加多条数据Controller
// *
// * @author haotian
// * @date 2024-12-17
// */
//@RestController
//@RequestMapping("/system/info")
//public class OrderInfoController extends BaseController
//{
// @Autowired
// private IOrderInfoService orderInfoService;
//
// /**
// * 查询订单信息若一个订单存在购买多个资源位则添加多条数据列表
// */
// @PreAuthorize("@ss.hasPermi('system:info:list')")
// @GetMapping("/list")
// public TableDataInfo list(OrderInfo orderInfo)
// {
// startPage();
// List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderInfo);
// return getDataTable(list);
// }
//
// /**
// * 导出订单信息若一个订单存在购买多个资源位则添加多条数据列表
// */
// @PreAuthorize("@ss.hasPermi('system:info:export')")
// @Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.EXPORT)
// @PostMapping("/export")
// public void export(HttpServletResponse response, OrderInfo orderInfo)
// {
// List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderInfo);
// ExcelUtil<OrderInfo> util = new ExcelUtil<OrderInfo>(OrderInfo.class);
// util.exportExcel(response, list, "订单信息,若一个订单存在购买多个资源位,则添加多条数据数据");
// }
//
// /**
// * 获取订单信息若一个订单存在购买多个资源位则添加多条数据详细信息
// */
// @PreAuthorize("@ss.hasPermi('system:info:query')")
// @GetMapping(value = "/{orderInfoId}")
// public AjaxResult getInfo(@PathVariable("orderInfoId") Long orderInfoId)
// {
// return success(orderInfoService.selectOrderInfoByOrderInfoId(orderInfoId));
// }
//
// /**
// * 新增订单信息若一个订单存在购买多个资源位则添加多条数据
// */
// @PreAuthorize("@ss.hasPermi('system:info:add')")
// @Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@RequestBody OrderInfo orderInfo)
// {
// return toAjax(orderInfoService.insertOrderInfo(orderInfo));
// }
//
// /**
// * 修改订单信息若一个订单存在购买多个资源位则添加多条数据
// */
// @PreAuthorize("@ss.hasPermi('system:info:edit')")
// @Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody OrderInfo orderInfo)
// {
// return toAjax(orderInfoService.updateOrderInfo(orderInfo));
// }
//
// /**
// * 删除订单信息若一个订单存在购买多个资源位则添加多条数据
// */
// @PreAuthorize("@ss.hasPermi('system:info:remove')")
// @Log(title = "订单信息,若一个订单存在购买多个资源位,则添加多条数据", businessType = BusinessType.DELETE)
// @DeleteMapping("/{orderInfoIds}")
// public AjaxResult remove(@PathVariable Long[] orderInfoIds)
// {
// return toAjax(orderInfoService.deleteOrderInfoByOrderInfoIds(orderInfoIds));
// }
//}

View File

@ -21,7 +21,7 @@ public class OrderInfo extends BaseEntity
private Long id;
private Long orderInfoId;
private String orderInfoId;
/** 资源位id */
@Excel(name = "资源位id")
@ -43,12 +43,12 @@ public class OrderInfo extends BaseEntity
return id;
}
public void setOrderInfoId(Long orderInfoId)
public void setOrderInfoId(String orderInfoId)
{
this.orderInfoId = orderInfoId;
}
public Long getOrderInfoId()
public String getOrderInfoId()
{
return orderInfoId;
}

View File

@ -43,8 +43,9 @@ public class SysOrder extends BaseEntity
@Excel(name = "删除标志默认为0")
private String deleteFlag;
private Long orderInfoId;
// private Long orderInfoId;
private String orderInfoId;
// 实付金额
private Long money;
@ -115,11 +116,11 @@ public class SysOrder extends BaseEntity
return deleteFlag;
}
public Long getOrderInfoId() {
public String getOrderInfoId() {
return orderInfoId;
}
public void setOrderInfoId(Long orderInfoId) {
public void setOrderInfoId(String orderInfoId) {
this.orderInfoId = orderInfoId;
}

View File

@ -18,7 +18,7 @@ public class OrderDetailDto {
private String present;
private Long orderInfoId;
private String orderInfoId;
private Long money;
@ -110,11 +110,11 @@ public class OrderDetailDto {
this.endTime = endTime;
}
public Long getOrderInfoId() {
public String getOrderInfoId() {
return orderInfoId;
}
public void setOrderInfoId(Long orderInfoId) {
public void setOrderInfoId(String orderInfoId) {
this.orderInfoId = orderInfoId;
}

View File

@ -6,7 +6,7 @@ public class OrderInfoDto {
private Long id;
private Long orderInfoId;
private String orderInfoId;
private Long orderId;
@ -129,11 +129,11 @@ public class OrderInfoDto {
this.userId = userId;
}
public Long getOrderInfoId() {
public String getOrderInfoId() {
return orderInfoId;
}
public void setOrderInfoId(Long orderInfoId) {
public void setOrderInfoId(String orderInfoId) {
this.orderInfoId = orderInfoId;
}

View File

@ -18,7 +18,7 @@ public class OrderListDto {
private Date startTime;
private Date endTime;
private Long orderInfoId;
private String orderInfoId;
private Long money;
@ -65,11 +65,11 @@ public class OrderListDto {
this.endTime = endTime;
}
public Long getOrderInfoId() {
public String getOrderInfoId() {
return orderInfoId;
}
public void setOrderInfoId(Long orderInfoId) {
public void setOrderInfoId(String orderInfoId) {
this.orderInfoId = orderInfoId;
}

View File

@ -6,11 +6,13 @@ public class OrderCacheVo {
private Long source_id;
private Long user_id;
private Long work_id;
private LocalDate startTime;
private LocalDate endTime;
private String way;
private Long money;
public Long getSourceId() {
return source_id;
}
@ -59,4 +61,12 @@ public class OrderCacheVo {
this.money = money;
}
public Long getWorkId() {
return work_id;
}
public void setWorkId(Long work_id) {
this.work_id = work_id;
}
}

View File

@ -18,7 +18,7 @@ public interface OrderInfoMapper
* @param orderInfoId 订单信息若一个订单存在购买多个资源位则添加多条数据主键
* @return 订单信息若一个订单存在购买多个资源位则添加多条数据
*/
public OrderInfo selectOrderInfoByOrderInfoId(Long orderInfoId);
public OrderInfo selectOrderInfoByOrderInfoId(String orderInfoId);
/**
* 查询订单信息若一个订单存在购买多个资源位则添加多条数据列表
@ -62,7 +62,7 @@ public interface OrderInfoMapper
public int deleteOrderInfoByOrderInfoIds(Long[] orderInfoIds);
public List<OrderInfoDto> getOrderInfoDtoList(Long orderInfoId);
public List<OrderInfoDto> getOrderInfoDtoList(String orderInfoId);
public OrderInfoDto getOrderInfoDto(Long id);
}

View File

@ -18,7 +18,7 @@ public interface IOrderInfoService
* @param orderInfoId 订单信息若一个订单存在购买多个资源位则添加多条数据主键
* @return 订单信息若一个订单存在购买多个资源位则添加多条数据
*/
public OrderInfo selectOrderInfoByOrderInfoId(Long orderInfoId);
public OrderInfo selectOrderInfoByOrderInfoId(String orderInfoId);
/**
* 查询订单信息若一个订单存在购买多个资源位则添加多条数据列表
@ -61,7 +61,7 @@ public interface IOrderInfoService
public int deleteOrderInfoByOrderInfoId(Long orderInfoId);
/*返回属于order_info_id的所有资源位订单*/
public List<OrderInfoDto> getOrderInfoDtoList(Long orderInfoId);
public List<OrderInfoDto> getOrderInfoDtoList(String orderInfoId);
/*返回定单详情*/
public OrderInfoDto getOrderInfoDto(Long id);

View File

@ -28,7 +28,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
* @return 订单信息若一个订单存在购买多个资源位则添加多条数据
*/
@Override
public OrderInfo selectOrderInfoByOrderInfoId(Long orderInfoId)
public OrderInfo selectOrderInfoByOrderInfoId(String orderInfoId)
{
return orderInfoMapper.selectOrderInfoByOrderInfoId(orderInfoId);
}
@ -94,7 +94,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
}
@Override
public List<OrderInfoDto> getOrderInfoDtoList(Long orderInfoId){
public List<OrderInfoDto> getOrderInfoDtoList(String orderInfoId){
return orderInfoMapper.getOrderInfoDtoList(orderInfoId);
}

View File

@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectOrderInfoByOrderInfoId" parameterType="Long" resultMap="OrderInfoResult">
<select id="selectOrderInfoByOrderInfoId" parameterType="String" resultMap="OrderInfoResult">
<include refid="selectOrderInfoVo"/>
where order_info_id = #{orderInfoId}
</select>