积分记录管理端

This commit is contained in:
wuchunlei
2024-05-13 16:05:19 +08:00
parent 1d8698a041
commit a455324bff
3 changed files with 54 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ public class DataMigrationUtil extends Thread {
// courseCatalogue();
// courseCatalogueChapter();
// courseCatalogueChapterVideo();
user();//用的都是copy表里的数据
// user();//用的都是copy表里的数据
}

View File

@@ -45,4 +45,7 @@ public class JfTransactionDetails implements Serializable {
@TableLogic
private Integer delFlag;
@TableField(exist = false)
private MyUserEntity user;
}

View File

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.JfTransactionDetails;
import com.peanut.modules.common.entity.MyUserEntity;
import com.peanut.modules.master.service.JfTransactionDetailsService;
import com.peanut.modules.master.service.MyUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
@@ -25,15 +29,25 @@ public class JfTransactionDetailsController {
@Autowired
private JfTransactionDetailsService jfService;
@Autowired
private MyUserService userService;
/**
* 列表
*/
@RequestMapping("/listByPage")
public R listByPage(@RequestBody Map<String, Object> params) {
MPJLambdaWrapper<JfTransactionDetails> wrapper = new MPJLambdaWrapper();
wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,JfTransactionDetails::getUserId);
wrapper.selectAll(JfTransactionDetails.class);
if (params.containsKey("userId")&& StringUtils.isNotEmpty(params.get("userId").toString())) {
wrapper.eq(JfTransactionDetails::getUserId,params.get("userId"));
}
if (params.containsKey("userName")&& StringUtils.isNotEmpty(params.get("userName").toString())) {
wrapper.like(MyUserEntity::getName,params.get("userName"));
wrapper.like(MyUserEntity::getNickname,params.get("userName"));
}
if (params.containsKey("actType")&&StringUtils.isNotEmpty(params.get("actType").toString())) {
wrapper.eq(JfTransactionDetails::getActType,params.get("actType"));
}
@@ -41,9 +55,16 @@ public class JfTransactionDetailsController {
wrapper.like(JfTransactionDetails::getRemark,params.get("remark"));
}
wrapper.orderByDesc(JfTransactionDetails::getCreateTime);
Page<JfTransactionDetails> records = jfService.page(new Page<>(
Page<JfTransactionDetails> page = jfService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
return R.ok().put("result", records);
List<JfTransactionDetails> records = page.getRecords();
if (records.size() > 0) {
for (int i=0;i<records.size();i++) {
records.get(i).setUser(userService.getById(records.get(i).getUserId()));
}
}
page.setRecords(records);
return R.ok().put("result", page);
}
@RequestMapping("/getJfTransactionDetailsById")
@@ -51,6 +72,33 @@ public class JfTransactionDetailsController {
return R.ok().put("result", jfService.getById(id));
}
//冲扣积分
@RequestMapping("/saveJfTransactionDetails")
public R saveJfTransactionDetails(@RequestBody Map<String, Object> params) {
JfTransactionDetails jf = new JfTransactionDetails();
MyUserEntity user = userService.getById(params.get("userId").toString());
BigDecimal changeAmount = new BigDecimal(params.get("changeAmount").toString());
String actType = params.get("actType").toString();
if (actType.equals("0")) {
jf.setActType(0);
user.setJf(user.getJf().add(changeAmount));
}else {
jf.setActType(1);
user.setJf(user.getJf().subtract(changeAmount));
}
userService.updateById(user);
jf.setUserId(user.getId());
jf.setChangeAmount(changeAmount);
jf.setRemark(params.get("remark").toString());
jf.setUserBalance(user.getJf());
jfService.save(jf);
return R.ok();
}
@RequestMapping("/saveOrUpdateJfTransactionDetails")
public R saveOrUpdateJfTransactionDetails(@RequestBody JfTransactionDetails jf) {
jfService.saveOrUpdate(jf);