Commit f59a9f20 by fanjiaxin

联调问题处理

parent 4bb14474
Pipeline #71565 passed with stages
in 1 minute 6 seconds
......@@ -390,7 +390,8 @@ public class DrmSharerConfig {
boolean isSuccess = false;
try {
// 设置推客分佣比例
weChatShopSetSharerProductCommissionRequest.handle(sharerAppid, oldBo.getProductId(), null);
weChatShopSetSharerProductCommissionRequest.handle(sharerAppid,
oldBo.getProductId(), null);
isSuccess = true;
} catch (Exception e) {
log.error("设置推客的的分佣类型和比例信息失败", e);
......@@ -406,7 +407,7 @@ public class DrmSharerConfig {
/**
* 保存推客商品分佣记录
*/
private void saveSharerProductCommissionRecord(String sharerAppid, Integer productId,
private void saveSharerProductCommissionRecord(String sharerAppid, String productId,
BigDecimal oldCommissionRatio,
BigDecimal newCommissionRatio,
CommissionChangeOptTypeEnum optTypeEnum,
......@@ -417,7 +418,7 @@ public class DrmSharerConfig {
SharerProductCommissionRecord record = new SharerProductCommissionRecord();
record.setOpenId(loginUserInfo.getOpenId());
record.setSharerAppid(sharerAppid);
record.setProductId(null != productId ? productId.toString() : "");
record.setProductId(productId);
record.setOptType(optTypeEnum.getCode());
record.setOptInfo(oldCommissionRatio.toPlainString() + "&"
+ (null == newCommissionRatio ? "" : newCommissionRatio.toPlainString()));
......@@ -436,7 +437,7 @@ public class DrmSharerConfig {
* 保存推客商品分佣金表
*/
private void saveSharerProductCommissionInfo(String openId,
Integer productId,
String productId,
BigDecimal commissionRatio,
SharerProductCommission.UnsetEnum unsetEnum) {
String sharerAppid = getSharerAppidByOpenId(openId);
......@@ -454,7 +455,7 @@ public class DrmSharerConfig {
sharerProductCommission = new SharerProductCommission();
sharerProductCommission.setOpenId(openId);
sharerProductCommission.setSharerAppid(sharerAppid);
sharerProductCommission.setProductId(productId.toString());
sharerProductCommission.setProductId(productId);
sharerProductCommission.setCommissionRatio(commissionRatio);
sharerProductCommission.setCommissionType(CommissionTypeEnum.PLATFORM.getCode());
sharerProductCommission.setUnset(unsetEnum.getCode());
......
......@@ -21,7 +21,7 @@ public class CommissionSharerProductBO implements Serializable {
/**
* 商品ID
*/
private Integer productId;
private String productId;
/**
* 分佣比例
*/
......
......@@ -34,7 +34,7 @@ public class ProductListVO {
/**
* 商品ID
*/
private Integer productId;
private String productId;
/**
* 商品推广链接
*/
......
......@@ -55,15 +55,15 @@ public class ProductServiceImpl implements IProductService {
.map(item -> {
WeChatPromoteProductDetailVO detailVO = weChatShopPromoteProductDetailRequest.handle(item.getShop_appid(),
item.getProduct_id());
if(null == detailVO){
if (null == detailVO) {
return null;
}
WeChatPromoteProductDetailVO.WeChatPromoteProductVO product = detailVO.getProduct();
if(null == product){
if (null == product) {
return null;
}
WeChatPromoteProductDetailVO.WeChatPromoteProductVO.WeChatPromoteProductInfoVO productInfo = product.getProduct_info();
if(null == productInfo){
if (null == productInfo) {
return null;
}
ProductListVO listVO = new ProductListVO();
......@@ -80,7 +80,7 @@ public class ProductServiceImpl implements IProductService {
BigDecimal commissionRatio = drmSharerConfig.getDefaultCommissionRatio();
// 获取用户信息
LoginUserInfo loginUserInfo = LoginUserContextHolder.get();
if(null != loginUserInfo && StringUtils.isNotBlank(loginUserInfo.getOpenId())){
if (null != loginUserInfo && StringUtils.isNotBlank(loginUserInfo.getOpenId())) {
WeChatSharerListVO sharerListVO = weChatShopSharerListRequest.handle(loginUserInfo.getOpenId(), "", 1);
if (null != sharerListVO && !CollectionUtils.isEmpty(sharerListVO.getSharer_info_list())) {
WeChatSharerInfoVO sharerInfoVO = sharerListVO.getSharer_info_list().get(0);
......@@ -94,7 +94,7 @@ public class ProductServiceImpl implements IProductService {
Integer serviceRatio = null != commissionInfo ? commissionInfo.getService_ratio() : null;
// 佣金=商品价格*服务费率*推客分佣比例,四舍五入保留小数点后两位
BigDecimal commission = null;
if(null != price && null != commissionRatio && null != serviceRatio){
if (null != price && null != commissionRatio && null != serviceRatio) {
commission = price.multiply(new BigDecimal(serviceRatio.toString()))
.multiply(commissionRatio).setScale(2, RoundingMode.HALF_UP);
}
......@@ -102,7 +102,8 @@ public class ProductServiceImpl implements IProductService {
listVO.setShopAppid(item.getShop_appid());
listVO.setProductId(item.getProduct_id());
// 获取推广链接
WeChatPromoteProductLinkVO promoteProductLinkVO = weChatShopPromoteProductLinkRequest.handle(item.getShop_appid(), item.getProduct_id());
WeChatPromoteProductLinkVO promoteProductLinkVO = weChatShopPromoteProductLinkRequest.handle(item.getProduct_id(),
item.getShop_appid());
listVO.setProductUrl(null != promoteProductLinkVO ? promoteProductLinkVO.getShort_link() : null);
return listVO;
})
......
......@@ -42,7 +42,7 @@ public class WeChatShopPromoteProductDetailRequest implements IWeChatRequest {
/**
* 处理
*/
public WeChatPromoteProductDetailVO handle(String shopAppid, Integer productId) {
public WeChatPromoteProductDetailVO handle(String shopAppid, String productId) {
WeChatPromoteProductDetailBO params = WeChatPromoteProductDetailBO.builder()
.plan_type(ProductPlanTypeEnum.OPEN.getCode())
.shop_appid(shopAppid)
......
......@@ -41,10 +41,10 @@ public class WeChatShopPromoteProductLinkRequest implements IWeChatRequest {
/**
* 处理
*/
public WeChatPromoteProductLinkVO handle(String sharerAppid, Integer productId) {
public WeChatPromoteProductLinkVO handle(String productId, String shopAppid) {
WeChatPromoteProductLinkBO params = WeChatPromoteProductLinkBO.builder()
.sharer_appid(sharerAppid)
.product_id(productId)
.shop_appid(shopAppid)
.build();
return weChatRestTemplateHandler.execute(getRequestUrl(), getRequestMethod(), params, WeChatPromoteProductLinkVO.class);
}
......
package com.netease.yanxuan.wx.store.sharer.integration.handler.impl;
import com.alibaba.fastjson.JSON;
import com.netease.yanxuan.wx.store.sharer.integration.config.WeChatConfig;
import com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatApi;
import com.netease.yanxuan.wx.store.sharer.integration.core.WeChatContextHolder;
......@@ -51,4 +52,57 @@ public class WeChatShopPromoteProductListRequest implements IWeChatRequest {
.build();
return weChatRestTemplateHandler.execute(getRequestUrl(), getRequestMethod(), params, WeChatPromoteProductListVO.class);
}
public static void main(String[] args) {
String resultJson = "{\n" +
" \"errcode\": 0,\n" +
" \"errmsg\": \"ok\",\n" +
" \"product_list\": [\n" +
" {\n" +
" \"product_id\": \"10000032169520\",\n" +
" \"shop_appid\": \"wxdad237db7677c305\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000157865162\",\n" +
" \"shop_appid\": \"wx015b4279a9e8f6fa\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000018293357\",\n" +
" \"shop_appid\": \"wxe0aa3c442f854635\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000129786349\",\n" +
" \"shop_appid\": \"wx55ea53cbc4855c21\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000168454112\",\n" +
" \"shop_appid\": \"wxf69920284f28bbe3\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000029788412\",\n" +
" \"shop_appid\": \"wx31f74421a0acf076\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000143496444\",\n" +
" \"shop_appid\": \"wx15aa8d178f9946ca\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000134193908\",\n" +
" \"shop_appid\": \"wx2e8388eeeea714de\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000144234386\",\n" +
" \"shop_appid\": \"wxd4c232e8fe49f909\"\n" +
" },\n" +
" {\n" +
" \"product_id\": \"10000076193764\",\n" +
" \"shop_appid\": \"wx66b0a1ddf47badf0\"\n" +
" }\n" +
" ],\n" +
" \"next_key\": \"CAoQChoWChQxMDAwMDAzMjk3MjY4MzM3NDMzMw==\"\n" +
"}";
WeChatPromoteProductListVO productListVO = JSON.parseObject(resultJson, WeChatPromoteProductListVO.class);
System.err.println(JSON.toJSONString(productListVO));
}
}
......@@ -41,7 +41,7 @@ public class WeChatShopSetSharerProductCommissionRequest implements IWeChatReque
/**
* 处理
*/
public WeChatCoreVO handle(String sharerAppid, Integer productId, String commissionRatio) {
public WeChatCoreVO handle(String sharerAppid, String productId, String commissionRatio) {
WeChatSetSharerProductCommissionBO params = WeChatSetSharerProductCommissionBO.builder()
.sharer_appid(sharerAppid)
.product_id(productId)
......
......@@ -22,7 +22,7 @@ public class WeChatPromoteProductDetailBO implements Serializable {
/**
* 商品id
*/
private Integer product_id;
private String product_id;
/**
* 商品的计划类型 1:定向计划 2:公开计划
*/
......
......@@ -26,7 +26,7 @@ public class WeChatPromoteProductLinkBO implements Serializable {
/**
* 商品 id,如果使用该参数,需要传入shop_appid
*/
private Integer product_id;
private String product_id;
/**
* 商品所属店铺 appid
*/
......
......@@ -22,7 +22,7 @@ public class WeChatSetSharerProductCommissionBO implements Serializable {
/**
* 商品列表
*/
private Integer product_id;
private String product_id;
/**
* 平台分佣时的分佣比例,范围为【100000 - 900000】,代表【10%-90%】
*/
......
......@@ -29,7 +29,7 @@ public class WeChatPromoteProductListVO extends WeChatCoreVO {
/**
* 商品ID
*/
private Integer product_id;
private String product_id;
/**
* 商品所属店铺 appid
......
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