Commit 4a4fd268 authored by hanfeng's avatar hanfeng

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

parents 26286c97 4843f402
......@@ -15,14 +15,23 @@ public class RabbitConstant {
public static final String ORDER_TOPIC = ORDER+ TOPIC_EXC;
public static final String INTEGRAL = "integral";
public static final String INTEGRAL_TOPIC = INTEGRAL + TOPIC_EXC;
/**************************key*********************************/
//用户
public static final String KEY_APPUSER_REGISTER = "appUser.register";
public static final String KEY_APPUSER_AUTH = "appUser.auth";
//积分
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_FINLISH = "order.finlish";
public static final String KEY_ORDER_CANCEL = "order.cancel";
//钱包
public static final String KEY_WALLET_ADD = "wallet.add";
static {
exchangeTopicSet = new HashSet<String>() {{
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
#项目url
XXMP_URL=https://xxtest.upyuns.com/image
XXMP_URL=/image
#token到期时间
TOKEN_OVER_TIME=604800
#itoken到期时间(6天)
......
......@@ -65,9 +65,9 @@ public class AppUserRelation implements Serializable {
/**
* 创建时间
*/
@Column(name = "ctr_time")
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间")
private Long ctrTime;
private Long crtTime;
/**
* 更新时间
......
......@@ -63,6 +63,13 @@ public class AppUserSellingWater implements Serializable {
@ApiModelProperty(value = "订单号")
private String orderNo;
/**
* 订单号
*/
@Column(name = "order_type")
@ApiModelProperty(value = "1-租车;2-旅游;3-会员;4-营地")
private Integer orderType;
/**
* 商品id
*/
......
......@@ -20,6 +20,11 @@ import lombok.Data;
public class MyWalletDetail implements Serializable {
private static final long serialVersionUID = 1L;
public static final int TYPE_POPULARIZE = 1;
public static final int SOURCE_ACTIVITY = 0;
public static final int ITYPE_IN = 0;
/**
* 主键ID
*/
......@@ -104,5 +109,4 @@ public class MyWalletDetail implements Serializable {
@ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime;
}
......@@ -27,9 +27,15 @@ public interface UserFeign {
public static final int MEMBER_DAYS_CONFIRM = 2;
public static final int MEMBER_DAYS_WITHDRAW = 3;
//后台用户
@RequestMapping(value = "/public/userinfo-by-token")
public ObjectRestResponse<UserDTO> userinfoByToken(@RequestParam("token") String token);
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/**
* token获取用户信息
* @param token
......@@ -37,9 +43,6 @@ public interface UserFeign {
*/
@RequestMapping(value = "/public/app/userinfo-by-token")
public ObjectRestResponse<AppUserDTO> userDetailByToken(@RequestParam("token") String token);
@RequestMapping(value = "/public/userinfo-by-uid")
public ObjectRestResponse<UserDTO> userinfoByUid(@RequestParam("uid") Integer uid);
/**
* id获取用户信息
* @param id
......
......@@ -46,7 +46,6 @@ public class TokenAop {
/**
* userFeign.userDetailByToken(""); 获取app用户的信息
* userFeign.userinfoByToken(""); 获取后台用户的信息
* Todo 还有token 校验规则 ,是否过期 未加入检验 .......
* @param proceedingJoinPoint
* @return
*/
......
......@@ -36,4 +36,8 @@ public class AppletWalletVo {
*/
@ApiModelProperty(value = "今日收益(元)")
private BigDecimal todayAmount;
@ApiModelProperty(value = "未入账金额")
private BigDecimal unbooked;
}
......@@ -79,7 +79,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
//永久稳定关系
public void foreverBind(Integer user_id ){
AppUserRelation relation=getMyBiz().getRelationByUserId(user_id);
if(relation!=null&&relation.getIsForever()==0){
if(relation!=null&&relation.getIsForever()==0&&relation.getParentId()!=null&&relation.getParentId()>0){
relation.setIsForever(1);
getMyBiz().updRelation(relation);
}
......
......@@ -103,15 +103,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
Integer parentId = relation.getParentId();
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---parentId===" + parentId);
BigDecimal amount = new BigDecimal("0.00");
for (OrderGoodsDTO goodsDto : goodsDTOList) {
//商品id
Integer goodId = goodsDto.getGoodId();
//商品价格
BigDecimal price = goodsDto.getPrice();
//商品类型
Integer type = goodsDto.getType();
Integer orderType = goodsDto.getType();
//商品比例
Integer extract = commissionBiz.getExtract(type, goodId);
Integer extract = commissionBiz.getExtract(orderType, goodId);
AppUserVo userVo = detailBiz.getUserInfoById(parentId);
Integer positionId = 6;
if (userVo != null) {
......@@ -137,6 +138,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setPositionId(positionId);
sellingWater.setOrderId(orderId);
sellingWater.setOrderNo(orderNo);
sellingWater.setOrderType(orderType);
sellingWater.setGoodId(goodId);
sellingWater.setTitle(goodsDto.getTitle());
sellingWater.setImg(goodsDto.getImg());
......@@ -146,6 +148,14 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setCommission(commission);
insertSelective(sellingWater);
log.info("购买计算用户拥成功----payOrderWater--------userId===" + userId);
amount = amount.add(commission);
}
log.info("购买计算用户未入账----payOrderWater--------userId===" + userId+"----amount===="+amount+"--orderType==="+orderType);
if(orderType==3){
finishOrderWater(orderWaterDTO);
}else if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,amount,1);
}
}
}
......@@ -161,14 +171,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
List<AppUserSellingWater> list = getWaterList(orderId);
BigDecimal amount = new BigDecimal("0.00");
Integer userId = 0;
Integer orderType=0;
if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
userId = sellingWater.getUserId();
sellingWater.setWaiting(1);
updateById(sellingWater);
BigDecimal commission = sellingWater.getCommission();
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission);
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission+"----orderType==="+orderType);
amount = amount.add(commission);
}
}
......@@ -176,7 +188,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包
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);
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,amount,2);
}
}
}
......@@ -191,10 +212,13 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
}
List<AppUserSellingWater> list = getWaterList(orderId);
BigDecimal amount = new BigDecimal("0.00");
BigDecimal unbooked = new BigDecimal("0.00");
Integer userId = 0;
Integer orderType=0;
if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
userId = sellingWater.getUserId();
sellingWater.setWaiting(1);
updateById(sellingWater);
......@@ -202,14 +226,23 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setStatus(1);
insertSelective(sellingWater);
BigDecimal commission = sellingWater.getCommission();
log.info("订单完成计算用户拥金----refundOrderWater----id====" + id + "---commission==" + commission);
log.info("订单完成计算用户拥金----refundOrderWater----id====" + id + "---commission==" + commission+"---orderType===="+orderType);
unbooked=unbooked.add(commission);
}
}
log.info("订单完成计算用户拥金----refundOrderWater----orderId====" + orderId + "---amount==" + amount);
log.info("订单完成计算用户拥金----refundOrderWater----orderId====" + orderId + "---amount==" + amount+"---unbooked==="+unbooked);
int r = amount.compareTo(BigDecimal.ZERO);
//更新钱包
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);
}
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,unbooked,2);
}
}
......@@ -282,6 +315,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
totalIncome = total.subtract(refund);
}
sellingWaterVos.sort(Comparator.comparing(SellingWalletVo::getCrtTime).reversed());
sellingWalletPagVo.setPageNum(pageNo);
sellingWalletPagVo.setPageSize(pageSize);
sellingWalletPagVo.setTotalCount(appUserSellingWaterPageDataVO.getTotalCount().intValue());
......
......@@ -46,7 +46,11 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
List<MyWallet> wallets = mapper.selectByExample(example);
MyWallet myWallet = wallets.get(0);
BeanUtils.copyProperties(myWallet, appletWalletVo);
appletWalletVo.setBalance(myWallet.getBalance()==null?new BigDecimal(0):myWallet.getBalance());
appletWalletVo.setTodayAmount(myWallet.getTodayAmount()==null?new BigDecimal(0):myWallet.getTodayAmount());
appletWalletVo.setTotalAmount(myWallet.getTotalAmount()==null?new BigDecimal(0):myWallet.getTotalAmount());
appletWalletVo.setUnbooked(myWallet.getUnbooked()==null?new BigDecimal(0):myWallet.getUnbooked());
appletWalletVo.setUserId(myWallet.getUserId());
return appletWalletVo;
}
......@@ -74,6 +78,9 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
BigDecimal totalConsumpution = userIdAndTotalConsumptionMap==null?new BigDecimal(0):userIdAndTotalConsumptionMap.get(wallet.getUserId())==null?new BigDecimal(0):userIdAndTotalConsumptionMap.get(wallet.getUserId());
BigDecimal withDrawaling = userIdAndWithdrawalingMap==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId())==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId());
walletpg.setWithdrawaling(withDrawaling);
walletpg.setWithdrawals(walletpg.getWithdrawals()==null?new BigDecimal(0):walletpg.getWithdrawals());
walletpg.setUnbooked(walletpg.getUnbooked()==null?new BigDecimal(0):walletpg.getUnbooked());
walletpg.setTotalAmount(walletpg.getTodayAmount()==null?walletpg.getUnbooked():walletpg.getTotalAmount().add(walletpg.getUnbooked()));
walletpg.setTotalConsumption(totalConsumpution);
walletPageVos.add(walletpg);
}
......
......@@ -35,8 +35,14 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
//我的钱包入账
public void updMyWater(Integer userId, Integer orderId,BigDecimal amount){
log.info("---我的钱包入账----userId==="+userId+"----orderId===="+orderId+"----amount===="+amount);
public void updMyWater(MyWalletDetail walletDetail){
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();
wallet.setUserId(userId);
wallet=selectOne(wallet);
......@@ -66,20 +72,15 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
if (lastTime!=null&&(lastTime==0||isToday(lastTime))){
todayAmount=wallet.getTodayAmount().add(amount);
}
unbooked=wallet.getUnbooked().subtract(unbooked);
}
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.setItype(0);
walletDetail.setBalance(oldBalance);
walletDetailBiz.insertSelective(walletDetail);
Long time=System.currentTimeMillis();
wallet.setBalance(balance);
wallet.setUnbooked(unbooked);
wallet.setTodayAmount(todayAmount);
wallet.setTotalAmount(totalAmount);
wallet.setUnbooked(unbooked);
......@@ -110,6 +111,33 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
return isToday;
}
//钱包未入账的处理type1-进;2-出
public void updMyWalletUnbooked(Integer userId,BigDecimal amount,Integer type){
MyWallet wallet=new MyWallet();
wallet.setUserId(userId);
wallet=selectOne(wallet);
BigDecimal unbooked=new BigDecimal("0.00");
if(wallet==null){
wallet=new MyWallet();
wallet.setUserId(userId);
if (type==1){
unbooked=amount;
}
wallet.setUnbooked(unbooked);
insertSelective(wallet);
}else {
if (type==1){
unbooked=wallet.getUnbooked().add(amount);
}else {
if (wallet.getUnbooked().compareTo(amount)>0){
unbooked=wallet.getUnbooked().subtract(amount);
}
}
wallet.setUnbooked(unbooked);
mapper.updMyWater(wallet);
}
}
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public int createWalletByUserId(Integer userId){
MyWallet myWallet = new MyWallet();
......
......@@ -20,12 +20,22 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
public static final String ORDER_WATER_QUEUE = "order.water.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 {
myQueue = new ArrayList<BindDTO>(){{
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_CANCEL));
add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH));
//支付完成后永久绑定关系
add(new BindDTO(ORDER_RELATION_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY));
//拥金计算
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_CANCEL));
add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ORDER_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();
}
}
});
}
}
......@@ -24,6 +24,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.github.wxiaoqi.security.admin.config.RabbitAdminConfig.*;
import static com.xxfc.platform.order.pojo.mq.OrderMQDTO.*;
@Component
@Slf4j
......@@ -46,16 +47,29 @@ public class WaterMQHandler {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
OrderMQDTO orderMQDTO = JSONUtil.toBean(msg, OrderMQDTO.class);
OrderWaterDTO orderWaterDTO = new OrderWaterDTO(){{
OrderWaterDTO orderWaterDTO = new OrderWaterDTO() {{
setUserId(orderMQDTO.getUserId());
setOrderNo(orderMQDTO.getNo());
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())) {
case RENT_VEHICLE:
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{
add(new OrderGoodsDTO(){{
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
......@@ -68,8 +82,8 @@ public class WaterMQHandler {
break;
case TOUR:
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{
add(new OrderGoodsDTO(){{
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderTourDetail().getGoodId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
......@@ -82,8 +96,8 @@ public class WaterMQHandler {
break;
case MEMBER:
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{
add(new OrderGoodsDTO(){{
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderMemberDetail().getMemberLevelId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
......@@ -115,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();
}
}
}
......@@ -199,6 +199,7 @@ public class AppPermissionService {
userRedisTemplate.expire(redisLockKey, 5, TimeUnit.MINUTES);//5分钟内过期
}
} catch (Exception e) {
e.printStackTrace();
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
return JsonResultUtil.createSuccessResultWithObj(result);
......@@ -215,6 +216,7 @@ public class AppPermissionService {
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JSONObject register(String username, String password, String headimgurl,
String nickname, String mobilecode, String openId, String unionid, Integer type,String code) {
log.info("register------code====="+code);
String activityCode = null;
// 判断参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(password) || StringUtils.isBlank(mobilecode)) {
......@@ -279,9 +281,13 @@ public class AppPermissionService {
}
parentId=appUserDetailBiz.getUserByCode(code);
}
if(parentId!=null&&parentId>0&&StringUtils.isNotBlank(activityCode)){
if(parentId!=null&&parentId>0){
relationBiz.bindRelation(userid, parentId, 1);
if(StringUtils.isNotBlank(activityCode)){
rsUserDetail.setInviterAccount(parentId);
}
}
//生成邀请码 长度改为8 不然重复率太高
rsUserDetail.setCode(UUIDUtils.genCodes(8));
appUserDetailBiz.insertSelective(rsUserDetail);
......@@ -358,6 +364,7 @@ public class AppPermissionService {
* 自动登录type;1-app;2-小程序
*/
public JSONObject autoLogin(Integer userid, String username, String headimgurl, String nickname,String code,String activityCode,Integer type) {
log.info("-----------autoLogin----code==="+code+"----activityCode===="+activityCode);
JSONObject data = new JSONObject();
AppUserVo userVo = appUserDetailBiz.getUserInfoById(userid);
if (userVo != null) {
......@@ -384,6 +391,7 @@ public class AppPermissionService {
//更新登录时间 和 ip
String clientIp = getIp();
appUserLoginBiz.updateLoginInfo(userid, clientIp);
log.info("-----------autoLogin----type==="+type);
if(type!=null&&type==1){
try {
Integer parentId=0;
......@@ -396,6 +404,7 @@ public class AppPermissionService {
}
//活动消息
Integer state=userVo.getState();
log.info("-----------autoLogin----state==="+state);
if(state!=null&&state==1){
if(userVo.getInviterAccount()==null||userVo.getInviterAccount()==0){
userVo.setInviterAccount(parentId);
......
......@@ -29,7 +29,7 @@
<result column="position_id" property="positionId"/>
<result column="source" property="source"/>
<result column="code" property="code"/>
<result column="invitera_ccount" property="inviterAccount"/>
<result column="inviter_account" property="inviterAccount"/>
<result column="state" property="state"/>
</resultMap>
......
......@@ -4,13 +4,15 @@
<select id="accquireIncomeByMemberIds" resultType="com.github.wxiaoqi.security.admin.bo.UserIncomeBo">
SELECT DISTINCT
SELECT DISTINCT
`source_id`as userId,
(( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 0 AND `waiting` = 1 )
- ( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 1 AND `waiting` = 1 )) as `income`
FROM
(( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 0 AND
`waiting` = 1 )
- ( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 1 AND
`waiting` = 1 )) as `income`
FROM
`app_user_selling_water` as ausw
WHERE
WHERE
source_id in
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
......@@ -18,6 +20,10 @@ WHERE
</select>
<select id="selectTotalIncomeByUserId" resultType="java.math.BigDecimal">
SELECT SUM(commission) FROM app_user_selling_water WHERE `user_id`=#{userId}
SELECT
( auswu.upIncome - auswd.dowIncome ) AS `income`
FROM
( SELECT SUM( commission ) AS upIncome FROM `app_user_selling_water` WHERE STATUS = 0 AND `user_id` = #{userId} ) AS `auswu`,
( SELECT SUM( commission ) AS `dowIncome` FROM `app_user_selling_water` WHERE STATUS = 1 AND `user_id` = #{userId} ) AS `auswd`;
</select>
</mapper>
\ No newline at end of file
package com.xxfc.platform.activity.dto;
import com.xxfc.platform.activity.entity.ActivityPopularizeItem;
import com.xxfc.platform.activity.entity.ActivityPopularizeLog;
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;
/**
* 用户参与推广活动(邀请有礼)的活动记录的记录(日志)
*
* @author libin
* @email 18178966185@163.com
* @date 2019-07-05 15:23:04
*/
@Data
public class ApLogDTO extends ActivityPopularizeLog {
ActivityPopularizeItem item;
}
package com.xxfc.platform.activity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class AwardDTO {
public static final int CONDITION_INVITE = 1;
/**
* 条件类型 1--邀请
*/
@ApiModelProperty("条件类型 1--邀请")
Integer conditionType;
/**
* 数量
*/
@ApiModelProperty("数量")
Integer num;
/**
* 奖励项
*/
@ApiModelProperty("奖励项")
List<AwardItemDTO> awardItems;
}
\ No newline at end of file
package com.xxfc.platform.activity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AwardItemDTO {
/**
* 奖励类型 1--现金;2--优惠券
*/
@ApiModelProperty("奖励类型")
Integer type;
/**
* 奖励内容(根据类型决定具体填什么,如优惠券就优惠券号)
*/
@ApiModelProperty("奖励")
String award;
}
\ No newline at end of file
......@@ -18,6 +18,12 @@
<artifactId>xx-activity-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-order-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
package com.xxfc.platform.activity.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.admin.dto.RegisterQueueDTO;
import com.github.wxiaoqi.security.admin.entity.MyWalletDetail;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import com.xxfc.platform.activity.dto.ApLogDTO;
import com.xxfc.platform.activity.dto.AwardDTO;
import com.xxfc.platform.activity.entity.ActivityPopularizeLog;
import com.xxfc.platform.activity.entity.ActivityPopularizeRelation;
import com.xxfc.platform.activity.entity.ActivityPopularizeUser;
import com.xxfc.platform.universal.feign.MQSenderFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -13,6 +23,9 @@ import com.xxfc.platform.activity.entity.ActivityPopularize;
import com.xxfc.platform.activity.mapper.ActivityPopularizeMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.math.BigDecimal;
import java.util.Date;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
......@@ -24,6 +37,7 @@ import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TR
* @date 2019-07-05 15:23:04
*/
@Service
@Slf4j
public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,ActivityPopularize> {
@Autowired
......@@ -41,24 +55,38 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
@Autowired
UserFeign userFeign;
@Autowired
MQSenderFeign mqSenderFeign;
public static final String POPULARIZE_0101 = "0101";
public static final String PREFIX = "P";
public static final Integer INVITE_ITEMID = 3;
public void handleRegister(RegisterQueueDTO registerQueueDTO) {
String activityCode = registerQueueDTO.getInParamDTO().getActivityCode().replace(PREFIX, "");
AppUserDTO appUserDTO = userFeign.userDetailById(registerQueueDTO.getAppUserId()).getData();
//获取活动code,并且注册来源是app 并且 非普通登录
if(POPULARIZE_0101.equals(registerQueueDTO.getInParamDTO().getActivityCode())
if(POPULARIZE_0101.equals(activityCode)
&& !RegisterQueueDTO.SIGN_LOGIN.equals(registerQueueDTO.getSign())) {
//查询出活动
ActivityPopularize activityPopularize = popularizeBiz.selectOne(new ActivityPopularize(){{
setCode(activityCode);
}});
Date now = DateUtil.date();
Date start = DateUtil.date(activityPopularize.getStartTime());
Date end = DateUtil.date(activityPopularize.getEndTime());
//判断是否活动超时
if(now.before(start) || now.after(end)) {
log.error("不在活动范围内 入参Json:"+ JSONUtil.toJsonStr(registerQueueDTO));
return;
}
Integer majorUserId = Integer.valueOf(appUserDTO.getInviterAccount());
//添加活动关系
......@@ -68,15 +96,15 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
setMinorUserId(appUserDTO.getUserid());
}});
ActivityPopularizeLog popularizeLog = popularizeLogBiz.selectOne(new ActivityPopularizeLog(){{
ApLogDTO apLogDTO = popularizeLogBiz.selectOneApLogDTO(new ActivityPopularizeLog(){{
setUserId(majorUserId);
setItemId(3);
setItemId(INVITE_ITEMID);
}});
//生成任务项
if(null == popularizeLog){
if(null == apLogDTO){
popularizeLogBiz.insertSelectiveRe(new ActivityPopularizeLog(){{
setItemId(3);
setItemId(INVITE_ITEMID);
setUserId(majorUserId);
setStatus(SYS_FALSE);
setPopularizeId(activityPopularize.getId());
......@@ -91,15 +119,26 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
//任务没有完成
if(!SYS_TRUE.equals(activityPopularizeUser.getStatus())) {
// AwardDTO awardDTO = JSONUtil.toBean(activityPopularize.getValue(), AwardDTO.class);
//检查是否满足奖励
if(relationBiz.selectList(new ActivityPopularizeRelation(){{
setMajorUserId(appUserDTO.getUserid());
setMajorUserId(majorUserId);
setPopularizeId(activityPopularize.getId());
}}).size() >= 10) {
}}).size() >= 2) {
apLogDTO.setStatus(SYS_TRUE);
popularizeLogBiz.updateSelectiveById(BeanUtil.toBean(apLogDTO, ActivityPopularizeLog.class));
activityPopularizeUser.setStatus(SYS_TRUE);
activityPopularizeUser.setCurrentProgress(apLogDTO.getItem().getProgress());
popularizeUserBiz.updateSelectiveById(activityPopularizeUser);
popularizeLog.setStatus(SYS_TRUE);
popularizeLogBiz.updateSelectiveById(popularizeLog);
mqSenderFeign.sendMessage(RabbitConstant.ADMIN_TOPIC, RabbitConstant.KEY_WALLET_ADD, JSONUtil.toJsonStr(new MyWalletDetail(){{
setAmount(new BigDecimal("50"));
setSource(SOURCE_ACTIVITY);
setUserId(majorUserId);
setActivityId(activityPopularize.getId());
setActivityName(activityPopularize.getName());
setType(TYPE_POPULARIZE);
setItype(ITYPE_IN);
}}));
}
}
}
......
package com.xxfc.platform.activity.biz;
import cn.hutool.core.bean.BeanUtil;
import com.xxfc.platform.activity.dto.ApLogDTO;
import com.xxfc.platform.activity.entity.ActivityPopularizeItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xxfc.platform.activity.entity.ActivityPopularizeLog;
......@@ -15,4 +19,18 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/
@Service
public class ActivityPopularizeLogBiz extends BaseBiz<ActivityPopularizeLogMapper,ActivityPopularizeLog> {
@Autowired
ActivityPopularizeItemBiz activityPopularizeItemBiz;
public ApLogDTO selectOneApLogDTO(ActivityPopularizeLog entity){
ActivityPopularizeLog apl = mapper.selectOne(entity);
if(null != apl) {
ApLogDTO apLogDTO = BeanUtil.toBean(apl, ApLogDTO.class);
apLogDTO.setItem(activityPopularizeItemBiz.selectById(apLogDTO.getItemId()));
return apLogDTO;
}else {
return null;
}
}
}
\ No newline at end of file
......@@ -161,13 +161,13 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example);
if(list.size()==0){
log.error(userId+"----没有可用优惠卷--TickerNo==="+TickerNo);
log.error(userId+"----没有可用优惠卷--tickerNo==="+TickerNo);
return couponAmout;
}
UserCoupon userCoupon=list.get(0);
if(userCoupon!=null&&userCoupon.getIsUse()==1){
log.error(userId+"----该优惠卷已使用--TickerNo=="+TickerNo);
log.error(userId+"----该优惠卷已使用--tickerNo=="+TickerNo);
return couponAmout;
}
if (type==1){
......@@ -209,7 +209,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return;
}
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("TickerNo",TickerNo).andEqualTo("isDel",0);
example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example);
if(list.size()==0){
log.error(TickerNo+"----优惠卷不存在");
......
......@@ -6,6 +6,8 @@ import com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import static com.github.wxiaoqi.security.common.config.rabbit.RabbitConstant.*;
/**
* rabbitmq配置类
......@@ -21,14 +23,19 @@ public class RabbitActivityConfig extends RabbitCommonConfig {
//新人注册有礼
public static final String ACTIVITY_NEW_QUEUE = "activity.new.queue";
public static final String INTEGRAL_HANDLE_QUEUE = "integral_handle_queue";
//优惠券
public static final String COUPON_CANCEL_QUEUE = "coupon.cancel.queue";
static {
myQueue = new ArrayList<BindDTO>(){{
add(new BindDTO(INTEGRAL_QUEUE, RabbitConstant.ORDER_TOPIC, "order.#"));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register"));
add(new BindDTO(POPULARZIE_0101_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth"));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.register"));
add(new BindDTO(ACTIVITY_NEW_QUEUE, RabbitConstant.ADMIN_TOPIC, "appUser.auth"));
add(new BindDTO(INTEGRAL_HANDLE_QUEUE, RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY));
add(new BindDTO(INTEGRAL_QUEUE, ORDER_TOPIC, "order.#"));
add(new BindDTO(POPULARZIE_0101_QUEUE, ADMIN_TOPIC, KEY_APPUSER_REGISTER));
add(new BindDTO(POPULARZIE_0101_QUEUE, ADMIN_TOPIC, KEY_APPUSER_AUTH));
add(new BindDTO(ACTIVITY_NEW_QUEUE, ADMIN_TOPIC, KEY_APPUSER_REGISTER));
add(new BindDTO(ACTIVITY_NEW_QUEUE, ADMIN_TOPIC, KEY_APPUSER_AUTH));
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();
}
}
});
}
}
......@@ -235,4 +235,11 @@ public class BaseOrder implements Serializable {
@ApiModelProperty(value = "优惠券优惠的价格")
@Column(name = "coupon_amount")
private BigDecimal couponAmount;
/**
* 使用的优惠券票号,逗号分割
*/
@ApiModelProperty(value = "使用的优惠券票号,逗号分割")
@Column(name = "coupon_ticker_nos")
private String couponTickerNos;
}
......@@ -9,10 +9,10 @@ import lombok.Data;
@Data
public class OrderMQDTO extends BaseOrder {
public static final Integer ORDER_CRT = 1;
public static final Integer ORDER_CANCEL = 2;
public static final Integer ORDER_PAY = 4;
public static final Integer ORDER_FINISH = 6;
public static final int ORDER_CRT = 1;
public static final int ORDER_CANCEL = 2;
public static final int ORDER_PAY = 4;
public static final int ORDER_FINISH = 6;
OrderRentVehicleDetail orderRentVehicleDetail;
......
......@@ -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.process.ResultCode;
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.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
......@@ -93,6 +94,9 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
@Autowired
OrderMsgBiz orderMsgBiz;
@Autowired
ActivityFeign activityFeign;
public List<OrderPageVO> pageByParm(Map<String, Object> paramMap){
return mapper.pageByParm(paramMap);
}
......@@ -284,13 +288,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
tourFeign.stock(otd.getSpePriceId(), otd.getTotalNumber(), TourFeign.STOCK_PLUS);
}
OrderMQDTO orderMQDTO = new OrderMQDTO();
orderMQDTO.setOrderMemberDetail(omd);
orderMQDTO.setOrderRentVehicleDetail(orvd);
orderMQDTO.setOrderTourDetail(otd);
//发送队列消息
sendQueue(orderMQDTO, OrderMQDTO.ORDER_CANCEL);
sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_CANCEL);
}else {
throw new BaseException(ResultCode.FAILED_CODE);
}
......@@ -321,7 +320,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
if(null == depositAmount) {
depositAmount = BigDecimal.ZERO;
}
BigDecimal refundGoodsAmount = calculateRefund(baseOrder.getGoodsAmount(), timeLag, dicParentKey, refundDesc);
//商品价格 - 优惠券减免的价格
BigDecimal refundGoodsAmount = calculateRefund(baseOrder.getGoodsAmount().subtract(baseOrder.getCouponAmount()), timeLag, dicParentKey, refundDesc);
//退款金额
BigDecimal refundAmount = depositAmount.add(refundGoodsAmount);
......@@ -498,17 +498,23 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//处理后台用户提醒短信的发送
orderMsgBiz.handelBgUserMsg4Pay(orvd, baseOrder, appUserDTO, OrderMsgBiz.RENT_PAY);
sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_PAY);
if(OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) {
sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_FINISH);
}
}
} else {
log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo);
}
}
public void sendOrderMq(OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, Integer sign) {
//发送队列消息
OrderMQDTO orderMQDTO = BeanUtil.toBean(baseOrder, OrderMQDTO.class);
orderMQDTO.setOrderRentVehicleDetail(orvd);
orderMQDTO.setOrderTourDetail(otd);
orderMQDTO.setOrderMemberDetail(omd);
sendQueue(orderMQDTO, OrderMQDTO.ORDER_PAY);
}
} else {
log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo);
}
sendQueue(orderMQDTO, sign);
}
/**
......
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.entity.BaseOrder;
import org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.OrderTourDetail;
......@@ -21,7 +24,16 @@ public class OrderTourDetailBiz extends BaseBiz<OrderTourDetailMapper,OrderTourD
private static Map<Integer, List<Integer>> ChargeOffAble;
public void ChargeOff() {
/**
* 更新(不成功抛异常)
* @param orderTourDetail
* @return
*/
public OrderTourDetail updateSelectiveByIdReT(OrderTourDetail orderTourDetail) {
if(updateSelectiveByIdRe(orderTourDetail) > 0) {
return selectById(orderTourDetail.getId());
}else {
throw new BaseException(ResultCode.DB_OPERATION_FAIL_CODE);
}
}
}
\ No newline at end of file
package com.xxfc.platform.order.biz;
import cn.hutool.core.bean.BeanUtil;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
......@@ -9,6 +8,7 @@ import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderTourDetail;
import com.xxfc.platform.order.mapper.OrderTourVerificationMapper;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderTourVerificationVO;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.tour.vo.TourGoodOrderFindVo;
......@@ -17,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;
/**
......@@ -89,25 +92,41 @@ public class OrderTourVerificationBiz{
}
// 出发时间 是否已经发车
Long departureTime = tourFeign.selectDepartureTimeByStartCompanyIdAndRouteId(tourDetail.getStartCompanyId(),tourDetail.getGoodId());
if (Instant.now().toEpochMilli()<departureTime){
Date departureDate = tourFeign.selectDepartureDataBySpeId(tourDetail.getSpePriceId());
Long departureTime = tourFeign.selectDepartureTimeByStartCompanyIdAndRouteId(tourDetail.getStartCompanyId(), tourDetail.getGoodId());
Integer departureStatus = tourFeign.selectDepartureStatusByVerificationId(verificationId);
LocalTime localDepartureTime = LocalTime.ofSecondOfDay(departureTime);
departureDate.setHours(localDepartureTime.getHour());
departureDate.setMinutes(localDepartureTime.getMinute());
departureDate.setSeconds(localDepartureTime.getSecond());
if (Instant.now().toEpochMilli()<departureDate.toInstant().toEpochMilli()){
return ObjectRestResponse.createFailedResultWithObj(400,"还未到发车时间",0);
}
Integer departureStatus = tourFeign.selectDepartureStatusByVerificationId(verificationId);
departureDate.setHours(0);
departureDate.setMinutes(0);
departureDate.setSeconds(0);
Instant seconddayInstant = departureDate.toInstant().plus(1, ChronoUnit.DAYS);
if(Instant.now().toEpochMilli()>seconddayInstant.toEpochMilli()){
return ObjectRestResponse.createFailedResultWithObj(400,"该票已无效",2);
}
if (departureStatus==1){
return ObjectRestResponse.createFailedResultWithObj(400,"已经发车",1);
}
baseOrder=new BaseOrder();
baseOrder.setId(orderId);
baseOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode());
baseOrder.setVersion(version);
baseOrderBiz.updateSelectiveById(baseOrder);
baseOrder = baseOrderBiz.updateSelectiveByIdReT(baseOrder);
tourDetail.setVerificationUser(userDTO.getId());
tourDetail.setVerificationName(userDTO.getName());
tourDetail.setVerificationTime(System.currentTimeMillis());
tourDetailBiz.updateSelectiveById(tourDetail);
tourDetail = tourDetailBiz.updateSelectiveByIdReT(tourDetail);
tourFeign.updateTourGoodPersonNum(verificationId,"verification_person",total_number);
baseOrderBiz.sendOrderMq(null,tourDetail,null, baseOrder, OrderMQDTO.ORDER_FINISH);
return ObjectRestResponse.succ();
}
......
......@@ -9,6 +9,7 @@ import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderUserLicense;
import com.xxfc.platform.order.entity.OrderVehicleCrosstown;
import com.xxfc.platform.order.mapper.OrderVehicaleCrosstownMapper;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.OrderVehicleCrosstownDto;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.Vehicle;
......@@ -60,14 +61,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
if (oldValue .size() == 1) {
//已有直接返回
//交车完成 设置订单状态为出行中
if(baseOrder.getStatus() == 4) {//
//判断交车时间是否是今天
baseOrder.setStatus(5);
baseOrderBiz.updateSelectiveById(baseOrder);
} else if(baseOrder.getStatus() == 5) {
baseOrder.setStatus(6);
baseOrderBiz.updateSelectiveById(baseOrder);
}
handleOrderStatus(baseOrder, orderRentVehicleDetail);
OrderVehicleCrosstownDto vehicleCrosstownDto = new OrderVehicleCrosstownDto();
BeanUtil.copyProperties(oldValue.get(0), vehicleCrosstownDto, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
List<OrderUserLicense> orderUserLicenses = orderUserLicenseBiz.selectByIds(oldValue.get(0).getUserLicenseId()).getData();
......@@ -85,15 +79,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} else if(oldValue .size() <= 0) {
getOrderLicense(orderVehicleCrosstownDto);
orderVehicalCrosstownBiz.insertSelective(orderVehicleCrosstownDto);
//交车完成 设置订单状态为出行中
if(baseOrder.getStatus() == 4) {
//判断是否是今日交车
baseOrder.setStatus(5);
baseOrderBiz.updateSelectiveById(baseOrder);
} else if(baseOrder.getStatus() == 5) {
baseOrder.setStatus(6);
baseOrderBiz.updateSelectiveById(baseOrder);
}
handleOrderStatus(baseOrder, orderRentVehicleDetail);
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
if(restResponse.getData() != null) {
orderVehicleCrosstownDto.setVehicleNumberPlat(restResponse.getData().getNumberPlate());
......@@ -103,6 +89,19 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.createDefaultFail();
}
private void handleOrderStatus(BaseOrder baseOrder, OrderRentVehicleDetail orderRentVehicleDetail) {
//交车完成 设置订单状态为出行中
if (baseOrder.getStatus() == 4) {
//判断是否是今日交车
baseOrder.setStatus(5);
baseOrderBiz.updateSelectiveById(baseOrder);
} else if (baseOrder.getStatus() == 5) {
baseOrder.setStatus(6);
baseOrderBiz.updateSelectiveById(baseOrder);
baseOrderBiz.sendOrderMq(orderRentVehicleDetail, null, null, baseOrder, OrderMQDTO.ORDER_FINISH);
}
}
public void getOrderLicense(OrderVehicleCrosstownDto orderVehicleCrosstownDto) {
OrderUserLicense orderUserLicense = new OrderUserLicense();
orderUserLicense.setLicenseIdCard(orderVehicleCrosstownDto.getLicenseIdCard());
......
......@@ -161,16 +161,14 @@ public class BaseOrderController extends CommonBaseController implements UserRes
List<Integer> userIds = list.stream().map(OrderListVo::getUserId).distinct().collect(Collectors.toList());
if(userIds != null && userIds.size() >0) {
ObjectRestResponse<List<AppUserVo>> objectRestResponse = userFeign.getByUserIds(userIds);
log.info("获取用户信息:objectRestResponse = {}", objectRestResponse.getMessage());
for (OrderListVo orderPageVO : list) {
if (objectRestResponse.getData() != null && objectRestResponse.getData().size() > 0) {
for (AppUserVo appUserVo : objectRestResponse.getData()) {
if (appUserVo != null && appUserVo.getUserid() == orderPageVO.getUserId()) {
if (appUserVo != null) {
orderPageVO.setTelephone(appUserVo.getUsername());
orderPageVO.setUsername(appUserVo.getNickname());
// ObjectRestResponse<AppUser> restResponse = userFeign.get(appUserVo.getUserid());
// if(restResponse.isRel()) {
// orderPageVO.setTelephone( restResponse.getData().getUsername());
// }
}
}
}
......
......@@ -43,7 +43,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
@RequestMapping(value = "/price/calculate/{type}/{no}", method = RequestMethod.GET)
@ResponseBody
@IgnoreClientToken
public ObjectRestResponse getOrderParam(@PathVariable(value = "no") String type, @PathVariable(value = "no") String no) {
public ObjectRestResponse getPriceCalculate(@PathVariable(value = "type") String type, @PathVariable(value = "no") String no) {
checkAppUser();
//根据no 查订单
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
......@@ -59,22 +59,22 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
switch (orderTypeEnum) {
case RENT_VEHICLE:
// orp.setRefundGoodsAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
, System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
, DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
, "取消订单退款:");
break;
case TOUR:
// String dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_REFUND;
// //不是省外,
// if(SYS_FALSE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
// dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_IN_REFUND;
// }
// orp.setRefundAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount().subtract(orderPageVO.getCouponAmount())
// , System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
// , DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
// , "取消订单退款:"));
break;
case TOUR:
String dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_REFUND;
//不是省外,
if(SYS_FALSE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
dicParentKey = DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.TOUR_IN_REFUND;
}
orp.setRefundAmount(baseOrderBiz.calculateRefund(orderPageVO.getGoodsAmount()
, System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
, DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
, "取消订单退款:"));
break;
default:
// orp.setRefundAmount(orderPageVO);
break;
......
......@@ -124,8 +124,6 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@Override
public void handleDetail(RentVehicleBO bo) {
//获取可用车辆
acquireVehicle(bo);
//设置订单状态为3
bo.getOrder().setStatus(OrderStatusEnum.ORDER_UNPAY.getCode());
//设置订单图片
......@@ -146,6 +144,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
activityFeign.use(bo.getAppUserDTO().getUserid(), bo.getTickerNo().get(0), bo.getOrder().getNo(), channel, bo.getOrder().getGoodsAmount(), ActivityFeign.TYPE_USE);
}
//获取可用车辆
acquireVehicle(bo);
super.handleDetail(bo);
//发送定时取消订单(数据字典设置--5分钟)
......@@ -245,6 +246,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
//待完成
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);
if(couponAmount.compareTo(BigDecimal.ZERO) > 0) {
detail.getOrder().setCouponTickerNos(detail.getTickerNo().get(0));
}
}
//总价格(包含押金)
......@@ -331,8 +335,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
RentVehicleBookDTO rentVehicleBookDTO = BeanUtil.toBean(detail.getBookVehicleVO(), RentVehicleBookDTO.class);
rentVehicleBookDTO.setModelId(detail.getModelId());
rentVehicleBookDTO.setUserName(BaseContextHandler.getName());
rentVehicleBookDTO.setLiftCompany(detail.getStartCompanyId());
rentVehicleBookDTO.setLiftAddr(detail.getStartAddr());
ObjectRestResponse<VehicleBookRecord> orr = vehicleFeign.rentApplyVehicle(rentVehicleBookDTO);
if(! CommonConstants.SYS_JSON_TRUE.equals(orr.getStatus())) {
if(!CommonConstants.SYS_JSON_TRUE.equals(orr.getStatus())) {
throw new BaseException(orr.getMessage(), orr.getStatus());
}
detail.setVehicleId(orr.getData().getVehicleId());
......
......@@ -218,6 +218,9 @@ public class OrderTourService extends AbstractOrderHandle<OrderTourDetailBiz, To
//待完成
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);
if(couponAmount.compareTo(BigDecimal.ZERO) > 0) {
detail.getOrder().setCouponTickerNos(detail.getTickerNo().get(0));
}
}
//总价格
......
......@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -100,4 +101,7 @@ public interface TourFeign {
@GetMapping("/tourGood/verfication/departure_status")
Integer selectDepartureStatusByVerificationId(@RequestParam(value = "verificationId") Integer verificationId);
@GetMapping("/spe/departure_date")
Date selectDepartureDataBySpeId(@RequestParam(value = "speIds") Integer speIds);
}
......@@ -21,7 +21,6 @@
</dependencies>
<build>
<finalName>xx-tour</finalName>
<plugins>
<!-- 此插件用来生成通用mapper的代码 -->
<plugin>
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.tour.dto.TourSpePriceDTO;
import com.xxfc.platform.tour.entity.TourGoodSpe;
import com.xxfc.platform.tour.entity.TourGoodSpePrice;
import com.xxfc.platform.tour.mapper.TourGoodSpePriceMapper;
import com.xxfc.platform.tour.vo.TourSpePriceVo;
......@@ -15,6 +16,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
/**
......@@ -101,4 +103,10 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
public void delGoodSpe(Integer goodId, List<Integer> ids){ mapper.delSpe(goodId,ids);}
public Date selectDepartureDataBySpeId(Integer speIds) {
TourGoodSpePrice tourGoodSpePrice = new TourGoodSpePrice();
tourGoodSpePrice.setId(speIds);
TourGoodSpePrice spePrice = mapper.selectOne(tourGoodSpePrice);
return spePrice.getStartTime();
}
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ import com.xxfc.platform.tour.dto.TourSpePriceDTO;
import com.xxfc.platform.tour.vo.TourSpePriceVo;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("spe")
@IgnoreClientToken
......@@ -32,4 +34,8 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
return baseBiz.cutStock(speId,number,type);
}
@GetMapping("/departure_date")
public Date selectDepartureDataBySpeId(@RequestParam(value = "speIds")Integer spePriceId){
return baseBiz.selectDepartureDataBySpeId(spePriceId);
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class CCPRestSmsUtils {
restAPI.init("app.cloopen.com", "8883");
restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559",
"3fe5e2f053674f23b029a9a9fc9503f0");
restAPI.setAppId("8a216da86812593601684bec10581ab5");
restAPI.setAppId("8a216da86bfdbeb5016c0d2543670a06");
}
public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) {
......
......@@ -13,8 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi.security.common.handler",
"com.github.wxiaoqi.security.common.log"
"com.github.wxiaoqi.security.common.handler"
})
@EnableDiscoveryClient
@EnableAceAuthClient
......
......@@ -10,21 +10,21 @@ import org.springframework.stereotype.Service;
public class CCPRestSmsBiz{
//租车订单通知(普通用户)1
public static final String TEMPLATE_ID_ORDER = "457270";
public static final String TEMPLATE_ID_ORDER = "458626";
//租车订单短信(会员权益)2
public static final String TEMPLATE_ID_ORDER_MEMBER = "457271";
public static final String TEMPLATE_ID_ORDER_MEMBER = "458625";
//旅游订单短信3
public static final String TEMPLATE_ID_ORDER_TOUR = "457272";
public static final String TEMPLATE_ID_ORDER_TOUR = "458624";
//加入会员通知4
public static final String TEMPLATE_ID_MEMBER = "457273";
public static final String TEMPLATE_ID_MEMBER = "458623";
//租/还车公司相同(订单支付后立即发送给相关负责人)5
public static final String TEMPLATE_ID_TAAKE_CAR = "457501";
public static final String TEMPLATE_ID_TAAKE_CAR = "458622";
//租/还车公司不同(发给租车公司负责人,订单支付后发送)6
public static final String TEMPLATE_ID_DIFFERENT_TAAKE_CAR = "457502";
public static final String TEMPLATE_ID_DIFFERENT_TAAKE_CAR = "458621";
// 租/还车公司不同(发给还车公司负责人,订单出车后发))(相同不发)7
public static final String TEMPLATE_ID_ALSO_CAR = "457503";
public static final String TEMPLATE_ID_ALSO_CAR = "458620";
//取消订单8
public static final String TEMPLATE_ID_CANCEL = "457506";
public static final String TEMPLATE_ID_CANCEL = "458627";
//发送模板消息
......
......@@ -77,6 +77,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
log.error("-----参数为空-----------");
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
log.error("-----payAmoun======="+payAmount+"------refundAmount======"+refundAmount);
Example example =new Example(OrderPay.class);
example.createCriteria().andEqualTo("orderNo", order_no).andEqualTo("isDel",0).andEqualTo("status",1);
List<OrderPay> list=payBiz.selectByExample(example);
......
......@@ -82,16 +82,15 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
}
@PostMapping(value = "/app/notify/alipay")
@PostMapping(value = "/app/unauth/notify/alipay")
@IgnoreUserToken
public String alipayNotify(){
return baseBiz.alipayNotify();
}
@GetMapping(value = "/app/generate_payment")
public Object generatePayment(@RequestParam("orderCode") String orderCode, @RequestParam("description") String description,
@RequestParam("payType") String payType, @RequestParam("amount") Integer amount) {
Object resp = baseBiz.generatePayment(orderCode, description, payType, amount);
public Object generatePayment(OrderPayVo orderPayVo) {
Object resp = baseBiz.generatePayment(orderPayVo);
return resp;
}
......
......@@ -15,6 +15,8 @@ import com.aliyuncs.profile.IClientProfile;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import com.github.wxiaoqi.security.common.util.RandomUtil;
......@@ -155,6 +157,62 @@ public class SmsService {
return false;
}
public boolean sendTemplate(String PhoneNumbers,String params,String templateCode) throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers(PhoneNumbers);
//必填:短信签名-可在短信控制台中找到
request.setSignName(SignName);
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(templateCode);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam(params);//\"name\":\"Tom\",
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
//request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
log.info("短信接口返回的数据----------------mobile======"+PhoneNumbers+"----templateParam===="+params);
log.info("Code=" + sendSmsResponse.getCode());
log.info("Message=" + sendSmsResponse.getMessage());
log.info("RequestId=" + sendSmsResponse.getRequestId());
log.info("BizId=" + sendSmsResponse.getBizId());
if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
//请求成功
return true;
}
return false;
}
public String getString(Map<String,Object> params){
if(params!=null){
StringBuilder sb = new StringBuilder("{");
for (Object o : params.keySet()) {
sb.append("\"" + o + "\"" +":"+"\"" + params.get(o) + "\"" +",");
}
sb.replace(sb.length() - 1, sb.length(), "}");
return sb.toString();
}
return null;
}
/* public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {
......@@ -188,14 +246,19 @@ public class SmsService {
}
*/
public static void main(String[] args) throws ClientException, InterruptedException {
SmsService SmsService=new SmsService();
SmsService smsService=new SmsService();
//发短信
String response = SmsService.sendSms("15521075918","123456");
Map<String,Object> params=new HashMap<>();
params.put("name","何振");
params.put("code","123456");
params.put("time",5);
params.put("other","何振2");
smsService.sendTemplate("13612688539","123","SMS_171112286");
/*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage());
System.out.println("RequestId=" + response.getRequestId());
System.out.println("BizId=" + response.getBizId());*/
System.out.println("BizId=" + response.getBizId());*//*
Thread.sleep(3000L);
/*
......
......@@ -53,7 +53,7 @@ public class UploadService {
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
realFileRelPath= SystemConfig.XXMP_URL+realFileRelPath;
realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath;
}
......@@ -83,7 +83,7 @@ public class UploadService {
realFileRelPath=filePath + "/" + no + ".jpg";
//将文件写入指定位置
ImgBase64Util.generateImage(imgFile,realFileRelPath);
realFileRelPath= SystemConfig.XXMP_URL+realFileRelPath;
realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath;
}
......
......@@ -78,4 +78,12 @@ public class BranchCompanyVo {
*/
private Integer zoneId;
/**
* 租车客服电话
*/
private String vehiceServicePhone;
/**
* 旅游客服电话
*/
private String tourServicePhone;
}
\ No newline at end of file
......@@ -27,4 +27,7 @@ public class VehiclePlanDto extends PageParam {
@ApiModelProperty(value = "停车分公司Id")
private Integer parkBranchCompanyId;
@ApiModelProperty(value = "所属分公司大区")
private Integer zoneId;
}
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import com.ace.cache.annotation.Cache;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
......@@ -24,11 +23,13 @@ import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.entity.VehicleWarningMsg;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -39,12 +40,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
......@@ -417,9 +417,10 @@ public class VehicleController extends BaseController<VehicleBiz> {
}
@RequestMapping(value = "/getVehiclePlanList", method = RequestMethod.GET)
@RequestMapping(value = "/app/unauth/getVehiclePlanList", method = RequestMethod.GET)
@ApiOperation(value = "获取排车信息")
@IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) {
//获取统计信息
List<VehicleCountVo> vehicleCountVos = baseBiz.countVehicleByParam(vehiclePlanDto);
......
......@@ -9,13 +9,16 @@
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="branch_type" property="branchType" jdbcType="INTEGER" />
<result column="subordinate_branch" property="subordinateBranch" jdbcType="INTEGER" />
<result column="location" property="location" jdbcType="VARCHAR" />
<result column="addr_province" property="addrProvince" jdbcType="INTEGER" />
<result column="addr_city" property="addrCity" jdbcType="INTEGER" />
<result column="addr_town" property="addrTown" jdbcType="INTEGER" />
<result column="addr_detail" property="addrDetail" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="vehice_service_phone" property="vehiceServicePhone"/>
<result column="tour_service_phone" property="tourServicePhone"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
</resultMap>
<select id="search" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO">
......
......@@ -425,6 +425,8 @@
<select id="getAllVehicle" parameterType="java.util.Map" resultMap="searchModel">
select *
from vehicle v1
-- 所属分公司
LEFT JOIN branch_company bc2 ON v1.subordinate_branch = bc2.id
<where>
<if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime}
......@@ -441,36 +443,46 @@
<if test="parkBranchCompanyId != null">
and v1.park_branch_company_id = #{parkBranchCompanyId}
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if>
</where>
</select>
<select id="countVehicleByParam" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto"
resultType="com.xxfc.platform.vehicle.pojo.VehicleCountVo">
SELECT count(*) total ,
CASE
WHEN travel_status = 1 THEN
WHEN v1.status = 1 THEN
'1'
WHEN travel_status = 2 THEN
WHEN v1.status = 2 THEN
'2'
WHEN travel_status = 3 THEN
WHEN v1.status = 3 THEN
'3'
WHEN travel_status = 4 THEN
WHEN v1.status = 4 THEN
'4'
WHEN v1.status = 5 THEN
'5'
ELSE
'-1'
'6'
END travel_status,
CASE
WHEN travel_status = 1 THEN
'出行中'
WHEN travel_status = 2 THEN
'预约中'
WHEN travel_status = 3 THEN
'空闲中'
WHEN travel_status = 4 THEN
'保养中'
WHEN v1.status = 1 THEN
'正常运行'
WHEN v1.status = 2 THEN
'维修'
WHEN v1.status = 3 THEN
'报废'
WHEN v1.status = 4 THEN
'出车'
WHEN v1.status = 5 THEN
'保养'
ELSE
'不可用'
END detail
from vehicle v1
-- 所属分公司
LEFT JOIN branch_company bc1 ON v1.subordinate_branch = bc1.id
<where>
<if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime}
......@@ -487,10 +499,15 @@
<if test="parkBranchCompanyId != null">
and v1.park_branch_company_id = #{parkBranchCompanyId}
</if>
<if test="zoneId !=null">
and bc1.zone_id = #{zoneId}
</if>
</where>
GROUP BY travel_status
GROUP BY v1.status
union all
SELECT count(*) total, '0' travel_status, '总数' detail from vehicle v2
-- 所属分公司
LEFT JOIN branch_company bc2 ON v2.subordinate_branch = bc2.id
<where>
<if test="startTime != null">
and v2.create_time between #{startTime} and #{endTime}
......@@ -507,44 +524,10 @@
<if test="parkBranchCompanyId != null">
and v2.park_branch_company_id = #{parkBranchCompanyId}
</if>
</where>
union all
SELECT count(*) total,
CASE
WHEN status = 1 THEN
'5'
WHEN status = 2 THEN
'6'
ELSE
'7'
END travel_status,
CASE
WHEN status = 1 THEN
'正常运行'
WHEN status = 2 THEN
'维修'
ELSE
'报废'
END travel_status
FROM vehicle v3
<where>
<if test="startTime != null">
and v3.create_time between #{startTime} and #{endTime}
</if>
<if test="numberPlate != null">
and v3.number_plate = #{numberPlate}
</if>
<if test="status != null">
and v3.status = #{status}
</if>
<if test="subordinateBranch != null">
and v3.subordinate_branch = #{subordinateBranch}
</if>
<if test="parkBranchCompanyId != null">
and v3.park_branch_company_id = #{parkBranchCompanyId}
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if>
</where>
GROUP BY status
</select>
<!-- 查询可用车辆/车型 的公用 from 和 where 部分条件 -->
......
......@@ -29,6 +29,7 @@
select w.*
from vehicle_warning_msg w
left join vehicle v on w.vehicle_id = v.id
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
<where>
<if test="vehicleId != null">
and w.vehicle_id = #{vehicleId}
......@@ -48,6 +49,9 @@
<if test="parkBranchCompanyId != null">
and v.park_branch_company_id = #{parkBranchCompanyId}
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if>
</where>
</select>
......
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