Quellcode durchsuchen

Merge branch 'develop' of gitadmin/tuoheng_qmhh into release

release
wanjing vor 11 Monaten
Ursprung
Commit
05a148755c
3 geänderte Dateien mit 100 neuen und 26 gelöschten Zeilen
  1. +6
    -0
      tuoheng-api/src/main/java/com/tuoheng/api/mapper/UserPointsDetailMapper.java
  2. +50
    -26
      tuoheng-api/src/main/java/com/tuoheng/api/service/points/receive/ReceivePonitsService.java
  3. +44
    -0
      tuoheng-api/src/main/resources/mapper/UserPointsDetailMapper.xml

+ 6
- 0
tuoheng-api/src/main/java/com/tuoheng/api/mapper/UserPointsDetailMapper.java Datei anzeigen

@@ -2,6 +2,9 @@ package com.tuoheng.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tuoheng.api.entity.domain.UserPointsDetail;
import org.apache.ibatis.annotations.Param;

import java.util.Date;

/**
* 用户积分明细表 Mapper 接口
@@ -10,4 +13,7 @@ import com.tuoheng.api.entity.domain.UserPointsDetail;
* @since 2023-05-06
*/
public interface UserPointsDetailMapper extends BaseMapper<UserPointsDetail> {

Integer selectTotalPointsByToDay(@Param("openid") String openid, @Param("pointsTime") String pointsTime);

}

+ 50
- 26
tuoheng-api/src/main/java/com/tuoheng/api/service/points/receive/ReceivePonitsService.java Datei anzeigen

@@ -48,32 +48,6 @@ public class ReceivePonitsService {
return result;
}

WestreamKnowUser westreamKnowUser = westreamKnowUserMapper.selectOne(new LambdaQueryWrapper<WestreamKnowUser>()
.eq(WestreamKnowUser::getTenantId, request.getTenantId())
.eq(WestreamKnowUser::getOpenid, request.getOpenid())
.eq(WestreamKnowUser::getKnowId, request.getKnowId())
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNotEmpty(westreamKnowUser)) {
return JsonResult.error("您已获得过积分了,仅能获取一次积分。");
} else {
westreamKnowUser = new WestreamKnowUser();
westreamKnowUser.setTenantId(request.getTenantId());
westreamKnowUser.setOpenid(request.getOpenid());
westreamKnowUser.setKnowId(request.getKnowId());
westreamKnowUser.setCreateUser(0);
westreamKnowUser.setCreateTime(DateUtils.now());
westreamKnowUserMapper.insert(westreamKnowUser);
}

WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>()
.eq(WestreamUser::getTenantId, request.getTenantId())
.eq(WestreamUser::getOpenid, request.getOpenid())
.eq(WestreamUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isEmpty(westreamUser)) {
log.info("领取积分,该用户不存在,tenantId:{}, openid:{}", request.getTenantId(), request.getOpenid());
return JsonResult.success("该用户不存在");
}

