Commit a47d3b54 by YG8999

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

parents 40bf13f1 cace8ddc
...@@ -15,6 +15,15 @@ public enum CleaningStatusEnum { ...@@ -15,6 +15,15 @@ public enum CleaningStatusEnum {
CleaningStatusEnum() { CleaningStatusEnum() {
} }
public static CleaningStatusEnum getEnumByCode(Integer code) {
for (CleaningStatusEnum status : CleaningStatusEnum.values()) {
if (status.getCode().compareTo(code)==0) {
return status;
}
}
return null;
}
public Integer getCode() { public Integer getCode() {
return code; return code;
} }
......
...@@ -9,6 +9,10 @@ public enum ErrorCodeEnum { ...@@ -9,6 +9,10 @@ public enum ErrorCodeEnum {
PARAM_ERROR("2100005", "参数不合法"), PARAM_ERROR("2100005", "参数不合法"),
//2100007 无权限操作 //2100007 无权限操作
NO_PERMISSION("2100007", "无权限操作"), NO_PERMISSION("2100007", "无权限操作"),
//2190002 access_token无效
ACCESS_TOKEN_INVALID("2190002", "access_token无效"),
//2190008 access_token过期,请刷新或重新授权
ACCESS_TOKEN_EXPIRE("2190008", "access_token过期,请刷新或重新授权"),
; ;
private String code; private String code;
......
...@@ -24,10 +24,7 @@ import share.common.constant.MqttConstants; ...@@ -24,10 +24,7 @@ import share.common.constant.MqttConstants;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.*; import share.common.enums.*;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.system.domain.SConsumerCoupon; import share.system.domain.*;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.domain.vo.MqttxVo; import share.system.domain.vo.MqttxVo;
import share.system.service.*; import share.system.service.*;
...@@ -119,11 +116,14 @@ public class RedisTask { ...@@ -119,11 +116,14 @@ public class RedisTask {
expiredCoupons.add(coupon.getId()); expiredCoupons.add(coupon.getId());
} }
logger.info("券码:{}->查询结束:{}", coupon.getCouponCode(), getconsumed); logger.info("券码:{}->查询结束:{}", coupon.getCouponCode(), getconsumed);
} else if (StringUtils.isNoneEmpty(coupon.getTiktokSkuId()) && coupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) { } else if (StringUtils.isNoneEmpty(coupon.getTiktokSkuId()) && coupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
//抖音复验券 //抖音复验券
JSONObject object = tiktokService.certificateGet(coupon.getCouponCode()); JSONObject object = tiktokService.certificateGet(coupon.getCouponCode());
JSONObject certificate = object.getJSONObject("certificate"); JSONObject certificate = object.getJSONObject("certificate");
Integer status = certificate.getInt("status"); Integer status = certificate.getInt("status");
if (status.equals(TiktokCouponStatusEnum.AVAILABLE.getCode())) {
expiredCoupons.add(coupon.getId());
}
if (status.equals(TiktokCouponStatusEnum.REFUND_SUCCESS.getCode()) | status.equals(TiktokCouponStatusEnum.REFUNDING.getCode())) { if (status.equals(TiktokCouponStatusEnum.REFUND_SUCCESS.getCode()) | status.equals(TiktokCouponStatusEnum.REFUNDING.getCode())) {
expiredCoupons.add(coupon.getId()); expiredCoupons.add(coupon.getId());
} }
...@@ -271,11 +271,15 @@ public class RedisTask { ...@@ -271,11 +271,15 @@ public class RedisTask {
SRoom room = roomService.getById(sOrder.getRoomId()); SRoom room = roomService.getById(sOrder.getRoomId());
if (ObjectUtil.isNotEmpty(room)) { if (ObjectUtil.isNotEmpty(room)) {
room.setStatus(RoomStatusEnum.FREE.getValue()); room.setStatus(RoomStatusEnum.FREE.getValue());
room.setIsDirtyRoom(YesNoEnum.yes.getIndex());
room.setUpdateTime(new Date()); room.setUpdateTime(new Date());
roomService.updateById(room); roomService.updateById(room);
} }
//判断订单是否已经添加保洁记录 //判断订单是否已经添加保洁记录
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId()); SCleanRecords cleanRecords = isCleanRecordsService.lastCleanByRoomId(sOrder.getRoomId());
if(cleanRecords.getStatus().compareTo(CleaningStatusEnum.UNCLEAN.getCode())!=0) {
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
}
//删除redis中的值 //删除redis中的值
redisUtil.delete(o); redisUtil.delete(o);
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(), deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(),
......
...@@ -120,12 +120,44 @@ public class RoomStatusServiceImpl implements RoomStatusService { ...@@ -120,12 +120,44 @@ public class RoomStatusServiceImpl implements RoomStatusService {
//设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单) //设置时间段房间可预约状态(可预约:大于营业开始时间,小于营业结束时间,大于当前时间,当前时间没有订单)
private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user){ private void setTimeHourStatus(RoomStatusVo vo,Date timeHourDate, SStore store, List<SOrder> orderList, SCleanRecords cleanRecords, String day, String finalNowTime, Boolean isToday, Integer orderType, SConsumer user){
vo.setStatus(RoomStatusEnum.FREE.getValue()); vo.setStatus(RoomStatusEnum.FREE.getValue());
checkIsDirtyRoom(vo,timeHourDate,store,cleanRecords,day);
checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday); checkTimeHourToSysDate(vo,timeHourDate,day,finalNowTime,isToday);
checkTimeHourToBusiness(vo,timeHourDate,store,day); checkTimeHourToBusiness(vo,timeHourDate,store,day);
checkTimeHourToOrder(vo,timeHourDate,orderList,cleanRecords,orderType, user); checkTimeHourToOrder(vo,timeHourDate,orderList,cleanRecords,orderType, user);
} }
private void checkIsDirtyRoom(RoomStatusVo vo,Date timeHourDate, SStore store, SCleanRecords cleanRecords, String day){
CleaningStatusEnum cleaningStatusEnum = null;
if (Objects.isNull(cleanRecords)) {
return;
}
cleaningStatusEnum = CleaningStatusEnum.getEnumByCode(cleanRecords.getStatus());
switch (cleaningStatusEnum){
case UNCLEAN:
case CLEANING:
//当天
if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate()))){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
changeStartHoldTime(vo,timeHourDate);
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
//次日
if(StringUtils.equals(day,DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.addDays(DateUtils.getNowDate(),1)))){
if(StringUtils.isNotBlank(store.getCleaningPeriod())
&&timeHourDate.getTime()<DateUtils.parseDate(day+" "+store.getCleaningPeriod()).getTime()){
vo.setStatus(RoomStatusEnum.HOLD.getValue());
changeStartHoldTime(vo,timeHourDate);
changeEndHoldTime(vo,DateUtils.addSeconds(timeHourDate, 59 * 60 + 59));
}
}
break;
case CLEANED:
break;
default:
break;
}
}
private void changeEndHoldTime(RoomStatusVo vo, Date date){ private void changeEndHoldTime(RoomStatusVo vo, Date date){
if(Objects.isNull(vo.getEndHoldTime())||vo.getEndHoldTime().compareTo(date)<0){ if(Objects.isNull(vo.getEndHoldTime())||vo.getEndHoldTime().compareTo(date)<0){
vo.setEndHoldTime(date); vo.setEndHoldTime(date);
......
...@@ -428,7 +428,7 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -428,7 +428,7 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
public SCleanRecords lastCleanByRoomId(Long roomId) { public SCleanRecords lastCleanByRoomId(Long roomId) {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SCleanRecords::getRoomId, roomId); queryWrapper.eq(SCleanRecords::getRoomId, roomId);
queryWrapper.gt(SCleanRecords::getCreateTime,DateUtils.addDays(new Date(),-1)); queryWrapper.gt(SCleanRecords::getCreateTime,DateUtils.addDays(new Date(),-7));
List<SCleanRecords> records = list(queryWrapper); List<SCleanRecords> records = list(queryWrapper);
if(CollectionUtils.isNotEmpty(records)){ if(CollectionUtils.isNotEmpty(records)){
Optional<SCleanRecords> cleanRecords = records.stream().max(Comparator.comparing(SCleanRecords::getCreateTime)); Optional<SCleanRecords> cleanRecords = records.stream().max(Comparator.comparing(SCleanRecords::getCreateTime));
......
...@@ -536,6 +536,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -536,6 +536,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
JSONObject object = tiktokService.certificateGet(byId.getCouponCode()); JSONObject object = tiktokService.certificateGet(byId.getCouponCode());
JSONObject certificate = object.getJSONObject("certificate"); JSONObject certificate = object.getJSONObject("certificate");
Integer status = certificate.getInt("status"); Integer status = certificate.getInt("status");
Boolean isDelete = false;
if (status.equals(TiktokCouponStatusEnum.AVAILABLE.getCode())) {
consumerCouponService.deleteSConsumerCouponById(byId.getId());
isDelete = true;
}
if (isDelete) {
throw new RuntimeException("优惠券异常,请稍后再试");
}
if (status.equals(TiktokCouponStatusEnum.REFUND_SUCCESS.getCode()) | status.equals(TiktokCouponStatusEnum.REFUNDING.getCode())) { if (status.equals(TiktokCouponStatusEnum.REFUND_SUCCESS.getCode()) | status.equals(TiktokCouponStatusEnum.REFUNDING.getCode())) {
throw new RuntimeException("优惠券异常,请稍后再试"); throw new RuntimeException("优惠券异常,请稍后再试");
} }
......
...@@ -155,6 +155,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -155,6 +155,10 @@ public class TiktokServiceImpl implements TiktokService {
} }
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// prepare(tiktokCouponDto);
// }
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
logger.error("抖音验券准备失败:{}", data.getStr("description")); logger.error("抖音验券准备失败:{}", data.getStr("description"));
throw new RuntimeException(data.getStr("description")); throw new RuntimeException(data.getStr("description"));
...@@ -177,6 +181,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -177,6 +181,10 @@ public class TiktokServiceImpl implements TiktokService {
.body(jsonObject.toString()).execute().body(); .body(jsonObject.toString()).execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// verify(tiktokCouponDto);
// }
JSONObject extra = entries.getJSONObject("extra"); JSONObject extra = entries.getJSONObject("extra");
if (data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode()) && ((JSONObject) data.getJSONArray("verify_results").get(0)).getStr("result").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode()) && ((JSONObject) data.getJSONArray("verify_results").get(0)).getStr("result").equals(ErrorCodeEnum.SUCCESS.getCode())) {
return data; return data;
...@@ -202,6 +210,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -202,6 +210,10 @@ public class TiktokServiceImpl implements TiktokService {
.body(jsonObject.toString()).execute().body(); .body(jsonObject.toString()).execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// cancel(tiktokCouponDto);
// }
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
logger.error("抖音撤销核销失败:{}", data.getStr("description")); logger.error("抖音撤销核销失败:{}", data.getStr("description"));
throw new RuntimeException(data.getStr("description")); throw new RuntimeException(data.getStr("description"));
...@@ -225,6 +237,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -225,6 +237,10 @@ public class TiktokServiceImpl implements TiktokService {
.form("encrypted_code", encode).execute().body(); .form("encrypted_code", encode).execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// certificateGet(encryptedCode);
// }
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
logger.error("抖音获取核销信息失败:{}", data.getStr("description")); logger.error("抖音获取核销信息失败:{}", data.getStr("description"));
throw new BaseException(data.getStr("description")); throw new BaseException(data.getStr("description"));
...@@ -245,6 +261,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -245,6 +261,10 @@ public class TiktokServiceImpl implements TiktokService {
.execute().body(); .execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// poiQuery(tiktokCouponDto);
// }
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
throw new RuntimeException(data.getStr("description")); throw new RuntimeException(data.getStr("description"));
} }
...@@ -278,6 +298,10 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -278,6 +298,10 @@ public class TiktokServiceImpl implements TiktokService {
.execute().body(); .execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// onlineQuery(onlineQueryDto);
// }
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) { if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
throw new RuntimeException(data.getStr("description")); throw new RuntimeException(data.getStr("description"));
} }
...@@ -294,7 +318,12 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -294,7 +318,12 @@ public class TiktokServiceImpl implements TiktokService {
.form("account_id", accountId) .form("account_id", accountId)
.execute().body(); .execute().body();
JSONObject entries = new JSONObject(result); JSONObject entries = new JSONObject(result);
return entries.getJSONObject("data"); JSONObject data = entries.getJSONObject("data");
// if (data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_INVALID.getCode()) | data.getStr("error_code").equals(ErrorCodeEnum.ACCESS_TOKEN_EXPIRE.getCode())) {
// clientToken();
// onlineGet(productIds, accountId);
// }
return data;
} }
@Override @Override
...@@ -354,7 +383,7 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -354,7 +383,7 @@ public class TiktokServiceImpl implements TiktokService {
sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode()); sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId())); sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date()); sConsumerCoupon.setCreateTime(new Date());
Integer originalAmount = amount.getInt("original_amount"); Integer originalAmount = amount.getInt("list_market_amount");
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(originalAmount / 100)); sConsumerCoupon.setSubPrice(BigDecimal.valueOf(originalAmount / 100));
//时间戳转年月日时分秒 //时间戳转年月日时分秒
sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L)); sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L));
......
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