Browse Source

汇率模块和退款模块完善

recharge_rate-and-refund-zlp
zhangluping 5 months ago
parent
commit
cd6293a5c4
  1. 2
      gold-system/.idea/compiler.xml
  2. 2
      gold-system/.idea/encodings.xml
  3. 1
      gold-system/.idea/misc.xml
  4. 22
      gold-system/demo/commons/src/main/java/com/example/commons/domain/entity/Statistics.java
  5. 1
      gold-system/demo/commons/src/main/java/com/example/commons/sevice/RefundService.java
  6. 11
      gold-system/demo/commons/src/main/java/com/example/commons/sevice/StatisticsService.java
  7. 2
      gold-system/demo/pom.xml
  8. 1
      gold-system/demo/refund/src/main/java/org/example/refund/controller/RefundController.java
  9. 18
      gold-system/demo/refund/src/main/java/org/example/refund/mapper/RefundMapper.java
  10. 4
      gold-system/demo/refund/src/main/java/org/example/refund/service/RefundServiceImpl.java
  11. 33
      gold-system/demo/statistics/.gitignore
  12. 73
      gold-system/demo/statistics/pom.xml
  13. 13
      gold-system/demo/statistics/src/main/java/org/example/statistics/StatisticsApplication.java
  14. 24
      gold-system/demo/statistics/src/main/java/org/example/statistics/controller/StatisticsController.java
  15. 38
      gold-system/demo/statistics/src/main/java/org/example/statistics/mapper/StatisticsMapper.java
  16. 29
      gold-system/demo/statistics/src/main/java/org/example/statistics/service/StatisticsServiceImpl.java
  17. 15
      gold-system/demo/statistics/src/main/resources/application.yml
  18. 6
      gold-system/demo/statistics/src/main/resources/static/index.html
  19. 13
      gold-system/demo/statistics/src/test/java/org/example/statistics/StatisticsApplicationTests.java

2
gold-system/.idea/compiler.xml

@ -10,6 +10,7 @@
<module name="user" /> <module name="user" />
<module name="commons" /> <module name="commons" />
<module name="refund" /> <module name="refund" />
<module name="statistics" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
</component> </component>
@ -18,6 +19,7 @@
<module name="commons" options="-parameters" /> <module name="commons" options="-parameters" />
<module name="recharge" options="-parameters" /> <module name="recharge" options="-parameters" />
<module name="refund" options="-parameters" /> <module name="refund" options="-parameters" />
<module name="statistics" options="-parameters" />
<module name="user" options="-parameters" /> <module name="user" options="-parameters" />
</option> </option>
</component> </component>

2
gold-system/.idea/encodings.xml

@ -7,6 +7,8 @@
<file url="file://$PROJECT_DIR$/demo/refund/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/demo/refund/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/demo/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/demo/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/demo/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/demo/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/demo/statistics/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/demo/statistics/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/demo/user/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/demo/user/src/main/java" charset="UTF-8" />
</component> </component>
</project> </project>

1
gold-system/.idea/misc.xml

@ -6,6 +6,7 @@
<list> <list>
<option value="$PROJECT_DIR$/demo/pom.xml" /> <option value="$PROJECT_DIR$/demo/pom.xml" />
<option value="$PROJECT_DIR$/demo/refund/pom.xml" /> <option value="$PROJECT_DIR$/demo/refund/pom.xml" />
<option value="$PROJECT_DIR$/demo/statistics/pom.xml" />
</list> </list>
</option> </option>
</component> </component>

22
gold-system/demo/commons/src/main/java/com/example/commons/domain/entity/Statistics.java

@ -0,0 +1,22 @@
package com.example.commons.domain.entity;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
public class Statistics {
private BigDecimal rechargeSumCoin;
private BigDecimal freeSumCoin;
private BigDecimal taskSumCoin;
private BigDecimal totalSumCoin;
private BigDecimal rechargeYesterdaySumCoin;
private BigDecimal freeYesterdaySumCoin;
private BigDecimal taskYesterdaySumCoin;
private BigDecimal totalYesterdaySumCoin;
private Integer rechargeCount;
private Integer rechargeCountThisWeek ;
private Integer rechargeCountLastWeek ;
}

1
gold-system/demo/commons/src/main/java/com/example/commons/sevice/RefundService.java

@ -10,6 +10,7 @@ import java.util.List;
@Service @Service
public interface RefundService { public interface RefundService {
int add(Detail detail) ; int add(Detail detail) ;
int addAudit(Detail detail);
void edit(Detail newDetail) ; void edit(Detail newDetail) ;
int softDelete(Integer detailId) ; int softDelete(Integer detailId) ;
Detail selectByDetailId(Integer detailId); Detail selectByDetailId(Integer detailId);

11
gold-system/demo/commons/src/main/java/com/example/commons/sevice/StatisticsService.java

@ -0,0 +1,11 @@
package com.example.commons.sevice;
import com.example.commons.domain.entity.Statistics;
import org.springframework.stereotype.Service;
@Service
public interface StatisticsService {
int totalYearCoin();
int yesterdayNewCoin();
int yearRechargeCount();
}

2
gold-system/demo/pom.xml

@ -21,6 +21,8 @@
<module>recharge</module> <module>recharge</module>
<module>commons</module> <module>commons</module>
<module>user</module> <module>user</module>
<module>refund</module>
<module>statistics</module>
</modules> </modules>
<properties> <properties>

1
gold-system/demo/refund/src/main/java/org/example/refund/controller/RefundController.java

@ -24,6 +24,7 @@ public class RefundController {
public Result add(@RequestBody Detail detail) { public Result add(@RequestBody Detail detail) {
// try { // try {
refundService.add(detail); refundService.add(detail);
refundService.addAudit(detail);
return Result.success(); return Result.success();
// } catch (Exception e) { // } catch (Exception e) {
// log.warn(Arrays.toString(e.getStackTrace())); // log.warn(Arrays.toString(e.getStackTrace()));

18
gold-system/demo/refund/src/main/java/org/example/refund/mapper/RefundMapper.java

@ -10,13 +10,21 @@ public interface RefundMapper {
@Insert({ @Insert({
"insert into detail", "insert into detail",
"(jwcode,refund_type,refund_goods,recharge_coin,free_coin,task_coin,remark,admin_id,create_time)",
"(jwcode,refund_type,refund_goods,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type)",
"values", "values",
"(#{jwcode},#{refundType},#{refundGoods},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now())"
"(#{jwcode},#{refundType},#{refundGoods},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),#{updateType})"
}) })
@Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId") @Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId")
int insert(Detail detail); int insert(Detail detail);
@Select({
"insert into audit",
"(jwcode,refund_id,admin_id,create_time,detail_id)",
"values",
"(,#{jwcode},#{refundId},#{adminId},now(),#{detailId})"
})
int insertAudit(Detail detail);
@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);
@ -34,16 +42,16 @@ public interface RefundMapper {
"LEFT JOIN admin a ON d.admin_id = a.admin_id", "LEFT JOIN admin a ON d.admin_id = a.admin_id",
"LEFT JOIN user u ON d.jwcode = u.jwcode", "LEFT JOIN user u ON d.jwcode = u.jwcode",
"LEFT JOIN audit au ON d.detail_id = au.refund_id", "LEFT JOIN audit au ON d.detail_id = au.refund_id",
"WHERE d.detail_flag = 1",
"WHERE d.detail_flag = 1 and update_type ='退款'",
"<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>", "<if test='jwcode != null'>AND d.jwcode = #{jwcode}</if>",
"<if test='refundType != null'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>", "<if test='refundType != null'>AND d.refund_type LIKE CONCAT('%', #{refundType}, '%')</if>",
"<if test='refundGoods != null'>AND d.refund_goods = #{refundGoods}</if>",
"<if test='refundGoods != null'>AND d.refund_goods LIKE CONCAT('%', #{refundGoods}, '%')</if>",
"<if test='rechargeCoin != null'>AND d.recharge_coin = #{rechargeCoin}</if>", "<if test='rechargeCoin != null'>AND d.recharge_coin = #{rechargeCoin}</if>",
"<if test='freeCoin != null'>AND d.free_coin = #{freeCoin}</if>", "<if test='freeCoin != null'>AND d.free_coin = #{freeCoin}</if>",
"<if test='taskCoin != null'>AND d.task_coin = #{taskCoin}</if>", "<if test='taskCoin != null'>AND d.task_coin = #{taskCoin}</if>",
"<if test='remark != null'>AND d.remark LIKE CONCAT('%', #{remark}, '%')</if>", "<if test='remark != null'>AND d.remark LIKE CONCAT('%', #{remark}, '%')</if>",
"<if test='adminId != null'>AND d.admin_id = #{adminId}</if>", "<if test='adminId != null'>AND d.admin_id = #{adminId}</if>",
"<if test='adminArea != null'>AND a.area = #{adminArea}</if>", // admin表字段过滤
"<if test='adminArea != null'>AND a.area LIKE CONCAT('%', #{adminArea}, '%')</if>", // admin表字段过滤
"<if test='adminName != null'>AND a.name LIKE CONCAT('%', #{adminName}, '%')</if>", // admin表字段过滤 "<if test='adminName != null'>AND a.name LIKE CONCAT('%', #{adminName}, '%')</if>", // admin表字段过滤
"<if test='userName != null'>AND u.name LIKE CONCAT('%', #{userName}, '%')</if>", // user表字段过滤 "<if test='userName != null'>AND u.name LIKE CONCAT('%', #{userName}, '%')</if>", // user表字段过滤
"<if test='auditStatus != null'>AND au.status = #{auditStatus}</if>", // audit 表字段过滤 "<if test='auditStatus != null'>AND au.status = #{auditStatus}</if>", // audit 表字段过滤

4
gold-system/demo/refund/src/main/java/org/example/refund/service/RefundServiceImpl.java

@ -22,6 +22,10 @@ public class RefundServiceImpl implements RefundService {
return refundMapper.insert(detail); return refundMapper.insert(detail);
} }
@Override
public int addAudit(Detail detail) {
return refundMapper.insertAudit(detail);
}
//自动软删除数据加更新数据 //自动软删除数据加更新数据
@Override @Override

33
gold-system/demo/statistics/.gitignore

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

73
gold-system/demo/statistics/pom.xml

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>statistics</artifactId>
<version>0.0.1</version>
<name>statistics</name>
<description>statistics</description>
<parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>commons</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

13
gold-system/demo/statistics/src/main/java/org/example/statistics/StatisticsApplication.java

@ -0,0 +1,13 @@
package org.example.statistics;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class StatisticsApplication {
public static void main(String[] args) {
SpringApplication.run(StatisticsApplication.class, args);
}
}

24
gold-system/demo/statistics/src/main/java/org/example/statistics/controller/StatisticsController.java

@ -0,0 +1,24 @@
package org.example.statistics.controller;
import com.example.commons.domain.vo.Result;
import com.example.commons.sevice.StatisticsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/statistics")
@RequiredArgsConstructor
@Slf4j
@CrossOrigin
public class StatisticsController {
private final StatisticsService statisticsService;
@PostMapping
public Result count(){
return Result.success(statisticsService.totalYearCoin());
}
}

38
gold-system/demo/statistics/src/main/java/org/example/statistics/mapper/StatisticsMapper.java

@ -0,0 +1,38 @@
package org.example.statistics.mapper;
import com.example.commons.domain.entity.Statistics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface StatisticsMapper {
//全年累计金币数
@Select("SELECT SUM(recharge_coin) AS rechargeSumCoin, " +
" SUM(free_coin) AS freeSumCoin, " +
" SUM(task_coin) AS taskSumCoin, " +
" (SUM(recharge_coin) + SUM(free_coin) + SUM(task_coin)) AS totalSumCoin " +
"FROM `detail` " +
"WHERE update_type = '充值' " +
" AND create_time >= '2024-01-01' " +
" AND create_time < NOW()")
int totalYearCoin();
//昨日新增
@Select("SELECT SUM(recharge_coin) AS rechargeYesterdaySumCoin, " +
" SUM(free_coin) AS freeYesterdaySumCoin, " +
" SUM(task_coin) AS taskYesterdaySumCoin, " +
" (SUM(recharge_coin) + SUM(free_coin) + SUM(task_coin)) AS totalYesterdaySumCoin " +
"FROM `detail` " +
"WHERE update_type = '充值' " +
" AND create_time >= CURDATE() - INTERVAL 1 DAY " +
" AND create_time < CURDATE()")
int yesterdayNewCoin();
//全年累计充值人数
@Select("SELECT COUNT(DISTINCT jwcode) AS rechargeCount " +
"FROM `detail` " +
"WHERE update_type = '充值' " +
" AND create_time >= '2024-01-01' " +
" AND create_time < NOW()")
int yearRechargeCount();
}

29
gold-system/demo/statistics/src/main/java/org/example/statistics/service/StatisticsServiceImpl.java

@ -0,0 +1,29 @@
package org.example.statistics.service;
import com.example.commons.domain.entity.Statistics;
import com.example.commons.sevice.StatisticsService;
import lombok.RequiredArgsConstructor;
import org.example.statistics.mapper.StatisticsMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@RequiredArgsConstructor
@Transactional
@Service
public class StatisticsServiceImpl implements StatisticsService {
private final StatisticsMapper statisticsMapper;
@Override
public int totalYearCoin() {
return statisticsMapper.totalYearCoin();
}
@Override
public int yesterdayNewCoin() {
return statisticsMapper.yesterdayNewCoin();
}
@Override
public int yearRechargeCount() {
return statisticsMapper.yearRechargeCount();
}
}

15
gold-system/demo/statistics/src/main/resources/application.yml

@ -0,0 +1,15 @@
server:
port: 10070
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?&serverTimezone=Asia/Shanghai
username: hwgold
password: 'AGX4Z3YMxiCG3GR2'
application:
name: statistics
mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

6
gold-system/demo/statistics/src/main/resources/static/index.html

@ -0,0 +1,6 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

13
gold-system/demo/statistics/src/test/java/org/example/statistics/StatisticsApplicationTests.java

@ -0,0 +1,13 @@
package org.example.statistics;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class StatisticsApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save