Przeglądaj źródła

我的兑换 接口

tags/V1.7.0
wanghaoran 1 rok temu
rodzic
commit
cbfd32539d
7 zmienionych plików z 236 dodań i 1 usunięć
  1. +35
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/controller/MyController.java
  2. +76
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/UserPointsDetail.java
  3. +24
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/entity/request/UserPointsDetailQuery.java
  4. +1
    -1
      tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamUserQuery.java
  5. +13
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/mapper/UserPointsDetailMapper.java
  6. +16
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/service/IUserPointsDetailService.java
  7. +71
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/UserPointsDetailServiceImpl.java

+ 35
- 0
tuoheng-api/src/main/java/com/tuoheng/api/controller/MyController.java Wyświetl plik

@@ -0,0 +1,35 @@
package com.tuoheng.api.controller;

import com.tuoheng.api.entity.request.UserPointsDetailQuery;
import com.tuoheng.api.service.IUserPointsDetailService;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 我的 前端控制器
*
* @author WangHaoran
* @since 2023-05-06
*/
@RestController
@RequestMapping("/my")
public class MyController {

@Autowired
IUserPointsDetailService userPointsDetailService;


/**
* 我的兑换
*
* @param userPointsDetailQuery 查询条件
* @return
*/
@GetMapping("/exchange")
public JsonResult exchange(UserPointsDetailQuery userPointsDetailQuery) {
return userPointsDetailService.exchange(userPointsDetailQuery);
}
}

+ 76
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/domain/UserPointsDetail.java Wyświetl plik

@@ -0,0 +1,76 @@
package com.tuoheng.api.entity.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tuoheng.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
* 用户积分明细表
*
* @author WangHaoran
* @since 2023-05-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("th_user_points_detail")
public class UserPointsDetail extends BaseEntity implements Serializable {

/**
* 租户ID
*/
private Integer tenantId;

/**
* 租户ID
*/
private String openid;

/**
* 用户昵称
*/
private String nickname;

/**
* 积分变动
*/
private Integer pointsChange;

/**
* 积分时间(精确到日)
*/
private Date pointsTime;

/**
* 类型,1增加 2减少
*/
private Integer type;

/**
* 操作人ID
*/
private Integer operatorId;

/**
* 操作人名称
*/
private String operatorName;

/**
* 商铺名称
*/
@TableField(exist = false)
private String shopsName;

/**
* 区域名称
*/
@TableField(exist = false)
private String areaName;
}

+ 24
- 0
tuoheng-api/src/main/java/com/tuoheng/api/entity/request/UserPointsDetailQuery.java Wyświetl plik

@@ -0,0 +1,24 @@
package com.tuoheng.api.entity.request;

import com.tuoheng.common.common.BaseQuery;
import lombok.Data;

/**
* 河流查询
*
* @author WangHaoran
* @since 2021-09-06
*/
@Data
public class UserPointsDetailQuery extends BaseQuery {

/**
* 租户ID
*/
private Integer tenantId;

/**
* 用户openid
*/
private String openid;
}

+ 1
- 1
tuoheng-api/src/main/java/com/tuoheng/api/entity/request/WestreamUserQuery.java Wyświetl plik

@@ -11,7 +11,7 @@ public class WestreamUserQuery {
private Integer tenantId;

/**
*
* 用户openid
*/
private String openid;
}

+ 13
- 0
tuoheng-api/src/main/java/com/tuoheng/api/mapper/UserPointsDetailMapper.java Wyświetl plik

@@ -0,0 +1,13 @@
package com.tuoheng.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.api.entity.domain.UserPointsDetail;

/**
* 用户积分明细表 Mapper 接口
*
* @author WangHaoran
* @since 2023-05-06
*/
public interface UserPointsDetailMapper extends BaseMapper<UserPointsDetail> {
}

+ 16
- 0
tuoheng-api/src/main/java/com/tuoheng/api/service/IUserPointsDetailService.java Wyświetl plik

@@ -0,0 +1,16 @@
package com.tuoheng.api.service;

import com.tuoheng.api.entity.domain.UserPointsDetail;
import com.tuoheng.api.entity.request.UserPointsDetailQuery;
import com.tuoheng.common.common.IBaseService;
import com.tuoheng.common.utils.JsonResult;

/**
* 用户积分明细表 服务类
*
* @author WangHaoran
* @since 2023-05-06
*/
public interface IUserPointsDetailService extends IBaseService<UserPointsDetail> {
JsonResult exchange(UserPointsDetailQuery userPointsDetailQuery);
}

+ 71
- 0
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/UserPointsDetailServiceImpl.java Wyświetl plik

@@ -0,0 +1,71 @@
package com.tuoheng.api.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.api.entity.domain.Merchant;
import com.tuoheng.api.entity.domain.UserPointsDetail;
import com.tuoheng.api.entity.request.UserPointsDetailQuery;
import com.tuoheng.api.mapper.MerchantMapper;
import com.tuoheng.api.mapper.UserPointsDetailMapper;
import com.tuoheng.api.service.IUserPointsDetailService;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 全民护河公告表 服务实现类
*
* @author WangHaoran
* @since 2023-05-06
*/
@Service
public class UserPointsDetailServiceImpl extends BaseServiceImpl<UserPointsDetailMapper, UserPointsDetail> implements IUserPointsDetailService {

@Autowired
UserPointsDetailMapper userPointsDetailMapper;

@Autowired
MerchantMapper merchantMapper;

@Override
public JsonResult exchange(UserPointsDetailQuery query) {
if (null == query.getPage() || null == query.getLimit()) {
return JsonResult.error("分页参数为空!");
}
if (null == query.getTenantId()) {
return JsonResult.error("租户ID为空!");
}
if (StringUtils.isNotEmpty(query.getOpenid())) {
return JsonResult.error("openid为空!");
}

// 获取分页数据
IPage<UserPointsDetail> page = new Page<>(query.getPage(), query.getLimit());
IPage<UserPointsDetail> pageData = userPointsDetailMapper.selectPage(page, new LambdaQueryWrapper<UserPointsDetail>()
.eq(UserPointsDetail::getMark, 1)
.eq(UserPointsDetail::getType, 2)
.eq(UserPointsDetail::getTenantId, query.getTenantId())
.eq(UserPointsDetail::getOpenid,query.getOpenid())
.orderByDesc(UserPointsDetail::getCreateTime));

for (UserPointsDetail record : pageData.getRecords()) {
if(null != record.getOperatorId()){
//查询商铺信息
Merchant merchant = merchantMapper.selectOne(new LambdaQueryWrapper<Merchant>()
.eq(Merchant::getMark, 1)
.eq(Merchant::getUserId, record.getOperatorId()));

if(ObjectUtil.isNotNull(merchant)){
record.setShopsName(merchant.getShopsName());
record.setAreaName(merchant.getAreaName());
}

}
}
return JsonResult.success(pageData);
}
}

Ładowanie…
Anuluj
Zapisz