app后台--支付回调---添加更新资源位信息.

This commit is contained in:
haotianmingyue 2024-12-24 11:41:43 +08:00
parent ed2c6dfc30
commit e2409e1091
4 changed files with 64 additions and 30 deletions

View File

@ -1066,35 +1066,14 @@ public class AppSystemController {
public AjaxResult getAllSource(SysSource sysSource) {
List<SysSource> sysSourceList = sysSourceService.selectSysSourceList(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));
for(SysSource sysSource1 : sysSourceList){
sysSource1.setPriceList(GsonUtils.fromJson(sysSource1.getPrice(), List.class));
}
return AjaxResult.success(sysSourceList);
return success(sysSourceList);
}

View File

@ -6,9 +6,13 @@ 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.SysSource;
import com.ruoyi.system.domain.UserWork;
import com.ruoyi.system.domain.vo.OrderCacheVo;
import com.ruoyi.system.service.IOrderInfoService;
import com.ruoyi.system.service.ISysOrderService;
import com.ruoyi.system.service.ISysSourceService;
import com.ruoyi.system.service.IUserWorkService;
import com.ruoyi.web.controller.app.baidu.GsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@ -18,10 +22,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
@RestController
@RequestMapping("/wxPay")
@ -35,6 +38,12 @@ public class PayBackController {
@Autowired
private ISysOrderService sysOrderService;
@Autowired
private ISysSourceService sysSourceService;
@Autowired
private IUserWorkService userWorkService;
@Transactional
@PostMapping("/wxRechargeCallback/{mchOrderNo}")
public String wxRechargeCallback(HttpServletRequest req, @PathVariable String mchOrderNo){
@ -72,6 +81,34 @@ public class PayBackController {
// 插入订单详情表 order_info
orderInfoService.insertOrderInfo(orderInfo);
//----------------------------------------- 更新资源位表 sys_source----------------------------------------------
// 获取资源位
SysSource sysSource = sysSourceService.selectSysSourceBySourceId(orderCacheVo.getSourceId());
// 购买次数+1
sysSource.setbBought(sysSource.getbBought()+1);
sysSource.setSourceStatus("1");
// 将LocalDate转换为ZonedDateTime指定时区例如系统默认时区----------------看看要不要把时间转换成LocalDate
ZonedDateTime zoneStartTime = orderCacheVo.getStartTime().atStartOfDay(ZoneId.of("Asia/Shanghai"));
sysSource.setStartTime(Date.from(zoneStartTime.toInstant()));
ZonedDateTime zoneEndTime = orderCacheVo.getEndTime().atStartOfDay(ZoneId.of("Asia/Shanghai"));
sysSource.setEndTime(Date.from(zoneEndTime.toInstant()));
// //---------- 更新资源位上的作品-----------------这时应该不更新------------系统的定是任务更新-------
// UserWork userWork = userWorkService.selectUserWorkByWorkId(orderCacheVo.getWorkId());
// sysSource.setWorkAddress(userWork.getWorkAddress());
// //------------更新资源位上的作品 end -------------------------------------------------------------
// 更新资源位信息
sysSourceService.updateSysSource(sysSource);
//------------------------------------------更新资源位表 sys_source end------------------------------------------
}
SysOrder sysOrder = new SysOrder();
@ -90,6 +127,9 @@ public class PayBackController {
sysOrderService.insertSysOrder(sysOrder);
System.out.println(list);
return "";

View File

@ -1,7 +1,11 @@
package com.ruoyi.system.domain;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.system.domain.dto.SetSourcePriceDto;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@ -78,6 +82,9 @@ public class SysSource extends BaseEntity
@Excel(name = "订单编号")
private Long orderId;
// 价格列表
private List<Map<String, SetSourcePriceDto>> priceList;
public void setSourceId(Long sourceId)
{
this.sourceId = sourceId;
@ -214,6 +221,14 @@ public class SysSource extends BaseEntity
return orderId;
}
public List<Map<String, SetSourcePriceDto>> getPriceList() {
return priceList;
}
public void setPriceList(List<Map<String, SetSourcePriceDto>> priceList) {
this.priceList = priceList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -14,7 +14,7 @@ public class SourceListDto {
private String part;
private String price;
// json 的价格
// json 的价格
private Map<String, String> priceJson;
private List<Map<String, SetSourcePriceDto>> priceList;