package com.matrix.system.shopXcx.api.service.impl;
|
|
import com.matrix.system.common.bean.CustomerDataDictionary;
|
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
|
import com.matrix.system.shopXcx.api.service.WxShopMemberDayService;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import java.util.*;
|
|
/**
|
* @description 会员日服务层
|
* @author wlz
|
* @date 2019-07-04 10:58
|
*/
|
@Service
|
public class WxShopMemberDayServiceImpl implements WxShopMemberDayService {
|
@Autowired
|
private CustomerDataDictionaryDao dictionaryDao;
|
|
|
@Override
|
public Double getMemberDay() {
|
String weekOfDate = getWeekOfDate(new Date());
|
CustomerDataDictionary memberDay = dictionaryDao.selectByTypeCode("member_day");
|
List<String> result = new ArrayList<>();
|
String extValue = memberDay.getExtValue();
|
String discount = memberDay.getValue();
|
if(null != extValue && !"".equals(extValue)){
|
result = Arrays.asList(extValue.split(",|,"));
|
}
|
if(CollectionUtils.isNotEmpty(result) && result.size() >0){
|
for(String memberDaySelect : result){
|
if(weekOfDate.equals(memberDaySelect)){
|
return Double.valueOf(discount);
|
}
|
|
}
|
}
|
return 1.0;
|
}
|
|
/**
|
* 获取当前日期是星期几
|
*
|
* @param dt
|
* @return 当前日期是星期几
|
*/
|
public static String getWeekOfDate(Date dt) {
|
String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
|
Calendar cal = Calendar.getInstance();
|
cal.setTime(dt);
|
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
if (w < 0) {
|
w = 0;
|
}
|
return weekDays[w];
|
}
|
}
|