Browse Source

后端整合模块

detached
huangqizhen 5 months ago
parent
commit
f86b12bcb6
  1. 41
      src/main/java/com/example/demo/controller/AuditController.java
  2. 13
      src/main/java/com/example/demo/controller/RefundController.java
  3. 4
      src/main/java/com/example/demo/domain/entity/Audit.java
  4. 3
      src/main/java/com/example/demo/domain/entity/Detail.java
  5. 1
      src/main/java/com/example/demo/domain/entity/Product.java
  6. 2
      src/main/java/com/example/demo/domain/entity/Rate.java
  7. 1
      src/main/java/com/example/demo/domain/entity/Recharge.java
  8. 2
      src/main/java/com/example/demo/domain/entity/User.java
  9. 1
      src/main/java/com/example/demo/domain/vo/ConsumeDetail.java
  10. 2
      src/main/java/com/example/demo/domain/vo/DetailVo.java
  11. 1
      src/main/java/com/example/demo/domain/vo/Page.java
  12. 2
      src/main/java/com/example/demo/domain/vo/RechargeVo.java
  13. 2
      src/main/java/com/example/demo/domain/vo/Statistics.java
  14. 2
      src/main/java/com/example/demo/domain/vo/Statisticss.java
  15. 2
      src/main/java/com/example/demo/domain/vo/SumCoin.java
  16. 2
      src/main/java/com/example/demo/domain/vo/UserVo.java
  17. 4
      src/main/java/com/example/demo/mapper/ConsumeMapper.java
  18. 4
      src/main/java/com/example/demo/mapper/DetailMapper.java
  19. 9
      src/main/java/com/example/demo/mapper/RefundMapper.java
  20. 5
      src/main/java/com/example/demo/mapper/UserMapper.java
  21. 8
      src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java
  22. 1
      src/main/java/com/example/demo/sevice/RefundService.java

41
src/main/java/com/example/demo/controller/AuditController.java

@ -2,23 +2,31 @@ package com.example.demo.controller;
import com.example.demo.domain.entity.Audit; import com.example.demo.domain.entity.Audit;
import com.example.demo.domain.entity.Detail;
import com.example.demo.domain.entity.User;
import com.example.demo.domain.vo.Page; import com.example.demo.domain.vo.Page;
import com.example.demo.domain.vo.Result; import com.example.demo.domain.vo.Result;
import com.example.demo.mapper.DetailMapper;
import com.example.demo.mapper.UserMapper;
import com.example.demo.sevice.AuditService; import com.example.demo.sevice.AuditService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
@RestController @RestController
@RequestMapping("/audit/audit") @RequestMapping("/audit/audit")
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@Transactional
@CrossOrigin @CrossOrigin
public class AuditController { public class AuditController {
private UserMapper userMapper;
private DetailMapper detailMapper;
private final AuditService auditService; private final AuditService auditService;
@PostMapping("/add") @PostMapping("/add")
public Result add(@RequestBody Audit audit){ public Result add(@RequestBody Audit audit){
@ -32,13 +40,34 @@ public class AuditController {
} }
@PostMapping("/edit") @PostMapping("/edit")
public Result edit(@RequestBody Audit audit){ public Result edit(@RequestBody Audit audit){
try {
//先执行auditService.edit(audit);
//然后创建一个类去接收这个audit如果status=1
//根据退款ID找到detail表中的记录获取到他的三种金币
//把金币加到user表中对应的金币中
auditService.edit(audit); auditService.edit(audit);
return Result.success();
}catch (Exception e){
log.warn(Arrays.toString(e.getStackTrace()));
return Result.error(e.getMessage());
if(audit.getStatus() == 1 && audit.getRefundId()!=null){
Detail detail = detailMapper.selectByRefundId(audit.getRefundId());
BigDecimal rechargeCoin = detail.getRechargeCoin();
BigDecimal taskCoin = detail.getTaskCoin();
BigDecimal freeCoin = detail.getFreeCoin();
User user = userMapper.selectByJwcode(detail.getJwcode());
user.setBuyJb(user.getBuyJb().add(rechargeCoin));
user.setCoreJb(user.getCoreJb().add(taskCoin));
user.setFree6(user.getFree6().add(freeCoin));
userMapper.update(user);
} }
return Result.success();
//
// try {
// auditService.edit(audit);
// return Result.success();
// }catch (Exception e){
// log.warn(Arrays.toString(e.getStackTrace()));
// return Result.error(e.getMessage());
// }
} }
@PostMapping @PostMapping
public Result search(@RequestBody Page page){ public Result search(@RequestBody Page page){

13
src/main/java/com/example/demo/controller/RefundController.java

@ -64,13 +64,24 @@ public class RefundController {
} }
@PostMapping("/searchByJWCODE") @PostMapping("/searchByJWCODE")
public Result searchByOrderCode(@RequestParam String jwcode) {
public Result searchByJWCODE(@RequestParam String jwcode) {
Detail detail = refundService.selectByJWCODE(jwcode); Detail detail = refundService.selectByJWCODE(jwcode);
// 检查返回的结果是否为空或无效 // 检查返回的结果是否为空或无效
if (detail == null || ObjectUtils.isEmpty(detail.getOrderCode())) { if (detail == null || ObjectUtils.isEmpty(detail.getOrderCode())) {
return Result.error("该订单不存在:"); return Result.error("该订单不存在:");
} }
// 成功时返回包含订单详情的数据
return Result.success(detail);
}
@PostMapping("/searchByOrderCode")
public Result searchByOrderCode(@RequestParam String orderCode) {
Detail detail = refundService.selectByOrderCode(orderCode);
// 检查返回的结果是否为空或无效
if (detail == null || ObjectUtils.isEmpty(detail.getOrderCode())) {
return Result.error("该订单不存在:");
}
// 成功时返回包含订单详情的数据 // 成功时返回包含订单详情的数据
return Result.success(detail); return Result.success(detail);

4
src/main/java/com/example/demo/domain/entity/Audit.java

@ -15,7 +15,7 @@ public class Audit {
private Integer rechargeId; private Integer rechargeId;
private Integer refundId; private Integer refundId;
private Integer adminId; private Integer adminId;
private String status;
private Integer status;
private Integer AuditFlag; private Integer AuditFlag;
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
@ -24,4 +24,6 @@ public class Audit {
private Date endDate; private Date endDate;
private String reson; private String reson;
private Integer detailId; private Integer detailId;
private String token;
} }

3
src/main/java/com/example/demo/domain/entity/Detail.java

@ -58,4 +58,7 @@ public class Detail implements Serializable {
private String productName; private String productName;
private Integer refundId; private Integer refundId;
private BigDecimal allCoin;
private String token;
} }

1
src/main/java/com/example/demo/domain/entity/Product.java

@ -22,5 +22,6 @@ public class Product {
private String productFlag; private String productFlag;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime; private LocalDateTime createTime;
private String token;
} }

2
src/main/java/com/example/demo/domain/entity/Rate.java

@ -22,4 +22,6 @@ public class Rate {
private Integer adminId; private Integer adminId;
private String adminName; private String adminName;
private String updateId; private String updateId;
private String token;
} }

1
src/main/java/com/example/demo/domain/entity/Recharge.java

@ -32,5 +32,6 @@ public class Recharge {
private Date startDate; private Date startDate;
private Date endDate; private Date endDate;
private String orderCode; private String orderCode;
private String token;
} }

2
src/main/java/com/example/demo/domain/entity/User.java

@ -31,4 +31,6 @@ public class User {
private BigDecimal free6; private BigDecimal free6;
private BigDecimal free12; private BigDecimal free12;
private Date lastTime; private Date lastTime;
private String token;
} }

1
src/main/java/com/example/demo/domain/vo/ConsumeDetail.java

@ -39,5 +39,6 @@ public class ConsumeDetail {
private Date startDate; private Date startDate;
private Date endDate; private Date endDate;
private Integer auditId; private Integer auditId;
private String token;
} }

