Commit 5340dbf4 authored by jiaorz's avatar jiaorz

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

parents 6329592e 25f5b42e
...@@ -15,14 +15,23 @@ public class RabbitConstant { ...@@ -15,14 +15,23 @@ public class RabbitConstant {
public static final String ORDER_TOPIC = ORDER+ TOPIC_EXC; public static final String ORDER_TOPIC = ORDER+ TOPIC_EXC;
public static final String INTEGRAL = "integral"; public static final String INTEGRAL = "integral";
public static final String INTEGRAL_TOPIC = INTEGRAL + TOPIC_EXC; public static final String INTEGRAL_TOPIC = INTEGRAL + TOPIC_EXC;
/**************************key*********************************/ /**************************key*********************************/
//用户
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 INTEGRAL_ROUTING_KEY = "integral_routing_key"; public static final String INTEGRAL_ROUTING_KEY = "integral_routing_key";
//订单
public static final String KEY_ORDER_PAY = "order.pay"; public static final String KEY_ORDER_PAY = "order.pay";
public static final String KEY_ORDER_FINLISH = "order.finlish"; public static final String KEY_ORDER_FINLISH = "order.finlish";
public static final String KEY_ORDER_CANCEL = "order.cancel"; public static final String KEY_ORDER_CANCEL = "order.cancel";
//钱包
public static final String KEY_WALLET_ADD = "wallet.add";
static { static {
exchangeTopicSet = new HashSet<String>() {{ exchangeTopicSet = new HashSet<String>() {{
add(ADMIN_TOPIC); add(ADMIN_TOPIC);
......
package com.github.wxiaoqi.security.common.util;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class ReferralCodeUtil {
//验证码长度
private static final int LEN = 6;
//验证码字符初始列表
private static final char STUFFS[] = {
'E','5','F','C','D','G','3','H',
'Q','A','4','B','1','N','P','I',
'J','2','R','S','T','U','V','6',
'7','M','W','X','8','K','L','Y'};
private static final int PERMUTATION;
private static final int MAX_COMBINATION;
private static char[] _stuffs = STUFFS;
static {
PERMUTATION = permutation(LEN);
MAX_COMBINATION = combination(_stuffs.length, LEN);
}
// public static void resetStuffs() {
// int length = STUFFS.length;
// char[] stuffs = new char[length];
// for (int i = 0; i < length; ++i) {
// stuffs[i] = STUFFS[i];
// }
// Random random = new Random();
// for (int i = 0; i < length; i++) {
// int p = random.nextInt(length);
// char tmp = stuffs[i];
// stuffs[i] = stuffs[p];
// stuffs[p] = tmp;
// }
// _stuffs = stuffs;
// }
private static int combination(int n,int m) {
int com = 1;
for(int i = n - m + 1; i <= n ; ++i) {
com *= i;
}
for(int i = 2; i <= m ; ++i ) {
com /= i;
}
return com;
}
private static int permutation(int n) {
int per = 1;
for(int i = 2; i <= n ; ++i) {
per *= i;
}
return per;
}
public static int decode(String code) {
if(code.length() != LEN) {
throw new RuntimeException("invalid code");
}
char[] chars = new char[LEN];
for(int i = 0; i < LEN;++i) {
chars[i] = code.charAt(i);
}
int com = combination(chars);
int per = permutation(chars);
return com * PERMUTATION + per;
}
public static String encode(int val) {
int com = val / PERMUTATION;
if(com >= MAX_COMBINATION) {
throw new RuntimeException("id can't be greater than 652458239");
}
int per = val % PERMUTATION;
char[] chars = combination(com);
chars = permutation(chars,per);
return new String(chars);
}
private static char[] combination(int com){
char[] chars = new char[LEN];
int start = 0;
int index = 0;
while (index < LEN) {
for(int s = start; s < _stuffs.length; ++s ) {
int c = combination(_stuffs.length - s - 1, LEN - index - 1);
if(com >= c) {
com -= c;
continue;
}
chars[index++] = _stuffs[s];
start = s + 1;
break;
}
}
return chars;
}
private static char[] sort(char[] src) {
char[] sort = new char[src.length];
int index = 0;
for(int i = 0; i < _stuffs.length; ++i) {
if(find(src, _stuffs[i]) != -1) {
sort[index++] = _stuffs[i];
}
}
return sort;
}
private static int combination(char[] chars) {
int[] offset = new int[LEN];
char[] sort = sort(chars);
for(int i = 0; i < sort.length;++i) {
offset[i] = find(_stuffs, sort[i]);
if(offset[i] == -1) {
throw new RuntimeException("invalid code");
}
}
int com = 0;
for(int i = 0;i < offset.length;++i) {
if(i == 0) {
if(offset[0] == 0) {
continue;
}
for(int n = 0; n < offset[0];++n) {
com += combination(_stuffs.length - n - 1, LEN - 1);
}
continue;
}
if(offset[i] - offset[i - 1] <= 1) {
continue;
}
for(int n = offset[i-1] + 1; n < offset[i];++n) {
com += combination(_stuffs.length - n - 1, LEN - i - 1);
}
}
return com;
}
private static char[] permutation(char[] chars,int per){
char[] tmpchars = new char[chars.length];
System.arraycopy(chars, 0, tmpchars, 0, chars.length);
int[] offset = new int[chars.length];
int step = chars.length;
for(int i = chars.length -1;i >= 0;--i) {
offset[i] = per % step;
per /= step;
step --;
}
for(int i = 0; i < chars.length;++i) {
if(offset[i] == 0)
continue;
char tmp = tmpchars[i];
tmpchars[i] = tmpchars[i - offset[i]];
tmpchars[i - offset[i]] = tmp;
}
return tmpchars;
}
private static int find(char[] chars,char ch) {
for(int i = 0;i < chars.length;++i) {
if(chars[i] == ch) {
return i;
}
}
return -1;
}
private static int permutation(char[] chars){
char[] sort = sort(chars);
int[] offset = new int[chars.length];
for(int i =chars.length -1;i >=0;--i ) {
int f = find(chars, sort[i]);
offset[i] = i - f;
char tmp = chars[i];
chars[i] = chars[i - offset[i]];
chars[i - offset[i]] = tmp;
}
int per = 0;
int step = 1;
for(int i = 0; i < offset.length;++i ) {
per = per * step + offset[i];
step++;
}
return per;
}
public static void main(String[] args) {
// try {
// List<String> lists = new ArrayList<>();
// Set<String> sets = new HashSet<>();
// File file = new File("./log2.txt");
// BufferedOutputStream buff = new BufferedOutputStream(new FileOutputStream(file));
// resetStuffs();
// for (int i = 1; i< 10000000; ++i) {
// String code = encode(i);
// int nid = decode(code);
// if (i != nid) {
// break;
// }
// String str = i + "->" + code + "->" + nid + "\n";
// buff.write(str.getBytes());
//
// lists.add(code);
// sets.add(code);
// }
// String result = "lists.size=" + lists.size() + ", sets.size=" + sets.size() + "\n";
// buff.write(result.getBytes());
// buff.flush();
// buff.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
Map<String, Integer> map = new HashMap<String, Integer>();
for (int i = 0; i < 10000; i++) {
String key = encode(i);
System.out.println(key);
if(null == map.get(key)) {
map.put(key, 1);
}else {
System.out.println("重复"+ key+ ":"+ i);
map.put(key, map.get(key) + 1);
}
}
int flag = 0;
Set<Map.Entry<String, Integer>> list = map.entrySet();
for(Map.Entry<String, Integer> e : list) {
if(e.getValue() > 1) {
flag++;
System.out.println(e.getKey()+ ":"+ e.getValue());
}
}
System.out.println("flag : "+ flag);
}
}
\ No newline at end of file
...@@ -11,8 +11,10 @@ import java.math.BigDecimal; ...@@ -11,8 +11,10 @@ import java.math.BigDecimal;
@Data @Data
public class OrderGoodsDTO { public class OrderGoodsDTO {
public static final Integer TYPE_RENT = 1;
public static final Integer TYPE_TOUR = 2;
public static final Integer TYPE_MEMBER = 3;
public static final Integer TYPE_CAMPSITE = 4;
/** /**
* 商品id * 商品id
......
...@@ -65,9 +65,9 @@ public class AppUserRelation implements Serializable { ...@@ -65,9 +65,9 @@ public class AppUserRelation implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
@Column(name = "ctr_time") @Column(name = "crt_time")
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private Long ctrTime; private Long crtTime;
/** /**
* 更新时间 * 更新时间
......
...@@ -27,9 +27,15 @@ public interface UserFeign { ...@@ -27,9 +27,15 @@ public interface UserFeign {
public static final int MEMBER_DAYS_CONFIRM = 2; public static final int MEMBER_DAYS_CONFIRM = 2;
public static final int MEMBER_DAYS_WITHDRAW = 3; public static final int MEMBER_DAYS_WITHDRAW = 3;
//后台用户
@RequestMapping(value = "/public/userinfo-by-token") @RequestMapping(value = "/public/userinfo-by-token")
public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token); public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token);
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/** /**
* token获取用户信息 * token获取用户信息
* @param token * @param token
...@@ -37,9 +43,6 @@ public interface UserFeign { ...@@ -37,9 +43,6 @@ public interface UserFeign {
*/ */
@RequestMapping(value = "/public/app/userinfo-by-token") @RequestMapping(value = "/public/app/userinfo-by-token")
public ObjectRestResponse<AppUserDTO> userDetailByToken(@RequestParam("token") String token); public ObjectRestResponse<AppUserDTO> userDetailByToken(@RequestParam("token") String token);
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/** /**
* id获取用户信息 * id获取用户信息
* @param id * @param id
......
...@@ -46,7 +46,6 @@ public class TokenAop { ...@@ -46,7 +46,6 @@ public class TokenAop {
/** /**
* userFeign.userDetailByToken(""); 获取app用户的信息 * userFeign.userDetailByToken(""); 获取app用户的信息
* userFeign.userinfoByToken(""); 获取后台用户的信息 * userFeign.userinfoByToken(""); 获取后台用户的信息
* Todo 还有token 校验规则 ,是否过期 未加入检验 .......
* @param proceedingJoinPoint * @param proceedingJoinPoint
* @return * @return
*/ */
......
...@@ -176,7 +176,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -176,7 +176,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
int r = amount.compareTo(BigDecimal.ZERO); int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包 //更新钱包
if (r == 1 && userId > 0) { if (r == 1 && userId > 0) {
myWaterBiz.updMyWater(userId, orderId, amount); MyWalletDetail detail=new MyWalletDetail();
detail.setUserId(userId);
detail.setAmount(amount);
detail.setCono(orderId);
detail.setSource(1);
myWaterBiz.updMyWater(detail);
} }
} }
...@@ -209,7 +214,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -209,7 +214,12 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
int r = amount.compareTo(BigDecimal.ZERO); int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包 //更新钱包
if (r == 1 && userId > 0) { if (r == 1 && userId > 0) {
myWaterBiz.updMyWater(userId, orderId, amount); MyWalletDetail detail=new MyWalletDetail();
detail.setUserId(userId);
detail.setAmount(amount);
detail.setCono(orderId);
detail.setSource(1);
myWaterBiz.updMyWater(detail);
} }
} }
......
...@@ -48,7 +48,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -48,7 +48,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
private AppUserLoginBiz appUserLoginBiz; private AppUserLoginBiz appUserLoginBiz;
public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO) { public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO,Integer userId,String name) {
if (userMemberSaveDTO != null) { if (userMemberSaveDTO != null) {
UserMemberDTO userMemberDTO = new UserMemberDTO(); UserMemberDTO userMemberDTO = new UserMemberDTO();
BaseUserMemberLevel level = userMemberLevelBiz.getLevel(userMemberSaveDTO.getMemberLevel()); BaseUserMemberLevel level = userMemberLevelBiz.getLevel(userMemberSaveDTO.getMemberLevel());
...@@ -76,6 +76,8 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -76,6 +76,8 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
.rentFreeDays(userMemberSaveDTO.getRentFreeDays()) .rentFreeDays(userMemberSaveDTO.getRentFreeDays())
.discount(level == null ? 0 : level.getDiscount() == null ? 0 : level.getDiscount()) .discount(level == null ? 0 : level.getDiscount() == null ? 0 : level.getDiscount())
.status(phoneAndUserIdMap == null ? 0 : (phoneAndUserIdMap.get(userMemberSaveDTO.getPhone()) == null ? 0 : 1)) .status(phoneAndUserIdMap == null ? 0 : (phoneAndUserIdMap.get(userMemberSaveDTO.getPhone()) == null ? 0 : 1))
.crtId(userId)
.crtName(name)
.isDel(0) .isDel(0)
.build(); .build();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
......
...@@ -35,8 +35,14 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{ ...@@ -35,8 +35,14 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
//我的钱包入账 //我的钱包入账
public void updMyWater(Integer userId, Integer orderId,BigDecimal amount){ public void updMyWater(MyWalletDetail walletDetail){
log.info("---我的钱包入账----userId==="+userId+"----orderId===="+orderId+"----amount===="+amount); if (walletDetail==null){
log.info("钱包入账-----参数为空");
}
Integer userId= walletDetail.getUserId();
BigDecimal amount= walletDetail.getAmount();
Integer source=walletDetail.getSource();
log.info("---我的钱包入账----userId==="+userId+"----source===="+source+"----amount===="+amount);
MyWallet wallet=new MyWallet(); MyWallet wallet=new MyWallet();
wallet.setUserId(userId); wallet.setUserId(userId);
wallet=selectOne(wallet); wallet=selectOne(wallet);
...@@ -70,12 +76,7 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{ ...@@ -70,12 +76,7 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
} }
log.info("---我的钱包入账----userId==="+userId+"----balance===="+balance+"----totalAmount===="+totalAmount+"---todayAmount==="+todayAmount+"---unbooked=="+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.setItype(1);
walletDetail.setAmount(amount);
walletDetail.setBalance(oldBalance); walletDetail.setBalance(oldBalance);
walletDetailBiz.insertSelective(walletDetail); walletDetailBiz.insertSelective(walletDetail);
Long time=System.currentTimeMillis(); Long time=System.currentTimeMillis();
......
...@@ -20,12 +20,22 @@ public class RabbitAdminConfig extends RabbitCommonConfig { ...@@ -20,12 +20,22 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
public static final String ORDER_WATER_QUEUE = "order.water.queue"; public static final String ORDER_WATER_QUEUE = "order.water.queue";
public static final String ORDER_FINLISH_USER_RE_QUEUE = "order.cancel.userRe.queue"; public static final String ORDER_FINLISH_USER_RE_QUEUE = "order.cancel.userRe.queue";
//钱包50入账
public static final String WALLET_ADD_QUEUE = "wallet.add.queue";
//支付完成后永久绑定关系
public static final String ORDER_RELATION_QUEUE = "order.relation.queue";
static { static {
myQueue = new ArrayList<BindDTO>(){{ myQueue = new ArrayList<BindDTO>(){{
//支付完成后永久绑定关系
add(new BindDTO(ORDER_RELATION_QUEUE, ADMIN_TOPIC, KEY_ORDER_PAY));
//拥金计算
add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_PAY)); add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_PAY));
add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH));
add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_CANCEL)); add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_CANCEL));
add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH));
//钱包
add(new BindDTO(WALLET_ADD_QUEUE, ADMIN_TOPIC,KEY_WALLET_ADD ));
}}; }};
} }
} }
......
package com.github.wxiaoqi.security.admin.handler;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.biz.AppUserRelationBiz;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.entity.AppUserRelation;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.ORDER_RELATION_QUEUE;
@Component
@Slf4j
public class RelationMQHandler {
@Autowired
AppUserRelationBiz relationBiz;
/**
* 永久关系绑定
* @param
*/
@RabbitListener(queues = ORDER_RELATION_QUEUE)
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息-----msg===="+msg);
OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
Integer sign=orderMQDTO.getSign();
Integer userId=orderMQDTO.getUserId();
log.info("接收到的消息-----sign===="+sign+"-----userId===="+userId);
relationBiz.foreverBind(userId);
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.info("接收到的消息失败");
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
} catch (IOException i) {
i.printStackTrace();
}
e.printStackTrace();
}
}
});
}
}
package com.github.wxiaoqi.security.admin.handler;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.biz.MyWalletBiz;
import com.github.wxiaoqi.security.admin.biz.MyWaterBiz;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.*;
@Component
@Slf4j
public class WalletMQHandler {
@Autowired
MyWaterBiz waterBiz;
/**
* 钱包入账
* @param
*/
@RabbitListener(queues = WALLET_ADD_QUEUE)
public void integralHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息-----msg===="+msg);
MyWalletDetail detail = JSONUtil.toBean(msg, MyWalletDetail.class);
waterBiz.updMyWater(detail);
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.info("接收到的消息失败");
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
} catch (IOException i) {
i.printStackTrace();
}
e.printStackTrace();
}
}
});
}
}
package com.github.wxiaoqi.security.admin.handler; package com.github.wxiaoqi.security.admin.handler;
import cn.hutool.db.sql.Order;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz; import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.dto.OrderGoodsDTO; import com.github.wxiaoqi.security.admin.dto.OrderGoodsDTO;
...@@ -22,6 +24,7 @@ import java.util.concurrent.ExecutorService; ...@@ -22,6 +24,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.*; import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.*;
import static com.xxfc.platform.order.pojo.mq.OrderMQDTO.*;
@Component @Component
@Slf4j @Slf4j
...@@ -43,27 +46,72 @@ public class WaterMQHandler { ...@@ -43,27 +46,72 @@ public class WaterMQHandler {
try { try {
String messageId = message.getMessageProperties().getMessageId(); String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8"); String msg = new String(message.getBody(), "UTF-8");
OrderMQDTO orderMQDTO = JSONObject.parseObject(msg, OrderMQDTO.class); OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
OrderWaterDTO orderWaterDTO = new OrderWaterDTO(){{ OrderWaterDTO orderWaterDTO = new OrderWaterDTO() {{
setUserId(orderMQDTO.getUserId()); setUserId(orderMQDTO.getUserId());
setOrderNo(orderMQDTO.getNo()); setOrderNo(orderMQDTO.getNo());
setOrderId(orderMQDTO.getId()); setOrderId(orderMQDTO.getId());
}}; }};
switch (orderMQDTO.getSign()) {
case ORDER_PAY:
orderWaterDTO.setStatus(1);
break;
case ORDER_FINISH:
orderWaterDTO.setStatus(2);
break;
case ORDER_CANCEL:
orderWaterDTO.setStatus(3);
break;
default:
break;
}
switch (OrderTypeEnum.get(orderMQDTO.getType())) { switch (OrderTypeEnum.get(orderMQDTO.getType())) {
case RENT_VEHICLE: case RENT_VEHICLE:
orderWaterDTO.setGoodsDTOList( orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{ new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO(){{ add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId()); setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId());
setGoodNumber(1); setGoodNumber(1);
setImg(orderMQDTO.getPicture()); setImg(orderMQDTO.getPicture());
setPrice(orderMQDTO.getGoodsAmount());
setTitle(orderMQDTO.getName());
setType(OrderGoodsDTO.TYPE_RENT);
}}); }});
}} }}
); );
break;
case TOUR:
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderTourDetail().getGoodId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
setPrice(orderMQDTO.getGoodsAmount());
setTitle(orderMQDTO.getName());
setType(OrderGoodsDTO.TYPE_RENT);
}});
}}
);
break;
case MEMBER:
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderMemberDetail().getMemberLevelId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
setPrice(orderMQDTO.getGoodsAmount());
setTitle(orderMQDTO.getName());
setType(OrderGoodsDTO.TYPE_MEMBER);
}});
}}
);
break;
default:
break;
} }
orderWaterDTO = JSONObject.parseObject(msg, OrderWaterDTO.class);
waterBiz.orderWater(orderWaterDTO); waterBiz.orderWater(orderWaterDTO);
executorService.shutdown(); executorService.shutdown();
...@@ -81,31 +129,5 @@ public class WaterMQHandler { ...@@ -81,31 +129,5 @@ public class WaterMQHandler {
} }
} }
}); });
// log.info("接收到的消息:json = {}", json);
// try{
//
// OrderWaterDTO orderWaterDTO = JSONObject.parseObject(json, OrderWaterDTO.class);
// waterBiz.orderWater(orderWaterDTO);
// }catch (Exception e){
// log.info("接收到的消息失败");
// e.printStackTrace();
// }
} }
@RabbitListener(queues = {ORDER_FINLISH_USER_RE_QUEUE})
public void integralHandler2(String json) {
log.info("接收到的消息:json = {}", json);
try{
OrderWaterDTO orderWaterDTO = JSONObject.parseObject(json, OrderWaterDTO.class);
waterBiz.orderWater(orderWaterDTO);
}catch (Exception e){
log.info("接收到的消息失败");
e.printStackTrace();
}
}
} }
...@@ -95,9 +95,15 @@ public class UserMemberAdminController { ...@@ -95,9 +95,15 @@ public class UserMemberAdminController {
@ApiOperation("会员新增") @ApiOperation("会员新增")
@PostMapping("/save") @PostMapping("/save")
public ObjectRestResponse<Void> saveUserMember(@RequestBody UserMemberSaveDTO userMemberSaveDTO) { public ObjectRestResponse<Void> saveUserMember(@RequestBody UserMemberSaveDTO userMemberSaveDTO,HttpServletRequest request) {
baseUserMemberExportBiz.saveUserMember(userMemberSaveDTO); try {
return ObjectRestResponse.succ(); IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
baseUserMemberExportBiz.saveUserMember(userMemberSaveDTO,Integer.valueOf(infoFromToken.getId()),infoFromToken.getName());
return ObjectRestResponse.succ();
} catch (Exception e) {
throw new BaseException(e);
}
} }
@ApiOperation("分页查询") @ApiOperation("分页查询")
......
...@@ -215,6 +215,7 @@ public class AppPermissionService { ...@@ -215,6 +215,7 @@ public class AppPermissionService {
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JSONObject register(String username, String password, String headimgurl, public JSONObject register(String username, String password, String headimgurl,
String nickname, String mobilecode, String openId, String unionid, Integer type,String code) { String nickname, String mobilecode, String openId, String unionid, Integer type,String code) {
log.info("register------code====="+code);
String activityCode = null; String activityCode = null;
// 判断参数和验证码 // 判断参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(password) || StringUtils.isBlank(mobilecode)) { if (StringUtils.isBlank(username) || StringUtils.isBlank(password) || StringUtils.isBlank(mobilecode)) {
...@@ -279,8 +280,12 @@ public class AppPermissionService { ...@@ -279,8 +280,12 @@ public class AppPermissionService {
} }
parentId=appUserDetailBiz.getUserByCode(code); parentId=appUserDetailBiz.getUserByCode(code);
} }
if(parentId!=null&&parentId>0&&StringUtils.isNotBlank(activityCode)){ if(parentId!=null&&parentId>0){
rsUserDetail.setInviterAccount(parentId); relationBiz.bindRelation(userid, parentId, 1);
if(StringUtils.isNotBlank(activityCode)){
rsUserDetail.setInviterAccount(parentId);
}
} }
//生成邀请码 长度改为8 不然重复率太高 //生成邀请码 长度改为8 不然重复率太高
rsUserDetail.setCode(UUIDUtils.genCodes(8)); rsUserDetail.setCode(UUIDUtils.genCodes(8));
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<result column="position_id" property="positionId"/> <result column="position_id" property="positionId"/>
<result column="source" property="source"/> <result column="source" property="source"/>
<result column="code" property="code"/> <result column="code" property="code"/>
<result column="invitera_ccount" property="inviterAccount"/> <result column="inviter_account" property="inviterAccount"/>
<result column="state" property="state"/> <result column="state" property="state"/>
</resultMap> </resultMap>
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
<artifactId>xx-activity-api</artifactId> <artifactId>xx-activity-api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-order-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -50,8 +50,8 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti ...@@ -50,8 +50,8 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
String activityCode = registerQueueDTO.getInParamDTO().getActivityCode().replace(PREFIX, ""); String activityCode = registerQueueDTO.getInParamDTO().getActivityCode().replace(PREFIX, "");
AppUserDTO appUserDTO = userFeign.userDetailById(registerQueueDTO.getAppUserId()).getData(); AppUserDTO appUserDTO = userFeign.userDetailById(registerQueueDTO.getAppUserId()).getData();
//获取活动code,并且注册来源是app 并且 是邀请注册 //获取活动code,并且注册来源是app 并且 非普通登录
if(POPULARIZE_0101.equals(registerQueueDTO.getInParamDTO().getActivityCode()) if(POPULARIZE_0101.equals(activityCode)
&& !RegisterQueueDTO.SIGN_LOGIN.equals(registerQueueDTO.getSign())) { && !RegisterQueueDTO.SIGN_LOGIN.equals(registerQueueDTO.getSign())) {
//查询出活动 //查询出活动
......
...@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant; ...@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
/** /**
* rabbitmq配置类 * rabbitmq配置类
...@@ -21,14 +23,19 @@ public class RabbitActivityConfig extends RabbitCommonConfig { ...@@ -21,14 +23,19 @@ public class RabbitActivityConfig extends RabbitCommonConfig {
//新人注册有礼 //新人注册有礼
public static final String ACTIVITY_NEW_QUEUE = "activity.new.queue"; public static final String ACTIVITY_NEW_QUEUE = "activity.new.queue";
public static final String INTEGRAL_HANDLE_QUEUE = "integral_handle_queue"; public static final String INTEGRAL_HANDLE_QUEUE = "integral_handle_queue";
//优惠券
public static final String COUPON_CANCEL_QUEUE = "coupon.cancel.queue";
static { static {
myQueue = new ArrayList<BindDTO>(){{ myQueue = new ArrayList<BindDTO>(){{
add(new BindDTO(INTEGRAL_QUEUE, RabbitConstant.ORDER_TOPIC, "order.#")); add(new BindDTO(INTEGRAL_QUEUE, ORDER_TOPIC, "order.#"));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register")); add(new BindDTO(POPULARZIE_0101_QUEUE, ADMIN_TOPIC, KEY_APPUSER_REGISTER));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth")); add(new BindDTO(POPULARZIE_0101_QUEUE, ADMIN_TOPIC, KEY_APPUSER_AUTH));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register")); add(new BindDTO(ACTIVITY_NEW_QUEUE, ADMIN_TOPIC, KEY_APPUSER_REGISTER));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth")); add(new BindDTO(ACTIVITY_NEW_QUEUE, ADMIN_TOPIC, KEY_APPUSER_AUTH));
add(new BindDTO(INTEGRAL_HANDLE_QUEUE, RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY)); add(new BindDTO(INTEGRAL_HANDLE_QUEUE, INTEGRAL_TOPIC, INTEGRAL_ROUTING_KEY));
add(new BindDTO(COUPON_CANCEL_QUEUE, ORDER_TOPIC, KEY_ORDER_CANCEL));
}}; }};
} }
......
package com.xxfc.platform.activity.handler;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.dto.RegisterQueueDTO;
import com.rabbitmq.client.Channel;
import com.xxfc.platform.activity.biz.ActivityPopularizeBiz;
import com.xxfc.platform.activity.biz.ActivityUserJoinBiz;
import com.xxfc.platform.activity.biz.UserCouponBiz;
import com.xxfc.platform.activity.config.RabbitActivityConfig;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
@Slf4j
public class CouponMQHandler {
@Autowired
ActivityPopularizeBiz activityPopularizeBiz;
@Autowired
ActivityUserJoinBiz activityUserJoinBiz;
@Autowired
UserCouponBiz userCouponBiz;
@RabbitListener(queues = {RabbitActivityConfig.COUPON_CANCEL_QUEUE})
public void popularizeHandler(Message message, @Headers Map<String, Object> headers, Channel channel) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(new Runnable() {
@Override
public void run() {
try {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
log.info("接收到的消息:msg = {}, 消息ID是:messageId = {} ", msg, messageId);
if (StringUtils.isNotBlank(msg)) {
OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
if(StrUtil.isNotBlank(orderMQDTO.getCouponTickerNos())) {
for(String tickerNo : orderMQDTO.getCouponTickerNos().split(",")) {
// 返还优惠券
userCouponBiz.cancelTickerNo(tickerNo);
}
}
}
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.info("接收到的消息失败");
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
} catch (IOException i) {
i.printStackTrace();
}
e.printStackTrace();
}
}
});
}
}
...@@ -85,6 +85,18 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> { ...@@ -85,6 +85,18 @@ public class AppVersionBiz extends BaseBiz<AppVersionMapper,AppVersion> {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ObjectRestResponse getVersionH5(Integer type){
Example example =new Example(AppVersion.class);
example.createCriteria().andEqualTo("isDel",0).andEqualTo("downloadSwitch",0).andEqualTo("sysType",type);
example.setOrderByClause("version DESC");
List<AppVersion> list=selectByExample(example);
if (list.size()>0){
AppVersion appVersion=list.get(0);
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).data(appVersion).rel(false);
}
return ObjectRestResponse.succ();
}
public RestResponse uploadDrivingLicense(MultipartFile file) throws IOException { public RestResponse uploadDrivingLicense(MultipartFile file) throws IOException {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER); String dirPathToday = File.separator + now.toString(DEFAULT_DATE_TIME_FORMATTER);
......
...@@ -46,9 +46,16 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio ...@@ -46,9 +46,16 @@ public class AppVersionController extends BaseController<AppVersionBiz,AppVersio
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse info( public ObjectRestResponse info(
@RequestParam(value = "type",defaultValue = "0") Integer type, @RequestParam(value = "type",defaultValue = "0") Integer type,
@RequestParam(value = "version",defaultValue = "") String version @RequestParam(value = "version",defaultValue = "") String version,
@RequestParam(value = "isH5",defaultValue = "0") Integer isH5
){ ){
return baseBiz.getVersion(version,type); ObjectRestResponse restResponse=null;
if (isH5!=null&&isH5==1){
restResponse= baseBiz.getVersionH5(type);
}else {
restResponse=baseBiz.getVersion(version,type);
}
return restResponse;
} }
......
...@@ -235,4 +235,11 @@ public class BaseOrder implements Serializable { ...@@ -235,4 +235,11 @@ public class BaseOrder implements Serializable {
@ApiModelProperty(value = "优惠券优惠的价格") @ApiModelProperty(value = "优惠券优惠的价格")
@Column(name = "coupon_amount") @Column(name = "coupon_amount")
private BigDecimal couponAmount; private BigDecimal couponAmount;
/**
* 使用的优惠券票号,逗号分割
*/
@ApiModelProperty(value = "使用的优惠券票号,逗号分割")
@Column(name = "coupon_ticker_no")
private String couponTickerNos;
} }
...@@ -9,10 +9,10 @@ import lombok.Data; ...@@ -9,10 +9,10 @@ import lombok.Data;
@Data @Data
public class OrderMQDTO extends BaseOrder { public class OrderMQDTO extends BaseOrder {
public static final Integer ORDER_CRT = 1; public static final int ORDER_CRT = 1;
public static final Integer ORDER_CANCEL = 2; public static final int ORDER_CANCEL = 2;
public static final Integer ORDER_PAY = 4; public static final int ORDER_PAY = 4;
public static final Integer ORDER_FINISH = 6; public static final int ORDER_FINISH = 6;
OrderRentVehicleDetail orderRentVehicleDetail; OrderRentVehicleDetail orderRentVehicleDetail;
......
...@@ -12,6 +12,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -12,6 +12,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.IntervalUtil; import com.github.wxiaoqi.security.common.util.IntervalUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.xxfc.platform.activity.feign.ActivityFeign;
import com.xxfc.platform.order.biz.inner.OrderMsgBiz; import com.xxfc.platform.order.biz.inner.OrderMsgBiz;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum; import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum; import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
...@@ -93,6 +94,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -93,6 +94,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
@Autowired @Autowired
OrderMsgBiz orderMsgBiz; OrderMsgBiz orderMsgBiz;
@Autowired
ActivityFeign activityFeign;
public List<OrderPageVO> pageByParm(Map<String, Object> paramMap){ public List<OrderPageVO> pageByParm(Map<String, Object> paramMap){
return mapper.pageByParm(paramMap); return mapper.pageByParm(paramMap);
} }
......
...@@ -245,6 +245,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -245,6 +245,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//待完成 //待完成
if(null != detail.getTickerNo() && detail.getTickerNo().size() > 0) { if(null != detail.getTickerNo() && detail.getTickerNo().size() > 0) {
couponAmount = activityFeign.use(dto.getUserid(), detail.getTickerNo().get(0), detail.getOrder().getNo(), channel, goodsAmount, ActivityFeign.TYPE_NO_USE); couponAmount = activityFeign.use(dto.getUserid(), detail.getTickerNo().get(0), detail.getOrder().getNo(), channel, goodsAmount, ActivityFeign.TYPE_NO_USE);
if(couponAmount.compareTo(BigDecimal.ZERO) > 0) {
detail.getOrder().setCouponTickerNos(detail.getTickerNo().get(0));
}
} }
//总价格(包含押金) //总价格(包含押金)
......
...@@ -218,6 +218,9 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To ...@@ -218,6 +218,9 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
//待完成 //待完成
if(null != detail.getTickerNo() && detail.getTickerNo().size() > 0) { if(null != detail.getTickerNo() && detail.getTickerNo().size() > 0) {
couponAmount = activityFeign.use(dto.getUserid(), detail.getTickerNo().get(0), detail.getOrder().getNo(), channel, goodsAmount, ActivityFeign.TYPE_NO_USE); couponAmount = activityFeign.use(dto.getUserid(), detail.getTickerNo().get(0), detail.getOrder().getNo(), channel, goodsAmount, ActivityFeign.TYPE_NO_USE);
if(couponAmount.compareTo(BigDecimal.ZERO) > 0) {
detail.getOrder().setCouponTickerNos(detail.getTickerNo().get(0));
}
} }
//总价格 //总价格
......
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