团购相关
This commit is contained in:
		| @ -65,12 +65,6 @@ public class ClientOrderController { | |||||||
|         return Result.ok(orderService.depositFreePayRentCarOrder(rentCarOrderReq)); |         return Result.ok(orderService.depositFreePayRentCarOrder(rentCarOrderReq)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @ApiOperation(value = "第三方订单") |  | ||||||
|     @PostMapping("/thirdPlatformRentCarOrder") |  | ||||||
|     public Result<RentCarOrderResultDTO> thirdPlatformRentCarOrder(@Valid @RequestBody RentCarThirdPlatformOrderReq rentCarOrderReq){ |  | ||||||
|         return Result.ok(orderService.thirdPlatformRentCarOrder(rentCarOrderReq)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @ApiOperation(value = "续租车") |     @ApiOperation(value = "续租车") | ||||||
|     @PostMapping("/reRentalCarOrder") |     @PostMapping("/reRentalCarOrder") | ||||||
|     public Result<RentCarOrderResultDTO> reRentalCarOrder(@Valid @RequestBody ReRentCarReq rentCarOrderReq){ |     public Result<RentCarOrderResultDTO> reRentalCarOrder(@Valid @RequestBody ReRentCarReq rentCarOrderReq){ | ||||||
|  | |||||||
| @ -2,10 +2,7 @@ package com.sczx.order.controller; | |||||||
|  |  | ||||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
| import com.sczx.order.common.Result; | import com.sczx.order.common.Result; | ||||||
| import com.sczx.order.dto.VerifyGroupBuyCouponsReq; | import com.sczx.order.dto.*; | ||||||
| import com.sczx.order.dto.OrderDetailDTO; |  | ||||||
| import com.sczx.order.dto.OrderDistribDTO; |  | ||||||
| import com.sczx.order.dto.OrderDistribQueryReq; |  | ||||||
| import com.sczx.order.service.OrderDistribService; | import com.sczx.order.service.OrderDistribService; | ||||||
| import com.sczx.order.service.OrderService; | import com.sczx.order.service.OrderService; | ||||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||||
| @ -55,7 +52,7 @@ public class PubOrderController { | |||||||
|  |  | ||||||
|     @ApiOperation(value = "团购券核销") |     @ApiOperation(value = "团购券核销") | ||||||
|     @PostMapping("/verifyGroupBuyCoupons") |     @PostMapping("/verifyGroupBuyCoupons") | ||||||
|     public Result<OrderDetailDTO> verifyGroupBuyCoupons(@Valid @RequestBody VerifyGroupBuyCouponsReq req){ |     public Result<RentCarOrderResultDTO> verifyGroupBuyCoupons(@Valid @RequestBody VerifyGroupBuyCouponsReq req){ | ||||||
|         return Result.ok(orderService.verifyGroupBuyCoupons( req)); |         return Result.ok(orderService.verifyGroupBuyCoupons( req)); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -38,6 +38,9 @@ public class RentCarThirdPlatformOrderReq { | |||||||
|     @ApiModelProperty(value = "第三方订单号") |     @ApiModelProperty(value = "第三方订单号") | ||||||
|     private String thirdOrderNo; |     private String thirdOrderNo; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "第三方团购码") | ||||||
|  |     private String couponCode; | ||||||
|  |  | ||||||
|     @ApiModelProperty(value = "订单来源") |     @ApiModelProperty(value = "订单来源") | ||||||
|     private String orderSource; |     private String orderSource; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| package com.sczx.order.service; | package com.sczx.order.service; | ||||||
|  |  | ||||||
| import com.sczx.order.dto.GroupBuyOrderInfoDto; | import com.sczx.order.dto.GroupBuyOrderInfoDto; | ||||||
|  | import com.sczx.order.dto.SimpleUserInfoDTO; | ||||||
|  |  | ||||||
| /** 团购券服务 | /** 团购券服务 | ||||||
|  * @Author: 张黎 |  * @Author: 张黎 | ||||||
| @ -10,12 +11,10 @@ import com.sczx.order.dto.GroupBuyOrderInfoDto; | |||||||
| public interface GroupBuyCouponService { | public interface GroupBuyCouponService { | ||||||
|     /** |     /** | ||||||
|      * 获取团购券下单信息 |      * 获取团购券下单信息 | ||||||
|      * @param couponCode 团购券码 |  | ||||||
|      * @param couponType 团购券类型 |  | ||||||
|      * @param mobile 手机号 |      * @param mobile 手机号 | ||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     GroupBuyOrderInfoDto getGroupBuyOrderInfoDto(String couponCode, String couponType, String mobile); |     SimpleUserInfoDTO getGroupBuyOrderInfoDto(String mobile); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 校验团购券码 |      * 校验团购券码 | ||||||
|  | |||||||
| @ -3,15 +3,18 @@ package com.sczx.order.service; | |||||||
| import com.meituan.sdk.MeituanResponse; | import com.meituan.sdk.MeituanResponse; | ||||||
| import com.meituan.sdk.auth.MeituanTokenResponse; | import com.meituan.sdk.auth.MeituanTokenResponse; | ||||||
| import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptConsumeResponse; | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptConsumeResponse; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareResponse; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptReverseconsume.TuangouReceiptReverseconsumeResponse; | ||||||
|  | import com.sczx.order.dto.VerifyGroupBuyCouponsReq; | ||||||
|  |  | ||||||
| public interface MeiTuanService { | public interface MeiTuanService { | ||||||
|  |  | ||||||
|     MeituanTokenResponse getAccessToken(String code , String state); |     MeituanTokenResponse getAccessToken(String code , String state); | ||||||
|  |  | ||||||
|     MeituanTokenResponse prepare(String code); |     MeituanResponse<TuangouReceiptPrepareResponse> prepare(VerifyGroupBuyCouponsReq req); | ||||||
|  |  | ||||||
|     MeituanResponse<TuangouReceiptConsumeResponse> consume(String code); |     MeituanResponse<TuangouReceiptConsumeResponse> consume(VerifyGroupBuyCouponsReq req); | ||||||
|  |  | ||||||
|     MeituanTokenResponse refreshAccessToken(String refreshToken); |     MeituanResponse<TuangouReceiptReverseconsumeResponse> reverseconsume(VerifyGroupBuyCouponsReq req, String dealId); | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ public interface OrderService { | |||||||
|      * @param req |      * @param req | ||||||
|      * @return |      * @return | ||||||
|      */ |      */ | ||||||
|     OrderDetailDTO verifyGroupBuyCoupons(VerifyGroupBuyCouponsReq req) ; |     RentCarOrderResultDTO verifyGroupBuyCoupons(VerifyGroupBuyCouponsReq req) ; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 提交租车订单 |      * 提交租车订单 | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ public class GroupBuyCouponServiceImpl implements GroupBuyCouponService { | |||||||
|     private MeiTuanService meiTuanService; |     private MeiTuanService meiTuanService; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public GroupBuyOrderInfoDto getGroupBuyOrderInfoDto(String couponCode, String couponType, String mobile) { |     public SimpleUserInfoDTO getGroupBuyOrderInfoDto(String mobile) { | ||||||
|         SimpleUserInfoDTO userInfoDTO = userInteg.getUInfoByMobile(mobile); |         SimpleUserInfoDTO userInfoDTO = userInteg.getUInfoByMobile(mobile); | ||||||
|         if(userInfoDTO==null){ |         if(userInfoDTO==null){ | ||||||
|             throw new BizException("用户不存在"); |             throw new BizException("用户不存在"); | ||||||
|  | |||||||
| @ -11,25 +11,31 @@ import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptCo | |||||||
| import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptConsumeResponse; | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptConsumeResponse; | ||||||
| import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareRequest; | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareRequest; | ||||||
| import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareResponse; | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareResponse; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptReverseconsume.TuangouReceiptReverseconsumeRequest; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptReverseconsume.TuangouReceiptReverseconsumeResponse; | ||||||
|  | import com.sczx.order.dto.VerifyGroupBuyCouponsReq; | ||||||
| import com.sczx.order.exception.BizException; | import com.sczx.order.exception.BizException; | ||||||
| import com.sczx.order.service.MeiTuanService; | import com.sczx.order.service.MeiTuanService; | ||||||
|  | import com.sczx.order.thirdpart.dto.CompanyStoreDTO; | ||||||
| import com.sczx.order.thirdpart.integration.StoreInteg; | import com.sczx.order.thirdpart.integration.StoreInteg; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.beans.factory.annotation.Value; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  | import java.time.format.DateTimeFormatter; | ||||||
|  | import java.util.UUID; | ||||||
|  |  | ||||||
| @Slf4j | @Slf4j | ||||||
| @Service | @Service | ||||||
| public class MeiTuanServiceImpl implements MeiTuanService { | public class MeiTuanServiceImpl implements MeiTuanService { | ||||||
|  |  | ||||||
|  |     @Value("${coupon.meituan.developer_id}") | ||||||
|  |     private Long DeveloperId; | ||||||
|  |  | ||||||
|     private Long DeveloperId = 116997L; |     @Value("${coupon.meituan.sign_key}") | ||||||
|  |     private String Signkey; | ||||||
|     private String Signkey = "n8xlhtshk7t1luvi"; |  | ||||||
|  |  | ||||||
|     //private String accessToken = "V2-26b8d231854d3fdf6a5c06273377a65e441e4c9f1c8cea4959c510bf0dd19ed7657e34bebe4b74aa455b80d3c757cd8a66e3ece9148e6d6838778db5f9600cf383dbf89c0cc27f07f777c98649bd94fe"; |  | ||||||
|  |  | ||||||
|     private String accessToken = "V2-549da132ffebe5ce5731a17ae166cb899e13c579900d6cbc4163b60e4d40440ccbe8e56d25c3341cd1003c5529c407085c06af2eb41d2d091353b4d2be6f887582d9d4bf247cf9a511581ad46ade47e8"; |  | ||||||
|  |  | ||||||
|     @Autowired |     @Autowired | ||||||
|     private StoreInteg storeInteg; |     private StoreInteg storeInteg; | ||||||
| @ -59,75 +65,101 @@ public class MeiTuanServiceImpl implements MeiTuanService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public MeituanTokenResponse prepare(String code) { |     public MeituanResponse<TuangouReceiptPrepareResponse> prepare(VerifyGroupBuyCouponsReq req) { | ||||||
|         try { |         try { | ||||||
|             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); |             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); | ||||||
|  |  | ||||||
|             TuangouReceiptPrepareRequest tuangouReceiptPrepareRequest = new TuangouReceiptPrepareRequest(); |             TuangouReceiptPrepareRequest tuangouReceiptPrepareRequest = new TuangouReceiptPrepareRequest(); | ||||||
|  |  | ||||||
|             tuangouReceiptPrepareRequest.setReceiptCode("0106972239359"); |             tuangouReceiptPrepareRequest.setReceiptCode(req.getCouponCode()); | ||||||
|  |  | ||||||
|  |             String appAuthToken = getAppAuthToken(req.getStoreId().intValue()).getMtToken(); | ||||||
|  |  | ||||||
|             String appAuthToken = accessToken; |  | ||||||
|             MeituanResponse<TuangouReceiptPrepareResponse> response = meituanClient.invokeApi(tuangouReceiptPrepareRequest, appAuthToken); |             MeituanResponse<TuangouReceiptPrepareResponse> response = meituanClient.invokeApi(tuangouReceiptPrepareRequest, appAuthToken); | ||||||
|  |  | ||||||
|             log.info("获取access_token响应结果: {}", JSONObject.toJSONString(response)); |  | ||||||
|  |  | ||||||
|             if (response.isSuccess()) { |             if (response.isSuccess()) { | ||||||
|                 TuangouReceiptPrepareResponse resp = response.getData(); |                 log.info("美团验券响应结果: {}", JSONObject.toJSONString(response)); | ||||||
|                 System.out.println(resp); |  | ||||||
|             } else { |             } else { | ||||||
|                 System.out.println("调用失败"); |                 log.error("美团验券异常: {}", JSONObject.toJSONString(response)); | ||||||
|  |                 throw new BizException("美团验券异常:"+response.getMsg()); | ||||||
|             } |             } | ||||||
|             return null; |             return null; | ||||||
|  |  | ||||||
|  |  | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             log.error("获取access_token异常", e); |             throw new RuntimeException("券验证失败"); | ||||||
|             return null; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public MeituanTokenResponse refreshAccessToken(String refreshToken) { |     public MeituanResponse<TuangouReceiptConsumeResponse> consume (VerifyGroupBuyCouponsReq req) { | ||||||
|         try { |         try { | ||||||
|             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); |             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); | ||||||
|  |             CompanyStoreDTO companyStoreDTO = getAppAuthToken(req.getStoreId().intValue()); | ||||||
|  |  | ||||||
|             MeituanTokenResponse response = meituanClient.refreshToken(58, refreshToken); |             String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); | ||||||
|  |             String uuidSuffix = UUID.randomUUID().toString().replace("-", "").substring(0, 6).toUpperCase(); | ||||||
|  |  | ||||||
|             return response; |  | ||||||
|  |  | ||||||
|         } catch (Exception e) { |  | ||||||
|             log.error("获取access_token异常", e); |  | ||||||
|             return null; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public MeituanResponse<TuangouReceiptConsumeResponse> consume (String code) { |  | ||||||
|         try { |  | ||||||
|             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); |  | ||||||
|  |  | ||||||
|             TuangouReceiptConsumeRequest tuangouReceiptConsumeRequest = new TuangouReceiptConsumeRequest(); |             TuangouReceiptConsumeRequest tuangouReceiptConsumeRequest = new TuangouReceiptConsumeRequest(); | ||||||
|  |  | ||||||
|             tuangouReceiptConsumeRequest.setReceiptCode("0106972239359"); |             tuangouReceiptConsumeRequest.setReceiptCode(req.getCouponCode()); | ||||||
|             tuangouReceiptConsumeRequest.setCount(1); |             tuangouReceiptConsumeRequest.setCount(1); | ||||||
|             tuangouReceiptConsumeRequest.setRequestId("fdae143414"); |             tuangouReceiptConsumeRequest.setRequestId(timestamp+uuidSuffix); | ||||||
|             tuangouReceiptConsumeRequest.setAppShopAccountName("customer"); |             tuangouReceiptConsumeRequest.setAppShopAccountName(companyStoreDTO.getName()); | ||||||
|             tuangouReceiptConsumeRequest.setAppShopAccount("customer"); |             tuangouReceiptConsumeRequest.setAppShopAccount(companyStoreDTO.getStoreNumber()); | ||||||
|  |  | ||||||
|  |             MeituanResponse<TuangouReceiptConsumeResponse> response = meituanClient.invokeApi(tuangouReceiptConsumeRequest, companyStoreDTO.getMtToken()); | ||||||
|  |  | ||||||
|             String appAuthToken = accessToken; |             log.info("美团核销响应结果: {}", JSONObject.toJSONString(response)); | ||||||
|             MeituanResponse<TuangouReceiptConsumeResponse> response = meituanClient.invokeApi(tuangouReceiptConsumeRequest, appAuthToken); |             if (response.isSuccess()) { | ||||||
|  |                 log.info("美团核销响应结果: {}", JSONObject.toJSONString(response)); | ||||||
|             log.info("获取access_token响应结果: {}", JSONObject.toJSONString(response)); |             } else { | ||||||
|  |                 log.error("美团核销异常: {}", JSONObject.toJSONString(response)); | ||||||
|  |                 throw new BizException("美团验券异常:"+response.getMsg()); | ||||||
|  |             } | ||||||
|             return response; |             return response; | ||||||
|         } catch (MtSdkException e) { |         } catch (MtSdkException e) { | ||||||
|             e.printStackTrace(); |             throw new RuntimeException("美团核销失败"); | ||||||
|             return null; |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public MeituanResponse<TuangouReceiptReverseconsumeResponse> reverseconsume(VerifyGroupBuyCouponsReq req, String dealId) { | ||||||
|  |         try { | ||||||
|  |             MeituanClient meituanClient = DefaultMeituanClient.builder(DeveloperId, Signkey).build(); | ||||||
|  |             CompanyStoreDTO companyStoreDTO = getAppAuthToken(req.getStoreId().intValue()); | ||||||
|  |  | ||||||
|  |             TuangouReceiptReverseconsumeRequest tuangouReceiptReverseconsumeRequest = new TuangouReceiptReverseconsumeRequest(); | ||||||
|  |  | ||||||
|  |             tuangouReceiptReverseconsumeRequest.setAppShopAccount(companyStoreDTO.getStoreNumber()); | ||||||
|  |             tuangouReceiptReverseconsumeRequest.setAppShopAccountName(companyStoreDTO.getName()); | ||||||
|  |             tuangouReceiptReverseconsumeRequest.setReceiptCode(req.getCouponCode()); | ||||||
|  |             tuangouReceiptReverseconsumeRequest.setDealId(dealId); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |             MeituanResponse<TuangouReceiptReverseconsumeResponse> response = meituanClient.invokeApi(tuangouReceiptReverseconsumeRequest, companyStoreDTO.getMtToken()); | ||||||
|  |  | ||||||
|  |             if (response.isSuccess()) { | ||||||
|  |                 TuangouReceiptReverseconsumeResponse resp = response.getData(); | ||||||
|  |                 log.info("美团撤销验券响应结果: {}", JSONObject.toJSONString(response)); | ||||||
|  |             } else { | ||||||
|  |                 log.error("美团撤销验券异常: {}", JSONObject.toJSONString(response)); | ||||||
|  |                 throw new BizException("美团撤销验券异常:"+response.getMsg()); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             return response; | ||||||
|  |         }catch (MtSdkException e) { | ||||||
|  |             throw new RuntimeException("美团美团撤销验券失败"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     private CompanyStoreDTO getAppAuthToken(Integer storeId) { | ||||||
|  |         CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(storeId); | ||||||
|  |         return companyStoreDTO; | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
| @ -7,6 +7,9 @@ import com.douyin.openapi.client.models.CertificatePrepareRequest; | |||||||
| import com.douyin.openapi.client.models.CertificatePrepareResponse; | import com.douyin.openapi.client.models.CertificatePrepareResponse; | ||||||
| import com.douyin.openapi.client.models.CertificateVerifyRequest; | import com.douyin.openapi.client.models.CertificateVerifyRequest; | ||||||
| import com.douyin.openapi.client.models.CertificateVerifyResponse; | import com.douyin.openapi.client.models.CertificateVerifyResponse; | ||||||
|  | import com.meituan.sdk.MeituanResponse; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptConsume.TuangouReceiptConsumeResponse; | ||||||
|  | import com.meituan.sdk.model.ddzh.tuangou.tuangouReceiptPrepare.TuangouReceiptPrepareResponse; | ||||||
| import com.sczx.order.common.constant.RedisKeyConstants; | import com.sczx.order.common.constant.RedisKeyConstants; | ||||||
| import com.sczx.order.common.enums.*; | import com.sczx.order.common.enums.*; | ||||||
| import com.sczx.order.convert.OrderCarImgConvert; | import com.sczx.order.convert.OrderCarImgConvert; | ||||||
| @ -102,11 +105,50 @@ public class OrderServiceImpl implements OrderService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public OrderDetailDTO verifyGroupBuyCoupons(VerifyGroupBuyCouponsReq req){ |     public RentCarOrderResultDTO verifyGroupBuyCoupons(VerifyGroupBuyCouponsReq req){ | ||||||
|  |         //校验用户是否存在,是否实名认证 | ||||||
|  |         SimpleUserInfoDTO  userInfoDTO = groupBuyCouponService.getGroupBuyOrderInfoDto(req.getMobile()); | ||||||
|  |  | ||||||
|  |         RentCarThirdPlatformOrderReq thirdRentCarOrder = new RentCarThirdPlatformOrderReq(); | ||||||
|  |         Map<String, String> productIdMap = new HashMap<>(); | ||||||
|  |  | ||||||
|         if (req.getCouponType() == CouponTypeEnum.MT.getCode()){ |         if (req.getCouponType() == CouponTypeEnum.MT.getCode()){ | ||||||
|             //TODO 调用美团验券接口 |             //TODO 调用美团验券接口 | ||||||
|  |             //美团验券 | ||||||
|  |             MeituanResponse<TuangouReceiptPrepareResponse> prepareResponse =meiTuanService.prepare( req); | ||||||
|  |             String phone = prepareResponse.getData().getMobile(); | ||||||
|  |             if (phone != null && !phone.isEmpty()){ | ||||||
|  |                 if (!comparePhoneNumbers(phone, req.getMobile())){ | ||||||
|  |                     throw new BizException("所提供的手机号码与团购手机号不一致"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             //使用输入的手机号进行后续操作 | ||||||
|  |             //核销团购券 | ||||||
|  |             MeituanResponse<TuangouReceiptConsumeResponse> consumeResponse =meiTuanService.consume( req); | ||||||
|  |             consumeResponse.getData().getResult().forEach(result -> { | ||||||
|  |                 productIdMap.put("mtOrderId",String.valueOf(result.getDealId())); | ||||||
|  |                 productIdMap.put("mtProductId",  String.valueOf(result.getDealGroupId())); | ||||||
|  |             }); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |             //生成第三方订单 | ||||||
|  |             CarModelPackageDTO carModelPackageDTO = carInteg.getCarModelPackageByThireId(productIdMap.get("mtProductId"),null); | ||||||
|  |             if (carModelPackageDTO == null){ | ||||||
|  |                 throw new BizException("无此对应团购套餐"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             thirdRentCarOrder.setCarModelId(carModelPackageDTO.getCarModelId()); | ||||||
|  |             thirdRentCarOrder.setRentCarRuleId(carModelPackageDTO.getCarRuleId()); | ||||||
|  |             thirdRentCarOrder.setCustomerId(userInfoDTO.getUserId().longValue()); | ||||||
|  |             thirdRentCarOrder.setStoreId(req.getStoreId()); | ||||||
|  |             thirdRentCarOrder.setOrderSource(CouponTypeEnum.MT.getCode()); | ||||||
|  |             thirdRentCarOrder.setCustomerName(userInfoDTO.getUserName()); | ||||||
|  |             thirdRentCarOrder.setCustomerPhone(userInfoDTO.getPhoneNumber()); | ||||||
|  |             thirdRentCarOrder.setThirdOrderNo(productIdMap.get("mtOrderId")); | ||||||
|  |             thirdRentCarOrder.setCouponCode(req.getCouponCode()); | ||||||
|  |  | ||||||
|  |             RentCarOrderResultDTO rentCarOrderResultDTO = thirdPlatformRentCarOrder(thirdRentCarOrder); | ||||||
|  |             return rentCarOrderResultDTO; | ||||||
|  |  | ||||||
|         }else if (req.getCouponType() == CouponTypeEnum.DY.getCode()){ |         }else if (req.getCouponType() == CouponTypeEnum.DY.getCode()){ | ||||||
|  |  | ||||||
| @ -125,25 +167,19 @@ public class OrderServiceImpl implements OrderService { | |||||||
|             String verifyToken = response.getData().getVerifyToken(); |             String verifyToken = response.getData().getVerifyToken(); | ||||||
|             AtomicReference<String> phone = new AtomicReference<>(""); |             AtomicReference<String> phone = new AtomicReference<>(""); | ||||||
|             response.getData().getCertificates().forEach(certificate -> { |             response.getData().getCertificates().forEach(certificate -> { | ||||||
|                 Long certificateId = certificate.getCertificateId(); |                 productIdMap.put("dyOrderId",String.valueOf(certificate.getCertificateId())); | ||||||
|                 String skuId = certificate.getSku().getSkuId(); |                 productIdMap.put("dyProductId",  String.valueOf(certificate.getSku().getSkuId())); | ||||||
|                 certificate.getReserveInfo().getOrderReserveUserInfoList().forEach(orderReserveUserInfo -> { |                 certificate.getReserveInfo().getOrderReserveUserInfoList().forEach(orderReserveUserInfo -> { | ||||||
|                     phone.set(orderReserveUserInfo.getPhone()); |                     phone.set(orderReserveUserInfo.getPhone()); | ||||||
|                     System.out.println(orderReserveUserInfo.getPhone()); |  | ||||||
|                 }); |                 }); | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             String finalPhone = phone.get(); |             String finalPhone = phone.get(); | ||||||
|  |  | ||||||
|             //校验用户是否存在,是否实名认证 |  | ||||||
|             GroupBuyOrderInfoDto groupBuyOrderInfoDTO = groupBuyCouponService.getGroupBuyOrderInfoDto(req.getCouponCode(), req.getCouponType(), req.getMobile()); |  | ||||||
|  |  | ||||||
|             if (finalPhone != null && !finalPhone.isEmpty()) { |             if (finalPhone != null && !finalPhone.isEmpty()) { | ||||||
|                 // 如果校验券没有返回手机号码,则使用前端所传手机号码 |                 if (!comparePhoneNumbers(finalPhone, req.getMobile())){ | ||||||
|                 log.info("您所团购的订单未填写手机号,将使用您提交给门店的手机号生成租车订单"); |                     throw new BizException("所提供的手机号码与团购手机号不一致"); | ||||||
|  |                 } | ||||||
|             }else{ |  | ||||||
|                 // 如果校验券有返回手机号码,则使用前端所传手机号码与该脱敏手机号码比对 |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             //核销抖音团购券 |             //核销抖音团购券 | ||||||
| @ -155,18 +191,52 @@ public class OrderServiceImpl implements OrderService { | |||||||
|  |  | ||||||
|             verifyResponse.getData().getVerifyResults().forEach(verifyResult -> { |             verifyResponse.getData().getVerifyResults().forEach(verifyResult -> { | ||||||
|                 //撤销验券需要下面两个值 |                 //撤销验券需要下面两个值 | ||||||
|                 verifyResult.getCertificateId(); |                 productIdMap.put("dyCertificateId",verifyResult.getCertificateId()); | ||||||
|                 verifyResult.getVerifyId(); |                 productIdMap.put("dyVerifyId",verifyResult.getVerifyId()); | ||||||
|             }); |             }); | ||||||
|  |  | ||||||
|             //TODO  生成订单 |             //TODO  生成订单 | ||||||
|  |             //生成第三方订单 | ||||||
|  |             CarModelPackageDTO carModelPackageDTO = carInteg.getCarModelPackageByThireId(null,productIdMap.get("dyProductId")); | ||||||
|  |             if (carModelPackageDTO == null){ | ||||||
|  |                 throw new BizException("无此对应团购套餐"); | ||||||
|  |             } | ||||||
|  |             thirdRentCarOrder.setCarModelId(carModelPackageDTO.getCarModelId()); | ||||||
|  |             thirdRentCarOrder.setRentCarRuleId(carModelPackageDTO.getCarRuleId()); | ||||||
|  |             thirdRentCarOrder.setCustomerId(userInfoDTO.getUserId().longValue()); | ||||||
|  |             thirdRentCarOrder.setStoreId(req.getStoreId()); | ||||||
|  |             thirdRentCarOrder.setOrderSource(CouponTypeEnum.DY.getCode()); | ||||||
|  |             thirdRentCarOrder.setCustomerName(userInfoDTO.getUserName()); | ||||||
|  |             thirdRentCarOrder.setCustomerPhone(userInfoDTO.getPhoneNumber()); | ||||||
|  |             thirdRentCarOrder.setThirdOrderNo(productIdMap.get("dyCertificateId")); | ||||||
|  |             thirdRentCarOrder.setCouponCode(productIdMap.get("dyVerifyId")); | ||||||
|  |  | ||||||
|  |             RentCarOrderResultDTO rentCarOrderResultDTO = thirdPlatformRentCarOrder(thirdRentCarOrder); | ||||||
|  |  | ||||||
|  |             return rentCarOrderResultDTO; | ||||||
|  |         } | ||||||
|  |         throw new BizException("券码类型错误"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|         return null; |     public boolean comparePhoneNumbers(String maskedPhone, String actualPhone) { | ||||||
|  |         // 检查输入参数 | ||||||
|  |         if (maskedPhone == null || actualPhone == null) { | ||||||
|  |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         // 比较前3位 | ||||||
|  |         String prefix1 = maskedPhone.substring(0, 3); | ||||||
|  |         String prefix2 = actualPhone.substring(0, 3); | ||||||
|  |  | ||||||
|  |         // 比较后4位 | ||||||
|  |         String suffix1 = maskedPhone.substring(maskedPhone.length() - 4); | ||||||
|  |         String suffix2 = actualPhone.substring(actualPhone.length() - 4); | ||||||
|  |  | ||||||
|  |         // 返回比对结果 | ||||||
|  |         return prefix1.equals(prefix2) && suffix1.equals(suffix2); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     @Override |     @Override | ||||||
|     public RentCarOrderResultDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq) { |     public RentCarOrderResultDTO submitRentCarOrder(RentCarOrderReq rentCarOrderReq) { | ||||||
| @ -569,10 +639,10 @@ public class OrderServiceImpl implements OrderService { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         //获取门店信息 |         //获取门店信息 | ||||||
| //        CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(rentCarOrderReq.getStoreId().toString())); |         CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(rentCarOrderReq.getStoreId().toString())); | ||||||
| //        if(Objects.isNull(companyStoreDTO)){ |         if(Objects.isNull(companyStoreDTO)){ | ||||||
| //            throw new BizException("运营商或门店已下架"); |             throw new BizException("运营商或门店已下架"); | ||||||
| //        } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         CarModelSimpleDTO carModelSimpleDTO = carInteg.getCarModelByModelId(rentCarOrderReq.getCarModelId()); |         CarModelSimpleDTO carModelSimpleDTO = carInteg.getCarModelByModelId(rentCarOrderReq.getCarModelId()); | ||||||
| @ -598,10 +668,11 @@ public class OrderServiceImpl implements OrderService { | |||||||
|                 //TODO 这里保存订单要做事物处理 |                 //TODO 这里保存订单要做事物处理 | ||||||
|                 //生成订单主表 |                 //生成订单主表 | ||||||
|                 OrderMainPO orderMainPO = OrderConvert.INSTANCE.subOrderToPo(rentCarOrderReq, userInfoDTO, rentCarRuleDTO); |                 OrderMainPO orderMainPO = OrderConvert.INSTANCE.subOrderToPo(rentCarOrderReq, userInfoDTO, rentCarRuleDTO); | ||||||
|                 //orderMainPO.setOperatorId(Long.valueOf(companyStoreDTO.getOperatingCompanyId())); |                 orderMainPO.setOperatorId(Long.valueOf(companyStoreDTO.getOperatingCompanyId())); | ||||||
|                 orderMainPO.setOrderNo(OrderUtil.generateOrderNo()); |                 orderMainPO.setOrderNo(OrderUtil.generateOrderNo()); | ||||||
|                 orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PICK.getCode()); |                 orderMainPO.setOrderStatus(OrderStatusEnum.WAIT_PICK.getCode()); | ||||||
|                 orderMainPO.setFirstOrderTime(LocalDateTime.now()); |                 orderMainPO.setFirstOrderTime(LocalDateTime.now()); | ||||||
|  |                 orderMainPO.setStoreId(rentCarOrderReq.getStoreId()); | ||||||
|  |  | ||||||
|                 //设置预计还车时间 |                 //设置预计还车时间 | ||||||
|                 LocalDateTime endRentTime = OrderUtil.getEndRentTime(orderMainPO.getFirstOrderTime(),1,rentCarRuleDTO.getRentalDays(), rentCarRuleDTO.getRentalType()); |                 LocalDateTime endRentTime = OrderUtil.getEndRentTime(orderMainPO.getFirstOrderTime(),1,rentCarRuleDTO.getRentalDays(), rentCarRuleDTO.getRentalType()); | ||||||
| @ -652,13 +723,13 @@ public class OrderServiceImpl implements OrderService { | |||||||
|                 BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |                 BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); | ||||||
|                 orderMainPO.setOrderAmount(orderAmount); |                 orderMainPO.setOrderAmount(orderAmount); | ||||||
|  |  | ||||||
|                 //发起支付返回预支付信息 |                 //支付号为团购码 | ||||||
|                 String paymentId = OrderUtil.generateSubOrderNo(OrderUtil.ZF_PREFIX); |                 String paymentId = rentCarOrderReq.getCouponCode(); | ||||||
|  |  | ||||||
|  |  | ||||||
|                 for(OrderSubPO orderSubPO : orderSubPOList){ |                 for(OrderSubPO orderSubPO : orderSubPOList){ | ||||||
|                     orderSubPO.setPaymentId(paymentId); |                     orderSubPO.setPaymentId(paymentId); | ||||||
|                     orderSubPO.setPayStatus(PayStatusEnum.USERPAYING.getCode()); |                     orderSubPO.setPayStatus(PayStatusEnum.SUCCESS.getCode()); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 orderMainRepo.save(orderMainPO); |                 orderMainRepo.save(orderMainPO); | ||||||
| @ -671,7 +742,7 @@ public class OrderServiceImpl implements OrderService { | |||||||
|  |  | ||||||
|                 //返回订单信息 |                 //返回订单信息 | ||||||
|                 OrderDTO orderDTO = OrderConvert.INSTANCE.poToDto(orderMainPO); |                 OrderDTO orderDTO = OrderConvert.INSTANCE.poToDto(orderMainPO); | ||||||
|                 //orderDTO.setCompanyStoreDTO(companyStoreDTO); |                 orderDTO.setCompanyStoreDTO(companyStoreDTO); | ||||||
|                 orderDTO.setCarModelSimpleDTO(carModelSimpleDTO); |                 orderDTO.setCarModelSimpleDTO(carModelSimpleDTO); | ||||||
|  |  | ||||||
|                 RentCarOrderResultDTO rentCarOrderResultDTO = new RentCarOrderResultDTO(); |                 RentCarOrderResultDTO rentCarOrderResultDTO = new RentCarOrderResultDTO(); | ||||||
|  | |||||||
| @ -0,0 +1,24 @@ | |||||||
|  | package com.sczx.order.thirdpart.dto; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @Data | ||||||
|  | @ApiModel(value = "车型套餐对象") | ||||||
|  | public class CarModelPackageDTO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("车型ID") | ||||||
|  |     private Long carModelId; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("套餐ID") | ||||||
|  |     private Long carRuleId; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("美团商品ID") | ||||||
|  |     private String mtProductId; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("抖音商品ID") | ||||||
|  |     private String dyProductId; | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -21,4 +21,6 @@ public interface CarFacade { | |||||||
|     @PostMapping("/car/getCarByCarCondition") |     @PostMapping("/car/getCarByCarCondition") | ||||||
|     Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req); |     Result<CarDTO> getCarByCarCondition(@RequestBody CarQueryConditionReq req); | ||||||
|  |  | ||||||
|  |     @RequestMapping("/carModel/getCarModelByThireId") | ||||||
|  |     Result<CarModelPackageDTO> getCarModelByThireId(@RequestParam(name = "mtId") String mtId,@RequestParam(name = "dyId") String dyId); | ||||||
| } | } | ||||||
| @ -69,6 +69,16 @@ public class CarInteg { | |||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public CarModelPackageDTO getCarModelPackageByThireId(String mtId,String dyId){ | ||||||
|  |         try{ | ||||||
|  |             Result<CarModelPackageDTO> result = carFacade.getCarModelByThireId(mtId,dyId); | ||||||
|  |             if(result.isSuccess()){ | ||||||
|  |                 return result.getData(); | ||||||
|  |             } | ||||||
|  |         } catch (Exception e){ | ||||||
|  |             log.error("根据美团/抖音商品id查询车型套餐信息失败",e); | ||||||
|  |             throw new InnerException("根据美团/抖音商品id查询车型套餐信息失败"); | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |      } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user