Commit c74a26ab by YG8429

添加自动添加权益金定时任务

parent 2f739f6e
package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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 share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.EquityFundExcess;
import share.system.domain.vo.EquityFundExcessVo;
import share.system.service.EquityFundExcessService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
/**
* 权益金过度Controller
*
* @author wuwenlong
* @date 2024-09-20
*/
@RestController
@RequestMapping("/system/equityFundExcess")
public class EquityFundExcessController extends BaseController
{
@Autowired
private EquityFundExcessService equityFundExcessService;
/**
* 查询权益金过度列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:list')")
@GetMapping("/list")
public TableDataInfo list(EquityFundExcessVo equityFundExcess)
{
startPage();
List<EquityFundExcess> list = equityFundExcessService.selectEquityFundExcessList(equityFundExcess);
TableDataInfo dataTable = getDataTable(list);
return equityFundExcessService.pageList(dataTable,equityFundExcess);
}
/**
* 导出权益金过度列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:export')")
@Log(title = "权益金过度", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquityFundExcess equityFundExcess)
{
List<EquityFundExcess> list = equityFundExcessService.selectEquityFundExcessList(equityFundExcess);
ExcelUtil<EquityFundExcess> util = new ExcelUtil<EquityFundExcess>(EquityFundExcess.class);
util.exportExcel(response, list, "权益金过度数据");
}
/**
* 获取权益金过度详细信息
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(equityFundExcessService.selectEquityFundExcessById(id));
}
/**
* 新增权益金过度
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:add')")
@Log(title = "权益金过度", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquityFundExcess equityFundExcess)
{
return toAjax(equityFundExcessService.insertEquityFundExcess(equityFundExcess));
}
/**
* 修改权益金过度
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:edit')")
@Log(title = "权益金过度", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquityFundExcess equityFundExcess)
{
return toAjax(equityFundExcessService.updateEquityFundExcess(equityFundExcess));
}
/**
* 删除权益金过度
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:remove')")
@Log(title = "权益金过度", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(equityFundExcessService.deleteEquityFundExcessByIds(ids));
}
}
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.EquityFundExcess;
import share.system.domain.vo.EquityFundExcessVo;
import share.system.service.EquityFundExcessService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 权益金过度Controller
*
* @author wuwenlong
* @date 2024-09-20
*/
@RestController
@RequestMapping("/equityFundExcess")
public class EquityFundExcessController extends BaseController
{
@Autowired
private EquityFundExcessService equityFundExcessService;
/**
* 查询权益金过度列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundExcess:list')")
@GetMapping("/list")
public TableDataInfo list(EquityFundExcessVo equityFundExcess)
{
startPage();
List<EquityFundExcess> list = equityFundExcessService.selectEquityFundExcessList(equityFundExcess);
TableDataInfo dataTable = getDataTable(list);
return equityFundExcessService.pageList(dataTable,equityFundExcess);
}
}
......@@ -123,6 +123,9 @@ public class RedisTask {
@Autowired
private DurationLogService durationLogService;
@Autowired
private EquityFundExcessService equityFundExcessService;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
......@@ -254,6 +257,7 @@ public class RedisTask {
if (!tiktok) {
tiktokService.clientToken();
}
wechatNewService.getMiniAccessToken();
wechatNewService.getPublicAccessToken();
logger.debug("AutomaticMtSessionKey:自动续期session结束");
}
......@@ -361,17 +365,18 @@ public class RedisTask {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
//添加时长
BigDecimal anHour = new BigDecimal(1.0);
BigDecimal accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getAccumulateEquityFund()) ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
BigDecimal accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getRemainingDuration()) ? consumerWallet.getRemainingDuration() : BigDecimal.ZERO;
consumerWallet.setRemainingDuration(accumulateEquityFund.add(anHour));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet);
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setVariableDuration(anHour);
durationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
durationLog.setCurrentDuration(accumulateEquityFund);
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(durationLog);
consumerWalletService.updateConsumerWallet(consumerWallet);
} else {
//新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet();
......@@ -401,6 +406,7 @@ public class RedisTask {
LambdaQueryWrapper<ConsumerMember> newConsumerMemberQueryWrapper = new LambdaQueryWrapper<>();
newConsumerMemberQueryWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getNewUid());
ConsumerMember newConsumerMember = consumerMemberService.getOne(newConsumerMemberQueryWrapper);
if (!(ObjectUtils.isEmpty(newConsumerMember)) && !(ObjectUtils.isEmpty(consumerMember))) {
//判断是否为权益会员和会员是否有效
if (YesNoEnum.yes.getIndex().equals(consumerMember.getIsRights())
&& new Date().getTime() < consumerMember.getExpirationDate().getTime()
......@@ -420,22 +426,23 @@ public class RedisTask {
String equityFund = sysConfigService.selectConfigByKey("sys.equityFundLog.equityFund");
BigDecimal addEquityFund = payPrice.multiply(new BigDecimal(equityFund)).setScale(2, RoundingMode.HALF_UP);
// BigDecimal addEquityFund = new BigDecimal(99).multiply(new BigDecimal(equityFund)).setScale(2, RoundingMode.HALF_UP);
BigDecimal aEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getEquityFund()) ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
// BigDecimal aEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getEquityFund()) ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
// consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
BigDecimal accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getAccumulateEquityFund()) ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
consumerWallet.setAccumulateEquityFund(accumulateEquityFund.
add(addEquityFund));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet);
//添加权益金日志记录
EquityFundLog equityFundLog = new EquityFundLog();
equityFundLog.setEquityFund(addEquityFund);
equityFundLog.setEquityFundType(EquityFundTypeEnum.ORDER.getCode());
equityFundLog.setOutTradeNo(sOrder.getOrderNo());
equityFundLog.setTerminalTrace(sOrder.getOutTradeNo());
equityFundLog.setUid(sharingActivities.getUid());
equityFundLog.setNewUid(sharingActivities.getNewUid());
equityFundLogService.insertEquityFundLog(equityFundLog);
//添加临时权益金日志记录
String equityFundExc = sysConfigService.selectConfigByKey("sys.equityFundExcess.equityFundExcess");
EquityFundExcess equityFundExcess = new EquityFundExcess();
equityFundExcess.setExpireTime(DateUtils.addDays(new Date(), Integer.parseInt(equityFundExc)));
equityFundExcess.setEquityFund(addEquityFund);
equityFundExcess.setOutTradeNo(sOrder.getOrderNo());
equityFundExcess.setUid(sharingActivities.getUid());
equityFundExcess.setNewUid(sharingActivities.getNewUid());
equityFundExcessService.insertEquityFundExcess(equityFundExcess);
}
}
}
}
......@@ -686,7 +693,7 @@ public class RedisTask {
logger.debug("AutoProgressLog:会员等级滚动降级开始");
//查询1年之前的数据
List<MemberProgressLog> list = memberProgressLogService.list(new LambdaQueryWrapper<MemberProgressLog>()
.lt(MemberProgressLog::getExpirationTime, new Date())
.le(MemberProgressLog::getExpirationTime, new Date())
);
if (CollectionUtil.isEmpty(list)) {
return;
......@@ -744,6 +751,52 @@ public class RedisTask {
logger.debug("AutoProgressLog:会员等级滚动降级结束");
}
/**
* 自动增加权益金
*/
@XxlJob("AutoEquityFundExcess")
public void AutoEquityFundExcess() {
logger.debug("AutoEquityFundExcess:权益金增加开始");
List<EquityFundExcess> list = equityFundExcessService.list(new LambdaQueryWrapper<EquityFundExcess>()
.le(EquityFundExcess::getExpireTime, new Date()));
if (CollectionUtil.isEmpty(list)) {
return;
}
List<Long> consumerIds = list.stream().map(EquityFundExcess::getUid).distinct().collect(Collectors.toList());
Map<Long,ConsumerWallet> consumerWalletMap = consumerWalletService.list(new LambdaQueryWrapper<ConsumerWallet>()
.in(ConsumerWallet::getConsumerId, consumerIds)).stream().collect(Collectors.toMap(ConsumerWallet::getConsumerId, item -> item));
List<ConsumerWallet> consumerWalletList = new ArrayList<>();
List<EquityFundLog> equityFundLogList = new ArrayList<>();
List<EquityFundExcess> equityFundExcessList = new ArrayList<>();
list.stream().forEach(item->{
ConsumerWallet consumerWallet = consumerWalletMap.get(item.getUid());
consumerWallet.setEquityFund(consumerWallet.getEquityFund().add(item.getEquityFund()));
consumerWalletList.add(consumerWallet);
EquityFundLog equityFundLog = new EquityFundLog();
equityFundLog.setEquityFund(item.getEquityFund());
equityFundLog.setEquityFundType(EquityFundTypeEnum.ORDER.getCode());
equityFundLog.setOutTradeNo(item.getOutTradeNo());
equityFundLog.setUid(item.getUid());
equityFundLog.setNewUid(item.getNewUid());
equityFundLog.setCreateTime(new Date());
equityFundLogList.add(equityFundLog);
item.setIsDelete(YesNoEnum.yes.getIndex());
equityFundExcessList.add(item);
});
if (CollectionUtil.isNotEmpty(consumerWalletList)){
consumerWalletService.updateBatchById(consumerWalletList);
}
if (CollectionUtil.isNotEmpty(equityFundLogList)){
equityFundLogService.saveBatch(equityFundLogList);
}
if (CollectionUtil.isNotEmpty(equityFundExcessList)){
equityFundExcessService.removeByIds(equityFundExcessList);
}
logger.debug("AutoProgressLog:权益金增加结束");
}
public void AutoAddRoomLabel() {
......
package share.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 权益金过度对象 s_equity_fund_excess
*
* @author wuwenlong
* @date 2024-09-20
*/
@Data
@TableName(value = "s_equity_fund_excess")
public class EquityFundExcess extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.AUTO)
private Long id;
/** 权益金额 */
@Excel(name = "权益金额")
private BigDecimal equityFund;
/** 上级id */
private Long uid;
/** 下级id */
private Long newUid;
/** 订单号 */
@Excel(name = "订单号")
private String outTradeNo;
/** 过期时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "过期时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date expireTime;
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Integer isDelete;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("equityFund", getEquityFund())
.append("uid", getUid())
.append("newUid", getNewUid())
.append("outTradeNo", getOutTradeNo())
.append("expireTime", getExpireTime())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
......@@ -52,7 +52,7 @@ public class EquityFundLog extends BaseEntity
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
private Integer isDelete;
......
......@@ -38,7 +38,7 @@ public class SharingActivities extends BaseEntity
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
private Integer isDelete;
......
......@@ -2,6 +2,9 @@ package share.system.domain.vo;
import lombok.Data;
import share.system.domain.ConsumerWallet;
import share.system.domain.EquityFundExcess;
import java.util.List;
@Data
public class ConsumerWalletVo extends ConsumerWallet {
......@@ -13,4 +16,8 @@ public class ConsumerWalletVo extends ConsumerWallet {
* 用户手机号
*/
private String phone;
private List<EquityFundExcessVo> equityFundExcessList;
}
package share.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import share.system.domain.EquityFundExcess;
import java.util.Date;
@Data
public class EquityFundExcessVo extends EquityFundExcess {
/** 上级电话 */
private String phone;
/** 上级用户昵称 */
private String nickName;
/** 下级电话 */
private String newPhone;
/** 下级用户昵称 */
private String newNickName;
/** 上级用户头像 */
private String avatar;
/** 下级用户头像 */
private String newAvatar;
/**
* 开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date startDate;
/**
* 结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date endDate;
}
......@@ -6,7 +6,6 @@ import share.system.domain.EquityFundLog;
@Data
public class EquityFundLogVo extends EquityFundLog {
/** 上级电话 */
private String phone;
/** 上级账号 */
......
......@@ -36,7 +36,7 @@ public class SConsumerVo extends SConsumer {
private ConsumerMember consumerMember;
private ConsumerWallet consumerWallet;
private ConsumerWalletVo consumerWallet;
private MemberConfigVo memberConfig;
......
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.EquityFundExcess;
/**
* 权益金过度Mapper接口
*
* @author wuwenlong
* @date 2024-09-20
*/
public interface EquityFundExcessMapper extends BaseMapper<EquityFundExcess>
{
/**
* 查询权益金过度
*
* @param id 权益金过度主键
* @return 权益金过度
*/
public EquityFundExcess selectEquityFundExcessById(Long id);
/**
* 查询权益金过度列表
*
* @param equityFundExcess 权益金过度
* @return 权益金过度集合
*/
public List<EquityFundExcess> selectEquityFundExcessList(EquityFundExcess equityFundExcess);
/**
* 新增权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
public int insertEquityFundExcess(EquityFundExcess equityFundExcess);
/**
* 修改权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
public int updateEquityFundExcess(EquityFundExcess equityFundExcess);
/**
* 删除权益金过度
*
* @param id 权益金过度主键
* @return 结果
*/
public int deleteEquityFundExcessById(Long id);
/**
* 批量删除权益金过度
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEquityFundExcessByIds(Long[] ids);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.EquityFundExcess;
import share.system.domain.vo.EquityFundExcessVo;
/**
* 权益金过度Service接口
*
* @author wuwenlong
* @date 2024-09-20
*/
public interface EquityFundExcessService extends IService<EquityFundExcess>
{
/**
* 查询权益金过度
*
* @param id 权益金过度主键
* @return 权益金过度
*/
public EquityFundExcess selectEquityFundExcessById(Long id);
/**
* 查询权益金过度列表
*
* @param equityFundExcess 权益金过度
* @return 权益金过度集合
*/
public List<EquityFundExcess> selectEquityFundExcessList(EquityFundExcess equityFundExcess);
/**
* 新增权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
public int insertEquityFundExcess(EquityFundExcess equityFundExcess);
/**
* 修改权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
public int updateEquityFundExcess(EquityFundExcess equityFundExcess);
/**
* 批量删除权益金过度
*
* @param ids 需要删除的权益金过度主键集合
* @return 结果
*/
public int deleteEquityFundExcessByIds(Long[] ids);
/**
* 删除权益金过度信息
*
* @param id 权益金过度主键
* @return 结果
*/
public int deleteEquityFundExcessById(Long id);
List<EquityFundExcessVo> selectEquityFundExcessVoList(Long id);
TableDataInfo pageList(TableDataInfo dataTable, EquityFundExcessVo equityFundExcess);
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import share.common.core.page.TableDataInfo;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.vo.EquityFundExcessVo;
import share.system.domain.vo.EquityFundLogVo;
import share.system.mapper.EquityFundExcessMapper;
import share.system.domain.EquityFundExcess;
import share.system.mapper.SConsumerMapper;
import share.system.service.EquityFundExcessService;
import share.system.service.SConsumerService;
/**
* 权益金过度Service业务层处理
*
* @author wuwenlong
* @date 2024-09-20
*/
@Service
public class EquityFundExcessServiceImpl extends ServiceImpl<EquityFundExcessMapper, EquityFundExcess> implements EquityFundExcessService
{
@Autowired
private EquityFundExcessMapper equityFundExcessMapper;
@Autowired
private SConsumerMapper sConsumerMapper;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询权益金过度
*
* @param id 权益金过度主键
* @return 权益金过度
*/
@Override
public EquityFundExcess selectEquityFundExcessById(Long id)
{
return equityFundExcessMapper.selectEquityFundExcessById(id);
}
/**
* 查询权益金过度列表
*
* @param equityFundExcess 权益金过度
* @return 权益金过度
*/
@Override
public List<EquityFundExcess> selectEquityFundExcessList(EquityFundExcess equityFundExcess)
{
return equityFundExcessMapper.selectEquityFundExcessList(equityFundExcess);
}
/**
* 新增权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
@Override
public int insertEquityFundExcess(EquityFundExcess equityFundExcess)
{
equityFundExcess.setCreateTime(DateUtils.getNowDate());
return equityFundExcessMapper.insertEquityFundExcess(equityFundExcess);
}
/**
* 修改权益金过度
*
* @param equityFundExcess 权益金过度
* @return 结果
*/
@Override
public int updateEquityFundExcess(EquityFundExcess equityFundExcess)
{
equityFundExcess.setUpdateTime(DateUtils.getNowDate());
return equityFundExcessMapper.updateEquityFundExcess(equityFundExcess);
}
/**
* 批量删除权益金过度
*
* @param ids 需要删除的权益金过度主键
* @return 结果
*/
@Override
public int deleteEquityFundExcessByIds(Long[] ids)
{
return equityFundExcessMapper.deleteEquityFundExcessByIds(ids);
}
/**
* 删除权益金过度信息
*
* @param id 权益金过度主键
* @return 结果
*/
@Override
public int deleteEquityFundExcessById(Long id)
{
return equityFundExcessMapper.deleteEquityFundExcessById(id);
}
@Override
public List<EquityFundExcessVo> selectEquityFundExcessVoList(Long id) {
List<EquityFundExcess> list = list(new LambdaQueryWrapper<EquityFundExcess>()
.eq(EquityFundExcess::getUid, id));
if (CollectionUtils.isEmpty(list)) return new ArrayList<>();
List<Long> collect = list.stream().map(EquityFundExcess::getNewUid).collect(Collectors.toList());
SConsumer sConsumer = sConsumerMapper.selectSConsumerById(id);
List<SConsumer> newConsumerList = sConsumerMapper.selectList(new LambdaQueryWrapper<SConsumer>()
.in(SConsumer::getId,collect));
Map<Long,SConsumer> newUserMap = sConsumerMapper.selectList(new LambdaQueryWrapper<SConsumer>()
.in(SConsumer::getId,collect))
.stream().collect(Collectors.toMap(SConsumer::getId, Function.identity()));
List<EquityFundExcessVo> equityFundExcessVo = new ArrayList<>();
list.stream().forEach(item -> {
EquityFundExcessVo vo = new EquityFundExcessVo();
BeanUtils.copyProperties(
item, vo);
if (StringUtils.isNotEmpty(sConsumer.getAvatar())) vo.setAvatar(sConsumer.getAvatar());
if (StringUtils.isNotEmpty(sConsumer.getPhone())) vo.setPhone(sConsumer.getPhone());
if (StringUtils.isNotEmpty(sConsumer.getNickName())) vo.setNickName(sConsumer.getNickName());
SConsumer consumer = newUserMap.get(item.getNewUid());
if (ObjectUtil.isNotEmpty(consumer)){
if (StringUtils.isNotEmpty(consumer.getAvatar())) vo.setNewAvatar(consumer.getAvatar());
if (StringUtils.isNotEmpty(consumer.getPhone())) vo.setNewPhone(consumer.getPhone());
if (StringUtils.isNotEmpty(consumer.getNickName())) vo.setNewNickName(consumer.getNickName());
}
equityFundExcessVo.add(vo);
});
return equityFundExcessVo;
}
@Override
public TableDataInfo pageList(TableDataInfo dataTable, EquityFundExcessVo equityFundExcess) {
List<EquityFundExcessVo> voList = new ArrayList<>();
List<EquityFundExcess> activities =(List<EquityFundExcess>) dataTable.getRows();
if (CollectionUtils.isEmpty(activities)) return dataTable;
List<Long> collect = activities.stream().map(EquityFundExcess::getNewUid).collect(Collectors.toList());
List<Long> uids = activities.stream().map(EquityFundExcess::getUid).collect(Collectors.toList());
LambdaQueryWrapper<SConsumer> newSConsumer = new LambdaQueryWrapper<SConsumer>();
LambdaQueryWrapper<SConsumer> uSConsumer = new LambdaQueryWrapper<SConsumer>();
newSConsumer.in(SConsumer::getId, collect);
uSConsumer.in(SConsumer::getId, uids);
if(StringUtils.isNotEmpty(equityFundExcess.getNewNickName())){
newSConsumer.like(SConsumer::getNickName,equityFundExcess.getNewNickName());
}
if(StringUtils.isNotEmpty(equityFundExcess.getNewPhone())){
newSConsumer.like(SConsumer::getPhone,equityFundExcess.getNewPhone());
}
if(StringUtils.isNotEmpty(equityFundExcess.getNickName())){
uSConsumer.like(SConsumer::getNickName,equityFundExcess.getNickName());
}
if(StringUtils.isNotEmpty(equityFundExcess.getPhone())){
uSConsumer.like(SConsumer::getPhone,equityFundExcess.getPhone());
}
Map<Long,SConsumer> newUserMap = sConsumerService.list(newSConsumer)
.stream().collect(Collectors.toMap(SConsumer::getId, Function.identity()));
Map<Long,SConsumer> userMap = sConsumerService.list(uSConsumer)
.stream().collect(Collectors.toMap(SConsumer::getId, Function.identity()));
activities.stream().forEach(item ->{
EquityFundExcessVo vo = new EquityFundExcessVo();
BeanUtils.copyProperties(item, vo);
Set<Long> longs = userMap.keySet();
Set<Long> longs1 = newUserMap.keySet();
if (!(longs.contains(item.getUid()) && longs1.contains(item.getNewUid()))){
return;
}
SConsumer newConsumer = newUserMap.get(item.getNewUid());
SConsumer uConsumer = userMap.get(item.getUid());
if(ObjectUtil.isNotEmpty(newConsumer)){
vo.setNewAvatar(StringUtils.isNotEmpty(newConsumer.getAvatar()) ? newConsumer.getAvatar():"");
vo.setNewNickName(StringUtils.isNotEmpty(newConsumer.getNickName()) ? newConsumer.getNickName():"");
vo.setNewPhone(StringUtils.isNotEmpty(newConsumer.getPhone()) ? newConsumer.getPhone():"");
}
if(ObjectUtil.isNotEmpty(uConsumer)){
vo.setAvatar(StringUtils.isNotEmpty(uConsumer.getAvatar()) ? uConsumer.getAvatar():"");
vo.setNickName(StringUtils.isNotEmpty(uConsumer.getNickName()) ? uConsumer.getNickName():"");
vo.setPhone(StringUtils.isNotEmpty(uConsumer.getPhone()) ? uConsumer.getPhone():"");
}
voList.add(vo);
});
dataTable.setRows(voList);
return dataTable;
}
}
......@@ -23,9 +23,7 @@ import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MemberConfigVo;
import share.system.domain.vo.SConsumerVo;
import share.system.domain.vo.*;
import share.system.mapper.ConsumerMemberMapper;
import share.system.mapper.SConsumerMapper;
import share.system.mapper.SStoreConsumerMapper;
......@@ -33,11 +31,9 @@ import share.system.request.RegisterThirdSConsumerRequest;
import share.system.service.*;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -71,6 +67,9 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Autowired
private SConsumerService sConsumerService;
@Autowired
private EquityFundExcessService equityFundExcessService;
/**
......@@ -245,7 +244,16 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
vo.setMemberConfig(memberConfigVo);
}
if (ObjectUtil.isNotEmpty(consumerWallet)) {
vo.setConsumerWallet(consumerWallet);
List<EquityFundExcessVo> equityFundExcessVos =
equityFundExcessService.selectEquityFundExcessVoList(currentUser.getId());
ConsumerWalletVo consumerWalletVo = new ConsumerWalletVo();
BeanUtils.copyProperties(consumerWallet, consumerWalletVo);
if (CollectionUtils.isEmpty(equityFundExcessVos)){
consumerWalletVo.setEquityFundExcessList(new ArrayList<>());
}else {
consumerWalletVo.setEquityFundExcessList(equityFundExcessVos);
}
vo.setConsumerWallet(consumerWalletVo);
}
List<Long> longList = storeConsumerMapper.selectByConsumerId(currentUser.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(longList)) {
......
......@@ -485,28 +485,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
if (request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
if (sOrder.getStatus().equals(OrderStatusEnum.USED.getCode())) {
//查询次订单用户有没有上级用户
SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
.eq(SharingActivities::getNewUid, sOrder.getConsumerId()));
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询权益金日志记录
EquityFundLog equityFundLog = equityFundLogService.getOne(new LambdaQueryWrapper<EquityFundLog>()
.eq(EquityFundLog::getNewUid,sOrder.getConsumerId())
.eq(EquityFundLog::getOutTradeNo,sOrder.getOrderNo())
.eq(EquityFundLog::getTerminalTrace,sOrder.getOutTradeNo()));
if (ObjectUtil.isNotEmpty(equityFundLog)){
ConsumerWallet aConsumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
.eq(ConsumerWallet::getConsumerId,sharingActivities.getUid()));
aConsumerWallet.setEquityFund(aConsumerWallet.getEquityFund().subtract(equityFundLog.getEquityFund()));
aConsumerWallet.setAccumulateEquityFund(aConsumerWallet.getAccumulateEquityFund().subtract(equityFundLog.getEquityFund()));
consumerWalletService.updateConsumerWallet(aConsumerWallet);
equityFundLog.setEquityFundType(EquityFundTypeEnum.ORDER_REFUND.getCode());
equityFundLog.setEquityFund(equityFundLog.getEquityFund().negate());
equityFundLogService.insertEquityFundLog(equityFundLog);
}
}
}
// if (sOrder.getStatus().equals(OrderStatusEnum.USED.getCode())) {
// //查询次订单用户有没有上级用户
// SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
// .eq(SharingActivities::getNewUid, sOrder.getConsumerId()));
// if (ObjectUtil.isNotEmpty(sharingActivities)) {
// //查询权益金日志记录
// EquityFundLog equityFundLog = equityFundLogService.getOne(new LambdaQueryWrapper<EquityFundLog>()
// .eq(EquityFundLog::getNewUid,sOrder.getConsumerId())
// .eq(EquityFundLog::getOutTradeNo,sOrder.getOrderNo())
// .eq(EquityFundLog::getTerminalTrace,sOrder.getOutTradeNo()));
// if (ObjectUtil.isNotEmpty(equityFundLog)){
// ConsumerWallet aConsumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
// .eq(ConsumerWallet::getConsumerId,sharingActivities.getUid()));
// aConsumerWallet.setEquityFund(aConsumerWallet.getEquityFund().subtract(equityFundLog.getEquityFund()));
// aConsumerWallet.setAccumulateEquityFund(aConsumerWallet.getAccumulateEquityFund().subtract(equityFundLog.getEquityFund()));
// consumerWalletService.updateConsumerWallet(aConsumerWallet);
// equityFundLog.setEquityFundType(EquityFundTypeEnum.ORDER_REFUND.getCode());
// equityFundLog.setEquityFund(equityFundLog.getEquityFund().negate());
// equityFundLogService.insertEquityFundLog(equityFundLog);
// }
// }
// }
// 退款金额大于0, 微信退款
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode())) {
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.EquityFundExcessMapper">
<resultMap type="EquityFundExcess" id="EquityFundExcessResult">
<result property="id" column="id" />
<result property="equityFund" column="equity_fund" />
<result property="uid" column="uid" />
<result property="newUid" column="new_uid" />
<result property="outTradeNo" column="out_trade_no" />
<result property="expireTime" column="expire_time" />
<result property="isDelete" column="is_delete" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectEquityFundExcessVo">
select id, equity_fund, uid, new_uid, out_trade_no, expire_time, is_delete, create_by, create_time, update_by, update_time, remark from s_equity_fund_excess
</sql>
<select id="selectEquityFundExcessList" parameterType="EquityFundExcess" resultMap="EquityFundExcessResult">
<include refid="selectEquityFundExcessVo"/>
where is_delete = 0
<if test="equityFund != null "> and equity_fund = #{equityFund}</if>
<if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no like concat('%', #{outTradeNo}, '%')</if>
<if test="startDate != null">
and DATE_FORMAT(expire_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(expire_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
</select>
<select id="selectEquityFundExcessById" parameterType="Long" resultMap="EquityFundExcessResult">
<include refid="selectEquityFundExcessVo"/>
where id = #{id}
</select>
<insert id="insertEquityFundExcess" parameterType="EquityFundExcess" useGeneratedKeys="true" keyProperty="id">
insert into s_equity_fund_excess
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="equityFund != null">equity_fund,</if>
<if test="uid != null">uid,</if>
<if test="newUid != null">new_uid,</if>
<if test="outTradeNo != null">out_trade_no,</if>
<if test="expireTime != null">expire_time,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="equityFund != null">#{equityFund},</if>
<if test="uid != null">#{uid},</if>
<if test="newUid != null">#{newUid},</if>
<if test="outTradeNo != null">#{outTradeNo},</if>
<if test="expireTime != null">#{expireTime},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateEquityFundExcess" parameterType="EquityFundExcess">
update s_equity_fund_excess
<trim prefix="SET" suffixOverrides=",">
<if test="equityFund != null">equity_fund = #{equityFund},</if>
<if test="uid != null">uid = #{uid},</if>
<if test="newUid != null">new_uid = #{newUid},</if>
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</if>
<if test="expireTime != null">expire_time = #{expireTime},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEquityFundExcessById" parameterType="Long">
delete from s_equity_fund_excess where id = #{id}
</delete>
<delete id="deleteEquityFundExcessByIds" parameterType="String">
delete from s_equity_fund_excess where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -26,7 +26,7 @@
<select id="selectEquityFundLogList" parameterType="EquityFundLog" resultMap="EquityFundLogResult">
<include refid="selectEquityFundLogVo"/>
where 1=1
where is_delete = 0
<if test="equityFundType != null and equityFundType != ''"> and equity_fund_type = #{equityFundType}</if>
<if test="equityFund != null "> and equity_fund = #{equityFund}</if>
<if test="uid != null "> and uid = #{uid}</if>
......
......@@ -24,12 +24,11 @@
<select id="selectSharingActivitiesList" parameterType="SharingActivities" resultMap="SharingActivitiesResult">
<include refid="selectSharingActivitiesVo"/>
<where>
where is_delete = 0
<if test="activityType != null and activityType != ''"> and activity_type = #{activityType}</if>
<if test="uid != null "> and uid = #{uid}</if>
<if test="newUid != null "> and new_uid = #{newUid}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
</where>
order by create_time desc
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment