Commit 84f93740 authored by shiyu's avatar shiyu

签到

parent 9f276395
package com.wwdz.ch.db.dao;
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);
UserSignin findLastedRecord(long userId);
List<UserSignin> findList(UserSigninRequestDto dto);
UserSignin findYesterdayRecord(long userId);
}
package com.wwdz.ch.db.domain;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/11/11
*/
@Data
public class UserSignin implements Entity {
/**
* id
*/
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 签到时间
*/
private Date signinTime;
/**
* 连续天数
*/
private Integer consecutiveDays;
private static final long serialVersionUID = 1L;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", signinTime=").append(signinTime);
sb.append(", consecutiveDays=").append(consecutiveDays);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
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.getSigninTime() == null ? other.getSigninTime() == null : this.getSigninTime().equals(other.getSigninTime()))
&& (this.getConsecutiveDays() == null ? other.getConsecutiveDays() == null : this.getConsecutiveDays().equals(other.getConsecutiveDays()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getSigninTime() == null) ? 0 : getSigninTime().hashCode());
result = prime * result + ((getConsecutiveDays() == null) ? 0 : getConsecutiveDays().hashCode());
return result;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public enum Column {
id("id", "id", "BIGINT", false),
userId("user_id", "userId", "BIGINT", false),
signinTime("signin_time", "signinTime", "TIMESTAMP", false),
consecutiveDays("consecutive_days", "consecutiveDays", "INTEGER", false);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String BEGINNING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private static final String ENDING_DELIMITER = "`";
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String column;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final boolean isColumnNameDelimited;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String javaProperty;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private final String jdbcType;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String value() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getValue() {
return this.column;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJavaProperty() {
return this.javaProperty;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getJdbcType() {
return this.jdbcType;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
this.column = column;
this.javaProperty = javaProperty;
this.jdbcType = jdbcType;
this.isColumnNameDelimited = isColumnNameDelimited;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String desc() {
return this.getEscapedColumnName() + " DESC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String asc() {
return this.getEscapedColumnName() + " ASC";
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public static Column[] excludes(Column ... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
}
return columns.toArray(new Column[]{});
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public String getEscapedColumnName() {
if (this.isColumnNameDelimited) {
return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
} else {
return this.column;
}
}
}
}
\ No newline at end of file
package com.wwdz.ch.db.dto.request;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
@Data
public class UserSigninRequestDto extends BaseRequestDto implements Entity {
/**
* id
*/
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 签到时间
*/
private Date signinTime;
/**
* 连续天数
*/
private Integer consecutiveDays;
}
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.xxdxxs.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
@Repository
public class UserSigninDaoImpl implements UserSigninDao {
@Autowired
UserSigninMapper userSigninMapper;
@Override
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();
criteria.andUserIdEqualTo(userId);
example.setOrderByClause("signin_time desc");
return userSigninMapper.selectOneByExample(example);
}
@Override
public List<UserSignin> findList(UserSigninRequestDto dto) {
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(dto.getUserId());
example.setOrderByClause("signin_time desc");
return userSigninMapper.selectByExample(example);
}
@Override
public UserSignin findYesterdayRecord(long userId) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime yesterday = now.minusDays(1);
LocalDateTime minTime = yesterday.with(LocalTime.MIN);
LocalDateTime maxTime = yesterday.with(LocalTime.MAX);
UserSigninExample example = new UserSigninExample();
UserSigninExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andSigninTimeGreaterThanOrEqualTo(DateUtils.fromLocalDateTime(minTime));
criteria.andSigninTimeLessThanOrEqualTo(DateUtils.fromLocalDateTime(maxTime));
return userSigninMapper.selectOneByExample(example);
}
}
package com.wwdz.ch.db.mapper;
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);
int deleteByExample(UserSigninExample example);
int deleteByPrimaryKey(Long id);
int insert(UserSignin record);
int insertSelective(UserSignin record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserSignin selectOneByExample(UserSigninExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
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
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<UserSignin> selectByExampleSelective(@Param("example") UserSigninExample example, @Param("selective") UserSignin.Column ... selective);
List<UserSignin> selectByExample(UserSigninExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_signin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserSignin selectByPrimaryKeySelective(@Param("id") Long id, @Param("selective") UserSignin.Column ... selective);
UserSignin selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UserSignin record, @Param("example") UserSigninExample example);
int updateByExample(@Param("record") UserSignin record, @Param("example") UserSigninExample example);
int updateByPrimaryKeySelective(UserSignin record);
int updateByPrimaryKey(UserSignin record);
}
\ No newline at end of file
...@@ -63,16 +63,16 @@ ...@@ -63,16 +63,16 @@
<!--生成Model类存放位置--> <!--生成Model类存放位置-->
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain.openShop" targetProject="ch-dao/src/main/java"> <javaModelGenerator targetPackage="com.wwdz.ch.db.domain" targetProject="ch-dao/src/main/java">
<property name="enableSubPackages" value="true"/> <property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/> <property name="trimStrings" value="true"/>
</javaModelGenerator> </javaModelGenerator>
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper.openShop" targetProject="ch-dao/src/main/resources"/> <sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.openShop" <javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
targetProject="ch-dao/src/main/java"/> targetProject="ch-dao/src/main/java"/>
<table tableName="user_account" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"> <table tableName="user_signin" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" /> <generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table> </table>
......
...@@ -89,12 +89,12 @@ public class WxPayServiceTest { ...@@ -89,12 +89,12 @@ public class WxPayServiceTest {
@Test @Test
public void refund() { public void refund() {
List<String> list = Arrays.asList("DA2411042000269405675"); List<String> list = Arrays.asList("DA2411091934133307007");
list.forEach(orderId ->{ list.forEach(orderId ->{
DistributionOrderRequestDto dto = new DistributionOrderRequestDto(); DistributionOrderRequestDto dto = new DistributionOrderRequestDto();
dto.setDistributionOrderId(orderId); dto.setDistributionOrderId(orderId);
dto.setAmount("30"); dto.setAmount("20");
dto.setRefundPrice("30"); dto.setRefundPrice("20");
Result result = wxPayServiceApi.refund(dto); Result result = wxPayServiceApi.refund(dto);
logger.info("申请微信支付退款:{}", result); 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