Compare commits

..

5 Commits

5 changed files with 45 additions and 2 deletions

View File

@ -132,10 +132,10 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
return selectList(wrapperX); return selectList(wrapperX);
} }
@Select(" SELECT a.status,d.label,a.create_time,a.pay_price,a.use_point,c.name,c.pic_url,b.count FROM trade_order a " + @Select(" SELECT a.id,a.status,d.label,a.create_time,a.pay_price,a.use_point,c.name,c.pic_url,b.count FROM trade_order a " +
" inner join trade_order_item b on a.id = b.order_id " + " inner join trade_order_item b on a.id = b.order_id " +
" inner join (SELECT sort, label, value, dict_type, css_class FROM system_dict_data WHERE dict_type = 'trade_order_status') d on d.sort = a.status "+ " inner join (SELECT sort, label, value, dict_type, css_class FROM system_dict_data WHERE dict_type = 'trade_order_status') d on d.sort = a.status "+
" inner join product_spu c on b.spu_id = c.id " + " inner join product_spu c on b.spu_id = c.id " +
" where a.user_id = #{userId} and a.use_point > 0 order by a.create_time ASC ") " where a.user_id = #{userId} and a.use_point > 0 order by a.create_time DESC ")
List<AppPointOrderVO> getPointOrder(Long userId); List<AppPointOrderVO> getPointOrder(Long userId);
} }

View File

@ -41,4 +41,15 @@ public class AppMemberPointRecordController {
return success(BeanUtils.toBean(pageResult, AppMemberPointRecordRespVO.class)); return success(BeanUtils.toBean(pageResult, AppMemberPointRecordRespVO.class));
} }
@GetMapping("/getPointInfo")
public CommonResult<MemberPointRecordDO> getPointInfo() {
MemberPointRecordDO pointInfo = pointRecordService.getPointInfo(getLoginUserId());
return success(pointInfo);
}
} }

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.dal.dataobject.point;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*; import lombok.*;
@ -66,4 +67,13 @@ public class MemberPointRecordDO extends BaseDO {
*/ */
private Integer totalPoint; private Integer totalPoint;
//总共获得的积分
@TableField(exist = false)
private Integer addUp;
//总共消费的积分
@TableField(exist = false)
private Integer reduce;
} }

View File

@ -39,4 +39,6 @@ public interface MemberPointRecordService {
* @param bizId 业务编号 * @param bizId 业务编号
*/ */
void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId); void createPointRecord(Long userId, Integer point, MemberPointBizTypeEnum bizType, String bizId);
MemberPointRecordDO getPointInfo(Long userId);
} }

View File

@ -92,4 +92,24 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
memberPointRecordMapper.insert(record); memberPointRecordMapper.insert(record);
} }
@Override
public MemberPointRecordDO getPointInfo(Long userId) {
List<MemberPointRecordDO> memberPointRecordDOList = memberPointRecordMapper.selectList("user_id", userId);
Integer addUp = 0;
Integer reduce = 0;
for (int i = 0; i < memberPointRecordDOList.size(); i++) {
MemberPointRecordDO memberPointRecordDO = memberPointRecordDOList.get(i);
if (memberPointRecordDO.getPoint() > 0){ //获得积分
addUp = addUp + memberPointRecordDO.getPoint();
}
if (memberPointRecordDO.getPoint() < 0){ //消费积分
reduce = reduce + memberPointRecordDO.getPoint();
}
}
MemberPointRecordDO memberPointRecordDO = new MemberPointRecordDO();
memberPointRecordDO.setAddUp(addUp);
memberPointRecordDO.setReduce(reduce);
return memberPointRecordDO;
}
} }