2
src/main/java/com/example/demo/domain/vo/DetailVo.java

@ -53,4 +53,6 @@ public class DetailVo {
private String userName; private String userName;
private Date startDate; private Date startDate;
private Date endDate; private Date endDate;
private String token;
} }

1
src/main/java/com/example/demo/domain/vo/Page.java

@ -25,6 +25,7 @@ public class Page implements Serializable {
private DetailVo detailVo; private DetailVo detailVo;
private Admin admin; private Admin admin;
public Integer getPageNum() { public Integer getPageNum() {
return pageNum; return pageNum;
} }

2
src/main/java/com/example/demo/domain/vo/RechargeVo.java

@ -38,4 +38,6 @@ public class RechargeVo {
private String reson; private String reson;
private String name; private String name;
private Integer auditId; private Integer auditId;
private String token;
} }

2
src/main/java/com/example/demo/domain/vo/Statistics.java

@ -42,5 +42,7 @@ public class Statistics {
private String subject; private String subject;
private String consumePlatform; private String consumePlatform;
private Integer firstRechargeCountYesterday; private Integer firstRechargeCountYesterday;
private String token;
} }

2
src/main/java/com/example/demo/domain/vo/Statisticss.java

@ -15,4 +15,6 @@ public class Statisticss {
private List<Statistics> HomilyChartSum; private List<Statistics> HomilyChartSum;
private List<Statistics> HomilyLinkSum; private List<Statistics> HomilyLinkSum;
private String token;
} }

2
src/main/java/com/example/demo/domain/vo/SumCoin.java

@ -72,4 +72,6 @@ public class SumCoin {
private BigDecimal totalRecharge; private BigDecimal totalRecharge;
private BigDecimal totalFree; private BigDecimal totalFree;
private BigDecimal totalTask; private BigDecimal totalTask;
private String token;
} }

2
src/main/java/com/example/demo/domain/vo/UserVo.java

@ -26,6 +26,6 @@ public class UserVo {
private BigDecimal free12; private BigDecimal free12;
private BigDecimal coreJb; private BigDecimal coreJb;
private BigDecimal buyJb ; private BigDecimal buyJb ;
private String token;
} }

