|
|
@@ -14,17 +14,18 @@ import com.kxmall.common.enums.RiderWorkStateType;
|
|
|
import com.kxmall.common.exception.ServiceException;
|
|
|
import com.kxmall.common.utils.StringUtils;
|
|
|
import com.kxmall.common.utils.file.FileUtils;
|
|
|
-import com.kxmall.group.domain.KxGroupShop;
|
|
|
import com.kxmall.rider.domain.KxRider;
|
|
|
import com.kxmall.rider.domain.KxRiderCycle;
|
|
|
import com.kxmall.rider.domain.bo.KxRiderBo;
|
|
|
import com.kxmall.rider.domain.vo.KxRiderVo;
|
|
|
import com.kxmall.rider.mapper.KxRiderCycleMapper;
|
|
|
import com.kxmall.rider.mapper.KxRiderMapper;
|
|
|
+import com.kxmall.rider.domain.KxRiderAuthAttachment;
|
|
|
import com.kxmall.storage.domain.KxStorage;
|
|
|
import com.kxmall.storage.mapper.KxStorageMapper;
|
|
|
import com.kxmall.system.service.ISysConfigService;
|
|
|
import com.kxmall.web.controller.rider.service.IKxRiderService;
|
|
|
+import com.kxmall.web.controller.rider.service.IKxRiderAuthAttachmentService;
|
|
|
import com.kxmall.wechat.WxMpConfiguration;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
|
|
@@ -59,6 +60,8 @@ public class KxRiderServiceImpl implements IKxRiderService {
|
|
|
|
|
|
private final ISysConfigService configService;
|
|
|
|
|
|
+ private final IKxRiderAuthAttachmentService attachmentService;
|
|
|
+
|
|
|
// 初始密码
|
|
|
private static final String ININT_PASSWORD = "123456";
|
|
|
|
|
|
@@ -76,6 +79,11 @@ public class KxRiderServiceImpl implements IKxRiderService {
|
|
|
if (riderCycles != null && riderCycles.size() > 0) {
|
|
|
riderVo.setWeekNumberIds(riderCycles.stream().map(KxRiderCycle::getWeekNumber).collect(Collectors.toList()));
|
|
|
}
|
|
|
+
|
|
|
+ // 查询骑手附件
|
|
|
+ List<KxRiderAuthAttachment> attachments = attachmentService.getAttachmentsByRiderId(id);
|
|
|
+ riderVo.setAttachments(attachments);
|
|
|
+
|
|
|
return riderVo;
|
|
|
}
|
|
|
throw new ServiceException("配送员不存在");
|
|
|
@@ -153,9 +161,15 @@ public class KxRiderServiceImpl implements IKxRiderService {
|
|
|
add.setUpdateTime(now);
|
|
|
add.setLoginType(0);
|
|
|
if (baseMapper.insert(add) > 0) {
|
|
|
+ Long riderDOId = add.getId();
|
|
|
+
|
|
|
+ // 保存骑手附件
|
|
|
+ if (bo.getAttachments() != null && !bo.getAttachments().isEmpty()) {
|
|
|
+ attachmentService.saveAttachments(riderDOId, bo.getAttachments());
|
|
|
+ }
|
|
|
+
|
|
|
List<Long> weekNumberIds = bo.getWeekNumberIds();
|
|
|
if (weekNumberIds != null && weekNumberIds.size() > 0) {
|
|
|
- Long riderDOId = add.getId();
|
|
|
KxRiderCycle riderCycle;
|
|
|
List<KxRiderCycle> riderCycleDOList = new ArrayList<>();
|
|
|
for (Long weekNumber : weekNumberIds) {
|
|
|
@@ -200,6 +214,12 @@ public class KxRiderServiceImpl implements IKxRiderService {
|
|
|
|
|
|
if (baseMapper.updateById(update) > 0) {
|
|
|
Long riderDOId = bo.getId();
|
|
|
+
|
|
|
+ // 更新骑手附件
|
|
|
+ if (bo.getAttachments() != null) {
|
|
|
+ attachmentService.saveAttachments(riderDOId, bo.getAttachments());
|
|
|
+ }
|
|
|
+
|
|
|
QueryWrapper<KxRiderCycle> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("rider_id", riderDOId);
|
|
|
riderCycleMapper.delete(queryWrapper);
|
|
|
@@ -411,4 +431,27 @@ public class KxRiderServiceImpl implements IKxRiderService {
|
|
|
public KxRider getById(Long riderId) {
|
|
|
return baseMapper.selectById(riderId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置骑手登录密码
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean resetRiderPassword(Long riderId) {
|
|
|
+ KxRider rider = baseMapper.selectById(riderId);
|
|
|
+ if (rider == null) {
|
|
|
+ throw new ServiceException("骑手不存在");
|
|
|
+ }
|
|
|
+ String phone = rider.getPhone();
|
|
|
+ if (StringUtils.isEmpty(phone)) {
|
|
|
+ throw new ServiceException("骑手手机号不存在,无法重置密码");
|
|
|
+ }
|
|
|
+ String saltSource = phone.length() >= 7 ? phone.substring(0, 7) : phone;
|
|
|
+ String cryptPassword = Md5Crypt.md5Crypt(ININT_PASSWORD.getBytes(), "$1$" + saltSource);
|
|
|
+ KxRider update = new KxRider();
|
|
|
+ update.setId(riderId);
|
|
|
+ update.setPassword(cryptPassword);
|
|
|
+ update.setUpdateTime(new Date());
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
}
|