|
|
@ -1,26 +1,57 @@ |
|
|
|
package com.yxt.yythmall.biz.customerstore; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.yythmall.api.customerstore.CustomerStore; |
|
|
|
import com.yxt.yythmall.api.customerstore.CustomerStoreDto; |
|
|
|
import com.yxt.yythmall.api.customerstore.CustomerStoreVo; |
|
|
|
import com.yxt.yythmall.api.lpkgiftcard.AppletVo; |
|
|
|
import com.yxt.yythmall.api.lpkstore.LpkStore; |
|
|
|
import com.yxt.yythmall.api.lpkstore.LpkStoreQuery; |
|
|
|
import com.yxt.yythmall.api.lpkstore.LpkStoreVo; |
|
|
|
import com.yxt.yythmall.api.lpkstore.StoreSelect; |
|
|
|
import com.yxt.yythmall.biz.lpkstore.LpkStoreService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.time.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author wangpengfei |
|
|
|
* @date 2023/11/21 15:03 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class CustomerStoreService extends MybatisBaseService<CustomerStoreMapper, CustomerStore> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
LpkStoreService lpkStoreService; |
|
|
|
public ResultBean<CustomerStoreVo> getStoreBySid(String customerSid) { |
|
|
|
ResultBean rb=new ResultBean().fail(); |
|
|
|
CustomerStoreVo vo=baseMapper.getStoreBySid(customerSid); |
|
|
|
|
|
|
|
if(null==vo){ |
|
|
|
LpkStoreVo list= lpkStoreService.getAllStoreByQuery(new LpkStoreQuery()).getData().get(0); |
|
|
|
CustomerStoreVo vo1=new CustomerStoreVo(); |
|
|
|
vo1.setAddress(list.getAddress()); |
|
|
|
vo1.setStoreSid(list.getSid()); |
|
|
|
vo1.setBusinessHours(list.getBusinessHours()); |
|
|
|
vo1.setStoreName(list.getName()); |
|
|
|
vo1.setName("张三"); |
|
|
|
vo1.setPhone("11111111111"); |
|
|
|
vo1=getStart(vo1); |
|
|
|
return rb.success().setData(vo1); |
|
|
|
} |
|
|
|
vo=getStart(vo); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean saveStore(CustomerStoreDto dto){ |
|
|
|
ResultBean rb=new ResultBean(); |
|
|
|
baseMapper.delete(new QueryWrapper<CustomerStore>().eq("customerSid",dto.getCustomerSid())); |
|
|
@ -29,4 +60,69 @@ public class CustomerStoreService extends MybatisBaseService<CustomerStoreMapper |
|
|
|
baseMapper.insert(customerStore); |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<Object> isSaturAndSun() { |
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
|
|
|
|
Date date =new Date(); |
|
|
|
SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
String nowDate =sdf1.format(date); |
|
|
|
String endDate= sdf1.format(DateUtil.offsetMonth(date,12)); |
|
|
|
LocalDate now = DateUtil.parse(nowDate).toSqlDate().toLocalDate(); |
|
|
|
LocalDate endD = DateUtil.parse(endDate).toSqlDate().toLocalDate(); |
|
|
|
List<String> weekMap = new ArrayList<>(); |
|
|
|
// 第一个星期六
|
|
|
|
LocalDate saturday = now.with(DayOfWeek.SATURDAY); |
|
|
|
do { |
|
|
|
if (CollectionUtils.isEmpty(weekMap)) { |
|
|
|
weekMap.add(saturday.toString()); |
|
|
|
} else { |
|
|
|
weekMap.add(saturday.toString()); |
|
|
|
} |
|
|
|
// 迭代一个星期
|
|
|
|
saturday = saturday.plus(Period.ofDays(7)); |
|
|
|
} while (saturday.compareTo(endD) < 1); |
|
|
|
// 第一个星期天
|
|
|
|
LocalDate sunday = now.with(DayOfWeek.SUNDAY); |
|
|
|
do { |
|
|
|
if (CollectionUtils.isEmpty(weekMap)) { |
|
|
|
weekMap.add(saturday.toString()); |
|
|
|
} else { |
|
|
|
weekMap.add(sunday.toString()); |
|
|
|
} |
|
|
|
// 迭代一个星期
|
|
|
|
sunday = sunday.plus(Period.ofDays(7)); |
|
|
|
} while (sunday.compareTo(endD) < 1); |
|
|
|
String nextYear = DateUtil.offsetMonth(new Date(), 12).toString(); |
|
|
|
int y = DateUtil.year(DateUtil.parse(nextYear)); |
|
|
|
weekMap.add(String.valueOf(y) + "-01-01"); |
|
|
|
Object[] array = weekMap.stream().sorted().toArray(); |
|
|
|
return rb.success().setData(array); |
|
|
|
} |
|
|
|
public CustomerStoreVo getStart(CustomerStoreVo vo) { |
|
|
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
LocalDate today = LocalDate.now(); // 获取今天的日期
|
|
|
|
LocalTime timeOfDay = LocalTime.of(15, 0); // 设置下午3点的小时数为15,分钟数为0
|
|
|
|
LocalDateTime dateAndTime = LocalDateTime.of(today, timeOfDay); // 将日期和时间合并成完整的日期时间对象
|
|
|
|
|
|
|
|
ZoneId zoneId = ZoneId.systemDefault(); |
|
|
|
Date date = Date.from(dateAndTime.atZone(zoneId).toInstant()); |
|
|
|
Date nowDate=new Date(); |
|
|
|
String start =""; |
|
|
|
|
|
|
|
//1>2 1 、1<2 -1 、1=2 0
|
|
|
|
int k= DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(nowDate)))).compareTo(DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(date))))); |
|
|
|
if(String.valueOf(k).equals("1")){ |
|
|
|
start=sdf.format(DateUtil.offsetDay(nowDate,+2)); |
|
|
|
}else{ |
|
|
|
start=sdf.format(DateUtil.offsetDay(nowDate,+1)); |
|
|
|
} |
|
|
|
String end=sdf.format(DateUtil.offsetDay(DateUtil.parse(start),4)); |
|
|
|
|
|
|
|
vo.setStart(start); |
|
|
|
vo.setEnd(end); |
|
|
|
vo.setReserveDate(start); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|