4
src/main/java/com/example/demo/mapper/ConsumeMapper.java
File diff suppressed because it is too large
View File

4
src/main/java/com/example/demo/mapper/DetailMapper.java

@ -24,9 +24,9 @@ public interface DetailMapper {
@Options(useGeneratedKeys = true,keyColumn = "detail_id",keyProperty = "detailId") @Options(useGeneratedKeys = true,keyColumn = "detail_id",keyProperty = "detailId")
int add(Detail detail); int add(Detail detail);
@Select({ @Select({
"SELECT * from detail where detail =#{detail}"
"SELECT * from detail where detail_id =#{detailId}"
}) })
Detail selectById(Integer id);
Detail selectByRefundId(Integer detail_id);
@Select({ @Select({
"<script>", "<script>",
"select detail.*,admin.name,admin.area,user.name as uname,audit.status from detail", "select detail.*,admin.name,admin.area,user.name as uname,audit.status from detail",

9
src/main/java/com/example/demo/mapper/RefundMapper.java

@ -38,13 +38,20 @@ public interface RefundMapper {
// Detail selectByOrderCode(@Param("orderCode") String orderCode); // Detail selectByOrderCode(@Param("orderCode") String orderCode);
//根据订单号查询
//根据精网号查询
@Select("SELECT d.*, p.name AS productName " + @Select("SELECT d.*, p.name AS productName " +
"FROM detail d " + "FROM detail d " +
"LEFT JOIN product p ON d.product_id = p.product_id " + "LEFT JOIN product p ON d.product_id = p.product_id " +
"WHERE d.jwcode = #{jwcode} AND d.detail_flag = 1 AND d.refund_flag = 1") "WHERE d.jwcode = #{jwcode} AND d.detail_flag = 1 AND d.refund_flag = 1")
Detail selectByJWCODE(String jwcode); Detail selectByJWCODE(String jwcode);
//根据订单号查询
@Select("SELECT d.*, p.name AS productName " +
"FROM detail d " +
"LEFT JOIN product p ON d.product_id = p.product_id " +
"WHERE d.order_code = #{orderCode} AND d.detail_flag = 1 AND d.refund_flag = 1")
Detail selectByOrderCode(String OrderCode);
//软删除 //软删除
@Update("update detail set detail_flag = 0 where detail_id = #{detailId}") @Update("update detail set detail_flag = 0 where detail_id = #{detailId}")
int update(@Param("detailId") Integer detailId); int update(@Param("detailId") Integer detailId);

5
src/main/java/com/example/demo/mapper/UserMapper.java

@ -82,7 +82,10 @@ public interface UserMapper {
}) })
int update(User user); int update(User user);
// //去掉免费金币先去6个月再去12月
@Select({
"select * from user where jwcode=#{jwode}"
})
User selectByJwcode(String jwcode);// //去掉免费金币先去6个月再去12月
// @Update({ // @Update({
// "<script>", // "<script>",
// "update user", // "update user",

8
src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java

@ -86,6 +86,11 @@ public class RefundServiceImpl implements RefundService {
} }
@Override @Override
public Detail selectByOrderCode(String orderCode) {
return refundMapper.selectByOrderCode(orderCode);
}
@Override
public Detail selectByJWCODE(String jwcode) { public Detail selectByJWCODE(String jwcode) {
return refundMapper.selectByJWCODE(jwcode); return refundMapper.selectByJWCODE(jwcode);
} }
@ -94,11 +99,14 @@ public class RefundServiceImpl implements RefundService {
public Detail selectByDetailId(Integer detailId) { public Detail selectByDetailId(Integer detailId) {
return refundMapper.selectByDetailId(detailId); return refundMapper.selectByDetailId(detailId);
} }
@Cacheable(key="#root.method.name") @Cacheable(key="#root.method.name")
@Override @Override
public List<Detail> search(Detail detail) { public List<Detail> search(Detail detail) {
return refundMapper.select(detail); return refundMapper.select(detail);
} }
@Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #detail.hashCode() ") @Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #detail.hashCode() ")
@Override @Override
public PageInfo<Detail> searchForPage(Integer pageNum, Integer pageSize, Detail detail) { public PageInfo<Detail> searchForPage(Integer pageNum, Integer pageSize, Detail detail) {

1
src/main/java/com/example/demo/sevice/RefundService.java

@ -15,6 +15,7 @@ public interface RefundService {
int update(Integer contactId) ; int update(Integer contactId) ;
boolean existsByContactId(Integer contactId); boolean existsByContactId(Integer contactId);
int softDelete(Integer detailId) ; int softDelete(Integer detailId) ;
Detail selectByOrderCode(String orderCode) ;
Detail selectByJWCODE(String jwcode) ; Detail selectByJWCODE(String jwcode) ;
Detail selectByDetailId(Integer detailId); Detail selectByDetailId(Integer detailId);
List<Detail> search(Detail detail); List<Detail> search(Detail detail);

Loading…
Cancel
Save