21 changed files with 492 additions and 27 deletions
-
3demo/audit/src/main/java/com/example/audit/mapper/AuditMapper.java
-
3demo/commons/src/main/java/com/example/commons/domain/entity/Detail.java
-
1demo/commons/src/main/java/com/example/commons/domain/vo/ConsumeDetail.java
-
48demo/commons/src/main/java/com/example/commons/domain/vo/DetailVo.java
-
1demo/commons/src/main/java/com/example/commons/domain/vo/Page.java
-
2demo/commons/src/main/java/com/example/commons/domain/vo/RechargeVo.java
-
22demo/commons/src/main/java/com/example/commons/sevice/ConsumeService.java
-
17demo/commons/src/main/java/com/example/commons/sevice/RefundService.java
-
55demo/consume/src/main/java/com/example/consume/controller/ConsumeController.java
-
59demo/consume/src/main/java/com/example/consume/mapper/ConsumeMapper.java
-
52demo/consume/src/main/java/com/example/consume/service/ConsumeServiceImpl.java
-
15demo/consume/src/main/resources/application.yml
-
2demo/pom.xml
-
24demo/recharge/src/main/java/com/example/recharge/mapper/RateMapper.java
-
2demo/recharge/src/main/java/com/example/recharge/mapper/RechargeMapper.java
-
57demo/refund/src/main/java/com/example/fefund/controller/RefundController.java
-
46demo/refund/src/main/java/com/example/fefund/mapper/RefundMapper.java
-
61demo/refund/src/main/java/com/example/fefund/service/RefundServiceImpl.java
-
15demo/refund/src/main/resources/application.yml
-
12demo/statistics/src/main/java/com/example/statistics/service/DetailServiceImpl.java
@ -0,0 +1,48 @@ |
|||||
|
package com.example.commons.domain.vo; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
public class DetailVo { |
||||
|
private Integer detailId; |
||||
|
private String name; |
||||
|
private String jwcode; |
||||
|
private String area; |
||||
|
private Integer activityId; |
||||
|
private String rechargeWay; |
||||
|
private String goods; |
||||
|
private String consumePlatform; |
||||
|
private String consumeType; |
||||
|
private String refundType; |
||||
|
private String refundGoods; |
||||
|
private Integer contactId; |
||||
|
private String remark; |
||||
|
private Double rechargeCoin; |
||||
|
private Double freeCoin; |
||||
|
private Double taskCoin; |
||||
|
private Integer adminId; |
||||
|
private Integer status; |
||||
|
private String updateType; |
||||
|
private Integer detailFlag; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date createTime; |
||||
|
|
||||
|
//搜索消费时间 |
||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private Date searchStartTime; |
||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
private Date searchEndTime; |
||||
|
|
||||
|
//提交人姓名 |
||||
|
private String adminName; |
||||
|
|
||||
|
//消费金币总数 |
||||
|
private Integer totalCoin; |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.example.commons.sevice; |
||||
|
|
||||
|
import com.example.commons.domain.entity.Admin; |
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.example.commons.domain.entity.User; |
||||
|
import com.example.commons.domain.vo.DetailVo; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface ConsumeService { |
||||
|
//新增消费记录 |
||||
|
int insert(Detail detail); |
||||
|
|
||||
|
User getByUserId(Integer userId); |
||||
|
|
||||
|
Admin getByadminId(Integer adminId); |
||||
|
|
||||
|
List<DetailVo> search(DetailVo detailVo); |
||||
|
|
||||
|
PageInfo<DetailVo> searchForPage(Integer pageNum, Integer pageSize, DetailVo detailVo); |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.example.commons.sevice; |
||||
|
|
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public interface RefundService { |
||||
|
int add(Detail detail) throws Exception; |
||||
|
void edit(Detail newDetail) throws Exception; |
||||
|
Detail selectByDetailId(Integer detailId); |
||||
|
List<Detail> search(Detail detail); |
||||
|
PageInfo<Detail> searchForPage(Integer pageNum, Integer pageSize, Detail detail); |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
package com.example.consume.controller; |
||||
|
|
||||
|
|
||||
|
import com.example.commons.domain.entity.Admin; |
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.example.commons.domain.entity.User; |
||||
|
import com.example.commons.domain.vo.DetailVo; |
||||
|
import com.example.commons.domain.vo.Page; |
||||
|
import com.example.commons.domain.vo.Result; |
||||
|
import com.example.consume.service.ConsumeServiceImpl; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.ObjectUtils; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/consume") |
||||
|
public class ConsumeController { |
||||
|
@Autowired |
||||
|
ConsumeServiceImpl consumeService; |
||||
|
@PostMapping("/add") |
||||
|
public Result add(@RequestParam("userId") Integer userId, @RequestBody Detail detail){ |
||||
|
// try { |
||||
|
System.out.println(userId+"-----------"); |
||||
|
//通过userid获取username,插入到detail |
||||
|
User user=consumeService.getByUserId(userId); |
||||
|
detail.setName(user.getName()); |
||||
|
//添加所属地区 |
||||
|
Admin admin=consumeService.getByadminId(detail.getAdminId()); |
||||
|
detail.setArea(admin.getArea()); |
||||
|
consumeService.insert(detail); |
||||
|
return Result.success(); |
||||
|
// } catch (Exception e) { |
||||
|
// log.warn(Arrays.toString(e.getStackTrace())); |
||||
|
// return Result.error(e.getMessage()); |
||||
|
// } |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@PostMapping("/select") |
||||
|
public Result search(@RequestBody Page detailpage){ |
||||
|
Integer pageNum = detailpage.getPageNum(); |
||||
|
Integer pageSize = detailpage.getPageSize(); |
||||
|
DetailVo detailVo = detailpage.getDetailVo(); |
||||
|
if(ObjectUtils.isEmpty(pageNum)){ |
||||
|
return Result.success(consumeService.search(detailVo)); |
||||
|
} |
||||
|
else { |
||||
|
return Result.success(consumeService.searchForPage(pageNum,pageSize,detailVo)); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package com.example.consume.mapper; |
||||
|
|
||||
|
|
||||
|
import com.example.commons.domain.entity.Admin; |
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.example.commons.domain.entity.User; |
||||
|
import com.example.commons.domain.vo.DetailVo; |
||||
|
import org.apache.ibatis.annotations.*; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface ConsumeMapper { |
||||
|
|
||||
|
//通过id查询user全部信息 |
||||
|
@Select({ |
||||
|
"select * from user where user_id=#{userId}" |
||||
|
}) |
||||
|
User getByUserId(Integer userId); |
||||
|
|
||||
|
//通过id查询admin全部信息 |
||||
|
@Select({ |
||||
|
"select * from admin where admin_id=#{adminId}" |
||||
|
}) |
||||
|
Admin getByadminId(@Param("adminId") Integer adminId); |
||||
|
//新增消费记录 |
||||
|
@Insert({ |
||||
|
"insert into detail", |
||||
|
"(jwcode,name,area,goods,consume_platform,consume_type,remark,recharge_coin,free_coin,task_coin,admin_id,create_time,detail_flag)", |
||||
|
"values", |
||||
|
"(#{jwcode},#{name},#{area},#{goods},'海外金币管理系统','购买商品',#{remark},#{rechargeCoin},#{freeCoin},#{taskCoin},#{adminId},now(),1)" |
||||
|
}) |
||||
|
// 获取自增主键 |
||||
|
@Options(useGeneratedKeys = true,keyColumn = "detail_id",keyProperty = "detailId") |
||||
|
int insert(Detail detail); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//模糊分页查询,查询消费明细 |
||||
|
@Select({ |
||||
|
"<script>", |
||||
|
"select detail.*,admin.name as adminName from detail ", |
||||
|
"inner join admin on detail.admin_id=admin.admin_id ", |
||||
|
"<where>", |
||||
|
"`detail_flag`=1", |
||||
|
"<if test='goods!=null'>and goods like concat('%','#{goods}','%')</if>", |
||||
|
"<if test='consumePlatform!=null'>and consume_platform like concat('%','#{consumePlatform}','%')</if>", |
||||
|
"<if test='consumeType!=null'>and consume_type like concat('%','#{consumeType}','%')</if>", |
||||
|
"<if test='searchStartTime != null and searchEndTime != null'>", |
||||
|
"and create_time between #{searchStartTime} and #{searchEndTime}", |
||||
|
"</if>", |
||||
|
"</where>", |
||||
|
"</script>" |
||||
|
}) |
||||
|
List<DetailVo> select(DetailVo detailVo); |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package com.example.consume.service; |
||||
|
|
||||
|
|
||||
|
import com.example.commons.domain.entity.Admin; |
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.example.commons.domain.entity.User; |
||||
|
import com.example.commons.domain.vo.DetailVo; |
||||
|
import com.example.commons.sevice.ConsumeService; |
||||
|
import com.example.consume.mapper.ConsumeMapper; |
||||
|
|
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class ConsumeServiceImpl implements ConsumeService { |
||||
|
@Autowired |
||||
|
ConsumeMapper consumeMapper; |
||||
|
|
||||
|
@Override |
||||
|
//新增消费记录 |
||||
|
public int insert(Detail detail) { |
||||
|
|
||||
|
//添加表单数据 |
||||
|
return consumeMapper.insert(detail); |
||||
|
} |
||||
|
@Override |
||||
|
public User getByUserId(Integer userId) { |
||||
|
return consumeMapper.getByUserId(userId); |
||||
|
} |
||||
|
@Override |
||||
|
public Admin getByadminId(Integer adminId) { |
||||
|
return consumeMapper.getByadminId(adminId); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public List<DetailVo> search(DetailVo detailVo) { |
||||
|
return consumeMapper.select(detailVo); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public PageInfo<DetailVo> searchForPage(Integer pageNum, Integer pageSize, DetailVo detailVo) { |
||||
|
PageHelper.startPage(pageNum, pageSize); |
||||
|
List<DetailVo> list = consumeMapper.select(detailVo); |
||||
|
return new PageInfo<>(list); |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
server: |
||||
|
port: 10050 |
||||
|
|
||||
|
spring: |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://39.101.133.168:3306/hwgold?serverTimezone=GMT%2b8&serverTimezone=Asia/Shanghai |
||||
|
username: hwgold |
||||
|
password: 'AGX4Z3YMxiCG3GR2' |
||||
|
application: |
||||
|
name: consume |
||||
|
mybatis: |
||||
|
configuration: |
||||
|
map-underscore-to-camel-case: true |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
@ -0,0 +1,57 @@ |
|||||
|
package com.example.fefund.controller; |
||||
|
|
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
|
||||
|
import com.example.commons.domain.vo.Page; |
||||
|
import com.example.commons.domain.vo.Result; |
||||
|
import com.example.commons.sevice.RefundService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.util.ObjectUtils; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/refund") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
@CrossOrigin |
||||
|
public class RefundController { |
||||
|
private final RefundService refundService; |
||||
|
|
||||
|
@PostMapping("/add") |
||||
|
public Result add(@RequestBody Detail detail) { |
||||
|
try { |
||||
|
refundService.add(detail); |
||||
|
return Result.success(); |
||||
|
} catch (Exception e) { |
||||
|
log.warn(Arrays.toString(e.getStackTrace())); |
||||
|
return Result.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/update") |
||||
|
public Result update(@RequestBody Detail newDetail) { |
||||
|
try { |
||||
|
refundService.edit(newDetail); |
||||
|
return Result.success(); |
||||
|
} catch (Exception e) { |
||||
|
log.warn(Arrays.toString(e.getStackTrace())); |
||||
|
return Result.error(e.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/search") |
||||
|
public Result search(@RequestBody Page page) { |
||||
|
Integer pageNum = page.getPageNum(); |
||||
|
Integer pageSize = page.getPageSize(); |
||||
|
Detail detail = page.getDetail(); |
||||
|
|
||||
|
if (ObjectUtils.isEmpty(detail)) { |
||||
|
return Result.success(refundService.search(detail)); |
||||
|
}else{ |
||||
|
return Result.success(refundService.searchForPage(pageNum, pageSize,detail)); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,46 @@ |
|||||
|
package com.example.fefund.mapper; |
||||
|
|
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import org.apache.ibatis.annotations.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface RefundMapper { |
||||
|
|
||||
|
@Insert({ |
||||
|
"insert into detail", |
||||
|
"(jwcord_id,refund_type,refund_goods,recharge_coin,free_coin,task_coin,remark,admin_id,creat_time)", |
||||
|
"values", |
||||
|
"(#{jwcode},#{refundType},#{refundGoods},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now())" |
||||
|
}) |
||||
|
@Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId") |
||||
|
int insert(Detail detail); |
||||
|
|
||||
|
@Update("update detail set detail_flag = 0 where detail_id = #{detailId}") |
||||
|
int update(Integer detailId); |
||||
|
|
||||
|
@Select("select * from detail where detail_id = #{detailId} and detail_flag = 1") |
||||
|
Detail selectByDetailId(Integer detailId); |
||||
|
|
||||
|
|
||||
|
@Select({ |
||||
|
"<script>", |
||||
|
"SELECT d.*, a.area AS adminArea", |
||||
|
"FROM detail d", |
||||
|
"LEFT JOIN admin a ON d.admin_id = a.admin_id", |
||||
|
"WHERE d.detail_flag = 1", |
||||
|
"<where>", |
||||
|
"<if test='jwcode != null'>AND d.jwcode = #{jwcode}</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='rechargeCoin != null'>AND d.recharge_coin = #{rechargeCoin}</if>", |
||||
|
"<if test='freeCoin != null'>AND d.free_coin = #{freeCoin}</if>", |
||||
|
"<if test='taskCoin != null'>AND d.task_coin = #{taskCoin}</if>", |
||||
|
"<if test='remark != null'>AND d.remark LIKE CONCAT('%', #{remark}, '%')</if>", |
||||
|
"<if test='adminId != null'>AND d.admin_id = #{adminId}</if>", |
||||
|
"</where>", |
||||
|
"</script>" |
||||
|
}) |
||||
|
List<Detail> select(Detail detail); |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
package com.example.fefund.service; |
||||
|
|
||||
|
|
||||
|
import com.example.commons.domain.entity.Detail; |
||||
|
import com.example.commons.sevice.RefundService; |
||||
|
import com.example.fefund.mapper.RefundMapper; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
|
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
@RequiredArgsConstructor |
||||
|
@Transactional |
||||
|
@Service |
||||
|
public class RefundServiceImpl implements RefundService { |
||||
|
private final RefundMapper refundMapper; |
||||
|
@Override |
||||
|
public int add(Detail detail) throws Exception { |
||||
|
return refundMapper.insert(detail); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void edit(Detail newDetail) throws Exception { |
||||
|
// 获取旧的明细记录 |
||||
|
Detail oldDetail = refundMapper.selectByDetailId(newDetail.getDetailId()); |
||||
|
|
||||
|
if (oldDetail == null || oldDetail.getDetailFlag() ==0) { |
||||
|
throw new IllegalArgumentException("该记录不存在或已被隐藏!"); |
||||
|
} |
||||
|
|
||||
|
// 软删除旧记录 |
||||
|
refundMapper.update(oldDetail.getDetailId()); |
||||
|
|
||||
|
// 插入新记录 |
||||
|
newDetail.setDetailId(null); // 清空 ID,让其自动生成 |
||||
|
newDetail.setDetailFlag(1); // 确保新记录未被删除 |
||||
|
refundMapper.insert(newDetail); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Detail selectByDetailId(Integer detailId) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Detail> search(Detail detail) { |
||||
|
return refundMapper.select(detail); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public PageInfo<Detail> searchForPage(Integer pageNum, Integer pageSize, Detail detail) { |
||||
|
PageHelper.startPage(pageNum, pageSize); |
||||
|
List<Detail> list = refundMapper.select(detail); |
||||
|
return new PageInfo<>(list); |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
server: |
||||
|
port: 10060 |
||||
|
|
||||
|
spring: |
||||
|
datasource: |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 |
||||
|
username: hwgold |
||||
|
password: 'AGX4Z3YMxiCG3GR2' |
||||
|
application: |
||||
|
name: refund |
||||
|
mybatis: |
||||
|
configuration: |
||||
|
map-underscore-to-camel-case: true |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
Write
Preview
Loading…
Cancel
Save
Reference in new issue