|
@@ -0,0 +1,138 @@
|
|
|
+package com.iotechn.unimall.app.api.market;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
+import com.iotechn.unimall.core.exception.ServiceException;
|
|
|
+import com.iotechn.unimall.data.domain.market.KouzhaoInfo;
|
|
|
+import com.iotechn.unimall.data.mapper.market.KouzhaoInfoMapper;
|
|
|
+import com.iotechn.unimall.data.model.Page;
|
|
|
+import com.iotechn.unimall.data.util.ExcelUtil;
|
|
|
+import org.apache.ibatis.session.RowBounds;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 口罩信息Service业务层处理
|
|
|
+ *
|
|
|
+ * @author jlb
|
|
|
+ * @date 2022-09-06
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class KouzhaoInfoServiceAppImpl implements IKouzhaoInfoAppService {
|
|
|
+ @Autowired
|
|
|
+ private KouzhaoInfoMapper kouzhaoInfoMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean add(KouzhaoInfo kouzhaoInfo, Long adminId) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ kouzhaoInfo.setGmtCreate(now);
|
|
|
+ kouzhaoInfo.setGmtUpdate(now);
|
|
|
+ String billNo = "";
|
|
|
+ String year = new SimpleDateFormat("yy", Locale.CHINESE).format(new Date());
|
|
|
+ String month = new SimpleDateFormat("MM", Locale.CHINESE).format(new Date());
|
|
|
+ String day = new SimpleDateFormat("dd",Locale.CHINESE).format(new Date());
|
|
|
+ int count = kouzhaoInfoMapper.selectCount(new EntityWrapper<KouzhaoInfo>()
|
|
|
+ .and("date(gmt_create) = curdate()"));
|
|
|
+ int maxCount = count + 1;
|
|
|
+ if (maxCount < 10) {
|
|
|
+ billNo = year + month + day + "00" + maxCount;
|
|
|
+ } else if (maxCount < 100) {
|
|
|
+ billNo = year + month + day + "0" + maxCount;
|
|
|
+ } else {
|
|
|
+ billNo = year + month + day + maxCount;
|
|
|
+ }
|
|
|
+ kouzhaoInfo.setNumberOrder(billNo);
|
|
|
+ return kouzhaoInfoMapper.insert(kouzhaoInfo) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<KouzhaoInfo> list(Long userId, String numberOrder, String name, String phone, String shejiUrl, String lituUrl, Date gmtUpdate, Date gmtCreate, Integer page, Integer limit) throws ServiceException {
|
|
|
+ Wrapper<KouzhaoInfo> wrapper = new EntityWrapper<KouzhaoInfo>();
|
|
|
+ if (!StringUtils.isEmpty(userId)) {
|
|
|
+ wrapper.eq("user_id", userId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(numberOrder)) {
|
|
|
+ wrapper.eq("number_order", numberOrder);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(name)) {
|
|
|
+ wrapper.eq("name", name);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(phone)) {
|
|
|
+ wrapper.eq("phone", phone);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(shejiUrl)) {
|
|
|
+ wrapper.eq("sheji_url", shejiUrl);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(lituUrl)) {
|
|
|
+ wrapper.eq("litu_url", lituUrl);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtUpdate)) {
|
|
|
+ wrapper.eq("gmt_update", gmtUpdate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtCreate)) {
|
|
|
+ wrapper.eq("gmt_create", gmtCreate);
|
|
|
+ }
|
|
|
+ wrapper.eq("delete_flag", 0);
|
|
|
+ List<KouzhaoInfo> list = kouzhaoInfoMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
|
|
|
+ Integer count = kouzhaoInfoMapper.selectCount(wrapper);
|
|
|
+ return new Page<KouzhaoInfo>(list, page, limit, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delete(String id) {
|
|
|
+ kouzhaoInfoMapper.deleteById(id);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean update(KouzhaoInfo kouzhaoInfo, Long adminId) throws ServiceException {
|
|
|
+ Date now = new Date();
|
|
|
+ kouzhaoInfo.setGmtUpdate(now);
|
|
|
+ return kouzhaoInfoMapper.updateById(kouzhaoInfo) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public KouzhaoInfo get(Long id) throws ServiceException {
|
|
|
+ return kouzhaoInfoMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String export(Long userId, String numberOrder, String name, String phone, String shejiUrl, String lituUrl, Date gmtUpdate, Date gmtCreate, Integer page, Integer limit) throws ServiceException {
|
|
|
+ Wrapper<KouzhaoInfo> wrapper = new EntityWrapper<KouzhaoInfo>();
|
|
|
+ if (!StringUtils.isEmpty(userId)) {
|
|
|
+ wrapper.eq("user_id", userId);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(numberOrder)) {
|
|
|
+ wrapper.eq("number_order", numberOrder);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(name)) {
|
|
|
+ wrapper.eq("name", name);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(phone)) {
|
|
|
+ wrapper.eq("phone", phone);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(shejiUrl)) {
|
|
|
+ wrapper.eq("sheji_url", shejiUrl);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(lituUrl)) {
|
|
|
+ wrapper.eq("litu_url", lituUrl);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtUpdate)) {
|
|
|
+ wrapper.eq("gmt_update", gmtUpdate);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gmtCreate)) {
|
|
|
+ wrapper.eq("gmt_create", gmtCreate);
|
|
|
+ }
|
|
|
+ List<KouzhaoInfo> list = kouzhaoInfoMapper.selectList(wrapper);
|
|
|
+ ExcelUtil<KouzhaoInfo> util = new ExcelUtil<KouzhaoInfo>(KouzhaoInfo.class);
|
|
|
+ return util.exportExcel(list, "操作日志");
|
|
|
+ }
|
|
|
+}
|