修改--审核不通过更新订单状态和释放资源位

This commit is contained in:
haotian 2025-04-23 11:59:04 +08:00
parent 698e4c14e6
commit 8f8439fc19
12 changed files with 180 additions and 24 deletions

View File

@ -132,8 +132,6 @@ public class PayBackController {
orderInfo.setWorkId(orderCacheVo.getWorkId());
orderInfo.setMoney(orderCacheVo.getMoney());
System.out.println("单个订单价格: "+orderCacheVo.getMoney());
// 订单初始状态 0, 下订单还未展示
orderInfo.setStatus("0");
// 插入订单详情表 order_info

View File

@ -10,10 +10,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysOrder;
import com.ruoyi.system.domain.SysUserNotification;
import com.ruoyi.system.domain.UserWork;
import com.ruoyi.system.domain.WorkReview;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.ReviewWorkDto;
import com.ruoyi.system.domain.dto.SeOnlineTimeDto;
import com.ruoyi.system.domain.dto.SeUserWorkCountDto;
@ -25,9 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.time.LocalDateTime;
import java.util.*;
//import static com.ruoyi.common.core.domain.AjaxResult.error;
//import static com.ruoyi.common.utils.PageUtils.startPage;
@ -56,6 +52,15 @@ public class SysWorkReviewController extends BaseController {
@Autowired
private ISysOrderService sysOrderService;
@Autowired
private IOrderInfoService orderInfoService;
@Autowired
private ISysSourceService sysSourceService;
@Autowired
private ISysSourceDefaultService sysSourceDefaultService;
/*
* 获取过审总数--workStatus=3
@ -248,16 +253,70 @@ public class SysWorkReviewController extends BaseController {
//-----------------------------新版审核逻辑-能无数个人审-以最后一个人审的为准---------------------
UserWork userWork = userWorkService.selectUserWorkByWorkId(workId);
// if(userWork.getWorkStatus() == null){
// return error("作品状态为空");
// }
// 审核不通过
if(workStatus.equals("4")){
// 退款逻辑--------判断时间-----退款----下架.
// 修改订单状态为1 已退款
List<SysOrder> sysOrderList = sysOrderService.getSysOrderByWordId(workId);
// List<SysOrder> sysOrderList = sysOrderService.getSysOrderByWordId(workId);
OrderInfo orderInfo = new OrderInfo();
orderInfo.setWorkId(workId);
orderInfo.setStatus("0");
Set<String> orderInfoIdSet = new HashSet<>();
Map<String, Long> orderInfoIdMap = new HashMap<>();
Date now = new Date();
// 获取订单详细信息
List<OrderInfo> orderInfoList = orderInfoService.selectOrderInfoList(orderInfo);
for(OrderInfo orderInfo1:orderInfoList){
// 添加原始订单
orderInfoIdSet.add(orderInfo1.getOrderInfoId());
orderInfo1.setStatus("1");
orderInfo1.setRefundTime(now);
orderInfoIdMap.put(orderInfo1.getOrderInfoId(), orderInfoIdMap.getOrDefault(orderInfo1.getOrderInfoId(), 0L)+orderInfo1.getMoney());
orderInfoService.updateOrderInfo(orderInfo1);
//---------------------------- 释放资源位--将资源位source_status改为0, work_id也指向0-----------------------------------------
SysSource sysSource = sysSourceService.selectSysSourceBySourceId(orderInfo1.getSourceId());
// 更换为默认背景--- 展示中审核不通过修改为默认背景
if(sysSource.getSourceStatus().equals("2")){
SysSourceDefault sysSourceDefault = sysSourceDefaultService.getSourceDefaultBySourceId(sysSource.getSourceId());
sysSource.setWorkAddress(sysSourceDefault.getWorkAddress());
}
sysSource.setSourceStatus("0");
sysSource.setWorkId(0L);
sysSource.setbBought(sysSource.getbBought()-1);
sysSourceService.updateSysSource(sysSource);
//-----------------------------释放资源位end-----------------------------------------------------------------------------------
// 下架资源位
}
// 原始订单状态改为已退款.
for(String orderInfoId:orderInfoIdSet){
// 更新订单
sysOrderService.updateSysOrderByOrderInfoId(orderInfoId, "1", orderInfoIdMap.getOrDefault(orderInfoId, 0L));
}
// 释放资源位
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.backstage.daily;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.DailyScenicDto;
import com.ruoyi.system.domain.dto.DailySourceDto;
@ -22,7 +23,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.*;
//@Component
@ -80,6 +81,9 @@ public class dailySysServer {
@Autowired
private ISysSourceDefaultService sysSourceDefaultService;
@Autowired
private IOrderInfoService orderInfoService;
//计数当前系统用户数量并且插入daily_sys表(日期是昨天)
@ -286,12 +290,29 @@ public class dailySysServer {
Long orderId = sysSource.getOrderId();
if(orderId != null){
SysOrder sysOrder = sysOrderService.selectSysOrderByOrderId(orderId);
if(sysOrder!=null){
// 修改order_info 状态
OrderInfo orderInfo = orderInfoService.getOrderInfoByOrderInfoIdAndWorkId(sysOrder.getOrderInfoId(), userwork.getWorkId());
orderInfo.setStatus("1");
orderInfo.setRefundTime(DateUtils.getNowDate());
orderInfoService.updateOrderInfo(orderInfo);
// 需改sys_order 状态和退款金额
sysOrder.setStatus("1");
sysOrder.setRefund(sysOrder.getRefund() + sysOrder.getMoney());
sysOrderService.updateSysOrder(sysOrder);
}
}
//
//发送退款消息通知
SysUserNotification sysUserNotification = new SysUserNotification();
sysUserNotification.setUserId(userwork.getUserId());
@ -302,10 +323,10 @@ public class dailySysServer {
userNotificationService.insertSysUserNotification(sysUserNotification);
// 修改资源位状态为0,可购买
SysScenicDefault sysScenicDefault = sysScenicDefaultService.getScenicDefaultByScenicAndPart(sysSource.getScenic(), sysSource.getPart());
sysSource.setPrice(sysScenicDefault.getPrice());
SysSourceDefault sysSourceDefault = sysSourceDefaultService.getSourceDefaultBySourceId(sysSource.getSourceId());
sysSource.setPrice(sysSourceDefault.getPrice());
sysSource.setSourceStatus("0");
sysSource.setWorkAddress(sysScenicDefault.getWorkAddress());
sysSource.setWorkAddress(sysSourceDefault.getWorkAddress());
sysSource.setWorkId(0L);
@ -319,7 +340,7 @@ public class dailySysServer {
// 结束展示--修改默认背景和默认价格, 这个区域的默认价格可能发生变化.
else if(sysSource.getSourceStatus().equals("2") &&
endTime.equals(now)){
// SysScenicDefault sysScenicDefault = sysScenicDefaultService.getScenicDefaultByScenicAndPart(sysSource.getScenic(), sysSource.getPart());
SysSourceDefault sysSourceDefault = sysSourceDefaultService.getSourceDefaultBySourceId(sysSource.getSourceId());
sysSource.setPrice(sysSourceDefault.getPrice());
@ -332,6 +353,14 @@ public class dailySysServer {
if(orderId != null){
SysOrder sysOrder = sysOrderService.selectSysOrderByOrderId(orderId);
if(sysOrder!=null){
// 修改order_info 状态
OrderInfo orderInfo = orderInfoService.getOrderInfoByOrderInfoIdAndWorkId(sysOrder.getOrderInfoId(), sysSource.getWorkId());
orderInfo.setStatus("2");
orderInfoService.updateOrderInfo(orderInfo);
// 修改sys_order 状态和退款金额
sysOrder.setStatus("2");
sysOrderService.updateSysOrder(sysOrder);
}
@ -392,8 +421,8 @@ public class dailySysServer {
}
}
// 修改资源位状态为闲置, 只是闲置不需要修改别的
sysSource.setSourceStatus("0");
// // 修改资源位状态为闲置, 只是闲置不需要修改别的. 20250423不能修改为闲置, 新用户发布的会和旧的产生冲突.
// sysSource.setSourceStatus("0");

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.domain;
import java.sql.Time;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
@ -62,6 +63,9 @@ public class SysOrder extends BaseEntity
// 退款金额
private Long refund;
// 退款时间
private Date updateTime;
public void setOrderId(Long orderId)
{
this.orderId = orderId;
@ -168,6 +172,16 @@ public class SysOrder extends BaseEntity
this.refund = refund;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -70,4 +70,9 @@ public interface OrderInfoMapper
* 根据orderInfoId返回orderInfo
* */
List<Long> getOrderInfoByOrderInfoId(String orderInfoId);
/***
* 根据orderInfoId和work_id返回orderInfo
*/
public OrderInfo getOrderInfoByOrderInfoIdAndWorkId(String orderInfoId, Long workId);
}

View File

@ -93,4 +93,10 @@ public interface SysOrderMapper
* 根据wordId返回订单列表
* */
public List<SysOrder> getSysOrderByWordId(@Param("wordId") Long wordId);
/**
* 根据orderInfoId退款
* */
public int updateSysOrderByOrderInfoId(@Param("orderInfoId") String orderInfoId, @Param("status") String status, @Param("money") Long money);
}

