|
@@ -0,0 +1,140 @@
|
|
|
|
|
+package shop.alien.store.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import shop.alien.entity.store.StorePlatformBenefits;
|
|
|
|
|
+import shop.alien.entity.store.StoreVirtualCurrency;
|
|
|
|
|
+import shop.alien.entity.store.vo.LifeUserViolationVo;
|
|
|
|
|
+import shop.alien.entity.store.vo.StorePlatformBenefitsVo;
|
|
|
|
|
+import shop.alien.mapper.StorePlatformBenefitsMapper;
|
|
|
|
|
+import shop.alien.mapper.StoreVirtualCurrencyMapper;
|
|
|
|
|
+import shop.alien.store.service.StorePlatformBenefitsService;
|
|
|
|
|
+import shop.alien.util.common.JwtUtil;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 福利表 服务实现类
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author ssk
|
|
|
|
|
+ * @since 2025-12-18
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Service
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class StorePlatformBenefitsServiceImpl extends ServiceImpl<StorePlatformBenefitsMapper, StorePlatformBenefits> implements StorePlatformBenefitsService {
|
|
|
|
|
+
|
|
|
|
|
+ private final StorePlatformBenefitsMapper benefitsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final StoreVirtualCurrencyMapper virtualCurrencyMapper;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public IPage<StorePlatformBenefitsVo> getPage(int page, int size, Integer type, String name) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.getPage - page={}, size={}, type={}, name={}", page, size, type, name);
|
|
|
|
|
+
|
|
|
|
|
+ IPage<StorePlatformBenefitsVo> pageRequest = new Page<>(page, size);
|
|
|
|
|
+ QueryWrapper<StorePlatformBenefitsVo> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 动态查询条件
|
|
|
|
|
+ if (type != null) {
|
|
|
|
|
+ queryWrapper.eq("type", type);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (name != null && !name.isEmpty()) {
|
|
|
|
|
+ queryWrapper.eq("name", name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 按创建时间倒序
|
|
|
|
|
+ queryWrapper.orderByDesc("created_time");
|
|
|
|
|
+
|
|
|
|
|
+ return benefitsMapper.getPlatformBenefitsPage(pageRequest, queryWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public StorePlatformBenefits getById(Integer id) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.getById - id={}", id);
|
|
|
|
|
+ return benefitsMapper.selectById(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int add(StorePlatformBenefits benefits) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.add - benefits={}", benefits);
|
|
|
|
|
+ JSONObject data = JwtUtil.getCurrentUserInfo();
|
|
|
|
|
+ Integer userId = null;
|
|
|
|
|
+ if (data != null) {
|
|
|
|
|
+ userId = data.getInteger("userId");
|
|
|
|
|
+ log.info("获取用户ID:userId={}", userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (benefits.getType() == 2) {
|
|
|
|
|
+ StoreVirtualCurrency virtualCurrency = new StoreVirtualCurrency();
|
|
|
|
|
+ virtualCurrency.setName(benefits.getName());
|
|
|
|
|
+ virtualCurrency.setStatus(0);
|
|
|
|
|
+ virtualCurrency.setCreatedTime(new Date());
|
|
|
|
|
+ virtualCurrency.setCreatedUserId(userId);
|
|
|
|
|
+ virtualCurrencyMapper.insert(virtualCurrency);
|
|
|
|
|
+
|
|
|
|
|
+ benefits.setBusinessId(virtualCurrency.getId().toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ benefits.setCreatedTime(new Date());
|
|
|
|
|
+ benefits.setDeleteFlag(0);
|
|
|
|
|
+ benefits.setCreatedUserId(userId);
|
|
|
|
|
+ // 默认待审核
|
|
|
|
|
+ if (benefits.getStatus() == null) {
|
|
|
|
|
+ benefits.setStatus(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ return benefitsMapper.insert(benefits);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int update(StorePlatformBenefits benefits) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.update - benefits={}", benefits);
|
|
|
|
|
+ JSONObject data = JwtUtil.getCurrentUserInfo();
|
|
|
|
|
+ Integer userId = null;
|
|
|
|
|
+ if (data != null) {
|
|
|
|
|
+ userId = data.getInteger("userId");
|
|
|
|
|
+ log.info("获取用户ID:userId={}", userId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (benefits.getType() == 2) {
|
|
|
|
|
+ StoreVirtualCurrency virtualCurrency = new StoreVirtualCurrency();
|
|
|
|
|
+ virtualCurrency.setId(benefits.getVirtualCurrencyId());
|
|
|
|
|
+ virtualCurrency.setName(benefits.getName());
|
|
|
|
|
+ virtualCurrency.setUpdatedTime(new Date());
|
|
|
|
|
+ virtualCurrency.setUpdatedUserId(userId);
|
|
|
|
|
+ virtualCurrencyMapper.updateById(virtualCurrency);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ benefits.setUpdatedUserId(userId);
|
|
|
|
|
+ benefits.setUpdatedTime(new Date());
|
|
|
|
|
+ return benefitsMapper.updateById(benefits);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int delete(Integer id) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.delete - id={}", id);
|
|
|
|
|
+ StorePlatformBenefits benefits = new StorePlatformBenefits();
|
|
|
|
|
+ benefits.setId(id);
|
|
|
|
|
+ benefits.setDeleteFlag(1);
|
|
|
|
|
+ benefits.setUpdatedTime(new Date());
|
|
|
|
|
+ return benefitsMapper.updateById(benefits);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int audit(Integer id, Integer status) {
|
|
|
|
|
+ log.info("StorePlatformBenefitsServiceImpl.audit - id={}, status={}", id, status);
|
|
|
|
|
+ StorePlatformBenefits benefits = new StorePlatformBenefits();
|
|
|
|
|
+ benefits.setId(id);
|
|
|
|
|
+ benefits.setStatus(status);
|
|
|
|
|
+ benefits.setUpdatedTime(new Date());
|
|
|
|
|
+ return benefitsMapper.updateById(benefits);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|