Commit 52cb8a7a by YG8429

临时权益金增加返佣状态字段,人工退款增加删除临时权益金记录表,绑定关系增加查询

parent 5ba32614
......@@ -65,7 +65,8 @@ public class SharingActivitiesController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:activities:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(sharingActivitiesService.selectSharingActivitiesById(id));
return success(sharingActivitiesService.selectSharingActivitiesUserById(id));
}
/**
......
......@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -656,10 +657,11 @@ public class RedisTask {
}
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));
.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<EquityFundExcess> ids = new ArrayList<>();
list.stream().forEach(item->{
ConsumerWallet consumerWallet = consumerWalletMap.get(item.getUid());
consumerWallet.setEquityFund(consumerWallet.getEquityFund().add(item.getEquityFund()));
......@@ -675,7 +677,8 @@ public class RedisTask {
equityFundLogList.add(equityFundLog);
item.setIsDelete(YesNoEnum.yes.getIndex());
ids.add(item.getId());
item.setRebateType(YesNoEnum.yes.getIndex());
ids.add(item);
});
if (CollectionUtil.isNotEmpty(consumerWalletList)){
consumerWalletService.updateBatchById(consumerWalletList);
......@@ -684,7 +687,7 @@ public class RedisTask {
equityFundLogService.saveBatch(equityFundLogList);
}
if (CollectionUtil.isNotEmpty(ids)){
equityFundExcessService.removeByIds(ids);
equityFundExcessService.updateBatchById(ids);
}
logger.debug("AutoEquityFundExcess:权益金增加结束");
}
......
......@@ -50,6 +50,9 @@ public class EquityFundExcess extends BaseEntity
@TableField(select = false)
private Integer isDelete;
@Excel(name = "返佣状态(0-未返佣,1-已返佣)")
private Integer rebateType;
@Override
public String toString() {
......
......@@ -67,4 +67,6 @@ public interface SharingActivitiesService extends IService<SharingActivities>
int selectSharingActivitiesCount(SharingActivities sharingActivities);
TableDataInfo pageList(TableDataInfo info,SharingActivitiesVo sharingActivities);
SharingActivitiesVo selectSharingActivitiesUserById(Long id);
}
......@@ -159,8 +159,6 @@ public class EquityFundExcessServiceImpl extends ServiceImpl<EquityFundExcessMap
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()));
......@@ -259,7 +257,7 @@ public class EquityFundExcessServiceImpl extends ServiceImpl<EquityFundExcessMap
ConsumerWallet consumerWallet = consumerWalletService.getOne(consumerWalletLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(consumerWallet)) {
//添加时长
BigDecimal anHour = new BigDecimal(1.0);
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());
......@@ -275,13 +273,13 @@ public class EquityFundExcessServiceImpl extends ServiceImpl<EquityFundExcessMap
} else {
//新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet();
BigDecimal defaultVlue = new BigDecimal(0.0);
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);
BigDecimal anHour = new BigDecimal("1.0");
newConsumerWallet.setRemainingDuration(defaultVlue.add(anHour));
newConsumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.insertConsumerWallet(newConsumerWallet);
......@@ -336,6 +334,7 @@ public class EquityFundExcessServiceImpl extends ServiceImpl<EquityFundExcessMap
equityFundExcess.setOutTradeNo(sOrder.getOrderNo());
equityFundExcess.setUid(sharingActivities.getUid());
equityFundExcess.setNewUid(sharingActivities.getNewUid());
equityFundExcess.setRebateType(YesNoEnum.no.getIndex());
equityFundExcessService.insertEquityFundExcess(equityFundExcess);
}
}
......
......@@ -22,6 +22,7 @@ import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import share.common.utils.StringUtils;
import share.system.domain.*;
import share.system.domain.vo.*;
import share.system.mapper.ConsumerMemberMapper;
......@@ -355,6 +356,12 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
.ne(ConsumerMember::getConsumerId,sConsumer.getNewId()));
List<Long> collect = consumerMembers.stream().map(ConsumerMember::getConsumerId).collect(Collectors.toList());
LambdaQueryWrapper<SConsumer> uSConsumer = new LambdaQueryWrapper<SConsumer>();
if (StringUtils.isNotEmpty(sConsumer.getPhone())){
uSConsumer.like(SConsumer::getPhone,sConsumer.getPhone());
}
if (StringUtils.isNotEmpty(sConsumer.getNickName())){
uSConsumer.like(SConsumer::getNickName,sConsumer.getNickName());
}
uSConsumer.in(SConsumer::getId,collect);
int count = consumerMemberService.count(
new LambdaQueryWrapper<ConsumerMember>()
......@@ -362,7 +369,7 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
.ne(ConsumerMember::getConsumerId, sConsumer.getNewId()));
List<SConsumer> userMap = sConsumerService.list(uSConsumer);
int start = (sConsumer.getPageNum() - 1) * sConsumer.getPageSize();
int end = Math.min(start + sConsumer.getPageSize(), count);
int end = Math.min(start + sConsumer.getPageSize(), userMap.size());
List<SConsumer> pagedList = userMap.subList(start, end);
TableDataInfo tableDataInfo = new TableDataInfo();
tableDataInfo.setRows(pagedList);
......
......@@ -179,6 +179,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
private EquityFundLogService equityFundLogService;
@Autowired
private EquityFundExcessService equityFundExcessService;
private final static Long FIVE = 5L;
......@@ -485,28 +488,26 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
if (request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
// if (sOrder.getStatus().equals(OrderStatusEnum.USED.getCode())) {
// //查询次订单用户有没有上级用户
// SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
// .eq(SharingActivities::getNewUid, sOrder.getConsumerId()));
// if (ObjectUtil.isNotEmpty(sharingActivities)) {
// //查询权益金日志记录
// EquityFundLog equityFundLog = equityFundLogService.getOne(new LambdaQueryWrapper<EquityFundLog>()
// .eq(EquityFundLog::getNewUid,sOrder.getConsumerId())
// .eq(EquityFundLog::getOutTradeNo,sOrder.getOrderNo())
// .eq(EquityFundLog::getTerminalTrace,sOrder.getOutTradeNo()));
// if (ObjectUtil.isNotEmpty(equityFundLog)){
// ConsumerWallet aConsumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
// .eq(ConsumerWallet::getConsumerId,sharingActivities.getUid()));
// aConsumerWallet.setEquityFund(aConsumerWallet.getEquityFund().subtract(equityFundLog.getEquityFund()));
// aConsumerWallet.setAccumulateEquityFund(aConsumerWallet.getAccumulateEquityFund().subtract(equityFundLog.getEquityFund()));
// consumerWalletService.updateConsumerWallet(aConsumerWallet);
// equityFundLog.setEquityFundType(EquityFundTypeEnum.ORDER_REFUND.getCode());
// equityFundLog.setEquityFund(equityFundLog.getEquityFund().negate());
// equityFundLogService.insertEquityFundLog(equityFundLog);
// }
// }
// }
if (sOrder.getStatus().equals(OrderStatusEnum.USED.getCode())) {
//查询次订单用户有没有上级用户
SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
.eq(SharingActivities::getNewUid, sOrder.getConsumerId()));
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询临时权益金记录表
EquityFundExcess equityFundExcess = equityFundExcessService.getOne(new LambdaQueryWrapper<EquityFundExcess>()
.eq(EquityFundExcess::getNewUid,sOrder.getConsumerId())
.eq(EquityFundExcess::getOutTradeNo,sOrder.getOrderNo())
.eq(EquityFundExcess::getRebateType,YesNoEnum.no.getIndex()));
if (ObjectUtil.isNotEmpty(equityFundExcess)){
ConsumerWallet aConsumerWallet = consumerWalletService.getOne(new LambdaQueryWrapper<ConsumerWallet>()
.eq(ConsumerWallet::getConsumerId,sharingActivities.getUid()));
aConsumerWallet.setEquityFund(aConsumerWallet.getEquityFund().subtract(equityFundExcess.getEquityFund()));
aConsumerWallet.setAccumulateEquityFund(aConsumerWallet.getAccumulateEquityFund().subtract(equityFundExcess.getEquityFund()));
consumerWalletService.updateConsumerWallet(aConsumerWallet);
equityFundExcessService.removeById(equityFundExcess.getId());
}
}
}
// 退款金额大于0, 微信退款
//退款
if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode())) {
......
......@@ -8,6 +8,7 @@ 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 lombok.val;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.record.DVALRecord;
import org.springframework.beans.BeanUtils;
......@@ -198,5 +199,23 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
return info;
}
@Override
public SharingActivitiesVo selectSharingActivitiesUserById(Long id) {
SharingActivities sharingActivities = sharingActivitiesMapper.selectSharingActivitiesById(id);
Long uid = sharingActivities.getUid();
Long newUid = sharingActivities.getNewUid();
SharingActivitiesVo vo = new SharingActivitiesVo();
SConsumer sConsumer = sConsumerService.selectSConsumerById(uid);
SConsumer newConsumer = sConsumerService.selectSConsumerById(newUid);
BeanUtils.copyProperties(sharingActivities, vo);
if(ObjectUtil.isNotEmpty(sConsumer)){
vo.setPhone(StringUtils.isNotEmpty(sConsumer.getPhone()) ? sConsumer.getPhone():"");
vo.setNickName(StringUtils.isNotEmpty(sConsumer.getNickName()) ? sConsumer.getNickName():"");
}
if(ObjectUtil.isNotEmpty(newConsumer)){
vo.setNewPhone(StringUtils.isNotEmpty(newConsumer.getPhone()) ? newConsumer.getPhone():"");
vo.setNewNickName(StringUtils.isNotEmpty(newConsumer.getNickName()) ? newConsumer.getNickName():"");
}
return vo;
}
}
......@@ -11,6 +11,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.transferbatch.TransferBatchService;
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferRequest;
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
......
......@@ -17,10 +17,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="rebateType" column="rebate_type" />
</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
select id, equity_fund, uid, new_uid, out_trade_no, expire_time, is_delete, create_by, create_time, update_by, update_time, remark,rebate_type from s_equity_fund_excess
</sql>
<select id="selectEquityFundExcessList" parameterType="EquityFundExcess" resultMap="EquityFundExcessResult">
......@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="rebateType != null">rebate_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="equityFund != null">#{equityFund},</if>
......@@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="rebateType != null">#{rebate_type},</if>
</trim>
</insert>
......@@ -85,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="rebateType != null">remark = #{rebate_type},</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