From a836f03a5d1fbfa81e147d09ffdfa87ba3975c13 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期二, 18 三月 2025 16:45:02 +0800
Subject: [PATCH] 1

---
 server/services/src/main/java/com/doumee/service/business/impl/DiscountLogServiceImpl.java |  123 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 0 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/DiscountLogServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/DiscountLogServiceImpl.java
new file mode 100644
index 0000000..fddabd9
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/service/business/impl/DiscountLogServiceImpl.java
@@ -0,0 +1,123 @@
+package com.doumee.service.business.impl;
+
+import com.doumee.core.constants.Constants;
+import com.doumee.core.model.PageData;
+import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.DiscountLogMapper;
+import com.doumee.dao.business.model.DiscountLog;
+import com.doumee.dao.business.model.DiscountMember;
+import com.doumee.dao.system.model.SystemUser;
+import com.doumee.service.business.DiscountLogService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 鐢ㄦ埛濂楅鍗′娇鐢ㄨ皟鏁存棩蹇楄〃Service瀹炵幇
+ * @author 姹熻箘韫�
+ * @date 2025/02/17 09:43
+ */
+@Service
+public class DiscountLogServiceImpl implements DiscountLogService {
+
+    @Autowired
+    private DiscountLogMapper discountLogMapper;
+
+    @Override
+    public String create(DiscountLog discountLog) {
+        discountLogMapper.insert(discountLog);
+        return discountLog.getId();
+    }
+
+    @Override
+    public void deleteById(String id) {
+        discountLogMapper.deleteById(id);
+    }
+
+    @Override
+    public void delete(DiscountLog discountLog) {
+        UpdateWrapper<DiscountLog> deleteWrapper = new UpdateWrapper<>(discountLog);
+        discountLogMapper.delete(deleteWrapper);
+    }
+
+    @Override
+    public void deleteByIdInBatch(List<String> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            return;
+        }
+        discountLogMapper.deleteBatchIds(ids);
+    }
+
+    @Override
+    public void updateById(DiscountLog discountLog) {
+        discountLogMapper.updateById(discountLog);
+    }
+
+    @Override
+    public void updateByIdInBatch(List<DiscountLog> discountLogs) {
+        if (CollectionUtils.isEmpty(discountLogs)) {
+            return;
+        }
+        for (DiscountLog discountLog: discountLogs) {
+            this.updateById(discountLog);
+        }
+    }
+
+    @Override
+    public DiscountLog findById(String id) {
+        return discountLogMapper.selectById(id);
+    }
+
+    @Override
+    public DiscountLog findOne(DiscountLog discountLog) {
+        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
+        return discountLogMapper.selectOne(wrapper);
+    }
+
+    @Override
+    public List<DiscountLog> findList(DiscountLog discountLog) {
+        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
+        return discountLogMapper.selectList(wrapper);
+    }
+  
+    @Override
+    public PageData<DiscountLog> findPage(PageWrap<DiscountLog> pageWrap) {
+        IPage<DiscountLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
+        MPJLambdaWrapper<DiscountLog> queryWrapper = new MPJLambdaWrapper<>();
+        Utils.MP.blankToNull(pageWrap.getModel());
+        DiscountLog model = pageWrap.getModel();
+        queryWrapper.selectAll(DiscountLog.class)
+                .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName)
+                .leftJoin(SystemUser.class,SystemUser::getId,DiscountLog::getCreator)
+                .eq(DiscountLog::getIsdeleted, Constants.ZERO)
+                .eq(Objects.nonNull(model.getType()),DiscountLog::getType,model.getType())
+                .eq(StringUtils.isNotBlank(model.getDiscountMemberId()),DiscountLog::getDiscountMemberId,model.getDiscountMemberId());
+        PageData<DiscountLog> pageData = PageData.from(discountLogMapper.selectJoinPage(page, DiscountLog.class,queryWrapper));
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(pageData.getRecords())){
+            for (DiscountLog discountLog:pageData.getRecords()) {
+                if(Constants.equalsInteger(discountLog.getType(),Constants.ZERO)&&Objects.nonNull(discountLog.getRidePrice())){
+                    discountLog.setRidePrice(
+                            Constants.translateMoney(discountLog.getRidePrice())
+                    );
+                }
+            }
+        }
+        return pageData;
+    }
+
+    @Override
+    public long count(DiscountLog discountLog) {
+        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
+        return discountLogMapper.selectCount(wrapper);
+    }
+}

--
Gitblit v1.9.3