短信 余额 短信 余额 明细
This commit is contained in:
parent
6e39b90840
commit
2842d53ab2
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.dto.SmsShopTemplateDTO;
|
||||
import com.czg.market.entity.SmsShopMoney;
|
||||
|
|
@ -38,35 +40,35 @@ public class SmsShopTemplateController {
|
|||
@Resource
|
||||
private SmsShopMoneyMapper shopMoneyMapper;
|
||||
|
||||
// /**
|
||||
// * 列表
|
||||
// */
|
||||
// @GetMapping("/smsTemplate")
|
||||
// public CzgResult<List<SmsShopTemplateDTO>> getTemplateList(@RequestParam(required = false) String title) {
|
||||
// List<SmsShopTemplateDTO> data = templateService.getTemplateList(title, StpKit.USER.getShopId());
|
||||
// return CzgResult.success(data);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增
|
||||
// */
|
||||
// @PostMapping("/smsTemplate")
|
||||
// public CzgResult<Void> addTemplate(@RequestBody @Validated(InsertGroup.class) SmsShopTemplateDTO param) {
|
||||
// param.setShopId(StpKit.USER.getShopId());
|
||||
// templateService.addTemplate(param);
|
||||
// return CzgResult.success();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 重新提交
|
||||
// * 状态为 -1 失败的 可以修改模板重新提交
|
||||
// */
|
||||
// @PostMapping("/smsTemplate/resubmit")
|
||||
// public CzgResult<Void> resubmit(@RequestBody @Validated(UpdateGroup.class) SmsShopTemplateDTO param) {
|
||||
// param.setShopId(StpKit.USER.getShopId());
|
||||
// templateService.resubmit(param);
|
||||
// return CzgResult.success();
|
||||
// }
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("/smsTemplate")
|
||||
public CzgResult<List<SmsShopTemplateDTO>> getTemplateList(@RequestParam(required = false) String title) {
|
||||
List<SmsShopTemplateDTO> data = templateService.getTemplateList(title, StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/smsTemplate")
|
||||
public CzgResult<Void> addTemplate(@RequestBody @Validated(InsertGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.addTemplate(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新提交
|
||||
* 状态为 -1 失败的 可以修改模板重新提交
|
||||
*/
|
||||
@PostMapping("/smsTemplate/resubmit")
|
||||
public CzgResult<Void> resubmit(@RequestBody @Validated(UpdateGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.resubmit(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺短信余额
|
||||
|
|
@ -90,9 +92,12 @@ public class SmsShopTemplateController {
|
|||
* 获取店铺短信余额明细
|
||||
*/
|
||||
@GetMapping("/smsMoneyDetail")
|
||||
public CzgResult<Page<SmsShopMoneyDetailDTO>> getSmsMoneyDetailPage(@RequestParam(required = false) Integer page,
|
||||
public CzgResult<JSONObject> getSmsMoneyDetailPage(@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
Page<SmsShopMoneyDetailDTO> data = smsMoneyDetailService.getSmsMoneyDetailPage(StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
JSONObject from = JSONObject.from(data);
|
||||
from.put("sendTotal", smsMoneyDetailService.countSendTotal(StpKit.USER.getShopId()));
|
||||
from.put("sendAmountTotal", smsMoneyDetailService.countSendAmountTotal(StpKit.USER.getShopId()));
|
||||
return CzgResult.success(from);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ public class SmsShopMoneyDetailDTO implements Serializable {
|
|||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 发送条数
|
||||
*/
|
||||
private Long sendRows;
|
||||
|
||||
/**
|
||||
* 消费值
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ public class SmsShopMoneyDetail implements Serializable {
|
|||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
/**
|
||||
* 发送短信条数
|
||||
*/
|
||||
private Long sendRows;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.czg.market.entity.SmsShopMoneyDetail;
|
|||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层。
|
||||
*
|
||||
|
|
@ -14,4 +16,12 @@ import com.mybatisflex.core.service.IService;
|
|||
public interface SmsShopMoneyDetailService extends IService<SmsShopMoneyDetail> {
|
||||
|
||||
Page<SmsShopMoneyDetailDTO> getSmsMoneyDetailPage(Long shopId);
|
||||
/**
|
||||
* 统计发送短信总数
|
||||
*/
|
||||
Long countSendTotal(Long shopId);
|
||||
/**
|
||||
* 统计发送短信累计金额
|
||||
*/
|
||||
BigDecimal countSendAmountTotal(Long shopId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层实现。
|
||||
*
|
||||
|
|
@ -27,4 +30,25 @@ public class SmsShopMoneyDetailServiceImpl extends ServiceImpl<SmsShopMoneyDetai
|
|||
.orderBy(SmsShopMoneyDetail::getCreateTime).desc();
|
||||
return pageAs(PageUtil.buildPage(), queryWrapper, SmsShopMoneyDetailDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countSendTotal(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper()
|
||||
.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.gt(SmsShopMoneyDetail::getSendRows, 0)
|
||||
.eq(SmsShopMoneyDetail::getType, 2)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0);
|
||||
return count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal countSendAmountTotal(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper()
|
||||
.select("sum(expense)")
|
||||
.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.gt(SmsShopMoneyDetail::getSendRows, 0)
|
||||
.eq(SmsShopMoneyDetail::getType, 2)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0);
|
||||
return getOneAs(queryWrapper, BigDecimal.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue