Commit 128a1094 authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents fd795a90 ab50a0cf
......@@ -24,7 +24,7 @@ public class UserTeamMemberBo {
/**
* 用户名
*/
private String userNamem;
private String userName;
/**
* 昵称
......
package com.github.wxiaoqi.security.admin.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 8:42
*/
@Data
public class WalletDTO {
@ApiModelProperty(value = "id")
private Long id;
/**
* 用户ID
*/
@ApiModelProperty("用户ID")
private Integer userId;
/**
* 余额(分)
*/
@ApiModelProperty(value = "余额(元)")
private BigDecimal balance;
/**
* 已提现金额
*/
@ApiModelProperty(value = "已提现金额")
private BigDecimal withdrawals;
/**
* 进账总额(元)
*/
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal totalAmount;
/**
* 进账总额(分)
*/
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal todayAmount;
/**
* 未入账金额
*/
@ApiModelProperty(value = "未入账金额")
private BigDecimal unbooked;
/**
* 是否冻结:0-正常,1-冻结
*/
@ApiModelProperty(value = "是否冻结:0-正常,1-冻结")
private Integer isFrozen;
/**
* 最后进账时间
*/
@ApiModelProperty(value = "最后进账时间")
private Long lastIntime;
}
......@@ -131,14 +131,14 @@ public class AppUserSellingWater implements Serializable {
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Integer crtTime;
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Integer updTime;
private Long updTime;
/**
* 所获佣金
......
......@@ -25,7 +25,7 @@ public class MyWallet implements Serializable {
*/
@Column(name = "id")
@ApiModelProperty(value = "id")
private Long id;
private Integer id;
/**
* 用户ID
......@@ -39,7 +39,7 @@ public class MyWallet implements Serializable {
* 余额(分)
*/
@Column(name = "balance")
@ApiModelProperty(value = "余额()")
@ApiModelProperty(value = "余额()")
private BigDecimal balance;
/**
......@@ -53,14 +53,14 @@ public class MyWallet implements Serializable {
* 进账总额(分)
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "进账总额()")
@ApiModelProperty(value = "进账总额()")
private BigDecimal totalAmount;
/**
* 进账总额(分)
*/
@Column(name = "today_amount")
@ApiModelProperty(value = "进账总额()")
@ApiModelProperty(value = "进账总额()")
private BigDecimal todayAmount;
/**
......
......@@ -26,14 +26,14 @@ public class MyWalletDetail implements Serializable {
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键ID")
private Long id;
private Integer id;
/**
* 用户ID
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户ID")
private String userId;
private Integer userId;
/**
* 来源:0-活动,1-佣金,2-会员充值,10-提现,11-转账,12-购买
......@@ -75,7 +75,7 @@ public class MyWalletDetail implements Serializable {
*/
@Column(name = "cono")
@ApiModelProperty(value = "单号")
private String cono;
private Integer cono;
/**
* 加上当时的收入的余额
......@@ -87,9 +87,9 @@ public class MyWalletDetail implements Serializable {
/**
* 操作者ID(如果系统操作,-1)
*/
@Column(name = "oper_user")
@Column(name = "crt_user")
@ApiModelProperty(value = "操作者ID(如果系统操作,-1)")
private Integer operUser;
private Integer crtUser;
/**
* 操作时间
......
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:20
*/
@Data
public class AppletWalletVo {
/**
* 用户ID
*/
@ApiModelProperty("用户ID")
private Integer userId;
/**
* 余额(元)
*/
@ApiModelProperty(value = "余额(元)")
private BigDecimal balance;
/**
* 进账总额(元)
*/
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal totalAmount;
/**
* 今日收益(元)
*/
@ApiModelProperty(value = "今日收益(元)")
private BigDecimal todayAmount;
}
package com.github.wxiaoqi.security.admin.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 11:02
*/
@Data
public class SellingWalletPagVo {
private BigDecimal totalIncome;
private List<SellingWalletVo> sellingWaters;
private Integer pageNum;
private Integer pageSize;
private Integer totalCount;
private Integer totalPage;
}
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 11:02
*/
@Data
public class SellingWalletVo {
/**
* 用户名
*/
private String username;
/**
* 昵称
*/
private String nickName;
/**
* 用户头像
*/
private String headUrl;
@ApiModelProperty(value = "商品数量")
private Integer goodNumber;
@ApiModelProperty(value = "商品标题")
private String title;
@ApiModelProperty(value = "图片")
private String img;
@ApiModelProperty(value = "售价")
private BigDecimal price;
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
private Integer waiting;
private Integer status;
/**
* 所获佣金
*/
private BigDecimal commission;
}
package com.github.wxiaoqi.security.admin.vo;
import com.github.wxiaoqi.security.admin.bo.UserTeamMemberBo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description 用户的团队成员
* @data 2019/7/11 14:46
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserTeamMemberVo {
private BigDecimal totalIncome;
private List<UserTeamMemberBo> userTeamMemberBos;
private Integer pageNum;
private Integer pageSize;
private Integer totalCount;
private Integer totalPage;
}
package com.github.wxiaoqi.security.admin.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 10:31
*/
@Data
public class WalletCathPageVo {
private BigDecimal totalWithdraw;
private List<WalletCathVo> walletCaths;
private Integer pageNum;
private Integer pageSize;
private Integer totalCount;
private Integer totalPage;
}
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 10:45
*/
@Data
public class WalletCathVo {
/**
* 用户iD
*/
@ApiModelProperty(value = "用户iD")
private String userId;
/**
* 提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)
*/
@ApiModelProperty(value = "提现类别,第三方提现类别(0-微信,1-支付宝,2-银行卡)")
private Integer cathType;
/**
* 商户订单号
*/
@ApiModelProperty(value = "商户订单号")
private String orderno;
/**
* 第三方订单号:如微信,支付宝,银行卡等
*/
@ApiModelProperty(value = "第三方订单号:如微信,支付宝,银行卡等")
private String cono;
/**
* 提现金额
*/
@ApiModelProperty(value = "提现金额")
private BigDecimal amount;
/**
* 订单状态:0-未提现,待审核,1-已审核
*/
@ApiModelProperty(value = "订单状态:0-未提现,待审核,1-已审核")
private Integer stauts;
/**
* 提现日期
*/
@ApiModelProperty(value = "提现日期", hidden = true )
private Long crtTime;
/**
* 审核日期
*/
@ApiModelProperty(value = "审核日期")
private Long finishTime;
}
package com.github.wxiaoqi.security.admin.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:20
*/
@Data
public class WalletVo {
@ApiModelProperty(value = "id")
private Long id;
/**
* 用户ID
*/
@ApiModelProperty("用户ID")
private Integer userId;
/**
* 余额(元)
*/
@ApiModelProperty(value = "余额(元)")
private BigDecimal balance;
/**
* 已提现金额
*/
@ApiModelProperty(value = "已提现金额")
private BigDecimal withdrawals;
/**
* 进账总额(元)
*/
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal totalAmount;
/**
* 进账总额(分)
*/
@ApiModelProperty(value = "进账总额(元)")
private BigDecimal todayAmount;
/**
* 未入账金额
*/
@ApiModelProperty(value = "未入账金额")
private BigDecimal unbooked;
/**
* 是否冻结:0-正常,1-冻结
*/
@ApiModelProperty(value = "是否冻结:0-正常,1-冻结")
private Integer isFrozen;
/**
* 最后进账时间
*/
@ApiModelProperty(value = "最后进账时间")
private Long lastIntime;
}
......@@ -19,6 +19,6 @@ public class AppUserPositionBiz extends BaseBiz<AppUserPositionMapper,AppUserPos
//获取用户职位的折扣
public Integer getExtract(Integer userId){
return getExtract(userId);
return mapper.getExtractByUserId(userId);
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.MyWallet;
import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:18
*/
@Transactional
@Service
public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
public AppletWalletVo findMyWallet(Integer userId){
AppletWalletVo appletWalletVo = new AppletWalletVo();
Example example = new Example(MyWallet.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userId",userId);
List<MyWallet> wallets = mapper.selectByExample(example);
MyWallet myWallet = wallets.get(0);
BeanUtils.copyProperties(myWallet,appletWalletVo);
return appletWalletVo;
}
}
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.MyWalletCath;
import com.github.wxiaoqi.security.admin.mapper.MyWalletCathMapper;
import com.github.wxiaoqi.security.admin.vo.WalletCathPageVo;
import com.github.wxiaoqi.security.admin.vo.WalletCathVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 10:21
*/
@Transactional
@Service
public class MyWalletCathBiz extends BaseBiz<MyWalletCathMapper, MyWalletCath> {
public WalletCathPageVo findWatchCatchByWithdrawalState(Integer userId,Integer state, Integer pageNo, Integer pageSize){
WalletCathPageVo walletCathPageVo = new WalletCathPageVo();
Example example = new Example(MyWalletCath.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("stauts",state);
criteria.andEqualTo("userId",userId);
PageDataVO<MyWalletCath> walletCathPage = PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.selectByExample(example));
List<MyWalletCath> walletCaths = walletCathPage.getData();
if (CollectionUtils.isEmpty(walletCaths)){
return walletCathPageVo;
}
WalletCathVo walletCathVo = null;
BigDecimal totalWithdraw = new BigDecimal(0);
List<WalletCathVo> walletCatchPageVos = new ArrayList<>();
for (MyWalletCath walletCath : walletCaths) {
walletCathVo = new WalletCathVo();
BeanUtils.copyProperties(walletCath,walletCathVo);
totalWithdraw = totalWithdraw.add(walletCathVo.getAmount());
walletCatchPageVos.add(walletCathVo);
}
walletCathPageVo.setPageNum(walletCathPage.getPageNum());
walletCathPageVo.setPageSize(walletCathPage.getPageSize());
walletCathPageVo.setTotalCount(walletCathPage.getTotalCount().intValue());
walletCathPageVo.setTotalPage(walletCathPage.getTotalPage());
walletCathPageVo.setTotalWithdraw(totalWithdraw);
walletCathPageVo.setWalletCaths(walletCatchPageVos);
return walletCathPageVo;
}
}
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:18
*/
@Transactional
@Service
public class MyWalletDetailBiz extends BaseBiz<MyWalletDetailMapper, MyWalletDetail> {
}
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.date.DateTime;
import com.github.wxiaoqi.security.admin.entity.MyWallet;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.mapper.MyWalletDetailMapper;
import com.github.wxiaoqi.security.admin.mapper.MyWalletMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 钱包
*
* @author libin
* @email 18178966185@163.com
* @date 2019-07-09 10:00:42
*/
@Service
@Slf4j
public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
@Autowired
MyWalletDetailBiz walletDetailBiz;
//我的钱包入账
public void updMyWater(Integer userId, Integer orderId,BigDecimal amount){
log.info("---我的钱包入账----userId==="+userId+"----orderId===="+orderId+"----amount===="+amount);
MyWallet wallet=new MyWallet();
wallet.setUserId(userId);
wallet=selectOne(wallet);
//进账之前余额
BigDecimal oldBalance=new BigDecimal("0.00");
BigDecimal balance=new BigDecimal("0.00");
//进账总额(元)
BigDecimal totalAmount=new BigDecimal("0.00");
//今日收益
BigDecimal todayAmount=new BigDecimal("0.00");
//未入账金额
BigDecimal unbooked=new BigDecimal("0.00");
Integer id=0;
if(wallet==null){
wallet=new MyWallet();
wallet.setUserId(userId);
totalAmount=amount;
todayAmount=amount;
balance=amount;
}else {
id=wallet.getId();
oldBalance=wallet.getBalance();
balance=wallet.getBalance().add(amount);
totalAmount=wallet.getTotalAmount().add(amount);
Long lastTime=wallet.getLastIntime();
todayAmount=amount;
if (lastTime!=null&&(lastTime==0||isToday(lastTime))){
todayAmount=wallet.getTodayAmount().add(amount);
}
unbooked=wallet.getUnbooked().subtract(unbooked);
}
log.info("---我的钱包入账----userId==="+userId+"----balance===="+balance+"----totalAmount===="+totalAmount+"---todayAmount==="+todayAmount+"---unbooked=="+unbooked);
MyWalletDetail walletDetail=new MyWalletDetail();
walletDetail.setUserId(userId);
walletDetail.setSource(1);
walletDetail.setCono(orderId);
walletDetail.setItype(1);
walletDetail.setAmount(amount);
walletDetail.setBalance(oldBalance);
walletDetailBiz.insertSelective(walletDetail);
Long time=System.currentTimeMillis();
wallet.setBalance(balance);
wallet.setTodayAmount(todayAmount);
wallet.setTotalAmount(totalAmount);
wallet.setUnbooked(unbooked);
wallet.setLastIntime(time);
wallet.setUpdTime(time);
if(id>0){
mapper.updMyWater(wallet);
}else {
wallet.setCrtTime(time);
insertSelective(wallet);
}
log.info("---我的钱包入账----userId==="+userId+"----成功");
}
// 这个时间戳是不是今天
public boolean isToday(long time) {
boolean isToday = false;
Date date;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
date = sdf.parse(sdf.format(new Date()));
if (time < date.getTime() && time > date.getTime()) {
isToday = true;
}
} catch (ParseException e) {
e.printStackTrace();
}
return isToday;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.admin.bo.UserTeamMemberBo;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.github.wxiaoqi.security.admin.vo.UserTeamMemberVo;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,28 +39,29 @@ public class UserBusinessBiz {
@Autowired
private AppUserDetailBiz appUserDetailBiz;
public PageDataVO<UserTeamMemberBo> findTeamMemberPageByUserId(Integer userId, Integer pageNo, Integer pageSize) {
public UserTeamMemberVo findTeamMemberPageByUserId(Integer userId, Integer pageNo, Integer pageSize) {
PageDataVO<UserTeamMemberBo> teamMemberPage = new PageDataVO<>();
UserTeamMemberVo userTeamMemberVo = new UserTeamMemberVo();
//根据用户id去关系表里查询下级
PageDataVO<AppUserRelation> memberPage = appUserRelationBiz.findMemberPageByLeaderId(userId, pageNo, pageSize);
List<AppUserRelation> teamMemberBos = memberPage.getData();
if (CollectionUtils.isEmpty(teamMemberBos)) {
return teamMemberPage;
return userTeamMemberVo;
}
List<Integer> memberIds = teamMemberBos.stream().map(team -> team.getUserId()).collect(Collectors.toList());
Map<Integer, BigDecimal> memberIdAndIncomeMap = appUserSellingWaterBiz.findMemberIdAndIncomeMapByMemberIds(memberIds);
if (memberIdAndIncomeMap == null) {
return teamMemberPage;
return userTeamMemberVo;
}
Map<Integer,AppUserLogin> userIdAndAppUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> UserIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> userIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
List<UserTeamMemberBo> userTeamMemberBos = new ArrayList<>();
UserTeamMemberBo userTeamMemberBo;
BigDecimal totalIncome = new BigDecimal(0);
for (AppUserRelation appUserRelation : teamMemberBos) {
userTeamMemberBo = new UserTeamMemberBo();
......@@ -68,21 +70,23 @@ public class UserBusinessBiz {
if (userIdAndAppUserLoginMap!=null){
AppUserLogin appUserLogin = userIdAndAppUserLoginMap.get(appUserRelation.getUserId());
userTeamMemberBo.setUserNamem(appUserLogin.getUsername());
userTeamMemberBo.setUserName(appUserLogin.getUsername());
}
if (UserIdAndAppUserDetailMap!=null){
AppUserDetail appUserDetail = UserIdAndAppUserDetailMap.get(appUserRelation.getUserId());
if (userIdAndAppUserDetailMap!=null){
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(appUserRelation.getUserId());
userTeamMemberBo.setHeadUrl(appUserDetail==null?"":appUserDetail.getHeadimgurl());
userTeamMemberBo.setNickName(appUserDetail==null?"":appUserDetail.getNickname());
}
userTeamMemberBo.setIncome(memberIdAndIncomeMap.get(appUserRelation.getUserId()));
totalIncome = totalIncome.add(userTeamMemberBo.getIncome());
userTeamMemberBos.add(userTeamMemberBo);
}
teamMemberPage.setPageNum(memberPage.getPageNum());
teamMemberPage.setPageSize(memberPage.getPageSize());
teamMemberPage.setTotalCount(memberPage.getTotalCount());
teamMemberPage.setTotalPage(memberPage.getTotalPage());
teamMemberPage.setData(userTeamMemberBos);
return teamMemberPage;
userTeamMemberVo.setPageNum(memberPage.getPageNum());
userTeamMemberVo.setPageSize(memberPage.getPageSize());
userTeamMemberVo.setTotalCount(memberPage.getTotalCount().intValue());
userTeamMemberVo.setTotalPage(memberPage.getTotalPage());
userTeamMemberVo.setUserTeamMemberBos(userTeamMemberBos);
userTeamMemberVo.setTotalIncome(totalIncome);
return userTeamMemberVo;
}
}
package com.github.wxiaoqi.security.admin.handler;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class IntegralMQHandler {
@Autowired
AppUserSellingWaterBiz waterBiz;
@RabbitListener(queues = "orderWater_queue")
public void integralHandler(String json) {
log.info("接收到的消息:json = {}", json);
try{
OrderWaterDTO orderWaterDTO = JSONObject.parseObject(json, OrderWaterDTO.class);
waterBiz.orderWater(orderWaterDTO);
}catch (Exception e){
log.info("接收到的消息失败");
e.printStackTrace();
}
}
}
......@@ -11,5 +11,9 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-07-11 14:14:54
*/
public interface MyWalletMapper extends Mapper<MyWallet> {
public void updMyWater(MyWallet myWallet);
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.MyWalletBiz;
import com.github.wxiaoqi.security.admin.vo.AppletWalletVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 9:17
*/
@RestController
@RequestMapping("/wallet")
public class MyWalletController {
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@Autowired
private MyWalletBiz myWalletBiz;
@GetMapping
public ObjectRestResponse<AppletWalletVo> findMyWallet(HttpServletRequest request){
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
AppletWalletVo wallet = myWalletBiz.findMyWallet(Integer.valueOf(infoFromToken.getId()));
return ObjectRestResponse.succ(wallet);
} catch (Exception e) {
throw new BaseException(e);
}
}
}
......@@ -2,6 +2,7 @@ package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.UserBusinessBiz;
import com.github.wxiaoqi.security.admin.bo.UserTeamMemberBo;
import com.github.wxiaoqi.security.admin.vo.UserTeamMemberVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
......@@ -36,11 +37,11 @@ public class UserBussinessController {
private UserBusinessBiz businessBiz;
@GetMapping("/teams")
public ObjectRestResponse<PageDataVO<UserTeamMemberBo>> findTeamPage(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, HttpServletRequest request){
public ObjectRestResponse<UserTeamMemberVo> findTeamPage(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, HttpServletRequest request){
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
PageDataVO<UserTeamMemberBo> teamMemberBoPageDataVO = businessBiz.findTeamMemberPageByUserId(Integer.valueOf(infoFromToken.getId()), pageNo, pageSize);
return ObjectRestResponse.succ(teamMemberBoPageDataVO);
UserTeamMemberVo userTeamMemberVo = businessBiz.findTeamMemberPageByUserId(Integer.valueOf(infoFromToken.getId()), pageNo, pageSize);
return ObjectRestResponse.succ(userTeamMemberVo);
} catch (Exception e) {
throw new BaseException(e);
}
......
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.AdminBootstrap;
import com.github.wxiaoqi.security.admin.biz.BaseUserMemberBiz;
import com.github.wxiaoqi.security.admin.biz.BaseUserMemberExportBiz;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.excel.ExcelImport;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* ${DESCRIPTION}
......@@ -33,9 +19,6 @@ public class UserMemberController {
@Autowired
private BaseUserMemberBiz memberBiz;
@Autowired
private BaseUserMemberExportBiz baseUserMemberExportBiz;
/**
* 购买会员
*
......@@ -66,8 +49,4 @@ public class UserMemberController {
) throws Exception {
return memberBiz.upMemberDays(userId, days, type);
}
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 11:35
*/
@RestController
@RequestMapping("/sellingwater")
public class UserSellingWaterController {
@Autowired
private AppUserSellingWaterBiz appUserSellingWaterBiz;
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@GetMapping("/page")
public ObjectRestResponse<SellingWalletPagVo> findSellingWaterPage(@RequestParam(required = false,value = "type") Integer wating,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
HttpServletRequest request) {
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
SellingWalletPagVo sellingWalletPagVo = appUserSellingWaterBiz.findSellingWaterPageByWaiting(wating, Integer.valueOf(infoFromToken.getId()), pageNo, pageSize);
return ObjectRestResponse.succ(sellingWalletPagVo);
} catch (Exception e) {
throw new BaseException(e);
}
}
}
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.MyWalletCathBiz;
import com.github.wxiaoqi.security.admin.vo.WalletCathPageVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/12 14:17
*/
@RestController
@RequestMapping("/walletcath")
public class WalletCathController {
@Autowired
private MyWalletCathBiz myWalletCathBiz;
@Autowired
private UserAuthUtil userAuthUtil;
@Autowired
private UserAuthConfig userAuthConfig;
@GetMapping
public ObjectRestResponse<WalletCathPageVo> findWatchCatchByWithdrawalState(@RequestParam("state") Integer state,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
HttpServletRequest request) {
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
WalletCathPageVo catchByWithdrawa = myWalletCathBiz.findWatchCatchByWithdrawalState(Integer.valueOf(infoFromToken.getId()), state, pageNo, pageSize);
return ObjectRestResponse.succ(catchByWithdrawa);
} catch (Exception e) {
throw new BaseException(e);
}
}
}
......@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.admin.dto.UserMemberSaveDTO;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.excel.ExcelImport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -26,11 +28,13 @@ import java.util.List;
*/
@RestController
@RequestMapping("/admin/member")
@Api("后台*会员管理")
public class UserMemberAdminController {
@Autowired
private BaseUserMemberExportBiz baseUserMemberExportBiz;
@ApiOperation("批量导入会员")
@PostMapping("/user/export")
public ObjectRestResponse importUserMember(@RequestPart("file") MultipartFile userMemberExcel) {
List<String[]> userMemberData = ExcelImport.getExcelData(userMemberExcel);
......@@ -52,6 +56,7 @@ public class UserMemberAdminController {
}
@ApiOperation("会员excel模板下载")
@GetMapping("/app/unauth/user/excel_model/dowload")
public ResponseEntity<byte[]> dowloadUserMemberExcelModel(HttpServletResponse response){
// 重置response
......@@ -68,6 +73,8 @@ public class UserMemberAdminController {
}
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
@ApiOperation("会员新增")
@PostMapping("/save")
public ObjectRestResponse<Void> saveUserMember(@RequestBody UserMemberSaveDTO userMemberSaveDTO) {
baseUserMemberExportBiz.saveUserMember(userMemberSaveDTO);
......
<?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.github.wxiaoqi.security.admin.mapper.MyWalletMapper">
<update id="updMyWater" parameterType="com.github.wxiaoqi.security.admin.entity.MyWallet">
update my_wallet
<set>
<if test=" userId!=null and userId!=''">
user_id=#{userId},
</if>
<if test="balance!=null and balance!='' ">
balance=#{balance},
</if>
<if test="balance!=null and balance!='' ">
withdrawals=#{withdrawals},
</if>
<if test="totalAmount!=null and totalAmount!='' ">
total_amount=#{totalAmount},
</if>
<if test="todayAmount!=null and todayAmount!='' ">
today_amount=#{todayAmount},
</if>
<if test="unbooked!=null and unbooked!='' ">
unbooked=#{unbooked},
</if>
<if test="isFrozen!=null and isFrozen!='' ">
is_frozen=#{isFrozen},
</if>
<if test="lastIntime!=null and lastIntime!='' ">
last_intime=#{lastIntime},
</if>
<if test="crtTime!=null and crtTime!='' ">
crt_time=#{crtTime},
</if>
<if test="updTime!=null and updTime!='' ">
upd_time=#{updTime},
</if>
<if test="version!=null and version!='' ">
version=version+1,
</if>
</set>
<where>
id=#{id} and version=#{version}
</where>
</update>
</mapper>
\ No newline at end of file
......@@ -114,6 +114,12 @@ public class IntegralRule{
*/
private String name;
/**
* 规则名称
*/
private String code;
/**
* 获取积分规则
*/
......
package com.xxfc.platform.activity.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import javax.persistence.Column;
......@@ -8,6 +10,7 @@ import javax.persistence.Table;
@Table(name = "integral_user_record")
@Data
@Builder
public class IntegralUserRecord {
/**
* 主键id
......@@ -34,8 +37,8 @@ public class IntegralUserRecord {
/**
* 积分规则id
*/
@Column(name = "integral_rule_id")
private Integer integralRuleId;
@Column(name = "integral_rule_code")
private String integralRuleCode;
/**
* 积分时间
......
......@@ -10,105 +10,7 @@ public class IntegralRuleDto extends PageParam {
/**
* 主键id
*/
private Integer id;
Integer id;
/**
* 周期单位:0-天,1-周;3-月;4-季;5-年
*/
private Integer period;
/**
* 次数
*/
private Integer number;
/**
* 积分
*/
private Integer point;
/**
* 积分兑换:金额/分
*/
private BigDecimal price;
/**
* 是否连续:0-不连续;1-连续
*/
private Boolean isContinuity;
/**
* 多少天后连续算
*/
private Integer finishDay;
/**
* n天获取的积分
*/
private Integer finishPoint;
/**
* 是否启用:1-启用;0-停用
*/
private Boolean status;
/**
* 创建时间
*/
private Long crtTime;
/**
* 是否删除:0-正常;1-删除
*/
private Boolean isdel;
/**
* 规则开始时间
*/
private Long startTime;
/**
* 规则结束时间
*/
private Long endTime;
/**
* 更新时间
*/
private Long updTime;
/**
* 备注
*/
private String remarks;
/**
* 描述
*/
private String desc;
/**
* 规则图片
*/
private String img;
/**
* 排序
*/
private Integer orderId;
/**
* 规则名称
*/
private String name;
/**
* 获取积分规则
*/
private String regulation;
/**
* json字符串 如:[{"day":4,"integeral":8},{"day":4,"integeral":8}]
*/
private String otherRule;
String code;
}
package com.xxfc.platform.activity.vo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.activity.entity.IntegralUserRecord;
import lombok.Data;
@Data
......@@ -8,6 +9,23 @@ public class IntegralUserRecordDto extends PageParam {
Integer userId;
Long startTime;
Long endTime;
Integer integralRuleId;
String integralRuleCode;
String amount;
/**
* 0-获取积分;1-抵扣积分
*/
private Integer type;
/**
* 积分数
*/
private Integer point;
/**
* 获取积分的途径id:如订单id,评论id,签到记录id
*/
private Integer channelId;
public IntegralUserRecord getIntegralUserRecord() {
return IntegralUserRecord.builder().integralRuleCode(integralRuleCode).userId(userId).channelId(channelId).point(point).type(type).isdel(false).isValid(true).build();
}
}
......@@ -60,12 +60,15 @@ public class IntegralRuleBiz extends BaseBiz<IntegralRuleMapper, IntegralRule> {
return ObjectRestResponse.succ();
}
public ObjectRestResponse<IntegralRule> getOne(IntegralRule integralRule) {
public ObjectRestResponse<IntegralRule> getOne(IntegralRuleDto integralRule) {
if(integralRule == null) {
return ObjectRestResponse.paramIsEmpty();
}
IntegralRule oldValue = mapper.selectByPrimaryKey(integralRule.getId());
return ObjectRestResponse.succ(oldValue);
List<IntegralRule> oldValue = mapper.selectAllByParam(integralRule);
if(oldValue != null && oldValue.size() > 0) {
return ObjectRestResponse.succ(oldValue.get(0));
}
return ObjectRestResponse.succ();
}
......
......@@ -14,6 +14,7 @@ import com.xxfc.platform.activity.entity.IntegralUserTotal;
import com.xxfc.platform.activity.mapper.IntegralSignRecordMapper;
import com.xxfc.platform.activity.user.UserInfoBiz;
import com.xxfc.platform.activity.util.IntegralToolsUtils;
import com.xxfc.platform.activity.vo.IntegralRuleDto;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import com.xxfc.platform.activity.vo.IntegralUserTotalDto;
import org.apache.commons.lang3.StringUtils;
......@@ -44,17 +45,20 @@ public class IntegralSignRecordBiz extends BaseBiz<IntegralSignRecordMapper, Int
* 签到
* @return
*/
public ObjectRestResponse add(Integer integralRuleId) {
public ObjectRestResponse add(String code) {
AppUserDTO appUserDTO = userInfoBiz.getUserInfo();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(508, "token is null or invalid");
}
if(StringUtils.isBlank(code)) {
return ObjectRestResponse.createDefaultFail();
}
List<IntegralSignRecord> integralSignRecordList = mapper.selectByUserId(appUserDTO.getUserid());
//第一次签到 默认连续1
if(integralSignRecordList == null || integralSignRecordList.size() <= 0) {
IntegralSignRecord integralSignRecord = new IntegralSignRecord();
IntegralRule integralRule = new IntegralRule();
integralRule.setId(integralRuleId);
IntegralRuleDto integralRule = new IntegralRuleDto();
integralRule.setCode(code);
ObjectRestResponse<IntegralRule> objectRestResponse = integralRuleBiz.getOne(integralRule);
if(objectRestResponse.getData() != null) {
integralSignRecord.setUserId(appUserDTO.getUserid());
......@@ -73,8 +77,8 @@ public class IntegralSignRecordBiz extends BaseBiz<IntegralSignRecordMapper, Int
IntegralSignRecord integralSignRecord = integralSignRecordList.get(0);
//判断最后签到的时间和当前时间是不是相差一天
int day = IntegralToolsUtils.differentDaysByMillisecond(integralSignRecord.getLastTime(), new Date().getTime());
IntegralRule integralRule = new IntegralRule();
integralRule.setId(integralRuleId);
IntegralRuleDto integralRule = new IntegralRuleDto();
integralRule.setCode(code);
ObjectRestResponse<IntegralRule> objectRestResponse = integralRuleBiz.getOne(integralRule);
if(objectRestResponse.getData() != null) {
if(day == 1) {//第二天续签
......@@ -139,13 +143,11 @@ public class IntegralSignRecordBiz extends BaseBiz<IntegralSignRecordMapper, Int
}
//添加积分记录
List<IntegralSignRecord> integralSignRecords = mapper.selectByUserId(appUserDTO.getUserid());
IntegralUserRecord integralUserRecord = new IntegralUserRecord();
IntegralUserRecordDto integralUserRecord = new IntegralUserRecordDto();
integralUserRecord.setUserId(appUserDTO.getUserid());
integralUserRecord.setType(0);
integralUserRecord.setIsdel(false);
integralUserRecord.setChannelId(integralSignRecords.get(0).getId());
integralUserRecord.setIntegralRuleId(integralRule.getId());
integralUserRecord.setIsValid(true);
integralUserRecord.setIntegralRuleCode(integralRule.getCode());
integralUserRecord.setPoint(point);
integralUserRecordBiz.add(integralUserRecord);
}
......@@ -170,7 +172,7 @@ public class IntegralSignRecordBiz extends BaseBiz<IntegralSignRecordMapper, Int
public boolean getSignNumberBoolean(AppUserDTO appUserDTO, IntegralRule integralRule) {
IntegralUserRecordDto integralUserRecordDto = new IntegralUserRecordDto();
integralUserRecordDto.setUserId(appUserDTO.getUserid());
integralUserRecordDto.setIntegralRuleId(integralRule.getId());
integralUserRecordDto.setIntegralRuleCode(integralRule.getCode());
switch (integralRule.getPeriod()) {
case 0 : //日
return getBoolean(IntegralToolsUtils.getDayStart(), IntegralToolsUtils.getDayStart() + 24 * 60 * 60 * 1000 - 1, integralUserRecordDto, integralRule);
......
......@@ -55,6 +55,34 @@ public class IntegralUserTotalBiz extends BaseBiz<IntegralUserTotalMapper, Integ
return ObjectRestResponse.succ();
}
public ObjectRestResponse update(IntegralUserTotalDto integralUserTotalDto) {
if(integralUserTotalDto == null || integralUserTotalDto.getUserId() == null) {
return ObjectRestResponse.paramIsEmpty();
}
List<IntegralUserTotal> integralUserTotalList = mapper.selectAllByParam(integralUserTotalDto);
if(integralUserTotalList != null && integralUserTotalList.size() > 0) {
if(integralUserTotalDto.getPoint() > 0) {//加
integralUserTotalList.get(0).setTotalPoint(integralUserTotalList.get(0).getTotalPoint() + integralUserTotalDto.getPoint());
integralUserTotalList.get(0).setRestPoint(integralUserTotalList.get(0).getRestPoint() + integralUserTotalDto.getPoint());
updateByIdRe( integralUserTotalList.get(0));
return ObjectRestResponse.succ();
} else { //减积分
integralUserTotalList.get(0).setRestPoint(integralUserTotalList.get(0).getTotalPoint() + integralUserTotalDto.getPoint());
updateByIdRe( integralUserTotalList.get(0));
return ObjectRestResponse.succ();
}
}
IntegralUserTotal integralUserTotal = new IntegralUserTotal();
integralUserTotal.setUserId(integralUserTotalDto.getUserId());
integralUserTotal.setTotalPoint(integralUserTotalDto.getPoint());
integralUserTotal.setRestPoint(integralUserTotalDto.getPoint());
integralUserTotal.setIsdel(false);
insertSelective(integralUserTotal);
return ObjectRestResponse.succ();
}
/**
* 删除信息
* @return
......
package com.xxfc.platform.activity.handler;
import com.alibaba.fastjson.JSONObject;
import com.xxfc.platform.activity.biz.IntegralUserRecordBiz;
import com.xxfc.platform.activity.vo.IntegralUserRecordDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class IntegralMQHandler {
@Autowired
IntegralUserRecordBiz integralUserRecordBiz;
@RabbitListener(queues = "integral_queue")
public void integralHandler(String json) {
log.info("接收到的消息:json = {}", json);
try{
if(StringUtils.isNotBlank(json)) {
IntegralUserRecordDto integralUserRecordDto = JSONObject.parseObject(json, IntegralUserRecordDto.class);
integralUserRecordBiz.add(integralUserRecordDto);
}
}catch (Exception e){
log.info("接收到的消息失败");
e.printStackTrace();
}
}
}
......@@ -37,8 +37,8 @@ public class IntegralRuleController {
@GetMapping(value = "/one")
@ApiOperation(value = "根据id获取制定规则")
public ObjectRestResponse<IntegralRule> getOne(IntegralRule integralRule) {
return integralRuleBiz.getOne(integralRule);
public ObjectRestResponse<IntegralRule> getOne(IntegralRuleDto integralRuleDto) {
return integralRuleBiz.getOne(integralRuleDto);
}
@GetMapping(value = "/list")
......
......@@ -17,8 +17,8 @@ public class IntegralSignRecordController {
IntegralSignRecordBiz integralSignRecordBiz;
@PostMapping(value = "/add")
public ObjectRestResponse add(Integer integralRuleId) {
return integralSignRecordBiz.add(integralRuleId);
public ObjectRestResponse add(String integralRuleCode) {
return integralSignRecordBiz.add(integralRuleCode);
}
}
......@@ -21,8 +21,8 @@ public class IntegralUserRecordController {
@PostMapping(value = "/add")
public ObjectRestResponse add(IntegralUserRecord integralUserRecord) {
return integralUserRecordBiz.add(integralUserRecord);
public ObjectRestResponse add(IntegralUserRecordDto integralUserRecordDto) {
return integralUserRecordBiz.add(integralUserRecordDto);
}
@PostMapping(value = "/delete")
......
......@@ -24,6 +24,7 @@
<result column="img" property="img" jdbcType="VARCHAR" />
<result column="order_id" property="orderId" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="regulation" property="regulation" jdbcType="LONGVARCHAR" />
<result column="other_rule" property="otherRule" jdbcType="LONGVARCHAR" />
</resultMap>
......@@ -35,6 +36,9 @@
<if test="id != null">
and id = #{id}
</if>
<if test="code != null">
and code = #{code}
</if>
and isdel = 0 and status = 1
</where>
order by order_id DESC ,crt_time DESC
......
......@@ -9,7 +9,7 @@
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="point" property="point" jdbcType="INTEGER" />
<result column="integral_rule_id" property="integralRuleId" jdbcType="INTEGER" />
<result column="integral_rule_code" property="integralRuleCode" jdbcType="INTEGER" />
<result column="crt_time" property="crtTime" jdbcType="BIGINT" />
<result column="is_valid" property="isValid" jdbcType="BIT" />
<result column="isdel" property="isdel" jdbcType="BIT" />
......@@ -27,6 +27,6 @@
</select>
<select id="selectByUserAndTime" resultType="com.xxfc.platform.activity.entity.IntegralUserRecord" parameterType="com.xxfc.platform.activity.vo.IntegralUserRecordDto">
select * from integral_user_record
where user_id = #{userId} and crt_time between #{startTime} and #{endTime} and integral_rule_id = #{integralRuleId}
where user_id = #{userId} and crt_time between #{startTime} and #{endTime} and integral_rule_code = #{integralRuleCode}
</select>
</mapper>
\ No newline at end of file
......@@ -30,6 +30,10 @@
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
......
......@@ -3,11 +3,12 @@ package com.xxfc.platform.universal.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;
@Data
@Table(name = "data_dictionary")
public class Dictionary {
public class Dictionary implements Serializable {
@Id
private Integer id;
......
package com.xxfc.platform.universal.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(value = "xx-universal", contextId = "sendMessage")
public interface MQSerderFeign {
@GetMapping(value = "/message/sendMessage")
public ObjectRestResponse sendMessage(@RequestParam(value = "exchange") String exchange, @RequestParam(value = "routingKey")String routKey, @RequestParam(value = "jsonParam") String jsonParam);
}
package com.xxfc.platform.universal.mq;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.transaction.RabbitTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
/**
* 项目中Mq的自动配置
*
* @author Vangelis
* @date 2019-06-01 20:36
*/
@Configuration
@Slf4j
@AllArgsConstructor
public class MQAutoConfiguration {
private final ConnectionFactory connectionFactory;
@Bean
@Scope("prototype")
public RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
//开启回调 必须设置为true
rabbitTemplate.setMandatory(true);
rabbitTemplate.setConfirmCallback((correlationData,ack,cause)->{
//实现消息到达交换器的回调方法
log.info("RabbitMQ sendMessage-->confirm-->start correlationData:{},ack:{},cause:{}",correlationData,ack,cause);
log.info("RabbitMQ sendMessage-->confirm-->end");
});
rabbitTemplate.setReturnCallback((message,replyCode,replyText,exchange,routingKey)->{
//实现消息到达队列的回调方法
log.info("RabbitMQ sendMessage-->returnedMessage-->start message:{},replyCode:{},replyText:{},exchange:{},routingKey:{}"
,message.toString(),replyCode,replyText,exchange,routingKey);
log.info("RabbitMQ sendMessage-->returnedMessage-->end");
});
return rabbitTemplate;
}
/**
* 监听器中默认封装实现
*/
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setConcurrentConsumers(3);
factory.setMaxConcurrentConsumers(10);
return factory;
}
/**
* 配置启用rabbitmq事务
*/
@Bean
public RabbitTransactionManager rabbitTransactionManager(CachingConnectionFactory connectionFactory) {
return new RabbitTransactionManager(connectionFactory);
}
}
package com.xxfc.platform.universal.mq;
import org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
import org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory;
@Configuration
public class RabbitConfig implements RabbitListenerConfigurer {
@Override
public void configureRabbitListeners(RabbitListenerEndpointRegistrar registrar) {
registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory());
}
@Bean
MessageHandlerMethodFactory messageHandlerMethodFactory() {
DefaultMessageHandlerMethodFactory messageHandlerMethodFactory = new DefaultMessageHandlerMethodFactory();
messageHandlerMethodFactory.setMessageConverter(consumerJackson2MessageConverter());
return messageHandlerMethodFactory;
}
@Bean
public MappingJackson2MessageConverter consumerJackson2MessageConverter() {
return new MappingJackson2MessageConverter();
}
}
\ No newline at end of file
package com.xxfc.platform.universal.mq;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
/**
* RabbitMQ封装发送消息
*
* @author Vangelis
* @date 2019-06-02 11:56
*/
@AllArgsConstructor
@Slf4j
@Component
@Scope("prototype")
public class RabbitMQSender implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback{
private RabbitTemplate rabbitTemplate;
@PostConstruct
private void init() {
// 使用当前类作为发送后回调通知
rabbitTemplate.setConfirmCallback(this);
//是否当前类作为返回失败错误处理
rabbitTemplate.setReturnCallback(this);
}
/**
* Confirmation callback.
*
* @param correlationData correlation data for the callback.
* @param ack true for ack, false for nack
* @param cause An optional cause, for nack, when available, otherwise null.
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
if (ack) {
log.info("消息已经确认收到");
}else {
log.info("消息没有确认收到,你该在这里写没有收到消息的处理代码");
}
}
/**
* 开启事务发送消息的封装
* @param exchange exchange
* @param routingKey routingKey
* @param msg 消息体
*/
@Transactional(rollbackFor = Exception.class)
public void sendMsg(String exchange,String routingKey,Object msg) {
log.info("使用事务发送消息,msg{}", msg);
rabbitTemplate.convertAndSend(exchange,routingKey,msg);
}
/**
* Returned message callback.
*
* @param message the returned message.
* @param replyCode the reply code.
* @param replyText the reply text.
* @param exchange the exchange.
* @param routingKey the routing key.
*/
@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
log.info("消息返回没有收到");
}
}
......@@ -34,6 +34,7 @@
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
......
package com.xxfc.platform.universal.biz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.entity.Dictionary;
import lombok.AllArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
public class MQServiceBiZ {
private RabbitTemplate rabbitTemplate;
public ObjectRestResponse sendMessage(String exchange, String routKey, String json) {
rabbitTemplate.convertAndSend(exchange, routKey, json);
return ObjectRestResponse.succ();
}
}
package com.xxfc.platform.universal.controller;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.biz.MQServiceBiZ;
import com.xxfc.platform.universal.entity.Dictionary;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "message")
public class MQSenderController {
@Autowired
private MQServiceBiZ mqServiceBiZ;
@GetMapping(value = "/sendMessage")
public ObjectRestResponse sendMessage(String exchange, String routKey, String json) {
return mqServiceBiZ.sendMessage(exchange, routKey, json);
}
}
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