From: yunpeng.ma Date: Wed, 5 Aug 2020 01:58:46 +0000 (+0800) Subject: 积分模块 X-Git-Tag: 1.0.25^2~3 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=3fce90f8dbdecfd1a9f87ef9305a2529f104d575;p=epayment%2Ffood_payapi.git 积分模块 --- diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java index 988afaaa..5483aa1c 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersonDao.java @@ -19,4 +19,8 @@ public interface PersonDao extends JpaRepository { TPerson findByUserid(String userid); Page findAllByNameContaining(String name, Pageable pageable); + + TPerson findByUseridAndAndName(String userid,String name); + + TPerson findByUseridAndIdtype(String userid,String idtype); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java index 18c15d99..ebf83923 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/api/dao/PersondtlDao.java @@ -2,6 +2,7 @@ package com.supwisdom.dlpay.api.dao; import com.supwisdom.dlpay.api.domain.TPersondtl; import com.supwisdom.dlpay.framework.data.CountAmountBean; +import com.supwisdom.dlpay.framework.domain.TPointsdtl; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,10 +10,16 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface PersondtlDao extends JpaRepository,JpaSpecificationExecutor { Page findByUseridAndStatus(String userid,String status, Pageable pageable); @Query("select count(t.refno) as totalcnt,sum(t.amount) as totalamt from TPersondtl t where t.status='success' and t.accdate=?1 and t.sourceType=?2 and t.tenantid=?3 ") CountAmountBean getPersondtlSumInfo(String accdate, String sourcetype, String tenantid); + + List findAllByUseridAndTransdateAndReverseFlagAndStatus(String userid, String transdate,String reverseFlag,String status); + + List findAllByUseridAndTransdateStartingWithAndReverseFlagAndStatus(String userid, String transdate,String reverseFlag,String status); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ConsumePointsDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ConsumePointsDao.java new file mode 100644 index 00000000..57fd086b --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/ConsumePointsDao.java @@ -0,0 +1,13 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TConsumePoints; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface ConsumePointsDao extends JpaRepository { + List findAllByAndRuletype(String ruletype, Sort sort); +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PersonLevelDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PersonLevelDao.java new file mode 100644 index 00000000..c0bd26dd --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PersonLevelDao.java @@ -0,0 +1,19 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TPersonLevel; +import com.supwisdom.dlpay.framework.domain.TRole; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface PersonLevelDao extends JpaRepository { + + @Query(value = "from TPersonLevel t where t.pointsLower<=:points and t.pointsUpper>=:points ") + TPersonLevel findTPersonLevelByPoints(@Param("points")Integer points); +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsActiveDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsActiveDao.java new file mode 100644 index 00000000..6454ba78 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsActiveDao.java @@ -0,0 +1,13 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TPointsActive; +import com.supwisdom.dlpay.framework.domain.TPointsMain; +import com.supwisdom.dlpay.framework.domain.TShop; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +@Repository +public interface PointsActiveDao extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDetailDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDetailDao.java new file mode 100644 index 00000000..db427c3c --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDetailDao.java @@ -0,0 +1,14 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TBusinesspara; +import com.supwisdom.dlpay.framework.domain.TPointsDetail; +import com.supwisdom.dlpay.framework.domain.TPointsTask; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PointsDetailDao extends JpaRepository { + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDtlDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDtlDao.java new file mode 100644 index 00000000..0f9f8ce6 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsDtlDao.java @@ -0,0 +1,23 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TPointsActive; +import com.supwisdom.dlpay.framework.domain.TPointsdtl; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface PointsDtlDao extends JpaRepository, JpaSpecificationExecutor { + + Page findAllByUserid(String userid, Pageable pageable); + + List findAllByUseridAndTypeAndFlagstatus(String userid, String type,String flagstatus); + + TPointsdtl findAllByUseridAndTransdateAndRefno(String userid,String transdate,Integer refno); + + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsMainDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsMainDao.java new file mode 100644 index 00000000..6769b7f2 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsMainDao.java @@ -0,0 +1,11 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TPointsMain; +import com.supwisdom.dlpay.framework.domain.TPointsTask; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PointsMainDao extends JpaRepository { + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsTaskDao.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsTaskDao.java new file mode 100644 index 00000000..8da33a8d --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/dao/PointsTaskDao.java @@ -0,0 +1,10 @@ +package com.supwisdom.dlpay.framework.dao; + +import com.supwisdom.dlpay.framework.domain.TPointsTask; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PointsTaskDao extends JpaRepository { + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TConsumePoints.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TConsumePoints.java new file mode 100644 index 00000000..84fb2c1f --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TConsumePoints.java @@ -0,0 +1,89 @@ +package com.supwisdom.dlpay.framework.domain; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "TB_CONSUME_POINTS") +public class TConsumePoints { + @Id + @SequenceGenerator(name = "conpointsno", sequenceName = "SEQ_CONPOINTSNO", allocationSize = 1, initialValue = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "conpointsno") + @Column(name = "ID", nullable = false, precision = 32) + private Integer id; + + @Column(name = "NAME", length = 32) + private String name; + + @Column(name = "CONSUMEAMOUNT") + private String consumeamount; + + @Column(name = "POINTS") + @NotNull + private Integer points; + + @Column(name = "RULETYPE") + private String ruletype; + + @Column(name = "UPDATETIME") + private String updatetime; + + @Column(name = "OPERATORID") + private String operatorid; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getConsumeamount() { + return consumeamount; + } + + public void setConsumeamount(String consumeamount) { + this.consumeamount = consumeamount; + } + + public Integer getPoints() { + return points; + } + + public void setPoints(Integer points) { + this.points = points; + } + + public String getRuletype() { + return ruletype; + } + + public void setRuletype(String ruletype) { + this.ruletype = ruletype; + } + + public String getUpdatetime() { + return updatetime; + } + + public void setUpdatetime(String updatetime) { + this.updatetime = updatetime; + } + + public String getOperatorid() { + return operatorid; + } + + public void setOperatorid(String operatorid) { + this.operatorid = operatorid; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPersonLevel.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPersonLevel.java new file mode 100644 index 00000000..33027d87 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPersonLevel.java @@ -0,0 +1,114 @@ +package com.supwisdom.dlpay.framework.domain; + +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "TB_PERSON_LEVEL") +public class TPersonLevel { + @Id + @SequenceGenerator(name = "personno", sequenceName = "SEQ_PERSONNO", allocationSize = 1, initialValue = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "personno") + @Column(name = "ID", nullable = false, precision = 32) + private Integer id; + + @Column(name = "NAME", length = 32) + private String name; + + @Column(name = "POINTSLOWER") + @NotNull + private Integer pointsLower; + + @Column(name = "POINTSUPPER") + @NotNull + private Integer pointsUpper; + + @Column(name = "UPDATETIME") + private String updatetime; + + @Column(name = "OPERATORID") + private String operatorid; + + @Column(name = "SINGLECONSUMEAMOUNT") + private Integer singleConsumeAmount; + + @Column(name = "singleamount") + private Integer singleAmount; + + @Column(name = "singlepoints") + private Integer singlePoints; + + public Integer getSingleConsumeAmount() { + return singleConsumeAmount; + } + + public void setSingleConsumeAmount(Integer singleConsumeAmount) { + this.singleConsumeAmount = singleConsumeAmount; + } + + public Integer getSingleAmount() { + return singleAmount; + } + + public void setSingleAmount(Integer singleAmount) { + this.singleAmount = singleAmount; + } + + public Integer getSinglePoints() { + return singlePoints; + } + + public void setSinglePoints(Integer singlePoints) { + this.singlePoints = singlePoints; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getPointsLower() { + return pointsLower; + } + + public void setPointsLower(Integer pointsLower) { + this.pointsLower = pointsLower; + } + + public Integer getPointsUpper() { + return pointsUpper; + } + + public void setPointsUpper(Integer pointsUpper) { + this.pointsUpper = pointsUpper; + } + + public String getUpdatetime() { + return updatetime; + } + + public void setUpdatetime(String updatetime) { + this.updatetime = updatetime; + } + + public String getOperatorid() { + return operatorid; + } + + public void setOperatorid(String operatorid) { + this.operatorid = operatorid; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsActive.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsActive.java new file mode 100644 index 00000000..4ec689cb --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsActive.java @@ -0,0 +1,155 @@ +package com.supwisdom.dlpay.framework.domain; + +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; + +@Entity +@Table(name = "TB_POINTS_ACTIVE") +public class TPointsActive { + @Id + @SequenceGenerator(name = "activeno", sequenceName = "SEQ_ACTIVENO", allocationSize = 1, initialValue = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "activeno") + @Column(name = "ID", nullable = false, precision = 32) + private Integer id; + + @Column(name = "NAME", length = 32) + private String name; + + @Column(name = "TYPE") + private String type; + + @Column(name = "STARTDATE") + private String startdate; + + @Column(name = "ENDDATE") + private String enddate; + + @Column(name = "WEEKNUMBER") + private Integer weeknumber; + + @Column(name = "WEEKDAY") + private String weekday; + + @Column(name = "RATE") + private String rate; + + @Column(name = "REMARK") + private String remark; + + @Column(name = "UPDATETIME") + private String updatetime; + + @Column(name = "OPERATORID") + private String operatorid; + + @Transient + private String yearStartDate; + + @Transient + private String yearEndDate; + + public String getYearStartDate() { + return yearStartDate; + } + + public void setYearStartDate(String yearStartDate) { + this.yearStartDate = yearStartDate; + } + + public String getYearEndDate() { + return yearEndDate; + } + + public void setYearEndDate(String yearEndDate) { + this.yearEndDate = yearEndDate; + } + + public String getUpdatetime() { + return updatetime; + } + + public void setUpdatetime(String updatetime) { + this.updatetime = updatetime; + } + + public String getOperatorid() { + return operatorid; + } + + public void setOperatorid(String operatorid) { + this.operatorid = operatorid; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getStartdate() { + return startdate; + } + + public void setStartdate(String startdate) { + this.startdate = startdate; + } + + public String getEnddate() { + return enddate; + } + + public void setEnddate(String enddate) { + this.enddate = enddate; + } + + public Integer getWeeknumber() { + return weeknumber; + } + + public void setWeeknumber(Integer weeknumber) { + this.weeknumber = weeknumber; + } + + public String getWeekday() { + return weekday; + } + + public void setWeekday(String weekday) { + this.weekday = weekday; + } + + public String getRate() { + return rate; + } + + public void setRate(String rate) { + this.rate = rate; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsDetail.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsDetail.java new file mode 100644 index 00000000..973a4ae9 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsDetail.java @@ -0,0 +1,68 @@ +package com.supwisdom.dlpay.framework.domain; + +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "TB_POINTS_DETAIL") +public class TPointsDetail { + @Id + @GenericGenerator(name = "idGenerator", strategy = "uuid") + @GeneratedValue(generator = "idGenerator") + @Column(name = "DETAILID", nullable = false, precision = 32) + private Integer detailid; + + @Column(name = "POINTSDTLID", length = 32) + private Integer pointsdtlId; + + @Column(name = "USERID") + private String userid; + + @Column(name = "POINTS") + private Integer points; + + @Column(name = "OUTDATE") + private String outDate; + + public Integer getDetailid() { + return detailid; + } + + public void setDetailid(Integer detailid) { + this.detailid = detailid; + } + + public Integer getPointsdtlId() { + return pointsdtlId; + } + + public void setPointsdtlId(Integer pointsdtlId) { + this.pointsdtlId = pointsdtlId; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public Integer getPoints() { + return points; + } + + public void setPoints(Integer points) { + this.points = points; + } + + public String getOutDate() { + return outDate; + } + + public void setOutDate(String outDate) { + this.outDate = outDate; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsMain.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsMain.java new file mode 100644 index 00000000..1aea3195 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsMain.java @@ -0,0 +1,117 @@ +package com.supwisdom.dlpay.framework.domain; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "TB_POINTS_MAIN") +public class TPointsMain { + @Id + @Column(name = "USERID", nullable = false, precision = 32) + private String userid; + + @Column(name = "POINTS", length = 32) + private Integer points; + + @Column(name = "ACCUMPOINTS") + private Integer accumPoints; + + @Column(name = "SUMPAYPOINTS") + private Integer sumpayPoints; + + @Column(name = "OUTPOINTS") + private Integer outPoints; + + @Column(name = "UPDATETIME") + private String updatetime; + + @Column(name = "LEVELID") + private Integer levelid; + + @Transient + private String name; + @Transient + private String cardno; + @Transient + private String levelname; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getLevelid() { + return levelid; + } + + public void setLevelid(Integer levelid) { + this.levelid = levelid; + } + + public String getCardno() { + return cardno; + } + + public void setCardno(String cardno) { + this.cardno = cardno; + } + + public String getLevelname() { + return levelname; + } + + public void setLevelname(String levelname) { + this.levelname = levelname; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public Integer getPoints() { + return points; + } + + public void setPoints(Integer points) { + this.points = points; + } + + public Integer getAccumPoints() { + return accumPoints; + } + + public void setAccumPoints(Integer accumPoints) { + this.accumPoints = accumPoints; + } + + public Integer getSumpayPoints() { + return sumpayPoints; + } + + public void setSumpayPoints(Integer sumpayPoints) { + this.sumpayPoints = sumpayPoints; + } + + public Integer getOutPoints() { + return outPoints; + } + + public void setOutPoints(Integer outPoints) { + this.outPoints = outPoints; + } + + public String getUpdatetime() { + return updatetime; + } + + public void setUpdatetime(String updatetime) { + this.updatetime = updatetime; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsTask.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsTask.java new file mode 100644 index 00000000..a0b32d3c --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsTask.java @@ -0,0 +1,100 @@ +package com.supwisdom.dlpay.framework.domain; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "TB_POINTS_TASK") +public class TPointsTask { + @Id + @SequenceGenerator(name = "taskno", sequenceName = "SEQ_TASKNO", allocationSize = 1, initialValue = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "taskno") + @Column(name = "TASKID", nullable = false, precision = 32) + private Integer taskid; + + @Column(name = "TASKNAME", length = 32) + private String taskname; + + @Column(name = "TYPE") + private String type; + + @Column(name = "TASKPOINTS") + @NotNull + private Integer taskpoints; + + @Column(name = "REMARK") + private String remark; + + @Column(name = "STARTTIME") + private String starttime; + + @Column(name = "ENDTIME") + private String endtime; + + @Column(name = "ENABLE") + private String enable; + + public Integer getTaskid() { + return taskid; + } + + public void setTaskid(Integer taskid) { + this.taskid = taskid; + } + + public String getTaskname() { + return taskname; + } + + public void setTaskname(String taskname) { + this.taskname = taskname; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getTaskpoints() { + return taskpoints; + } + + public void setTaskpoints(Integer taskpoints) { + this.taskpoints = taskpoints; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public String getStarttime() { + return starttime; + } + + public void setStarttime(String starttime) { + this.starttime = starttime; + } + + public String getEndtime() { + return endtime; + } + + public void setEndtime(String endtime) { + this.endtime = endtime; + } + + public String getEnable() { + return enable; + } + + public void setEnable(String enable) { + this.enable = enable; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsdtl.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsdtl.java new file mode 100644 index 00000000..8879b2cc --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/domain/TPointsdtl.java @@ -0,0 +1,166 @@ +package com.supwisdom.dlpay.framework.domain; + +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.*; + +@Entity +@Table(name = "TB_POINTSDTL") +public class TPointsdtl { + @Id + @GenericGenerator(name = "idGenerator", strategy = "uuid") + @GeneratedValue(generator = "idGenerator") + @Column(name = "ID", nullable = false, precision = 32) + private Integer id; + + @Column(name = "REFNO", length = 32) + private Integer refno; + + @Column(name = "TYPE") + private String type; + + @Column(name = "USERID") + private String userid; + + @Column(name = "POINTS") + private String points; + + @Column(name = "STATUS", length = 32) + private String status; + + @Column(name = "AFTPOINTS") + private Integer aftpoints; + + @Column(name = "BILLNO") + private String billno; + + @Column(name = "TRANSDATE") + private String transdate; + + @Column(name = "TRANSTIME", length = 32) + private String transtime; + + @Column(name = "DETAILID") + private Integer detailid; + + @Column(name = "MAINSTATUS") + private String mainstatus; + + @Column(name = "FLAGSTATUS") + private String flagstatus; + + @Transient + private TPointsMain tPointsMain; + + public TPointsMain gettPointsMain() { + return tPointsMain; + } + + public void settPointsMain(TPointsMain tPointsMain) { + this.tPointsMain = tPointsMain; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getRefno() { + return refno; + } + + public void setRefno(Integer refno) { + this.refno = refno; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getPoints() { + return points; + } + + public void setPoints(String points) { + this.points = points; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Integer getAftpoints() { + return aftpoints; + } + + public void setAftpoints(Integer aftpoints) { + this.aftpoints = aftpoints; + } + + public String getBillno() { + return billno; + } + + public void setBillno(String billno) { + this.billno = billno; + } + + public String getTransdate() { + return transdate; + } + + public void setTransdate(String transdate) { + this.transdate = transdate; + } + + public String getTranstime() { + return transtime; + } + + public void setTranstime(String transtime) { + this.transtime = transtime; + } + + public Integer getDetailid() { + return detailid; + } + + public void setDetailid(Integer detailid) { + this.detailid = detailid; + } + + public String getMainstatus() { + return mainstatus; + } + + public void setMainstatus(String mainstatus) { + this.mainstatus = mainstatus; + } + + public String getFlagstatus() { + return flagstatus; + } + + public void setFlagstatus(String flagstatus) { + this.flagstatus = flagstatus; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java index fe39ac82..04717256 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java @@ -4,6 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.sql.Timestamp; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -358,4 +359,53 @@ public class DateUtil { public static Boolean sameDay(Timestamp d1, Timestamp d2) { return (compareDay(d1, d2) == 0); } + + /** + * 格式化字符串日期 + * @param dateStr 字符串日期 + * @param srcFormat 字符串日期格式 + * @param destFormat 目标格式 + * @return + */ + public static String formatDateStr(String dateStr, String srcFormat, String destFormat) { + Date date = getDate(dateStr, srcFormat); + if(date==null){ + return dateStr; + } + return formatDate(date, destFormat); + } + + /** + * Description: string 格式的日期转换成java.util.Date格式的日期 + * + * @param @param datetime + * @param @param pattern + * @param @return + * @param @throws ParseException + * @return Date Modify History: 2010-8-5 Linqing.He create + */ + public static Date getDate(String datetime, String pattern) { + if(datetime==null){ + return null; + } + SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); + Date startDate = null; + try { + startDate = dateFormat.parse(datetime); + }catch (Exception e) { + logger.error("error:",e); + } + return startDate; + } + + /** + * 按照给定格式,格式化日期对象 + * @param date 日期对象 + * @param pattern 给定格式 + * @return + */ + public static String formatDate(Date date, String pattern) { + DateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java index 9c2162ff..d69548dd 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/util/TradeDict.java @@ -110,4 +110,14 @@ public class TradeDict { public static final String REVERSE_FLAG_WIP = "wip"; public static final String REVERSE_FLAG_CANCEL = "cancel"; public static final String REVERSE_FLAG_REFUND = "refund"; + + + /* + * 积分中心模块 + * + * + * */ + public static final String CONSUME_FLAG_SINGLE = "single"; + public static final String CONSUME_FLAG_DAY = "day"; + public static final String CONSUME_FLAG_MONTH = "month"; } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/bean/LevelBean.java b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/LevelBean.java new file mode 100644 index 00000000..964ef8c9 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/bean/LevelBean.java @@ -0,0 +1,173 @@ +package com.supwisdom.dlpay.system.bean; + +import com.supwisdom.dlpay.framework.domain.TConsumePoints; +import com.supwisdom.dlpay.framework.domain.TPersonLevel; +import com.supwisdom.dlpay.framework.domain.TPointsActive; +import com.supwisdom.dlpay.framework.domain.TPointsTask; + +import java.util.List; + +public class LevelBean extends PageBean { + private List tPersonLevels; + private TPointsTask tPointsTask; + private String name; + private String idno; + private String userid; + private Integer levelid; + private Integer conPointsid; + private List tConsumePoints; + private List monthList; + private List dayList; + private Integer pointslimit; + private Integer pointsdate; + private TPointsActive pointsActive; + private String type; + private Integer activeid; + private String startDate; + private String endDate; + private String pointsName; + + public String getPointsName() { + return pointsName; + } + + public void setPointsName(String pointsName) { + this.pointsName = pointsName; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public Integer getActiveid() { + return activeid; + } + + public void setActiveid(Integer activeid) { + this.activeid = activeid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public TPointsActive getPointsActive() { + return pointsActive; + } + + public void setPointsActive(TPointsActive pointsActive) { + this.pointsActive = pointsActive; + } + + public Integer getPointsdate() { + return pointsdate; + } + + public void setPointsdate(Integer pointsdate) { + this.pointsdate = pointsdate; + } + + public Integer getPointslimit() { + return pointslimit; + } + + public void setPointslimit(Integer pointslimit) { + this.pointslimit = pointslimit; + } + + public List getMonthList() { + return monthList; + } + + public void setMonthList(List monthList) { + this.monthList = monthList; + } + + public List getDayList() { + return dayList; + } + + public void setDayList(List dayList) { + this.dayList = dayList; + } + + public Integer getConPointsid() { + return conPointsid; + } + + public void setConPointsid(Integer conPointsid) { + this.conPointsid = conPointsid; + } + + public List gettConsumePoints() { + return tConsumePoints; + } + + public void settConsumePoints(List tConsumePoints) { + this.tConsumePoints = tConsumePoints; + } + + public Integer getLevelid() { + return levelid; + } + + public void setLevelid(Integer levelid) { + this.levelid = levelid; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIdno() { + return idno; + } + + public void setIdno(String idno) { + this.idno = idno; + } + + public TPointsTask gettPointsTask() { + return tPointsTask; + } + + public void settPointsTask(TPointsTask tPointsTask) { + this.tPointsTask = tPointsTask; + } + + public List gettPersonLevels() { + return tPersonLevels; + } + + public void settPersonLevels(List tPersonLevels) { + this.tPersonLevels = tPersonLevels; + } +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/controller/PointsController.java b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/PointsController.java new file mode 100644 index 00000000..e3f43e0b --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/controller/PointsController.java @@ -0,0 +1,282 @@ +package com.supwisdom.dlpay.system.controller; + +import com.supwisdom.dlpay.api.bean.JsonResult; +import com.supwisdom.dlpay.framework.dao.DictionaryDao; +import com.supwisdom.dlpay.framework.domain.*; +import com.supwisdom.dlpay.framework.security.OperUtil; +import com.supwisdom.dlpay.framework.util.*; +import com.supwisdom.dlpay.system.bean.LevelBean; +import com.supwisdom.dlpay.system.service.OperatorService; +import com.supwisdom.dlpay.system.service.PointsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + + +@Controller +public class PointsController { + + @Autowired + private PointsService pointsService; + @Autowired + private OperatorService operatorService; + + + @GetMapping("/level/index") + public String index() { + return "system/level/index"; + } + + @GetMapping("/level/list") + @PreAuthorize("hasPermission('/user/list','')") + @ResponseBody + public JsonResult getDataList() { + try { + LevelBean levelBean = pointsService.getLevel(); + return JsonResult.ok().put("datalist",levelBean.gettPersonLevels()) + .put("pointsdate",levelBean.getPointsdate()); + } catch (Exception e) { + e.printStackTrace(); + return JsonResult.error("系统查询错误"); + } + } + + @PostMapping("/level/add") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult add(@RequestBody LevelBean levelBean) { + TOperator operator = OperUtil.getCurrentOper(); + if (operator != null) { + operator = operatorService.getOperatorByCode(operator.getOpercode()); + } + for (TPersonLevel tPersonLevel : levelBean.gettPersonLevels()) { + if (StringUtil.isEmpty(tPersonLevel.getName()) + || tPersonLevel.getPointsLower() == null + || tPersonLevel.getPointsUpper() == null) { + return JsonResult.error("参数错误"); + } + if (tPersonLevel.getPointsLower() > tPersonLevel.getPointsUpper()) { + return JsonResult.error("积分下限必须小于积分上限"); + } + tPersonLevel.setUpdatetime(DateUtil.getNow()); + tPersonLevel.setOperatorid(operator.getOpercode()); + } + return pointsService.saveLevel(levelBean); + } + + @PostMapping("/level/delete") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult deleteLevel(@RequestBody LevelBean levelBean) { + TPersonLevel tPersonLevel = new TPersonLevel(); + tPersonLevel.setId(levelBean.getLevelid()); + return pointsService.deleteLevel(tPersonLevel); + } + + @GetMapping("/task/list") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public PageResult getTPointsTask(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize) { + try { + if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; + if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; + LevelBean searchBean = new LevelBean(); + searchBean.setPageNo(pageNo); + searchBean.setPageSize(pageSize); + return pointsService.getTPointsTask(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } + + + @PostMapping("/task/add") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult saveTask(@RequestBody LevelBean levelBean) { + if (levelBean.gettPointsTask().getTaskid() == null + || levelBean.gettPointsTask().getTaskpoints() == null) { + return JsonResult.error("参数错误"); + } + return pointsService.saveTask(levelBean.gettPointsTask()); + } + + @GetMapping("/task/loadadd") + public String add() { + return "system/level/taskadd"; + } + + + @GetMapping("/userpoints/index") + public String userpointsindex() { + return "system/level/userpointsindex"; + } + + @GetMapping("/userpoints/list") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public PageResult getTPointsByname(@RequestParam("name") String name, + @RequestParam("idno") String idno, + @RequestParam(value = "startDate",required = false) String startDate, + @RequestParam(value = "endDate",required = false) String endDate, + @RequestParam(value = "pointsName",required = false) String pointsName, + @RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize) { + try { + LevelBean searchBean = new LevelBean(); + searchBean.setName(name); + searchBean.setIdno(idno); + searchBean.setPageNo(pageNo); + searchBean.setPageSize(pageSize); + if(!StringUtil.isEmpty(startDate)){ + searchBean.setStartDate(DateUtil.formatDateStr(startDate,"yyyyå¹´MM月dd日","yyyyMMdd")); + } + if(!StringUtil.isEmpty(endDate)){ + searchBean.setEndDate(DateUtil.formatDateStr(endDate,"yyyyå¹´MM月dd日","yyyyMMdd")); + } + if(!StringUtil.isEmpty(pointsName)){ + searchBean.setPointsName(pointsName); + } + return pointsService.getTPointsByname(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } + + +// @GetMapping("/pointsdetail/list") +// @PreAuthorize("hasPermission('/user/add','')") +// @ResponseBody +// public PageResult getTPointsdetailByname(@RequestParam("page") Integer pageNo, +// @RequestParam("limit") Integer pageSize, +// @RequestParam("userid") String userid) { +// try { +// LevelBean searchBean = new LevelBean(); +// searchBean.setUserid(userid); +// searchBean.setPageNo(pageNo); +// searchBean.setPageSize(pageSize); +// return pointsService.getTPointsdetailByname(searchBean); +// } catch (Exception e) { +// e.printStackTrace(); +// return new PageResult<>(99, "系统查询错误"); +// } +// } + +// @GetMapping("/pointsdetail/pointsdetailindex") +// public String pointsdetail() { +// return "system/level/pointsdetail"; +// } + + + @GetMapping("/consume/rulelist") + @PreAuthorize("hasPermission('/user/list','')") + @ResponseBody + public JsonResult getConpointsList() { + try { + LevelBean levelBean = pointsService.getConpoints(); + return JsonResult.ok().put("monthConsumeList", levelBean.getMonthList()) + .put("pointslimit", levelBean.getPointslimit()) + .put("dayConsumeList", levelBean.getDayList()); + } catch (Exception e) { + e.printStackTrace(); + return JsonResult.error("系统查询错误"); + } + } + + @PostMapping("/consume/addRulelist") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult addRulelist(@RequestBody LevelBean levelBean) { + TOperator operator = OperUtil.getCurrentOper(); + if (operator != null) { + operator = operatorService.getOperatorByCode(operator.getOpercode()); + } + for (TConsumePoints tConsumePoints : levelBean.gettConsumePoints()) { + if (StringUtil.isEmpty(tConsumePoints.getConsumeamount()) || tConsumePoints.getPoints() == null) { + return JsonResult.error("参数错误"); + } + tConsumePoints.setUpdatetime(DateUtil.getNow()); + tConsumePoints.setOperatorid(operator.getOpercode()); + } + return pointsService.saveConpoints(levelBean); + } + + @PostMapping("/consume/deleteRule") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult deleteRule(@RequestBody LevelBean levelBean) { + TConsumePoints tConsumePoints = new TConsumePoints(); + tConsumePoints.setId(levelBean.getConPointsid()); + return pointsService.deleteConpoints(tConsumePoints); + } + + + + /* + * 活动日管理 + * + * */ + @GetMapping("/pointsActive/index") + public String pointsActiveIndex() { + return "system/level/pointsactiveindex"; + } + + @GetMapping("/pointsActive/list") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public PageResult getActiveList(@RequestParam("page") Integer pageNo, + @RequestParam("limit") Integer pageSize, + @RequestParam("name") String name, + @RequestParam("type") String type) { + try { + LevelBean searchBean = new LevelBean(); + searchBean.setName(name); + searchBean.setType(type); + searchBean.setPageNo(pageNo); + searchBean.setPageSize(pageSize); + return pointsService.getActiveList(searchBean); + } catch (Exception e) { + e.printStackTrace(); + return new PageResult<>(99, "系统查询错误"); + } + } + + @PostMapping("/pointsActive/delete") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult deletePointsActive(@RequestBody LevelBean levelBean) { + TPointsActive tPointsActive = new TPointsActive(); + tPointsActive.setId(levelBean.getActiveid()); + return pointsService.deleteActive(tPointsActive); + } + + @PostMapping("/pointsActive/add") + @PreAuthorize("hasPermission('/user/add','')") + @ResponseBody + public JsonResult addPointsActive(@RequestBody LevelBean levelBean) { + TOperator operator = OperUtil.getCurrentOper(); + if (operator != null) { + operator = operatorService.getOperatorByCode(operator.getOpercode()); + } + if( levelBean.getPointsActive()!=null){ + levelBean.getPointsActive().setUpdatetime(DateUtil.getNow()); + levelBean.getPointsActive().setOperatorid(operator.getOpercode()); + return pointsService.saveActive( levelBean.getPointsActive()); + }else { + return JsonResult.error("参数不能为空"); + } + } + + @GetMapping("/pointsActive/loadadd") + public String add(ModelMap map) { + return "system/level/pointsactiveadd"; + } + +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/PointsService.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/PointsService.java new file mode 100644 index 00000000..c359f08c --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/PointsService.java @@ -0,0 +1,100 @@ +package com.supwisdom.dlpay.system.service; + +import com.supwisdom.dlpay.api.bean.JsonResult; +import com.supwisdom.dlpay.api.domain.TAccount; +import com.supwisdom.dlpay.api.domain.TPerson; +import com.supwisdom.dlpay.api.domain.TPersonIdentity; +import com.supwisdom.dlpay.api.domain.TPointsAccount; +import com.supwisdom.dlpay.framework.domain.*; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.system.bean.CitizenCardSearchBean; +import com.supwisdom.dlpay.system.bean.CitizenCardShowBean; +import com.supwisdom.dlpay.system.bean.LevelBean; +import com.supwisdom.dlpay.system.bean.PersonParamBean; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +public interface PointsService { + + /* + * 用户等级 + * + * */ + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult saveLevel(LevelBean levelBean); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult deleteLevel(TPersonLevel tPersonLevel); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + LevelBean getLevel(); + + /* + * + * 任务 + * + * */ + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + PageResult getTPointsTask(LevelBean levelBean); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult saveTask(TPointsTask tPointsTask); + + + /* + * + * 会员积分 + * + * */ + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + PageResult getTPointsByname(LevelBean levelBean); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + PageResult getTPointsdetailByname(LevelBean levelBean); + + + /* + * 消费获得积分规则 + * */ + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult saveConpoints(LevelBean levelBean); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult deleteConpoints(TConsumePoints consumePoints); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + LevelBean getConpoints(); + + /* + * 通过消费获得积分 + * + * */ + //单次消费进行积分处理 + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + Boolean singleHandlePoints(String userid,Double amount,String billno); + + //日消费进行积分处理 + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + Boolean dayHandlePoints(String userid,String billno); + + //月消费进行积分处理 + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + Boolean monthHandlePoints(String userid,String billno); + + + /* + * + * 活动日管理 * + * */ + PageResult getActiveList(LevelBean levelBean); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult deleteActive(TPointsActive tPointsActive); + + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) + JsonResult saveActive(TPointsActive tPointsActive); +} diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/PointsServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/PointsServiceImpl.java new file mode 100644 index 00000000..ab51abf1 --- /dev/null +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/PointsServiceImpl.java @@ -0,0 +1,439 @@ +package com.supwisdom.dlpay.system.service.impl; + +import com.supwisdom.dlpay.api.bean.JsonResult; +import com.supwisdom.dlpay.api.dao.CardDao; +import com.supwisdom.dlpay.api.dao.PersonDao; +import com.supwisdom.dlpay.api.dao.PersondtlDao; +import com.supwisdom.dlpay.api.domain.TCard; +import com.supwisdom.dlpay.api.domain.TPerson; +import com.supwisdom.dlpay.api.domain.TPersondtl; +import com.supwisdom.dlpay.framework.dao.*; +import com.supwisdom.dlpay.framework.domain.*; +import com.supwisdom.dlpay.framework.util.DateUtil; +import com.supwisdom.dlpay.framework.util.PageResult; +import com.supwisdom.dlpay.framework.util.StringUtil; +import com.supwisdom.dlpay.framework.util.TradeDict; +import com.supwisdom.dlpay.system.bean.LevelBean; +import com.supwisdom.dlpay.system.service.PointsService; +import com.supwisdom.dlpay.util.ConstantUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +@Service +public class PointsServiceImpl implements PointsService { + private Logger logger = LoggerFactory.getLogger(PointsServiceImpl.class); + + @Autowired + private PersonLevelDao personLevelDao; + @Autowired + private PointsTaskDao pointsTaskDao; + @Autowired + private PointsMainDao pointsMainDao; + @Autowired + private CardDao cardDao; + @Autowired + private PersonDao personDao; + @Autowired + private PointsDetailDao pointsDetailDao; + @Autowired + private PointsDtlDao pointsDtlDao; + @Autowired + private ConsumePointsDao consumePointsDao; + @Autowired + private DictionaryDao dictionaryDao; + @Autowired + private PersondtlDao persondtlDao; + @Autowired + private PointsActiveDao pointsActiveDao; + + + @Override + public LevelBean getLevel() { + LevelBean levelBean = new LevelBean(); + Sort sort = new Sort(Sort.Direction.ASC, "id"); + List list = personLevelDao.findAll(sort); + if (!StringUtil.isEmpty(list)) levelBean.settPersonLevels(list); + List tDictionaries = dictionaryDao.findAllByDicttype("pointsdate"); + if(tDictionaries!=null&&tDictionaries.size()>0){ + levelBean.setPointsdate(Integer.parseInt(tDictionaries.get(0).getDictval())); + } + return levelBean; + } + + @Override + public JsonResult saveLevel(LevelBean levelBean) { + List tDictionaries = dictionaryDao.findAllByDicttype("pointsdate"); + if(tDictionaries!=null&&tDictionaries.size()>0){ + tDictionaries.get(0).setDictval(levelBean.getPointsdate()+""); + dictionaryDao.save(tDictionaries.get(0)); + }else { + TDictionary tDictionary = new TDictionary(); + tDictionary.setDictcaption("积分中心的过期时间"); + tDictionary.setDicttype("pointsdate"); + tDictionary.setDicttypename("积分过期天数"); + tDictionary.setDictval(levelBean.getPointsdate()+""); + tDictionary.setTenantId("{tenantid}"); + dictionaryDao.save(tDictionary); + } + List tPersonLevel = levelBean.gettPersonLevels(); + personLevelDao.saveAll(tPersonLevel); + return JsonResult.ok("成功"); + } + + @Override + public JsonResult deleteLevel(TPersonLevel tPersonLevel) { + Optional ret = personLevelDao.findById(tPersonLevel.getId()); + if (!ret.isPresent()) { + return JsonResult.error("等级不存在"); + } + if (tPersonLevel.getId() == 1) { + return JsonResult.error("该等级不能删除"); + } + personLevelDao.deleteById(tPersonLevel.getId()); + return JsonResult.ok("成功"); + } + + + @Override + public PageResult getTPointsTask(LevelBean param) { + Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()); + return new PageResult<>(pointsTaskDao.findAll(pageable)); + } + + @Override + public JsonResult saveTask(TPointsTask tPointsTask) { + pointsTaskDao.save(tPointsTask); + return JsonResult.ok("成功"); + } + + + @Override + public PageResult getTPointsByname(LevelBean param) { + TCard tCard = cardDao.findCardByCardnoAndCardtype(param.getIdno(), ConstantUtil.CARDTYPE_CITIZENCARD); + if(tCard==null||StringUtil.isEmpty(tCard.getUserid())){ + return new PageResult<>(99, "未查询到该用户的信息"); + } + TPerson tPerson = personDao.findByUseridAndAndName(tCard.getUserid(),param.getName()); + if(tPerson==null){ + return new PageResult<>(99, "未查询到该用户的信息"); + } + Optional pointsMain = pointsMainDao.findById(tCard.getUserid()); + TPointsMain tPointsMain; + TPersonLevel tPersonLevel; + if(pointsMain.orElse(null)==null){ + tPointsMain = new TPointsMain(); + tPointsMain.setPoints(0); + tPointsMain.setUpdatetime(DateUtil.getNow("yyyy-MM-dd HH:mm:ss")); + tPersonLevel = personLevelDao.findTPersonLevelByPoints(tPointsMain.getPoints()); + if(tPersonLevel==null){ + return new PageResult<>(99, "请设置0积分等级"); + } + }else{ + tPointsMain = pointsMain.orElse(null); + tPointsMain.setUpdatetime(DateUtil.parseToDateFormat(tPointsMain.getUpdatetime())); + Optional tPersonLeveltemp = personLevelDao.findById(tPointsMain.getLevelid()); + tPersonLevel = tPersonLeveltemp.orElse(null); + } + tPointsMain.setName(param.getName()); + tPointsMain.setCardno(param.getIdno()); + tPointsMain.setLevelname(tPersonLevel.getName()); + Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()); + +// Page page = pointsDtlDao.findAllByUserid(tCard.getUserid(),pageable); + + Page page = pointsDtlDao.findAll(new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + if (!StringUtil.isEmpty(tCard.getUserid())) { + predicates.add(criteriaBuilder.equal(root.get("userid").as(String.class), tCard.getUserid().trim())); + } + if (!StringUtil.isEmpty(param.getStartDate())) { + predicates.add(criteriaBuilder.ge(root.get("transdate").as(Long.class), Long.valueOf(DateUtil.unParseToDateFormat(param.getStartDate())))); + } + if (!StringUtil.isEmpty(param.getEndDate())) { + predicates.add(criteriaBuilder.le(root.get("transdate").as(Long.class), Long.valueOf(DateUtil.unParseToDateFormat(param.getEndDate())))); + } + if (!StringUtil.isEmpty(param.getPointsName())) { + predicates.add(criteriaBuilder.equal(root.get("type").as(String.class), param.getPointsName().trim())); + } + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); + } + }, pageable); + + if(page.getContent()!=null&&page.getContent().size()>0){ + page.getContent().get(0).settPointsMain(tPointsMain); + } + return new PageResult<>(page); + } + + @Override + public PageResult getTPointsdetailByname(LevelBean param) { + Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize()); + return new PageResult<>(pointsDtlDao.findAllByUserid(param.getUserid(),pageable)); + } + + + + @Override + public LevelBean getConpoints() { + Sort sort = new Sort(Sort.Direction.ASC, "id"); + List monthlist = consumePointsDao.findAllByAndRuletype("month",sort); + List daylist = consumePointsDao.findAllByAndRuletype("day",sort); + List tDictionaries = dictionaryDao.findAllByDicttype("pointslimit"); + LevelBean levelBean = new LevelBean(); + if(tDictionaries!=null&&tDictionaries.size()>0){ + levelBean.setPointslimit(Integer.parseInt(tDictionaries.get(0).getDictval())); + } + if (!StringUtil.isEmpty(monthlist)) levelBean.setMonthList(monthlist); + if (!StringUtil.isEmpty(daylist)) levelBean.setDayList(daylist); + return levelBean; + } + + @Override + public JsonResult saveConpoints(LevelBean levelBean) { + List tDictionaries = dictionaryDao.findAllByDicttype("pointslimit"); + if(tDictionaries!=null&&tDictionaries.size()>0){ + tDictionaries.get(0).setDictval(levelBean.getPointslimit()+""); + dictionaryDao.save(tDictionaries.get(0)); + }else { + TDictionary tDictionary = new TDictionary(); + tDictionary.setDictcaption("积分中心的单日积分上限"); + tDictionary.setDicttype("pointslimit"); + tDictionary.setDicttypename("单日积分上限"); + tDictionary.setDictval(levelBean.getPointslimit()+""); + tDictionary.setTenantId("{tenantid}"); + dictionaryDao.save(tDictionary); + } + List consumePoints = levelBean.gettConsumePoints(); + consumePointsDao.saveAll(consumePoints); + return JsonResult.ok("成功"); + } + + @Override + public JsonResult deleteConpoints(TConsumePoints tConsumePoints) { + Optional ret = consumePointsDao.findById(tConsumePoints.getId()); + if (!ret.isPresent()) { + return JsonResult.error("消费规则不存在"); + } + if (tConsumePoints.getId() == 1) { + return JsonResult.error("该消费规则不能删除"); + } + consumePointsDao.deleteById(tConsumePoints.getId()); + return JsonResult.ok("成功"); + } + + @Override + public Boolean singleHandlePoints(String userid, Double amount,String billno) { + int rate = 1; + // 1.根据当天日期判断当天是否该用户的特殊日期或者生日,得到实际倍率 + TPerson person = personDao.findByUseridAndIdtype(userid,"idcard"); + if(person!=null&&!StringUtil.isEmpty(person.getIdno())){ + String nowDate = DateUtil.getNow("MMdd"); + String brithdate = person.getIdno().substring(10,4); + if(nowDate.equals(brithdate)){ + rate = 2; + } + } + //2. 查询用户的等级,获取单次消费获得积分的规则 + TPersonLevel personLevel; + Optional pointsMain = pointsMainDao.findById(userid); + if(pointsMain.orElse(null)!=null){ + Integer levelid = pointsMain.orElse(null).getLevelid(); + if(levelid!=null){ + personLevel = personLevelDao.getOne(levelid); + }else { + if(pointsMain.orElse(null).getPoints()==null){ + pointsMain.orElse(null).setPoints(0); + } + personLevel = personLevelDao.findTPersonLevelByPoints(pointsMain.orElse(null).getPoints()); + } + }else { + return false; + } + //3. 根据规则计算积分,得到的积分与当日积分上限进行比较,得到实际获得的积分 + int resultPoints = 0; + if(amount >= personLevel.getSingleConsumeAmount()){ + BigDecimal bigDecimal = new BigDecimal(amount); + BigDecimal result = bigDecimal.divide(new BigDecimal(personLevel.getSingleAmount()),0,BigDecimal.ROUND_DOWN); + int resultInt = result.intValue(); + //计算得到的积分 + resultPoints = resultInt * personLevel.getSinglePoints(); + //获得流水积分 + List tPointsdtls = pointsDtlDao.findAllByUseridAndTypeAndFlagstatus(userid,"","in"); + int allPoints = tPointsdtls.stream().mapToInt(o -> Integer.parseInt(o.getPoints())).sum(); + List tDictionaries = dictionaryDao.findAllByDicttype("pointslimit"); + int pointslimit = 0; + if(tDictionaries!=null&&tDictionaries.size()>0){ + pointslimit = Integer.parseInt(tDictionaries.get(0).getDictval()); + } + if(allPoints=pointslimit){ + resultPoints = pointslimit - allPoints; + } + } + } + //4. 对积分的主子表和流水表进行添加,查询用户的积分,得到的积分去查询等级表更新用户的等级 + insertDtl(userid, TradeDict.CONSUME_FLAG_SINGLE,resultPoints*rate,personLevel.getId(),billno); + return null; + } + + @Override + public Boolean dayHandlePoints(String userid,String billno) { + // 1.根据用户id查询积分流水表获得当日的消费金额 + List tPersondtl = persondtlDao.findAllByUseridAndTransdateAndReverseFlagAndStatus(userid, DateUtil.getNow("yyyyMMdd"),"none","success"); + Double allConsume = tPersondtl.stream().mapToDouble(o -> o.getAmount()).sum(); + // 2.循环日消费奖励规则 + Sort sort = new Sort(Sort.Direction.ASC, "id"); + List daylist = consumePointsDao.findAllByAndRuletype("day",sort); + for(TConsumePoints temp:daylist){ + // 3.判断用户是否达到日消费奖励积分的额度,达到再次判断是否获得过该规则的奖励 + if(allConsume>Double.parseDouble(temp.getConsumeamount())){ + TPointsdtl tPointsdtltemp = pointsDtlDao.findAllByUseridAndTransdateAndRefno(userid, DateUtil.getNow("yyyyMMdd"), temp.getId()); + if(tPointsdtltemp==null){ + // 4.奖励的积分对积分主子表和流水表进行添加 + insertDtl(userid, TradeDict.CONSUME_FLAG_DAY,temp.getPoints(),temp.getId(),billno); + } + } + } + return null; + } + + @Override + public Boolean monthHandlePoints(String userid,String billno) { + // 1.根据用户id查询积分流水表获得当月的消费金额 + List tPersondtl = persondtlDao.findAllByUseridAndTransdateStartingWithAndReverseFlagAndStatus(userid, DateUtil.getNow("yyyyMM"),"none","success"); + Double allConsume = tPersondtl.stream().mapToDouble(o -> o.getAmount()).sum(); + // 2.循环月消费奖励规则 + Sort sort = new Sort(Sort.Direction.ASC, "id"); + List monthlist = consumePointsDao.findAllByAndRuletype("month",sort); + for(TConsumePoints temp:monthlist){ + // 3.判断用户是否达到月消费奖励积分的额度,达到再次判断是否获得过该规则的奖励 + if(allConsume>Double.parseDouble(temp.getConsumeamount())){ + TPointsdtl tPointsdtltemp = pointsDtlDao.findAllByUseridAndTransdateAndRefno(userid, DateUtil.getNow("yyyyMMdd"), temp.getId()); + if(tPointsdtltemp==null){ + // 4.奖励的积分对积分主子表和流水表进行添加 + insertDtl(userid, TradeDict.CONSUME_FLAG_DAY,temp.getPoints(),temp.getId(),billno); + } + } + } + return null; + } + + public Boolean insertDtl(String userid,String type,int points,Integer refno,String billno){ + //主表流水 + TPointsMain tPointsMain; + Optional pointsMain = pointsMainDao.findById(userid); + if(pointsMain.orElse(null)!=null){ + tPointsMain = pointsMain.orElse(null); + tPointsMain.setPoints(tPointsMain.getPoints()+points); + tPointsMain.setAccumPoints(tPointsMain.getAccumPoints()+points); + TPersonLevel tPersonLevelByPoints = personLevelDao.findTPersonLevelByPoints(tPointsMain.getPoints()); + if(tPersonLevelByPoints.getId()>tPointsMain.getLevelid()){ + tPointsMain.setLevelid(tPersonLevelByPoints.getId()); + } + }else{ + tPointsMain = new TPointsMain(); + tPointsMain.setUserid(userid); + tPointsMain.setPoints(points); + tPointsMain.setAccumPoints(points); + TPersonLevel tPersonLevelByPoints = personLevelDao.findTPersonLevelByPoints(points); + tPointsMain.setLevelid(tPersonLevelByPoints.getId()); + } + tPointsMain.setUpdatetime(DateUtil.getNow()); + TPointsMain tPointsMainResult = pointsMainDao.save(tPointsMain); + //子表流水 + TPointsDetail tPointsDetail = new TPointsDetail(); + tPointsDetail.setUserid(userid); + tPointsDetail.setPoints(points); + List tDictionaries = dictionaryDao.findAllByDicttype("pointsdate"); + if(tDictionaries!=null&&tDictionaries.size()>0){ + String outdate = DateUtil.getNowInterDay(Integer.parseInt(tDictionaries.get(0).getDictval())); + tPointsDetail.setOutDate(outdate); + }else { + return false; + } + TPointsDetail tPointsDetailresult = pointsDetailDao.save(tPointsDetail); + //积分流水表信息 + TPointsdtl tPointsdtl = new TPointsdtl(); + tPointsdtl.setRefno(refno); + tPointsdtl.setType(type); + tPointsdtl.setUserid(userid); + tPointsdtl.setPoints("+"+points); + tPointsdtl.setStatus("init"); + tPointsdtl.setAftpoints(tPointsMainResult.getPoints()); + tPointsdtl.setBillno(billno); + tPointsdtl.setTransdate(DateUtil.getNow("yyyyMMdd")); + tPointsdtl.setTranstime(DateUtil.getNow("HHmmss")); + tPointsdtl.setDetailid(tPointsDetailresult.getDetailid()); + tPointsdtl.setFlagstatus("in"); + tPointsdtl.setMainstatus("init"); + TPointsdtl tPointsdtlresult = pointsDtlDao.save(tPointsdtl); + + tPointsDetail.setPointsdtlId(tPointsdtlresult.getId()); + pointsDetailDao.save(tPointsDetail); + return true; + } + + + + @Override + public PageResult getActiveList(LevelBean param) { + Pageable pageable = PageRequest.of(param.getPageNo() - 1, param.getPageSize(),Sort.by("id")); + Page page = pointsActiveDao.findAll(new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + if (!StringUtil.isEmpty(param.getName())) { + predicates.add(criteriaBuilder.like(root.get("name").as(String.class), "%" +param.getName().trim() + "%")); + } + if (!StringUtil.isEmpty(param.getType())) { + predicates.add(criteriaBuilder.equal(root.get("type").as(String.class), param.getType().trim())); + } + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); + } + }, pageable); + + return new PageResult<>(page); + } + + + @Override + public JsonResult deleteActive(TPointsActive tPointsActive) { + pointsActiveDao.deleteById(tPointsActive.getId()); + return JsonResult.ok("成功"); + } + + + @Override + public JsonResult saveActive(TPointsActive tPointsActive) { + if("no".equals(tPointsActive.getType())){ + tPointsActive.setWeeknumber(null); + tPointsActive.setStartdate(DateUtil.formatDateStr(tPointsActive.getStartdate(),"yyyyå¹´MM月dd日","yyyyMMdd")); + tPointsActive.setEnddate(DateUtil.formatDateStr(tPointsActive.getEnddate(),"yyyyå¹´MM月dd日","yyyyMMdd")); + } + if("year".equals(tPointsActive.getType())){ + tPointsActive.setWeeknumber(null); + tPointsActive.setStartdate(DateUtil.formatDateStr(tPointsActive.getYearStartDate(),"MM月dd日","MMdd")); + tPointsActive.setEnddate(DateUtil.formatDateStr(tPointsActive.getYearEndDate(),"MM月dd日","MMdd")); + } + pointsActiveDao.save(tPointsActive); + return JsonResult.ok("成功"); + } +} diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt index 5e431b77..3ba1de2f 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/impl/transaction_service_impl.kt @@ -424,6 +424,7 @@ class TransactionServiceImpl : TransactionService { originTrans.reverseFlag = TradeDict.REVERSE_FLAG_WIP originTrans.refundAmount = refundAmount transactionMainDao.save(originTrans) + //退款之后进行积分处理 return transaction } diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_service.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_service.kt index 861212a2..903a8026 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_service.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/service/transaction_service.kt @@ -5,6 +5,7 @@ import com.supwisdom.dlpay.api.TransactionBuilder import com.supwisdom.dlpay.api.domain.TTransactionMain import com.supwisdom.dlpay.exception.TransactionProcessException import com.supwisdom.dlpay.framework.util.TradeErrorCode +import com.supwisdom.dlpay.system.service.PointsService import org.springframework.beans.factory.annotation.Autowired import org.springframework.dao.DataAccessException import org.springframework.stereotype.Service @@ -66,6 +67,10 @@ class TransactionServiceProxy { @Autowired private lateinit var kafkaSendMsgService: KafkaSendMsgService + @Autowired + private lateinit var pointsService: PointsService + + fun init(builder: TransactionBuilder): TTransactionMain { try { @@ -102,6 +107,8 @@ class TransactionServiceProxy { if (it.person && !it.personDtl.userid.isNullOrEmpty()) { kafkaSendMsgService.sendJpushMessage(it.personDtl.userid, "交易提醒", "你有一笔${it.personDtl.amount}元的支出,点击查看详情", it.refno, mutableMapOf(), it.tenantid) } + //支付成功 进行积分处理 + } } @@ -137,4 +144,4 @@ class TransactionServiceProxy { } } -} \ No newline at end of file +} diff --git a/payapi/src/main/resources/templates/system/level/index.html b/payapi/src/main/resources/templates/system/level/index.html new file mode 100644 index 00000000..1766c081 --- /dev/null +++ b/payapi/src/main/resources/templates/system/level/index.html @@ -0,0 +1,718 @@ +
+ +
+
+
+
+ + +
+
+ +
1级会员设置:
+
+ 会员名称为 + ,累计积分为 + --- + 分。 + +
订单实付金额满 + 元时,每消费 + 元,可获得 + 积分; +
+
+
+
+
+
积分到期设置
+
每隔 + 日,清除积分。(不影响历史积分,从修改当日起生效。)
+
+
+
+
+
+
+
+
+ +
+
日累积消费积分设置 + +
+
+
+
当日累计消费金额满 + 元时,可额外获得 + 积分; + +
+
+
单日消费积分上限 + 积分。 +
+
+
+
+
月累积消费积分设置 + +
+
+
+
当月累计消费金额满 + 元时,可额外获得 + 积分; + +
+
+
+
+
+
+
+
+ diff --git a/payapi/src/main/resources/templates/system/level/pointsactiveadd.html b/payapi/src/main/resources/templates/system/level/pointsactiveadd.html new file mode 100644 index 00000000..16eed53d --- /dev/null +++ b/payapi/src/main/resources/templates/system/level/pointsactiveadd.html @@ -0,0 +1,209 @@ + +
+ +
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ + diff --git a/payapi/src/main/resources/templates/system/level/pointsactiveindex.html b/payapi/src/main/resources/templates/system/level/pointsactiveindex.html new file mode 100644 index 00000000..88d7d544 --- /dev/null +++ b/payapi/src/main/resources/templates/system/level/pointsactiveindex.html @@ -0,0 +1,177 @@ +
+
+

活动日管理

+ + 积分中心 + 活动日管理 + +
+
+
+ 活动日名称: +   +
+ 循环方式: + +
+ + +
+ +
+
+
+
+
+ + + diff --git a/payapi/src/main/resources/templates/system/level/pointsdetail.html b/payapi/src/main/resources/templates/system/level/pointsdetail.html new file mode 100644 index 00000000..29d326f2 --- /dev/null +++ b/payapi/src/main/resources/templates/system/level/pointsdetail.html @@ -0,0 +1,42 @@ +
+ diff --git a/payapi/src/main/resources/templates/system/level/taskadd.html b/payapi/src/main/resources/templates/system/level/taskadd.html new file mode 100644 index 00000000..e5e059ca --- /dev/null +++ b/payapi/src/main/resources/templates/system/level/taskadd.html @@ -0,0 +1,82 @@ + +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+