release-会员购买订单和商城联动

release-2024-04-25
wangqing 4 days ago
parent edba9a3354
commit e42acd3c8e

@ -20,12 +20,15 @@ import enums.MembershipEnums;
import enums.PointEnums;
import enums.UserVipStatusEnum;
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.transaction.annotation.Transactional;
import util.IdWorker;
import util.JwtUtil;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -61,6 +64,8 @@ public class MemberShipService {
private final UserPointLogService userPointLogService;
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) {
this.vipSkuDao = vipSkuDao;
@ -123,7 +128,8 @@ public class MemberShipService {
.build();
membershipOrder.setId(String.valueOf(idWorker.nextId()));
membershipOrderDao.save(membershipOrder);
// 发消息创建商城订单,payType 微信支付
createMallOrder(membershipOrder,2,0);
// 调用request.setXxx(val)设置所需参数具体参数可见Request定义
Amount amount = new Amount();
amount.setTotal(one.getAmount());
@ -147,6 +153,57 @@ public class MemberShipService {
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)
public void updateOrderStatus(Transaction transaction) {
String outTradeNo = transaction.getOutTradeNo();
@ -164,6 +221,8 @@ public class MemberShipService {
one.setStatus(MembershipEnums.PAY_FAIL.getCode());
}
membershipOrderDao.save(one);
updateMallOrder(one);
}
/**
@ -244,6 +303,8 @@ public class MemberShipService {
dealUserVipCalc(membershipOrder);
membershipOrderDao.save(membershipOrder);
// 发消息创建商城订单,payType 4苹果支付
createMallOrder(membershipOrder,4,3);
}

@ -44,15 +44,15 @@ wx:
mchSerialNo: 541E42E46254E026DE1E1D13602865CE049866C2
# mchSerialNo: 6A7BA1555FC56FBFAB2086527E88AA7FCA4A566F
apiV3Key: Indiecn2024181189288661529541569
notifyUrl: https://beta.indie.cn/user/wx/pay/payNotify
# privateKeyPath: /home/wxcert/apiclient_key.pem
privateKeyPath: D:\apiclient_key.pem
# privateCertPath: /home/wxcert/apiclient_cert.pem
privateCertPath: D:\apiclient_cert.pem
# platformCertPath: /home/wxcert/apiclient_cert.pem
platformCertPath: D:\apiclient_cert.pem
# publicKeyPath: /home/wxcert/pub_key.pem
publicKeyPath: D:\pub_key.pem
notifyUrl: https://beta.indie.cn/user/wechat/payNotify
privateKeyPath: /home/wxcert/apiclient_key.pem
# privateKeyPath: D:\apiclient_key.pem
privateCertPath: /home/wxcert/apiclient_cert.pem
# privateCertPath: D:\apiclient_cert.pem
platformCertPath: /home/wxcert/apiclient_cert.pem
# platformCertPath: D:\apiclient_cert.pem
publicKeyPath: /home/wxcert/pub_key.pem
# publicKeyPath: D:\pub_key.pem
publicKeyId: PUB_KEY_ID_0116763892292024111200648800000198
applePay:
certificate: https://sandbox.itunes.apple.com/verifyReceipt

Loading…
Cancel
Save