短信 余额 短信 余额 明细
This commit is contained in:
parent
26cde08873
commit
6e39b90840
|
|
@ -1,56 +1,98 @@
|
|||
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.dto.SmsShopTemplateDTO;
|
||||
import com.czg.market.entity.SmsShopMoney;
|
||||
import com.czg.market.service.SmsShopMoneyDetailService;
|
||||
import com.czg.market.service.SmsShopTemplateService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.market.mapper.SmsShopMoneyMapper;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信模板
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/smsTemplate")
|
||||
@RequestMapping("/admin")
|
||||
public class SmsShopTemplateController {
|
||||
@Resource
|
||||
private SmsShopTemplateService templateService;
|
||||
@Resource
|
||||
private SmsShopMoneyDetailService smsMoneyDetailService;
|
||||
@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
|
||||
public CzgResult<List<SmsShopTemplateDTO>> getTemplateList(@RequestParam(required = false) String title) {
|
||||
List<SmsShopTemplateDTO> data = templateService.getTemplateList(title, StpKit.USER.getShopId());
|
||||
@GetMapping("/smsMoney")
|
||||
public CzgResult<SmsShopMoney> getShopSmsMoney() {
|
||||
SmsShopMoney shopMoney = shopMoneyMapper.selectOneByQuery(
|
||||
new QueryWrapper()
|
||||
.eq(SmsShopMoney::getShopId, StpKit.USER.getShopId())
|
||||
);
|
||||
if (shopMoney == null) {
|
||||
shopMoney = new SmsShopMoney();
|
||||
shopMoney.setShopId(StpKit.USER.getShopId());
|
||||
shopMoney.setMoney(BigDecimal.ZERO);
|
||||
shopMoneyMapper.insert(shopMoney);
|
||||
}
|
||||
return CzgResult.success(shopMoney);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺短信余额明细
|
||||
*/
|
||||
@GetMapping("/smsMoneyDetail")
|
||||
public CzgResult<Page<SmsShopMoneyDetailDTO>> getSmsMoneyDetailPage(@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
Page<SmsShopMoneyDetailDTO> data = smsMoneyDetailService.getSmsMoneyDetailPage(StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
public CzgResult<Void> addTemplate(@RequestBody @Validated(InsertGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.addTemplate(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新提交
|
||||
* 状态为 -1 失败的 可以修改模板重新提交
|
||||
*/
|
||||
@PostMapping("/resubmit")
|
||||
public CzgResult<Void> resubmit(@RequestBody @Validated(UpdateGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.resubmit(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
package com.czg.market.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 短信余额明细 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsShopMoneyDetailDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 变动原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 1+ 2-
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消费值
|
||||
*/
|
||||
private BigDecimal expense;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.czg.market.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 店铺短信余额 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sms_shop_money")
|
||||
public class SmsShopMoney implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
private BigDecimal money;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.czg.market.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 短信余额明细 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sms_shop_money_detail")
|
||||
public class SmsShopMoneyDetail implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 变动原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 1+ 2-
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消费值
|
||||
*/
|
||||
private BigDecimal expense;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyDetailService extends IService<SmsShopMoneyDetail> {
|
||||
|
||||
Page<SmsShopMoneyDetailDTO> getSmsMoneyDetailPage(Long shopId);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
|
||||
/**
|
||||
* 短信余额明细 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyDetailMapper extends BaseMapper<SmsShopMoneyDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.SmsShopMoney;
|
||||
|
||||
/**
|
||||
* 店铺短信余额 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyMapper extends BaseMapper<SmsShopMoney> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
import com.czg.market.service.SmsShopMoneyDetailService;
|
||||
import com.czg.service.market.mapper.SmsShopMoneyDetailMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Service
|
||||
public class SmsShopMoneyDetailServiceImpl extends ServiceImpl<SmsShopMoneyDetailMapper, SmsShopMoneyDetail> implements SmsShopMoneyDetailService {
|
||||
|
||||
@Override
|
||||
public Page<SmsShopMoneyDetailDTO> getSmsMoneyDetailPage(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0)
|
||||
.orderBy(SmsShopMoneyDetail::getCreateTime).desc();
|
||||
return pageAs(PageUtil.buildPage(), queryWrapper, SmsShopMoneyDetailDTO.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.SmsShopMoneyDetailMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.SmsShopMoneyMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue