李雨欣 9.3测试接口21:25

master
liyuxin 2024-09-03 21:25:26 +08:00
parent 6c51f1b2e2
commit e35d8f8cbf
9 changed files with 279 additions and 4 deletions

View File

@ -4,15 +4,13 @@ import lombok.Data;
@Data
public class AliPay {
//订单编号
private String traceNo;
//商品金额
private double totalAmount;
//商品名称
private String subject;
//订单追踪号,商户自己生成,可已不使用
private String alipayTraceNo;
}

View File

@ -0,0 +1,56 @@
package com.muyu.market.admain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.awt.desktop.ScreenSleepEvent;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@SuperBuilder
@NoArgsConstructor
@TableName(value = "market_spend",autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class Spend extends BaseEntity {
/**
* ID
*/
@TableId(value = "spend_id",type = IdType.AUTO)
private Long spendId;
/**
*
*/
@Schema(type = "String",description = "数据模块名称")
private String name;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(type = "Date",description = "时间周期")
private Date spendDay;
/**
*
*/
@Schema(type = "BigDecimal",description = "金额")
private BigDecimal price;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "消费时间",type = "Date")
private Date spendTime;
}

View File

@ -0,0 +1,49 @@
package com.muyu.market.admain.request;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@SuperBuilder
@NoArgsConstructor
@Tag(name = "消费记录表",description = "记录客户消费的数据")
public class SpendReq {
/**
* ID
*/
@TableId(value = "spend_id",type = IdType.AUTO)
private Long spendId;
/**
*
*/
@Schema(type = "String",description = "数据块名称")
private String name;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(type = "Date",description = "时间周期")
private Date spendDay;
/**
*
*/
@Schema(type = "BigDecimal",description = "金额")
private BigDecimal price;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(type = "Date",description = "消费时间")
private Date spendTime;
}

View File

@ -0,0 +1,67 @@
package com.muyu.market.admain.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.market.admain.Record;
import com.muyu.market.admain.Spend;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
import java.util.Date;
@Data
@AllArgsConstructor
@SuperBuilder
@NoArgsConstructor
@Tag(name = "记录消费",description = "记录客户消费的数据")
public class SpendResp {
/**
* Id
*/
@TableId(value = "spend_id",type = IdType.AUTO)
private Long spendId;
/**
*
*/
@Schema(type = "String",description = "数据模块名称")
private String name;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(type = "Date",description = "时间周期")
private Date spendDay;
/**
*
*/
@Schema(type = "BigDecimal",description = "金额")
private BigDecimal price;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(type = "Date",description = "消费时间")
private Date spendTime;
public static SpendResp selSpendList(Spend spend){
return SpendResp
.builder()
.spendId(spend.getSpendId())
.name(spend.getName())
.spendDay(spend.getSpendDay())
.price(spend.getPrice())
.spendTime(spend.getSpendTime())
.build();
}
}

View File

@ -93,9 +93,10 @@ public class AliPayController {
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
System.out.println("买家付款时间: " + params.get("gmt_payment"));
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
// 更新订单已支付的逻辑代码
}
}
return "success";

View File

@ -0,0 +1,38 @@
package com.muyu.market.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.market.admain.request.RecordListReq;
import com.muyu.market.admain.request.SpendReq;
import com.muyu.market.admain.response.RecordListResp;
import com.muyu.market.admain.response.SpendResp;
import com.muyu.market.server.service.SpendService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/spend")
@Tag(name = "消费记录控制层",description = "消费记录控制层")
@RequiredArgsConstructor
public class SpendController {
@Autowired
private SpendService spendService;
@RequestMapping(path = "/spendList",method = RequestMethod.POST)
@Operation(summary = "消费记录展示",description = "根据接口")
public Result<List<SpendResp>> findBySpendList(@Validated @RequestBody SpendReq spendReq){
return Result.success(spendService.findBySpendList(spendReq));
}
}

View File

@ -0,0 +1,9 @@
package com.muyu.market.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.market.admain.Spend;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SpendMapper extends BaseMapper<Spend> {
}

View File

@ -0,0 +1,45 @@
package com.muyu.market.server.service.Impl;
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.market.admain.Record;
import com.muyu.market.admain.Spend;
import com.muyu.market.admain.request.SpendReq;
import com.muyu.market.admain.response.RecordListResp;
import com.muyu.market.admain.response.SpendResp;
import com.muyu.market.server.mapper.SpendMapper;
import com.muyu.market.server.service.SpendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SpendServiceImpl extends ServiceImpl<SpendMapper, Spend> implements SpendService {
@Autowired
private SpendMapper spendMapper;
@Override
public List<SpendResp> findBySpendList(SpendReq spendReq) {
LambdaQueryWrapper<Spend> spendLambdaQueryWrapper = new LambdaQueryWrapper<>();
/**
*
*/
if (StringUtils.isNotBlank( spendReq.getName())){
spendLambdaQueryWrapper.like( Spend::getName,spendReq.getName());
}
List<Spend> spendList = this.list(spendLambdaQueryWrapper);
return spendList.stream()
.map(SpendResp::selSpendList)
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,12 @@
package com.muyu.market.server.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.market.admain.Spend;
import com.muyu.market.admain.request.SpendReq;
import com.muyu.market.admain.response.SpendResp;
import java.util.List;
public interface SpendService extends IService<Spend> {
List<SpendResp> findBySpendList(SpendReq spendReq);
}