Commit 5a792656 by ping.wu

抖音卖券下单

parent 53af3295
......@@ -83,6 +83,8 @@ public class CreateOrderVo {
private String mobile;
private String saleCouponPhone;
/**
* 渠道 1 saas 2 支付宝 3. iwc i围餐 5 头条
*/
......
......@@ -169,14 +169,12 @@ public class CheckOrder {
}
public AssortmentCustomerInfoVo checkOrderByMemberNew(String sessionId, String cardCode) {
public AssortmentCustomerInfoVo checkOrderByMemberNew(String sessionId) {
// 通过sessionId查询缓存中会员id
AssortmentCustomerInfoVo userLoginInfoDto = customerInfoManager.getCustomerInfoByObject(sessionId);
if (userLoginInfoDto == null || StringUtils.isEmpty(userLoginInfoDto.getMemberId())) {
throw new ServiceException(ResponseResult.NOT_LOGIN);
}
//校验会员svc卡信息
// checkCardCode(userLoginInfoDto.getPartnerId(), userLoginInfoDto.getMemberId(), cardCode);
return userLoginInfoDto;
}
......
......@@ -26,6 +26,7 @@ import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.ordercenter.config.OrderCenterProperties;
import com.freemud.application.sdk.api.ordercenter.entities.v1.OrderBeanV1;
import com.freemud.application.sdk.api.ordercenter.entities.vo.OrderCallBackRequestVo;
import com.freemud.application.sdk.api.ordercenter.enums.BizTypeEnum;
import com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderInfoReqs;
import com.freemud.sdk.api.assortment.order.enums.OrderSourceType;
import com.freemud.sdk.api.assortment.order.util.LockUtils;
......@@ -128,8 +129,11 @@ public class OrderAdapterServiceImpl {
private SaasOrderHandle saasOrderHandle;
@Autowired
private OrderCallbackClient orderCallbackClient;
@Autowired
private SellCouponOrderServiceImpl sellCouponOrderServiceImpl;
//获取下单实现对象
private OrderFactoryService getCreateOrderBean(AssortmentCustomerInfoVo assortmentCustomerInfoVo,CreateOrderVo createOrderVo){
// 扩展字段中存储 sessionKey
createOrderVo.setSessionKey(assortmentCustomerInfoVo.getSessionKey());
......@@ -150,6 +154,11 @@ public class OrderAdapterServiceImpl {
if (UserLoginChannelEnum.APP.getCode().equals(assortmentCustomerInfoVo.getChannel())) {
return appOrderService;
}
//抖音卖券
if (Objects.equals(BizTypeEnum.SALE_COUPON.getBizType(),createOrderVo.getBizType())) {
return sellCouponOrderServiceImpl;
}
return orderService;
}
......
......@@ -1112,4 +1112,14 @@ public class PayServiceImpl {
}
/**
* 获取门店支付信息
*
* aggregationType 6-会员、7-微商城、8-一键购买 9:积分商城
*/
public AssortmentOpenPlatformIappWxappStore getIappWxappStoreInfo(String wxAppId, String aggregationType) {
AssortmentOpenPlatformIappWxappStore wxAppStore = assortmentOpenPlatformIappWxappStoreManager.selectIappWxappStoreByWxAppIdAndAggregationType(wxAppId, aggregationType);
return wxAppStore;
}
}
......@@ -14,6 +14,7 @@ import cn.freemud.entities.dto.product.ProductInfo;
import cn.freemud.entities.dto.product.ValidateProductInfosDto;
import cn.freemud.entities.dto.promotion.CalculationDiscountGoodsDto;
import cn.freemud.entities.dto.promotion.CalculationDiscountRequestDto;
import cn.freemud.entities.vo.CreateOrderVo;
import cn.freemud.entities.vo.NgsSellCouponCreateOrderVo;
import cn.freemud.entities.vo.PaysuccessNoticeMessage;
import cn.freemud.entities.vo.SellCouponCreateOrderVo;
......@@ -22,12 +23,14 @@ import cn.freemud.interceptor.ServiceException;
import cn.freemud.manager.BuyProductOnceManager;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.CouponService;
import cn.freemud.service.OrderFactoryService;
import cn.freemud.service.business.OrderBusinessService;
import cn.freemud.service.thirdparty.PromotionDiscountClient;
import cn.freemud.service.thirdparty.StoreItemClient;
import cn.freemud.utils.AppLogUtil;
import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.db.AssortmentOpenPlatformIappWxappStore;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.constant.ResponseResultEnum;
......@@ -105,7 +108,7 @@ import static com.freemud.sdk.api.assortment.order.domain.ResponseCodeConstant.R
*/
@Service
public class SellCouponOrderServiceImpl {
public class SellCouponOrderServiceImpl implements OrderFactoryService {
@Autowired
private CheckOrder checkOrder;
......@@ -124,10 +127,10 @@ public class SellCouponOrderServiceImpl {
private OrderAdapter orderAdapter;
@Autowired
private OrderSdkAdapter orderSdkAdapter;
// @Autowired
// private RedisCache redisCache;
@Autowired
protected RedisTemplate redisTemplate;
private RedisCache redisCache;
// @Autowired
// protected RedisTemplate redisTemplate;
@Autowired
private CouponService couponService;
@Autowired
......@@ -166,11 +169,113 @@ public class SellCouponOrderServiceImpl {
/**
* 抖音卖券
*/
@Override
public BaseResponse createOrder(CreateOrderVo requestVo) {
// 查询用户信息、校验svc卡
AssortmentCustomerInfoVo userLoginInfoDto = checkOrder.checkOrderByMemberNew(requestVo.getSessionId());
String trackingNo = LogThreadLocal.getTrackingNo();
String partnerId = userLoginInfoDto.getPartnerId();
String userId = userLoginInfoDto.getMemberId();
String wxAppId = userLoginInfoDto.getWxAppId();
if(CollectionUtils.isEmpty(requestVo.getProducts())){
return ResponseUtil.error(ResponseCodeConstant.RESPONSE_ERROR_STR, "无商品信息");
}
String skuId = requestVo.getProducts().get(0).getSkuId();
//10-抖音卖券门店
AssortmentOpenPlatformIappWxappStore wxAppStore = payService.getIappWxappStoreInfo(wxAppId,"10");
if ((wxAppStore == null || wxAppStore.getClientCode() == null)) {
return ResponseUtil.error(ResponseCodeConstant.RESPONSE_ERROR_STR, "支付门店未配置");
}
String storeId = wxAppStore.getStoreId();
//查询门店信息
StoreInfoRequest storeInfoRequest = new StoreInfoRequest(partnerId, storeId,null);
StoreResponse storeResponse = storeCenterService.getStoreInfo(storeInfoRequest, trackingNo);
if (storeResponse == null || storeResponse.getStatusCode() != 100 || storeResponse.getBizVO() == null) {
throw new ServiceException(ResponseResult.STORE_NOT_FOUND);
}
GetProductInfoDto getProductInfoDto = new GetProductInfoDto();
getProductInfoDto.setPartnerId(partnerId);
getProductInfoDto.setShopId(storeId);
getProductInfoDto.setProductInfoType(2);
getProductInfoDto.setProductIds(Arrays.asList(skuId));
getProductInfoDto.setChannel(BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode());
ProductInfosDto productInfosDto = storeItemClient.listProductInfos(getProductInfoDto);
if (!ResponseCodeConstant.RESPONSE_SUCCESS.equals(productInfosDto.getErrcode()) || CollectionUtils.isEmpty(productInfosDto.getData().getProducts())) {
AppLogUtil.infoLog("查询商品信息失败,getProductInfoDto,baseResponse",getProductInfoDto,productInfosDto);
return ResponseUtil.error(ResponseResult.STORE_ITEM_CHECK_INVAILD);
}
//卖券订单biztype默认传入6
BaseResponse createOrderRequestResponse = checkOrderCoupon(userLoginInfoDto, storeResponse, trackingNo, requestVo.getMenuType(), BizTypeEnum.SALE_COUPON.getBizType(), partnerId, storeId, skuId,requestVo.getCardCode());
if (createOrderRequestResponse == null || !ResponseResult.SUCCESS.getCode().equals(createOrderRequestResponse.getCode()) || createOrderRequestResponse.getResult() == null) {
return createOrderRequestResponse;
}
CreateOrderRequest createOrderRequest = (CreateOrderRequest) createOrderRequestResponse.getResult();
OrderBaseResp<OrderInfoReqs> orderInfoReqsBaseResponse = orderSdkService.createOrder(createOrderRequest, trackingNo);
CreateOrderResponse createOrderResponse = orderSdkAdapter.convent2NEWOrderInfoReqs(orderInfoReqsBaseResponse);
if (createOrderResponse == null || createOrderResponse.getErrcode() != 100) {
return ResponseUtil.error(ResponseResult.ORDER_CREATE_ERROR);
}else{
OrderBeanV1 orderBean = createOrderResponse.getData();
if(productInfosDto.getData().getProducts().get(0).getStockLimit() == 1){
CreateOrderProductRequest productRequest = new CreateOrderProductRequest();
productRequest.setSpecification(skuId);
productRequest.setHasStockProudct(true);
productRequest.setNumber(1);
UpdateStocksRequest updateStocksRequest = orderSdkAdapter.getUpdateProductStock(
orderBean, Arrays.asList(productRequest), StockChangeType.REDUCE,requestVo.getMenuType());
com.freemud.application.sdk.api.base.BaseResponse baseResponse = stockSdkService.reducesStocks(updateStocksRequest, "");
ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(),
"updateStock", JSONObject.toJSONString(updateStocksRequest), JSONObject.toJSONString(baseResponse));
if (!ObjectUtils.equals(RESPONSE_SUCCESS_STR, baseResponse.getCode())) {
//TODO 失败取消订单
CancelOrderRequest cancelOrderRequest = orderSdkAdapter.convent2CancelOrderRequest(orderBean.getOid(), orderBean.getCompanyId(),
AfterSalesType.SYSTEM_CANCEL, "商品库存不足", "", null);
BaseOrderResponse orderResponse = orderCenterSdkService.orderCancel(cancelOrderRequest);
return ResponseUtil.error(baseResponse.getCode(),"商品库存不足");
}
}
}
//创建支付
CreatePrepayRequestDto createPrepayRequestDto = new CreatePrepayRequestDto();
createPrepayRequestDto.setPartnerId(partnerId);
createPrepayRequestDto.setTransId(orderInfoReqsBaseResponse.getResult().getOrderCode());
createPrepayRequestDto.setWxAppId(userLoginInfoDto.getWxAppId());
createPrepayRequestDto.setOpenId(userLoginInfoDto.getOpenId());
createPrepayRequestDto.setCardCode(requestVo.getCardCode());
createPrepayRequestDto.setPayCode(null);
createPrepayRequestDto.setFatherOrderBean(createOrderResponse.getData());
createPrepayRequestDto.setProductOrderBean(createOrderResponse.getData());
createPrepayRequestDto.setTotalAmount(createOrderRequest.getSettlementAmount());
createPrepayRequestDto.setCardAmount(0);
OrderExtInfoDto orderExtInfoDto = new OrderExtInfoDto();
orderExtInfoDto.setOpenid(userLoginInfoDto.getOpenId());
orderExtInfoDto.setAppid(userLoginInfoDto.getWxAppId());
orderExtInfoDto.setSessionId(requestVo.getSessionId());
orderExtInfoDto.setVersion(requestVo.getVersion());
// 扩展字段中存储 sessionKey
orderExtInfoDto.setSessionKey(userLoginInfoDto.getSessionKey());
orderExtInfoDto.setFormId(requestVo.getFormId());
orderExtInfoDto.setFromAppId(userLoginInfoDto.getWxAppId());
orderExtInfoDto.setSaleCouponPhone(requestVo.getSaleCouponPhone());
createPrepayRequestDto.setOrderExtInfoDTO(orderExtInfoDto);
return payService.createPrepayOrder(createPrepayRequestDto);
}
/**
* 卖券订单创建
*/
public BaseResponse createOrder(SellCouponCreateOrderVo requestVo){
// 查询用户信息、校验svc卡
AssortmentCustomerInfoVo userLoginInfoDto = checkOrder.checkOrderByMemberNew(requestVo.getSessionId(), requestVo.getCardCode());
AssortmentCustomerInfoVo userLoginInfoDto = checkOrder.checkOrderByMemberNew(requestVo.getSessionId());
String trackingNo = LogThreadLocal.getTrackingNo();
String partnerId = userLoginInfoDto.getPartnerId();
String storeId = requestVo.getShopId();
......@@ -438,7 +543,7 @@ public class SellCouponOrderServiceImpl {
String key = this.getFolwNo(requestVo.getAppId(), date);
int flowno = 0;
// RedisTemplate redisTemplate = redisCache.getRedisTemplate();
RedisTemplate redisTemplate = redisCache.getRedisTemplate();
if (redisTemplate.opsForValue().setIfAbsent(key, 0)) {
redisTemplate.expire(key, 24, TimeUnit.HOURS);
......@@ -574,15 +679,20 @@ public class SellCouponOrderServiceImpl {
Integer bizType){
CreateOrderRequest request = new CreateOrderRequest();
Integer orderClient = OrderClientType.SAAS.getIndex();
request.setPayChannel(PayChannelType.WECHAT.getIndex().toString());
request.setPayChannelType(PayChannelType.WECHAT.getIndex());
if(UserLoginChannelEnum.ALIPAY.getCode().equals(userLoginInfoDto.getChannel())){
orderClient = OrderClientType.ALIPAY.getIndex();
request.setPayChannel(PayChannelType.ALIPAY.getIndex().toString());
request.setPayChannelType(PayChannelType.ALIPAY.getIndex());
}
if(UserLoginChannelEnum.APP.getCode().equals(userLoginInfoDto.getChannel())){
orderClient = OrderClientType.APP.getIndex();
}
//抖音小程序
if("5".equalsIgnoreCase(channel)) {
if("5".equalsIgnoreCase(userLoginInfoDto.getChannel())) {
request.setPayChannel(PayChannelType.TIKTOKPAY.getIndex().toString());
request.setPayChannelType(PayChannelType.TIKTOKPAY.getIndex());
orderClient = OrderClientType.TIKTOKPAY.getIndex();
}
String partnerId = userLoginInfoDto.getPartnerId();
......@@ -670,10 +780,6 @@ public class SellCouponOrderServiceImpl {
request.setOrderExtended(orderAdapter.saveStoreInfo(storeInfo));
request.setOperator(userLoginInfoDto.getNickName());
request.setAppId(userLoginInfoDto.getWxAppId());
if("5".equalsIgnoreCase(channel)){
request.setPayChannelType(PayChannelType.TIKTOKPAY.getIndex());
}
request.setPayChannel(channel);
return request;
}
......@@ -929,4 +1035,5 @@ public class SellCouponOrderServiceImpl {
return null;
}
}
......@@ -205,4 +205,7 @@ public class OrderExtInfoDto {
private String province;
private Long totalScore;
//抖音支付卖券手机号
private String saleCouponPhone;
}
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