Commit ecd35dd7 by YG8429

分享新用户注册时增加绑定记录,订单结束时有上级时长自动增加1小时

parent 81bb964f
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.SharingActivities;
import share.system.service.SharingActivitiesService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
/**
* 分享活动绑定关系Controller
*
* @author wuwenlong
* @date 2024-09-02
*/
@RestController
@RequestMapping("/system/activities")
public class SharingActivitiesController extends BaseController
{
@Autowired
private SharingActivitiesService sharingActivitiesService;
/**
* 查询分享活动绑定关系列表
*/
@PreAuthorize("@ss.hasPermi('system:activities:list')")
@GetMapping("/list")
public TableDataInfo list(SharingActivities sharingActivities)
{
startPage();
List<SharingActivities> list = sharingActivitiesService.selectSharingActivitiesList(sharingActivities);
return getDataTable(list);
}
/**
* 导出分享活动绑定关系列表
*/
@PreAuthorize("@ss.hasPermi('system:activities:export')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.EXPORT)
@PostMapping("/export")
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, "分享活动绑定关系数据");
}
/**
* 获取分享活动绑定关系详细信息
*/
@PreAuthorize("@ss.hasPermi('system:activities:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sharingActivitiesService.selectSharingActivitiesById(id));
}
/**
* 新增分享活动绑定关系
*/
@PreAuthorize("@ss.hasPermi('system:activities:add')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SharingActivities sharingActivities)
{
return toAjax(sharingActivitiesService.insertSharingActivities(sharingActivities));
}
/**
* 修改分享活动绑定关系
*/
@PreAuthorize("@ss.hasPermi('system:activities:edit')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SharingActivities sharingActivities)
{
return toAjax(sharingActivitiesService.updateSharingActivities(sharingActivities));
}
/**
* 删除分享活动绑定关系
*/
@PreAuthorize("@ss.hasPermi('system:activities:remove')")
@Log(title = "分享活动绑定关系", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sharingActivitiesService.deleteSharingActivitiesByIds(ids));
}
}
......@@ -19,6 +19,7 @@ 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.security.core.parameters.P;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
......@@ -107,6 +108,9 @@ public class RedisTask {
@Autowired
private MemberConfigService memberConfigService;
@Autowired
private SharingActivitiesService sharingActivitiesService;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
......@@ -328,6 +332,44 @@ public class RedisTask {
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
isOrderService.updateById(sOrder);
//查询当前用户是否只有一个订单
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder :: getConsumerId,sOrder.getConsumerId());
List<SOrder> sOrderList = isOrderService.list(sOrderLambdaQueryWrapper);
if (sOrderList.size() == 1){
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities :: getNewUid,sOrder.getConsumerId());
SharingActivities sharingActivities = sharingActivitiesService.getOne(sharingActivitiesLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(sharingActivities)){
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);
consumerWallet.setRemainingDuration(consumerWallet.getRemainingDuration().add(anHour));
consumerWallet.setUpdateTime(DateUtils.getNowDate());
consumerWalletService.updateConsumerWallet(consumerWallet);
}else {
//新增钱包
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);
}
}
}
// 修改房间状态
SRoom room = roomService.getById(sOrder.getRoomId());
if (ObjectUtil.isNotEmpty(room)) {
......
......@@ -58,6 +58,18 @@ public class ConsumerWallet extends BaseEntity {
@TableField(select = false)
private Long isDelete;
/**
* 权益金
*/
@Excel(name = "权益金")
private BigDecimal equityFund;
/**
* 累计权益金
*/
@Excel(name = "累计权益金")
private BigDecimal accumulateEquityFund;
@Override
public String toString() {
......
package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
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
*
* @author wuwenlong
* @date 2024-09-02
*/
@Data
@TableName("s_sharing_activities")
public class SharingActivities extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 活动类型(0-新用户注册,1-权益金会员分享) */
@Excel(name = "活动类型(0-新用户注册,1-权益金会员分享)")
private String activityType;
/** 上级id */
@Excel(name = "上级id")
private Long uid;
/** 下级id */
@Excel(name = "下级id")
private Long newUid;
/** 删除标记:1-删除,0-正常 */
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("activityType", getActivityType())
.append("uid", getUid())
.append("newUid", getNewUid())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SharingActivities;
/**
* 分享活动绑定关系Mapper接口
*
* @author wuwenlong
* @date 2024-09-02
*/
public interface SharingActivitiesMapper extends BaseMapper<SharingActivities>
{
/**
* 查询分享活动绑定关系
*
* @param id 分享活动绑定关系主键
* @return 分享活动绑定关系
*/
public SharingActivities selectSharingActivitiesById(Long id);
/**
* 查询分享活动绑定关系列表
*
* @param sharingActivities 分享活动绑定关系
* @return 分享活动绑定关系集合
*/
public List<SharingActivities> selectSharingActivitiesList(SharingActivities sharingActivities);
/**
* 新增分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
public int insertSharingActivities(SharingActivities sharingActivities);
/**
* 修改分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
public int updateSharingActivities(SharingActivities sharingActivities);
/**
* 删除分享活动绑定关系
*
* @param id 分享活动绑定关系主键
* @return 结果
*/
public int deleteSharingActivitiesById(Long id);
/**
* 批量删除分享活动绑定关系
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteSharingActivitiesByIds(Long[] ids);
}
......@@ -46,4 +46,10 @@ public class WxRegisterPhoneRequest implements Serializable {
@NotBlank(message = "手机号code不能为空")
private String phoneCode;
@ApiModelProperty(value = "上级id")
private Long uid;
@ApiModelProperty(value = "活动类型")
private String activityType;
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SharingActivities;
/**
* 分享活动绑定关系Service接口
*
* @author wuwenlong
* @date 2024-09-02
*/
public interface SharingActivitiesService extends IService<SharingActivities>
{
/**
* 查询分享活动绑定关系
*
* @param id 分享活动绑定关系主键
* @return 分享活动绑定关系
*/
public SharingActivities selectSharingActivitiesById(Long id);
/**
* 查询分享活动绑定关系列表
*
* @param sharingActivities 分享活动绑定关系
* @return 分享活动绑定关系集合
*/
public List<SharingActivities> selectSharingActivitiesList(SharingActivities sharingActivities);
/**
* 新增分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
public int insertSharingActivities(SharingActivities sharingActivities);
/**
* 修改分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
public int updateSharingActivities(SharingActivities sharingActivities);
/**
* 批量删除分享活动绑定关系
*
* @param ids 需要删除的分享活动绑定关系主键集合
* @return 结果
*/
public int deleteSharingActivitiesByIds(Long[] ids);
/**
* 删除分享活动绑定关系信息
*
* @param id 分享活动绑定关系主键
* @return 结果
*/
public int deleteSharingActivitiesById(Long id);
}
......@@ -21,9 +21,11 @@ import share.common.core.redis.RedisUtil;
import share.common.exception.base.BaseException;
import share.common.utils.CommonUtil;
import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import share.common.utils.wx.WxUtil;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerToken;
import share.system.domain.SharingActivities;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.WeChatMiniAuthorizeVo;
import share.system.domain.vo.WeChatPhoneNumberVo;
......@@ -32,10 +34,7 @@ import share.system.request.RegisterThirdSConsumerRequest;
import share.system.request.WxBindingPhoneRequest;
import share.system.request.WxRegisterPhoneRequest;
import share.system.response.LoginResponse;
import share.system.service.SConsumerCenterService;
import share.system.service.SConsumerService;
import share.system.service.SConsumerTokenService;
import share.system.service.WechatNewService;
import share.system.service.*;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
......@@ -66,6 +65,9 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
@Autowired
private WechatNewService wechatNewService;
@Autowired
private SharingActivitiesService sharingActivitiesService;
/**
* 小程序登录
......@@ -306,6 +308,17 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
if (finalIsNew) {// 新用户
Long id = sConsumerService.saveSConsumer(finalSConsumer);
finalSConsumer.setId(id);
Long uid = request.getUid();
//判断是否为分享新用户
if (uid != null){
//添加绑定关系
SharingActivities sharingActivities = new SharingActivities();
sharingActivities.setActivityType(request.getActivityType());
sharingActivities.setUid(uid);
sharingActivities.setNewUid(id);
sharingActivities.setCreateTime(DateUtils.getNowDate());
sharingActivitiesService.save(sharingActivities);
}
}
sConsumerTokenService.bind(registerThirdSConsumerRequest.getOpenId(), finalSConsumer.getId(), response.getUnionId());
sConsumer.setLastLoginTime(DateUtil.nowDateTime());
......@@ -418,7 +431,6 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
}
/**
* 检测手机验证码
*
......
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.SharingActivitiesMapper;
import share.system.domain.SharingActivities;
import share.system.service.SharingActivitiesService;
/**
* 分享活动绑定关系Service业务层处理
*
* @author wuwenlong
* @date 2024-09-02
*/
@Service
public class SharingActivitiesServiceImpl extends ServiceImpl<SharingActivitiesMapper, SharingActivities> implements SharingActivitiesService
{
@Autowired
private SharingActivitiesMapper sharingActivitiesMapper;
/**
* 查询分享活动绑定关系
*
* @param id 分享活动绑定关系主键
* @return 分享活动绑定关系
*/
@Override
public SharingActivities selectSharingActivitiesById(Long id)
{
return sharingActivitiesMapper.selectSharingActivitiesById(id);
}
/**
* 查询分享活动绑定关系列表
*
* @param sharingActivities 分享活动绑定关系
* @return 分享活动绑定关系
*/
@Override
public List<SharingActivities> selectSharingActivitiesList(SharingActivities sharingActivities)
{
return sharingActivitiesMapper.selectSharingActivitiesList(sharingActivities);
}
/**
* 新增分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
@Override
public int insertSharingActivities(SharingActivities sharingActivities)
{
sharingActivities.setCreateTime(DateUtils.getNowDate());
return sharingActivitiesMapper.insertSharingActivities(sharingActivities);
}
/**
* 修改分享活动绑定关系
*
* @param sharingActivities 分享活动绑定关系
* @return 结果
*/
@Override
public int updateSharingActivities(SharingActivities sharingActivities)
{
sharingActivities.setUpdateTime(DateUtils.getNowDate());
return sharingActivitiesMapper.updateSharingActivities(sharingActivities);
}
/**
* 批量删除分享活动绑定关系
*
* @param ids 需要删除的分享活动绑定关系主键
* @return 结果
*/
@Override
public int deleteSharingActivitiesByIds(Long[] ids)
{
return sharingActivitiesMapper.deleteSharingActivitiesByIds(ids);
}
/**
* 删除分享活动绑定关系信息
*
* @param id 分享活动绑定关系主键
* @return 结果
*/
@Override
public int deleteSharingActivitiesById(Long id)
{
return sharingActivitiesMapper.deleteSharingActivitiesById(id);
}
}
......@@ -19,6 +19,8 @@
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="equityFund" column="equity_fund"/>
<result property="accumulateEquityFund" column="accumulate_equity_fund"/>
</resultMap>
<sql id="selectConsumerWalletVo">
......@@ -32,7 +34,9 @@
create_time,
update_by,
update_time,
remark
remark,
equity_fund,
accumulate_equity_fund
from s_consumer_wallet
</sql>
......@@ -83,7 +87,9 @@
w.create_time,
w.update_by,
w.update_time,
w.remark
w.remark,
w.equity_fund,
w.accumulate_equity_fund
from s_consumer_wallet w join s_consumer c on w.consumer_id = c.id
<where>
<if test="nickName != null and nickName != ''">and c.nick_name like concat('%', #{nickName},'%')
......@@ -111,6 +117,8 @@
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="equityFund != null">equity_fund,</if>
<if test="accumulateEquityFund != null">accumulate_equity_fund,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerId != null">#{consumerId},</if>
......@@ -123,6 +131,8 @@
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="equityFund != null">#{equityFund},</if>
<if test="accumulateEquityFund != null">#{accumulateEquityFund},</if>
</trim>
</insert>
......@@ -139,6 +149,8 @@
<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="equityFund != null">equity_fund = #{equityFund},</if>
<if test="accumulateEquityFund != null">accumulate_equity_fund = #{accumulateEquityFund},</if>
</trim>
where id = #{id}
</update>
......
<?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.SharingActivitiesMapper">
<resultMap type="SharingActivities" id="SharingActivitiesResult">
<result property="id" column="id" />
<result property="activityType" column="activity_type" />
<result property="uid" column="uid" />
<result property="newUid" column="new_uid" />
<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="selectSharingActivitiesVo">
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>
<if test="activityType != null and activityType != ''"> and activity_type = #{activityType}</if>
<if test="uid != null "> and uid = #{uid}</if>
<if test="newUid != null "> and new_uid = #{newUid}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
</where>
</select>
<select id="selectSharingActivitiesById" parameterType="Long" resultMap="SharingActivitiesResult">
<include refid="selectSharingActivitiesVo"/>
where id = #{id}
</select>
<insert id="insertSharingActivities" parameterType="SharingActivities" useGeneratedKeys="true" keyProperty="id">
insert into s_sharing_activities
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="activityType != null and activityType != ''">activity_type,</if>
<if test="uid != null">uid,</if>
<if test="newUid != null">new_uid,</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="activityType != null and activityType != ''">#{activityType},</if>
<if test="uid != null">#{uid},</if>
<if test="newUid != null">#{newUid},</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="updateSharingActivities" parameterType="SharingActivities">
update s_sharing_activities
<trim prefix="SET" suffixOverrides=",">
<if test="activityType != null and activityType != ''">activity_type = #{activityType},</if>
<if test="uid != null">uid = #{uid},</if>
<if test="newUid != null">new_uid = #{newUid},</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="deleteSharingActivitiesById" parameterType="Long">
delete from s_sharing_activities where id = #{id}
</delete>
<delete id="deleteSharingActivitiesByIds" parameterType="String">
delete from s_sharing_activities 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