Commit e243f138 by wuwenlong

Merge remote-tracking branch 'origin/main'

parents a6338704 52e2754b
......@@ -75,11 +75,7 @@ public class SCleanConsumerController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SConsumer sConsumer)
{
sConsumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
sConsumer.setAccount(sConsumer.getPhone());
String password = BaseUtil.encryptPassword("12345678", sConsumer.getPhone());
sConsumer.setPwd(password);
return toAjax(sConsumerService.insertSConsumer(sConsumer));
return toAjax(sConsumerService.addCleanConsumer(sConsumer));
}
/**
......@@ -101,6 +97,6 @@ public class SCleanConsumerController extends BaseController
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sConsumerService.deleteSConsumerByIds(ids));
return toAjax(sConsumerService.deleteCleanConsumerByIds(ids));
}
}
......@@ -10,7 +10,9 @@ public enum SmsTypeEnum {
SMS_CODE_TEMP(1,"sms.code.template","短信验证码"),
SMS_CLEAN_RECORDS_TEMP(2,"sms.clean.records.template","保洁任务短信提示"),
SMS_CLEAN_RECORDS_TEMP_15(3,"sms.clean.records.template.15","即将保洁任务短信提醒")
SMS_CLEAN_RECORDS_TEMP_15(3,"sms.clean.records.template.15","即将保洁任务短信提醒"),
SMS_ORDER_START_TEMP(4,"sms.order.start.template","订单即将开始提示短信"),
SMS_ORDER_END_TEMP(5,"sms.order.end.template","订单即结束始提示短信"),
;
private Integer code;
......
......@@ -6,6 +6,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.util.AntPathMatcher;
import share.common.constant.Constants;
import share.common.core.text.StrFormatter;
......@@ -611,4 +614,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
return sb.toString();
}
/**
* 将字符串中的数字与字母分开
* @param str
* @return
*/
public static Map<String,String> spiltStr(String str) {
if (StrUtil.isNotEmpty(str)) {
Map<String, String> map = MapUtil.newHashMap();
String letters = "";
String digits = "";
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (Character.isLetter(c)) {
letters += c;
} else if (Character.isDigit(c)) {
digits += c;
}
}
map.put("letters", letters);
map.put("digits", digits);
return map;
}
return null;
}
}
\ No newline at end of file
......@@ -29,15 +29,15 @@ public class CaptchaConfig
// 验证码图片高度 默认为50
properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
// 验证码文本字符大小 默认为40
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38");
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "45");
// KAPTCHA_SESSION_KEY
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode");
// 验证码文本字符长度 默认为5
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
// properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
......
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SConsumptionRecords;
@Data
public class SConsumptionRecordsVo extends SConsumptionRecords {
private String orderNo;
private String nickName;
private String phone;
}
......@@ -60,4 +60,6 @@ public interface SStoreMapper extends BaseMapper<SStore>
* @return 结果
*/
public int deleteSStoreByIds(Long[] ids);
SStore selectByMaxDeviceGroup();
}
......@@ -113,4 +113,13 @@ public interface SConsumerService extends IService<SConsumer>
boolean editSConsumer(SConsumer request);
List<SConsumer> selectUnallocatedList(SConsumerVo sConsumer);
/**
* 添加保洁人员
* @param sConsumer
* @return
*/
int addCleanConsumer(SConsumer sConsumer);
int deleteCleanConsumerByIds(Long[] ids);
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -13,10 +16,12 @@ import org.springframework.stereotype.Service;
import share.common.constant.Constants;
import share.common.constant.SmsConstants;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SRoomPack;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper;
......@@ -215,4 +220,42 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
public List<SConsumer> selectUnallocatedList(SConsumerVo sConsumer) {
return baseMapper.selectUnallocatedList(sConsumer);
}
@Override
public int addCleanConsumer(SConsumer sConsumer) {
LambdaQueryWrapper<SConsumer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and((wrapper)->{
wrapper.eq(SConsumer::getPhone, sConsumer.getPhone())
.or()
.eq(SConsumer::getAccount, sConsumer.getPhone());
});
List<SConsumer> list = baseMapper.selectList(queryWrapper);
// 存在用户设置未保洁人员,不存在新增保洁人员
if (list.size() > 0) {
SConsumer consumer = list.get(0);
consumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
return baseMapper.updateSConsumer(consumer);
} else {
sConsumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
sConsumer.setAccount(sConsumer.getPhone());
String password = BaseUtil.encryptPassword("12345678", sConsumer.getPhone());
sConsumer.setPwd(password);
return baseMapper.insertSConsumer(sConsumer);
}
}
@Override
public int deleteCleanConsumerByIds(Long[] ids) {
if (ArrayUtil.isNotEmpty(ids)) {
List<Long> idList = ListUtil.toList(ids);
List<SConsumer> list = baseMapper.selectBatchIds(idList);
list.stream().forEach(sConsumer -> {
sConsumer.setRoleType(RoleTypeEnum.MEMBRO.getCode());
});
updateBatchById(list);
return idList.size();
}
return 0;
}
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.SOrder;
import share.system.domain.vo.SConsumptionRecordsVo;
import share.system.mapper.SConsumerMapper;
import share.system.mapper.SConsumptionRecordsMapper;
import share.system.domain.SConsumptionRecords;
import share.system.mapper.SOrderMapper;
import share.system.service.ISConsumptionRecordsService;
import share.system.service.SConsumerService;
/**
* 消费记录Service业务层处理
......@@ -20,6 +30,12 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
@Autowired
private SConsumptionRecordsMapper sConsumptionRecordsMapper;
@Autowired
private SConsumerMapper sConsumerMapper;
@Autowired
private SOrderMapper sOrderMapper;
/**
* 查询消费记录
*
......@@ -41,7 +57,29 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
@Override
public List<SConsumptionRecords> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords)
{
return sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords);
List<SConsumptionRecords> sConsumptionRecordsList = sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords);
//获取消费记录的用户id集合
List<Long> collect = sConsumptionRecordsList.stream().map(SConsumptionRecords::getConsumerId).collect(Collectors.toList());
//获取用户id集合的用户信息
List<SConsumer> sConsumers = sConsumerMapper.selectBatchIds(collect);
List<Long> oredrIds = sConsumptionRecordsList.stream().map(SConsumptionRecords::getOrderId).collect(Collectors.toList());
List<SOrder> sOrders = sOrderMapper.selectBatchIds(oredrIds);
List<SConsumptionRecordsVo> sConsumptionRecordsVoList = new ArrayList<>();
BeanUtils.copyProperties(sConsumptionRecordsList, sConsumptionRecordsVoList);
sConsumptionRecordsVoList.stream().forEach(item -> {
sConsumers.stream().forEach(vo -> {
if (item.getConsumerId().equals(vo.getId())) {
item.setNickName(vo.getNickName());
item.setPhone(vo.getPhone());
}
});
sOrders.stream().forEach(vo -> {
if (item.getOrderId().equals(vo.getId())) {
item.setOrderNo(vo.getOrderNo());
}
});
});
return sConsumptionRecordsList;
}
/**
......
......@@ -3,6 +3,9 @@ package share.system.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopScopeResponseEntity;
......@@ -82,6 +85,21 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
@Override
public int insertSStore(SStore sStore) {
sStore.setCreateTime(DateUtils.getNowDate());
// 获取最新设备分组
SStore store = baseMapper.selectByMaxDeviceGroup();
if (ObjectUtil.isNotEmpty(store)) {
String deviceGroup = store.getDeviceGroup();
Map<String,String> map = share.common.utils.StringUtils.spiltStr(deviceGroup);
if (ObjectUtil.isNotEmpty(map)) {
String s = ObjectUtil.isNotEmpty(map.get("letters")) ? map.get("letters") : "FFFA";
Integer e = NumberUtil.isInteger(map.get("digits")) ? Integer.parseInt(map.get("digits"))+1 : 10000001;
sStore.setDeviceGroup(StrUtil.concat(true, s, String.valueOf(e)));
} else {
sStore.setDeviceGroup("FFFA10000001");
}
} else {
sStore.setDeviceGroup("FFFA10000001");
}
return baseMapper.insertSStore(sStore);
}
......
......@@ -123,12 +123,26 @@ public class SmsServiceImpl implements SmsService {
@Override
public boolean sendSmsOrderStartRemind(String phone, SStore store, SRoom room) {
return false;
// 通过配置获取短信模版
SysConfig config = sysConfigMapper.checkConfigKeyUnique(SmsTypeEnum.SMS_ORDER_START_TEMP.getValue());
if (config != null) {
String content = MessageFormat.format(config.getConfigValue(), room.getName(), store.getAddress());
return sendSms(phone, SmsTypeEnum.SMS_ORDER_START_TEMP.getCode(), content);
} else {
return Boolean.FALSE;
}
}
@Override
public boolean sendSmsOrderEndRemind(String phone, SStore store, SRoom room) {
return false;
// 通过配置获取短信模版
SysConfig config = sysConfigMapper.checkConfigKeyUnique(SmsTypeEnum.SMS_ORDER_END_TEMP.getValue());
if (config != null) {
String content = MessageFormat.format(config.getConfigValue(), room.getName());
return sendSms(phone, SmsTypeEnum.SMS_ORDER_END_TEMP.getCode(), content);
} else {
return Boolean.FALSE;
}
}
private String getSmsContent(String phone, Integer tag) {
......
......@@ -48,8 +48,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="consumerId != null"> and t1.consumer_id = #{consumerId}</if>
<if test="roomId != null"> and t1.room_id = #{roomId}</if>
<if test="storeId != null"> and t1.store_id = #{storeId}</if>
<if test="createTime != null ">
and DATE_FORMAT(t1.create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime}, '%Y-%m-%d')
</if>
</where>
ORDER BY create_time DESC
order by create_time desc
</select>
<select id="selectSCleanRecordsById" parameterType="Long" resultMap="SCleanRecordsResult">
......
......@@ -69,6 +69,7 @@
<if test="openEndTime != null "> and open_end_time = #{openEndTime}</if>
<if test="storeType != null "> and store_type = #{storeType}</if>
</where>
order by create_time desc
</select>
<select id="selectSStoreById" parameterType="Long" resultMap="SStoreResult">
......@@ -76,6 +77,10 @@
where id = #{id}
</select>
<select id="selectByMaxDeviceGroup" resultMap="SStoreResult">
<include refid="selectSStoreVo"/> order by device_group desc limit 1
</select>
<insert id="insertSStore" parameterType="SStore" useGeneratedKeys="true" keyProperty="id">
insert into s_store
<trim prefix="(" suffix=")" suffixOverrides=",">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment