Commit 2dec1bba by 吕明尚

Merge branch 'refs/heads/test' into test-lms

# Conflicts:
#	share-quartz/src/main/java/share/quartz/task/RedisTask.java
#	share-system/src/main/java/share/system/domain/vo/SConsumerVo.java
#	share-system/src/main/java/share/system/service/impl/SConsumerServiceImpl.java
#	share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
parents 38919ea9 ecd18fe9
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));
}
}
......@@ -17,6 +17,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.EquityFundLog;
import share.system.domain.vo.EquityFundLogVo;
import share.system.service.EquityFundLogService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -39,11 +40,12 @@ public class EquityFundLogController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:list')")
@GetMapping("/list")
public TableDataInfo list(EquityFundLog equityFundLog)
public TableDataInfo list(EquityFundLogVo equityFundLog)
{
startPage();
List<EquityFundLog> list = equityFundLogService.selectEquityFundLogList(equityFundLog);
return getDataTable(list);
TableDataInfo dataTable = getDataTable(list);
return equityFundLogService.pageList(dataTable,equityFundLog);
}
/**
......
......@@ -17,6 +17,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.SConsumer;
import share.system.domain.vo.SConsumerVo;
import share.system.service.SConsumerService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -34,6 +35,8 @@ public class SConsumerController extends BaseController
@Autowired
private SConsumerService sConsumerService;
/**
* 查询会员用户列表
*/
......@@ -46,6 +49,18 @@ public class SConsumerController extends BaseController
return getDataTable(list);
}
/**
* 查询会员用户列表
*/
// @PreAuthorize("@ss.hasPermi('system:consumer:list')")
@GetMapping("/selectConsumernotById")
public TableDataInfo selectConsumernotById(SConsumerVo sConsumer)
{
return sConsumerService.selectConsumernotById(sConsumer);
}
@GetMapping("/query")
public AjaxResult query() {
return success(sConsumerService.selectSConsumerList(new SConsumer()));
......
......@@ -18,6 +18,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.SharingActivities;
import share.system.domain.vo.SharingActivitiesVo;
import share.system.service.SharingActivitiesService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -39,10 +40,11 @@ public class SharingActivitiesController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:activities:list')")
@GetMapping("/list")
public TableDataInfo list(SharingActivities sharingActivities) {
public TableDataInfo list(SharingActivitiesVo sharingActivities) {
startPage();
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
return getDataTable(list);
TableDataInfo dataTable = getDataTable(list);
return sharingActivitiesService.pageList(dataTable,sharingActivities);
}
/**
......@@ -85,6 +87,7 @@ public class SharingActivitiesController extends BaseController {
@Log(title = "分享活动绑定关系", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SharingActivities sharingActivities) {
return toAjax(sharingActivitiesService.updateSharingActivities(sharingActivities));
}
......
......@@ -11,9 +11,11 @@ public class Constants
{
//订单提前进场时间限制
public final static Integer OPEN_DOOR_AHEAD_HOUR = 30;
public final static Integer OPEN_DOOR_AHEAD_HOUR = 60;
//订单提前进场时间限制 -1
public final static Integer OPEN_DOOR_AHEAD_HOUR_MINUS = -30;
public final static Integer OPEN_DOOR_AHEAD_HOUR_MINUS = -60;
//房间锁定时间
public final static Integer ROOM_LOCK_HOUR = 30;
//保洁锁定订单房间状态延迟时间
public final static Integer ROOM_LOCK_DELAY_MINUTE = 60;
......
package share.common.enums;
public enum EquityFundTypeEnum {
RECHARGE("0", "充值"),
RIGHTS("1", "权益购买"),
ORDER("2","订单消费"),
ORDER_REFUND("3","订单消费退款"),
WITHDRAW_BALANCE("4","权益金提现到余额"),
WITHDRAW_WX("5","权益金提现到微信"),
;
EquityFundTypeEnum() {
}
EquityFundTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private String code;
private String name;
}
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.SConsumer;
import share.system.domain.vo.EquityFundExcessVo;
import share.system.domain.vo.FrontTokenComponent;
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)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
equityFundExcess.setUid(user.getId());
startPage();
List<EquityFundExcess> list = equityFundExcessService.selectEquityFundExcessList(equityFundExcess);
TableDataInfo dataTable = getDataTable(list);
return equityFundExcessService.pageList(dataTable,equityFundExcess);
}
}
......@@ -11,7 +11,9 @@ import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.EquityFundLog;
import share.system.domain.SConsumer;
import share.system.domain.SharingActivities;
import share.system.domain.vo.DurationLogVo;
import share.system.domain.vo.EquityFundLogVo;
import share.system.domain.vo.FrontTokenComponent;
import share.system.service.EquityFundLogService;
......@@ -34,12 +36,13 @@ public class EquityFundLogController extends BaseController {
* 查询本人权益金记录列表
*/
@GetMapping("/list")
public TableDataInfo list(EquityFundLog equityFundLog) {
startPage();
public TableDataInfo list(EquityFundLogVo equityFundLog) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
equityFundLog.setUid(user.getId());
startPage();
List<EquityFundLog> list = equityFundLogService.selectEquityFundLogList(equityFundLog);
return getDataTable(list);
TableDataInfo dataTable = getDataTable(list);
return equityFundLogService.pageList(dataTable,equityFundLog);
}
......
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 org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.EquityFundLog;
import share.system.domain.SConsumer;
import share.system.domain.SharingActivities;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SharingActivitiesVo;
import share.system.service.SharingActivitiesService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
......@@ -34,20 +31,40 @@ public class SharingActivitiesController extends BaseController {
* 查询分享活动绑定关系列表
*/
@GetMapping("/list")
public TableDataInfo list(SharingActivities sharingActivities) {
startPage();
public TableDataInfo list(SharingActivitiesVo sharingActivities) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sharingActivities.setUid(user.getId());
startPage();
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
return getDataTable(list);
TableDataInfo dataTable = getDataTable(list);
return sharingActivitiesService.pageList(dataTable,sharingActivities);
}
@GetMapping("/query")
public AjaxResult query(SharingActivities sharingActivities) {
public TableDataInfo query(SharingActivitiesVo sharingActivities) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sharingActivities.setNewUid(user.getId());
startPage();
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
return success(list);
TableDataInfo dataTable = getDataTable(list);
return sharingActivitiesService.pageList(dataTable,sharingActivities);
}
/**
* 查询下级数量
* @param sharingActivities
* @return
*/
@GetMapping("/countNum")
public AjaxResult countNum(SharingActivities sharingActivities){
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sharingActivities.setUid(user.getId());
return success(sharingActivitiesService.selectSharingActivitiesCount(sharingActivities));
}
}
......@@ -74,6 +74,9 @@ public class OrderTask {
@Autowired
private ISCleanRecordsService isCleanRecordsService;
@Autowired
private EquityFundExcessService equityFundExcessService;
final int ZERO = 0;
//10分钟的常量
......@@ -341,6 +344,7 @@ public class OrderTask {
if (orders != null && orders.size() > 0) {
orders.stream().forEach(sOrder -> {
logger.debug("订单号为:" + sOrder.getOrderNo() + "的订单异常");
equityFundExcessService.extracted(sOrder);
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
sOrder.setUpdateTime(new Date());
......
......@@ -91,9 +91,6 @@ public class RedisTask {
private RoomLabelService roomLabelService;
@Autowired
private WechatNewService wechatNewService1;
@Autowired
private SConsumerTokenService sConsumerTokenService;
@Autowired
......@@ -119,13 +116,11 @@ public class RedisTask {
private ISysConfigService sysConfigService;
@Autowired
private SConsumerService consumerService;
@Autowired
private EquityFundLogService equityFundLogService;
@Autowired
private DurationLogService durationLogService;
private EquityFundExcessService equityFundExcessService;
//15分钟的常量
......@@ -258,6 +253,7 @@ public class RedisTask {
if (!tiktok) {
tiktokService.clientToken();
}
wechatNewService.getMiniAccessToken();
wechatNewService.getPublicAccessToken();
logger.debug("AutomaticMtSessionKey:自动续期session结束");
}
......@@ -344,115 +340,8 @@ public class RedisTask {
redisUtil.delete(o);
throw new BaseException("订单不存在!");
}
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getNewUid, sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询当前用户是否只有一个订单
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder::getConsumerId, sOrder.getConsumerId());
sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus());
sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
List<SOrder> sOrderList = isOrderService.list(sOrderLambdaQueryWrapper);
if (sOrderList.size() == 1) {
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(consumerWallet)) {
//添加时长
BigDecimal anHour = new BigDecimal(1.0);
BigDecimal accumulateEquityFund = consumerWallet.getAccumulateEquityFund() != null ? consumerWallet.getAccumulateEquityFund() : 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.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(durationLog);
} else {
//新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet();
BigDecimal defaultVlue = new BigDecimal(0.0);
newConsumerWallet.setConsumerId(sharingActivities.getUid());
newConsumerWallet.setBalance(defaultVlue);
newConsumerWallet.setRemainingIntegral(defaultVlue);
newConsumerWallet.setEquityFund(defaultVlue);
newConsumerWallet.setAccumulateEquityFund(defaultVlue);
BigDecimal anHour = new BigDecimal(1.0);
newConsumerWallet.setRemainingDuration(defaultVlue.add(anHour));
newConsumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.insertConsumerWallet(newConsumerWallet);
DurationLog newDurationLog = new DurationLog();
newDurationLog.setConsumerId(consumerWallet.getConsumerId());
newDurationLog.setVariableDuration(anHour);
newDurationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
newDurationLog.setOperationType(YesNoEnum.yes.getIndex());
newDurationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(newDurationLog);
}
}
//查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberWrapper = new LambdaQueryWrapper<>();
consumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberWrapper);
LambdaQueryWrapper<ConsumerMember> newConsumerMemberQueryWrapper = new LambdaQueryWrapper<>();
newConsumerMemberQueryWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getNewUid());
ConsumerMember newConsumerMember = consumerMemberService.getOne(newConsumerMemberQueryWrapper);
//判断是否为权益会员和会员是否有效
if (YesNoEnum.yes.getIndex().equals(consumerMember.getIsRights()) && new Date().getTime() < consumerMember.getExpirationDate().getTime()
&& YesNoEnum.yes.getIndex().equals(newConsumerMember.getIsRights()) && new Date().getTime() < newConsumerMember.getExpirationDate().getTime()) {
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME.getValue() + sharingActivities.getUid().toString());
Boolean newAboolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME.getValue() + sharingActivities.getNewUid().toString());
if (aBoolean && newAboolean) {
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
BigDecimal payPrice = sOrder.getPayPrice();
if (payPrice.signum() > 0) {
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 = consumerWallet.getEquityFund() != null ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
BigDecimal accumulateEquityFund = consumerWallet.getAccumulateEquityFund() != null ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
consumerWallet.setAccumulateEquityFund(accumulateEquityFund.
add(addEquityFund));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet);
//添加权益金日志记录
//下级用户
SConsumer newConsumer = consumerService.getById(sOrder.getConsumerId());
//上级用户
SConsumer consumer = consumerService.getById(sharingActivities.getUid());
EquityFundLog equityFundLog = new EquityFundLog();
equityFundLog.setEquityFund(addEquityFund);
equityFundLog.setEquityFundType("1");
equityFundLog.setOutTradeNo(sOrder.getOutTradeNo());
equityFundLog.setTerminalTrace(sOrder.getOutTradeNo());
equityFundLog.setUid(sharingActivities.getUid());
equityFundLog.setNewUid(sharingActivities.getNewUid());
equityFundLog.setPhone(consumer.getPhone());
equityFundLog.setAccount(consumer.getAccount());
equityFundLog.setNickName(consumer.getNickName());
equityFundLog.setAvatar(consumer.getAvatar());
equityFundLog.setNewAvatar(newConsumer.getAvatar());
equityFundLog.setNewPhone(newConsumer.getPhone());
equityFundLog.setNewAccount(newConsumer.getAccount());
equityFundLog.setNewNickName(newConsumer.getNickName());
equityFundLogService.insertEquityFundLog(equityFundLog);
}
}
}
}
equityFundExcessService.extracted(sOrder);
if (extracted(o, sOrders, sOrder)) return;
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
......@@ -490,7 +379,6 @@ public class RedisTask {
});
logger.debug("AutoAddSCleanRecords:自动添加保洁记录结束");
}
@XxlJob("autoRoomExpireTime")
public void autoRoomExpireTime() {
logger.debug("autoRoomExpireTime:房间15分钟续单开始");
......@@ -698,7 +586,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;
......@@ -706,19 +594,24 @@ public class RedisTask {
list.sort(Comparator.comparing(MemberProgressLog::getOperationType).reversed());
//获得list的consumerId
List<Long> consumerIds = list.stream().map(MemberProgressLog::getConsumerId).distinct().collect(Collectors.toList());
Map<Long, ConsumerMember> consumerMemberMap = consumerMemberService.list(new LambdaQueryWrapper<ConsumerMember>().in(ConsumerMember::getConsumerId, consumerIds))
.stream().collect(Collectors.toMap(ConsumerMember::getConsumerId, item -> item));
//按照consumerId进行分组
Map<Long, List<MemberProgressLog>> collect = list.stream().collect(Collectors.groupingBy(MemberProgressLog::getConsumerId));
Map<Long, MemberConfig> memberConfigMap = memberConfigService.list().stream().collect(Collectors.toMap(MemberConfig::getMembershipLevel, item -> item));
List<ConsumerMember> updateList = new ArrayList<>();
consumerIds.stream().forEach(item -> {
List<MemberProgressLog> memberProgressLogs = collect.get(item);
if (memberProgressLogs.size() > 0) {
//查询会员
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, item));
ConsumerMember consumerMember = consumerMemberMap.get(item);
;
if (consumerMember.getMembershipProgress().equals(BigDecimal.ZERO)) {
//结束此次循环
return;
}
//查询会员配置
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
MemberConfig memberConfig = memberConfigMap.get(consumerMember.getMembershipLevel());
final BigDecimal[] sum = {BigDecimal.ZERO};
//计算扣除进度
memberProgressLogs.stream().forEach(log -> {
......@@ -750,12 +643,59 @@ public class RedisTask {
}
}
}
consumerMemberService.updateConsumerMember(consumerMember);
updateList.add(consumerMember);
}
});
if (!CollectionUtils.isEmpty(updateList)) consumerMemberService.updateBatchById(updateList);
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<Long> ids = 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());
ids.add(item.getId());
});
if (CollectionUtil.isNotEmpty(consumerWalletList)){
consumerWalletService.updateBatchById(consumerWalletList);
}
if (CollectionUtil.isNotEmpty(equityFundLogList)){
equityFundLogService.saveBatch(equityFundLogList);
}
if (CollectionUtil.isNotEmpty(ids)){
equityFundExcessService.removeByIds(ids);
}
logger.debug("AutoProgressLog:权益金增加结束");
}
public void AutoAddRoomLabel() {
......@@ -842,56 +782,4 @@ public class RedisTask {
});
logger.debug("AutoUpdateOpenid:自动更新用户unionid结束");
}
//自动删除次卡
@XxlJob("AutomaticallyDeleteSecondaryCards")
public void AutomaticallyDeleteSecondaryCards() {
logger.debug("AutomaticallyDeleteSecondaryCards:自动删除次卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.SECONDARY_CARD + "*");
if (keys.size() == 0) {
return;
}
keys.stream().forEach(key -> {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerSecondaryCardId = jsonObject.getLong("consumerSecondaryCardId");
if (expirationTime.getTime() < new Date().getTime()) {
ConsumerSecondaryCard byId = consumerSecondaryCardService.getById(consumerSecondaryCardId);
if (ObjectUtil.isNotEmpty(byId)) {
byId.setIsDelete(YesNoEnum.yes.getIndex());
consumerSecondaryCardService.updateById(byId);
}
redisUtil.delete(key);
}
});
logger.debug("AutomaticallyDeleteSecondaryCards:自动删除次卡结束");
}
//自动删除月卡
@XxlJob("AutomaticallyDeleteMonthlyCards")
public void AutomaticallyDeleteMonthlyCards() {
logger.debug("AutomaticallyDeleteSecondaryCards:自动删除月卡开始");
Set<String> keys = redisTemplate.keys(ReceiptRdeisEnum.MONTHLY_CARD + "*");
if (keys.size() == 0) {
return;
}
keys.stream().forEach(key -> {
String value = redisUtil.get(String.valueOf(key));
JSONObject jsonObject = new JSONObject(value);
Date expirationTime = jsonObject.getDate("expirationTime");
Long consumerMonthlyCardId = jsonObject.getLong("consumerMonthlyCardId");
if (expirationTime.getTime() < new Date().getTime()) {
ConsumerMonthlyCard byId = consumerMonthlyCardService.getById(consumerMonthlyCardId);
if (ObjectUtil.isNotEmpty(byId)) {
byId.setIsDelete(YesNoEnum.yes.getIndex());
consumerMonthlyCardService.updateById(byId);
}
redisUtil.delete(key);
}
});
logger.debug("AutomaticallyDeleteSecondaryCards:自动删除月卡结束");
}
}
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,39 +52,9 @@ public class EquityFundLog extends BaseEntity
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
private Integer isDelete;
/** 上级电话 */
@Excel(name = "上级电话")
private String phone;
/** 上级账号 */
@Excel(name = "上级账号")
private String account;
/** 上级用户昵称 */
@Excel(name = "上级用户昵称")
private String nickName;
/** 下级电话 */
@Excel(name = "下级电话")
private String newPhone;
/** 下级账号 */
@Excel(name = "下级账号")
private String newAccount;
/** 下级用户昵称 */
@Excel(name = "下级用户昵称")
private String newNickName;
/** 上级用户头像 */
@Excel(name = "上级用户头像")
private String avatar;
/** 下级用户头像 */
@Excel(name = "下级用户头像")
private String newAvatar;
@Override
......@@ -103,14 +73,6 @@ public class EquityFundLog extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("phone", getPhone())
.append("account", getAccount())
.append("nickName", getNickName())
.append("newPhone", getNewPhone())
.append("newAccount", getNewAccount())
.append("newNickName", getNewNickName())
.append("avatar", getAvatar())
.append("newAvatar", getNewAvatar())
.toString();
}
}
package share.system.domain;
import com.baomidou.mybatisplus.annotation.*;
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 com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
/**
* 分享活动绑定关系对象 s_sharing_activities
......@@ -14,11 +13,13 @@ import lombok.Data;
* @date 2024-09-14
*/
@Data
@TableName("s_sharing_activities")
public class SharingActivities extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.AUTO)
private Long id;
/** 活动类型(0-新用户注册,1-权益金会员分享) */
......@@ -37,31 +38,9 @@ public class SharingActivities extends BaseEntity
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
private Integer isDelete;
/** 上级用户头像 */
@Excel(name = "上级用户头像")
private String avatar;
/** 下级用户头像 */
@Excel(name = "下级用户头像")
private String newAvatar;
/** 上级用户昵称 */
@Excel(name = "上级用户昵称")
private String nickName;
/** 下级用户昵称 */
@Excel(name = "下级用户昵称")
private String newNickName;
/** 上级电话 */
@Excel(name = "上级电话")
private String phone;
/** 下级电话 */
@Excel(name = "下级电话")
private String newPhone;
@Override
......@@ -77,12 +56,6 @@ public class SharingActivities extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("avatar", getAvatar())
.append("newAvatar", getNewAvatar())
.append("nickName", getNickName())
.append("newNickName", getNewNickName())
.append("phone", getPhone())
.append("newPhone", getNewPhone())
.toString();
}
}
......@@ -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;
}
package share.system.domain.vo;
import lombok.Data;
import share.common.annotation.Excel;
import share.system.domain.EquityFundLog;
@Data
public class EquityFundLogVo extends EquityFundLog {
/** 上级电话 */
private String phone;
/** 上级账号 */
private String account;
/** 上级用户昵称 */
private String nickName;
/** 下级电话 */
private String newPhone;
/** 下级账号 */
private String newAccount;
/** 下级用户昵称 */
private String newNickName;
/** 上级用户头像 */
private String avatar;
/** 下级用户头像 */
private String newAvatar;
}
......@@ -38,10 +38,19 @@ public class SConsumerVo extends SConsumer {
private ConsumerMember consumerMember;
private ConsumerWallet consumerWallet;
private ConsumerWalletVo consumerWallet;
private MemberConfigVo memberConfig;
private Integer pageNum;
private Integer pageSize;
private Long newId;
private List<ConsumerMonthlyCardVo> monthlyCardList;
private List<ConsumerSecondaryCardVo> secondaryCardList;
......
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SharingActivities;
@Data
public class SharingActivitiesVo extends SharingActivities {
/** 上级用户头像 */
private String avatar;
/** 下级用户头像 */
private String newAvatar;
/** 上级用户昵称 */
private String nickName;
/** 下级用户昵称 */
private String newNickName;
/** 上级电话 */
private String phone;
/** 下级电话 */
private String newPhone;
private Integer pageNum;
private Integer pageSize;
}
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.SOrder;
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);
void extracted(SOrder sOrder);
}
......@@ -2,7 +2,10 @@ 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.EquityFundLog;
import share.system.domain.vo.EquityFundLogVo;
import share.system.domain.vo.SharingActivitiesVo;
/**
* 权益金记录Service接口
......@@ -63,4 +66,8 @@ public interface EquityFundLogService extends IService<EquityFundLog>
List<EquityFundLog> selectEquityFundLogByUid(Long uid);
List<EquityFundLog> selectEquityFundLogByNewUid(Long newUid);
TableDataInfo pageList(TableDataInfo info, EquityFundLogVo sharingActivities);
}
package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.SConsumer;
import share.system.domain.vo.SConsumerVo;
import share.system.request.RegisterThirdSConsumerRequest;
......@@ -128,4 +129,7 @@ public interface SConsumerService extends IService<SConsumer>
boolean unbind(SConsumer request);
boolean bind(SConsumer request);
TableDataInfo selectConsumernotById(SConsumerVo sConsumer);
}
......@@ -3,7 +3,9 @@ package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.SharingActivities;
import share.system.domain.vo.SharingActivitiesVo;
/**
* 分享活动绑定关系Service接口
......@@ -62,4 +64,7 @@ public interface SharingActivitiesService extends IService<SharingActivities>
public int deleteSharingActivitiesById(Long id);
int selectSharingActivitiesCount(SharingActivities sharingActivities);
TableDataInfo pageList(TableDataInfo info,SharingActivitiesVo sharingActivities);
}
......@@ -471,7 +471,7 @@ public class CallbackServiceImpl implements CallbackService {
wechatPayInfoService.updateById(wechatInfo);
//新增权益金日志
addEquityFundLog(recharge.getConsumerId(),
recharge.getRechargeAmount(),recharge.getOutTradeNo(),recharge.getTerminalTrace(),"0");
recharge.getRechargeAmount(),recharge.getRechargeNo(),recharge.getTerminalTrace(),EquityFundTypeEnum.RECHARGE.getCode());
aFalse = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
......@@ -553,7 +553,7 @@ public class CallbackServiceImpl implements CallbackService {
wechatPayInfoService.updateById(equityPayInfo);
//新增权益金日志
addEquityFundLog(equityMembersOrder.getConsumerId(),
equityMembersOrder.getPayPrice(),equityMembersOrder.getEquityOrderNo(),equityMembersOrder.getTerminalTrace(),"1");
equityMembersOrder.getPayPrice(),equityMembersOrder.getEquityOrderNo(),equityMembersOrder.getTerminalTrace(),EquityFundTypeEnum.RIGHTS.getCode());
aBoolean = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
......@@ -788,9 +788,9 @@ public class CallbackServiceImpl implements CallbackService {
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid()));
if (ObjectUtil.isNotEmpty(consumerWallet)) {
BigDecimal aEquityFund = consumerWallet.getEquityFund() != null ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
BigDecimal aEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getEquityFund()) ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
BigDecimal accumulateEquityFund = consumerWallet.getAccumulateEquityFund() != null ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
BigDecimal accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getAccumulateEquityFund()) ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
consumerWallet.setAccumulateEquityFund(accumulateEquityFund.
add(addEquityFund));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
......@@ -809,10 +809,6 @@ public class CallbackServiceImpl implements CallbackService {
consumerWalletService.insertConsumerWallet(newConsumerWallet);
}
//添加权益金日志记录
//下级用户
SConsumer newConsumer = consumerService.getById(consumerId);
//上级用户
SConsumer consumer = consumerService.getById(sharingActivities.getUid());
EquityFundLog equityFundLog = new EquityFundLog();
equityFundLog.setEquityFund(addEquityFund);
equityFundLog.setEquityFundType(type);
......@@ -820,92 +816,11 @@ public class CallbackServiceImpl implements CallbackService {
equityFundLog.setTerminalTrace(terminalTrace);
equityFundLog.setUid(sharingActivities.getUid());
equityFundLog.setNewUid(sharingActivities.getNewUid());
equityFundLog.setPhone(consumer.getPhone());
equityFundLog.setAccount(consumer.getAccount());
equityFundLog.setNickName(consumer.getNickName());
equityFundLog.setAvatar(consumer.getAvatar());
equityFundLog.setNewAvatar(newConsumer.getAvatar());
equityFundLog.setNewPhone(newConsumer.getPhone());
equityFundLog.setNewAccount(newConsumer.getAccount());
equityFundLog.setNewNickName(newConsumer.getNickName());
equityFundLogService.insertEquityFundLog(equityFundLog);
}
}
}
}
// /**
// * 新增权益金日志
// * @param consumerId 用户ID
// * @param payPrice 消费金额
// * @param equityOrderNo 订单编号
// * @param terminalTrace 终端流水号
// * @param type 权益类型
// */
// private void addEquityFundLogRights(Long consumerId, BigDecimal payPrice, String equityOrderNo, String terminalTrace, String type) {
// //查询是否有上级
// SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
// .eq(SharingActivities::getNewUid, consumerId)
// .eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex()));
// if (ObjectUtil.isNotEmpty(sharingActivities)) {
// //查询会员用户类型
// LambdaQueryWrapper<ConsumerMember> consumerMemberWrapper = new LambdaQueryWrapper<>();
// consumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
// ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberWrapper);
// LambdaQueryWrapper<ConsumerMember> newConsumerMemberWrapper = new LambdaQueryWrapper<>();
// newConsumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
// ConsumerMember newConsumerMember = consumerMemberService.getOne(newConsumerMemberWrapper);
// //判断是否为权益会员和会员是否有效
// if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime()
// && "2".equals(newConsumerMember.getMemberType()) && new Date().getTime() < newConsumerMember.getExpirationDate().getTime()) {
// Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
// Boolean newAboolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getNewUid().toString());
// if (aBoolean && newAboolean) {
// String equityFund = sysConfigService.selectConfigByKey("sys.equityFundLog.equityFund");
// //查询上级用户是否有钱包
// ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
// .eq(ConsumerWallet::getConsumerId, sharingActivities.getUid()));
// if (ObjectUtil.isNotEmpty(consumerWallet)) {
// consumerWallet.setEquityFund(consumerWallet.getEquityFund().add(payPrice.multiply(new BigDecimal(equityFund))));
// consumerWallet.setAccumulateEquityFund(consumerWallet.getAccumulateEquityFund().
// add(payPrice.multiply(new BigDecimal(equityFund))));
// consumerWallet.setUpdateTime(DateUtils.getNowDate());
// consumerWalletService.updateConsumerWallet(consumerWallet);
// } else {
// //新增钱包
// ConsumerWallet newConsumerWallet = new ConsumerWallet();
// BigDecimal defaultVlue = new BigDecimal(0.0);
// newConsumerWallet.setConsumerId(sharingActivities.getUid());
// newConsumerWallet.setBalance(defaultVlue);
// newConsumerWallet.setRemainingIntegral(defaultVlue);
// newConsumerWallet.setRemainingDuration(defaultVlue);
// newConsumerWallet.setEquityFund(consumerWallet.getEquityFund().add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
// newConsumerWallet.setAccumulateEquityFund(consumerWallet.getAccumulateEquityFund()
// .add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
// consumerWalletService.insertConsumerWallet(newConsumerWallet);
// }
// //添加权益金日志记录
// //下级用户
// SConsumer newConsumer = consumerService.getById(consumerId);
// //上级用户
// SConsumer consumer = consumerService.getById(sharingActivities.getUid());
// EquityFundLog equityFundLog = new EquityFundLog();
// equityFundLog.setEquityFund(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP)));
// equityFundLog.setEquityFundType(type);
// equityFundLog.setOutTradeNo(equityOrderNo);
// equityFundLog.setTerminalTrace(terminalTrace);
// equityFundLog.setUid(sharingActivities.getUid());
// equityFundLog.setNewUid(sharingActivities.getNewUid());
// equityFundLog.setPhone(consumer.getPhone());
// equityFundLog.setAccount(consumer.getAccount());
// equityFundLog.setNickName(consumer.getNickName());
// equityFundLog.setNewPhone(newConsumer.getPhone());
// equityFundLog.setNewAccount(newConsumer.getAccount());
// equityFundLog.setNewNickName(newConsumer.getNickName());
// equityFundLogService.insertEquityFundLog(equityFundLog);
// }
// }
// }
// }
......
package share.system.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
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 org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import share.common.core.page.TableDataInfo;
import share.common.core.redis.RedisUtil;
import share.common.enums.OrderStatusEnum;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.RefundStatusEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.*;
import share.system.domain.vo.EquityFundExcessVo;
import share.system.domain.vo.EquityFundLogVo;
import share.system.mapper.EquityFundExcessMapper;
import share.system.mapper.SConsumerMapper;
import share.system.service.*;
/**
* 权益金过度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;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private ISOrderService isOrderService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private ConsumerWalletService consumerWalletService;
@Autowired
private SharingActivitiesService sharingActivitiesService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private DurationLogService durationLogService;
@Autowired
private EquityFundExcessService equityFundExcessService;
/**
* 查询权益金过度
*
* @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;
}
@Override
public void extracted(SOrder sOrder) {
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getNewUid, sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询当前用户是否只有一个订单
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder::getConsumerId, sOrder.getConsumerId());
sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.in(SOrder::getStatus, OrderStatusEnum.getValidOrderStatus());
sOrderLambdaQueryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
List<SOrder> sOrderList = isOrderService.list(sOrderLambdaQueryWrapper);
if (sOrderList.size() == 1) {
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(consumerWallet)) {
//添加时长
BigDecimal anHour = new BigDecimal(1.0);
BigDecimal accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getRemainingDuration()) ? consumerWallet.getRemainingDuration() : BigDecimal.ZERO;
consumerWallet.setRemainingDuration(accumulateEquityFund.add(anHour));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
durationLog.setVariableDuration(anHour);
durationLog.setCurrentDuration(accumulateEquityFund);
durationLog.setOperationType(YesNoEnum.yes.getIndex());
durationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(durationLog);
consumerWalletService.updateConsumerWallet(consumerWallet);
} else {
//新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet();
BigDecimal defaultVlue = new BigDecimal(0.0);
newConsumerWallet.setConsumerId(sharingActivities.getUid());
newConsumerWallet.setBalance(defaultVlue);
newConsumerWallet.setRemainingIntegral(defaultVlue);
newConsumerWallet.setEquityFund(defaultVlue);
newConsumerWallet.setAccumulateEquityFund(defaultVlue);
BigDecimal anHour = new BigDecimal(1.0);
newConsumerWallet.setRemainingDuration(defaultVlue.add(anHour));
newConsumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.insertConsumerWallet(newConsumerWallet);
DurationLog newDurationLog = new DurationLog();
newDurationLog.setConsumerId(consumerWallet.getConsumerId());
newDurationLog.setVariableDuration(anHour);
newDurationLog.setCurrentDuration(consumerWallet.getRemainingDuration());
newDurationLog.setOperationType(YesNoEnum.yes.getIndex());
newDurationLog.setOperationTime(DateUtils.getNowDate());
durationLogService.insertDurationLog(newDurationLog);
}
}
//查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberWrapper = new LambdaQueryWrapper<>();
consumerMemberWrapper.eq(ConsumerMember::getConsumerId, sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberWrapper);
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()
&& ((YesNoEnum.yes.getIndex().equals(newConsumerMember.getIsRights())
&& new Date().getTime() < newConsumerMember.getExpirationDate().getTime())
|| (newConsumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())))
) {
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME.getValue() + sharingActivities.getUid().toString());
Boolean newAboolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME.getValue() + sharingActivities.getNewUid().toString());
if (aBoolean && (newAboolean || newConsumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()))) {
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerWalletLambdaQueryWrapper.eq(ConsumerWallet::getConsumerId, sharingActivities.getUid());
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
BigDecimal payPrice = sOrder.getPayPrice();
if (payPrice.signum() > 0) {
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 accumulateEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getAccumulateEquityFund()) ? consumerWallet.getAccumulateEquityFund() : BigDecimal.ZERO;
consumerWallet.setAccumulateEquityFund(accumulateEquityFund.
add(addEquityFund));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet);
//添加临时权益金日志记录
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);
}
}
}
}
}
}
}
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.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.common.utils.StringUtils;
import share.system.domain.SConsumer;
import share.system.domain.vo.EquityFundLogVo;
import share.system.mapper.EquityFundLogMapper;
import share.system.domain.EquityFundLog;
import share.system.service.EquityFundLogService;
import share.system.service.SConsumerService;
/**
* 权益金记录Service业务层处理
......@@ -23,6 +36,9 @@ public class EquityFundLogServiceImpl extends ServiceImpl<EquityFundLogMapper, E
@Autowired
private EquityFundLogMapper equityFundLogMapper;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询权益金记录
*
......@@ -44,6 +60,8 @@ public class EquityFundLogServiceImpl extends ServiceImpl<EquityFundLogMapper, E
@Override
public List<EquityFundLog> selectEquityFundLogList(EquityFundLog equityFundLog)
{
return equityFundLogMapper.selectEquityFundLogList(equityFundLog);
}
......@@ -108,4 +126,59 @@ public class EquityFundLogServiceImpl extends ServiceImpl<EquityFundLogMapper, E
return equityFundLogMapper.selectList(new LambdaQueryWrapper<EquityFundLog>().eq(EquityFundLog::getNewUid,newUid));
}
@Override
public TableDataInfo pageList(TableDataInfo info, EquityFundLogVo equityFundLog) {
List<EquityFundLogVo> voList = new ArrayList<>();
List<EquityFundLog> activities =(List<EquityFundLog>) info.getRows();
if (CollectionUtils.isEmpty(activities)) return info;
List<Long> collect = activities.stream().map(EquityFundLog::getNewUid).collect(Collectors.toList());
List<Long> uids = activities.stream().map(EquityFundLog::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(equityFundLog.getNewNickName())){
newSConsumer.like(SConsumer::getNickName,equityFundLog.getNewNickName());
}
if(StringUtils.isNotEmpty(equityFundLog.getNewPhone())){
newSConsumer.like(SConsumer::getPhone,equityFundLog.getNewPhone());
}
if(StringUtils.isNotEmpty(equityFundLog.getNickName())){
uSConsumer.like(SConsumer::getNickName,equityFundLog.getNickName());
}
if(StringUtils.isNotEmpty(equityFundLog.getPhone())){
uSConsumer.like(SConsumer::getPhone,equityFundLog.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 ->{
EquityFundLogVo vo = new EquityFundLogVo();
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);
});
info.setRows(voList);
return info;
}
}
......@@ -128,7 +128,7 @@ public class OpenInterfaceServiceImpl implements OpenInterfaceService {
throw new BaseException("房间当前时段已被占用不可开门!");
}
//判断预约时间是否到达,可提前30分钟开门
//判断预约时间是否到达,可提前60分钟开门
if (DateUtils.addMinutes(sOrder.getPreStartDate(), Constants.OPEN_DOOR_AHEAD_HOUR_MINUS).compareTo(new Date()) > 0) {
throw new BaseException("预约时间未到达,可提前" + Constants.OPEN_DOOR_AHEAD_HOUR + "分钟进场,请耐心等候!");
}
......
......@@ -316,12 +316,12 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
SConsumer newConsumer = sConsumerService.selectSConsumerById(id);
SharingActivities sharingActivities = new SharingActivities();
sharingActivities.setUid(uid);
sharingActivities.setPhone(consumer.getPhone());
sharingActivities.setAvatar(consumer.getAvatar());
sharingActivities.setNickName(consumer.getNickName());
sharingActivities.setNewPhone(newConsumer.getPhone());
sharingActivities.setNewAvatar(newConsumer.getAvatar());
sharingActivities.setNewNickName(newConsumer.getNickName());
// sharingActivities.setPhone(consumer.getPhone());
// sharingActivities.setAvatar(consumer.getAvatar());
// sharingActivities.setNickName(consumer.getNickName());
// sharingActivities.setNewPhone(newConsumer.getPhone());
// sharingActivities.setNewAvatar(newConsumer.getAvatar());
// sharingActivities.setNewNickName(newConsumer.getNickName());
sharingActivities.setNewUid(id);
sharingActivities.setCreateTime(DateUtils.getNowDate());
sharingActivitiesService.insertSharingActivities(sharingActivities);
......
......@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import share.common.constant.SmsConstants;
import share.common.core.page.TableDataInfo;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
......@@ -22,15 +23,19 @@ import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import share.system.domain.*;
import share.system.domain.vo.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MemberConfigVo;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper;
import share.system.mapper.SStoreConsumerMapper;
import share.system.request.RegisterThirdSConsumerRequest;
import share.system.service.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 会员用户Service业务层处理
......@@ -63,6 +68,15 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
@Autowired
private SConsumerService sConsumerService;
@Autowired
private EquityFundExcessService equityFundExcessService;
/**
* 查询会员用户
*
......@@ -240,7 +254,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)) {
......
......@@ -181,6 +181,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
private SecondaryCardLogService secondaryCardLogService;
@Autowired
private SharingActivitiesService sharingActivitiesService;
@Autowired
private EquityFundLogService equityFundLogService;
private final static Long FIVE = 5L;
......@@ -486,6 +493,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);
// }
// }
// }
// 退款金额大于0, 微信退款
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode())) {
......@@ -882,8 +911,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
ConsumerWallet consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
ConsumerMember consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
ConsumerMonthlyCard consumerMonthlyCard = consumerMonthlyCardService.getById(request.getMonthlyCardId());
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardService.getById(request.getSecondaryCardId());
List<SStore> stores = storeService.list();
SRoom room = roomService.getById(request.getRoomId());
SStore sStore = storeService.getById(request.getStoreId());
......@@ -941,7 +968,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sOrder.setPayStatus(YesNoEnum.yes.getIndex());
sOrder.setPayTime(DateUtils.getNowDate());
creatExtracted(consumerWallet, sOrder, consumerMember);
createCard(consumerMonthlyCard, sOrder, consumerSecondaryCard);
} else {
// response = orderPayService.payment(sOrder);
// 扫呗聚合支付
......@@ -1075,32 +1101,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private void createCard(ConsumerMonthlyCard consumerMonthlyCard, SOrder sOrder, ConsumerSecondaryCard consumerSecondaryCard) {
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
MonthlyCardLog monthlyCardLog = new MonthlyCardLog();
monthlyCardLog.setConsumerMonthlyCardId(consumerMonthlyCard.getId());
monthlyCardLog.setConsumerId(sOrder.getConsumerId());
monthlyCardLog.setPhone(sOrder.getConsumerPhone());
monthlyCardLog.setUseDuration(sOrder.getDuration());
monthlyCardLog.setResidueDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
consumerMonthlyCard.setFreeDuration(consumerMonthlyCard.getFreeDuration().subtract(sOrder.getDuration()));
consumerMonthlyCardService.updateById(consumerMonthlyCard);
monthlyCardLogService.save(monthlyCardLog);
} else if (ObjectUtil.isNotEmpty(consumerSecondaryCard)) {
SecondaryCardLog secondaryCardLog = new SecondaryCardLog();
secondaryCardLog.setConsumerSecondaryCardId(consumerSecondaryCard.getId());
secondaryCardLog.setConsumerId(sOrder.getConsumerId());
secondaryCardLog.setPhone(sOrder.getConsumerPhone());
secondaryCardLog.setPackId(sOrder.getPackId());
secondaryCardLog.setUsageCount(1L);
secondaryCardLog.setResidueCount(consumerSecondaryCard.getNumber() - 1L);
consumerSecondaryCard.setNumber(consumerSecondaryCard.getNumber() - 1);
secondaryCardLogService.save(secondaryCardLog);
consumerSecondaryCardService.updateById(consumerSecondaryCard);
}
}
private void creatExtracted(ConsumerWallet consumerWallet, SOrder sOrder, ConsumerMember consumerMember) {
if (ObjectUtil.isNotEmpty(consumerWallet)) {
if (ObjectUtil.isNotEmpty(sOrder.getDuration()) && sOrder.getDuration().compareTo(BigDecimal.ZERO) > 0) {
......@@ -1210,7 +1210,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
MemberConfig one = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>()
// .eq(MemberConfig::getMemberType, consumerMember.getMemberType())
.eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel() + 1L));
// if (consumerMember.getMemberType().equals(MemberTypeEnum.NORMAL.getIndex())) {
if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex())) {
// consumerMember.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
if (ObjectUtil.isNotEmpty(one) && membershipProgress.compareTo(BigDecimal.valueOf(one.getLimitRequirements())) >= 0) {
......@@ -1467,7 +1466,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (redisUtil.exists(Constants.ORDER_LOCK_KEY_PREFIX + roomId)) {
throw new BaseException("当前房间下单太火爆了,请稍后再试!");
}
redisUtil.set(Constants.ORDER_LOCK_KEY_PREFIX + roomId, roomId, Long.valueOf(Constants.OPEN_DOOR_AHEAD_HOUR));
redisUtil.set(Constants.ORDER_LOCK_KEY_PREFIX + roomId, roomId, Long.valueOf(Constants.ROOM_LOCK_HOUR));
}
private void unLockOrder(CreateOrderRequest request,String keyValue) {
......@@ -1578,12 +1577,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// + "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' ");
//订单开始时间在 【预定开始时间 和 预定结束时间+30分保洁】区间内
//订单结束时间在 【预定开始时间-30分钟保洁 和 预定结束时间】区间内
queryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
// queryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
// + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreStartDate())
// + "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
// "OR IFNULL(end_date,pre_end_date) BETWEEN '"
// + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
// + "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' )");
queryWrapper.apply("IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' )");
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,
DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' ");
break;
default:
throw new BaseException("订单类型异常!");
......@@ -1607,20 +1610,24 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
if (request.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
if (!(DateUtils.addMinutes(lastOrder.getEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE).compareTo(request.getPreStartDate()) < 0)) {
unLockOrder(request.getRoomId());
throw new BaseException("下单时间已被预定!");
}
} else if (request.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
if (!(lastOrder.getEndDate().compareTo(request.getPreStartDate()) < 0)) {
unLockOrder(request.getRoomId());
throw new BaseException("下单时间已被预定!");
}
}
}
unLockOrder(request.getRoomId());
throw new BaseException("下单时间已被预定!");
}
if (request.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
List<SOrder> sOrderList = list(sOrderLambdaQueryWrapper);
List<SOrder> orders = list(orderLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(sOrderList) || CollectionUtils.isNotEmpty(orders)) {
unLockOrder(request.getRoomId());
throw new BaseException("下单时间已被预定!");
}
}
......@@ -1643,18 +1650,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
order.setBalance(priceResponse.getBalance());
order.setDuration(priceResponse.getDuration());
order.setDiscountRatio(priceResponse.getDiscountRatio());
if (ObjectUtil.isNotEmpty(request.getMonthlyCardId())) {
order.setMonthlyCardId(request.getMonthlyCardId());
}
if (ObjectUtil.isNotEmpty(request.getSecondaryCardId())) {
order.setSecondaryCardId(request.getSecondaryCardId());
}
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0
&& priceResponse.getDuration().compareTo(request.getDuration()) != 0
&& priceResponse.getBalance().compareTo(request.getBalance()) != 0
&& priceResponse.getDiscountRatio().compareTo(request.getDiscountRatio()) != 0
&& (ObjectUtil.isNotEmpty(request.getSecondaryCardId()) && priceResponse.getSecondaryCardId().compareTo(request.getSecondaryCardId()) != 0)
&& (ObjectUtil.isNotEmpty(request.getMonthlyCardId()) && priceResponse.getMonthlyCardId().compareTo(request.getMonthlyCardId()) != 0)
) {
throw new BaseException("订单金额异常!");
}
......@@ -2484,39 +2483,39 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
Activity activity = null;
// ConsumerMember consumerMember = null;
// ConsumerWallet consumerWallet = null;
ConsumerMember consumerMember = null;
ConsumerWallet consumerWallet = null;
ConsumerMonthlyCard consumerMonthlyCard = null;
List<ConsumerSecondaryCard> consumerSecondaryCardList = null;
LambdaQueryWrapper<Activity> queryWrapper = new LambdaQueryWrapper<>();
if (ObjectUtil.isNotEmpty(user)) {
// consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
// consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
consumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>().eq(ConsumerWallet::getConsumerId, user.getId()));
consumerMember = consumerMemberService.getOne(new LambdaQueryWrapper<ConsumerMember>().eq(ConsumerMember::getConsumerId, user.getId()));
consumerMonthlyCard = consumerMonthlyCardService.getOne(new LambdaQueryWrapper<ConsumerMonthlyCard>().eq(ConsumerMonthlyCard::getConsumerId, user.getId()));
consumerSecondaryCardList = consumerSecondaryCardService.list(new LambdaQueryWrapper<ConsumerSecondaryCard>().eq(ConsumerSecondaryCard::getConsumerId, user.getId())
.ne(ConsumerSecondaryCard::getNumber, YesNoEnum.no.getIndex())
);
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
//// if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
//// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
//// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
//// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
//// } else {
//// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
//// }
// if (consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
// queryWrapper.in(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex(), MemberTypeEnum.RIGHTS.getIndex());
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getIsOpen, YesNoEnum.yes.getIndex());
// if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
// } else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
//// activity.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
// } else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex())) {
//// activity.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
// } else {
// queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
// }
// }
if (consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.NORMAL.getIndex());
} else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex())) {
queryWrapper.in(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex(), MemberTypeEnum.RIGHTS.getIndex());
} else if (consumerMember.getIsRecharge().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRights().equals(YesNoEnum.no.getIndex())) {
// activity.setMemberType(MemberTypeEnum.RECHARGE.getIndex());
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RECHARGE.getIndex());
} else if (consumerMember.getIsRights().equals(YesNoEnum.yes.getIndex()) && consumerMember.getIsRecharge().equals(YesNoEnum.no.getIndex())) {
// activity.setMemberType(MemberTypeEnum.RIGHTS.getIndex());
queryWrapper.eq(Activity::getMemberType, MemberTypeEnum.RIGHTS.getIndex());
}
}
// if (ObjectUtil.isNotEmpty(consumerWallet)) {
// priceResponse.setAvailableBalance(consumerWallet.getBalance());
// priceResponse.setAvailableDuration(consumerWallet.getRemainingDuration());
......@@ -2533,18 +2532,17 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode());
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
// activity = activityService.getOne(queryWrapper);
// totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
//// priceResponse.setTotalFeeNow(totalFee);
//// priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
//// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
// }
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
}
......@@ -2555,15 +2553,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode());
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// queryWrapper.eq(Activity::getPackId, roomLabel.getPackId());
// activity = activityService.getOne(queryWrapper);
// totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
// priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
// }
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getPackId, roomLabel.getPackId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
}
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
}
......@@ -2577,15 +2576,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.TIME.getCode());
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
// activity = activityService.getOne(queryWrapper);
// totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
// priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
// }
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
priceResponse.setDiscountRatio(priceResponse.getDiscount());
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, room, request, consumerMember);
}
if (ObjectUtil.isNotEmpty(consumerMonthlyCard)) {
totalFee = getBigDecimal(consumerMonthlyCard, timeLong, priceResponse, totalPrice, room);
}
......@@ -2599,20 +2599,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setTotalFee(payPrice);
priceResponse.setTotalFeeNow(payPrice);
request.setBuyType(BuyTypeEnum.PACK.getCode());
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// queryWrapper.eq(Activity::getPackId, request.getPackId());
// activity = activityService.getOne(queryWrapper);
// totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
// priceResponse.setTotalFeeNow(totalFee);
// priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
// priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
// }
// if(ObjectUtil.isNotEmpty(consumerMonthlyCard)){
// totalFee = getBigDecimal(consumerMonthlyCard,timeLong,priceResponse,totalFee,room);
// }
if (CollectionUtils.isNotEmpty(consumerSecondaryCardList)) {
totalFee = getBigDecimal(consumerSecondaryCardList, priceResponse, byId, payPrice);
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getPackId, request.getPackId());
activity = activityService.getOne(queryWrapper);
totalFee = getBigDecimal(request, activity, payPrice, user, consumerMember);
priceResponse.setTotalFeeNow(totalFee);
priceResponse.setMemberDiscount(payPrice.subtract(totalFee));
priceResponse.setDiscount(totalFee.divide(payPrice, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
totalFee = getBigDecimal(consumerWallet, activity, timeLong, priceResponse, totalFee, byId, request);
}
}
......@@ -2632,11 +2626,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// } else {
// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// }
if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
} else {
priceResponse.setDiscountRatio(new BigDecimal(0));
}
// if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// } else {
// priceResponse.setDiscountRatio(new BigDecimal(0));
// }
} else {
// 判断优惠券是否可以使用
if (Objects.nonNull(user) && Objects.nonNull(request.getCouponId())) {
......@@ -2651,52 +2645,65 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse.setRemainingBalance(new BigDecimal(0));
priceResponse.setRemainingDuration(new BigDecimal(0));
if (priceResponse.getPayFee().compareTo(new BigDecimal(0)) > 0) {
// if (ObjectUtil.isNotEmpty(consumerMember)) {
// MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
//
// BigDecimal payFee = priceResponse.getPayFee();
// BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
// if (payFee.compareTo(divide) == 0) {
// priceResponse.setDiscount(BigDecimal.ZERO);
// }
// //总金额乘以折扣比例除以100
// priceResponse.setPayFee(divide);
// priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
// priceResponse.setTotalFeeNow(divide);
// priceResponse.setMemberDiscount(payFee.subtract(divide));
//// priceResponse.setCouponFee(priceResponse.getDiscountFee());
// if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// } else {
// priceResponse.setDiscountRatio(new BigDecimal(0));
// }
// }
// if (ObjectUtil.isNotEmpty(consumerWallet)) {
// if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) {
// priceResponse.setBalance(priceResponse.getPayFee());
// priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee()));
// totalFee = new BigDecimal(0);
// } else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) {
// priceResponse.setBalance(consumerWallet.getBalance());
// totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance());
// }
// priceResponse.setPayFee(totalFee);
// }
// if (ObjectUtil.isEmpty(consumerWallet) && ObjectUtil.isEmpty(consumerMember)) {
// priceResponse.setTotalFeeNow(priceResponse.getPayFee());
// priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
// }
if (ObjectUtil.isNotEmpty(consumerWallet) && ObjectUtil.isNotEmpty(consumerMember)) {
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getMembershipLevel, consumerMember.getMembershipLevel()));
if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) >= 0) {
BigDecimal payFee = priceResponse.getPayFee();
BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
if (payFee.compareTo(divide) == 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
}
//总金额乘以折扣比例除以100
priceResponse.setPayFee(divide);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(payFee.subtract(divide));
priceResponse.setBalance(priceResponse.getPayFee());
priceResponse.setRemainingBalance(consumerWallet.getBalance().subtract(priceResponse.getPayFee()));
totalFee = new BigDecimal(0);
} else if (consumerWallet.getBalance().compareTo(priceResponse.getPayFee()) < 0) {
priceResponse.setBalance(consumerWallet.getBalance());
totalFee = priceResponse.getPayFee().subtract(consumerWallet.getBalance());
}
priceResponse.setPayFee(totalFee);
priceResponse.setTotalFeeNow(totalFee);
if (priceResponse.getPayFee().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal payFee = priceResponse.getPayFee();
BigDecimal divide = priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
if (payFee.compareTo(divide) == 0) {
priceResponse.setDiscount(BigDecimal.ZERO);
}
//总金额乘以折扣比例除以100
priceResponse.setPayFee(divide);
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setTotalFeeNow(divide);
priceResponse.setMemberDiscount(payFee.subtract(divide));
// priceResponse.setCouponFee(priceResponse.getDiscountFee());
// if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// } else {
// priceResponse.setDiscountRatio(new BigDecimal(0));
// }
}
}
// priceResponse.setDiscount(priceResponse.getPayFee().divide(priceResponse.getTotalFeeNow(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
if (ObjectUtil.isEmpty(consumerWallet) && ObjectUtil.isEmpty(consumerMember)) {
priceResponse.setTotalFeeNow(priceResponse.getPayFee());
priceResponse.setMemberDiscount(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
}
} else {
priceResponse.setDiscount(BigDecimal.ZERO);
}
}
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
} else {
priceResponse.setDiscountRatio(new BigDecimal(0));
}
// if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
// priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
// } else {
// priceResponse.setDiscountRatio(new BigDecimal(0));
// }
}
return priceResponse;
}
......@@ -2929,46 +2936,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return payPrice;
}
private BigDecimal getBigDecimal(ConsumerMonthlyCard consumerMonthlyCard, BigDecimal timeLong,
ComputedOrderPriceResponse priceResponse, BigDecimal totalFee, SRoom room) {
if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) >= 0) {
priceResponse.setDuration(timeLong);
priceResponse.setRemainingDuration(consumerMonthlyCard.getFreeDuration().subtract(timeLong));
priceResponse.setDiscount(BigDecimal.ZERO);
totalFee = new BigDecimal(0);
priceResponse.setMemberDiscount(new BigDecimal(0.00));
priceResponse.setTotalFeeNow(priceResponse.getTotalFee());
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
} else if (consumerMonthlyCard.getFreeDuration().compareTo(timeLong) < 0) {
priceResponse.setDuration(consumerMonthlyCard.getFreeDuration());
priceResponse.setRemainingDuration(new BigDecimal(0));
BigDecimal remainingBalance = consumerMonthlyCard.getFreeDuration().multiply(room.getPrice());
remainingBalance = totalFee.subtract(remainingBalance);
priceResponse.setTotalFeeNow(remainingBalance);
priceResponse.setMemberDiscount(totalFee.subtract(remainingBalance));
totalFee = remainingBalance;
priceResponse.setPayFee(remainingBalance);
priceResponse.setMonthlyCardId(consumerMonthlyCard.getId());
}
return totalFee;
}
private BigDecimal getBigDecimal(List<ConsumerSecondaryCard> consumerSecondaryCardList,
ComputedOrderPriceResponse priceResponse, SPack byId, BigDecimal payPrice) {
//获取集合中次数最少的次卡,次数不低于0
ConsumerSecondaryCard consumerSecondaryCard = consumerSecondaryCardList.stream().min(Comparator.comparing(ConsumerSecondaryCard::getNumber)).get();
if (consumerSecondaryCard.getPackId().equals(byId.getId())) {
priceResponse.setDiscount(BigDecimal.ZERO);
priceResponse.setMemberDiscount(BigDecimal.ZERO);
priceResponse.setTotalFeeNow(payPrice);
priceResponse.setPayFee(BigDecimal.ZERO);
priceResponse.setSecondaryCardId(consumerSecondaryCard.getId());
payPrice = BigDecimal.ZERO;
}
return payPrice;
}
private BigDecimal computeTotalPrice(Long packId, BigDecimal totalPrice) {
SPack pack = packService.getById(packId);
if (Objects.isNull(pack)) {
......
package share.system.service.impl;
import java.time.YearMonth;
import java.util.List;
import java.util.Set;
import java.util.*;
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.poi.hssf.record.DVALRecord;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.core.redis.RedisUtil;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.StringUtils;
import share.system.domain.SConsumer;
import share.system.domain.vo.SharingActivitiesVo;
import share.system.mapper.SharingActivitiesMapper;
import share.system.domain.SharingActivities;
import share.system.service.SConsumerService;
import share.system.service.SharingActivitiesService;
import javax.annotation.Resource;
/**
* 分享活动绑定关系Service业务层处理
*
......@@ -30,7 +39,7 @@ import share.system.service.SharingActivitiesService;
@Service
public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesMapper, SharingActivities> implements SharingActivitiesService
{
@Autowired
@Resource
private SharingActivitiesMapper sharingActivitiesMapper;
@Autowired
......@@ -39,6 +48,10 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询分享活动绑定关系
*
......@@ -60,6 +73,8 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
@Override
public List<SharingActivities> selectSharingActivitiesList(SharingActivities sharingActivities)
{
return sharingActivitiesMapper.selectSharingActivitiesList(sharingActivities);
}
......@@ -88,9 +103,9 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
{
SConsumer consumer = consumerService.selectSConsumerById(sharingActivities.getUid());
sharingActivities.setUpdateTime(DateUtils.getNowDate());
sharingActivities.setAvatar(consumer.getAvatar());
sharingActivities.setPhone(consumer.getPhone());
sharingActivities.setNickName(consumer.getNickName());
// sharingActivities.setAvatar(consumer.getAvatar());
// sharingActivities.setPhone(consumer.getPhone());
// sharingActivities.setNickName(consumer.getNickName());
return sharingActivitiesMapper.updateSharingActivities(sharingActivities);
}
......@@ -118,6 +133,70 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
return sharingActivitiesMapper.deleteSharingActivitiesById(id);
}
@Override
public int selectSharingActivitiesCount(SharingActivities sharingActivities) {
return sharingActivitiesMapper.selectCount(new LambdaQueryWrapper<SharingActivities>()
.eq(SharingActivities::getUid,sharingActivities.getUid())
.eq(SharingActivities::getIsDelete,YesNoEnum.no.getIndex()));
}
@Override
public TableDataInfo pageList(TableDataInfo info,SharingActivitiesVo sharingActivities) {
List<SharingActivitiesVo> voList = new ArrayList<>();
List<SharingActivities> activities =(List<SharingActivities>) info.getRows();
if (CollectionUtils.isEmpty(activities)){
return info;
}
List<Long> collect = activities.stream().map(SharingActivities::getNewUid).collect(Collectors.toList());
List<Long> uids = activities.stream().map(SharingActivities::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(sharingActivities.getNewNickName())){
newSConsumer.like(SConsumer::getNickName,sharingActivities.getNewNickName());
}
if(StringUtils.isNotEmpty(sharingActivities.getNewPhone())){
newSConsumer.like(SConsumer::getPhone,sharingActivities.getNewPhone());
}
if(StringUtils.isNotEmpty(sharingActivities.getNickName())){
uSConsumer.like(SConsumer::getNickName,sharingActivities.getNickName());
}
if(StringUtils.isNotEmpty(sharingActivities.getPhone())){
uSConsumer.like(SConsumer::getPhone,sharingActivities.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 ->{
SharingActivitiesVo vo = new SharingActivitiesVo();
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);
});
info.setRows(voList);
return info;
}
}
<?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
......@@ -18,23 +18,15 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="phone" column="phone" />
<result property="account" column="account" />
<result property="nickName" column="nick_name" />
<result property="newPhone" column="new_phone" />
<result property="newAccount" column="new_account" />
<result property="newNickName" column="new_nick_name" />
<result property="avatar" column="avatar" />
<result property="newAvatar" column="new_avatar" />
</resultMap>
<sql id="selectEquityFundLogVo">
select id, equity_fund_type, equity_fund, uid, new_uid, terminal_trace, out_trade_no, is_delete, create_by, create_time, update_by, update_time, remark, phone, account, nick_name, new_phone, new_account, new_nick_name, avatar, new_avatar from s_equity_fund_log
select id, equity_fund_type, equity_fund, uid, new_uid, terminal_trace, out_trade_no, is_delete, create_by, create_time, update_by, update_time, remark from s_equity_fund_log
</sql>
<select id="selectEquityFundLogList" parameterType="EquityFundLog" resultMap="EquityFundLogResult">
<include refid="selectEquityFundLogVo"/>
<where>
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>
......@@ -42,15 +34,7 @@
<if test="terminalTrace != null and terminalTrace != ''"> and terminal_trace = #{terminalTrace}</if>
<if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="account != null and account != ''"> and account = #{account}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="newPhone != null and newPhone != ''"> and new_phone = #{newPhone}</if>
<if test="newAccount != null and newAccount != ''"> and new_account = #{newAccount}</if>
<if test="newNickName != null and newNickName != ''"> and new_nick_name like concat('%', #{newNickName}, '%')</if>
<if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
<if test="newAvatar != null and newAvatar != ''"> and new_avatar = #{newAvatar}</if>
</where>
order by create_time desc
</select>
<select id="selectEquityFundLogById" parameterType="Long" resultMap="EquityFundLogResult">
......@@ -73,14 +57,6 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="phone != null">phone,</if>
<if test="account != null">account,</if>
<if test="nickName != null">nick_name,</if>
<if test="newPhone != null">new_phone,</if>
<if test="newAccount != null">new_account,</if>
<if test="newNickName != null">new_nick_name,</if>
<if test="avatar != null">avatar,</if>
<if test="newAvatar != null">new_avatar,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="equityFundType != null and equityFundType != ''">#{equityFundType},</if>
......@@ -95,14 +71,6 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="phone != null">#{phone},</if>
<if test="account != null">#{account},</if>
<if test="nickName != null">#{nickName},</if>
<if test="newPhone != null">#{newPhone},</if>
<if test="newAccount != null">#{newAccount},</if>
<if test="newNickName != null">#{newNickName},</if>
<if test="avatar != null">#{avatar},</if>
<if test="newAvatar != null">#{newAvatar},</if>
</trim>
</insert>
......@@ -121,14 +89,6 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="account != null">account = #{account},</if>
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="newPhone != null">new_phone = #{newPhone},</if>
<if test="newAccount != null">new_account = #{newAccount},</if>
<if test="newNickName != null">new_nick_name = #{newNickName},</if>
<if test="avatar != null">avatar = #{avatar},</if>
<if test="newAvatar != null">new_avatar = #{newAvatar},</if>
</trim>
where id = #{id}
</update>
......
......@@ -126,6 +126,7 @@
from s_consumer t1
left join s_store_consumer t2 on t2.consumer_id = t1.id
where t1.role_type = '1'
and t2.position = '1'
and t1.id in (select consumer_id from s_store_consumer where store_id = #{storeId} and position = '1')
</select>
......
......@@ -15,32 +15,21 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="avatar" column="avatar" />
<result property="newAvatar" column="new_avatar" />
<result property="nickName" column="nick_name" />
<result property="newNickName" column="new_nick_name" />
<result property="phone" column="phone" />
<result property="newPhone" column="new_phone" />
</resultMap>
<sql id="selectSharingActivitiesVo">
select id, activity_type, uid, new_uid, is_delete, create_by, create_time, update_by, update_time, remark, avatar, new_avatar, nick_name, new_nick_name, phone, new_phone from s_sharing_activities
select id, activity_type, uid, new_uid, is_delete, create_by, create_time, update_by, update_time, remark
from s_sharing_activities
</sql>
<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>
<if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
<if test="newAvatar != null and newAvatar != ''"> and new_avatar = #{newAvatar}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="newNickName != null and newNickName != ''"> and new_nick_name like concat('%', #{newNickName}, '%')</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="newPhone != null and newPhone != ''"> and new_phone = #{newPhone}</if>
</where>
order by create_time desc
</select>
<select id="selectSharingActivitiesById" parameterType="Long" resultMap="SharingActivitiesResult">
......@@ -60,12 +49,6 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="avatar != null">avatar,</if>
<if test="newAvatar != null">new_avatar,</if>
<if test="nickName != null">nick_name,</if>
<if test="newNickName != null">new_nick_name,</if>
<if test="phone != null">phone,</if>
<if test="newPhone != null">new_phone,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="activityType != null and activityType != ''">#{activityType},</if>
......@@ -77,12 +60,6 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="avatar != null">#{avatar},</if>
<if test="newAvatar != null">#{newAvatar},</if>
<if test="nickName != null">#{nickName},</if>
<if test="newNickName != null">#{newNickName},</if>
<if test="phone != null">#{phone},</if>
<if test="newPhone != null">#{newPhone},</if>
</trim>
</insert>
......@@ -97,13 +74,6 @@
<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>
<if test="avatar != null">avatar = #{avatar},</if>
<if test="newAvatar != null">new_avatar = #{newAvatar},</if>
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="newNickName != null">new_nick_name = #{newNickName},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="newPhone != null">new_phone = #{newPhone},</if>
</trim>
where id = #{id}
</update>
......
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