Commit 9f64d13f authored by hezhen's avatar hezhen

Merge branch 'dev-tiande' of http://113.105.137.151:22280/youjj/cloud-platform into dev-tiande

parents fb0a5656 8edc1eae
...@@ -24,6 +24,8 @@ public class RabbitConstant { ...@@ -24,6 +24,8 @@ public class RabbitConstant {
//用户 //用户
public static final String KEY_APPUSER_REGISTER = "appUser.register"; public static final String KEY_APPUSER_REGISTER = "appUser.register";
public static final String KEY_APPUSER_AUTH = "appUser.auth"; public static final String KEY_APPUSER_AUTH = "appUser.auth";
public static final String KEY_MEMBER_SHARE = "member.share";
//积分 //积分
public static final String INTEGRAL_ROUTING_KEY = "integral_routing_key"; public static final String INTEGRAL_ROUTING_KEY = "integral_routing_key";
...@@ -36,6 +38,9 @@ public class RabbitConstant { ...@@ -36,6 +38,9 @@ public class RabbitConstant {
public static final String KEY_ORDER_END_1 = "order.end.1"; public static final String KEY_ORDER_END_1 = "order.end.1";
public static final String KEY_ORDER_END_2 = "order.end.2"; public static final String KEY_ORDER_END_2 = "order.end.2";
//钱包 //钱包
public static final String KEY_WALLET_ADD = "wallet.add"; public static final String KEY_WALLET_ADD = "wallet.add";
......
...@@ -40,7 +40,7 @@ public class OrderUtil { ...@@ -40,7 +40,7 @@ public class OrderUtil {
if (orderIndex.intValue() > 9999) { if (orderIndex.intValue() > 9999) {
orderIndex = new AtomicInteger(1); orderIndex = new AtomicInteger(1);
} }
String indexString = String.format("%s%s%04d", currTime, midFix, orderIndex); String indexString = String.format("%s%s%04d", currTime, midFix, orderIndex.intValue());
return indexString; return indexString;
} }
......
package com.github.wxiaoqi.security.admin.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
/**
* @ClassName : MemberShareCountRecordDto
* @Description : 会员分成统计
* @Author : jiaoruizhen
* @Date: 2020-11-04 15:02
*/
@Data
public class MemberShareCountRecordDto extends PageParam {
private Long userId;
private String countMonth;
private String startDate;
private String endDate;
}
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 会员分成月统计信息
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
@Data
@Table(name = "member_share_count_record")
public class MemberShareCountRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 会员用户分成月统计id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("会员用户分成月统计id")
private Long id;
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Long userId;
/**
* 用户姓名
*/
@Column(name = "real_name")
@ApiModelProperty(value = "用户姓名")
private String realName;
/**
* 统计月份
*/
@Column(name = "count_month")
@ApiModelProperty(value = "统计月份")
private String countMonth;
/**
* 总金额
*/
@Column(name = "amount")
@ApiModelProperty(value = "总金额")
private BigDecimal amount;
/**
*
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "", hidden = true )
private Long crtTime;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true )
private Long updTime;
/**
* 会员等级
*/
@Column(name = "member_level")
@ApiModelProperty(value = "会员等级")
private Integer memberLevel;
}
package com.github.wxiaoqi.security.admin.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 会员分成记录
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
@Data
@Table(name = "member_share_record")
public class MemberShareRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 会员分成记录id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("会员分成记录id")
private Long id;
/**
* 订单编号
*/
@Column(name = "order_no")
@ApiModelProperty(value = "订单编号")
private String orderNo;
/**
* 参与会员用户id,用逗号分隔
*/
@Column(name = "member_ids")
@ApiModelProperty(value = "参与会员用户id,用逗号分隔")
private String memberIds;
/**
* 会员订单支付时间
*/
@Column(name = "pay_time")
@ApiModelProperty(value = "会员订单支付时间")
private Long payTime;
/**
* 会员等级
*/
@Column(name = "member_level")
@ApiModelProperty(value = "会员等级")
private Integer memberLevel;
/**
* 会员等级id
*/
@Column(name = "member_level_id")
@ApiModelProperty(value = "会员等级id")
private Integer memberLevelId;
/**
* 订单金额
*/
@Column(name = "order_amount")
@ApiModelProperty(value = "订单金额")
private BigDecimal orderAmount;
/**
* 总分成金额
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "总分成金额")
private BigDecimal totalAmount;
/**
* 每人可分成金额
*/
@Column(name = "amount")
@ApiModelProperty(value = "每人可分成金额")
private BigDecimal amount;
/**
*
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "", hidden = true )
private Long crtTime;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true )
private Long updTime;
/**
* 订单下单用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "订单下单用户id")
private Long userId;
/**
* 下单时间
*/
@Column(name = "order_time")
@ApiModelProperty(value = "下单时间")
private Long orderTime;
/**
* 分成人数
*/
@Column(name = "member_num")
@ApiModelProperty(value = "分成人数")
private Integer memberNum;
}
...@@ -144,6 +144,13 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem ...@@ -144,6 +144,13 @@ public class BaseUserMemberBiz extends BaseBiz<BaseUserMemberMapper, BaseUserMem
} }
private void generateData(Integer level, Long userId) {
List<BaseUserMember> baseUserMemberList = getMyBiz().selectList(new BaseUserMember(){{setIsBind(1); setIsDel(0);setMemberLevel(level);}});
if (baseUserMemberList != null && baseUserMemberList.size() > 0) {
}
}
/** /**
* // * //
* *
......
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.admin.dto.MemberShareCountRecordDto;
import com.github.wxiaoqi.security.admin.entity.MemberShareCountRecord;
import com.github.wxiaoqi.security.admin.mapper.MemberShareCountRecordMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.*;
/**
* 会员分成月统计信息
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
@Service
@Slf4j
public class MemberShareCountRecordBiz extends BaseBiz<MemberShareCountRecordMapper, MemberShareCountRecord> {
public void batchSave(List<MemberShareCountRecord> list) {
mapper.batchSave(list);
}
/**
* 分页查询统计信息
* @param memberShareCountRecordDto
* @return
*/
public ObjectRestResponse selectList(MemberShareCountRecordDto memberShareCountRecordDto) {
Query query = new Query(memberShareCountRecordDto);
PageDataVO<MemberShareCountRecord> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectList(query.getSuper()));
return ObjectRestResponse.succ(pageDataVO);
}
/**
* 会员分成导出信息
* @param httpServletResponse
* @param memberShareCountRecordDto
* @throws Exception
*/
public void exportRecordList(HttpServletResponse httpServletResponse, MemberShareCountRecordDto memberShareCountRecordDto)throws Exception {
ExcelWriter writer = null;
try {
writer = ExcelUtil.getWriter(true);
//封装表头
writer.addHeaderAlias("countMonth", "统计月份");
writer.addHeaderAlias("userId", "用户id");
writer.addHeaderAlias("realName", "真实姓名");
writer.addHeaderAlias("amount", "金额");
//处理数据
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
memberShareCountRecordDto.setLimit(Integer.MAX_VALUE);
Query query = new Query(memberShareCountRecordDto);
List<MemberShareCountRecord> memberShareCountRecordList = mapper.selectList(query.getSuper());
if (memberShareCountRecordList != null && memberShareCountRecordList.size() > 0) {
for (MemberShareCountRecord memberShareCountRecord : memberShareCountRecordList) {
Map<String, Object> map = new HashMap();
map.put("userId", memberShareCountRecord.getUserId());
map.put("realName", memberShareCountRecord.getRealName());
map.put("countMonth", memberShareCountRecord.getCountMonth());
map.put("amount", memberShareCountRecord.getAmount());
list.add(map);
}
}
if (list.size() == 0) {
Map<String, Object> map = new HashMap<String, Object>();
writer.addHeaderAlias("countMonth", "统计月份");
writer.addHeaderAlias("userId", "用户id");
writer.addHeaderAlias("realName", "真实姓名");
writer.addHeaderAlias("amount", "金额");
map.put("userId", "");
map.put("realName", "");
map.put("countMonth", "");
map.put("amount", "");
list.add(map);
}
writer.write(list);
httpServletResponse.setContentType("application/octet-stream;charset=utf-8");
httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("会员分成明细.xlsx", "utf-8"));
writer.flush(httpServletResponse.getOutputStream());
}catch (Exception ex) {
log.error(ex.getMessage(), ex);
throw ex;
}finally {
if (writer != null) {
writer.close();
}
}
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.biz;
import cn.hutool.core.map.MapUtil;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.entity.MemberShareCountRecord;
import com.github.wxiaoqi.security.admin.entity.MemberShareRecord;
import com.github.wxiaoqi.security.admin.mapper.BaseUserMemberLevelMapper;
import com.github.wxiaoqi.security.admin.mapper.MemberShareRecordMapper;
import com.github.wxiaoqi.security.admin.util.DateUtils;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.order.entity.OrderMemberDetail;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 会员分成记录
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
@Service
@Slf4j
public class MemberShareRecordBiz extends BaseBiz<MemberShareRecordMapper, MemberShareRecord> {
@Autowired
MemberShareCountRecordBiz memberShareCountRecordBiz;
@Autowired
BaseUserMemberBiz baseUserMemberBiz;
@Autowired
BaseUserMemberLevelMapper baseUserMemberLevelMapper;
/**
* 根据订单号查询分成记录
* 每个订单有且只有一条记录
* @param no
* @return
*/
public MemberShareRecord getOneByOrderNo(String no) {
Example example = new Example(MemberShareRecord.class);
example.createCriteria().andEqualTo("orderNo", no);
return mapper.selectOneByExample(example);
}
/**
* 新增或者编辑会员分成记录
* @param memberShareRecord
*/
public void addUpdate(MemberShareRecord memberShareRecord) {
if (memberShareRecord != null) {
MemberShareRecord old = getOneByOrderNo(memberShareRecord.getOrderNo());
if (old == null) {
insertSelectiveRe(memberShareRecord);
updateAllLevelInfo(memberShareRecord);
} else {
if (StringUtils.isNotBlank(memberShareRecord.getMemberIds())) {
old.setMemberIds(memberShareRecord.getMemberIds());
}
if (memberShareRecord.getMemberNum() != null) {
old.setMemberNum(memberShareRecord.getMemberNum());
}
if (memberShareRecord.getAmount() != null) {
old.setAmount(memberShareRecord.getAmount());
}
updateSelectiveByIdRe(old);
updateAllLevelInfo(old);
}
}
generateData();
}
/**
* 查看某一用户分成记录明细
* @return
*/
public ObjectRestResponse<List<MemberShareRecord>> getAllRecord(Long userId) {
Example example = new Example(MemberShareRecord.class);
example.createCriteria().andLike("memberIds", "%," + userId + ",%");
return ObjectRestResponse.succ(mapper.selectByExample(example));
}
/**
* 更新相同会员等级的分成信息
* @param memberShareRecord
*/
public void updateAllLevelInfo(MemberShareRecord memberShareRecord) {
if (memberShareRecord != null && memberShareRecord.getMemberLevel() != null) {
List<MemberShareRecord> list = getAllByLevel(memberShareRecord.getMemberLevel());
if (list != null && list.size() > 0) {
list.parallelStream().forEach(record -> {
if (StringUtils.isNotBlank(memberShareRecord.getMemberIds())) {
record.setMemberIds(memberShareRecord.getMemberIds());
}
if (memberShareRecord.getMemberNum() != null) {
record.setMemberNum(memberShareRecord.getMemberNum());
}
if (memberShareRecord.getAmount() != null) {
record.setAmount(memberShareRecord.getAmount());
}
updateSelectiveByIdRe(record);
});
}
}
}
/**
* 获取同级别的所有分成记录
* @param level
* @return
*/
private List<MemberShareRecord> getAllByLevel(Integer level) {
Example example = new Example(MemberShareRecord.class);
example.createCriteria().andEqualTo("memberLevel", level);
return mapper.selectByExample(example);
}
/**
* 根据日期查询所有分成记录
* @param startDate
* @param endDate
* @return
*/
private List<MemberShareRecord> getAllByDate(Long startDate, Long endDate) {
Example example = new Example(MemberShareRecord.class);
example.createCriteria().andBetween("payTime", startDate, endDate);
return mapper.selectByExample(example);
}
/**
* 统计分成信息
*/
public void generateData() {
DateTime dateTime = DateTime.now().minusMonths(1);
Long startDate = DateUtils.getStartOfDay(dateTime.toDate());
Long endDate = DateUtils.getEndOfDay(dateTime.toDate());
List<MemberShareRecord> list = getAllByDate(startDate, endDate);
if (list != null && list.size() > 0) {
Map<Integer, List<MemberShareRecord>> groupedMap =
list.stream().collect(Collectors.groupingBy(MemberShareRecord::getMemberLevel));
if (MapUtil.isNotEmpty(groupedMap)) {
for (Map.Entry<Integer, List<MemberShareRecord>> entry : groupedMap.entrySet()) {
Integer level = entry.getKey();
List<MemberShareRecord> memberShareRecordList = entry.getValue();
generateDataByUser(memberShareRecordList, level, dateTime);
}
}
}
}
private void generateDataByUser(List<MemberShareRecord> memberShareRecordList, Integer level, DateTime dateTime) {
if (memberShareRecordList != null) {
Map<Long, BigDecimal> amountMap = new HashMap<>();
memberShareRecordList.parallelStream().forEach(memberShareRecord -> {
if (StringUtils.isNotBlank(memberShareRecord.getMemberIds())) {
String[] arr = memberShareRecord.getMemberIds().split(",");
if (arr != null) {
for (String id : arr) {
if (StringUtils.isNotBlank(id)) {
Long userId = Long.parseLong(id);
if (amountMap.get(userId) != null) {
amountMap.put(userId, amountMap.get(userId).add(memberShareRecord.getAmount()));
} else {
amountMap.put(userId, memberShareRecord.getAmount());
}
}
}
}
}
});
if (MapUtil.isNotEmpty(amountMap)) {
List<MemberShareCountRecord> memberShareCountRecordList = new ArrayList<>();
for (Map.Entry<Long, BigDecimal> entry : amountMap.entrySet()) {
MemberShareCountRecord memberShareCountRecord = new MemberShareCountRecord();
memberShareCountRecord.setUserId(entry.getKey());
memberShareCountRecord.setAmount(entry.getValue());
memberShareCountRecord.setMemberLevel(level);
memberShareCountRecord.setCountMonth(dateTime.toString("yyyy-MM"));
memberShareCountRecord.setCrtTime(System.currentTimeMillis());
memberShareCountRecord.setUpdTime(System.currentTimeMillis());
memberShareCountRecordList.add(memberShareCountRecord);
}
if (memberShareCountRecordList.size() > 0) {
memberShareCountRecordBiz.batchSave(memberShareCountRecordList);
}
}
}
}
/**
* 接收会员订单支付成功后处理
* @param orderMemberDetail
*/
public void generateMemberShareQueue(OrderMemberDetail orderMemberDetail) {
if (orderMemberDetail != null) {
log.info("会员订单信息: {}", orderMemberDetail);
BaseUserMemberLevel baseUserMemberLevel = baseUserMemberLevelMapper.selectOne(new BaseUserMemberLevel(){{setIsdel(0); setId(orderMemberDetail.getMemberLevelId());}});
log.info("会员等级信息: {}", baseUserMemberLevel);
if (baseUserMemberLevel != null && baseUserMemberLevel.getIsShare() == 1) {
List<BaseUserMember> baseUserMemberList = baseUserMemberBiz.selectList(new BaseUserMember(){{setIsDel(0); setMemberLevel(orderMemberDetail.getMemberLevel());}});
if (baseUserMemberList != null && baseUserMemberList.size() > 0) {
List<Integer> userIds = baseUserMemberList.stream().map(BaseUserMember::getUserId).collect(Collectors.toList());
if (userIds != null && userIds.size() > 0) {
MemberShareRecord memberShareRecord = new MemberShareRecord();
memberShareRecord.setOrderNo(orderMemberDetail.getBaseOrder().getNo());
memberShareRecord.setPayTime(orderMemberDetail.getBaseOrder().getPayTime());
memberShareRecord.setOrderAmount(orderMemberDetail.getBaseOrder().getOrderAmount());
memberShareRecord.setMemberLevel(orderMemberDetail.getMemberLevel());
memberShareRecord.setMemberLevelId(orderMemberDetail.getMemberLevelId());
memberShareRecord.setUserId(orderMemberDetail.getBaseOrder().getUserId().longValue());
memberShareRecord.setOrderTime(orderMemberDetail.getCrtTime());
memberShareRecord.setTotalAmount(baseUserMemberLevel.getShareAmount());
memberShareRecord.setMemberNum(userIds.size());
memberShareRecord.setAmount(baseUserMemberLevel.getShareAmount().divide(new BigDecimal(userIds.size()).setScale(2, BigDecimal.ROUND_HALF_UP)));
StringBuilder stringBuilder = new StringBuilder();
userIds.parallelStream().forEach(id -> {
stringBuilder.append(",");
stringBuilder.append(id);
stringBuilder.append(",");
});
memberShareRecord.setMemberIds(stringBuilder.toString());
addUpdate(memberShareRecord);
}
}
}
}
}
}
\ No newline at end of file
...@@ -33,6 +33,7 @@ public class RabbitAdminConfig extends RabbitCommonConfig { ...@@ -33,6 +33,7 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
//同步门店信息 //同步门店信息
public static final String COMPANY_UPD_QUEUE = "company:upd.queue"; public static final String COMPANY_UPD_QUEUE = "company:upd.queue";
public static final String MEMBER_SHARE_QUEUE = "admin.member.share";
static { static {
myQueue = new ArrayList<BindDTO>() {{ myQueue = new ArrayList<BindDTO>() {{
...@@ -50,6 +51,8 @@ public class RabbitAdminConfig extends RabbitCommonConfig { ...@@ -50,6 +51,8 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
add(new BindDTO(CORPORATION_UPD_QUEUE, VEHICLE_TOPIC, KEY_CORPORATION_UPD)); add(new BindDTO(CORPORATION_UPD_QUEUE, VEHICLE_TOPIC, KEY_CORPORATION_UPD));
//门店 //门店
add(new BindDTO(COMPANY_UPD_QUEUE, VEHICLE_TOPIC, KEY_COMPANY_UPD)); add(new BindDTO(COMPANY_UPD_QUEUE, VEHICLE_TOPIC, KEY_COMPANY_UPD));
add(new BindDTO(MEMBER_SHARE_QUEUE, ADMIN_TOPIC, KEY_MEMBER_SHARE));
}}; }};
} }
} }
......
package com.github.wxiaoqi.security.admin.handler;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.biz.MemberShareRecordBiz;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.entity.OrderMemberDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.util.Map;
import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.MEMBER_SHARE_QUEUE;
/**
* @ClassName : MemberShareMQHandler
* @Description : 会员分成消息队列
* @Author : jiaoruizhen
* @Date: 2020-11-05 11:10
*/
@Component
@Slf4j
public class MemberShareMQHandler {
@Autowired
MemberShareRecordBiz memberShareRecordBiz;
@RabbitListener(queues = MEMBER_SHARE_QUEUE)
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
try {
Thread.sleep(2000);
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息-----msg===="+msg);
OrderMemberDetail orderMemberDetail = JSONUtil.toBean(msg, OrderMemberDetail.class);
memberShareRecordBiz.generateMemberShareQueue(orderMemberDetail);
} catch (Exception e) {
log.error("接收消息失败:{}", e);
}
}
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.MemberShareCountRecord;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
/**
* 会员分成月统计信息
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
public interface MemberShareCountRecordMapper extends Mapper<MemberShareCountRecord> {
void batchSave(List<MemberShareCountRecord> list);
List<MemberShareCountRecord> selectList(Map<String, Object> params);
}
package com.github.wxiaoqi.security.admin.mapper;
import com.github.wxiaoqi.security.admin.entity.MemberShareRecord;
import tk.mybatis.mapper.common.Mapper;
/**
* 会员分成记录
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-11-03 11:12:15
*/
public interface MemberShareRecordMapper extends Mapper<MemberShareRecord> {
}
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.MemberShareCountRecordBiz;
import com.github.wxiaoqi.security.admin.dto.MemberShareCountRecordDto;
import com.github.wxiaoqi.security.admin.entity.MemberShareCountRecord;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import lombok.extern.slf4j.Slf4j;
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.HttpServletResponse;
@RestController
@RequestMapping("memberShareCountRecord")
@Slf4j
public class MemberShareCountRecordController extends BaseController<MemberShareCountRecordBiz, MemberShareCountRecord> {
@GetMapping(value = "selectList")
public ObjectRestResponse selectList(MemberShareCountRecordDto memberShareCountRecordDto) {
return baseBiz.selectList(memberShareCountRecordDto);
}
@GetMapping(value = "export")
public ObjectRestResponse export(HttpServletResponse response, MemberShareCountRecordDto memberShareCountRecordDto) {
try {
baseBiz.exportRecordList(response, memberShareCountRecordDto);
} catch (Exception e) {
log.error("{}", e);
return ObjectRestResponse.createDefaultFail();
}
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.MemberShareRecordBiz;
import com.github.wxiaoqi.security.admin.entity.MemberShareRecord;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("memberShareRecord")
public class MemberShareRecordController extends BaseController<MemberShareRecordBiz, MemberShareRecord> {
/**
* 获取用户分成明细
* @param userId
* @return
*/
@GetMapping(value = "getAllRecord")
public ObjectRestResponse getAllRecord(Long userId) {
return baseBiz.getAllRecord(userId);
}
/**
* 统计用户分成信息
*/
@GetMapping(value = "/app/unauth/generateData")
public void generateData() {
baseBiz.generateData();
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.admin.util;
import org.joda.time.DateTime;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/10/23 10:52
*/
public class DateUtils {
public static LocalDate dateToLocalDate(Date date) {
return LocalDate.from(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
}
public static Date localDateToDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
/**
* 获取当天的开始时间
* @return
*/
public static long getStartOfDay() {
return getStartOfDay(new Date());
}
/**
* 获取某天的开始时间
* @param date
* @return
*/
public static long getStartOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTimeAtStartOfDay();
return startOfDay.getMillis();
}
/**
* 获取当天的结束时间
* @return
*/
public static long getEndOfDay() {
return getEndOfDay(new Date());
}
/**
* 获取某天的结束时间
* @param date
* @return
*/
public static long getEndOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime endOfDay = dateTime.millisOfDay().withMaximumValue();
return endOfDay.getMillis();
}
}
<?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.MemberShareCountRecordMapper">
<insert id="batchSave" parameterType="list">
insert into member_share_count_record ( user_id, real_name, count_month, amount, crt_time, upd_time, member_level)
VALUES
<foreach collection="list" item="emp" index="index" separator=",">
(
#{emp.userId,jdbcType=BIGINT},
#{emp.realName,jdbcType=VARCHAR},
#{emp.countMonth,jdbcType=VARCHAR},
#{emp.amount,jdbcType=DECIMAL},
#{emp.crtTime,jdbcType=TIMESTAMP},
#{emp.updTime,jdbcType=TIMESTAMP},
#{emp.memberLevel,jdbcType=INTEGER}
)
</foreach>
ON DUPLICATE KEY UPDATE
user_id = values(user_id),
real_name = values(real_name),
count_month = values(count_month),
amount = values(amount),
crt_time = values(crt_time),
upd_time = values(upd_time),
member_level = values(member_level)
</insert>
<select id="selectList" resultType="com.github.wxiaoqi.security.admin.entity.MemberShareCountRecord">
select msr.count_month as countMonth, msr.user_id as userId, sum(msr.amount) as amount, aud.realname as realName from member_share_count_record msr
LEFT JOIN app_user_detail aud on aud.userid = msr.user_id
<where>
<if test="userId != null">
and msr.user_id = #{userId}
</if>
<if test="startDate != null and startDate != ''">
and msr.count_month between #{startDate} and #{endDate}
</if>
<if test="countMonth != null and countMonth != ''">
and msr.count_month = #{countMonth}
</if>
</where>
group by msr.count_month, msr.user_id
order By msr.count_month DESC
</select>
</mapper>
\ No newline at end of file
<?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.MemberShareRecordMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.github.wxiaoqi.security.admin.entity.MemberShareRecord" id="memberShareRecordMap">
<result property="id" column="id"/>
<result property="orderNo" column="order_no"/>
<result property="memberIds" column="member_ids"/>
<result property="payTime" column="pay_time"/>
<result property="memberLevel" column="member_level"/>
<result property="memberLevelId" column="member_level_id"/>
<result property="orderAmount" column="order_amount"/>
<result property="totalAmount" column="total_amount"/>
<result property="amount" column="amount"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="userId" column="user_id"/>
<result property="orderTime" column="order_time"/>
<result property="memberNum" column="member_num"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -11,8 +11,8 @@ spring: ...@@ -11,8 +11,8 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
#url: jdbc:mysql://10.5.52.3:3306/xxfc_vehicle?useUnicode=true&characterEncoding=UTF-8 #url: jdbc:mysql://10.5.52.3:3306/xxfc_vehicle?useUnicode=true&characterEncoding=UTF-8
#url: jdbc:mysql://10.5.52.3:3306/tiande_order?useUnicode=true&characterEncoding=UTF-8 url: jdbc:mysql://10.5.52.3:3306/tiande_admin_v1?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://10.5.52.4:3307/chw_vehicle?useUnicode=true&characterEncoding=UTF-8 #url: jdbc:mysql://10.5.52.4:3307/chw_vehicle?useUnicode=true&characterEncoding=UTF-8
username: root username: root
password: sslcloud123*() password: sslcloud123*()
jackson: jackson:
......
#\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F #\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F
#\u5305\u540D #\u5305\u540D
package=com.xxfc.platform.vehicle package=com.github.wxiaoqi.security.admin
#\u4F5C\u8005 #\u4F5C\u8005
author=libin author=jiaoruizhen
#Email #Email
email=18178966185@163.com email=jiaoruizhen@126.com
#\u8868\u524D\u9519\u8BEF\u7684Unicode\u5B57\u7B26\u4E32! #\u8868\u524D\u9519\u8BEF\u7684Unicode\u5B57\u7B26\u4E32!
tablePrefix= tablePrefix=
#\u524D\u7AEF\u6A21\u5757\u524D\u7F00 #\u524D\u7AEF\u6A21\u5757\u524D\u7F00
......
...@@ -28,7 +28,7 @@ public class ${className} implements Serializable { ...@@ -28,7 +28,7 @@ public class ${className} implements Serializable {
* $column.comments * $column.comments
*/ */
@Id @Id
@GeneratedValue(generator = "JDBC") @GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("$column.comments") @ApiModelProperty("$column.comments")
private $column.attrType $column.attrname; private $column.attrType $column.attrname;
#else #else
......
package com.xxfc.platform.order.entity; package com.xxfc.platform.order.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
/** /**
* *
...@@ -82,4 +82,8 @@ public class OrderMemberDetail implements Serializable { ...@@ -82,4 +82,8 @@ public class OrderMemberDetail implements Serializable {
@Column(name = "member_level_id") @Column(name = "member_level_id")
@ApiModelProperty(value = "会员等级id") @ApiModelProperty(value = "会员等级id")
private Integer memberLevelId; private Integer memberLevelId;
@Transient
BaseOrder baseOrder;
} }
...@@ -6,9 +6,7 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -6,9 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.dto.UserMemberDTO; import com.github.wxiaoqi.security.admin.dto.UserMemberDTO;
...@@ -19,6 +17,7 @@ import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; ...@@ -19,6 +17,7 @@ import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface; import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.admin.vo.AppUserVo; import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...@@ -285,16 +284,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -285,16 +284,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
if (!companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getStartCompanyId()) && !companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getEndCompanyId())) { if (!companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getStartCompanyId()) && !companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getEndCompanyId())) {
return ObjectRestResponse.createFailedResult(ResCode.YOU_AUTH_FAIL.getCode(), ResCode.YOU_AUTH_FAIL.getDesc()); return ObjectRestResponse.createFailedResult(ResCode.YOU_AUTH_FAIL.getCode(), ResCode.YOU_AUTH_FAIL.getDesc());
} }
if (userDTO.getCompanyId() == orderPageVo.getOrderRentVehicleDetail().getEndCompanyId()) {
orderPageVo.setUserCompanyStatus(true);
}
if (orderPageVo.getStatus() == 4) { //未交车 if (orderPageVo.getStatus() == 4) { //未交车
// boolean flag = getTodayTime(orderPageVo.getOrderRentVehicleDetail().getStartTime()); if (userDTO.getCompanyId().equals(orderPageVo.getOrderRentVehicleDetail().getStartCompanyId())) {
// if (!flag) { orderPageVo.setUserCompanyStatus(true);
// return ObjectRestResponse.createFailedResult(3501, "今日不是交车日期"); }
// }
getDriverInfo(orderPageVo); getDriverInfo(orderPageVo);
} else if (orderPageVo.getStatus() >= 5 || orderPageVo.getStatus() == -1) {//出行中 已交车 } else if (orderPageVo.getStatus() >= 5 || orderPageVo.getStatus() == -1) {//出行中 已交车
if (userDTO.getCompanyId().equals(orderPageVo.getOrderRentVehicleDetail().getEndCompanyId())) {
orderPageVo.setUserCompanyStatus(true);
}
//设置违约金金额 //设置违约金金额
getDriverInfo(orderPageVo); getDriverInfo(orderPageVo);
getUserLicense(orderPageVo); getUserLicense(orderPageVo);
...@@ -754,6 +752,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements ...@@ -754,6 +752,11 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
ObjectRestResponse orr = userFeign.buyMember(userMemberDTO); ObjectRestResponse orr = userFeign.buyMember(userMemberDTO);
log.info("orr.getStatus() : " + orr.getStatus()); log.info("orr.getStatus() : " + orr.getStatus());
omd.setBaseOrder(baseOrder);
//发送消息队列到admin,进行分成计算
mqSenderFeign.sendMessage(RabbitConstant.ADMIN_TOPIC, RabbitConstant.KEY_MEMBER_SHARE, JSONUtil.toJsonStr(omd));
} else if (OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) { } else if (OrderTypeEnum.RENT_VEHICLE.getCode().equals(baseOrder.getType())) {
updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode()); updateOrder.setStatus(OrderStatusEnum.ORDER_TOSTART.getCode());
orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail() {{ orvd = orderRentVehicleBiz.selectOne(new OrderRentVehicleDetail() {{
......
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