Commit ce4c4e40 by YG8999

Merge remote-tracking branch 'origin/dev' into dev

parents 6376ac76 88617da6
......@@ -31,7 +31,7 @@ public class SCleanConsumerController extends BaseController
private SConsumerService sConsumerService;
/**
* 查询保洁员用户列表
* 查询员用户列表
*/
@PreAuthorize("@ss.hasPermi('system:cleanConsumer:list')")
@GetMapping("/list")
......@@ -68,7 +68,7 @@ public class SCleanConsumerController extends BaseController
}
/**
* 新增保洁员用户
* 新增员用户
*/
@PreAuthorize("@ss.hasPermi('system:cleanConsumer:add')")
@Log(title = "保洁员", businessType = BusinessType.INSERT)
......
......@@ -26,6 +26,7 @@ import share.system.domain.SStore;
import share.system.domain.SStoreConsumer;
import share.system.domain.SysUserRole;
import share.system.domain.vo.SConsumerVo;
import share.system.domain.vo.SStoreConsumerVo;
import share.system.service.ISStoreService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -175,9 +176,9 @@ public class SStoreController extends BaseController
@PreAuthorize("@ss.hasPermi('system:store:edit')")
@Log(title = "门店", businessType = BusinessType.GRANT)
@PutMapping("/consumer/cancelAll")
public AjaxResult cancelAuthUserAll(Long storeId, Long[] consumerIds)
public AjaxResult cancelAuthUserAll(SStoreConsumerVo storeConsumer)
{
return toAjax(sStoreService.deleteStoreConsumers(storeId, consumerIds));
return toAjax(sStoreService.deleteStoreConsumers(storeConsumer));
}
/**
......@@ -186,9 +187,9 @@ public class SStoreController extends BaseController
@PreAuthorize("@ss.hasPermi('system:store:edit')")
@Log(title = "门店", businessType = BusinessType.GRANT)
@PutMapping("/consumer/selectAll")
public AjaxResult selectAuthUserAll(Long storeId, Long[] consumerIds)
public AjaxResult selectAuthUserAll(SStoreConsumerVo storeConsumer)
{
return toAjax(sStoreService.insertStoreConsumers(storeId, consumerIds));
return toAjax(sStoreService.insertStoreConsumers(storeConsumer));
}
......
package share.common.enums;
//职位枚举
public enum PositionEnum {
//1保洁人员 2管理员
CLEANER(1, "保洁人员"),
ADMIN(2, "管理员"),
;
private Integer code;
private String name;
PositionEnum() {
}
PositionEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -2,8 +2,8 @@ package share.common.enums;
public enum RoleTypeEnum {
MEMBRO(0, "会员"),
CLEANER(1, "保洁人员"),
ADMIN(2, "后台管理人员");;
CLEANER(1, "员"),
;
private Integer code;
private String name;
......
......@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import share.common.enums.MessageReminderEnum;
import share.system.config.WxMaProperties;
import share.system.domain.vo.SendTemplateMessageItemVo;
import share.system.domain.vo.TemplateMessageVo;
......@@ -19,6 +20,7 @@ import share.system.util.WXMsgPushUtils;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -32,6 +34,8 @@ import java.util.Map;
public class WxMsgPushController {
private final WxMaService wxMaService;
private final WxMaProperties properties;
@Autowired
private WechatNewService wechatNewService;
/**
* // * 跳转的小程序页面
* //
......@@ -66,43 +70,81 @@ public class WxMsgPushController {
@GetMapping("/getOpenId")
public void getOpenId(String openId) throws Exception {
// HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
// TemplateMessageVo templateMessageVo = new TemplateMessageVo();
// templateMessageVo.setTouser(openId);
// templateMessageVo.setTemplate_id("oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8");
// templateMessageVo.setUrl("http://www.baidu.com");
// data.put("thing4", new SendTemplateMessageItemVo("预约门店"));
// data.put("thing7", new SendTemplateMessageItemVo("服务名称"));
// data.put("date3", new SendTemplateMessageItemVo(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")));
// data.put("thing5", new SendTemplateMessageItemVo("地址"));
// templateMessageVo.setData(data);
// log.info("开始发送消息!!!!");
// Boolean b = wechatNewService.sendMiniSubscribeMessage(templateMessageVo);
// if(b){
// log.info("消息发送成功!!!!");
// }
HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
TemplateMessageVo templateMessageVo = new TemplateMessageVo();
templateMessageVo.setTouser(openId);
templateMessageVo.setMiniprogram_state("trial");
templateMessageVo.setPage("/pages/orderResult/orderResult?orderNo=CJ431705545528576539");
templateMessageVo.setTemplate_id(MessageReminderEnum.END.getValue());
data.put("thing5", new SendTemplateMessageItemVo("武汉"));
//服务名称
data.put("thing6", new SendTemplateMessageItemVo("服务名称"));
//订单时间
data.put("time7", new SendTemplateMessageItemVo("2020-12-12 12:12:12 ~ 2020-12-13 12:12:12"));
//温馨提示
data.put("thing4", new SendTemplateMessageItemVo(MessageReminderEnum.END.getTips()));
templateMessageVo.setData(data);
log.info("开始发送消息!!!!");
Boolean a = wechatNewService.sendMiniSubscribeMessage(templateMessageVo);
if (a) {
log.info("消息发送成功!!!!");
}
templateMessageVo.setTemplate_id(MessageReminderEnum.RESERVER.getValue());
//订单门店
data.put("thing3", new SendTemplateMessageItemVo("武汉"));
//服务名称
data.put("thing1", new SendTemplateMessageItemVo("服务名称"));
//订单时间
data.put("date2", new SendTemplateMessageItemVo(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")));
//温馨提示
data.put("thing6", new SendTemplateMessageItemVo(MessageReminderEnum.RESERVER.getTips()));
log.info("开始发送消息!!!!");
Boolean b = wechatNewService.sendMiniSubscribeMessage(templateMessageVo);
if (b) {
log.info("消息发送成功!!!!");
}
templateMessageVo.setTemplate_id(MessageReminderEnum.START.getValue());
//预约门店
data.put("thing6", new SendTemplateMessageItemVo("武汉"));
//服务名称
data.put("thing7", new SendTemplateMessageItemVo("服务名称"));
//预约时间
data.put("time8", new SendTemplateMessageItemVo("2024-12-12 12:12:12 ~ 2024-12-13 12:12:12"));
//温馨提示
data.put("thing5", new SendTemplateMessageItemVo(MessageReminderEnum.START.getTips()));
Map<String, String> map = new HashMap<>();
map.put("thing4", "预约门店");
map.put("thing7", "服务名称");
map.put("date3", LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"));
map.put("thing5", "地址");
WxMaSubscribeMessage wxMaSubscribeMessage = WxMaSubscribeMessage.builder()
.toUser(openId)
.templateId("oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8")
.page(PAGES_ZP)
.build();
// 设置将推送的消息
map.forEach((k, v) -> {
wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData(k, v));
});
try {
log.info("开始发送消息!!!!");
wxMaService.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage);
Boolean c = wechatNewService.sendMiniSubscribeMessage(templateMessageVo);
if (c) {
log.info("消息发送成功!!!!");
} catch (WxErrorException e) {
e.printStackTrace();
}
// Map<String, String> data = new HashMap<>();
// data.put("thing5", "订单门店");
// //服务名称
// data.put("thin6", "服务名称");
// //订单时间
// data.put("time7", new Date().toString());
// //温馨提示
// data.put("thing4", MessageReminderEnum.RESERVER.getTips());
// WxMaSubscribeMessage wxMaSubscribeMessage = WxMaSubscribeMessage.builder()
// .toUser(openId)
// .templateId("UkvsRnZkZB_w3MqXPbRhi4jEk8ML4N9PWT3rnd3Bhxg")
// .page(PAGES_ZP)
// .build();
// // 设置将推送的消息
// data.forEach((k, v) -> {
// wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData(k, v));
// });
// try {
// log.info("开始发送消息!!!!");
// wxMaService.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage);
// log.info("消息发送成功!!!!");
// } catch (WxErrorException e) {
// e.printStackTrace();
// }
}
}
package share.web.controller.system;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -8,6 +9,8 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.utils.SecurityUtils;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.Device;
......@@ -15,6 +18,7 @@ import share.system.domain.SConsumer;
import share.system.domain.vo.DeviceParamVo;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.mapper.SStoreConsumerMapper;
import share.system.mqtt.MqttGatewayComponent;
import share.system.service.DeviceLogService;
import share.system.service.DeviceService;
......@@ -41,6 +45,8 @@ public class DeviceController extends BaseController {
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private SConsumerService consumerService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
......@@ -49,6 +55,13 @@ public class DeviceController extends BaseController {
@PostMapping(value = "/openOrClose")
public AjaxResult openOrClose(@RequestBody DeviceParamVo deviceParam) {
SConsumer user = consumerService.getInfo();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员");
}
List<Long> longs = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是管理员");
}
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(deviceParam.getDevId(),
user.getAccount(), deviceParam.getOpType());
......
......@@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -21,9 +22,14 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.common.enums.CleaningStatusEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.system.domain.SCleanRecords;
import share.system.domain.SConsumer;
import share.system.domain.SStoreConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SCleanRecordsVo;
import share.system.mapper.SStoreConsumerMapper;
import share.system.service.DeviceOpService;
import share.system.service.ISCleanRecordsService;
import share.common.utils.poi.ExcelUtil;
......@@ -42,6 +48,8 @@ public class SCleanRecordsController extends BaseController
{
@Autowired
private ISCleanRecordsService sCleanRecordsService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
* 查询保洁记录列表
......@@ -76,13 +84,9 @@ public class SCleanRecordsController extends BaseController
*/
@ApiOperation(value = "已开始的保洁记录列表")
@GetMapping("/myCleanList")
public TableDataInfo myCleanList(SCleanRecords sCleanRecords)
public TableDataInfo myCleanList(SCleanRecordsVo sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
startPage();
List<SCleanRecords> list = sCleanRecordsService.myCleanList(sCleanRecords);
return getDataTable(list);
return sCleanRecordsService.myCleanList(sCleanRecords);
}
/**
......@@ -104,10 +108,6 @@ public class SCleanRecordsController extends BaseController
@PostMapping(value = "/startClean")
public AjaxResult startClean(@RequestBody SCleanRecords sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
sCleanRecords.setStartDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANING.getCode());
return toAjax(sCleanRecordsService.startCleanRecords(sCleanRecords));
}
......@@ -119,10 +119,7 @@ public class SCleanRecordsController extends BaseController
@PostMapping(value = "/endClean")
public AjaxResult endClean(@RequestBody SCleanRecords sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
sCleanRecords.setEndDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
return toAjax(sCleanRecordsService.endCleanRecords(sCleanRecords));
}
......
......@@ -15,6 +15,7 @@ import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.system.domain.SConsumer;
import share.system.domain.vo.SConsumerVo;
import share.system.service.SConsumerService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -38,7 +39,7 @@ public class SConsumerController extends BaseController
*/
@ApiOperation(value = "个人中心-用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
public R<SConsumer> getSConsumerCenter() {
public R<SConsumerVo> getSConsumerCenter() {
return R.ok(sConsumerService.getSConsumer());
}
......
......@@ -79,15 +79,11 @@ public class SStoreController extends BaseController
}
/**
* 查询全部门店及全部房间,每个房间绑定的设备列表
* 用户负责的门店设备
*/
@GetMapping("/storeList")
@ApiOperation(value = "查询全部门店及全部房间,每个房间绑定的设备列表")
public AjaxResult storeList() {
return success(sStoreService.storeList());
}
}
package share.quartz.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import share.common.enums.ConsumerCouponStatusEnum;
import share.common.enums.UserStatusEnum;
import share.common.enums.YesNoEnum;
import share.system.domain.CouponLog;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SStore;
import share.system.service.CouponLogService;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISStoreService;
import share.system.service.QPService;
import share.system.service.impl.QPServiceImpl;
import java.util.*;
......@@ -25,17 +17,9 @@ import java.util.stream.Collectors;
@Component("couponRetryTask")
public class CouponRetryTask {
@Autowired
private CouponLogService couponLogService;
@Autowired
private QPService qpService;
@Autowired
private ISStoreService sStoreService;
@Autowired
private ISConsumerCouponService sConsumerCouponService;
private static final Logger logger = LoggerFactory.getLogger(QPServiceImpl.class);
private static final Integer TRY_NUMBER = 3;
public void AuToRetryCoupon() {
LambdaQueryWrapper<SConsumerCoupon> consumerCouponWrapper = new LambdaQueryWrapper<>();
consumerCouponWrapper.eq(SConsumerCoupon::getUseStatus, UserStatusEnum.UNUSED.getCode());
......@@ -50,46 +34,5 @@ public class CouponRetryTask {
if (!CollectionUtils.isEmpty(expiredSConsumerCounpons)) {
sConsumerCouponService.updateBatchById(expiredSConsumerCounpons);
}
LambdaQueryWrapper<CouponLog> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CouponLog::getStatus, YesNoEnum.no.getDisplay_3());
queryWrapper.eq(CouponLog::getNumber, TRY_NUMBER);
List<CouponLog> list = couponLogService.list(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
return;
}
//根据code分组
Map<String, List<CouponLog>> collect = list.stream().collect(Collectors.groupingBy(CouponLog::getCode));
//门店id集合
List<Long> storeIds = list.stream().map(CouponLog::getStoreId).distinct().collect(Collectors.toList());
List<SStore> sStoreList = sStoreService.listByIds(storeIds);
//遍历Map
collect.forEach((k, v) -> {
CouponLog couponLog = v.get(0);
SStore sStore = sStoreList.stream().filter(s -> s.getId().equals(couponLog.getStoreId())).findFirst().get();
if (couponLog.getNumber().equals(TRY_NUMBER)) {
for (int i = 0; i < TRY_NUMBER; i++) {
try {
qpService.consume(couponLog.getCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.TASK.getCode());
} catch (Exception e) {
logger.error("验卷失败:{}", e.getMessage());
} finally {
couponLog.setNumber(couponLog.getNumber() - 1);
couponLogService.updateById(couponLog);
}
}
//根据code批量更新状态
LambdaUpdateWrapper<CouponLog> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(CouponLog::getCode, k);
//设置number为0
updateWrapper.set(CouponLog::getNumber, 0);
couponLogService.update(updateWrapper);
//更新优惠卷领取状态
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setId(couponLog.getCouponId());
sConsumerCoupon.setUseStatus(UserStatusEnum.EXPIRED.getCode());
sConsumerCouponService.updateById(sConsumerCoupon);
}
});
}
}
......@@ -7,11 +7,18 @@ import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareRequest;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareResponse;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......@@ -85,45 +92,31 @@ public class RedisTask {
final long THREE_MINUTES = 60 * 3;
public void AuToReceiptCode() {
//获取redis中所有以tuangou.receipt.prepare开头的key
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.PREPARE.getValue() + "*");
if (keys.size() == 0) {
return;
}
/**
* 自动删除所有可用但已退款的优惠券
*/
public void AutoDelRefundedCoupon() {
//获取所有待使用的优惠卷
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getUseStatus, CouponStatusEnum.NORMAL.getValue());
List<SConsumerCoupon> list = isConsumerCouponService.list(queryWrapper);
//遍历key
keys.stream().forEach(o -> {
//获取key对应的value
String value = redisUtil.get(String.valueOf(o));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
//判断是否过期
if (expirationTime.getTime() < new Date().getTime()) {
//获取redis中的券码id
Long consumerCouponId = jsonObject.getLong("consumerCouponId");
if (CollectionUtils.isEmpty(list)) {
//删除redis中的值
redisUtil.delete(o);
//删除数据库中的值
isConsumerCouponService.deleteSConsumerCouponById(consumerCouponId);
//跳过循环
return;
}
if (ObjectUtil.isEmpty(list.stream().filter(item -> item.getId().equals(consumerCouponId)).findFirst().orElse(null))) {
//删除redis中的值
redisUtil.delete(o);
//删除数据库中的值
isConsumerCouponService.deleteSConsumerCouponById(consumerCouponId);
} else {
//删除redis中的值
redisUtil.delete(o);
LambdaQueryWrapper<SConsumerCoupon> wrapper = Wrappers.lambdaQuery();
wrapper.eq(SConsumerCoupon::getUseStatus, CouponStatusEnum.NORMAL.getValue());
wrapper.isNotNull(SConsumerCoupon::getCouponCode);
List<SConsumerCoupon> coupons = isConsumerCouponService.list(wrapper);
List<SStore> stores = storeService.list();
List<Long> expiredCoupons = new ArrayList<>();
if (!CollectionUtils.isEmpty(coupons)) {
for (SConsumerCoupon coupon : coupons) {
//验券
TuangouReceiptGetConsumedReponseEntity getconsumed = qpService.getconsumed(coupon.getCouponCode(),
stores.stream().filter(store -> store.getId().equals(coupon.getStoreId())).findFirst().get().getOpenShopUuid());
if (getconsumed == null) {
expiredCoupons.add(coupon.getId());
}
logger.info("券码:{}->查询结束:{}", coupon.getCouponCode(), getconsumed);
}
});
//逻辑删除所有异常优惠券
isConsumerCouponService.removeByIds(expiredCoupons);
}
}
public void processAutoReceiptCode() {
......
......@@ -53,7 +53,7 @@ public class SConsumer implements Serializable
private Integer level;
/** 会员角色类型(0:会员,1:保洁人员,2:后台管理人员) */
@ApiModelProperty(value = "会员角色类型", example = "0=:会员,1:保洁人员,2:后台管理人员")
@ApiModelProperty(value = "会员角色类型", example = "0=:会员,1:员")
private Integer roleType;
/** 会员性别(0:未知,1:男,2:女) */
......
......@@ -80,6 +80,12 @@ public class SRoom extends BaseEntity
@Excel(name = "其他可能硬件接入参数(备用2)")
private String params2;
// /**
// * 是否脏房
// */
// @Excel(name = "是否脏房(0:否,1:是)")
// private Integer isDirtyRoom;
/**
* 套餐ID
*/
......
package share.system.domain;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -9,6 +10,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author: lwj
* @create: 2023-10-16 17:02
*/
@Data
public class SStoreConsumer {
/** 门店ID */
private Long storeId;
......@@ -16,27 +18,6 @@ public class SStoreConsumer {
/** 保洁员ID */
private Long consumerId;
public Long getStoreId() {
return storeId;
}
private Integer position;
public void setStoreId(Long storeId) {
this.storeId = storeId;
}
public Long getConsumerId() {
return consumerId;
}
public void setConsumerId(Long consumerId) {
this.consumerId = consumerId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("storeId", getStoreId())
.append("consumerId", getConsumerId())
.toString();
}
}
package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.util.List;
@Data
public class SCleanRecordsVo extends BaseEntity {
/**
* 门店ID
*/
private List<Long> storeIds;
/**
* 保洁人员ID
*/
private Long consumerId;
private Integer status;
/**
* 门店名称
*/
private String storeName;
Integer pageNum;
Integer pageSize;
}
......@@ -14,4 +14,10 @@ public class SConsumerVo extends SConsumer {
private Long storeId;
private Integer position;
private Boolean isCleaner;
private Boolean isAdmin;
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SStoreConsumer;
@Data
public class SStoreConsumerVo {
/**
* 门店ID
*/
private Long storeId;
/**
* 保洁员ID
*/
private Long consumerId;
private Integer position;
private Long[] consumerIds;
}
......@@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SCleanRecords;
import share.system.domain.SRoom;
import share.system.domain.vo.SCleanRecordsVo;
/**
* 保洁记录Mapper接口
......
package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import share.system.domain.SStore;
import share.system.domain.SStoreConsumer;
import share.system.domain.SysUserRole;
......@@ -12,7 +14,7 @@ import java.util.List;
* @author: lwj
* @create: 2023-10-16 17:07
*/
public interface SStoreConsumerMapper {
public interface SStoreConsumerMapper extends BaseMapper<SStoreConsumer> {
public int deleteByConsumerId(Long consumerId);
......@@ -29,8 +31,10 @@ public interface SStoreConsumerMapper {
public int deleteInfo(SStoreConsumer storeConsumer);
public int deleteInfos(@Param("storeId") Long storeId, @Param("consumerIds") Long[] consumerIds);
public int deleteInfos(@Param("storeId") Long storeId, @Param("consumerIds") Long[] consumerIds, @Param("position") Integer position);
List<Long> selectByConsumerId(Long id);
List<Long> selectByConsumerId(@Param("consumerId") Long consumerId, @Param("position") Integer position);
List<SStoreConsumer> queryByConsumerId(Long id);
}
......@@ -4,7 +4,9 @@ import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.SCleanRecords;
import share.system.domain.vo.SCleanRecordsVo;
/**
* 保洁记录Service接口
......@@ -72,7 +74,7 @@ public interface ISCleanRecordsService extends IService<SCleanRecords>
List<SCleanRecords> unCleanList(SCleanRecords sCleanRecords);
List<SCleanRecords> myCleanList(SCleanRecords sCleanRecords);
TableDataInfo myCleanList(SCleanRecordsVo sCleanRecords);
SCleanRecords getByRoomId(Long roomId);
......
......@@ -5,6 +5,7 @@ import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SStore;
import share.system.domain.vo.SStoreConsumerVo;
import share.system.domain.vo.SStoreVo;
import share.system.request.SStoreRequest;
import share.system.domain.SStoreConsumer;
......@@ -90,13 +91,14 @@ public interface ISStoreService extends IService<SStore>
int deleteStoreConsumer(SStoreConsumer storeConsumer);
int deleteStoreConsumers(Long storeId, Long[] consumerIds);
int deleteStoreConsumers(SStoreConsumerVo storeConsumer);
int insertStoreConsumers(Long storeId, Long[] consumerIds);
int insertStoreConsumers(SStoreConsumerVo storeConsumer);
List<SStore> listVoByCleaner();
int dataSync();
List<SStoreVo> storeList();
}
......@@ -91,7 +91,7 @@ public interface SConsumerService extends IService<SConsumer>
* 获取当前登陆用户个人信息(空则返回异常)
* @return
*/
SConsumer getSConsumer();
SConsumerVo getSConsumer();
/**
* 获取当前登陆用户个人信息
......
package share.system.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dianping.openapi.sdk.api.customerauth.session.CustomerKeyShopScopeQuery;
......@@ -90,35 +92,24 @@ public class QPServiceImpl implements QPService {
*/
@Override
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid, String status) {
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
sStoreLambdaQueryWrapper.eq(SStore::getOpenShopUuid, openShopUuid);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore) || StoreStatusEnum.STOP.getIndex().equals(sStore.getStatus())) {
throw new RuntimeException("门店状态异常,请联系管理员");
}
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code.trim(), openShopUuid, status);
//获取用户信息
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//查询领取记录表
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getDealId, prepare.getDeal_id());
queryWrapper.eq(SConsumerCoupon::getCouponCode, code);
queryWrapper.eq(SConsumerCoupon::getUseStatus, UserStatusEnum.UNUSED.getCode());
SConsumerCoupon couponTwo = isConsumerCouponService.getOne(queryWrapper);
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
sStoreLambdaQueryWrapper.eq(SStore::getOpenShopUuid, openShopUuid);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore)) {
throw new RuntimeException("门店不存在");
}
if (sStore.getStatus().equals(StoreStatusEnum.STOP.getIndex())) {
throw new RuntimeException("门店已停止");
}
if (ObjectUtils.isNotEmpty(couponTwo)) {
//判断是否本人领取过
if (couponTwo.getConsumerId().equals(user.getId())) {
//领取删除原来的
isConsumerCouponService.deleteSConsumerCouponById(couponTwo.getId());
//删除redis
redisUtil.delete(ReceiptRdeisEnum.PREPARE.getValue() + prepare.getReceipt_code());
} else {
return null;
}
SConsumerCoupon unUsedCoupon = isConsumerCouponService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(unUsedCoupon)) {
throw new RuntimeException("该券已被领取");
}
//根据优惠卷名称查询优惠劵配置 查询list,取第一个
TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo();
......@@ -134,20 +125,15 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date());
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(prepare.getDeal_marketprice()));
//根据门店id查询门店信息
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal = queryshopdeal(openShopUuid);
queryshopdeal.stream().forEach(o -> {
//查询美团团购信息
List<TuangouDealQueryShopDealResponseEntity> groupActivities = queryshopdeal(openShopUuid);
groupActivities.forEach(o -> {
//套餐名称相同并且在售卖中
if (prepare.getDeal_title().equals(o.getTitle()) && o.getSale_status().equals(saleStatusEnum.SELLING.getCode())) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date receiptEndDate = sdf.parse(o.getReceipt_end_date());
Date receiptBeginDate = sdf.parse(o.getReceipt_begin_date());
sConsumerCoupon.setStartDate(receiptBeginDate);
sConsumerCoupon.setEndDate(receiptEndDate);
} catch (Exception e) {
e.printStackTrace();
}
if (prepare.getDeal_title().equals(o.getTitle()) && saleStatusEnum.SELLING.getCode().equals(o.getSale_status())) {
Date receiptEndDate = DateUtil.parse(o.getReceipt_end_date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN);
Date receiptBeginDate = DateUtil.parse(o.getReceipt_begin_date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN);
sConsumerCoupon.setStartDate(receiptBeginDate);
sConsumerCoupon.setEndDate(receiptEndDate);
}
});
......@@ -187,19 +173,12 @@ public class QPServiceImpl implements QPService {
}
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
response.setConsumerCouponId(sConsumerCoupon.getId());
//设置过期时间30分钟
Map<String, String> map = new HashMap<>();
map.put("receipt_code", prepare.getReceipt_code());
map.put("consumerCouponId", String.valueOf(response.getConsumerCouponId()));
//设置30分钟后的时间
Date date = DateUtils.addMinutes(new Date(), 30);
map.put("expirationTime", String.valueOf(date));
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.PREPARE.getValue() + prepare.getReceipt_code(), jsonObject.toString());
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String output1 = format2.format(prepare.getReceiptEndDate());
String output1 = DateUtil.format(prepare.getReceiptEndDate(), DatePattern.NORM_DATETIME_PATTERN);
BeanUtils.copyProperties(prepare, response);
response.setExpirationTime(output1);
//核销美团券
consume(code.trim(), 1, openShopUuid, ConsumerCouponStatusEnum.ORDER.getCode());
return response;
}
......@@ -414,7 +393,18 @@ public class QPServiceImpl implements QPService {
logger.error("适用店铺查询接口:{}", response.getMsg());
throw new RuntimeException(response.getMsg());
}
return response.getData();
//查询所有门店
List<SStore> list = storeService.list();
//过滤以增加的门店 根据open_shop_uuid
List<CustomerKeyShopScopeResponseEntity> data = response.getData();
List<CustomerKeyShopScopeResponseEntity> collect = data.stream().filter(o1 -> {
Optional<SStore> first = list.stream().filter(o2 -> o2.getOpenShopUuid().equals(o1.getOpen_shop_uuid())).findFirst();
if (first.isPresent()) {
return false;
}
return true;
}).collect(java.util.stream.Collectors.toList());
return collect;
}
}
......@@ -12,21 +12,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import share.common.constant.Constants;
import share.common.constant.SmsConstants;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.PayStatusEnum;
import share.common.enums.PositionEnum;
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.SStoreConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper;
import share.system.domain.SConsumer;
import share.system.mapper.SStoreConsumerMapper;
import share.system.request.RegisterThirdSConsumerRequest;
import share.system.service.ISConsumerCouponService;
import share.system.service.SConsumerService;
......@@ -45,6 +51,8 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Autowired
private ISConsumerCouponService sConsumerCouponService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
* 查询会员用户
......@@ -168,7 +176,7 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
}
@Override
public SConsumer getSConsumer() {
public SConsumerVo getSConsumer() {
SConsumer currentUser = getInfo();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(currentUser.getId());
......@@ -177,10 +185,25 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
if(count>0){
currentUser.setNumber(count);
}
SConsumerVo vo = new SConsumerVo();
BeanUtils.copyProperties(currentUser, vo);
List<Long> longList = storeConsumerMapper.selectByConsumerId(currentUser.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(longList)) {
vo.setIsCleaner(false);
} else {
vo.setIsCleaner(true);
}
List<Long> adminList = storeConsumerMapper.selectByConsumerId(currentUser.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(adminList)) {
vo.setIsAdmin(false);
} else {
vo.setIsAdmin(true);
}
if (ObjectUtil.isNull(currentUser)) {
throw new BaseException("您的登录已过期,请先登录");
}
return currentUser;
return vo;
}
/**
......@@ -264,9 +287,10 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
if (ArrayUtil.isNotEmpty(ids)) {
List<Long> idList = ListUtil.toList(ids);
List<SConsumer> list = baseMapper.selectBatchIds(idList);
//解除所有门店关联
storeConsumerMapper.deleteBatchIds(idList);
list.stream().forEach(sConsumer -> {
sConsumer.setRoleType(RoleTypeEnum.MEMBRO.getCode());
});
updateBatchById(list);
return idList.size();
......
......@@ -14,6 +14,11 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptGetConsumed;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponse;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedRequest;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -323,7 +328,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (Objects.nonNull(byId)) {
if (byId.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
if (StringUtils.isNotEmpty(byId.getCouponCode())) {
qpService.prepare(byId.getCouponCode(), sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.ORDER.getCode());
TuangouReceiptGetConsumedReponseEntity getconsumed = qpService.getconsumed(byId.getCouponCode(), sStore.getOpenShopUuid());
if (getconsumed == null) {
throw new RuntimeException("优惠券异常,请稍后再试");
}
}
} else {
throw new BaseException("优惠券已使用!");
......@@ -349,10 +357,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
save(sOrder);
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
if (Objects.nonNull(byId)) {
if (StringUtils.isNotEmpty(byId.getCouponCode())) {
//验劵
qpService.consume(byId.getCouponCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.ORDER.getCode());
}
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(request.getCouponId());
consumerCoupon.setUseDate(new Date());
......@@ -795,10 +799,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId);
if (ObjectUtil.isNotEmpty(consumerCoupon)) {
if (consumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
if (StringUtils.isNotEmpty(consumerCoupon.getCouponCode())) {
//验劵
qpService.consume(consumerCoupon.getCouponCode(), 1, sStore.getOpenShopUuid(), ConsumerCouponStatusEnum.WECHAT.getCode());
}
consumerCoupon.setUseDate(new Date());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
......
......@@ -10,6 +10,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
import share.common.enums.DeviceType;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
......@@ -23,6 +24,7 @@ import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreConsumerMapper;
import share.system.service.*;
/**
......@@ -52,6 +54,8 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private DeviceOpService deviceOpService;
@Autowired
private RoomStatusService roomStatusService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
......@@ -281,6 +285,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
public String openDoor(Long id) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员");
}
List<Long> longs = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是保洁人员");
}
SRoom room = baseMapper.selectById(id);
......
......@@ -9,12 +9,8 @@ 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;
import lombok.var;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.record.DVALRecord;
import org.bouncycastle.util.Store;
import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.distance.DistanceUtils;
import org.locationtech.spatial4j.shape.Point;
......@@ -27,6 +23,7 @@ import org.springframework.stereotype.Service;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SRoomVo;
import share.system.domain.vo.SStoreConsumerVo;
import share.system.domain.vo.SStoreVo;
import share.system.mapper.*;
import share.system.request.SStoreRequest;
......@@ -350,18 +347,19 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
}
@Override
public int deleteStoreConsumers(Long storeId, Long[] consumerIds) {
return storeConsumerMapper.deleteInfos(storeId, consumerIds);
public int deleteStoreConsumers(SStoreConsumerVo storeConsumer) {
return storeConsumerMapper.deleteInfos(storeConsumer.getStoreId(), storeConsumer.getConsumerIds(), storeConsumer.getPosition());
}
@Override
public int insertStoreConsumers(Long storeId, Long[] consumerIds) {
public int insertStoreConsumers(SStoreConsumerVo storeConsumer) {
// 新增保洁与门店关系
List<SStoreConsumer> list = new ArrayList<SStoreConsumer>();
for (Long consumerId : consumerIds) {
for (Long consumerId : storeConsumer.getConsumerIds()) {
SStoreConsumer sc = new SStoreConsumer();
sc.setStoreId(storeId);
sc.setStoreId(storeConsumer.getStoreId());
sc.setConsumerId(consumerId);
sc.setPosition(storeConsumer.getPosition());
list.add(sc);
}
return storeConsumerMapper.batchSStoreConsumer(list);
......@@ -371,10 +369,12 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
public List<SStore> listVoByCleaner() {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new BaseException("当前用户不是保洁人员!");
throw new BaseException("当前用户不是店员!");
}
List<Long> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(storeIdList)) {
throw new RuntimeException("当前用户不是保洁人员");
}
//查询保洁人员所属门店
List<Long> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId());
List<SStore> storeList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeIdList)) {
// 查询门店信息
......@@ -444,13 +444,19 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
}
return 0;
}
@Override
public List<SStoreVo> storeList() {
SConsumer user = consumerService.getInfo();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new BaseException("当前用户不是店员!");
}
List<Long> storeIds = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(storeIds)) {
return new ArrayList<>();
}
//查询所有门店
List<SStore> sStores = baseMapper.selectSStoreList(new SStore());
//获取所有门店id
List<Long> storeIds = sStores.stream().map(SStore::getId).collect(Collectors.toList());
List<SStore> sStores = baseMapper.selectList(new LambdaQueryWrapper<SStore>().in(SStore::getId, storeIds));
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sStores)) {
voList = convertDosToVos(sStores);
......@@ -474,7 +480,11 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
}
List<Device> devices = new ArrayList<>();
deviceList.stream().forEach(device -> {
if (room.getId().compareTo(device.getRoomId()) == 0) {
Long roomId = device.getRoomId();
if (ObjectUtil.isEmpty(roomId)) {
return;
}
if (room.getId().compareTo(roomId) == 0) {
devices.add(device);
}
});
......
......@@ -54,7 +54,7 @@
t1.free_amount, t1.total_times, t1.duration, t1.status, t1.pwd, t1.create_time, t1.last_login_time
from s_consumer t1
left join s_store_consumer t2 on t2.consumer_id = t1.id
where t1.role_type = '1' and t2.store_id = #{storeId}
where t1.role_type = '1' and t2.position=#{position} and t2.store_id = #{storeId}
<if test="nickName != null and nickName != ''">
AND t1.nick_name like concat('%', #{nickName}, '%')
</if>
......@@ -67,7 +67,8 @@
t1.free_amount, t1.total_times, t1.duration, t1.status, t1.pwd, t1.create_time, t1.last_login_time
from s_consumer t1
where t1.role_type = '1'
and t1.id not in (select consumer_id from s_store_consumer where store_id = #{storeId})
and t1.id not in (select consumer_id from s_store_consumer where store_id = #{storeId} and position =
#{position})
<if test="nickName != null and nickName != ''">
AND t1.nick_name like concat('%', #{nickName}, '%')
</if>
......@@ -90,7 +91,8 @@
t1.free_amount, t1.total_times, t1.duration, t1.status, t1.pwd, t1.create_time, t1.last_login_time
from s_consumer t1
left join s_store_consumer t2 on t2.consumer_id = t1.id
where t1.role_type = '1' and t1.id in (select consumer_id from s_store_consumer where store_id = #{storeId})
where t1.role_type = '1'
and t1.id in (select consumer_id from s_store_consumer where store_id = #{storeId} and position = '1')
</select>
......
......@@ -14,6 +14,7 @@
<result property="info" column="info" />
<result property="status" column="status" />
<result property="price" column="price" />
<!-- <result property="isDirtyRoom" column="is_dirty_room"/>-->
<result property="doorLockCode" column="door_lock_code" />
<result property="electricControlCode" column="electric_control_code" />
<result property="password" column="password" />
......@@ -27,7 +28,27 @@
</resultMap>
<sql id="selectSRoomVo">
select id, store_id, name, room_type, images, facilities, info, status, price, door_lock_code, electric_control_code, password, params1, params2, create_by, create_time, update_by, update_time, remark from s_room
select id,
store_id,
name,
room_type,
images,
facilities,
info,
status,
price,
<!-- is_dirty_room,-->
door_lock_code,
electric_control_code,
password,
params1,
params2,
create_by,
create_time,
update_by,
update_time,
remark
from s_room
</sql>
<select id="selectSRoomList" parameterType="SRoom" resultMap="SRoomResult">
......@@ -41,6 +62,7 @@
<if test="info != null and info != ''"> and info = #{info}</if>
<if test="status != null and status != '' or status ==0">and status = #{status}</if>
<if test="price != null "> and price = #{price}</if>
<!-- <if test="isDirtyRoom != null ">and is_dirty_room = #{isDirtyRoom}</if>-->
<if test="doorLockCode != null and doorLockCode != ''"> and door_lock_code = #{doorLockCode}</if>
<if test="electricControlCode != null and electricControlCode != ''"> and electric_control_code = #{electricControlCode}</if>
<if test="password != null and password != ''"> and password = #{password}</if>
......@@ -65,6 +87,7 @@
<if test="info != null">info,</if>
<if test="status != null">status,</if>
<if test="price != null">price,</if>
<!-- <if test="isDirtyRoom != null">is_dirty_room,</if> -->
<if test="doorLockCode != null">door_lock_code,</if>
<if test="electricControlCode != null">electric_control_code,</if>
<if test="password != null">password,</if>
......@@ -85,6 +108,7 @@
<if test="info != null">#{info},</if>
<if test="status != null">#{status},</if>
<if test="price != null">#{price},</if>
<!-- <if test="isDirtyRoom != null">#{isDirtyRoom},</if> -->
<if test="doorLockCode != null">#{doorLockCode},</if>
<if test="electricControlCode != null">#{electricControlCode},</if>
<if test="password != null">#{password},</if>
......@@ -109,6 +133,7 @@
<if test="info != null">info = #{info},</if>
<if test="status != null">status = #{status},</if>
<if test="price != null">price = #{price},</if>
<!-- <if test="isDirtyRoom != null">is_dirty_room = #{isDirtyRoom},</if> -->
<if test="doorLockCode != null">door_lock_code = #{doorLockCode},</if>
<if test="electricControlCode != null">electric_control_code = #{electricControlCode},</if>
<if test="password != null">password = #{password},</if>
......
......@@ -7,6 +7,7 @@
<resultMap type="SStoreConsumer" id="SStoreConsumerResult">
<result property="storeId" column="store_id" />
<result property="consumerId" column="consumer_id" />
<result property="position" column="position"/>
</resultMap>
<delete id="deleteByConsumerId" parameterType="Long">
......@@ -17,7 +18,17 @@
select count(1) from s_store_consumer where store_id=#{storeId}
</select>
<select id="selectByConsumerId" resultType="Long">
select store_id from s_store_consumer where consumer_id=#{consumerId}
select store_id
from s_store_consumer
where consumer_id = #{consumerId}
<if test="position != null">
and position = #{position}
</if>
</select>
<select id="queryByConsumerId" resultMap="SStoreConsumerResult">
select store_id, store_id, position
from s_store_consumer
where consumer_id = #{consumerId}
</select>
<delete id="deleteSStoreConsumer" parameterType="Long">
......@@ -28,18 +39,22 @@
</delete>
<insert id="batchSStoreConsumer">
insert into s_store_consumer(consumer_id, store_id) values
insert into s_store_consumer(consumer_id, store_id,position) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.consumerId},#{item.storeId})
(#{item.consumerId},#{item.storeId},#{item.position})
</foreach>
</insert>
<delete id="deleteInfo" parameterType="SStoreConsumer">
delete from s_store_consumer where consumer_id=#{consumerId} and store_id=#{storeId}
delete
from s_store_consumer
where consumer_id = #{consumerId}
and store_id = #{storeId}
and position = #{position}
</delete>
<delete id="deleteInfos">
delete from s_store_consumer where store_id=#{storeId} and consumer_id in
delete from s_store_consumer where store_id=#{storeId} and position = #{position} and consumer_id in
<foreach collection="consumerIds" item="consumerId" open="(" separator="," close=")">
#{consumerId}
</foreach>
......
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