View File

@ -69,5 +69,10 @@ public interface IOrderInfoService
/**
* 根据orderInfoId返回orderInfo
* */
List<Long> getOrderInfoByOrderInfoId(String orderInfoId);
public List<Long> getOrderInfoByOrderInfoId(String orderInfoId);
/***
* 根据orderInfoId和work_id返回orderInfo
*/
public OrderInfo getOrderInfoByOrderInfoIdAndWorkId(String orderInfoId, Long workId);
}

View File

@ -101,4 +101,9 @@ public interface ISysOrderService
* 根据wordId返回订单列表
* */
public List<SysOrder> getSysOrderByWordId(Long wordId);
/**
* 根据orderInfoId退款
* */
public int updateSysOrderByOrderInfoId(String orderInfoId, String status, Long money);
}

View File

@ -110,4 +110,12 @@ public class OrderInfoServiceImpl implements IOrderInfoService
public List<Long> getOrderInfoByOrderInfoId(String orderInfoId){
return orderInfoMapper.getOrderInfoByOrderInfoId(orderInfoId);
}
/***
* 根据orderInfoId和work_id返回orderInfo
*/
@Override
public OrderInfo getOrderInfoByOrderInfoIdAndWorkId(String orderInfoId, Long workId){
return orderInfoMapper.getOrderInfoByOrderInfoIdAndWorkId(orderInfoId, workId);
}
}

View File

@ -70,6 +70,8 @@ public class SysOrderServiceImpl implements ISysOrderService
@Override
public int updateSysOrder(SysOrder sysOrder)
{
// 设置更新时间
sysOrder.setUpdateTime(DateUtils.getNowDate());
return sysOrderMapper.updateSysOrder(sysOrder);
}
@ -144,4 +146,12 @@ public class SysOrderServiceImpl implements ISysOrderService
public List<SysOrder> getSysOrderByWordId(Long wordId){
return sysOrderMapper.getSysOrderByWordId(wordId);
}
/**
* 根据orderInfoId退款
* */
@Override
public int updateSysOrderByOrderInfoId(String orderInfoId, String status, Long money){
return sysOrderMapper.updateSysOrderByOrderInfoId(orderInfoId, status, money);
}
}

View File

@ -70,6 +70,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from order_info
where order_info_id = #{orderInfoId}
</select>
<select id="getOrderInfoByOrderInfoIdAndWorkId" resultMap="OrderInfoResult">
select *
from order_info
where order_info_id = #{orderInfoId} and work_id = #{workId}
</select>
<insert id="insertOrderInfo" parameterType="OrderInfo">
@ -79,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
<if test="sourceId != null">source_id,</if>
<if test="workId != null">work_id,</if>
<if test="id != null">id,</if>
-- <if test="id != null">id,</if>
<if test="status != null">status,</if>
<if test="refundTime != null">refund_time,</if>
<if test="money != null">money,</if>
@ -89,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if>
<if test="sourceId != null">#{sourceId},</if>
<if test="workId != null">#{workId},</if>
<if test="id != null">#{id},</if>
<!-- <if test="id != null">#{id},</if>-->
<if test="status != null">#{status},</if>
<if test="refundTime != null">#{refundTime},</if>
<if test="money != null">#{money},</if>
@ -102,12 +107,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark = #{remark},</if>
<if test="sourceId != null">source_id = #{sourceId},</if>
<if test="workId != null">work_id = #{workId},</if>
<if test="id != null">id = #{id},</if>
<if test="status != null">status = #{status},</if>
<if test="refundTime != null">refund_time = #{refundTime},</if>
<if test="money != null">money = #{money},</if>
<if test="orderInfoId != null">order_info_id = #{orderInfoId},</if>
</trim>
where order_info_id = #{orderInfoId}
where id = #{id}
</update>
<delete id="deleteOrderInfoByOrderInfoId" parameterType="Long">

View File

@ -18,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="detail" column="detail" />
<result property="status" column="status" />
<result property="refund" column="refund"/>
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap id="OrderListDtoResult" type="OrderListDto">
@ -80,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectSysOrderVo">
select order_id, user_id, source_id, create_time, start_time, end_time, delete_flag from sys_order
select order_id, user_id, source_id, create_time, start_time, end_time, delete_flag , refund, update_time, order_info_id from sys_order
</sql>
<select id="selectSysOrderList" parameterType="SysOrder" resultMap="SysOrderResult">
@ -97,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="detail != null and detail != ''"> and detail like concat('%', #{detail}, '%')</if>
<if test="status != null "> and status = #{status}</if>
<if test="refund != null "> and refund = #{refund}</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
</where>
</select>
@ -167,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="detail != null">detail,</if>
<if test="status != null">status,</if>
<if test="refund != null">refund,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
@ -181,6 +184,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="detail != null">#{detail},</if>
<if test="status != null">#{status},</if>
<if test="refund != null">#{refund},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
@ -199,9 +203,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="detail != null">detail = #{detail},</if>
<if test="status != null">status = #{status},</if>
<if test="refund != null">refund = #{refund},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where order_id = #{orderId}
</update>
<update id="updateSysOrderByOrderInfoId">
update sys_order
set status = #{status},
refund = #{money},
update_time = CURRENT_TIMESTAMP
where order_info_id = #{orderInfoId}
</update>
<delete id="deleteSysOrderByOrderId" parameterType="Long">
delete from sys_order where order_id = #{orderId}