From aa5e71b065c696f3653e9fa5461f1a01e4960831 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Wed, 27 Dec 2023 10:28:18 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/mapper/WxUserScriptLogMapper.java | 4 ++ .../mapper/WxUserScriptLogMapper.xml | 24 +++++++- .../controller/WxUserScriptLogController.java | 55 +++++++++++++++++++ .../service/IWxUserScriptLogService.java | 14 +++++ .../impl/WxUserScriptLogServiceImpl.java | 53 ++++++++++++++++++ 5 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxUserScriptLogController.java create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxUserScriptLogService.java create mode 100644 flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserScriptLogServiceImpl.java diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java index 1843563..3e31263 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxUserScriptLogMapper.java @@ -62,4 +62,8 @@ public interface WxUserScriptLogMapper { public int deleteWxUserScriptLogByIds(Long[] ids); void deleteWxUserScriptLogByWxUserId(@Param("userId") Long userId); + + Integer getNoReadMessageNum(WxUserScriptLog query); + + void hasBeenRead(WxUserScriptLog query); } diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml index e57d80d..b83b2d8 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserScriptLogMapper.xml @@ -56,13 +56,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and tag_ids = #{tagIds} and status = #{status} + order by create_time desc - + + + insert into wx_user_script_log @@ -141,6 +151,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update wx_user_script_log set + `is_read` = 1 + + and wx_user_id = #{wxUserId} + and is_read = #{isRead} + and status = #{status} + + + delete from wx_user_script_log where id = #{id} @@ -154,4 +174,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from wx_user_script_log where wx_user_id = #{userId} + + \ No newline at end of file diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxUserScriptLogController.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxUserScriptLogController.java new file mode 100644 index 0000000..bbc1d67 --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxUserScriptLogController.java @@ -0,0 +1,55 @@ +package com.flossom.miniProgram.controller; + +import com.flossom.common.core.domain.R; +import com.flossom.common.core.domain.entity.WxUserScriptLog; +import com.flossom.common.core.web.controller.BaseController; +import com.flossom.common.core.web.page.TableDataInfo; +import com.flossom.miniProgram.service.IWxUserScriptLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 发送话术记录Controller + * + * @author flossom + * @date 2023-12-20 + */ +@RestController +@RequestMapping("/userScriptLog") +public class WxUserScriptLogController extends BaseController { + + @Autowired + private IWxUserScriptLogService wxUserScriptLogService; + + + /** + * 查询发送话术记录列表 + */ + @GetMapping("/list") + public TableDataInfo list() { + startPage(); + List list = wxUserScriptLogService.selectWxUserScriptLogList(); + return getDataTable(list); + } + + /** + * 查询是否有没未读消息 + */ + @GetMapping("getNoReadMessageNum") + public R getNoReadMessageNum() { + return R.ok(wxUserScriptLogService.getNoReadMessageNum()); + } + + /** + * 触发所有已读 + */ + @GetMapping("/hasBeenRead") + public R hasBeenRead() { + wxUserScriptLogService.hasBeenRead(); + return R.ok(); + } + + +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxUserScriptLogService.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxUserScriptLogService.java new file mode 100644 index 0000000..e3fd68f --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxUserScriptLogService.java @@ -0,0 +1,14 @@ +package com.flossom.miniProgram.service; + +import com.flossom.common.core.domain.entity.WxUserScriptLog; + +import java.util.List; + +public interface IWxUserScriptLogService { + List selectWxUserScriptLogList(); + + Integer getNoReadMessageNum(); + + void hasBeenRead(); + +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserScriptLogServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserScriptLogServiceImpl.java new file mode 100644 index 0000000..8c84254 --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxUserScriptLogServiceImpl.java @@ -0,0 +1,53 @@ +package com.flossom.miniProgram.service.impl; + +import com.flossom.common.core.domain.entity.WxUserScriptLog; +import com.flossom.common.core.enums.Status; +import com.flossom.common.core.mapper.WxUserScriptLogMapper; +import com.flossom.common.security.utils.SecurityUtils; +import com.flossom.miniProgram.service.IWxUserScriptLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service +public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService { + + @Autowired + private WxUserScriptLogMapper wxUserScriptLogMapper; + + @Override + public List selectWxUserScriptLogList() { + WxUserScriptLog query = new WxUserScriptLog(); + // 消息归属人 + query.setWxUserId(SecurityUtils.getWxUserId()); + // 消息状态正常 + query.setStatus(Status.OK.getCode()); + return wxUserScriptLogMapper.selectWxUserScriptLogList(query); + } + + @Override + public Integer getNoReadMessageNum() { + WxUserScriptLog query = new WxUserScriptLog(); + // 消息归属人 + query.setWxUserId(SecurityUtils.getWxUserId()); + // 消息状态正常 + query.setStatus(Status.OK.getCode()); + // 未读 + query.setIsRead(0); + return wxUserScriptLogMapper.getNoReadMessageNum(query); + } + + @Override + public void hasBeenRead() { + WxUserScriptLog query = new WxUserScriptLog(); + // 消息归属人 + query.setWxUserId(20L); + // 消息状态正常 + query.setStatus(Status.OK.getCode()); + // 未读 + query.setIsRead(0); + wxUserScriptLogMapper.hasBeenRead(query); + } +} From 28f97a96ee7a8b2d7da2777348049862b3c93d41 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Wed, 27 Dec 2023 10:59:42 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=87=E6=9C=9F=E7=A7=AF=E5=88=86=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/entity/WxUserMember.java | 17 ++++++++++++++++- .../resources/mapper/WxUserMemberMapper.xml | 9 +++++++-- .../miniProgram/domain/vo/LoginUserVo.java | 18 +++++++++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserMember.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserMember.java index 3539560..74c3c12 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserMember.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/entity/WxUserMember.java @@ -44,6 +44,12 @@ public class WxUserMember extends BaseEntity { @Excel(name = "积分") private Integer credit; + /** + * 即将过期积分 + */ + @Excel(name = "即将过期积分") + private Integer expireCredit; + /** * openid */ @@ -367,15 +373,24 @@ public class WxUserMember extends BaseEntity { this.devicesNum = devicesNum; } + public Integer getExpireCredit() { + return expireCredit; + } + + public void setExpireCredit(Integer expireCredit) { + this.expireCredit = expireCredit; + } + public WxUserMember() { } - public WxUserMember(Long id, String nickname, String headimg, String username, Integer credit, String openid, String unionid, Integer userType, Integer level, String mobile, Long provinceId, String province, Long cityId, String city, Long areaId, String area, Date birthday, Integer clock, Integer activity, String wechat, Integer isAbutment, Integer isCompleteInformation, Integer devicesNum, Date loginTime, Integer status) { + public WxUserMember(Long id, String nickname, String headimg, String username, Integer credit, Integer expireCredit, String openid, String unionid, Integer userType, Integer level, String mobile, Long provinceId, String province, Long cityId, String city, Long areaId, String area, Date birthday, Integer clock, Integer activity, String wechat, Integer isAbutment, Integer isCompleteInformation, Integer devicesNum, Date loginTime, Integer status) { this.id = id; this.nickname = nickname; this.headimg = headimg; this.username = username; this.credit = credit; + this.expireCredit = expireCredit; this.openid = openid; this.unionid = unionid; this.userType = userType; diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserMemberMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserMemberMapper.xml index 0b6db33..a932c1c 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserMemberMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserMemberMapper.xml @@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -38,11 +39,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, nickname, headimg, username, credit, openid, unionid, user_type, level, mobile, province_id, city_id, area_id, province, city, area, birthday, clock, activity, wechat, is_abutment, login_time, is_complete_information, devices_num, status, create_by, create_time, update_by, update_time, remark from wx_user_member + select id, nickname, headimg, username, credit, expire_credit, openid, unionid, user_type, level, mobile, province_id, city_id, area_id, province, city, area, birthday, clock, activity, wechat, is_abutment, login_time, is_complete_information, devices_num, status, create_by, create_time, update_by, update_time, remark from wx_user_member - member.id, member.nickname, member.headimg, member.username, member.credit, member.openid, member.unionid, member.user_type, member.level, member.mobile, + member.id, member.nickname, member.headimg, member.username, member.credit, member.expire_credit, member.openid, member.unionid, member.user_type, member.level, member.mobile, member.province_id, member.city_id, member.area_id, member.province, member.city, member.area, member.birthday, member.clock, member.activity, member.wechat, member.is_abutment, member.login_time, member.is_complete_information, member.devices_num, member.status, member.create_by, member.create_time, member.update_by, member.update_time, member.remark @@ -56,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and headimg = #{headimg} and username like concat('%', #{username}, '%') and credit = #{credit} + and expire_credit = #{expireCredit} and openid = #{openid} and unionid = #{unionid} and user_type = #{userType} @@ -158,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" headimg, username, credit, + expire_credit, openid, unionid, user_type, @@ -189,6 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{headimg}, #{username}, #{credit}, + #{expireCredit}, #{openid}, #{unionid}, #{userType}, @@ -224,6 +228,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" headimg = #{headimg}, username = #{username}, credit = #{credit}, + expire_credit = #{expireCredit}, openid = #{openid}, unionid = #{unionid}, user_type = #{userType}, diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/LoginUserVo.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/LoginUserVo.java index 2233fe2..c6c7faf 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/LoginUserVo.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/domain/vo/LoginUserVo.java @@ -36,6 +36,12 @@ public class LoginUserVo { @Excel(name = "积分") private Integer credit; + /** + * 即将过期积分 + */ + @Excel(name = "即将过期积分") + private Integer expireCredit; + /** * 手机 */ @@ -96,12 +102,13 @@ public class LoginUserVo { public LoginUserVo() { } - public LoginUserVo(Long id, String nickname, String headimg, String username, Integer credit, String mobile, Long provinceId, String province, Long cityId, String city, Long areaId, String area, Date birthday, String token) { + public LoginUserVo(Long id, String nickname, String headimg, String username, Integer credit, Integer expireCredit, String mobile, Long provinceId, String province, Long cityId, String city, Long areaId, String area, Date birthday, String token, String integralText) { this.id = id; this.nickname = nickname; this.headimg = headimg; this.username = username; this.credit = credit; + this.expireCredit = expireCredit; this.mobile = mobile; this.provinceId = provinceId; this.province = province; @@ -111,6 +118,7 @@ public class LoginUserVo { this.area = area; this.birthday = birthday; this.token = token; + this.integralText = integralText; } public Long getId() { @@ -232,4 +240,12 @@ public class LoginUserVo { public void setIntegralText(String integralText) { this.integralText = integralText; } + + public Integer getExpireCredit() { + return expireCredit; + } + + public void setExpireCredit(Integer expireCredit) { + this.expireCredit = expireCredit; + } } From 392687454701162a053957d72579cbb3897bfd63 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Wed, 27 Dec 2023 14:11:33 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/WxUserIntegralLogMapper.xml | 3 + .../WxUserIntegralLogController.java | 42 +++++----- .../service/IWxUserIntegralLogService.java | 3 + .../impl/WxUserIntegralLogServiceImpl.java | 82 +++++++++++++++---- 4 files changed, 93 insertions(+), 37 deletions(-) diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserIntegralLogMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserIntegralLogMapper.xml index 81ff59f..088eb9c 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserIntegralLogMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxUserIntegralLogMapper.xml @@ -31,6 +31,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and float_score = #{floatScore} and soure_id = #{soureId} and remark_content = #{remarkContent} + + and create_time <= #{createTime} + diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserIntegralLogController.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserIntegralLogController.java index 6f6486c..3eda269 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserIntegralLogController.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/controller/WxUserIntegralLogController.java @@ -4,6 +4,7 @@ import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.flossom.common.core.domain.R; import com.flossom.common.core.domain.entity.WxUserIntegralLog; import com.flossom.common.core.utils.poi.ExcelUtil; import com.flossom.common.core.web.controller.BaseController; @@ -13,14 +14,7 @@ import com.flossom.common.log.annotation.Log; import com.flossom.common.log.enums.BusinessType; import com.flossom.common.security.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.flossom.system.service.IWxUserIntegralLogService; /** @@ -31,8 +25,7 @@ import com.flossom.system.service.IWxUserIntegralLogService; */ @RestController @RequestMapping("/integralLog") -public class WxUserIntegralLogController extends BaseController -{ +public class WxUserIntegralLogController extends BaseController { @Autowired private IWxUserIntegralLogService wxUserIntegralLogService; @@ -41,8 +34,7 @@ public class WxUserIntegralLogController extends BaseController */ @RequiresPermissions("system:integralLog:list") @GetMapping("/list") - public TableDataInfo list(WxUserIntegralLog wxUserIntegralLog) - { + public TableDataInfo list(WxUserIntegralLog wxUserIntegralLog) { startPage(); List list = wxUserIntegralLogService.selectWxUserIntegralLogList(wxUserIntegralLog); return getDataTable(list); @@ -54,8 +46,7 @@ public class WxUserIntegralLogController extends BaseController @RequiresPermissions("system:integralLog:export") @Log(title = "微信用户积分流水", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, WxUserIntegralLog wxUserIntegralLog) - { + public void export(HttpServletResponse response, WxUserIntegralLog wxUserIntegralLog) { List list = wxUserIntegralLogService.selectWxUserIntegralLogList(wxUserIntegralLog); ExcelUtil util = new ExcelUtil(WxUserIntegralLog.class); util.exportExcel(response, list, "微信用户积分流水数据"); @@ -66,8 +57,7 @@ public class WxUserIntegralLogController extends BaseController */ @RequiresPermissions("system:integralLog:query") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(wxUserIntegralLogService.selectWxUserIntegralLogById(id)); } @@ -77,8 +67,7 @@ public class WxUserIntegralLogController extends BaseController @RequiresPermissions("system:integralLog:add") @Log(title = "微信用户积分流水", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody WxUserIntegralLog wxUserIntegralLog) - { + public AjaxResult add(@RequestBody WxUserIntegralLog wxUserIntegralLog) { return toAjax(wxUserIntegralLogService.insertWxUserIntegralLog(wxUserIntegralLog)); } @@ -88,8 +77,7 @@ public class WxUserIntegralLogController extends BaseController @RequiresPermissions("system:integralLog:edit") @Log(title = "微信用户积分流水", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody WxUserIntegralLog wxUserIntegralLog) - { + public AjaxResult edit(@RequestBody WxUserIntegralLog wxUserIntegralLog) { return toAjax(wxUserIntegralLogService.updateWxUserIntegralLog(wxUserIntegralLog)); } @@ -98,9 +86,17 @@ public class WxUserIntegralLogController extends BaseController */ @RequiresPermissions("system:integralLog:remove") @Log(title = "微信用户积分流水", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(wxUserIntegralLogService.deleteWxUserIntegralLogByIds(ids)); } + + /** + * 计算所有用户得过期积分 + */ + @GetMapping("/countUserExpireIntegral") + public R countUserExpireIntegral(@RequestParam(required = false, value = "idList") List idList) { + wxUserIntegralLogService.countUserExpireIntegral(idList); + return R.ok(); + } } diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserIntegralLogService.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserIntegralLogService.java index 1198613..9a35411 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserIntegralLogService.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/IWxUserIntegralLogService.java @@ -59,4 +59,7 @@ public interface IWxUserIntegralLogService * @return 结果 */ public int deleteWxUserIntegralLogById(Long id); + + void countUserExpireIntegral(List idList); + } diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserIntegralLogServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserIntegralLogServiceImpl.java index f490869..b3be038 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserIntegralLogServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserIntegralLogServiceImpl.java @@ -1,10 +1,20 @@ package com.flossom.system.service.impl; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.temporal.TemporalAdjusters; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import com.flossom.common.core.domain.entity.WxUserIntegralLog; +import com.flossom.common.core.domain.entity.WxUserMember; +import com.flossom.common.core.enums.Status; import com.flossom.common.core.mapper.WxUserIntegralLogMapper; +import com.flossom.common.core.mapper.WxUserMemberMapper; import com.flossom.common.core.utils.DateUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.flossom.system.service.IWxUserIntegralLogService; @@ -16,11 +26,13 @@ import com.flossom.system.service.IWxUserIntegralLogService; * @date 2023-12-14 */ @Service -public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService -{ +public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService { @Autowired private WxUserIntegralLogMapper wxUserIntegralLogMapper; + @Autowired + private WxUserMemberMapper wxUserMemberMapper; + /** * 查询微信用户积分流水 * @@ -28,8 +40,7 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 微信用户积分流水 */ @Override - public WxUserIntegralLog selectWxUserIntegralLogById(Long id) - { + public WxUserIntegralLog selectWxUserIntegralLogById(Long id) { return wxUserIntegralLogMapper.selectWxUserIntegralLogById(id); } @@ -40,8 +51,7 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 微信用户积分流水 */ @Override - public List selectWxUserIntegralLogList(WxUserIntegralLog wxUserIntegralLog) - { + public List selectWxUserIntegralLogList(WxUserIntegralLog wxUserIntegralLog) { return wxUserIntegralLogMapper.selectWxUserIntegralLogList(wxUserIntegralLog); } @@ -52,8 +62,7 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 结果 */ @Override - public int insertWxUserIntegralLog(WxUserIntegralLog wxUserIntegralLog) - { + public int insertWxUserIntegralLog(WxUserIntegralLog wxUserIntegralLog) { wxUserIntegralLog.setCreateTime(DateUtils.getNowDate()); return wxUserIntegralLogMapper.insertWxUserIntegralLog(wxUserIntegralLog); } @@ -65,8 +74,7 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 结果 */ @Override - public int updateWxUserIntegralLog(WxUserIntegralLog wxUserIntegralLog) - { + public int updateWxUserIntegralLog(WxUserIntegralLog wxUserIntegralLog) { return wxUserIntegralLogMapper.updateWxUserIntegralLog(wxUserIntegralLog); } @@ -77,8 +85,7 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 结果 */ @Override - public int deleteWxUserIntegralLogByIds(Long[] ids) - { + public int deleteWxUserIntegralLogByIds(Long[] ids) { return wxUserIntegralLogMapper.deleteWxUserIntegralLogByIds(ids); } @@ -89,8 +96,55 @@ public class WxUserIntegralLogServiceImpl implements IWxUserIntegralLogService * @return 结果 */ @Override - public int deleteWxUserIntegralLogById(Long id) - { + public int deleteWxUserIntegralLogById(Long id) { return wxUserIntegralLogMapper.deleteWxUserIntegralLogById(id); } + + @Override + public void countUserExpireIntegral(List idList) { + // 1、获取所有用户 + List wxUserMembers = new ArrayList<>(); + if (idList != null && idList.size() > 0) { + for (Long aLong : idList) { + WxUserMember wxUserMember = wxUserMemberMapper.selectWxUserMemberById(aLong); + if (wxUserMember != null) { + wxUserMembers.add(wxUserMember); + } + } + } else { + WxUserMember wxUserMember = new WxUserMember(); + wxUserMember.setUserType(1); // 会员 + wxUserMember.setStatus(Status.OK.getCode()); + wxUserMembers = wxUserMemberMapper.selectWxUserMemberList(wxUserMember); + } + + for (WxUserMember userMember : wxUserMembers) { + WxUserIntegralLog query = new WxUserIntegralLog(); + query.setUserId(userMember.getId()); + // 2、根据用户id获取用户的历史积分记录 + // 增加: 时间为 当前时间上一年的最后一天的最后一刻 + LocalDateTime queryTime = LocalDateTime.now().minusYears(1).with(TemporalAdjusters.lastDayOfYear()).with(LocalTime.MAX); + query.setCreateTime(Date.from(queryTime.atZone(ZoneId.systemDefault()).toInstant())); + List increaseUserIntegralLogList = wxUserIntegralLogMapper.selectWxUserIntegralLogList(query); + Long increaseIntegral = increaseUserIntegralLogList.stream().filter(wxUserIntegralLog -> + StringUtils.equals(wxUserIntegralLog.getSource(), "1") + ).mapToLong(WxUserIntegralLog::getFloatScore).sum(); + + // 扣减: 时间为当前 + query.setCreateTime(null); + List reduceUserIntegralLogList = wxUserIntegralLogMapper.selectWxUserIntegralLogList(query); + Long reduceIntegral = reduceUserIntegralLogList.stream().filter(wxUserIntegralLog -> + StringUtils.equals(wxUserIntegralLog.getSource(), "2") + ).mapToLong(WxUserIntegralLog::getFloatScore).sum(); + + // 3、计算该用户得过期积分,并保存到用户信息表得过期积分中 + // 当增加的大于扣除的就直接扣减 + if (increaseIntegral > reduceIntegral) { + userMember.setExpireCredit(increaseIntegral.intValue() - reduceIntegral.intValue()); + } else { + userMember.setExpireCredit(0); + } + wxUserMemberMapper.updateWxUserMember(userMember); + } + } } From e815e5ac1bf2261c9a4303bffc5e5b77ec33ab01 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Wed, 27 Dec 2023 14:29:52 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxUserScriptLogServiceImpl.java | 10 +++++++++- flossom-ui/src/views/system/member/index.vue | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java index 68eec75..0204b35 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserScriptLogServiceImpl.java @@ -56,7 +56,15 @@ public class WxUserScriptLogServiceImpl implements IWxUserScriptLogService { */ @Override public List selectWxUserScriptLogList(WxUserScriptLog wxUserScriptLog) { - return wxUserScriptLogMapper.selectWxUserScriptLogList(wxUserScriptLog); + List wxUserScriptLogs = wxUserScriptLogMapper.selectWxUserScriptLogList(wxUserScriptLog); + for (WxUserScriptLog userScriptLog : wxUserScriptLogs) { + if (userScriptLog.getIsCustom() == 0 && userScriptLog.getScriptTemplateId() != null) { + WxScriptTemplate wxScriptTemplate = wxScriptTemplateMapper.selectWxScriptTemplateById(userScriptLog.getScriptTemplateId().longValue()); + userScriptLog.setContent(wxScriptTemplate.getContent()); + userScriptLog.setTitile(wxScriptTemplate.getTitile()); + } + } + return wxUserScriptLogs; } /** diff --git a/flossom-ui/src/views/system/member/index.vue b/flossom-ui/src/views/system/member/index.vue index 27dc3fe..0f5533d 100644 --- a/flossom-ui/src/views/system/member/index.vue +++ b/flossom-ui/src/views/system/member/index.vue @@ -240,7 +240,7 @@ - + @@ -650,7 +705,6 @@ import { listMember, getMember, delMember, - addMember, updateMember, selectUserCount, getMiniProgramTags, @@ -671,6 +725,7 @@ import { scriptTreeSelect, editRemark, delRemark, openOrCloseClock, openOrCloseActivity, uObtainUserScriptLog, delUserScriptLog, obtainUserIntegralLog, + allExport, batchExport, } from "@/api/system/member"; import Treeselect from "@riophae/vue-treeselect"; import {tagTreeSelect} from "@/api/system/wechatTab"; @@ -681,23 +736,6 @@ export default { components: {Treeselect}, data() { return { - tableData: [{ - date: '2016-05-02', - name: '王小虎', - address: '上海市普陀区金沙江路 1518 弄' - }, { - date: '2016-05-04', - name: '王小虎', - address: '上海市普陀区金沙江路 1517 弄' - }, { - date: '2016-05-01', - name: '王小虎', - address: '上海市普陀区金沙江路 1519 弄' - }, { - date: '2016-05-03', - name: '王小虎', - address: '上海市普陀区金沙江路 1516 弄' - }], // 遮罩层 loading: true, // 选中数组 @@ -811,6 +849,31 @@ export default { orderByColumn: "createTime", isAsc: "desc" }, + // 导出数据选择字段 + exportFieldsVisible: false, + exportFieldsForm: { + userIdList: null, + exportFields: null, + }, + allFields: false, + exportFieldList: { + id: null, + nickname: null, + credit: null, + expireCredit: null, + unionid: null, + mobile: null, + province: null, + city: null, + area: null, + birthday: null, + devicesNum: null, + devicesName: null, + createTime: null, + wecomTags: null, + miniProgramTags: null, + + }, // 查询参数 queryParams: { pageNum: 1, @@ -941,26 +1004,20 @@ export default { this.reset(); }, // 关闭添加小程序标签窗口 - cancelMiniProgramDialog(isclose) { + cancelMiniProgramDialog() { this.title = null; this.tagIdArray = []; - if (isclose) { - this.batchMiniProgramVisible = false; - } + this.batchMiniProgramVisible = false; }, - cancelIntegralDialog(isclose) { + cancelIntegralDialog() { this.integralForm.source = null; this.integralForm.floatScore = null; this.integralForm.remarkContent = "后台操作"; - if (isclose) { - this.batchIntegralVisible = false; - } + this.batchIntegralVisible = false; }, - cancelRemarkDialog(isclose) { + cancelRemarkDialog() { this.remarkForm.content = null; - if (isclose) { - this.batchRemarkVisible = false; - } + this.batchRemarkVisible = false; }, cancelUserScriptLogDialog() { this.userScriptLogVisible = false; @@ -978,7 +1035,26 @@ export default { this.userIntegralLogQuery.userId = null; this.userIntegralLogQuery.userIntegralLogList = null; }, - cancelscriptDialog(isclose) { + cancelExportFieldsDialog() { + this.allFields = false; + this.exportFieldList.nickname = null; + this.exportFieldList.id = null; + this.exportFieldList.credit = null; + this.exportFieldList.expireCredit = null; + this.exportFieldList.unionid = null; + this.exportFieldList.mobile = null; + this.exportFieldList.province = null; + this.exportFieldList.city = null; + this.exportFieldList.area = null; + this.exportFieldList.birthday = null; + this.exportFieldList.devicesNum = null; + this.exportFieldList.devicesName = null; + this.exportFieldList.createTime = null; + this.exportFieldList.wecomTags = null; + this.exportFieldList.miniProgramTags = null; + this.exportFieldsVisible = false + }, + cancelscriptDialog() { this.scriptForm.isCustom = null; this.scriptForm.scriptName = null; this.scriptForm.titile = null; @@ -997,9 +1073,7 @@ export default { this.tagIdArray = []; this.scriptForm.scriptTemplateId = null; this.scriptForm.scriptContent = null; - if (isclose) { - this.batchScriptVisible = false; - } + this.batchScriptVisible = false; }, /** 查询部门下拉树结构 */ getDeptTree() { @@ -1213,9 +1287,11 @@ export default { }) return } + this.exportFieldsVisible = true; } if (this.batchOperateValue == 13) { console.log("导出全量数据"); + this.exportFieldsVisible = true; } } }, @@ -1413,6 +1489,32 @@ export default { this.cancelRemarkDialog(true); }) } + + // 导出用户数据 + if (this.batchOperateValue == 12) { + let exportFields = Object.values(this.exportFieldList).filter(val => val != null); + if (exportFields.length == 0) { + this.$modal.msgError("请选择导出字段"); + return; + } + this.exportFieldsForm.userIdList = this.ids; + this.exportFieldsForm.exportFields = exportFields; + this.download('/system/member/batchExport', { + ...this.exportFieldsForm + }, `微信会员_${new Date().getTime()}.xlsx`); + this.cancelExportFieldsDialog(); + } + if (this.batchOperateValue == 13) { + let exportFields = Object.values(this.exportFieldList).filter(val => val != null); + if (exportFields.length == 0) { + this.$modal.msgError("请选择导出字段"); + return; + } + this.download('/system/member/allExport', { + ...Object.assign({}, this.queryParams, {exportFields: exportFields}) + }, `微信会员_${new Date().getTime()}.xlsx`) + this.cancelExportFieldsDialog(); + } }, // 打开用户备注修改 ocEditRemarkDialog(row) { @@ -1518,8 +1620,52 @@ export default { this.userIntegralLogQuery.orderByColumn = prop; this.userIntegralLogQuery.isAsc = column.order == 'ascending' ? 'asc' : 'desc'; this.getUserIntegralLogList(); + }, + isExportAllFields() { + if (this.allFields) { + this.exportFieldList.nickname = "nickname"; + this.exportFieldList.id = "id"; + this.exportFieldList.credit = "credit"; + this.exportFieldList.expireCredit = "expireCredit"; + this.exportFieldList.unionid = "unionid"; + this.exportFieldList.mobile = "mobile"; + this.exportFieldList.province = "province"; + this.exportFieldList.city = "city"; + this.exportFieldList.area = "area"; + this.exportFieldList.birthday = "birthday"; + this.exportFieldList.devicesNum = "devicesNum"; + this.exportFieldList.devicesName = "devicesName"; + this.exportFieldList.createTime = "createTime"; + this.exportFieldList.wecomTags = "wecomTags"; + this.exportFieldList.miniProgramTags = "miniProgramTags"; + } else { + this.exportFieldList.nickname = null; + this.exportFieldList.id = null; + this.exportFieldList.credit = null; + this.exportFieldList.expireCredit = null; + this.exportFieldList.unionid = null; + this.exportFieldList.mobile = null; + this.exportFieldList.province = null; + this.exportFieldList.city = null; + this.exportFieldList.area = null; + this.exportFieldList.birthday = null; + this.exportFieldList.devicesNum = null; + this.exportFieldList.devicesName = null; + this.exportFieldList.createTime = null; + this.exportFieldList.wecomTags = null; + this.exportFieldList.miniProgramTags = null; + } + }, + exportArea() { + if (this.exportFieldList.province != null) { + this.exportFieldList.city = "city"; + this.exportFieldList.area = "area"; + } else { + this.exportFieldList.city = null; + this.exportFieldList.area = null; + } } - } + }, } ; From 244c36ea7b11ac896ff2b60695f5db37795a1c58 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Thu, 28 Dec 2023 14:43:26 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E5=A2=9E=E5=8A=A0=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flossom-ui/src/views/system/member/index.vue | 86 +++++++++++--------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/flossom-ui/src/views/system/member/index.vue b/flossom-ui/src/views/system/member/index.vue index 86b7799..b760a25 100644 --- a/flossom-ui/src/views/system/member/index.vue +++ b/flossom-ui/src/views/system/member/index.vue @@ -1,6 +1,6 @@