|
|
@ -20,12 +20,15 @@ import enums.MembershipEnums;
|
|
|
|
import enums.PointEnums;
|
|
|
|
import enums.PointEnums;
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.IdWorker;
|
|
|
|
import util.JwtUtil;
|
|
|
|
import util.JwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Objects;
|
|
|
@ -61,6 +64,8 @@ public class MemberShipService {
|
|
|
|
|
|
|
|
|
|
|
|
private final UserPointLogService userPointLogService;
|
|
|
|
private final UserPointLogService userPointLogService;
|
|
|
|
private final UserInfoService userInfoService;
|
|
|
|
private final UserInfoService userInfoService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
public MemberShipService(VipSkuDao vipSkuDao, WxPayConfig wxPayConfig, IdWorker idWorker, WxPayPublicKeyConfig wxPayPublicKeyConfig, MembershipOrderDao membershipOrderDao, JwtUtil jwtUtil, JPAQueryFactory jpaQueryFactory, UserInfoDao userInfoDao, UserPointLogService userPointLogService, UserInfoService userInfoService) {
|
|
|
|
public MemberShipService(VipSkuDao vipSkuDao, WxPayConfig wxPayConfig, IdWorker idWorker, WxPayPublicKeyConfig wxPayPublicKeyConfig, MembershipOrderDao membershipOrderDao, JwtUtil jwtUtil, JPAQueryFactory jpaQueryFactory, UserInfoDao userInfoDao, UserPointLogService userPointLogService, UserInfoService userInfoService) {
|
|
|
|
this.vipSkuDao = vipSkuDao;
|
|
|
|
this.vipSkuDao = vipSkuDao;
|
|
|
@ -123,7 +128,8 @@ public class MemberShipService {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
membershipOrder.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
membershipOrder.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
membershipOrderDao.save(membershipOrder);
|
|
|
|
membershipOrderDao.save(membershipOrder);
|
|
|
|
|
|
|
|
// 发消息创建商城订单,payType 微信支付
|
|
|
|
|
|
|
|
createMallOrder(membershipOrder,2,0);
|
|
|
|
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
|
|
|
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
|
|
|
Amount amount = new Amount();
|
|
|
|
Amount amount = new Amount();
|
|
|
|
amount.setTotal(one.getAmount());
|
|
|
|
amount.setTotal(one.getAmount());
|
|
|
@ -147,6 +153,57 @@ public class MemberShipService {
|
|
|
|
return map;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建订单
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param membershipOrder 会员订单开通对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void createMallOrder(MembershipOrder membershipOrder,Integer payType,Integer status) {
|
|
|
|
|
|
|
|
// 只有待上架允许上架
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mallMqMap = new HashMap<>();
|
|
|
|
|
|
|
|
mallMqMap.put("skuId", membershipOrder.getSkuId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// userid
|
|
|
|
|
|
|
|
mallMqMap.put("userId", membershipOrder.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// username
|
|
|
|
|
|
|
|
UserInfo userInfo = userInfoDao.findById(membershipOrder.getUserId()).get();
|
|
|
|
|
|
|
|
mallMqMap.put("nickName", userInfo.getNickName());
|
|
|
|
|
|
|
|
// List<UserinfoShippingAddress> byUserIdAndAcquiesce = userinfoShippingAddressDao.findByUserIdAndAcquiesce(lotteryUser.getUserId(), 1);
|
|
|
|
|
|
|
|
mallMqMap.put("receiverProvince","");
|
|
|
|
|
|
|
|
mallMqMap.put("receiverCity","");
|
|
|
|
|
|
|
|
mallMqMap.put("receiverRegion","");
|
|
|
|
|
|
|
|
mallMqMap.put("receiverDetailAddress","");
|
|
|
|
|
|
|
|
mallMqMap.put("receiverName",membershipOrder.getNickName());
|
|
|
|
|
|
|
|
mallMqMap.put("receiverPhone",userInfo.getMobile());
|
|
|
|
|
|
|
|
mallMqMap.put("orderCode",membershipOrder.getOrderCode());
|
|
|
|
|
|
|
|
// 支付方式:0->未支付;1->支付宝;2->微信;3->积分 4->苹果支付
|
|
|
|
|
|
|
|
mallMqMap.put("payType",payType);
|
|
|
|
|
|
|
|
//订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单
|
|
|
|
|
|
|
|
mallMqMap.put("status",status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 地址
|
|
|
|
|
|
|
|
// if (null != byUserIdAndAcquiesce) {
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverProvince",regionDao.findById(byUserIdAndAcquiesce.get(0).getProvinceId()).get().getName());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverCity",regionDao.findById(byUserIdAndAcquiesce.get(0).getCityId()).get().getName());
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverRegion",regionDao.findById(byUserIdAndAcquiesce.get(0).getDistrictId()).get().getName());
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverDetailAddress",byUserIdAndAcquiesce.get(0).getAddress());
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverName",byUserIdAndAcquiesce.get(0).getConsignee());
|
|
|
|
|
|
|
|
// mallMqMap.put("receiverPhone",byUserIdAndAcquiesce.get(0).getPhone());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
rabbitTemplate.convertAndSend("luoo_mall_vipsku_order_add", mallMqMap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateMallOrder(MembershipOrder membershipOrder) {
|
|
|
|
|
|
|
|
Map<String, Object> mallMqMap = new HashMap<>();
|
|
|
|
|
|
|
|
mallMqMap.put("orderCode", membershipOrder.getOrderCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rabbitTemplate.convertAndSend("luoo_mall_vipsku_order_update", mallMqMap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void updateOrderStatus(Transaction transaction) {
|
|
|
|
public void updateOrderStatus(Transaction transaction) {
|
|
|
|
String outTradeNo = transaction.getOutTradeNo();
|
|
|
|
String outTradeNo = transaction.getOutTradeNo();
|
|
|
@ -164,6 +221,8 @@ public class MemberShipService {
|
|
|
|
one.setStatus(MembershipEnums.PAY_FAIL.getCode());
|
|
|
|
one.setStatus(MembershipEnums.PAY_FAIL.getCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
membershipOrderDao.save(one);
|
|
|
|
membershipOrderDao.save(one);
|
|
|
|
|
|
|
|
updateMallOrder(one);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -244,6 +303,8 @@ public class MemberShipService {
|
|
|
|
dealUserVipCalc(membershipOrder);
|
|
|
|
dealUserVipCalc(membershipOrder);
|
|
|
|
|
|
|
|
|
|
|
|
membershipOrderDao.save(membershipOrder);
|
|
|
|
membershipOrderDao.save(membershipOrder);
|
|
|
|
|
|
|
|
// 发消息创建商城订单,payType 4苹果支付
|
|
|
|
|
|
|
|
createMallOrder(membershipOrder,4,3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|