Commit f35e3c30 authored by shiyu's avatar shiyu

1

parent fca9bf73
......@@ -99,7 +99,6 @@ public class SysExchangeApplyOrderServiceImpl implements SysExchangeApplyOrderSe
//订单更新为待发货
distributionOrderDao.updateState(targetUserOrderId, DistributionEnum.DistributionOrderStateEnum.PRE_SEND.getCode());
distributionOrderDao.updateState(userOrderId, DistributionEnum.DistributionOrderStateEnum.PRE_SEND.getCode());
//发短信通知申请单双方,平台的鉴定结果
try {
//通知提交方
......@@ -114,7 +113,6 @@ public class SysExchangeApplyOrderServiceImpl implements SysExchangeApplyOrderSe
} catch (Exception e) {
logger.info(">>>>>>>>> 交换申请单号:{}, 通过, 发送平台检查结果通知短信失败 <<<<<<<<<", exchangeApplyOrder.getExchangeApplyOrderId());
}
} else {
//平台审核不通过
exchangeApplyOrderDao.updateState(orderId, dto.getState());
......
......@@ -38,4 +38,38 @@ public class SigninEnum {
return name;
}
}
public enum DateStateEnum {
PASS(0, "过去"),
CURRENT(1, "当前"),
FUTURE(2, "将来"),
;
private Integer code;
private String name;
DateStateEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static String getNameByCode(int code) {
for (SigninEnum.DateStateEnum dateStateEnum : SigninEnum.DateStateEnum.values()) {
if (code == dateStateEnum.getCode()) {
return dateStateEnum.getName();
}
}
return null;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
}
......@@ -73,6 +73,9 @@ public class DateTimeUtil {
return null;
}
/**
* 获取yyyy-MM格式月份的首末时间
* @param yearMonth
......@@ -92,6 +95,19 @@ public class DateTimeUtil {
}
/**
* 获取时间中的日期为几号
* @param dateString
* @return
*/
public static int getDayFromDateString(String dateString) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(dateString, formatter);
return date.getDayOfMonth();
}
/**
......@@ -123,11 +139,6 @@ public class DateTimeUtil {
public static void main(String[] args) {
List<String> datesList = getMonthDates("2024-08");
System.out.println(datesList);
}
public static List<String> getMonthDates(String yearMonth) {
List<String> dates = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
......@@ -142,4 +153,29 @@ public class DateTimeUtil {
}
return dates;
}
public static int getFirstDayOfMonth(int year, int month) {
if (month < 1 || month > 12) {
throw new IllegalArgumentException("月份无效,请输入1到12之间的数字。");
}
LocalDate firstDayOfMonth = LocalDate.of(year, month, 1);
return firstDayOfMonth.getDayOfWeek().getValue();
}
public static void main(String[] args) {
List<String> datesList = getMonthDates("2024-08");
System.out.println(datesList);
int year = 2024; // 示例年份
int month = 10; // 示例月份
// 调用方法并输出结果
int dayOfWeekInt = getFirstDayOfMonth(year, month);
System.out.println(year + "年 " + month + "月的一号是: " + dayOfWeekInt);
System.out.println("号" + getDayFromDateString("2024-08-09"));
LocalDate today = LocalDate.now();
System.out.println(today.getYear()+ "-" + today.getMonthValue());
}
}
package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.UserSignin;
import com.wwdz.ch.db.dto.request.UserSigninRequestDto;
import com.wwdz.ch.db.domain.UserSignIn;
import com.wwdz.ch.db.dto.request.UserSignInRequestDto;
import java.util.List;
public interface UserSigninDao {
boolean insert(UserSignin userSignin);
boolean insert(UserSignIn userSignin);
UserSignin findLastedRecord(long userId);
UserSignIn findLastedRecord(long userId);
List<UserSignin> findList(UserSigninRequestDto dto);
List<UserSignIn> findList(UserSignInRequestDto dto);
/**
* 查询昨天的签到记录
* @param userId
* @return
*/
UserSignin findYesterdayRecord(long userId);
UserSignIn findYesterdayRecord(long userId);
/**
* 判断某一日期是否签到过
......@@ -29,9 +29,9 @@ public interface UserSigninDao {
boolean isExisted(long userId, String date);
UserSignin findRecord(long userId, String date);
UserSignIn findRecord(long userId, String date);
boolean update(UserSignin userSignin);
boolean update(UserSignIn userSignin);
boolean updateByPrimaryKey(UserSignin userSignin);
boolean updateByPrimaryKey(UserSignIn userSignin);
}
......@@ -10,10 +10,10 @@ import lombok.Data;
/**
* @author shiyu
* @date 2024/11/15
* @date 2024/11/21
*/
@Data
public class UserSignin implements Entity {
public class UserSignIn implements Entity {
/**
* id
*/
......@@ -37,7 +37,7 @@ public class UserSignin implements Entity {
/**
* 签到日期
*/
private String signinDate;
private String signInDate;
/**
* 连续天数
......@@ -71,7 +71,7 @@ public class UserSignin implements Entity {
sb.append(", userId=").append(userId);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", signinDate=").append(signinDate);
sb.append(", signInDate=").append(signInDate);
sb.append(", consecutiveDays=").append(consecutiveDays);
sb.append(", isReward=").append(isReward);
sb.append(", rewardLevel=").append(rewardLevel);
......@@ -92,12 +92,12 @@ public class UserSignin implements Entity {
if (getClass() != that.getClass()) {
return false;
}
UserSignin other = (UserSignin) that;
UserSignIn other = (UserSignIn) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getSigninDate() == null ? other.getSigninDate() == null : this.getSigninDate().equals(other.getSigninDate()))
&& (this.getSignInDate() == null ? other.getSignInDate() == null : this.getSignInDate().equals(other.getSignInDate()))
&& (this.getConsecutiveDays() == null ? other.getConsecutiveDays() == null : this.getConsecutiveDays().equals(other.getConsecutiveDays()))
&& (this.getIsReward() == null ? other.getIsReward() == null : this.getIsReward().equals(other.getIsReward()))
&& (this.getRewardLevel() == null ? other.getRewardLevel() == null : this.getRewardLevel().equals(other.getRewardLevel()))
......@@ -112,7 +112,7 @@ public class UserSignin implements Entity {
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getSigninDate() == null) ? 0 : getSigninDate().hashCode());
result = prime * result + ((getSignInDate() == null) ? 0 : getSignInDate().hashCode());
result = prime * result + ((getConsecutiveDays() == null) ? 0 : getConsecutiveDays().hashCode());
result = prime * result + ((getIsReward() == null) ? 0 : getIsReward().hashCode());
result = prime * result + ((getRewardLevel() == null) ? 0 : getRewardLevel().hashCode());
......@@ -122,7 +122,7 @@ public class UserSignin implements Entity {
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table user_signin
* This enum corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -132,7 +132,7 @@ public class UserSignin implements Entity {
userId("user_id", "userId", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
signinDate("signin_date", "signinDate", "VARCHAR", false),
signInDate("sign_in_date", "signInDate", "VARCHAR", false),
consecutiveDays("consecutive_days", "consecutiveDays", "INTEGER", false),
isReward("is_reward", "isReward", "BIT", false),
rewardLevel("reward_level", "rewardLevel", "INTEGER", false),
......@@ -140,7 +140,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -149,7 +149,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -158,7 +158,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -167,7 +167,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -176,7 +176,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -185,7 +185,7 @@ public class UserSignin implements Entity {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
* This field corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -194,7 +194,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -205,7 +205,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -216,7 +216,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -227,7 +227,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -238,7 +238,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -252,7 +252,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -263,7 +263,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -274,7 +274,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......@@ -289,7 +289,7 @@ public class UserSignin implements Entity {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
......
......@@ -5,7 +5,11 @@ import lombok.Data;
import java.util.Date;
@Data
public class UserSigninRequestDto extends BaseRequestDto implements Entity {
public class UserSignInRequestDto extends BaseRequestDto implements Entity {
private String year;
private String month;
/**
* id
......@@ -41,7 +45,7 @@ public class UserSigninRequestDto extends BaseRequestDto implements Entity {
/**
* 签到日期
*/
private String signinDate;
private String signInDate;
/**
* 连续天数
......
package com.wwdz.ch.db.impl;
import com.wwdz.ch.db.dao.UserSigninDao;
import com.wwdz.ch.db.domain.UserSignin;
import com.wwdz.ch.db.domain.UserSigninExample;
import com.wwdz.ch.db.dto.request.UserSigninRequestDto;
import com.wwdz.ch.db.mapper.UserSigninMapper;
import com.wwdz.ch.db.domain.UserSignIn;
import com.wwdz.ch.db.domain.UserSignInExample;
import com.wwdz.ch.db.dto.request.UserSignInRequestDto;
import com.wwdz.ch.db.mapper.UserSignInMapper;
import com.xxdxxs.db.component.JdbcHelper;
import com.xxdxxs.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@Repository
public class UserSigninDaoImpl implements UserSigninDao {
@Autowired
UserSigninMapper userSigninMapper;
UserSignInMapper userSignInMapper;
@Override
public boolean insert(UserSignin userSignin) {
return userSigninMapper.insert(userSignin) > 0;
public boolean insert(UserSignIn userSignin) {
return userSignInMapper.insert(userSignin) > 0;
}
@Override
public UserSignin findLastedRecord(long userId) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
public UserSignIn findLastedRecord(long userId) {
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
example.setOrderByClause("create_time desc");
return userSigninMapper.selectOneByExample(example);
return userSignInMapper.selectOneByExample(example);
}
@Override
public List<UserSignin> findList(UserSigninRequestDto dto) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
public List<UserSignIn> findList(UserSignInRequestDto dto) {
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(dto.getUserId());
JdbcHelper.ifPresent(dto.getStartQueryTime(), criteria :: andCreateTimeGreaterThanOrEqualTo);
JdbcHelper.ifPresent(dto.getEndQueryTime(), criteria :: andCreateTimeLessThanOrEqualTo);
example.setOrderByClause("create_time desc");
return userSigninMapper.selectByExample(example);
return userSignInMapper.selectByExample(example);
}
@Override
public UserSignin findYesterdayRecord(long userId) {
public UserSignIn findYesterdayRecord(long userId) {
LocalDate yesterday = LocalDate.now().minusDays(1);
String yesterdayString = DateUtils.DATE.format(yesterday);
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSigninDateEqualTo(yesterdayString);
return userSigninMapper.selectOneByExample(example);
criteria.andSignInDateEqualTo(yesterdayString);
return userSignInMapper.selectOneByExample(example);
}
@Override
public boolean isExisted(long userId, String date) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSigninDateEqualTo(date);
return userSigninMapper.countByExample(example) > 0;
criteria.andSignInDateEqualTo(date);
return userSignInMapper.countByExample(example) > 0;
}
@Override
public UserSignin findRecord(long userId, String date) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
public UserSignIn findRecord(long userId, String date) {
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSigninDateEqualTo(date);
return userSigninMapper.selectOneByExample(example);
criteria.andSignInDateEqualTo(date);
return userSignInMapper.selectOneByExample(example);
}
@Override
public boolean update(UserSignin userSignin) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
public boolean update(UserSignIn userSignin) {
UserSignInExample example = new UserSignInExample();
UserSignInExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userSignin.getUserId());
criteria.andSigninDateEqualTo(userSignin.getSigninDate());
return userSigninMapper.updateByExampleSelective(userSignin, example) > 0;
criteria.andSignInDateEqualTo(userSignin.getSignInDate());
return userSignInMapper.updateByExampleSelective(userSignin, example) > 0;
}
@Override
public boolean updateByPrimaryKey(UserSignin userSignin) {
return userSigninMapper.updateByPrimaryKeySelective(userSignin) > 0;
public boolean updateByPrimaryKey(UserSignIn userSignin) {
return userSignInMapper.updateByPrimaryKeySelective(userSignin) > 0;
}
}
package com.wwdz.ch.db.mapper;
import com.wwdz.ch.db.domain.UserSignin;
import com.wwdz.ch.db.domain.UserSigninExample;
import com.wwdz.ch.db.domain.UserSignIn;
import com.wwdz.ch.db.domain.UserSignInExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserSigninMapper {
long countByExample(UserSigninExample example);
public interface UserSignInMapper {
long countByExample(UserSignInExample example);
int deleteByExample(UserSigninExample example);
int deleteByExample(UserSignInExample example);
int deleteByPrimaryKey(Long id);
int insert(UserSignin record);
int insert(UserSignIn record);
int insertSelective(UserSignin record);
int insertSelective(UserSignIn record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserSignin selectOneByExample(UserSigninExample example);
UserSignIn selectOneByExample(UserSignInExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserSignin selectOneByExampleSelective(@Param("example") UserSigninExample example, @Param("selective") UserSignin.Column ... selective);
UserSignIn selectOneByExampleSelective(@Param("example") UserSignInExample example, @Param("selective") UserSignIn.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<UserSignin> selectByExampleSelective(@Param("example") UserSigninExample example, @Param("selective") UserSignin.Column ... selective);
List<UserSignIn> selectByExampleSelective(@Param("example") UserSignInExample example, @Param("selective") UserSignIn.Column ... selective);
List<UserSignin> selectByExample(UserSigninExample example);
List<UserSignIn> selectByExample(UserSignInExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
* This method corresponds to the database table user_sign_in
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserSignin selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") UserSignin.Column ... selective);
UserSignIn selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") UserSignIn.Column ... selective);
UserSignin selectByPrimaryKey(Long id);
UserSignIn selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UserSignin record, @Param("example") UserSigninExample example);
int updateByExampleSelective(@Param("record") UserSignIn record, @Param("example") UserSignInExample example);
int updateByExample(@Param("record") UserSignin record, @Param("example") UserSigninExample example);
int updateByExample(@Param("record") UserSignIn record, @Param("example") UserSignInExample example);
int updateByPrimaryKeySelective(UserSignin record);
int updateByPrimaryKeySelective(UserSignIn record);
int updateByPrimaryKey(UserSignin record);
int updateByPrimaryKey(UserSignIn record);
}
\ No newline at end of file
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
targetProject="ch-dao/src/main/java"/>
<table tableName="user_signin" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="user_sign_in" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -3,16 +3,18 @@ package com.wwdz.ch.wx.impl;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.SigninEnum;
import com.wwdz.ch.core.entity.SignDateRecord;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.DateTimeUtil;
import com.wwdz.ch.core.util.IdUtils;
import com.wwdz.ch.db.dao.UserSigninDao;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.domain.UserSignin;
import com.wwdz.ch.db.domain.UserSignIn;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.dto.request.UserSigninRequestDto;
import com.wwdz.ch.db.dto.request.UserSignInRequestDto;
import com.wwdz.ch.wx.service.UserSigninService;
import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,8 +22,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class UserSigninServiceImpl implements UserSigninService {
......@@ -35,7 +39,7 @@ public class UserSigninServiceImpl implements UserSigninService {
DistributionOrderDao distributionOrderDao;
@Override
public Result signin(UserSigninRequestDto dto) {
public Result signin(UserSignInRequestDto dto) {
try {
long userId = dto.getUserId();
//检查是否已签到过
......@@ -44,11 +48,11 @@ public class UserSigninServiceImpl implements UserSigninService {
return Result.failed("您今天已签到过");
}
//今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天
UserSignin yesterdaySignin = userSigninDao.findYesterdayRecord(userId);
UserSignIn yesterdaySignin = userSigninDao.findYesterdayRecord(userId);
if (yesterdaySignin == null) {
UserSignin userSignin = new UserSignin();
UserSignIn userSignin = new UserSignIn();
userSignin.setUserId(userId);
userSignin.setSigninDate(todayStr);
userSignin.setSignInDate(todayStr);
userSignin.setCreateTime(new Date());
userSignin.setUpdateTime(new Date());
userSignin.setConsecutiveDays(1);
......@@ -57,9 +61,9 @@ public class UserSigninServiceImpl implements UserSigninService {
userSignin.setRewardLevel(SigninEnum.LevelEnum.ZERO.getCode());
userSigninDao.insert(userSignin);
} else {
UserSignin userSignin = new UserSignin();
UserSignIn userSignin = new UserSignIn();
userSignin.setUserId(userId);
userSignin.setSigninDate(todayStr);
userSignin.setSignInDate(todayStr);
userSignin.setCreateTime(new Date());
userSignin.setUpdateTime(new Date());
//连续签到天数
......@@ -92,17 +96,17 @@ public class UserSigninServiceImpl implements UserSigninService {
@Transactional
@Override
public Result getReward(UserSigninRequestDto dto) {
public Result getReward(UserSignInRequestDto dto) {
try {
//查询签到记录
UserSignin userSignin = userSigninDao.findRecord(dto.getUserId(), dto.getSigninDate());
UserSignIn userSignin = userSigninDao.findRecord(dto.getUserId(), dto.getSignInDate());
if (!userSignin.getIsReward()) {
return Result.failed("尚未完成连续签到的天数");
}
if (userSignin.getIsGet()) {
return Result.failed("该奖励已领取");
}
UserSignin updateDto = new UserSignin();
UserSignIn updateDto = new UserSignIn();
updateDto.setId(userSignin.getId());
updateDto.setIsGet(true);
updateDto.setUpdateTime(new Date());
......@@ -137,20 +141,45 @@ public class UserSigninServiceImpl implements UserSigninService {
@Override
public Result findList(UserSigninRequestDto dto) {
public Result findList(UserSignInRequestDto dto) {
try {
//当前是几号
LocalDate today = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
String formattedDate = today.format(formatter);
//格式如20241101的日期,int类型用户比较
int currentDay = Integer.parseInt(formattedDate);
//当前的年和月
int year = today.getYear();
int month = today.getMonthValue();
if (StringUtils.isEmpty(dto.getYear()) || StringUtils.isEmpty(dto.getMonth())) {
dto.setYearMonth(year + "-" + month);
} else {
dto.setYearMonth(dto.getYear() + "-" + dto.getMonth());
}
//该月份所有的日期
List<String> dateList = DateTimeUtil.getMonthDates(dto.getYearMonth());
Date startTime = DateTimeUtil.getDateWithMinTime(dateList.get(0));
Date endTime = DateTimeUtil.getDateWithMaxTime(dateList.get((dateList.size() - 1)));
dto.setStartQueryTime(startTime);
dto.setEndQueryTime(endTime);
List<UserSignin> userSigninList = userSigninDao.findList(dto);
/* for (String dateStr : dateList) {
if () {
List<UserSignIn> userSignInList = userSigninDao.findList(dto);
List<String> signDateList = userSignInList.stream().map(UserSignIn::getSignInDate).collect(Collectors.toList());
for (String dateStr : dateList) {
SignDateRecord signDateRecord = new SignDateRecord();
int day = Integer.parseInt(dateStr.replace("-", ""));
if (day < currentDay) {
signDateRecord.setDateState(SigninEnum.DateStateEnum.PASS.getCode());
} else if (day == currentDay) {
signDateRecord.setDateState(SigninEnum.DateStateEnum.CURRENT.getCode());
} else {
signDateRecord.setDateState(SigninEnum.DateStateEnum.FUTURE.getCode());
}
//签到记录里包含该日期则表示已签到
if (signDateList.contains(dateStr)) {
signDateRecord.setIsSignIn(true);
}
}
}*/
return Result.success();
} catch (Exception e) {
......@@ -159,6 +188,18 @@ public class UserSigninServiceImpl implements UserSigninService {
return Result.failed();
}
@Override
public Result getShareInfo(UserSignInRequestDto dto) {
try {
} catch (Exception e) {
logger.error("获取分享信息失败 error : {}", e);
}
return Result.failed();
}
public static void main(String[] args) {
List<String> dateList = DateTimeUtil.getMonthDates("2024-11");
Date startTime = DateTimeUtil.getDateWithMinTime(dateList.get(0));
......
package com.wwdz.ch.wx.impl.distribution;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
......@@ -22,7 +21,6 @@ import com.wwdz.ch.core.entity.SupplierItemVo;
import com.wwdz.ch.wx.aspect.AddBrowseLog;
import com.wwdz.ch.wx.constant.CollectionBookConstants;
import com.wwdz.ch.wx.entity.GroupPurchaseInfo;
import com.wwdz.ch.wx.entity.request.ItemTagOperateRequestDto;
import com.wwdz.ch.wx.entity.vo.distribution.AuctionDetailVo;
import com.wwdz.ch.wx.entity.vo.distribution.AuctionRecordRowVo;
import com.wwdz.ch.wx.service.FollowFansRecordService;
......@@ -30,9 +28,6 @@ import com.wwdz.ch.wx.service.distribution.CollectionItemsRelationService;
import com.wwdz.ch.wx.service.distribution.DistributionOrderService;
import com.wwdz.ch.wx.service.distribution.GroupPurchaseService;
import com.wwdz.ch.wx.service.distribution.SupplierItemService;
import com.wwdz.mall.common.vo.response.CloudServerResponse;
import com.wwdz.shop.api.DTO.ShopDTO;
import com.wwdz.shop.api.query.ShopQueryOption;
import com.wwdz.shop.api.service.ShopReadService;
import com.xxdxxs.utils.*;
import org.redisson.api.RLock;
......
package com.wwdz.ch.wx.service;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.UserSigninRequestDto;
import com.wwdz.ch.db.dto.request.UserSignInRequestDto;
public interface UserSigninService {
......@@ -10,20 +10,26 @@ public interface UserSigninService {
* @param dto
* @return
*/
Result signin(UserSigninRequestDto dto);
Result signin(UserSignInRequestDto dto);
/**
* 领取奖励
* @param dto
* @return
*/
Result getReward(UserSigninRequestDto dto);
Result getReward(UserSignInRequestDto dto);
/**
* 查询签到记录
* @param dto
* @return
*/
Result findList(UserSigninRequestDto dto);
Result findList(UserSignInRequestDto dto);
/**
* 获取分享信息
* @param dto
* @return
*/
Result getShareInfo(UserSignInRequestDto dto);
}
......@@ -3,7 +3,7 @@ package com.wwdz.ch.wx.web;
import com.alibaba.fastjson.JSON;
import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dto.request.UserSigninRequestDto;
import com.wwdz.ch.db.dto.request.UserSignInRequestDto;
import com.wwdz.ch.wx.service.UserSigninService;
import com.xxdxxs.service.FormHandler;
import com.xxdxxs.validation.Validator;
......@@ -27,7 +27,7 @@ public class UserSigninController {
@ApiOperation(value = "用户签到")
@PostMapping("/checkAbleToOpenShop")
public Result checkAbleToOpenShop(@RequestBody UserSigninRequestDto dto) {
public Result checkAbleToOpenShop(@RequestBody UserSignInRequestDto dto) {
logger.info("【请求开始】用户签到,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("userId", "用户id").must().number()
......@@ -41,7 +41,7 @@ public class UserSigninController {
@ApiOperation(value = "领取奖励")
@PostMapping("/getReward")
public Result getReward(@RequestBody UserSigninRequestDto dto) {
public Result getReward(@RequestBody UserSignInRequestDto dto) {
logger.info("【请求开始】领取奖励,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("userId", "用户id").must().number()
......@@ -57,7 +57,7 @@ public class UserSigninController {
@ApiOperation(value = "查询签到记录")
@PostMapping("/findList")
public Result findList(@RequestBody UserSigninRequestDto dto) {
public Result findList(@RequestBody UserSignInRequestDto dto) {
logger.info("【请求开始】查询签到记录,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("userId", "用户id").must().number()
......
......@@ -89,12 +89,12 @@ public class WxPayServiceTest {
@Test
public void refund() {
List<String> list = Arrays.asList("DA2411061130292824378", "DA2411050940309904308", "DA2411040955234251934");
List<String> list = Arrays.asList("DA2411192041343155076");
list.forEach(orderId ->{
DistributionOrderRequestDto dto = new DistributionOrderRequestDto();
dto.setDistributionOrderId(orderId);
dto.setAmount("1");
dto.setRefundPrice("1");
dto.setAmount("24.9");
dto.setRefundPrice("24.9");
Result result = wxPayServiceApi.refund(dto);
logger.info("申请微信支付退款:{}", result);
});
......
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