Bladeren bron

1、优化积分兑换的需求,防止更改数据

rayson 8 maanden geleden
bovenliggende
commit
f6bc0f5f76

+ 1 - 1
menduner/menduner-system-api/src/main/java/com/citu/module/menduner/system/enums/ErrorCodeConstants.java

@@ -27,8 +27,8 @@ public interface ErrorCodeConstants {
     ErrorCode MDE_COMMON_ENTERPRISE_ID_NOT_NULL = new ErrorCode(1_099_000_007, "企业id不能为空");
     ErrorCode MDE_COMMON_USER_TYPE_NOT_NULL = new ErrorCode(1_099_000_008, "用户类型不能为空");
     ErrorCode MDE_FILE_FORMAT_ERROR = new ErrorCode(1_099_000_009, "文件格式不正确,仅支持.doc, .docx, .pdf文件");
-
     ErrorCode MDE_FILE_NOT_NULL = new ErrorCode(1_099_000_010, "文件附件不能为空");
+    ErrorCode MDE_REQUEST_ILLEGAL = new ErrorCode(1_099_000_011, "非法请求");
 
 
     // ========== 人员信息-个人档案 1_100_001_000 ==========

+ 7 - 11
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/controller/admin/fair/FairController.java

@@ -1,8 +1,6 @@
 package com.citu.module.menduner.system.controller.admin.fair;
 
 
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import com.citu.framework.apilog.core.annotation.ApiAccessLog;
 import com.citu.framework.common.pojo.CommonResult;
 import com.citu.framework.common.pojo.PageParam;
@@ -26,10 +24,8 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 import static com.citu.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static com.citu.framework.common.pojo.CommonResult.success;
@@ -106,8 +102,8 @@ public class FairController {
     @Operation(summary = "获得招聘会白名单企业")
     public CommonResult<PageResult<FairWhiteRespVO>> page(@Valid FairWhitePageReqVO reqVO) {
         reqVO.setJobFairId(1L);
-        PageResult<FairWhiteDO> fairWhiteList =  fairService.page(reqVO);
-        PageResult<FairWhiteRespVO> resp=  BeanUtils.toBean(fairWhiteList, FairWhiteRespVO.class);
+        PageResult<FairWhiteDO> fairWhiteList = fairService.page(reqVO);
+        PageResult<FairWhiteRespVO> resp = BeanUtils.toBean(fairWhiteList, FairWhiteRespVO.class);
         for (FairWhiteRespVO fairWhiteRespVO : resp.getList()) {
             fairWhiteRespVO.setJobFair(BeanUtils.toBean(fairService.getJobFair(fairWhiteRespVO.getJobFairId()), JobFairRespVO.class));
         }
@@ -130,15 +126,15 @@ public class FairController {
 
     @PutMapping("/add-white-list2")
     @Operation(summary = "添加企业白名单2")
-    public CommonResult<Boolean> addWhiteList2(@RequestParam("enterpriseNames") String enterpriseNames) {
-        fairService.addWhiteList2(1L, StrUtil.split(enterpriseNames, ","));
+    public CommonResult<Boolean> addWhiteList2(@RequestParam("enterpriseName") String enterpriseName) {
+        fairService.addWhiteList2(1L, Collections.singletonList(enterpriseName));
         return success(true);
     }
 
     @PutMapping("/remove-white-list2")
     @Operation(summary = "移除企业白名单2")
-    public CommonResult<Boolean> removeWhiteList2(@RequestParam("enterpriseNames") String enterpriseNames) {
-        fairService.removeWhiteList2(1L, StrUtil.split(enterpriseNames, ","));
+    public CommonResult<Boolean> removeWhiteList2(@RequestParam("enterpriseName") String enterpriseName) {
+        fairService.removeWhiteList2(1L, Collections.singletonList(enterpriseName));
         return success(true);
     }
 

+ 2 - 2
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/mq/consumer/UserMemberConsumer.java

@@ -28,7 +28,7 @@ import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exce
 import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_USER_NOT_EXISTS;
 
 /**
- * 众聘职位完成支付 消费
+ * 用户会员完成支付 消费
  **/
 @Slf4j
 @Component
@@ -137,7 +137,7 @@ public class UserMemberConsumer implements RocketMQListener<Long> {
 
         // 加积分
         EventAsyncUrlEnum urlEnum = getEventAsyncUrlEnum(packageDO.getDay());
-        // 表示  userDO.getId() 因为企业用户注册, 所以加积分
+        // 表示  userDO.getId() 因为购买会员, 所以加积分
         pointOperateProducer.send(EventAsyncConfirmMessage.builder()
                 // 给谁加,谁申请给谁加
                 .userId(user.getId())

+ 1 - 1
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/order/TradeOrderServiceImpl.java

@@ -217,7 +217,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
                 .setMerchantOrderId(String.valueOf(order.getId())) // 支付单号
                 .setMerchantRefundId(refundId)
                 .setReason("交易退款").setPrice(Math.toIntExact(order.getPrice()))).getCheckedData();// 价格信息
-        // 2.3 更新退款单到 demo 订单
+        // 2.3 更新退款单到 订单
         tradeOrderMapper.updateById(new TradeOrderDO().setId(id)
                 .setPayRefundId(payRefundId).setRefundPrice(order.getPrice()));
     }

+ 18 - 3
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/redeem/RedeemServiceImpl.java

@@ -4,21 +4,24 @@ package com.citu.module.menduner.system.service.redeem;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.citu.framework.common.pojo.PageResult;
 import com.citu.framework.common.util.object.BeanUtils;
+import com.citu.module.menduner.common.enums.MathOperationEnum;
+import com.citu.module.menduner.common.enums.PointBizTypeEnum;
 import com.citu.module.menduner.common.util.LoginUserContext;
 import com.citu.module.menduner.system.controller.app.jobhunt.redeem.vo.AppRedeemSubmitReqVO;
 import com.citu.module.menduner.system.controller.base.redeem.RedeemPageReqVO;
 import com.citu.module.menduner.system.controller.base.redeem.RedeemSaveReqVO;
 import com.citu.module.menduner.system.dal.dataobject.redeem.RedeemDO;
 import com.citu.module.menduner.system.dal.mysql.redeem.RedeemMapper;
-import com.citu.module.menduner.common.enums.MathOperationEnum;
-import com.citu.module.menduner.common.enums.PointBizTypeEnum;
 import com.citu.module.menduner.system.service.record.UserAccountRecordService;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
 
 import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static com.citu.module.menduner.system.enums.ErrorCodeConstants.MDE_REQUEST_ILLEGAL;
 import static com.citu.module.menduner.system.enums.ErrorCodeConstants.REDEEM_NOT_EXISTS;
 
 /**
@@ -30,9 +33,14 @@ import static com.citu.module.menduner.system.enums.ErrorCodeConstants.REDEEM_NO
 @Validated
 public class RedeemServiceImpl implements RedeemService {
 
+    private final static Map<String, Integer> GOOD_MAP = new HashMap<>() {{
+        put("减压捏捏乐", 500);
+        put("瑞幸咖啡券-瑞幸咖啡精致享受券", 2000);
+        put("门墩儿酒店英语学习年卡", 8000);
+        put("房券-高端酒店房券", 12000);
+    }};
     @Resource
     private RedeemMapper redeemMapper;
-
     @Resource
     private UserAccountRecordService accountRecordService;
 
@@ -83,6 +91,13 @@ public class RedeemServiceImpl implements RedeemService {
     public void submit(AppRedeemSubmitReqVO reqVO) {
         RedeemDO redeem = BeanUtils.toBean(reqVO, RedeemDO.class);
         redeem.setUserId(LoginUserContext.getUserId());
+        Integer point = GOOD_MAP.computeIfAbsent(reqVO.getName(), v -> 0);
+        if (0 == point) {
+            throw exception(REDEEM_NOT_EXISTS);
+        }
+        if (!point.equals(reqVO.getPoint())) {
+            throw exception(MDE_REQUEST_ILLEGAL);
+        }
         redeemMapper.insert(redeem);
         // 创建记录
         accountRecordService.createPointRecord(

+ 1 - 0
menduner/menduner-system-biz/src/main/resources/i18n/messages_en_US.properties

@@ -28,6 +28,7 @@
 1_099_000_008=User Type cannot be empty
 1_099_000_009=The file format is incorrect and only supports. doc,. docx, and. pdf files
 1_099_000_010=File attachment cannot be empty
+1_099_000_011=Illegal request
 # ========== 人才信息-人才档案 1_100_001_000 ==========
 1_100_001_001=Personal Profile Does Not Exist
 1_100_001_002=Personal advantage cannot be empty

+ 1 - 0
menduner/menduner-system-biz/src/main/resources/i18n/messages_zh_CN.properties

@@ -28,6 +28,7 @@
 1_099_000_008=用户类型不能为空
 1_099_000_009=文件格式不正确,仅支持.doc, .docx, .pdf文件
 1_099_000_010=文件附件不能为空
+1_099_000_011=非法请求
 # ========== 人才信息-人才档案 1_100_001_000 ==========
 1_100_001_001=人才档案不存在
 1_100_001_002=人才优势不能为空