培训班报表更改
This commit is contained in:
@@ -121,10 +121,10 @@ public class TrainingClassServiceImpl extends ServiceImpl<TrainingClassDao, Trai
|
||||
trainingToUser.setTrainingId(buyOrder.getTrainingClassId());
|
||||
trainingToUser.setUserId(buyOrder.getUserId());
|
||||
trainingToUser.setOrderSn(buyOrder.getOrderSn());
|
||||
trainingToUser.setIdentity(buyOrder.getTrainingClassIdentity());
|
||||
trainingToUser.setIdentity(buyOrder.getTrainingClassIdentity().substring(0,buyOrder.getTrainingClassIdentity().indexOf(":")));
|
||||
trainingToUser.setType("订单");
|
||||
trainingToUser.setFee(buyOrder.getRealMoney());
|
||||
trainingToUser.setJf(buyOrder.getRealMoney());
|
||||
trainingToUser.setJf(buyOrder.getJfDeduction());
|
||||
trainingToUser.setPayType("1".equals(buyOrder.getPaymentMethod())?"微信":("2".equals(buyOrder.getPaymentMethod())?"支付宝":"天医币"));
|
||||
trainingToUserService.save(trainingToUser);
|
||||
}
|
||||
|
||||
@@ -67,12 +67,13 @@ public class StatisticsController {
|
||||
.leftJoin("pay_wechat_order pwo on pwo.order_sn = t.order_sn")
|
||||
.leftJoin("pay_zfb_order pzo on pzo.relevanceOid = t.order_sn and pzo.trade_no is not null")
|
||||
.select("""
|
||||
t.create_time,t1.name,t1.tel,t1.email,t2.title,t.identity,t.order_sn,pwo.order_id wxNo,pzo.trade_no zfbNo,t.fee+t.abroad_fee+t.jf total,
|
||||
t.create_time,t1.name,t1.tel,t1.email,t2.title,t.identity,t.order_sn,if(t.type='管理员' and t.pay_type='微信',t.order_sn,pwo.order_id) wxNo,
|
||||
if(t.type='管理员' and t.pay_type='支付宝',t.order_sn,pzo.trade_no) zfbNo,t.fee+t.abroad_fee total,
|
||||
IF(t.pay_type='微信',t.fee,0) 微信,
|
||||
IF(t.pay_type='支付宝',t.fee,0) 支付宝,
|
||||
IF(t.pay_type='天医币',t.fee,0) 天医币,
|
||||
IF(t.pay_type='银行',t.fee,0) 银行,
|
||||
IF(t.pay_type='海外',t.fee,0) 海外,
|
||||
IF(t.pay_type='海外',t.abroad_fee,0) 海外,
|
||||
IF(t.pay_type='赠送',t.fee,0) 赠送,t.jf,t.remark
|
||||
""")
|
||||
.apply("DATE_FORMAT(t.create_time,'%Y-%m') = '"+params.get("date")+"'")
|
||||
@@ -153,7 +154,7 @@ public class StatisticsController {
|
||||
public R getTrainingClassTotal() {
|
||||
List<Map<String,Object>> list = trainingClassService.listMaps(new MPJLambdaWrapper<TrainingClass>()
|
||||
.leftJoin(TrainingToUser.class, TrainingToUser::getTrainingId,TrainingClass::getId)
|
||||
.select(TrainingClass::getTitle)
|
||||
.select(TrainingClass::getId,TrainingClass::getTitle)
|
||||
.select("SUM(case when pay_type = '微信' then t1.fee else 0 end) 微信")
|
||||
.select("SUM(case when pay_type = '支付宝' then t1.fee else 0 end) 支付宝")
|
||||
.select("SUM(case when pay_type = '天医币' then t1.fee else 0 end) 天医币")
|
||||
@@ -173,12 +174,15 @@ public class StatisticsController {
|
||||
.leftJoin("pay_wechat_order pwo on pwo.order_sn = t.order_sn")
|
||||
.leftJoin("pay_zfb_order pzo on pzo.relevanceOid = t.order_sn and pzo.trade_no is not null")
|
||||
.select("""
|
||||
t.create_time,t1.name,t1.tel,t1.email,t.identity,t.order_sn,pwo.order_id wxNo,pzo.trade_no zfbNo,t.fee+t.abroad_fee+t.jf total,
|
||||
t.create_time,t1.name,t1.tel,t1.email,t.identity,t.order_sn,
|
||||
if(t.type='管理员' and t.pay_type='微信',t.order_sn,pwo.order_id) wxNo,
|
||||
if(t.type='管理员' and t.pay_type='支付宝',t.order_sn,pzo.trade_no) zfbNo,
|
||||
t.fee+t.abroad_fee total,
|
||||
IF(t.pay_type='微信',t.fee,0) 微信,
|
||||
IF(t.pay_type='支付宝',t.fee,0) 支付宝,
|
||||
IF(t.pay_type='天医币',t.fee,0) 天医币,
|
||||
IF(t.pay_type='银行',t.fee,0) 银行,
|
||||
IF(t.pay_type='海外',t.fee,0) 海外,
|
||||
IF(t.pay_type='海外',t.abroad_fee,0) 海外,
|
||||
IF(t.pay_type='赠送',t.fee,0) 赠送,t.jf,t.remark
|
||||
""")
|
||||
.eq(TrainingToUser::getTrainingId,params.get("trainingId"))
|
||||
|
||||
@@ -6,10 +6,7 @@ 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.*;
|
||||
import com.peanut.modules.common.service.BuyOrderService;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.common.service.TrainingClassService;
|
||||
import com.peanut.modules.common.service.TrainingToUserService;
|
||||
import com.peanut.modules.common.service.*;
|
||||
import com.peanut.modules.master.service.VipBuyConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -17,12 +14,14 @@ import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -45,7 +44,9 @@ public class TrainingClassController {
|
||||
@Autowired
|
||||
private VipBuyConfigService vipBuyConfigService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
private TransactionDetailsService transactionDetailsService;
|
||||
@Autowired
|
||||
private JfTransactionDetailsService jfTransactionDetailsService;
|
||||
|
||||
//vip商品类型
|
||||
@RequestMapping("/getVipBuyConfigList")
|
||||
@@ -147,13 +148,14 @@ public class TrainingClassController {
|
||||
//统计学员类型人数金额
|
||||
List<Map<String,Object>> list = trainingToUserService.listMaps(new MPJLambdaWrapper<TrainingToUser>()
|
||||
.select("""
|
||||
identity 身份,count(1) 人数,SUM(IF(pay_type='海外',abroad_fee,fee)) 总金额,
|
||||
identity 身份,count(1) 人数,SUM(IF(pay_type='海外',abroad_fee,fee)+jf) 总金额,
|
||||
SUM(case when pay_type = '微信' then fee else 0 end) 微信,
|
||||
SUM(case when pay_type = '支付宝' then fee else 0 end) 支付宝,
|
||||
SUM(case when pay_type = '天医币' then fee else 0 end) 天医币,
|
||||
SUM(jf) 积分,
|
||||
SUM(case when pay_type = '银行' then abroad_fee else 0 end) 银行,
|
||||
SUM(case when pay_type = '海外' then abroad_fee else 0 end) 海外
|
||||
SUM(case when pay_type = '银行' then fee else 0 end) 银行,
|
||||
SUM(case when pay_type = '海外' then abroad_fee else 0 end) 海外,
|
||||
SUM(case when pay_type = '赠送' then fee else 0 end) 赠送
|
||||
""")
|
||||
.eq(TrainingToUser::getTrainingId,params.get("trainingId"))
|
||||
.groupBy(TrainingToUser::getIdentity));
|
||||
@@ -166,7 +168,8 @@ public class TrainingClassController {
|
||||
titleRow.createCell(7).setCellValue("天医币");
|
||||
titleRow.createCell(8).setCellValue("银行");
|
||||
titleRow.createCell(9).setCellValue("海外");
|
||||
titleRow.createCell(10).setCellValue("积分抵扣");
|
||||
titleRow.createCell(10).setCellValue("赠送");
|
||||
titleRow.createCell(11).setCellValue("积分抵扣");
|
||||
for (Map<String,Object> map:list){
|
||||
titleRow = sheet.createRow(++i);
|
||||
titleRow.createCell(2).setCellValue(map.get("身份").toString());
|
||||
@@ -177,12 +180,13 @@ public class TrainingClassController {
|
||||
titleRow.createCell(7).setCellValue(map.get("天医币").toString());
|
||||
titleRow.createCell(8).setCellValue(map.get("银行").toString());
|
||||
titleRow.createCell(9).setCellValue(map.get("海外").toString());
|
||||
titleRow.createCell(10).setCellValue(map.get("积分").toString());
|
||||
titleRow.createCell(10).setCellValue(map.get("赠送").toString());
|
||||
titleRow.createCell(11).setCellValue(map.get("积分").toString());
|
||||
}
|
||||
//合计
|
||||
Map<String,Object> map = trainingToUserService.getMap(new MPJLambdaWrapper<TrainingToUser>()
|
||||
.select("""
|
||||
count(1) 人数,SUM(IF(pay_type='海外',abroad_fee,fee)) 总金额,
|
||||
count(1) 人数,SUM(IF(pay_type='海外',abroad_fee,fee)+jf) 总金额,
|
||||
SUM(case when pay_type = '微信' then fee else 0 end) 微信,
|
||||
SUM(case when pay_type = '支付宝' then fee else 0 end) 支付宝,
|
||||
SUM(case when pay_type = '天医币' then fee else 0 end) 天医币,
|
||||
@@ -231,7 +235,7 @@ public class TrainingClassController {
|
||||
IF(pay_type='支付宝',t.fee,0) 支付宝,
|
||||
IF(pay_type='天医币',t.fee,0) 天医币,
|
||||
IF(pay_type='银行',t.fee,0) 银行,
|
||||
IF(pay_type='海外',t.fee,0) 海外,
|
||||
IF(pay_type='海外',t.abroad_fee,0) 海外,
|
||||
IF(pay_type='赠送',t.fee,0) 赠送,t.jf,t.remark
|
||||
""")
|
||||
.eq(TrainingToUser::getTrainingId,params.get("trainingId"))
|
||||
@@ -297,15 +301,69 @@ public class TrainingClassController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//修改报名时间
|
||||
@RequestMapping("/trainingClassUpdateCreateTime")
|
||||
public R trainingClassUpdateCreateTime(@RequestBody Map<String,Object> params) {
|
||||
trainingToUserService.update(new LambdaUpdateWrapper<TrainingToUser>()
|
||||
.set(TrainingToUser::getCreateTime,params.get("createTime"))
|
||||
.eq(TrainingToUser::getId,params.get("id")));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//培训班添加用户
|
||||
@RequestMapping("/addUserToTrainingClass")
|
||||
@Transactional
|
||||
public R addUserToTrainingClass(@RequestBody TrainingToUser trainingToUser) {
|
||||
if (StringUtils.isEmpty(trainingToUser.getPayType())){
|
||||
return R.error("支付方式不能为空");
|
||||
}
|
||||
List list = trainingToUserService.list(new LambdaQueryWrapper<TrainingToUser>()
|
||||
.eq(TrainingToUser::getTrainingId,trainingToUser.getTrainingId())
|
||||
.eq(TrainingToUser::getUserId,trainingToUser.getUserId()));
|
||||
if (list.size()>0){
|
||||
return R.error("已存在");
|
||||
}
|
||||
if(trainingToUser.getFee().compareTo(BigDecimal.ZERO)<0||trainingToUser.getJf().compareTo(BigDecimal.ZERO)<0||trainingToUser.getAbroadFee().compareTo(BigDecimal.ZERO)<0){
|
||||
return R.error("金额不能为负数");
|
||||
}
|
||||
MyUserEntity user = userService.getById(trainingToUser.getUserId());
|
||||
if ("天医币".equals(trainingToUser.getPayType())) {
|
||||
if (trainingToUser.getFee().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (user.getPeanutCoin().compareTo(trainingToUser.getFee()) < 0) {
|
||||
return R.error("天医币余额不足");
|
||||
}
|
||||
}
|
||||
if (trainingToUser.getJf().compareTo(BigDecimal.ZERO)>0){
|
||||
if (user.getJf().compareTo(trainingToUser.getJf())<0){
|
||||
return R.error("积分余额不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("天医币".equals(trainingToUser.getPayType())){
|
||||
if (trainingToUser.getFee().compareTo(BigDecimal.ZERO)>0){
|
||||
user.setPeanutCoin(user.getPeanutCoin().subtract(trainingToUser.getFee()));
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(user.getId());
|
||||
transactionDetailsEntity.setUserName(user.getName());
|
||||
transactionDetailsEntity.setChangeAmount(trainingToUser.getFee().negate());
|
||||
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
transactionDetailsEntity.setTel(user.getTel());
|
||||
transactionDetailsEntity.setOrderType("扣费");
|
||||
transactionDetailsEntity.setNote("报名培训班:"+trainingClassService.getById(trainingToUser.getTrainingId()).getTitle());
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
}
|
||||
if (trainingToUser.getJf().compareTo(BigDecimal.ZERO)>0){
|
||||
user.setJf(user.getJf().subtract(trainingToUser.getJf()));
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(user.getId());
|
||||
jfTransactionDetails.setChangeAmount(trainingToUser.getJf().negate());
|
||||
jfTransactionDetails.setActType(1);
|
||||
jfTransactionDetails.setUserBalance(user.getJf());
|
||||
jfTransactionDetails.setRemark("报名培训班:"+trainingClassService.getById(trainingToUser.getTrainingId()).getTitle());
|
||||
jfTransactionDetailsService.save(jfTransactionDetails);
|
||||
}
|
||||
userService.updateById(user);
|
||||
}
|
||||
trainingToUser.setType("管理员");
|
||||
trainingToUserService.save(trainingToUser);
|
||||
return R.ok();
|
||||
@@ -313,8 +371,36 @@ public class TrainingClassController {
|
||||
|
||||
//培训班删除用户
|
||||
@RequestMapping("/delUserToTrainingClass")
|
||||
@Transactional
|
||||
public R delUserToTrainingClass(@RequestBody Map<String,Object> params) {
|
||||
trainingToUserService.removeById(params.get("id").toString());
|
||||
TrainingToUser trainingToUser = trainingToUserService.getById(params.get("id").toString());
|
||||
MyUserEntity user = userService.getById(trainingToUser.getUserId());
|
||||
trainingToUserService.removeById(trainingToUser);
|
||||
if ("天医币".equals(trainingToUser.getPayType())){
|
||||
if (trainingToUser.getFee().compareTo(BigDecimal.ZERO)>0){
|
||||
user.setPeanutCoin(user.getPeanutCoin().add(trainingToUser.getFee()));
|
||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||
transactionDetailsEntity.setUserId(user.getId());
|
||||
transactionDetailsEntity.setUserName(user.getName());
|
||||
transactionDetailsEntity.setChangeAmount(trainingToUser.getFee());
|
||||
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
|
||||
transactionDetailsEntity.setTel(user.getTel());
|
||||
transactionDetailsEntity.setOrderType("后台充值");
|
||||
transactionDetailsEntity.setNote("退款培训班:"+trainingClassService.getById(trainingToUser.getTrainingId()).getTitle());
|
||||
transactionDetailsService.save(transactionDetailsEntity);
|
||||
}
|
||||
if (trainingToUser.getJf().compareTo(BigDecimal.ZERO)>0){
|
||||
user.setJf(user.getJf().add(trainingToUser.getJf()));
|
||||
JfTransactionDetails jfTransactionDetails = new JfTransactionDetails();
|
||||
jfTransactionDetails.setUserId(user.getId());
|
||||
jfTransactionDetails.setChangeAmount(trainingToUser.getJf());
|
||||
jfTransactionDetails.setActType(0);
|
||||
jfTransactionDetails.setUserBalance(user.getJf());
|
||||
jfTransactionDetails.setRemark("退款培训班:"+trainingClassService.getById(trainingToUser.getTrainingId()).getTitle());
|
||||
jfTransactionDetailsService.save(jfTransactionDetails);
|
||||
}
|
||||
userService.updateById(user);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user