Commit 6c2bec7c by YG8429

新增权益分享绑定,微信支付回调新增充值、权益消费验证是否绑定活动并返利3%并增加日志

parent c3ced9b9
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.EquityFundLog;
import share.system.service.EquityFundLogService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
/**
* 权益金记录Controller
*
* @author wuwenlong
* @date 2024-09-10
*/
@RestController
@RequestMapping("/system/equityFundLog")
public class EquityFundLogController extends BaseController
{
@Autowired
private EquityFundLogService equityFundLogService;
/**
* 查询权益金记录列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:list')")
@GetMapping("/list")
public TableDataInfo list(EquityFundLog equityFundLog)
{
startPage();
List<EquityFundLog> list = equityFundLogService.selectEquityFundLogList(equityFundLog);
return getDataTable(list);
}
/**
* 导出权益金记录列表
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:export')")
@Log(title = "权益金记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, EquityFundLog equityFundLog)
{
List<EquityFundLog> list = equityFundLogService.selectEquityFundLogList(equityFundLog);
ExcelUtil<EquityFundLog> util = new ExcelUtil<EquityFundLog>(EquityFundLog.class);
util.exportExcel(response, list, "权益金记录数据");
}
/**
* 获取权益金记录详细信息
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(equityFundLogService.selectEquityFundLogById(id));
}
/**
* 新增权益金记录
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:add')")
@Log(title = "权益金记录", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody EquityFundLog equityFundLog)
{
return toAjax(equityFundLogService.insertEquityFundLog(equityFundLog));
}
/**
* 修改权益金记录
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:edit')")
@Log(title = "权益金记录", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody EquityFundLog equityFundLog)
{
return toAjax(equityFundLogService.updateEquityFundLog(equityFundLog));
}
/**
* 删除权益金记录
*/
@PreAuthorize("@ss.hasPermi('system:equityFundLog:remove')")
@Log(title = "权益金记录", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(equityFundLogService.deleteEquityFundLogByIds(ids));
}
}
......@@ -2,6 +2,7 @@ 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;
......@@ -23,14 +24,13 @@ import share.common.core.page.TableDataInfo;
/**
* 分享活动绑定关系Controller
*
*
* @author wuwenlong
* @date 2024-09-02
*/
@RestController
@RequestMapping("/system/activities")
public class SharingActivitiesController extends BaseController
{
public class SharingActivitiesController extends BaseController {
@Autowired
private SharingActivitiesService sharingActivitiesService;
......@@ -39,8 +39,7 @@ public class SharingActivitiesController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:activities:list')")
@GetMapping("/list")
public TableDataInfo list(SharingActivities sharingActivities)
{
public TableDataInfo list(SharingActivities sharingActivities) {
startPage();
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
return getDataTable(list);
......@@ -52,8 +51,7 @@ public class SharingActivitiesController extends BaseController
@PreAuthorize("@ss.hasPermi('system:activities:export')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SharingActivities sharingActivities)
{
public void export(HttpServletResponse response, SharingActivities sharingActivities) {
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
ExcelUtil<SharingActivities> util = new ExcelUtil<SharingActivities>(SharingActivities.class);
util.exportExcel(response, list, "分享活动绑定关系数据");
......@@ -64,8 +62,7 @@ public class SharingActivitiesController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:activities:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(sharingActivitiesService.selectSharingActivitiesById(id));
}
......@@ -75,19 +72,31 @@ public class SharingActivitiesController extends BaseController
@PreAuthorize("@ss.hasPermi('system:activities:add')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SharingActivities sharingActivities)
{
public AjaxResult add(@RequestBody SharingActivities sharingActivities) {
return toAjax(sharingActivitiesService.insertSharingActivities(sharingActivities));
}
/**
* 新增分享活动绑定关系
*/
// @PreAuthorize("@ss.hasPermi('system:activities:addSharingActivities')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.INSERT)
@PostMapping("/addSharingActivities")
public AjaxResult addSharingActivities(@RequestBody SharingActivities sharingActivities) {
AjaxResult ajaxResult = sharingActivitiesService.addSharingActivities(sharingActivities);
return ajaxResult;
}
/**
* 修改分享活动绑定关系
*/
@PreAuthorize("@ss.hasPermi('system:activities:edit')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SharingActivities sharingActivities)
{
public AjaxResult edit(@RequestBody SharingActivities sharingActivities) {
return toAjax(sharingActivitiesService.updateSharingActivities(sharingActivities));
}
......@@ -96,9 +105,8 @@ public class SharingActivitiesController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:activities:remove')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(sharingActivitiesService.deleteSharingActivitiesByIds(ids));
}
}
......@@ -32,6 +32,7 @@ import share.system.domain.vo.MqttxVo;
import share.system.service.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
......@@ -110,6 +111,15 @@ public class RedisTask {
@Autowired
private SharingActivitiesService sharingActivitiesService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private SConsumerService consumerService;
@Autowired
private EquityFundLogService equityFundLogService;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
......@@ -339,6 +349,8 @@ public class RedisTask {
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getNewUid,sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getActivityType,"0");
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getIsDelete,YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)){
LambdaQueryWrapper<ConsumerWallet> consumerWalletLambdaQueryWrapper = new LambdaQueryWrapper<>();
......@@ -354,21 +366,69 @@ public class RedisTask {
//新增钱包
ConsumerWallet newConsumerWallet = new ConsumerWallet();
BigDecimal defaultVlue = new BigDecimal(0.0);
newConsumerWallet.setCreateTime(DateUtils.getNowDate());
newConsumerWallet.setConsumerId(sharingActivities.getUid());
newConsumerWallet.setBalance(defaultVlue);
newConsumerWallet.setRemainingIntegral(defaultVlue);
newConsumerWallet.setRemainingDuration(defaultVlue);
newConsumerWallet.setEquityFund(defaultVlue);
newConsumerWallet.setAccumulateEquityFund(defaultVlue);
consumerWalletService.save(newConsumerWallet);
BigDecimal anHour = new BigDecimal(1.0);
newConsumerWallet.setRemainingDuration(newConsumerWallet.getRemainingDuration().add(anHour));
newConsumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(newConsumerWallet);
consumerWalletService.insertConsumerWallet(newConsumerWallet);
}
}
}
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getNewUid,sOrder.getConsumerId());
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getActivityType,"1");
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getIsDelete,YesNoEnum.no.getIndex());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)){
//查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerMemberLambdaQueryWrapper.eq(ConsumerMember::getConsumerId,sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberLambdaQueryWrapper);
//判断是否为权益会员和会员是否有效
if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime() ){
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (aBoolean){
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");
consumerWallet.setEquityFund(consumerWallet.getEquityFund().add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
consumerWallet.setAccumulateEquityFund(consumerWallet.getAccumulateEquityFund().
add(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP))));
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(payPrice.multiply(new BigDecimal(equityFund).setScale(2, RoundingMode.HALF_UP)));
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.setNewPhone(newConsumer.getPhone());
equityFundLog.setNewAccount(newConsumer.getAccount());
equityFundLog.setNewNickName(newConsumer.getNickName());
equityFundLogService.insertEquityFundLog(equityFundLog);
}
}
}
}
if (extracted(o, sOrders, sOrder)) return;
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
......
package share.system.domain;
import java.math.BigDecimal;
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 lombok.Data;
/**
* 权益金记录对象 s_equity_fund_log
*
* @author wuwenlong
* @date 2024-09-10
*/
@Data
@TableName(value = "s_equity_fund_log")
public class EquityFundLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.AUTO)
private Long id;
/** 权益金类型(0-充值,1-权益订单) */
@Excel(name = "权益金类型(0-充值,1-权益订单)")
private String equityFundType;
/** 权益金额 */
@Excel(name = "权益金额")
private BigDecimal equityFund;
/** 上级id */
@Excel(name = "上级id")
private Long uid;
/** 下级id */
@Excel(name = "下级id")
private Long newUid;
/** 终端流水号 */
@Excel(name = "终端流水号")
private String terminalTrace;
/** 订单号 */
@Excel(name = "订单号")
private String outTradeNo;
/** 删除标记:1-删除,0-正常 */
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long 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;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("equityFundType", getEquityFundType())
.append("equityFund", getEquityFund())
.append("uid", getUid())
.append("newUid", getNewUid())
.append("terminalTrace", getTerminalTrace())
.append("outTradeNo", getOutTradeNo())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
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
......@@ -21,6 +19,7 @@ public class SharingActivities extends BaseEntity
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(type = IdType.AUTO)
private Long id;
/** 活动类型(0-新用户注册,1-权益金会员分享) */
......
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.EquityFundLog;
/**
* 权益金记录Mapper接口
*
* @author wuwenlong
* @date 2024-09-10
*/
public interface EquityFundLogMapper extends BaseMapper<EquityFundLog>
{
/**
* 查询权益金记录
*
* @param id 权益金记录主键
* @return 权益金记录
*/
public EquityFundLog selectEquityFundLogById(Long id);
/**
* 查询权益金记录列表
*
* @param equityFundLog 权益金记录
* @return 权益金记录集合
*/
public List<EquityFundLog> selectEquityFundLogList(EquityFundLog equityFundLog);
/**
* 新增权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
public int insertEquityFundLog(EquityFundLog equityFundLog);
/**
* 修改权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
public int updateEquityFundLog(EquityFundLog equityFundLog);
/**
* 删除权益金记录
*
* @param id 权益金记录主键
* @return 结果
*/
public int deleteEquityFundLogById(Long id);
/**
* 批量删除权益金记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEquityFundLogByIds(Long[] ids);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.EquityFundLog;
/**
* 权益金记录Service接口
*
* @author wuwenlong
* @date 2024-09-10
*/
public interface EquityFundLogService extends IService<EquityFundLog>
{
/**
* 查询权益金记录
*
* @param id 权益金记录主键
* @return 权益金记录
*/
public EquityFundLog selectEquityFundLogById(Long id);
/**
* 查询权益金记录列表
*
* @param equityFundLog 权益金记录
* @return 权益金记录集合
*/
public List<EquityFundLog> selectEquityFundLogList(EquityFundLog equityFundLog);
/**
* 新增权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
public int insertEquityFundLog(EquityFundLog equityFundLog);
/**
* 修改权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
public int updateEquityFundLog(EquityFundLog equityFundLog);
/**
* 批量删除权益金记录
*
* @param ids 需要删除的权益金记录主键集合
* @return 结果
*/
public int deleteEquityFundLogByIds(Long[] ids);
/**
* 删除权益金记录信息
*
* @param id 权益金记录主键
* @return 结果
*/
public int deleteEquityFundLogById(Long id);
}
......@@ -2,6 +2,7 @@ package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.domain.AjaxResult;
import share.system.domain.SharingActivities;
/**
......@@ -59,4 +60,6 @@ public interface SharingActivitiesService extends IService<SharingActivities>
* @return 结果
*/
public int deleteSharingActivitiesById(Long id);
AjaxResult addSharingActivities(SharingActivities sharingActivities);
}
......@@ -7,10 +7,12 @@ import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import share.common.config.SaobeiConfig;
import share.common.config.WeChatConfig;
......@@ -30,6 +32,8 @@ import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.security.Security;
import java.util.*;
......@@ -79,10 +83,30 @@ public class CallbackServiceImpl implements CallbackService {
@Autowired
private MonthlyCardOrderService monthlyCardOrderService;
@Autowired
private SharingActivitiesService sharingActivitiesService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private EquityFundLogService equityFundLogService;
@Autowired
private ConsumerWalletService consumerWalletService;
@Autowired
private SConsumerService consumerService;
@Autowired
private ConsumerMemberService consumerMemberService;
@Autowired
private RedisTemplate redisTemplate;
/**
* 微信支付回调
*/
@DSTransactional
*/@DSTransactional
@Override
public String weChat(String xmlInfo) {
StringBuffer sb = new StringBuffer();
......@@ -445,6 +469,9 @@ public class CallbackServiceImpl implements CallbackService {
wechatInfo.setTradeState("1");
wechatInfo.setTradeStateDesc("支付成功");
wechatPayInfoService.updateById(wechatInfo);
//新增权益金日志
addEquityFundLog(recharge.getConsumerId(),
recharge.getRechargeAmount(),recharge.getOutTradeNo(),recharge.getTerminalTrace(),"0");
aFalse = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
......@@ -524,6 +551,9 @@ public class CallbackServiceImpl implements CallbackService {
equityPayInfo.setTradeState("1");
equityPayInfo.setTradeStateDesc("支付成功");
wechatPayInfoService.updateById(equityPayInfo);
//新增权益金日志
addEquityFundLog(equityMembersOrder.getConsumerId(),
equityMembersOrder.getPayPrice(),equityMembersOrder.getEquityOrderNo(),equityMembersOrder.getTerminalTrace(),"1");
aBoolean = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
......@@ -728,6 +758,76 @@ public class CallbackServiceImpl implements CallbackService {
}
/**
* 新增权益金日志
* @param consumerId 用户ID
* @param payPrice 消费金额
* @param equityOrderNo 订单编号
* @param terminalTrace 终端流水号
* @param type 权益类型
*/
private void addEquityFundLog(Long consumerId, BigDecimal payPrice, String equityOrderNo, String terminalTrace, String type) {
//查询是否有上级
SharingActivities sharingActivities = sharingActivitiesService.getOne(new LambdaQueryWrapper<SharingActivities>()
.eq(SharingActivities::getNewUid, consumerId)
.eq(SharingActivities::getActivityType, "1")
.eq(SharingActivities::getIsDelete, YesNoEnum.no.getIndex()));
if (ObjectUtil.isNotEmpty(sharingActivities)) {
//查询会员用户类型
LambdaQueryWrapper<ConsumerMember> consumerMemberLambdaQueryWrapper = new LambdaQueryWrapper<>();
consumerMemberLambdaQueryWrapper.eq(ConsumerMember::getConsumerId,sharingActivities.getUid());
ConsumerMember consumerMember = consumerMemberService.getOne(consumerMemberLambdaQueryWrapper);
//判断是否为权益会员和会员是否有效
if ("2".equals(consumerMember.getMemberType()) && new Date().getTime() < consumerMember.getExpirationDate().getTime() ){
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (aBoolean){
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);
}
}
}
}
/**
* 支付订单回调通知
* @return MyRecord
*/
......@@ -865,4 +965,6 @@ public class CallbackServiceImpl implements CallbackService {
}
return result;
}
}
package share.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.mapper.EquityFundLogMapper;
import share.system.domain.EquityFundLog;
import share.system.service.EquityFundLogService;
/**
* 权益金记录Service业务层处理
*
* @author wuwenlong
* @date 2024-09-10
*/
@Service
public class EquityFundLogServiceImpl extends ServiceImpl<EquityFundLogMapper, EquityFundLog> implements EquityFundLogService
{
@Autowired
private EquityFundLogMapper equityFundLogMapper;
/**
* 查询权益金记录
*
* @param id 权益金记录主键
* @return 权益金记录
*/
@Override
public EquityFundLog selectEquityFundLogById(Long id)
{
return equityFundLogMapper.selectEquityFundLogById(id);
}
/**
* 查询权益金记录列表
*
* @param equityFundLog 权益金记录
* @return 权益金记录
*/
@Override
public List<EquityFundLog> selectEquityFundLogList(EquityFundLog equityFundLog)
{
return equityFundLogMapper.selectEquityFundLogList(equityFundLog);
}
/**
* 新增权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
@Override
public int insertEquityFundLog(EquityFundLog equityFundLog)
{
equityFundLog.setCreateTime(DateUtils.getNowDate());
return equityFundLogMapper.insertEquityFundLog(equityFundLog);
}
/**
* 修改权益金记录
*
* @param equityFundLog 权益金记录
* @return 结果
*/
@Override
public int updateEquityFundLog(EquityFundLog equityFundLog)
{
equityFundLog.setUpdateTime(DateUtils.getNowDate());
return equityFundLogMapper.updateEquityFundLog(equityFundLog);
}
/**
* 批量删除权益金记录
*
* @param ids 需要删除的权益金记录主键
* @return 结果
*/
@Override
public int deleteEquityFundLogByIds(Long[] ids)
{
return equityFundLogMapper.deleteEquityFundLogByIds(ids);
}
/**
* 删除权益金记录信息
*
* @param id 权益金记录主键
* @return 结果
*/
@Override
public int deleteEquityFundLogById(Long id)
{
return equityFundLogMapper.deleteEquityFundLogById(id);
}
}
......@@ -317,7 +317,7 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
sharingActivities.setUid(uid);
sharingActivities.setNewUid(id);
sharingActivities.setCreateTime(DateUtils.getNowDate());
sharingActivitiesService.save(sharingActivities);
sharingActivitiesService.insertSharingActivities(sharingActivities);
}
}
sConsumerTokenService.bind(registerThirdSConsumerRequest.getOpenId(), finalSConsumer.getId(), response.getUnionId());
......
package share.system.service.impl;
import java.util.List;
import java.util.Set;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.data.redis.core.RedisTemplate;
import share.common.core.domain.AjaxResult;
import share.common.core.redis.RedisUtil;
import share.common.enums.ReceiptRdeisEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -21,6 +29,9 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
@Autowired
private SharingActivitiesMapper sharingActivitiesMapper;
@Autowired
private RedisTemplate redisTemplate;
/**
* 查询分享活动绑定关系
*
......@@ -54,7 +65,8 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
@Override
public int insertSharingActivities(SharingActivities sharingActivities)
{
sharingActivities.setCreateTime(DateUtils.getNowDate());
return sharingActivitiesMapper.insertSharingActivities(sharingActivities);
}
......@@ -94,4 +106,29 @@ public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesM
{
return sharingActivitiesMapper.deleteSharingActivitiesById(id);
}
/**
* 新增分享活动绑定关系
* @param sharingActivities
* @return
*/
@Override
public AjaxResult addSharingActivities(SharingActivities sharingActivities) {
sharingActivities.setCreateTime(DateUtils.getNowDate());
Long newUid = sharingActivities.getNewUid();
SharingActivities sharingActivities1 = sharingActivitiesMapper.selectOne(new LambdaQueryWrapper<SharingActivities>().eq(SharingActivities::getNewUid, newUid));
if (ObjectUtil.isNotEmpty(sharingActivities1)){
return AjaxResult.success("此用户以绑定其他权益会员");
}
Boolean B = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (!B){
return AjaxResult.success("分享用户权益过期");
}
sharingActivitiesMapper.insertSharingActivities(sharingActivities);
Boolean aBoolean = redisTemplate.hasKey(ReceiptRdeisEnum.EQUITY_MEMBERS_TIME + sharingActivities.getUid().toString());
if (!aBoolean){
sharingActivitiesMapper.deleteSharingActivitiesById(sharingActivities.getId());
}
return AjaxResult.success();
}
}
<?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.EquityFundLogMapper">
<resultMap type="EquityFundLog" id="EquityFundLogResult">
<result property="id" column="id" />
<result property="equityFundType" column="equity_fund_type" />
<result property="equityFund" column="equity_fund" />
<result property="uid" column="uid" />
<result property="newUid" column="new_uid" />
<result property="terminalTrace" column="terminal_trace" />
<result property="outTradeNo" column="out_trade_no" />
<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" />
<result property="account" column="account" />
<result property="nickName" column="nick_name" />
<result property="phone" column="phone" />
<result property="newAccount" column="new_account" />
<result property="newNickName" column="new_nick_name" />
<result property="newPhone" column="new_phone" />
</resultMap>
<sql id="selectEquityFundLogVo">
select id, equity_fund_type, equity_fund,
, new_uid, terminal_trace, out_trade_no, is_delete,
create_by, create_time, update_by, update_time, remark,
account,nick_name,phone,new_account,new_nick_name,new_phone
from s_equity_fund_log
</sql>
<select id="selectEquityFundLogList" parameterType="EquityFundLog" resultMap="EquityFundLogResult">
<include refid="selectEquityFundLogVo"/>
<where>
<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>
<if test="newUid != null "> and new_uid = #{newUid}</if>
<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>
</where>
</select>
<select id="selectEquityFundLogById" parameterType="Long" resultMap="EquityFundLogResult">
<include refid="selectEquityFundLogVo"/>
where id = #{id}
</select>
<insert id="insertEquityFundLog" parameterType="EquityFundLog" useGeneratedKeys="true" keyProperty="id">
insert into s_equity_fund_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="equityFundType != null and equityFundType != ''">equity_fund_type,</if>
<if test="equityFund != null">equity_fund,</if>
<if test="uid != null">uid,</if>
<if test="newUid != null">new_uid,</if>
<if test="terminalTrace != null">terminal_trace,</if>
<if test="outTradeNo != null">out_trade_no,</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>
<if test="account != null">account,</if>
<if test="nickName != null">nickName,</if>
<if test="phone != null">phone,</if>
<if test="newAccount != null">new_account,</if>
<if test="newNickName != null">new_nickName,</if>
<if test="newPhone != null">new_phone,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="equityFundType != null and equityFundType != ''">#{equityFundType},</if>
<if test="equityFund != null">#{equityFund},</if>
<if test="uid != null">#{uid},</if>
<if test="newUid != null">#{newUid},</if>
<if test="terminalTrace != null">#{terminalTrace},</if>
<if test="outTradeNo != null">#{outTradeNo},</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>
<if test="account != null">#{account},</if>
<if test="nickName != null">#{nickName},</if>
<if test="phone != null">#{phone},</if>
<if test="newAccount != null">#{new_account},</if>
<if test="newNickName != null">#{new_nickName},</if>
<if test="newPhone != null">#{new_phone},</if>
</trim>
</insert>
<update id="updateEquityFundLog" parameterType="EquityFundLog">
update s_equity_fund_log
<trim prefix="SET" suffixOverrides=",">
<if test="equityFundType != null and equityFundType != ''">equity_fund_type = #{equityFundType},</if>
<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="terminalTrace != null">terminal_trace = #{terminalTrace},</if>
<if test="outTradeNo != null">out_trade_no = #{outTradeNo},</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="deleteEquityFundLogById" parameterType="Long">
delete from s_equity_fund_log where id = #{id}
</delete>
<delete id="deleteEquityFundLogByIds" parameterType="String">
delete from s_equity_fund_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
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