Commit ce4c4e40 by YG8999

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

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