@@ -108,6 +108,10 @@ public enum OperateType { | |||
ORDER_CANCEL("订单取消"), | |||
ORDER_RECEIVEGOODS("订单确认收货"), | |||
//权益 | |||
EQUITY_LINK_RECEIVE("权益领取"), | |||
EQUITY_LINK_ISSUE("权益发放"), | |||
; | |||
private final String value; | |||
@@ -40,8 +40,7 @@ public class IssueCouponDetail extends StringPropertyUUIDEntity { | |||
@NotNull | |||
@Column(name = "CODE_CREATE_TIME") | |||
private LocalDateTime codeCreateTime;//兑换码生成时间 | |||
@NotBlank | |||
@Size(max = 50) | |||
@NotNull | |||
@Enumerated(EnumType.STRING) | |||
@Column(name = "COUPON_STATUS") | |||
private CouponStatus status;//状态(待领取、领取后待激活、已激活待使用、已使用、已过期) |
@@ -41,7 +41,7 @@ public class NoticeFlashPageRequest extends JpaDateTimePageableDataRequest<Notic | |||
@Override | |||
public HqlBuilder toSelectHql(){ | |||
HqlBuilder hql = new HqlBuilder("from NoticeFlash where 1=1 and deleted = 0 "); | |||
hql.append(" and title like :title",title); | |||
hql.append(" and title like :title",like(title)); | |||
hql.append(" and status = :status",status); | |||
hql.append(" and flashType = :flashType",flashType); | |||
hql.append(" and insertTime >= :startTime",startTime); |
@@ -33,13 +33,13 @@ public class VehicleInfoController extends MyValidController { | |||
@Autowired | |||
private VehicleInfoManager manager; | |||
@ApiOperation("车辆绑定列表查询") | |||
@ApiOperation("车辆信息分页查询") | |||
@PostMapping("/page") | |||
public ApiResponse<Pagination> page(@Valid @RequestBody VehicleInfoPageRequestDTO dto) throws ManagerException { | |||
return ApiResponse.of(manager.page(dto)); | |||
} | |||
@ApiOperation("车辆绑定列表查询") | |||
@ApiOperation("车辆查看详情查询") | |||
@PostMapping("/view") | |||
public ApiResponse<VehicleInfoViewResponseDTO> view(@Valid @RequestBody VehicleInfoViewRequestDTO dto) throws ManagerException { | |||
return ApiResponse.of(manager.view(dto)); |
@@ -39,17 +39,24 @@ public class UserEquityLinkController { | |||
@ApiOperation(value = "查看分组下的权益") | |||
@PostMapping(value = "/pageEquityDetail") | |||
public ApiResponse<Pagination> pageEquityDetail(@Valid @RequestBody UserEquityLinkEquityDetailRequestDTO dto) throws ManagerException { | |||
public ApiResponse<Pagination> pageEquityDetail(@Valid @RequestBody UserEquityLinkDetailRequestDTO dto) throws ManagerException { | |||
return ApiResponse.of(manager.pageEquityDetail(dto)); | |||
} | |||
@ApiOperation(value = "权益领取") | |||
@PostMapping(value = "/equityReceive") | |||
public ApiResponse<UserEquityLinkEquityReceiveResponseDTO> equityReceive(@Valid @RequestBody UserEquityLinkEquityReceiveRequestDTO dto) throws ManagerException { | |||
public ApiResponse<UserEquityLinkReceiveResponseDTO> equityReceive(@Valid @RequestBody UserEquityLinkReceiveRequestDTO dto) throws ManagerException { | |||
return ApiResponse.of(manager.equityReceive(dto)); | |||
} | |||
@ApiOperation(value = "权益发放") | |||
@PostMapping(value = "/equityIssue") | |||
public ApiResponse<UserEquityLinkIssueResponseDTO> equityIssue(@Valid @RequestBody UserEquityLinkIssueRequestDTO dto) throws ManagerException { | |||
return ApiResponse.of(manager.equityIssue(dto)); | |||
} | |||
} |
@@ -1,13 +1,11 @@ | |||
package cn.com.taiji.iaw.dto.issue.equityLink; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Author:ChenChao | |||
@@ -17,7 +15,7 @@ import javax.validation.constraints.NotNull; | |||
*/ | |||
@Data | |||
@ApiModel(description = "查看分组下的权益请求") | |||
public class UserEquityLinkEquityDetailRequestDTO extends AbstractBizRequestDTO { | |||
public class UserEquityLinkDetailRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "权益id") |
@@ -0,0 +1,25 @@ | |||
package cn.com.taiji.iaw.dto.issue.equityLink; | |||
import cn.com.taiji.core.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/7/9 14:36 | |||
* @Filename:AgreeProtocolReqDTO | |||
* @description: | |||
*/ | |||
@Data | |||
@ApiModel(description = "权益发放请求") | |||
public class UserEquityLinkIssueRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank(message = "订单编号不能为空") | |||
@ApiModelProperty(value = "订单编号") | |||
private String orderNo; | |||
} |
@@ -0,0 +1,17 @@ | |||
package cn.com.taiji.iaw.dto.issue.equityLink; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/7/9 14:16 | |||
* @Filename:CheckProtocolResDTO | |||
* @description: | |||
*/ | |||
@ApiModel(description = "权益发放响应") | |||
@Data | |||
public class UserEquityLinkIssueResponseDTO { | |||
} |
@@ -15,7 +15,7 @@ import javax.validation.constraints.NotBlank; | |||
*/ | |||
@Data | |||
@ApiModel(description = "权益领取请求") | |||
public class UserEquityLinkEquityReceiveRequestDTO extends AbstractBizRequestDTO { | |||
public class UserEquityLinkReceiveRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "数据id") |
@@ -1,11 +1,8 @@ | |||
package cn.com.taiji.iaw.dto.issue.equityLink; | |||
import cn.com.taiji.core.entity.issue.UserEquityLink; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/7/9 14:16 | |||
@@ -14,7 +11,7 @@ import java.util.List; | |||
*/ | |||
@ApiModel(description = "权益领取响应") | |||
@Data | |||
public class UserEquityLinkEquityReceiveResponseDTO { | |||
public class UserEquityLinkReceiveResponseDTO { | |||
} |
@@ -15,7 +15,9 @@ import cn.com.taiji.iaw.dto.issue.equityLink.*; | |||
public interface UserEquityLinkManager { | |||
UserEquityLinkGroupQueryResponseDTO groupQuery(CommRequestDTO dto) throws ManagerException; | |||
Pagination pageEquityDetail(UserEquityLinkEquityDetailRequestDTO dto) throws ManagerException; | |||
Pagination pageEquityDetail(UserEquityLinkDetailRequestDTO dto) throws ManagerException; | |||
UserEquityLinkEquityReceiveResponseDTO equityReceive(UserEquityLinkEquityReceiveRequestDTO dto) throws ManagerException; | |||
UserEquityLinkReceiveResponseDTO equityReceive(UserEquityLinkReceiveRequestDTO dto) throws ManagerException; | |||
UserEquityLinkIssueResponseDTO equityIssue(UserEquityLinkIssueRequestDTO dto) throws ManagerException; | |||
} |
@@ -3,17 +3,17 @@ package cn.com.taiji.iaw.manager.issue; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.pub.CollectionTools; | |||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||
import cn.com.taiji.core.entity.dict.issue.CouponStatus; | |||
import cn.com.taiji.core.entity.issue.IssueCouponDetail; | |||
import cn.com.taiji.core.entity.issue.IssueSingleEquity; | |||
import cn.com.taiji.core.entity.issue.UserEquityLink; | |||
import cn.com.taiji.core.repo.jpa.issue.IssueCouponDetailRepo; | |||
import cn.com.taiji.core.repo.jpa.issue.IssueSingleEquityRepo; | |||
import cn.com.taiji.core.repo.jpa.issue.UserEquityLinkRepo; | |||
import cn.com.taiji.core.entity.dict.issue.IssueOrderStatus; | |||
import cn.com.taiji.core.entity.dict.log.OperateType; | |||
import cn.com.taiji.core.entity.issue.*; | |||
import cn.com.taiji.core.repo.jpa.issue.*; | |||
import cn.com.taiji.core.repo.request.issue.UserEquityLinkPageRequest; | |||
import cn.com.taiji.iaw.dto.CommRequestDTO; | |||
import cn.com.taiji.iaw.dto.issue.equityLink.*; | |||
import cn.com.taiji.iaw.manager.AbstractIawManager; | |||
import org.aspectj.org.eclipse.jdt.internal.core.nd.db.IString; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
@@ -38,6 +38,10 @@ public class UserEquityLinkManagerImpl extends AbstractIawManager implements Use | |||
private IssueSingleEquityRepo singleEquityRepo; | |||
@Autowired | |||
private IssueCouponDetailRepo couponDetailRepo; | |||
@Autowired | |||
private IssueOrderinfoRepo orderinfoRepo; | |||
@Autowired | |||
private IssueMultipleEquityRepo multipleEquityRepo; | |||
@Override | |||
public UserEquityLinkGroupQueryResponseDTO groupQuery(CommRequestDTO dto) throws ManagerException { | |||
@@ -46,7 +50,7 @@ public class UserEquityLinkManagerImpl extends AbstractIawManager implements Use | |||
} | |||
@Override | |||
public Pagination pageEquityDetail(UserEquityLinkEquityDetailRequestDTO dto) throws ManagerException { | |||
public Pagination pageEquityDetail(UserEquityLinkDetailRequestDTO dto) throws ManagerException { | |||
UserEquityLinkPageRequest pageRequest = new UserEquityLinkPageRequest(); | |||
pageRequest.setEquityId(dto.getEquityId()); | |||
pageRequest.setOpenId(findOpenIdByToken(dto.getAccessToken())); | |||
@@ -55,13 +59,13 @@ public class UserEquityLinkManagerImpl extends AbstractIawManager implements Use | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
public UserEquityLinkEquityReceiveResponseDTO equityReceive(UserEquityLinkEquityReceiveRequestDTO dto) throws ManagerException { | |||
public UserEquityLinkReceiveResponseDTO equityReceive(UserEquityLinkReceiveRequestDTO dto) throws ManagerException { | |||
UserEquityLink equityLink = repo.findById(dto.getId()).orElse(null); | |||
if (LocalDateTime.now().isAfter(equityLink.getReceiveEndTime())){ | |||
if (LocalDateTime.now().isAfter(equityLink.getValidEndTime())){ | |||
throw new ManagerException("权益已过期!"); | |||
} | |||
//获取兑换码 | |||
IssueSingleEquity singleEquity = singleEquityRepo.findById(equityLink.getEquityId()).orElse(null); | |||
IssueSingleEquity singleEquity = singleEquityRepo.findBySingleEquityId(equityLink.getEquityId()); | |||
if (singleEquity == null ){ | |||
throw new ManagerException("单项权益异常!"); | |||
} | |||
@@ -79,9 +83,58 @@ public class UserEquityLinkManagerImpl extends AbstractIawManager implements Use | |||
equityLink.setCouponId(issueCouponDetail.getRedeemCode()); | |||
equityLink.setStatus(CouponStatus.WAIT_ACTIVATED); | |||
equityLink.setReceiveTime(LocalDateTime.now()); | |||
equityLink.setValidStartTime(issueCouponDetail.getValidStartTime()); | |||
equityLink.setValidEndTime(issueCouponDetail.getValidEndTime()); | |||
repo.merge(equityLink); | |||
persistOperateLog(OperateType.EQUITY_LINK_RECEIVE,equityLink.getId(),dto.getOrderSource(),findOpenIdByToken(dto.getAccessToken()),"权益领取"); | |||
return new UserEquityLinkReceiveResponseDTO(); | |||
} | |||
@Override | |||
@Transactional(rollbackFor = Exception.class) | |||
public UserEquityLinkIssueResponseDTO equityIssue(UserEquityLinkIssueRequestDTO dto) throws ManagerException { | |||
IssueOrderinfo orderinfo = orderinfoRepo.findByOrderNo(dto.getOrderNo()); | |||
if (orderinfo == null){ | |||
throw new ManagerException("未查询到发行订单"); | |||
} | |||
if (IssueOrderStatus.ACTIVE.equals(orderinfo.getOrderStatus())){ | |||
throw new ManagerException("订单未激活,无法发放权益!"); | |||
} | |||
if (!SourceType.WECHAT.equals(orderinfo.getOrderSource()) || !SourceType.SERVICE_HALL.equals(orderinfo.getOrderSource())){ | |||
throw new ManagerException("订单来源异常!"); | |||
} | |||
if (orderinfo.getEquityId().endsWith("S")){ | |||
addEquityLink(orderinfo.getUserId(),orderinfo.getOrderNo(),orderinfo.getEquityId()); | |||
} else if (orderinfo.getEquityId().endsWith("M")) { | |||
IssueMultipleEquity multipleEquityId = multipleEquityRepo.findByMultipleEquityId(orderinfo.getEquityId()); | |||
for (String singleEquityId : multipleEquityId.getSingleIds().split(",")) { | |||
addEquityLink(orderinfo.getUserId(),orderinfo.getOrderNo(),singleEquityId); | |||
} | |||
} | |||
persistOperateLog(OperateType.EQUITY_LINK_ISSUE,orderinfo.getId(),dto.getOrderSource(),findOpenIdByToken(dto.getAccessToken()),"权益发放"); | |||
return new UserEquityLinkIssueResponseDTO(); | |||
} | |||
return new UserEquityLinkEquityReceiveResponseDTO(); | |||
private void addEquityLink(String openId, String orderNo, String equityId) throws ManagerException { | |||
UserEquityLink equityLink = new UserEquityLink(); | |||
equityLink.setOpenId(openId); | |||
equityLink.setOrderNo(orderNo); | |||
//订单类型1-发行订单 2-权益购买订单 | |||
equityLink.setOrderType(1); | |||
equityLink.setStatus(CouponStatus.WAIT_GET); | |||
//获取权益信息 | |||
IssueSingleEquity singleEquity = singleEquityRepo.findBySingleEquityId(equityId); | |||
if (singleEquity == null ){ | |||
throw new ManagerException("未获取到权益!"); | |||
} | |||
equityLink.setEquityId(singleEquity.getId()); | |||
equityLink.setEquityName(singleEquity.getEquityName()); | |||
equityLink.setProductIntro(singleEquity.getProductIntro()); | |||
equityLink.setFee(singleEquity.getDiscountPrice()); | |||
equityLink.setSellingPoint(singleEquity.getSellingPoint()); | |||
equityLink.setReceiveEndTime(LocalDateTime.now().plusMonths(1)); | |||
repo.save(equityLink); | |||
} | |||