From 262cdc113a44bbd51f98a56ce91966dc7b2ea938 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期六, 08 一月 2022 17:55:25 +0800
Subject: [PATCH] 数字商业街代码提交

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsCouponServiceImpl.java |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 1 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsCouponServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsCouponServiceImpl.java
index f52da70..6f49450 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsCouponServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsCouponServiceImpl.java
@@ -1,10 +1,34 @@
 package com.panzhihua.service_community.service.impl;
 
+import java.util.Date;
+import java.util.List;
+
+import com.alibaba.fastjson.JSONObject;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.GameStatisticsVO;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.VerifiedReturnVO;
+import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.service_community.dao.McsGameDAO;
+import com.panzhihua.service_community.dao.McsVerifiedRecordDAO;
+import com.panzhihua.service_community.entity.McsGame;
+import com.panzhihua.service_community.entity.McsVerifiedRecord;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.model.dtos.community.microCommercialStreet.PageJoinGameListDTO;
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.McsCouponVO;
+import com.panzhihua.common.model.vos.community.microCommercialStreet.MyCouponVO;
 import com.panzhihua.service_community.dao.McsCouponDAO;
 import com.panzhihua.service_community.entity.McsCoupon;
 import com.panzhihua.service_community.service.McsCouponService;
-import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+import static java.util.Objects.isNull;
+import static java.util.Objects.nonNull;
 
 /**
  * (McsCoupon)表服务实现类
@@ -15,4 +39,93 @@
 @Service("mcsCouponService")
 public class McsCouponServiceImpl extends ServiceImpl<McsCouponDAO, McsCoupon> implements McsCouponService {
 
+    @Resource
+    private McsVerifiedRecordDAO mcsVerifiedRecordDAO;
+    @Resource
+    private McsGameDAO mcsGameDAO;
+    @Resource
+    private UserService userService;
+
+    /**
+     * 我的戳戳卷
+     * @return
+     * @param type
+     * @param userId
+     */
+    @Override
+    public R getMyCoupon(Integer type, Long userId) {
+        MyCouponVO myCouponVO = this.baseMapper.getMyCouponData(userId);
+        List<McsCouponVO> mcsCoupons = this.baseMapper.getCouponList(type, userId);
+        myCouponVO.setCouponList(mcsCoupons);
+        return R.ok(myCouponVO);
+    }
+
+    /**
+     * 我的评价-参与游戏列表
+     * @param pageJoinGameListDTO
+     * @return
+     */
+    @Override
+    public R getJoinGameList(PageJoinGameListDTO pageJoinGameListDTO) {
+        Page page = new Page<>();
+        page.setSize(pageJoinGameListDTO.getPageSize());
+        page.setCurrent(pageJoinGameListDTO.getPageNum());
+        IPage<McsCouponVO> mcsCoupons = this.baseMapper.pageJoinGameList(page, pageJoinGameListDTO);
+        return R.ok(mcsCoupons);
+    }
+
+    /**
+     * 戳戳卷核销
+     * @param couponId
+     * @return
+     */
+    @Override
+    public R verifyMcsCoupon(Long couponId) {
+        McsCoupon mcsCoupon = this.baseMapper.selectById(couponId);
+        if (isNull(mcsCoupon) || mcsCoupon.getIsVerified()) {
+            return R.fail("无效卷码");
+        }
+        Date nowDate = new Date();
+        McsGame mcsGame = mcsGameDAO.selectById(mcsCoupon.getGameId());
+        if (isNull(mcsGame) || mcsGame.getExpireAt().before(nowDate)) {
+            return R.fail("已过期");
+        }
+        McsVerifiedRecord mcsVerifiedRecord = new McsVerifiedRecord();
+        mcsVerifiedRecord.setCouponId(couponId);
+        mcsVerifiedRecord.setAward(mcsCoupon.getAward());
+        mcsVerifiedRecord.setName(mcsGame.getName());
+        mcsVerifiedRecord.setMerchantId(mcsGame.getMerchantId());
+        int num = mcsVerifiedRecordDAO.insert(mcsVerifiedRecord);
+        if (num > 0) {
+            mcsCoupon.setIsVerified(true);
+            this.baseMapper.updateById(mcsCoupon);
+            VerifiedReturnVO verifiedReturnVO = new VerifiedReturnVO();
+            verifiedReturnVO.setAward(mcsCoupon.getAward());
+            verifiedReturnVO.setAwardType(mcsGame.getAwardType());
+            verifiedReturnVO.setCouponId(couponId);
+            verifiedReturnVO.setCover(mcsGame.getCover());
+            verifiedReturnVO.setGameName(mcsGame.getName());
+            R<LoginUserInfoVO> userInfoVOR = userService.getUserInfoByUserId(mcsCoupon.getUserId().toString());
+            if (R.isOk(userInfoVOR) && nonNull(userInfoVOR.getData())) {
+                LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(userInfoVOR.getData()), LoginUserInfoVO.class);
+                verifiedReturnVO.setNickName(loginUserInfoVO.getNickName());
+            } else {
+                verifiedReturnVO.setNickName("默认昵称");
+            }
+            verifiedReturnVO.setVerifiedAt(nowDate);
+            return R.ok(verifiedReturnVO);
+        }
+        return R.fail("核验失败,请重试");
+    }
+
+    /**
+     * 游戏统计
+     * @param userId
+     * @return
+     */
+    @Override
+    public R getMcsGameStatistics(Long userId) {
+        GameStatisticsVO gameStatisticsVO = this.baseMapper.getMcsGameStatistics(userId);
+        return R.ok(gameStatisticsVO);
+    }
 }

--
Gitblit v1.7.1