Commit 4a8cd32c by ping.wu

商品券锁定失效校验换接口

parent 7a35f90a
......@@ -5,8 +5,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CheckSpqInfoRequestDto {
private String partnerId;
private String storeId;
......@@ -15,4 +13,28 @@ public class CheckSpqInfoRequestDto {
*/
private String couponCode;
private String menuType;
private String userId;
private String channel;
public CheckSpqInfoRequestDto() {
}
public CheckSpqInfoRequestDto(String partnerId, String storeId, String couponCode, String menuType) {
this.partnerId = partnerId;
this.storeId = storeId;
this.couponCode = couponCode;
this.menuType = menuType;
}
public CheckSpqInfoRequestDto(String partnerId, String storeId, String couponCode, String menuType, String userId, String channel) {
this.partnerId = partnerId;
this.storeId = storeId;
this.couponCode = couponCode;
this.menuType = menuType;
this.userId = userId;
this.channel = channel;
}
}
......@@ -85,6 +85,8 @@ public enum ResponseResult {
SHOPPING_CART_SHOP_ID_NOT_EMPTY("44019", "门店编号不能为空"),
SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP("44020", "券不适用于该门店"),
SHOPPING_CART_SEAT_EMPTY("44020", "键位为空"),
SHOPPING_CART_COUPON_CAN_NOT_USE("44021", "商品券不可用"),
SHOPPING_CART_PRODUCT_CAN_NOT_USE("44022", "商品不可用"),
/**
* 订单状态码
......
......@@ -57,15 +57,6 @@ public interface CouponService {
* @return
*/
List<GetCouponDetailResponseDto.Details> getMemberCoupons(String partnerId, String storeId, List<String> codes);
/**
* 获取麦咖啡卡券详情
*
* @param requestVo
* @return
*/
GetCouponDetailResponseDto getMCCafeMemberCoupon(GetMemberCouponRequestVo requestVo);
/**
* 同步券到会员卡包(投放会员卡包)
*
......@@ -86,12 +77,6 @@ public interface CouponService {
* 获取卡券服务商户密钥
*/
String getAppSecret(String partnerId);
/**
* 获取卡券服务麦咖啡商户密钥
*/
String getMCCafeAppSecret(String partnerId);
/**
* 通过code校验券是否存在,返回商品券信息pid、price、code
*
......@@ -100,6 +85,12 @@ public interface CouponService {
*/
CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto);
/**
* 麦咖啡商品券校验
*/
CheckSpqInfoResponseDto checkGoodsCoupon(CheckSpqInfoRequestDto requestDto);
/**
* 领券
*
......
......@@ -38,9 +38,12 @@ import cn.freemud.service.CommonService;
import cn.freemud.service.CouponService;
import cn.freemud.service.ItemService;
import cn.freemud.service.UserService;
import cn.freemud.service.impl.mcoffee.entity.CouponCodeVo;
import cn.freemud.service.impl.mcoffee.entity.MCCafeCouponRequest;
import cn.freemud.service.thirdparty.*;
import cn.freemud.utils.*;
import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.couponcenter.offline.response.CouponQueryResponse;
import com.freemud.card.sdk.comm.Finals;
import com.freemud.card.sdk.comm.SignUtil;
import com.freemud.card.sdk.service.CouponAvailableService;
......@@ -61,6 +64,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -74,8 +78,6 @@ import java.util.stream.Collectors;
public class CouponServiceImpl implements CouponService {
private final Gson gson = new Gson();
//@Autowired
//private MemberProductClient memberProductClient;
@Autowired
private CustomerExtendClient customerExtendClient;
@Autowired
......@@ -85,13 +87,7 @@ public class CouponServiceImpl implements CouponService {
@Autowired
private CouponAdapter couponAdapter;
@Autowired
private StoreAdapter storeAdapter;
@Autowired
private CouponOnlineClient couponOnlineClient;
@Autowired
private CouponOnlineMCCafeClient couponOnlineMCCafeClient;
@Autowired
private CouponAvailableService couponAvailableService;
@Value("${coupon.app.id}")
private String appid;
@Autowired
......@@ -99,12 +95,6 @@ public class CouponServiceImpl implements CouponService {
@Autowired
private CardBinClient cardBinClient;
@Autowired
private CardBinMCCafeClient cardBinMCCafeClient;
@Autowired
private StoreItemClient storeItemClient;
@Autowired
private StoreItemAdapter storeItemAdapter;
@Autowired
private CouponServiceImpl couponService;
@Autowired
private GetCouponService getCouponService;
......@@ -118,6 +108,26 @@ public class CouponServiceImpl implements CouponService {
private String couponPartnerId;
@Autowired
private CouponAdapterClient couponAdaptClient;
@Autowired
private CouponClient mCoffeeCouponClient;
@Autowired
private ActivityClient activityClient;
private final static String application = "isaas";
/**
* 券来源:
* 60:wechat
* 61:xinmeida
* 62:tmall
* 63:isaas
*/
private final static String SOURCE_FLAG = "63";
private final static String FORMAT_YYYY_DD_23_59_59 = "yyyy-MM-dd 23:59:59";
/**
* 获取优惠券列表
......@@ -258,32 +268,6 @@ public class CouponServiceImpl implements CouponService {
return null;
}
@Override
public GetCouponDetailResponseDto getMCCafeMemberCoupon(GetMemberCouponRequestVo requestVo) {
log.info("getMemberCoupon:" + gson.toJson(requestVo));
//TODO 券详情查券服务
Map<String, String> map = new TreeMap<String, String>();
if (StringUtils.isBlank(requestVo.getPartnerId()) || StringUtils.isBlank(requestVo.getCouponCode())) {
return null;
}
map.put(Finals.CODES, requestVo.getCouponCode());
map.put(Finals.PARTNER_ID, requestVo.getPartnerId());
map.put(Finals.MERCHANT_ID, requestVo.getPartnerId());
map.put(Finals.ACTION, "code.allDetails");
// 券码接口新增参数:组织机构(多个用英文逗号分离)
String channelIds = commonService.getOrgIdsAsString(requestVo.getPartnerId(), requestVo.getStoreId());
map.put(Finals.CHANNEL_CODE_LIST, channelIds);
String appSecret = getMCCafeAppSecret(requestVo.getPartnerId());
String sign = SignUtil.createMD5Sign(map, appSecret);
map.put(Finals.SIGN, sign);
GetCouponDetailResponseDto responseDto = couponOnlineMCCafeClient.getMCCafeCouponDetails(map);
LogUtil.info("couponOnlineClient.getCouponDetails****", map, gson.toJson(responseDto));
if (ResponseCodeConstant.RESPONSE_SUCCESS_1.equals(responseDto.getResult())) {
return responseDto;
}
return null;
}
/**
* 批次查询
*/
......@@ -339,22 +323,6 @@ public class CouponServiceImpl implements CouponService {
return appSecret;
}
@Override
public String getMCCafeAppSecret(String partnerId) {
// 获取券服务的密钥
String couponAppSecret = RedisUtil.getCouponAppSecret(partnerId);
String appSecret = redisCache.getValue(couponAppSecret);
if (StringUtils.isBlank(appSecret)) {
GetAppKeyResponseDto getAppKeyResponseDto = cardBinMCCafeClient.getMCCafeAppKey(GetAppKeyRequestDto.builder().partnerId(partnerId).appId(appid).build());
if (Objects.equals(String.valueOf(getAppKeyResponseDto.getStatusCode()), ResponseResult.SUCCESS.getCode())
&& getAppKeyResponseDto.getData() != null) {
redisCache.save(couponAppSecret, getAppKeyResponseDto.getData().getAppKey());
appSecret = getAppKeyResponseDto.getData().getAppKey();
}
}
return appSecret;
}
/**
* key = 活动code , value = 返回是否匹配点餐方式
*/
......@@ -679,21 +647,69 @@ public class CouponServiceImpl implements CouponService {
return dto;
}
@Autowired
private ActivityClient activityClient;
private final static String application = "isaas";
/**
* 券来源:
* 60:wechat
* 61:xinmeida
* 62:tmall
* 63:isaas
* 麦咖啡券查询
* @param requestDto
* @return
*/
private final static String SOURCE_FLAG = "63";
@Override
public CheckSpqInfoResponseDto checkGoodsCoupon(CheckSpqInfoRequestDto requestDto) {
log.info("checkGoodsCoupon****" + gson.toJson(requestDto));
String partnerId = requestDto.getPartnerId();
String couponCode = requestDto.getCouponCode();
String storeId = requestDto.getStoreId();
MCCafeCouponRequest mcCafeCouponRequest =new MCCafeCouponRequest();
mcCafeCouponRequest.setVer(Integer.valueOf(Version.VERSION_1));
mcCafeCouponRequest.setReqtype(0);
mcCafeCouponRequest.setPartnerId(Integer.parseInt(partnerId));
mcCafeCouponRequest.setStore_id(storeId);
mcCafeCouponRequest.setStation_id("1");
mcCafeCouponRequest.setOperator_id(requestDto.getUserId());
String channel = "mocoffee_wx";
if("2".equals(requestDto.getChannel())){
channel = "mocoffee_zfb";
}
mcCafeCouponRequest.setChannel(channel);
List<CouponCodeVo> couponCodeVos = Arrays.asList(new CouponCodeVo(couponCode));
mcCafeCouponRequest.setCouponlist(couponCodeVos);
mcCafeCouponRequest.setSign("skip");
CouponQueryResponse response = mCoffeeCouponClient.query(mcCafeCouponRequest);
LogUtil.info("mCoffeeCouponClient.query", gson.toJson(mcCafeCouponRequest), gson.toJson(response));
if (response == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(response.getStatusCode())
|| response.getCodeInfo() == null || CollectionUtils.isEmpty(response.getCodeInfo().getProducts())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE);
}
String skuId = response.getCodeInfo().getMcd_productCode();
//券返回的商品id
List<String> skuIds = Lists.newArrayList();
skuIds.add(String.valueOf(skuId));
// 通过skuid查询spuid
Map<String, GetProductsVo> productsVoMap = itemService.getProducts(skuIds, partnerId, storeId , requestDto.getMenuType());
GetProductsVo productsVo = productsVoMap.get(skuId);
if (null == productsVo || !Objects.equals(productsVo.getStatus(), StoreItemStatus.PUT_ON_SALE.getCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_PRODUCT_CAN_NOT_USE);
}
CheckSpqInfoResponseDto dto = new CheckSpqInfoResponseDto();
dto.setCouponCode(couponCode);
dto.setActiveCode(response.getCodeInfo().getAct_id());
dto.setCouponName(response.getCodeInfo().getAct_name());
dto.setActivityName(response.getCodeInfo().getAct_name());
dto.setPrice(productsVo.getFinalPrice());
dto.setSpuId(productsVo.getSpuId());
dto.setSpuName(productsVo.getSkuName());
dto.setSkuId(productsVo.getSkuId());
dto.setSkuName(StringUtils.isNotBlank(productsVo.getSkuName()) ? productsVo.getSkuName() : productsVo.getSpuName());
dto.setPicture(productsVo.getSpuPicture());
log.info("dto***" + dto);
return dto;
}
private final static String FORMAT_YYYY_DD_23_59_59 = "yyyy-MM-dd 23:59:59";
/**
* 领券
......
......@@ -114,13 +114,14 @@ public class ShoppingCartMCoffeeServiceImpl {
String receiveId = addShoppingCartGoodsRequestVo.getReceiveId();
Integer operationType = addShoppingCartGoodsRequestVo.getOperationType();
String couponCode = addShoppingCartGoodsRequestVo.getCouponCode();
String channel = assortmentCustomerInfoVo.getChannel();
String spuId2 = spuId;
List<Long> productIds = new ArrayList<>();
//商品券校验
if (spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
couponCode = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(),userId,channel);
goodsId = spuId2;
}
productIds.add(Long.parseLong(goodsId));
......@@ -161,13 +162,13 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
private String validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds, String menuType) {
private String validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds, String menuType,String userId,String channel) {
String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType,userId,channel);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkGoodsCoupon(checkSpqInfoRequestDto);
if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE);
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId();
......
......@@ -58,14 +58,9 @@ public class CouponDiscountCalculation {
@Autowired
private CommonService commonService;
@Autowired
// private CouponAvailableService couponAvailableService;
private CouponClient mCoffeeCouponClient;
@Autowired
private CouponAdapter couponAdapter;
// @Autowired
// private RedisCache redisCache;
// @Autowired
// private CardBinClient cardBinClient;
@Value("${coupon.app.id}")
private String appid;
......
package cn.freemud.service.impl.mcoffee.entity;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: CouponCodeVo
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 18:43
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class CouponCodeVo {
private String coupon;
public CouponCodeVo() {
}
public CouponCodeVo(String coupon) {
this.coupon = coupon;
}
}
package cn.freemud.service.impl.mcoffee.entity;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCCafeCouponRequest
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 15:23
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class MCCafeCouponRequest {
/**
* 接口版本
*/
private Integer ver;
/**
* kdg.Y 开个店渠道且需要回调三方
* kgd.N 开个店渠道且不需要回调三方
*/
// private String appFlag;
/**
* 需要查询的券码,仅供查询券使用
*/
// private String coupon;
/**
* 请求操作类型,0是卡券查询,2是卡券交易查询,3是卡券冲正,71是卡券核销
*/
private Integer reqtype;
/**
* 商家门店号
*/
private String store_id;
/**
* 子品牌 ID 可以为空
*/
// private String organize_id;
/**
* 组织机构ID(注意和channle的区别)
*/
// private List<String> channel_ids;
/**
* 组织机构code(注意和channle的区别)
*/
// private List<String> channel_codes;
/**
* 商家POS机编号
*/
private String station_id;
/**
* 营业员编号
*/
private String operator_id;
/**
* 商户编号
*/
private Integer partnerId;
// private Integer checkValue;
// private Integer clientReqCount;
/**
* POS交易序号
*/
// private String trans_id;
/**
* 营业日
*/
// private String business_date;
/**
* 优惠券列表
*/
// private List<MCCafeTransactionVo> transactions;
/**
* 签名
*/
private String sign;
/**
* 追加key
*/
// private String appSecret;
// private String openid;
// private String transactionuuid;
// private String status;
// private Boolean isManual;
//核销渠道,麦咖啡微信小程序就传 mocoffee_wx,麦咖啡支付宝小程序就传 mocoffee_zfb
private String channel;
private List<CouponCodeVo> couponlist;
}
package cn.freemud.service.impl.mcoffee.entity;
import lombok.Data;
import java.math.BigDecimal;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCCafeProductRedeemVo
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 15:25
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class MCCafeProductRedeemVo {
private String pid;
/**
* 第三方商品编号 有的话会校验
*/
private String customer_code;
private Integer seq;
private Integer consume_num;
private Integer gid;
private Integer DiscountAmount;
private String brand_code;
private String pcata;
private BigDecimal redeem_price;
//键位商品编号
private String keyProductCode;
}
package cn.freemud.service.impl.mcoffee.entity;
import lombok.Data;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCCafeTransactionVo
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 15:24
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class MCCafeTransactionVo {
private Integer pay_amount;
private String code;
private String ebcode;
/**
* 优惠总金额,由第三方计算,单位分
*/
private Long totalAmount;
private List<MCCafeProductRedeemVo> products;
}
package cn.freemud.service.impl.mcoffee.entity;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MccofeBaseResponse
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 19:15
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class MccofeBaseResponse {
public Integer statusCode;
public String msg;
public String act_id;
public Integer ver = 1;
}
package cn.freemud.service.impl.mcoffee.entity;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: McdNetBatchQueryResponse
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/9/10 19:28
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
public class McdNetBatchQueryResponse {
// private List<Coupon> couponList;
// /**
// * 响应描述
// */
// private String content;
//
//
// private Integer statusCode;
// private String msg;
// private Integer couponType;
// private String code;
// private McdNetCouponInfoRespDto codeInfo;
}
......@@ -15,6 +15,8 @@ package cn.freemud.service.thirdparty;
import cn.freemud.entities.dto.*;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableReq;
import cn.freemud.service.impl.mcoffee.entity.CouponAvailableResp;
import cn.freemud.service.impl.mcoffee.entity.MCCafeCouponRequest;
import com.freemud.application.sdk.api.couponcenter.offline.response.CouponQueryResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -24,36 +26,36 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping(produces = {"application/json;charset=UTF-8"})
public interface CouponClient {
/**
* 领取优惠券
*/
@PostMapping("/coupon/create")
CouponBaseResponseDto create(CouponCreateDto couponCreateDto);
// /**
// * 领取优惠券
// */
// @PostMapping("/coupon/create")
// CouponBaseResponseDto create(CouponCreateDto couponCreateDto);
/**
* 查询用户优惠券列表
*/
@PostMapping("/coupon/list")
CouponListResponseDto list(CouponListDto couponListDto);
// /**
// * 查询用户优惠券列表
// */
// @PostMapping("/coupon/list")
// CouponListResponseDto list(CouponListDto couponListDto);
/**
* 优惠券核销
*/
@Deprecated
@PostMapping("/coupon/verification")
CouponBaseResponseDto verification(CouponVerificationDto couponVerificationDto);
// /**
// * 优惠券核销
// */
// @Deprecated
// @PostMapping("/coupon/verification")
// CouponBaseResponseDto verification(CouponVerificationDto couponVerificationDto);
/**
* 核销验证接口
*/
@PostMapping("/check/user/coupon")
CouponBaseResponseDto verifyCheck(VerifyCheckRequestDto verifyCheckRequestDto);
// /**
// * 核销验证接口
// */
// @PostMapping("/check/user/coupon")
// CouponBaseResponseDto verifyCheck(VerifyCheckRequestDto verifyCheckRequestDto);
/**
* 核销成功通知接口
*/
@PostMapping("/coupon/verification/notice")
CouponBaseResponseDto verifyNotice(VerifyNoticeRequestDto verifyNoticeRequestDto);
// /**
// * 核销成功通知接口
// */
// @PostMapping("/coupon/verification/notice")
// CouponBaseResponseDto verifyNotice(VerifyNoticeRequestDto verifyNoticeRequestDto);
/**
* 麦咖啡校验券是否可用
......@@ -61,5 +63,10 @@ public interface CouponClient {
@PostMapping("/mccafe/getCouponsAvailable")
CouponAvailableResp getCouponsAvailable(CouponAvailableReq req);
/**
* 麦咖啡校验券
*/
@PostMapping("/mccafe/batchQuery")
CouponQueryResponse query(MCCafeCouponRequest mcCafeCouponRequest);
}
package cn.freemud.service.thirdparty;
import cn.freemud.entities.dto.CouponCodeResponseDto;
import cn.freemud.entities.dto.CouponCodeVerificationMCCafeDto;
import com.freemud.application.sdk.api.couponcenter.offline.response.CouponRedeemResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@FeignClient(name = "COUPONMCCafe",url="http://coupon-api-gateway-koderover-dev-coupon.api-ingress.sandload.cn")
public interface CouponOfflineMCCafeClient {
@PostMapping("/mccafe/redeem")
CouponRedeemResponse redeem(CouponCodeVerificationMCCafeDto couponCodeVerificationMCCafeDto);
@PostMapping("/mccafe/cancelRedeem")
CouponRedeemResponse cancelRedeem(CouponCodeVerificationMCCafeDto couponCodeVerificationMCCafeDto);
@PostMapping("/mccafe/query")
CouponRedeemResponse query(CouponCodeVerificationMCCafeDto couponCodeVerificationMCCafeDto);
@PostMapping("/mccafe/lock")
CouponRedeemResponse lock(CouponCodeVerificationMCCafeDto couponCodeVerificationMCCafeDto);
@PostMapping("/mccafe/unlock")
CouponRedeemResponse unlock(CouponCodeVerificationMCCafeDto couponCodeVerificationMCCafeDto);
}
package cn.freemud.service.thirdparty;
//import cn.freemud.constant.IgnoreFeignLogAnnotation;
import cn.freemud.entities.dto.GetCouponDetailResponseDto;
import cn.freemud.interceptor.FormSupportConfig;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Map;
//@IgnoreFeignLogAnnotation
@FeignClient(name = "COUPONOLINEMCCafe", url = "fffff", configuration = FormSupportConfig.class)
public interface CouponOnlineMCCafeClient {
/**
* 查询券详情
*/
@PostMapping(value = "/mccafe/code_v4", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}
)
GetCouponDetailResponseDto getMCCafeCouponDetails(@RequestBody Map<String, ?> map);
}
......@@ -45,82 +45,82 @@ public class CouponClientTest {
* "ver": 1
* }
*/
@Test
public void create () {
CouponCreateDto couponCreateDto = new CouponCreateDto();
couponCreateDto.setVer(Version.VERSION_1);
couponCreateDto.setUserId("115381881188636164");
// 4933
couponCreateDto.setActivityCodes(Arrays.asList("5016"));
couponCreateDto.setPartnerCode("1864");
couponCreateDto.setMobile("15754070662");
System.out.println(JSON.toJSON(couponCreateDto));
CouponBaseResponseDto responseDto = couponClient.create(couponCreateDto);
System.out.println(JSON.toJSON(responseDto));
}
@Test
public void list() {
CouponListDto couponListDto = new CouponListDto();
couponListDto.setPartnerCode("1809");
couponListDto.setUserId("12333");
couponListDto.setVer(Version.VERSION_1);
// 优惠券类型,0:满减券 1:代金券
couponListDto.setType(1);
System.out.println(JSON.toJSON(couponListDto));
CouponListResponseDto couponListResponseDto = couponClient.list(couponListDto);
System.out.println(JSON.toJSON(couponListResponseDto));
List<CouponListResponseDto.CouponBean> filterList = couponListResponseDto.getResult().stream().filter(a -> Arrays.stream(a.getStoreId().split(",")).anyMatch(Predicate.isEqual("000100"))).collect(Collectors.toList());
Map<String, CouponListResponseDto.CouponBean> couponBeanMap = filterList.stream().collect(Collectors.toMap(CouponListResponseDto.CouponBean::getCouponCode, a -> a,(k1, k2)->k1));
System.out.println(couponBeanMap);
}
@Test
public void verification() {
CouponVerificationDto couponVerificationDto = new CouponVerificationDto();
couponVerificationDto.setVer(Version.VERSION_1);
couponVerificationDto.setUserId("115381146196928724");
couponVerificationDto.setStoreId("1014");
couponVerificationDto.setPartnerCode("1864");
// 126065756376018730
couponVerificationDto.setOrderId("126082012916363042");
// 108077749714629
couponVerificationDto.setCodes(Arrays.asList("108075569721930"));
System.out.println(JSON.toJSON(couponVerificationDto));
CouponBaseResponseDto couponBaseResponseDto = couponClient.verification(couponVerificationDto);
System.out.println(JSON.toJSON(couponBaseResponseDto));
}
@Test
public void checkTest() {
VerifyCheckRequestDto verifyCheckRequestDto = new VerifyCheckRequestDto();
verifyCheckRequestDto.setCouponCodes(Arrays.asList("88600017956864226138"));
verifyCheckRequestDto.setPartnerCode("1864");
verifyCheckRequestDto.setUserId("1");
verifyCheckRequestDto.setVer(Integer.valueOf(Version.VERSION_1));
System.out.println(JSON.toJSONString(verifyCheckRequestDto));
CouponBaseResponseDto couponBaseResponseDto = couponClient.verifyCheck(verifyCheckRequestDto);
System.out.println(JSON.toJSONString(couponBaseResponseDto));
}
@Test
public void noticeTest() {
VerifyNoticeRequestDto verifyNoticeRequestDto = new VerifyNoticeRequestDto();
verifyNoticeRequestDto.setVer(Integer.valueOf(Version.VERSION_1));
verifyNoticeRequestDto.setCouponCode("88600017956864226138");
verifyNoticeRequestDto.setOrderId("1");
verifyNoticeRequestDto.setPartnerCode("1864");
verifyNoticeRequestDto.setStoreId("1002");
verifyNoticeRequestDto.setUserId("1");
System.out.println(JSON.toJSONString(verifyNoticeRequestDto));
CouponBaseResponseDto couponBaseResponseDto = couponClient.verifyNotice(verifyNoticeRequestDto);
System.out.println(JSON.toJSONString(couponBaseResponseDto));
}
// @Test
// public void create () {
// CouponCreateDto couponCreateDto = new CouponCreateDto();
// couponCreateDto.setVer(Version.VERSION_1);
// couponCreateDto.setUserId("115381881188636164");
// // 4933
// couponCreateDto.setActivityCodes(Arrays.asList("5016"));
// couponCreateDto.setPartnerCode("1864");
// couponCreateDto.setMobile("15754070662");
// System.out.println(JSON.toJSON(couponCreateDto));
// CouponBaseResponseDto responseDto = couponClient.create(couponCreateDto);
// System.out.println(JSON.toJSON(responseDto));
// }
// @Test
// public void list() {
// CouponListDto couponListDto = new CouponListDto();
// couponListDto.setPartnerCode("1809");
// couponListDto.setUserId("12333");
// couponListDto.setVer(Version.VERSION_1);
// // 优惠券类型,0:满减券 1:代金券
// couponListDto.setType(1);
//
// System.out.println(JSON.toJSON(couponListDto));
// CouponListResponseDto couponListResponseDto = couponClient.list(couponListDto);
// System.out.println(JSON.toJSON(couponListResponseDto));
//
//
// List<CouponListResponseDto.CouponBean> filterList = couponListResponseDto.getResult().stream().filter(a -> Arrays.stream(a.getStoreId().split(",")).anyMatch(Predicate.isEqual("000100"))).collect(Collectors.toList());
//
// Map<String, CouponListResponseDto.CouponBean> couponBeanMap = filterList.stream().collect(Collectors.toMap(CouponListResponseDto.CouponBean::getCouponCode, a -> a,(k1, k2)->k1));
// System.out.println(couponBeanMap);
//
// }
// @Test
// public void verification() {
// CouponVerificationDto couponVerificationDto = new CouponVerificationDto();
// couponVerificationDto.setVer(Version.VERSION_1);
// couponVerificationDto.setUserId("115381146196928724");
// couponVerificationDto.setStoreId("1014");
// couponVerificationDto.setPartnerCode("1864");
// // 126065756376018730
// couponVerificationDto.setOrderId("126082012916363042");
// // 108077749714629
// couponVerificationDto.setCodes(Arrays.asList("108075569721930"));
// System.out.println(JSON.toJSON(couponVerificationDto));
// CouponBaseResponseDto couponBaseResponseDto = couponClient.verification(couponVerificationDto);
// System.out.println(JSON.toJSON(couponBaseResponseDto));
// }
// @Test
// public void checkTest() {
// VerifyCheckRequestDto verifyCheckRequestDto = new VerifyCheckRequestDto();
// verifyCheckRequestDto.setCouponCodes(Arrays.asList("88600017956864226138"));
// verifyCheckRequestDto.setPartnerCode("1864");
// verifyCheckRequestDto.setUserId("1");
// verifyCheckRequestDto.setVer(Integer.valueOf(Version.VERSION_1));
// System.out.println(JSON.toJSONString(verifyCheckRequestDto));
// CouponBaseResponseDto couponBaseResponseDto = couponClient.verifyCheck(verifyCheckRequestDto);
// System.out.println(JSON.toJSONString(couponBaseResponseDto));
// }
// @Test
// public void noticeTest() {
// VerifyNoticeRequestDto verifyNoticeRequestDto = new VerifyNoticeRequestDto();
// verifyNoticeRequestDto.setVer(Integer.valueOf(Version.VERSION_1));
// verifyNoticeRequestDto.setCouponCode("88600017956864226138");
// verifyNoticeRequestDto.setOrderId("1");
// verifyNoticeRequestDto.setPartnerCode("1864");
// verifyNoticeRequestDto.setStoreId("1002");
// verifyNoticeRequestDto.setUserId("1");
// System.out.println(JSON.toJSONString(verifyNoticeRequestDto));
// CouponBaseResponseDto couponBaseResponseDto = couponClient.verifyNotice(verifyNoticeRequestDto);
// System.out.println(JSON.toJSONString(couponBaseResponseDto));
// }
@Test
public void verificationTest() {
......
......@@ -173,22 +173,22 @@ public class CouponServiceTest {
/**
* 批量券详情查询code_v4
*/
@Test
public void couponCodeV4() {
GetMemberCouponRequestVo getMemberCouponRequestVo = new GetMemberCouponRequestVo();
getMemberCouponRequestVo.setCouponCode("");
getMemberCouponRequestVo.setPartnerId("");
getMemberCouponRequestVo.setStoreId("");
GetCouponDetailResponseDto responseDto = couponService.getMCCafeMemberCoupon(getMemberCouponRequestVo);
System.out.println(JSON.toJSONString(responseDto));
}
@Test
public String getAppSecret(String partner) {
String appSecret = couponService.getMCCafeAppSecret(partner);
System.out.println(appSecret);
return appSecret;
}
// @Test
// public void couponCodeV4() {
// GetMemberCouponRequestVo getMemberCouponRequestVo = new GetMemberCouponRequestVo();
// getMemberCouponRequestVo.setCouponCode("");
// getMemberCouponRequestVo.setPartnerId("");
// getMemberCouponRequestVo.setStoreId("");
// GetCouponDetailResponseDto responseDto = couponService.getMCCafeMemberCoupon(getMemberCouponRequestVo);
// System.out.println(JSON.toJSONString(responseDto));
// }
// @Test
// public String getAppSecret(String partner) {
// String appSecret = couponService.getMCCafeAppSecret(partner);
// System.out.println(appSecret);
// return appSecret;
// }
......
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