ThDict dict = dictMapper.selectOne(new LambdaQueryWrapper<ThDict>()
.eq(ThDict::getTenantId, request.getTenantId())
.eq(ThDict::getCode, DictEnum.POINTS_RULE.getCode())
@@ -93,6 +67,56 @@ public class ReceivePonitsService {
return JsonResult.success("积分规则未设置");
}

ThDictData dailyLimitWestreamSubmitDictData = dictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>()
.eq(ThDictData::getTenantId, request.getTenantId())
.eq(ThDictData::getDictId, dict.getId())
.eq(ThDictData::getName, DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode())
.eq(ThDictData::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isEmpty(dailyLimitWestreamSubmitDictData)) {
log.info("领取积分,每日上报最大限额字典项不存在,tenantId:{}, dictDataName:{}", request.getTenantId(), DictDataEnum.DAILY_LIMIT_WESTREAM_SUBMIT.getCode());
return JsonResult.success("积分规则未设置");
}

Integer dailyLimitWestreamSubmit = 0;
if (ObjectUtil.isNotEmpty(dailyLimitWestreamSubmitDictData)) {
dailyLimitWestreamSubmit = Integer.parseInt(dailyLimitWestreamSubmitDictData.getValue());
}

String pointsTime = DateUtils.getDate();
Integer totalPointsByToDay = userPointsDetailMapper.selectTotalPointsByToDay(request.getOpenid(), pointsTime);
if (ObjectUtil.isNotEmpty(totalPointsByToDay)) {
if (totalPointsByToDay >= dailyLimitWestreamSubmit) {
log.info("领取积分,已超过每日积分上限,totalPointsByToDay:{}, dailyLimitWestreamSubmit:{}", totalPointsByToDay, dailyLimitWestreamSubmit);
return JsonResult.success("已超过每日积分上限");
}
}

WestreamUser westreamUser = westreamUserMapper.selectOne(new LambdaQueryWrapper<WestreamUser>()
.eq(WestreamUser::getTenantId, request.getTenantId())
.eq(WestreamUser::getOpenid, request.getOpenid())
.eq(WestreamUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isEmpty(westreamUser)) {
log.info("领取积分,该用户不存在,tenantId:{}, openid:{}", request.getTenantId(), request.getOpenid());
return JsonResult.success("该用户不存在");
}

WestreamKnowUser westreamKnowUser = westreamKnowUserMapper.selectOne(new LambdaQueryWrapper<WestreamKnowUser>()
.eq(WestreamKnowUser::getTenantId, request.getTenantId())
.eq(WestreamKnowUser::getOpenid, request.getOpenid())
.eq(WestreamKnowUser::getKnowId, request.getKnowId())
.eq(WestreamKnowUser::getMark, MarkEnum.VALID.getCode()));
if (ObjectUtil.isNotEmpty(westreamKnowUser)) {
return JsonResult.error("您已获得过积分了,仅能获取一次积分。");
} else {
westreamKnowUser = new WestreamKnowUser();
westreamKnowUser.setTenantId(request.getTenantId());
westreamKnowUser.setOpenid(request.getOpenid());
westreamKnowUser.setKnowId(request.getKnowId());
westreamKnowUser.setCreateUser(0);
westreamKnowUser.setCreateTime(DateUtils.now());
westreamKnowUserMapper.insert(westreamKnowUser);
}

UserPointsDetail userPointsDetail = new UserPointsDetail();
userPointsDetail.setTenantId(request.getTenantId());
userPointsDetail.setOpenid(request.getOpenid());

+ 44
- 0
tuoheng-api/src/main/resources/mapper/UserPointsDetailMapper.xml Datei anzeigen

@@ -0,0 +1,44 @@
<?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="com.tuoheng.api.mapper.UserPointsDetailMapper">

<resultMap id="BaseResultMap" type="com.tuoheng.api.entity.domain.UserPointsDetail">
<id property="id" column="id" />
<result property="tenantId" column="tenant_id"/>
<result property="openid" column="openid" />
<result property="nickname" column="nickname" />
<result property="pointsChange" column="points_change" />
<result property="pointsTime" column="points_time"/>
<result property="type" column="type" />
<result property="operatorId" column="operator_id" />
<result property="operatorName" column="operator_name" />
<result property="changeName" column="change_name" />
<result property="exchangeFlag" column="exchange_flag"/>
<result property="goodsId" column="goods_id" />
<result property="goodsPoints" column="goods_points" />
<result property="goodsCount" column="goods_count" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>

<sql id="Base_Column_List">
id, tenant_id, openid, nickname,
points_change, points_time, type, operator_id, operator_name, change_name, exchange_flag, goods_id, goods_points, goods_count,
create_user, create_time, update_user, update_time, mark
</sql>

<select id="selectTotalPointsByToDay" resultType="java.lang.Integer">
select sum(id)
from th_user_points_detail
<where>
<if test="1 == 1"> and mark = 1 and type = 1 </if>
<if test="openid != null and openid != ''"> and openid = #{openid} </if>
<if test="pointsTime != null "> and points_time = #{pointsTime} </if>
</where>
</select>
</mapper>

Laden…
Abbrechen
Speichern