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 { ...@@ -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
#项目url #项目url
XXMP_URL=https://xxtest.upyuns.com/image XXMP_URL=/image
#token到期时间 #token到期时间
TOKEN_OVER_TIME=604800 TOKEN_OVER_TIME=604800
#itoken到期时间(6天) #itoken到期时间(6天)
......
...@@ -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;
/** /**
* 更新时间 * 更新时间
......
...@@ -62,6 +62,13 @@ public class AppUserSellingWater implements Serializable { ...@@ -62,6 +62,13 @@ public class AppUserSellingWater implements Serializable {
@Column(name = "order_no") @Column(name = "order_no")
@ApiModelProperty(value = "订单号") @ApiModelProperty(value = "订单号")
private String orderNo; private String orderNo;
/**
* 订单号
*/
@Column(name = "order_type")
@ApiModelProperty(value = "1-租车;2-旅游;3-会员;4-营地")
private Integer orderType;
/** /**
* 商品id * 商品id
......
...@@ -19,7 +19,12 @@ import lombok.Data; ...@@ -19,7 +19,12 @@ import lombok.Data;
@Table(name = "my_wallet_detail") @Table(name = "my_wallet_detail")
public class MyWalletDetail implements Serializable { public class MyWalletDetail implements Serializable {
private static final long serialVersionUID = 1L; 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 * 主键ID
*/ */
...@@ -103,6 +108,5 @@ public class MyWalletDetail implements Serializable { ...@@ -103,6 +108,5 @@ public class MyWalletDetail implements Serializable {
@Column(name = "crt_time") @Column(name = "crt_time")
@ApiModelProperty(value = "操作时间", hidden = true ) @ApiModelProperty(value = "操作时间", hidden = true )
private Long crtTime; 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
*/ */
......
...@@ -36,4 +36,8 @@ public class AppletWalletVo { ...@@ -36,4 +36,8 @@ public class AppletWalletVo {
*/ */
@ApiModelProperty(value = "今日收益(元)") @ApiModelProperty(value = "今日收益(元)")
private BigDecimal todayAmount; private BigDecimal todayAmount;
@ApiModelProperty(value = "未入账金额")
private BigDecimal unbooked;
} }
...@@ -79,7 +79,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel ...@@ -79,7 +79,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
//永久稳定关系 //永久稳定关系
public void foreverBind(Integer user_id ){ public void foreverBind(Integer user_id ){
AppUserRelation relation=getMyBiz().getRelationByUserId(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); relation.setIsForever(1);
getMyBiz().updRelation(relation); getMyBiz().updRelation(relation);
} }
......
...@@ -103,15 +103,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -103,15 +103,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
Integer parentId = relation.getParentId(); Integer parentId = relation.getParentId();
log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---parentId===" + parentId); log.info("购买计算用户拥金----payOrderWater--------userId===" + userId + "---parentId===" + parentId);
BigDecimal amount = new BigDecimal("0.00");
for (OrderGoodsDTO goodsDto : goodsDTOList) { for (OrderGoodsDTO goodsDto : goodsDTOList) {
//商品id //商品id
Integer goodId = goodsDto.getGoodId(); Integer goodId = goodsDto.getGoodId();
//商品价格 //商品价格
BigDecimal price = goodsDto.getPrice(); 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); AppUserVo userVo = detailBiz.getUserInfoById(parentId);
Integer positionId = 6; Integer positionId = 6;
if (userVo != null) { if (userVo != null) {
...@@ -137,6 +138,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -137,6 +138,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setPositionId(positionId); sellingWater.setPositionId(positionId);
sellingWater.setOrderId(orderId); sellingWater.setOrderId(orderId);
sellingWater.setOrderNo(orderNo); sellingWater.setOrderNo(orderNo);
sellingWater.setOrderType(orderType);
sellingWater.setGoodId(goodId); sellingWater.setGoodId(goodId);
sellingWater.setTitle(goodsDto.getTitle()); sellingWater.setTitle(goodsDto.getTitle());
sellingWater.setImg(goodsDto.getImg()); sellingWater.setImg(goodsDto.getImg());
...@@ -146,6 +148,14 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -146,6 +148,14 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setCommission(commission); sellingWater.setCommission(commission);
insertSelective(sellingWater); insertSelective(sellingWater);
log.info("购买计算用户拥成功----payOrderWater--------userId===" + userId); 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 ...@@ -161,14 +171,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
List<AppUserSellingWater> list = getWaterList(orderId); List<AppUserSellingWater> list = getWaterList(orderId);
BigDecimal amount = new BigDecimal("0.00"); BigDecimal amount = new BigDecimal("0.00");
Integer userId = 0; Integer userId = 0;
Integer orderType=0;
if (list.size() > 0) { if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) { for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId(); Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
userId = sellingWater.getUserId(); userId = sellingWater.getUserId();
sellingWater.setWaiting(1); sellingWater.setWaiting(1);
updateById(sellingWater); updateById(sellingWater);
BigDecimal commission = sellingWater.getCommission(); BigDecimal commission = sellingWater.getCommission();
log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission); log.info("订单完成计算用户拥金----finishOrderWater----id====" + id + "---commission==" + commission+"----orderType==="+orderType);
amount = amount.add(commission); amount = amount.add(commission);
} }
} }
...@@ -176,7 +188,16 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -176,7 +188,16 @@ 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);
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,amount,2);
}
} }
} }
...@@ -191,10 +212,13 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -191,10 +212,13 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
} }
List<AppUserSellingWater> list = getWaterList(orderId); List<AppUserSellingWater> list = getWaterList(orderId);
BigDecimal amount = new BigDecimal("0.00"); BigDecimal amount = new BigDecimal("0.00");
BigDecimal unbooked = new BigDecimal("0.00");
Integer userId = 0; Integer userId = 0;
Integer orderType=0;
if (list.size() > 0) { if (list.size() > 0) {
for (AppUserSellingWater sellingWater : list) { for (AppUserSellingWater sellingWater : list) {
Integer id = sellingWater.getId(); Integer id = sellingWater.getId();
orderType=sellingWater.getOrderType();
userId = sellingWater.getUserId(); userId = sellingWater.getUserId();
sellingWater.setWaiting(1); sellingWater.setWaiting(1);
updateById(sellingWater); updateById(sellingWater);
...@@ -202,14 +226,23 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -202,14 +226,23 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
sellingWater.setStatus(1); sellingWater.setStatus(1);
insertSelective(sellingWater); insertSelective(sellingWater);
BigDecimal commission = sellingWater.getCommission(); 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); 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);
}
if(orderType==1||orderType==2){
myWaterBiz.updMyWalletUnbooked(userId,unbooked,2);
} }
} }
...@@ -282,6 +315,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A ...@@ -282,6 +315,7 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
totalIncome = total.subtract(refund); totalIncome = total.subtract(refund);
} }
sellingWaterVos.sort(Comparator.comparing(SellingWalletVo::getCrtTime).reversed());
sellingWalletPagVo.setPageNum(pageNo); sellingWalletPagVo.setPageNum(pageNo);
sellingWalletPagVo.setPageSize(pageSize); sellingWalletPagVo.setPageSize(pageSize);
sellingWalletPagVo.setTotalCount(appUserSellingWaterPageDataVO.getTotalCount().intValue()); sellingWalletPagVo.setTotalCount(appUserSellingWaterPageDataVO.getTotalCount().intValue());
......
...@@ -46,7 +46,11 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -46,7 +46,11 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> {
List<MyWallet> wallets = mapper.selectByExample(example); List<MyWallet> wallets = mapper.selectByExample(example);
MyWallet myWallet = wallets.get(0); 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; return appletWalletVo;
} }
...@@ -74,6 +78,9 @@ public class MyWalletBiz extends BaseBiz<MyWalletMapper, MyWallet> { ...@@ -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 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()); BigDecimal withDrawaling = userIdAndWithdrawalingMap==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId())==null?new BigDecimal(0):userIdAndWithdrawalingMap.get(wallet.getUserId());
walletpg.setWithdrawaling(withDrawaling); 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); walletpg.setTotalConsumption(totalConsumpution);
walletPageVos.add(walletpg); walletPageVos.add(walletpg);
} }
......
...@@ -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);
...@@ -66,20 +72,15 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{ ...@@ -66,20 +72,15 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
if (lastTime!=null&&(lastTime==0||isToday(lastTime))){ if (lastTime!=null&&(lastTime==0||isToday(lastTime))){
todayAmount=wallet.getTodayAmount().add(amount); 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); log.info("---我的钱包入账----userId==="+userId+"----balance===="+balance+"----totalAmount===="+totalAmount+"---todayAmount==="+todayAmount+"---unbooked=="+unbooked);
MyWalletDetail walletDetail=new MyWalletDetail(); walletDetail.setItype(0);
walletDetail.setUserId(userId);
walletDetail.setSource(1);
walletDetail.setCono(orderId);
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();
wallet.setBalance(balance); wallet.setBalance(balance);
wallet.setUnbooked(unbooked);
wallet.setTodayAmount(todayAmount); wallet.setTodayAmount(todayAmount);
wallet.setTotalAmount(totalAmount); wallet.setTotalAmount(totalAmount);
wallet.setUnbooked(unbooked); wallet.setUnbooked(unbooked);
...@@ -110,6 +111,33 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{ ...@@ -110,6 +111,33 @@ public class MyWaterBiz extends BaseBiz<MyWalletMapper, MyWallet>{
return isToday; 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) @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public int createWalletByUserId(Integer userId){ public int createWalletByUserId(Integer userId){
MyWallet myWallet = new MyWallet(); MyWallet myWallet = new MyWallet();
......
...@@ -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_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_PAY)); //支付完成后永久绑定关系
add(new BindDTO(ORDER_WATER_QUEUE, ADMIN_TOPIC, KEY_ORDER_FINLISH)); add(new BindDTO(ORDER_RELATION_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY));
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_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; ...@@ -24,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
...@@ -46,16 +47,29 @@ public class WaterMQHandler { ...@@ -46,16 +47,29 @@ public class WaterMQHandler {
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 = JSONUtil.toBean(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());
...@@ -68,8 +82,8 @@ public class WaterMQHandler { ...@@ -68,8 +82,8 @@ public class WaterMQHandler {
break; break;
case TOUR: case TOUR:
orderWaterDTO.setGoodsDTOList( orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{ new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO(){{ add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderTourDetail().getGoodId()); setGoodId(orderMQDTO.getOrderTourDetail().getGoodId());
setGoodNumber(1); setGoodNumber(1);
setImg(orderMQDTO.getPicture()); setImg(orderMQDTO.getPicture());
...@@ -82,8 +96,8 @@ public class WaterMQHandler { ...@@ -82,8 +96,8 @@ public class WaterMQHandler {
break; break;
case MEMBER: case MEMBER:
orderWaterDTO.setGoodsDTOList( orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>(){{ new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO(){{ add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderMemberDetail().getMemberLevelId()); setGoodId(orderMQDTO.getOrderMemberDetail().getMemberLevelId());
setGoodNumber(1); setGoodNumber(1);
setImg(orderMQDTO.getPicture()); setImg(orderMQDTO.getPicture());
...@@ -115,31 +129,5 @@ public class WaterMQHandler { ...@@ -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 { ...@@ -199,6 +199,7 @@ public class AppPermissionService {
userRedisTemplate.expire(redisLockKey, 5, TimeUnit.MINUTES);//5分钟内过期 userRedisTemplate.expire(redisLockKey, 5, TimeUnit.MINUTES);//5分钟内过期
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常"); return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
} }
return JsonResultUtil.createSuccessResultWithObj(result); return JsonResultUtil.createSuccessResultWithObj(result);
...@@ -215,6 +216,7 @@ public class AppPermissionService { ...@@ -215,6 +216,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 +281,12 @@ public class AppPermissionService { ...@@ -279,8 +281,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));
...@@ -358,6 +364,7 @@ public class AppPermissionService { ...@@ -358,6 +364,7 @@ public class AppPermissionService {
* 自动登录type;1-app;2-小程序 * 自动登录type;1-app;2-小程序
*/ */
public JSONObject autoLogin(Integer userid, String username, String headimgurl, String nickname,String code,String activityCode,Integer type) { 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(); JSONObject data = new JSONObject();
AppUserVo userVo = appUserDetailBiz.getUserInfoById(userid); AppUserVo userVo = appUserDetailBiz.getUserInfoById(userid);
if (userVo != null) { if (userVo != null) {
...@@ -384,6 +391,7 @@ public class AppPermissionService { ...@@ -384,6 +391,7 @@ public class AppPermissionService {
//更新登录时间 和 ip //更新登录时间 和 ip
String clientIp = getIp(); String clientIp = getIp();
appUserLoginBiz.updateLoginInfo(userid, clientIp); appUserLoginBiz.updateLoginInfo(userid, clientIp);
log.info("-----------autoLogin----type==="+type);
if(type!=null&&type==1){ if(type!=null&&type==1){
try { try {
Integer parentId=0; Integer parentId=0;
...@@ -396,6 +404,7 @@ public class AppPermissionService { ...@@ -396,6 +404,7 @@ public class AppPermissionService {
} }
//活动消息 //活动消息
Integer state=userVo.getState(); Integer state=userVo.getState();
log.info("-----------autoLogin----state==="+state);
if(state!=null&&state==1){ if(state!=null&&state==1){
if(userVo.getInviterAccount()==null||userVo.getInviterAccount()==0){ if(userVo.getInviterAccount()==null||userVo.getInviterAccount()==0){
userVo.setInviterAccount(parentId); userVo.setInviterAccount(parentId);
......
...@@ -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>
......
...@@ -4,20 +4,26 @@ ...@@ -4,20 +4,26 @@
<select id="accquireIncomeByMemberIds" resultType="com.github.wxiaoqi.security.admin.bo.UserIncomeBo"> <select id="accquireIncomeByMemberIds" resultType="com.github.wxiaoqi.security.admin.bo.UserIncomeBo">
SELECT DISTINCT SELECT DISTINCT
`source_id`as userId, `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` = 0 AND
- ( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 1 AND `waiting` = 1 )) as `income` `waiting` = 1 )
FROM - ( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 1 AND
`app_user_selling_water` as ausw `waiting` = 1 )) as `income`
WHERE FROM
source_id in `app_user_selling_water` as ausw
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=","> WHERE
#{memberId} source_id in
</foreach> <foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
</foreach>
</select> </select>
<select id="selectTotalIncomeByUserId" resultType="java.math.BigDecimal"> <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> </select>
</mapper> </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 @@ ...@@ -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>
......
package com.xxfc.platform.activity.biz; 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.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.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; 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.ActivityPopularizeLog;
import com.xxfc.platform.activity.entity.ActivityPopularizeRelation; import com.xxfc.platform.activity.entity.ActivityPopularizeRelation;
import com.xxfc.platform.activity.entity.ActivityPopularizeUser; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -13,6 +23,9 @@ import com.xxfc.platform.activity.entity.ActivityPopularize; ...@@ -13,6 +23,9 @@ import com.xxfc.platform.activity.entity.ActivityPopularize;
import com.xxfc.platform.activity.mapper.ActivityPopularizeMapper; import com.xxfc.platform.activity.mapper.ActivityPopularizeMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; 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_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE; 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 ...@@ -24,6 +37,7 @@ import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TR
* @date 2019-07-05 15:23:04 * @date 2019-07-05 15:23:04
*/ */
@Service @Service
@Slf4j
public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,ActivityPopularize> { public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,ActivityPopularize> {
@Autowired @Autowired
...@@ -41,24 +55,38 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti ...@@ -41,24 +55,38 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
@Autowired @Autowired
UserFeign userFeign; UserFeign userFeign;
@Autowired
MQSenderFeign mqSenderFeign;
public static final String POPULARIZE_0101 = "0101"; public static final String POPULARIZE_0101 = "0101";
public static final String PREFIX = "P"; public static final String PREFIX = "P";
public static final Integer INVITE_ITEMID = 3;
public void handleRegister(RegisterQueueDTO registerQueueDTO) { public void handleRegister(RegisterQueueDTO registerQueueDTO) {
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())) {
//查询出活动 //查询出活动
ActivityPopularize activityPopularize = popularizeBiz.selectOne(new ActivityPopularize(){{ ActivityPopularize activityPopularize = popularizeBiz.selectOne(new ActivityPopularize(){{
setCode(activityCode); 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()); Integer majorUserId = Integer.valueOf(appUserDTO.getInviterAccount());
//添加活动关系 //添加活动关系
...@@ -68,15 +96,15 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti ...@@ -68,15 +96,15 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
setMinorUserId(appUserDTO.getUserid()); setMinorUserId(appUserDTO.getUserid());
}}); }});
ActivityPopularizeLog popularizeLog = popularizeLogBiz.selectOne(new ActivityPopularizeLog(){{ ApLogDTO apLogDTO = popularizeLogBiz.selectOneApLogDTO(new ActivityPopularizeLog(){{
setUserId(majorUserId); setUserId(majorUserId);
setItemId(3); setItemId(INVITE_ITEMID);
}}); }});
//生成任务项 //生成任务项
if(null == popularizeLog){ if(null == apLogDTO){
popularizeLogBiz.insertSelectiveRe(new ActivityPopularizeLog(){{ popularizeLogBiz.insertSelectiveRe(new ActivityPopularizeLog(){{
setItemId(3); setItemId(INVITE_ITEMID);
setUserId(majorUserId); setUserId(majorUserId);
setStatus(SYS_FALSE); setStatus(SYS_FALSE);
setPopularizeId(activityPopularize.getId()); setPopularizeId(activityPopularize.getId());
...@@ -91,15 +119,26 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti ...@@ -91,15 +119,26 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
//任务没有完成 //任务没有完成
if(!SYS_TRUE.equals(activityPopularizeUser.getStatus())) { if(!SYS_TRUE.equals(activityPopularizeUser.getStatus())) {
// AwardDTO awardDTO = JSONUtil.toBean(activityPopularize.getValue(), AwardDTO.class);
//检查是否满足奖励 //检查是否满足奖励
if(relationBiz.selectList(new ActivityPopularizeRelation(){{ if(relationBiz.selectList(new ActivityPopularizeRelation(){{
setMajorUserId(appUserDTO.getUserid()); setMajorUserId(majorUserId);
setPopularizeId(activityPopularize.getId()); setPopularizeId(activityPopularize.getId());
}}).size() >= 10) { }}).size() >= 2) {
apLogDTO.setStatus(SYS_TRUE);
popularizeLogBiz.updateSelectiveById(BeanUtil.toBean(apLogDTO, ActivityPopularizeLog.class));
activityPopularizeUser.setStatus(SYS_TRUE); activityPopularizeUser.setStatus(SYS_TRUE);
activityPopularizeUser.setCurrentProgress(apLogDTO.getItem().getProgress());
popularizeUserBiz.updateSelectiveById(activityPopularizeUser); popularizeUserBiz.updateSelectiveById(activityPopularizeUser);
popularizeLog.setStatus(SYS_TRUE); mqSenderFeign.sendMessage(RabbitConstant.ADMIN_TOPIC, RabbitConstant.KEY_WALLET_ADD, JSONUtil.toJsonStr(new MyWalletDetail(){{
popularizeLogBiz.updateSelectiveById(popularizeLog); 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; 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 org.springframework.stereotype.Service;
import com.xxfc.platform.activity.entity.ActivityPopularizeLog; import com.xxfc.platform.activity.entity.ActivityPopularizeLog;
...@@ -15,4 +19,18 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -15,4 +19,18 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/ */
@Service @Service
public class ActivityPopularizeLogBiz extends BaseBiz<ActivityPopularizeLogMapper,ActivityPopularizeLog> { 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> { ...@@ -161,13 +161,13 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0); example.createCriteria().andEqualTo("tickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example); List<UserCoupon> list=selectByExample(example);
if(list.size()==0){ if(list.size()==0){
log.error(userId+"----没有可用优惠卷--TickerNo==="+TickerNo); log.error(userId+"----没有可用优惠卷--tickerNo==="+TickerNo);
return couponAmout; return couponAmout;
} }
UserCoupon userCoupon=list.get(0); UserCoupon userCoupon=list.get(0);
if(userCoupon!=null&&userCoupon.getIsUse()==1){ if(userCoupon!=null&&userCoupon.getIsUse()==1){
log.error(userId+"----该优惠卷已使用--TickerNo=="+TickerNo); log.error(userId+"----该优惠卷已使用--tickerNo=="+TickerNo);
return couponAmout; return couponAmout;
} }
if (type==1){ if (type==1){
...@@ -209,7 +209,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -209,7 +209,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return; return;
} }
Example example=new Example(UserCoupon.class); 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); List<UserCoupon> list=selectByExample(example);
if(list.size()==0){ if(list.size()==0){
log.error(TickerNo+"----优惠卷不存在"); log.error(TickerNo+"----优惠卷不存在");
......
...@@ -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();
}
}
});
}
}
...@@ -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_nos")
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);
} }
...@@ -284,13 +288,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -284,13 +288,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
tourFeign.stock(otd.getSpePriceId(), otd.getTotalNumber(), TourFeign.STOCK_PLUS); 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 { }else {
throw new BaseException(ResultCode.FAILED_CODE); throw new BaseException(ResultCode.FAILED_CODE);
} }
...@@ -321,7 +320,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -321,7 +320,8 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
if(null == depositAmount) { if(null == depositAmount) {
depositAmount = BigDecimal.ZERO; 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); BigDecimal refundAmount = depositAmount.add(refundGoodsAmount);
...@@ -498,19 +498,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> { ...@@ -498,19 +498,25 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper,BaseOrder> {
//处理后台用户提醒短信的发送 //处理后台用户提醒短信的发送
orderMsgBiz.handelBgUserMsg4Pay(orvd, baseOrder, appUserDTO, OrderMsgBiz.RENT_PAY); orderMsgBiz.handelBgUserMsg4Pay(orvd, baseOrder, appUserDTO, OrderMsgBiz.RENT_PAY);
sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_PAY);
//发送队列消息 if(OrderTypeEnum.MEMBER.getCode().equals(baseOrder.getType())) {
OrderMQDTO orderMQDTO = BeanUtil.toBean(baseOrder, OrderMQDTO.class); sendOrderMq(orvd, otd, omd, baseOrder, OrderMQDTO.ORDER_FINISH);
orderMQDTO.setOrderRentVehicleDetail(orvd); }
orderMQDTO.setOrderTourDetail(otd);
orderMQDTO.setOrderMemberDetail(omd);
sendQueue(orderMQDTO, OrderMQDTO.ORDER_PAY);
} }
} else { } else {
log.error(" order has payed , orderNo:{}, tradeNo:{} ", orderNo, tradeNo); 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, sign);
}
/** /**
* 更新(不成功抛异常) * 更新(不成功抛异常)
* @param baseOrder * @param baseOrder
......
package com.xxfc.platform.order.biz; 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 org.springframework.stereotype.Service;
import com.xxfc.platform.order.entity.OrderTourDetail; import com.xxfc.platform.order.entity.OrderTourDetail;
...@@ -21,7 +24,16 @@ public class OrderTourDetailBiz extends BaseBiz<OrderTourDetailMapper,OrderTourD ...@@ -21,7 +24,16 @@ public class OrderTourDetailBiz extends BaseBiz<OrderTourDetailMapper,OrderTourD
private static Map<Integer, List<Integer>> ChargeOffAble; 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; 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.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
...@@ -9,6 +8,7 @@ import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum; ...@@ -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.BaseOrder;
import com.xxfc.platform.order.entity.OrderTourDetail; import com.xxfc.platform.order.entity.OrderTourDetail;
import com.xxfc.platform.order.mapper.OrderTourVerificationMapper; 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.order.pojo.order.OrderTourVerificationVO;
import com.xxfc.platform.tour.feign.TourFeign; import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.tour.vo.TourGoodOrderFindVo; import com.xxfc.platform.tour.vo.TourGoodOrderFindVo;
...@@ -17,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.Instant; import java.time.Instant;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -89,26 +92,42 @@ public class OrderTourVerificationBiz{ ...@@ -89,26 +92,42 @@ public class OrderTourVerificationBiz{
} }
// 出发时间 是否已经发车 // 出发时间 是否已经发车
Long departureTime = tourFeign.selectDepartureTimeByStartCompanyIdAndRouteId(tourDetail.getStartCompanyId(),tourDetail.getGoodId()); Date departureDate = tourFeign.selectDepartureDataBySpeId(tourDetail.getSpePriceId());
if (Instant.now().toEpochMilli()<departureTime){ 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); 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){ if (departureStatus==1){
return ObjectRestResponse.createFailedResultWithObj(400,"已经发车",1); return ObjectRestResponse.createFailedResultWithObj(400,"已经发车",1);
} }
baseOrder=new BaseOrder(); baseOrder=new BaseOrder();
baseOrder.setId(orderId); baseOrder.setId(orderId);
baseOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode()); baseOrder.setStatus(OrderStatusEnum.ORDER_FINISH.getCode());
baseOrder.setVersion(version); baseOrder.setVersion(version);
baseOrderBiz.updateSelectiveById(baseOrder); baseOrder = baseOrderBiz.updateSelectiveByIdReT(baseOrder);
tourDetail.setVerificationUser(userDTO.getId()); tourDetail.setVerificationUser(userDTO.getId());
tourDetail.setVerificationName(userDTO.getName()); tourDetail.setVerificationName(userDTO.getName());
tourDetail.setVerificationTime(System.currentTimeMillis()); tourDetail.setVerificationTime(System.currentTimeMillis());
tourDetailBiz.updateSelectiveById(tourDetail); tourDetail = tourDetailBiz.updateSelectiveByIdReT(tourDetail);
tourFeign.updateTourGoodPersonNum(verificationId,"verification_person",total_number); tourFeign.updateTourGoodPersonNum(verificationId,"verification_person",total_number);
return ObjectRestResponse.succ(); baseOrderBiz.sendOrderMq(null,tourDetail,null, baseOrder, OrderMQDTO.ORDER_FINISH);
return ObjectRestResponse.succ();
} }
//确定上车 //确定上车
......
...@@ -9,6 +9,7 @@ import com.xxfc.platform.order.entity.OrderRentVehicleDetail; ...@@ -9,6 +9,7 @@ import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderUserLicense; import com.xxfc.platform.order.entity.OrderUserLicense;
import com.xxfc.platform.order.entity.OrderVehicleCrosstown; import com.xxfc.platform.order.entity.OrderVehicleCrosstown;
import com.xxfc.platform.order.mapper.OrderVehicaleCrosstownMapper; 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.order.pojo.order.OrderVehicleCrosstownDto;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.Vehicle; import com.xxfc.platform.vehicle.entity.Vehicle;
...@@ -60,14 +61,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -60,14 +61,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
if (oldValue .size() == 1) { if (oldValue .size() == 1) {
//已有直接返回 //已有直接返回
//交车完成 设置订单状态为出行中 //交车完成 设置订单状态为出行中
if(baseOrder.getStatus() == 4) {// handleOrderStatus(baseOrder, orderRentVehicleDetail);
//判断交车时间是否是今天
baseOrder.setStatus(5);
baseOrderBiz.updateSelectiveById(baseOrder);
} else if(baseOrder.getStatus() == 5) {
baseOrder.setStatus(6);
baseOrderBiz.updateSelectiveById(baseOrder);
}
OrderVehicleCrosstownDto vehicleCrosstownDto = new OrderVehicleCrosstownDto(); OrderVehicleCrosstownDto vehicleCrosstownDto = new OrderVehicleCrosstownDto();
BeanUtil.copyProperties(oldValue.get(0), vehicleCrosstownDto, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(oldValue.get(0), vehicleCrosstownDto, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
List<OrderUserLicense> orderUserLicenses = orderUserLicenseBiz.selectByIds(oldValue.get(0).getUserLicenseId()).getData(); List<OrderUserLicense> orderUserLicenses = orderUserLicenseBiz.selectByIds(oldValue.get(0).getUserLicenseId()).getData();
...@@ -85,15 +79,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -85,15 +79,7 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
} else if(oldValue .size() <= 0) { } else if(oldValue .size() <= 0) {
getOrderLicense(orderVehicleCrosstownDto); getOrderLicense(orderVehicleCrosstownDto);
orderVehicalCrosstownBiz.insertSelective(orderVehicleCrosstownDto); orderVehicalCrosstownBiz.insertSelective(orderVehicleCrosstownDto);
//交车完成 设置订单状态为出行中 handleOrderStatus(baseOrder, orderRentVehicleDetail);
if(baseOrder.getStatus() == 4) {
//判断是否是今日交车
baseOrder.setStatus(5);
baseOrderBiz.updateSelectiveById(baseOrder);
} else if(baseOrder.getStatus() == 5) {
baseOrder.setStatus(6);
baseOrderBiz.updateSelectiveById(baseOrder);
}
RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId()); RestResponse<Vehicle> restResponse = vehicleFeign.findById(orderRentVehicleDetail.getVehicleId());
if(restResponse.getData() != null) { if(restResponse.getData() != null) {
orderVehicleCrosstownDto.setVehicleNumberPlat(restResponse.getData().getNumberPlate()); orderVehicleCrosstownDto.setVehicleNumberPlat(restResponse.getData().getNumberPlate());
...@@ -103,6 +89,19 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp ...@@ -103,6 +89,19 @@ public class OrderVehicalCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return ObjectRestResponse.createDefaultFail(); 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) { public void getOrderLicense(OrderVehicleCrosstownDto orderVehicleCrosstownDto) {
OrderUserLicense orderUserLicense = new OrderUserLicense(); OrderUserLicense orderUserLicense = new OrderUserLicense();
orderUserLicense.setLicenseIdCard(orderVehicleCrosstownDto.getLicenseIdCard()); orderUserLicense.setLicenseIdCard(orderVehicleCrosstownDto.getLicenseIdCard());
......
...@@ -161,16 +161,14 @@ public class BaseOrderController extends CommonBaseController implements UserRes ...@@ -161,16 +161,14 @@ public class BaseOrderController extends CommonBaseController implements UserRes
List<Integer> userIds = list.stream().map(OrderListVo::getUserId).distinct().collect(Collectors.toList()); List<Integer> userIds = list.stream().map(OrderListVo::getUserId).distinct().collect(Collectors.toList());
if(userIds != null && userIds.size() >0) { if(userIds != null && userIds.size() >0) {
ObjectRestResponse<List<AppUserVo>> objectRestResponse = userFeign.getByUserIds(userIds); ObjectRestResponse<List<AppUserVo>> objectRestResponse = userFeign.getByUserIds(userIds);
log.info("获取用户信息:objectRestResponse = {}", objectRestResponse.getMessage());
for (OrderListVo orderPageVO : list) { for (OrderListVo orderPageVO : list) {
if (objectRestResponse.getData() != null && objectRestResponse.getData().size() > 0) { if (objectRestResponse.getData() != null && objectRestResponse.getData().size() > 0) {
for (AppUserVo appUserVo : objectRestResponse.getData()) { for (AppUserVo appUserVo : objectRestResponse.getData()) {
if (appUserVo != null && appUserVo.getUserid() == orderPageVO.getUserId()) { if (appUserVo != null) {
orderPageVO.setTelephone(appUserVo.getUsername());
orderPageVO.setUsername(appUserVo.getNickname()); 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 ...@@ -43,7 +43,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
@RequestMapping(value = "/price/calculate/{type}/{no}", method = RequestMethod.GET) @RequestMapping(value = "/price/calculate/{type}/{no}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@IgnoreClientToken @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(); checkAppUser();
//根据no 查订单 //根据no 查订单
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{ OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
...@@ -59,22 +59,22 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe ...@@ -59,22 +59,22 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
switch (orderTypeEnum) { switch (orderTypeEnum) {
case RENT_VEHICLE: 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() // , System.currentTimeMillis() - orderPageVO.getOrderRentVehicleDetail().getStartTime()
// , DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND // , DictionaryKey.APP_ORDER+ "_"+ DictionaryKey.RENT_REFUND
// , "取消订单退款:")); // , "取消订单退款:"));
break; 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: default:
// orp.setRefundAmount(orderPageVO); // orp.setRefundAmount(orderPageVO);
break; break;
......
...@@ -124,8 +124,6 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -124,8 +124,6 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
@Override @Override
public void handleDetail(RentVehicleBO bo) { public void handleDetail(RentVehicleBO bo) {
//获取可用车辆
acquireVehicle(bo);
//设置订单状态为3 //设置订单状态为3
bo.getOrder().setStatus(OrderStatusEnum.ORDER_UNPAY.getCode()); bo.getOrder().setStatus(OrderStatusEnum.ORDER_UNPAY.getCode());
//设置订单图片 //设置订单图片
...@@ -146,6 +144,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -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); activityFeign.use(bo.getAppUserDTO().getUserid(), bo.getTickerNo().get(0), bo.getOrder().getNo(), channel, bo.getOrder().getGoodsAmount(), ActivityFeign.TYPE_USE);
} }
//获取可用车辆
acquireVehicle(bo);
super.handleDetail(bo); super.handleDetail(bo);
//发送定时取消订单(数据字典设置--5分钟) //发送定时取消订单(数据字典设置--5分钟)
...@@ -245,6 +246,9 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -245,6 +246,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));
}
} }
//总价格(包含押金) //总价格(包含押金)
...@@ -331,8 +335,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl ...@@ -331,8 +335,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
RentVehicleBookDTO rentVehicleBookDTO = BeanUtil.toBean(detail.getBookVehicleVO(), RentVehicleBookDTO.class); RentVehicleBookDTO rentVehicleBookDTO = BeanUtil.toBean(detail.getBookVehicleVO(), RentVehicleBookDTO.class);
rentVehicleBookDTO.setModelId(detail.getModelId()); rentVehicleBookDTO.setModelId(detail.getModelId());
rentVehicleBookDTO.setUserName(BaseContextHandler.getName()); rentVehicleBookDTO.setUserName(BaseContextHandler.getName());
rentVehicleBookDTO.setLiftCompany(detail.getStartCompanyId());
rentVehicleBookDTO.setLiftAddr(detail.getStartAddr());
ObjectRestResponse<VehicleBookRecord> orr = vehicleFeign.rentApplyVehicle(rentVehicleBookDTO); 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()); throw new BaseException(orr.getMessage(), orr.getStatus());
} }
detail.setVehicleId(orr.getData().getVehicleId()); detail.setVehicleId(orr.getData().getVehicleId());
......
...@@ -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));
}
} }
//总价格 //总价格
......
...@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -100,4 +101,7 @@ public interface TourFeign { ...@@ -100,4 +101,7 @@ public interface TourFeign {
@GetMapping("/tourGood/verfication/departure_status") @GetMapping("/tourGood/verfication/departure_status")
Integer selectDepartureStatusByVerificationId(@RequestParam(value = "verificationId") Integer verificationId); Integer selectDepartureStatusByVerificationId(@RequestParam(value = "verificationId") Integer verificationId);
@GetMapping("/spe/departure_date")
Date selectDepartureDataBySpeId(@RequestParam(value = "speIds") Integer speIds);
} }
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
</dependencies> </dependencies>
<build> <build>
<finalName>xx-tour</finalName>
<plugins> <plugins>
<!-- 此插件用来生成通用mapper的代码 --> <!-- 此插件用来生成通用mapper的代码 -->
<plugin> <plugin>
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.tour.dto.TourSpePriceDTO; 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.entity.TourGoodSpePrice;
import com.xxfc.platform.tour.mapper.TourGoodSpePriceMapper; import com.xxfc.platform.tour.mapper.TourGoodSpePriceMapper;
import com.xxfc.platform.tour.vo.TourSpePriceVo; import com.xxfc.platform.tour.vo.TourSpePriceVo;
...@@ -15,6 +16,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -15,6 +16,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -101,4 +103,10 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP ...@@ -101,4 +103,10 @@ public class TourGoodSpeBiz extends BaseBiz<TourGoodSpePriceMapper, TourGoodSpeP
public void delGoodSpe(Integer goodId, List<Integer> ids){ mapper.delSpe(goodId,ids);} 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; ...@@ -8,6 +8,8 @@ import com.xxfc.platform.tour.dto.TourSpePriceDTO;
import com.xxfc.platform.tour.vo.TourSpePriceVo; import com.xxfc.platform.tour.vo.TourSpePriceVo;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController @RestController
@RequestMapping("spe") @RequestMapping("spe")
@IgnoreClientToken @IgnoreClientToken
...@@ -32,4 +34,8 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> { ...@@ -32,4 +34,8 @@ public class TourGoodSpeController extends TourBaseController<TourGoodSpeBiz> {
return baseBiz.cutStock(speId,number,type); 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 { ...@@ -14,7 +14,7 @@ public class CCPRestSmsUtils {
restAPI.init("app.cloopen.com", "8883"); restAPI.init("app.cloopen.com", "8883");
restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559", restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559",
"3fe5e2f053674f23b029a9a9fc9503f0"); "3fe5e2f053674f23b029a9a9fc9503f0");
restAPI.setAppId("8a216da86812593601684bec10581ab5"); restAPI.setAppId("8a216da86bfdbeb5016c0d2543670a06");
} }
public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) { public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) {
......
...@@ -13,8 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -13,8 +13,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication(scanBasePackages = { @SpringBootApplication(scanBasePackages = {
"com.xxfc.platform", "com.xxfc.platform",
"com.github.wxiaoqi.security.common.handler", "com.github.wxiaoqi.security.common.handler"
"com.github.wxiaoqi.security.common.log"
}) })
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableAceAuthClient @EnableAceAuthClient
......
...@@ -10,21 +10,21 @@ import org.springframework.stereotype.Service; ...@@ -10,21 +10,21 @@ import org.springframework.stereotype.Service;
public class CCPRestSmsBiz{ public class CCPRestSmsBiz{
//租车订单通知(普通用户)1 //租车订单通知(普通用户)1
public static final String TEMPLATE_ID_ORDER = "457270"; public static final String TEMPLATE_ID_ORDER = "458626";
//租车订单短信(会员权益)2 //租车订单短信(会员权益)2
public static final String TEMPLATE_ID_ORDER_MEMBER = "457271"; public static final String TEMPLATE_ID_ORDER_MEMBER = "458625";
//旅游订单短信3 //旅游订单短信3
public static final String TEMPLATE_ID_ORDER_TOUR = "457272"; public static final String TEMPLATE_ID_ORDER_TOUR = "458624";
//加入会员通知4 //加入会员通知4
public static final String TEMPLATE_ID_MEMBER = "457273"; public static final String TEMPLATE_ID_MEMBER = "458623";
//租/还车公司相同(订单支付后立即发送给相关负责人)5 //租/还车公司相同(订单支付后立即发送给相关负责人)5
public static final String TEMPLATE_ID_TAAKE_CAR = "457501"; public static final String TEMPLATE_ID_TAAKE_CAR = "458622";
//租/还车公司不同(发给租车公司负责人,订单支付后发送)6 //租/还车公司不同(发给租车公司负责人,订单支付后发送)6
public static final String TEMPLATE_ID_DIFFERENT_TAAKE_CAR = "457502"; public static final String TEMPLATE_ID_DIFFERENT_TAAKE_CAR = "458621";
// 租/还车公司不同(发给还车公司负责人,订单出车后发))(相同不发)7 // 租/还车公司不同(发给还车公司负责人,订单出车后发))(相同不发)7
public static final String TEMPLATE_ID_ALSO_CAR = "457503"; public static final String TEMPLATE_ID_ALSO_CAR = "458620";
//取消订单8 //取消订单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> { ...@@ -77,6 +77,7 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper,OrderRefund> {
log.error("-----参数为空-----------"); log.error("-----参数为空-----------");
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空"); return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
} }
log.error("-----payAmoun======="+payAmount+"------refundAmount======"+refundAmount);
Example example =new Example(OrderPay.class); Example example =new Example(OrderPay.class);
example.createCriteria().andEqualTo("orderNo", order_no).andEqualTo("isDel",0).andEqualTo("status",1); example.createCriteria().andEqualTo("orderNo", order_no).andEqualTo("isDel",0).andEqualTo("status",1);
List<OrderPay> list=payBiz.selectByExample(example); List<OrderPay> list=payBiz.selectByExample(example);
......
...@@ -82,16 +82,15 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> { ...@@ -82,16 +82,15 @@ public class OrderPayController extends BaseController<OrderPayBiz,OrderPay> {
} }
@PostMapping(value = "/app/notify/alipay") @PostMapping(value = "/app/unauth/notify/alipay")
@IgnoreUserToken @IgnoreUserToken
public String alipayNotify(){ public String alipayNotify(){
return baseBiz.alipayNotify(); return baseBiz.alipayNotify();
} }
@GetMapping(value = "/app/generate_payment") @GetMapping(value = "/app/generate_payment")
public Object generatePayment(@RequestParam("orderCode") String orderCode, @RequestParam("description") String description, public Object generatePayment(OrderPayVo orderPayVo) {
@RequestParam("payType") String payType, @RequestParam("amount") Integer amount) { Object resp = baseBiz.generatePayment(orderPayVo);
Object resp = baseBiz.generatePayment(orderCode, description, payType, amount);
return resp; return resp;
} }
......
...@@ -15,6 +15,8 @@ import com.aliyuncs.profile.IClientProfile; ...@@ -15,6 +15,8 @@ import com.aliyuncs.profile.IClientProfile;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.github.wxiaoqi.security.common.util.RandomUtil; import com.github.wxiaoqi.security.common.util.RandomUtil;
...@@ -155,6 +157,62 @@ public class SmsService { ...@@ -155,6 +157,62 @@ public class SmsService {
return false; 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 { /* public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {
...@@ -188,14 +246,19 @@ public class SmsService { ...@@ -188,14 +246,19 @@ public class SmsService {
} }
*/ */
public static void main(String[] args) throws ClientException, InterruptedException { 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("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode()); System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage()); System.out.println("Message=" + response.getMessage());
System.out.println("RequestId=" + response.getRequestId()); System.out.println("RequestId=" + response.getRequestId());
System.out.println("BizId=" + response.getBizId());*/ System.out.println("BizId=" + response.getBizId());*//*
Thread.sleep(3000L); Thread.sleep(3000L);
/* /*
......
...@@ -53,7 +53,7 @@ public class UploadService { ...@@ -53,7 +53,7 @@ public class UploadService {
String filePath = baseUploadPath + realFileRelPath; String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置 //将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath)); FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
realFileRelPath= SystemConfig.XXMP_URL+realFileRelPath; realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath; return realFileRelPath;
} }
...@@ -83,7 +83,7 @@ public class UploadService { ...@@ -83,7 +83,7 @@ public class UploadService {
realFileRelPath=filePath + "/" + no + ".jpg"; realFileRelPath=filePath + "/" + no + ".jpg";
//将文件写入指定位置 //将文件写入指定位置
ImgBase64Util.generateImage(imgFile,realFileRelPath); ImgBase64Util.generateImage(imgFile,realFileRelPath);
realFileRelPath= SystemConfig.XXMP_URL+realFileRelPath; realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath; return realFileRelPath;
} }
......
...@@ -78,4 +78,12 @@ public class BranchCompanyVo { ...@@ -78,4 +78,12 @@ public class BranchCompanyVo {
*/ */
private Integer zoneId; private Integer zoneId;
/**
* 租车客服电话
*/
private String vehiceServicePhone;
/**
* 旅游客服电话
*/
private String tourServicePhone;
} }
\ No newline at end of file
...@@ -27,4 +27,7 @@ public class VehiclePlanDto extends PageParam { ...@@ -27,4 +27,7 @@ public class VehiclePlanDto extends PageParam {
@ApiModelProperty(value = "停车分公司Id") @ApiModelProperty(value = "停车分公司Id")
private Integer parkBranchCompanyId; private Integer parkBranchCompanyId;
@ApiModelProperty(value = "所属分公司大区")
private Integer zoneId;
} }
package com.xxfc.platform.vehicle.rest; package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.ace.cache.annotation.Cache;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
...@@ -24,11 +23,13 @@ import com.xxfc.platform.vehicle.common.CustomIllegalParamException; ...@@ -24,11 +23,13 @@ import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; 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.*;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto; import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -39,12 +40,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,12 +40,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import java.util.*; import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.HashSet;
import java.util.stream.Collectors; 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;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
...@@ -417,9 +417,10 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -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 = "获取排车信息") @ApiOperation(value = "获取排车信息")
@IgnoreClientToken @IgnoreClientToken
@IgnoreUserToken
public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) { public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) {
//获取统计信息 //获取统计信息
List<VehicleCountVo> vehicleCountVos = baseBiz.countVehicleByParam(vehiclePlanDto); List<VehicleCountVo> vehicleCountVos = baseBiz.countVehicleByParam(vehiclePlanDto);
......
...@@ -9,13 +9,16 @@ ...@@ -9,13 +9,16 @@
<result column="name" property="name" jdbcType="VARCHAR" /> <result column="name" property="name" jdbcType="VARCHAR" />
<result column="branch_type" property="branchType" jdbcType="INTEGER" /> <result column="branch_type" property="branchType" jdbcType="INTEGER" />
<result column="subordinate_branch" property="subordinateBranch" 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_province" property="addrProvince" jdbcType="INTEGER" />
<result column="addr_city" property="addrCity" jdbcType="INTEGER" /> <result column="addr_city" property="addrCity" jdbcType="INTEGER" />
<result column="addr_town" property="addrTown" jdbcType="INTEGER" /> <result column="addr_town" property="addrTown" jdbcType="INTEGER" />
<result column="addr_detail" property="addrDetail" jdbcType="VARCHAR" /> <result column="addr_detail" property="addrDetail" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" 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> </resultMap>
<select id="search" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO"> <select id="search" resultType="com.xxfc.platform.vehicle.pojo.CompanySearchVO">
......
...@@ -425,6 +425,8 @@ ...@@ -425,6 +425,8 @@
<select id="getAllVehicle" parameterType="java.util.Map" resultMap="searchModel"> <select id="getAllVehicle" parameterType="java.util.Map" resultMap="searchModel">
select * select *
from vehicle v1 from vehicle v1
-- 所属分公司
LEFT JOIN branch_company bc2 ON v1.subordinate_branch = bc2.id
<where> <where>
<if test="startTime != null"> <if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime} and v1.create_time between #{startTime} and #{endTime}
...@@ -441,36 +443,46 @@ ...@@ -441,36 +443,46 @@
<if test="parkBranchCompanyId != null"> <if test="parkBranchCompanyId != null">
and v1.park_branch_company_id = #{parkBranchCompanyId} and v1.park_branch_company_id = #{parkBranchCompanyId}
</if> </if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if>
</where> </where>
</select> </select>
<select id="countVehicleByParam" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto" <select id="countVehicleByParam" parameterType="com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto"
resultType="com.xxfc.platform.vehicle.pojo.VehicleCountVo"> resultType="com.xxfc.platform.vehicle.pojo.VehicleCountVo">
SELECT count(*) total , SELECT count(*) total ,
CASE CASE
WHEN travel_status = 1 THEN WHEN v1.status = 1 THEN
'1' '1'
WHEN travel_status = 2 THEN WHEN v1.status = 2 THEN
'2' '2'
WHEN travel_status = 3 THEN WHEN v1.status = 3 THEN
'3' '3'
WHEN travel_status = 4 THEN WHEN v1.status = 4 THEN
'4' '4'
WHEN v1.status = 5 THEN
'5'
ELSE ELSE
'-1' '6'
END travel_status, END travel_status,
CASE CASE
WHEN travel_status = 1 THEN WHEN v1.status = 1 THEN
'出行中' '正常运行'
WHEN travel_status = 2 THEN WHEN v1.status = 2 THEN
'预约中' '维修'
WHEN travel_status = 3 THEN WHEN v1.status = 3 THEN
'空闲中' '报废'
WHEN travel_status = 4 THEN WHEN v1.status = 4 THEN
'保养中' '出车'
WHEN v1.status = 5 THEN
'保养'
ELSE ELSE
'不可用' '不可用'
END detail END detail
from vehicle v1 from vehicle v1
-- 所属分公司
LEFT JOIN branch_company bc1 ON v1.subordinate_branch = bc1.id
<where> <where>
<if test="startTime != null"> <if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime} and v1.create_time between #{startTime} and #{endTime}
...@@ -487,10 +499,15 @@ ...@@ -487,10 +499,15 @@
<if test="parkBranchCompanyId != null"> <if test="parkBranchCompanyId != null">
and v1.park_branch_company_id = #{parkBranchCompanyId} and v1.park_branch_company_id = #{parkBranchCompanyId}
</if> </if>
<if test="zoneId !=null">
and bc1.zone_id = #{zoneId}
</if>
</where> </where>
GROUP BY travel_status GROUP BY v1.status
union all union all
SELECT count(*) total, '0' travel_status, '总数' detail from vehicle v2 SELECT count(*) total, '0' travel_status, '总数' detail from vehicle v2
-- 所属分公司
LEFT JOIN branch_company bc2 ON v2.subordinate_branch = bc2.id
<where> <where>
<if test="startTime != null"> <if test="startTime != null">
and v2.create_time between #{startTime} and #{endTime} and v2.create_time between #{startTime} and #{endTime}
...@@ -507,44 +524,10 @@ ...@@ -507,44 +524,10 @@
<if test="parkBranchCompanyId != null"> <if test="parkBranchCompanyId != null">
and v2.park_branch_company_id = #{parkBranchCompanyId} and v2.park_branch_company_id = #{parkBranchCompanyId}
</if> </if>
</where> <if test="zoneId !=null">
union all and bc2.zone_id = #{zoneId}
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> </if>
</where> </where>
GROUP BY status
</select> </select>
<!-- 查询可用车辆/车型 的公用 from 和 where 部分条件 --> <!-- 查询可用车辆/车型 的公用 from 和 where 部分条件 -->
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
select w.* select w.*
from vehicle_warning_msg w from vehicle_warning_msg w
left join vehicle v on w.vehicle_id = v.id left join vehicle v on w.vehicle_id = v.id
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
<where> <where>
<if test="vehicleId != null"> <if test="vehicleId != null">
and w.vehicle_id = #{vehicleId} and w.vehicle_id = #{vehicleId}
...@@ -48,6 +49,9 @@ ...@@ -48,6 +49,9 @@
<if test="parkBranchCompanyId != null"> <if test="parkBranchCompanyId != null">
and v.park_branch_company_id = #{parkBranchCompanyId} and v.park_branch_company_id = #{parkBranchCompanyId}
</if> </if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if>
</where> </where>
</select> </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