Authored by gemingdan

skn返佣-前台

@@ -2,8 +2,10 @@ package com.yoho.unions.dal; @@ -2,8 +2,10 @@ package com.yoho.unions.dal;
2 2
3 import com.yoho.service.model.union.request.UnionShareRebateReqBo; 3 import com.yoho.service.model.union.request.UnionShareRebateReqBo;
4 import com.yoho.unions.dal.model.UnionShareRebateBrand; 4 import com.yoho.unions.dal.model.UnionShareRebateBrand;
  5 +import org.apache.ibatis.annotations.Param;
5 6
6 import java.util.List; 7 import java.util.List;
  8 +import java.util.Set;
7 9
8 public interface UnionShareRebateBrandMapper { 10 public interface UnionShareRebateBrandMapper {
9 int deleteByPrimaryKey(Integer id); 11 int deleteByPrimaryKey(Integer id);
@@ -15,6 +17,7 @@ public interface UnionShareRebateBrandMapper { @@ -15,6 +17,7 @@ public interface UnionShareRebateBrandMapper {
15 UnionShareRebateBrand selectByPrimaryKey(Integer id); 17 UnionShareRebateBrand selectByPrimaryKey(Integer id);
16 UnionShareRebateBrand selectByBrand(Integer brand); 18 UnionShareRebateBrand selectByBrand(Integer brand);
17 List<UnionShareRebateBrand> selectListByCon(UnionShareRebateReqBo req); 19 List<UnionShareRebateBrand> selectListByCon(UnionShareRebateReqBo req);
  20 + List<UnionShareRebateBrand> selectListByBrands(@Param("brands")Set<Integer> brands);
18 int selectCountByCon(UnionShareRebateReqBo req); 21 int selectCountByCon(UnionShareRebateReqBo req);
19 22
20 int updateByPrimaryKeySelective(UnionShareRebateBrand record); 23 int updateByPrimaryKeySelective(UnionShareRebateBrand record);
@@ -5,6 +5,7 @@ import com.yoho.unions.dal.model.UnionShareRebateSkn; @@ -5,6 +5,7 @@ import com.yoho.unions.dal.model.UnionShareRebateSkn;
5 import org.apache.ibatis.annotations.Param; 5 import org.apache.ibatis.annotations.Param;
6 6
7 import java.util.List; 7 import java.util.List;
  8 +import java.util.Set;
8 9
9 public interface UnionShareRebateSknMapper { 10 public interface UnionShareRebateSknMapper {
10 int deleteByPrimaryKey(Integer id); 11 int deleteByPrimaryKey(Integer id);
@@ -16,7 +17,7 @@ public interface UnionShareRebateSknMapper { @@ -16,7 +17,7 @@ public interface UnionShareRebateSknMapper {
16 UnionShareRebateSkn selectByPrimaryKey(Integer id); 17 UnionShareRebateSkn selectByPrimaryKey(Integer id);
17 UnionShareRebateSkn selectBySkn(Integer skn); 18 UnionShareRebateSkn selectBySkn(Integer skn);
18 List<UnionShareRebateSkn> selectListByCon(UnionShareRebateReqBo req); 19 List<UnionShareRebateSkn> selectListByCon(UnionShareRebateReqBo req);
19 - List<UnionShareRebateSkn> selectListBySkns(@Param("skns")List<Integer> skns); 20 + List<UnionShareRebateSkn> selectListBySkns(@Param("skns")Set<Integer> skns);
20 int selectCountByCon(UnionShareRebateReqBo req); 21 int selectCountByCon(UnionShareRebateReqBo req);
21 22
22 int updateByPrimaryKeySelective(UnionShareRebateSkn record); 23 int updateByPrimaryKeySelective(UnionShareRebateSkn record);
@@ -45,6 +45,15 @@ @@ -45,6 +45,15 @@
45 <if test="state != null"> and state = #{state,jdbcType=INTEGER}</if> 45 <if test="state != null"> and state = #{state,jdbcType=INTEGER}</if>
46 limit #{start},#{size} 46 limit #{start},#{size}
47 </select> 47 </select>
  48 + <select id="selectListByBrands" resultMap="BaseResultMap" >
  49 + select
  50 + <include refid="Base_Column_List" />
  51 + from union_share_rebate_brand
  52 + where brand in
  53 + <foreach collection="brands" item="brand" open="(" separator="," close=")">
  54 + #{brand}
  55 + </foreach>
  56 + </select>
48 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 57 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
49 delete from union_share_rebate_brand 58 delete from union_share_rebate_brand
50 where id = #{id,jdbcType=INTEGER} 59 where id = #{id,jdbcType=INTEGER}
@@ -48,6 +48,15 @@ @@ -48,6 +48,15 @@
48 <if test="state != null"> and state = #{state,jdbcType=INTEGER}</if> 48 <if test="state != null"> and state = #{state,jdbcType=INTEGER}</if>
49 limit #{start},#{size} 49 limit #{start},#{size}
50 </select> 50 </select>
  51 + <select id="selectListBySkns" resultMap="BaseResultMap" >
  52 + select
  53 + <include refid="Base_Column_List" />
  54 + from union_share_rebate_skn
  55 + where skn in
  56 + <foreach collection="skns" item="items" separator="," open="(" close=")">
  57 + #{items}
  58 + </foreach>
  59 + </select>
51 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 60 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
52 delete from union_share_rebate_skn 61 delete from union_share_rebate_skn
53 where id = #{id,jdbcType=INTEGER} 62 where id = #{id,jdbcType=INTEGER}
@@ -114,23 +114,23 @@ public class UnionRebateRest { @@ -114,23 +114,23 @@ public class UnionRebateRest {
114 } 114 }
115 115
116 /** 116 /**
117 - * 批量查询skn返佣list todo 117 + * 批量查询skn返佣list
118 * */ 118 * */
119 @RequestMapping("/queryRebateList") 119 @RequestMapping("/queryRebateList")
120 @ResponseBody 120 @ResponseBody
121 - public List<UnionShareRebateBo> queryRebateList(@RequestBody BatchBaseRequest<UnionSknRebateBo> req){ 121 + public List<UnionSknRebateBo> queryRebateList(@RequestBody BatchBaseRequest<UnionSknRebateBo> req){
122 log.info("queryBrandList.req is {}", req); 122 log.info("queryBrandList.req is {}", req);
123 - List<UnionShareRebateBo> result = unionShareRebateService.queryRebateList(req.getParams()); 123 + List<UnionSknRebateBo> result = unionShareRebateService.queryRebateList(req.getParams());
124 return result; 124 return result;
125 } 125 }
126 /** 126 /**
127 - * 查询skn返佣 todo 127 + * 查询skn返佣
128 * */ 128 * */
129 @RequestMapping("/querySknRebate") 129 @RequestMapping("/querySknRebate")
130 @ResponseBody 130 @ResponseBody
131 - public UnionShareRebateBo querySknRebate(@RequestBody UnionSknRebateBo req) { 131 + public UnionSknRebateBo querySknRebate(@RequestBody UnionSknRebateBo req) {
132 log.info("queryBrandList.req is {}", req); 132 log.info("queryBrandList.req is {}", req);
133 - UnionShareRebateBo result = unionShareRebateService.querySknRebate(req); 133 + UnionSknRebateBo result = unionShareRebateService.querySknRebate(req);
134 return result; 134 return result;
135 } 135 }
136 136
@@ -24,7 +24,8 @@ public interface IUnionShareRebateService { @@ -24,7 +24,8 @@ public interface IUnionShareRebateService {
24 int addBrand(UnionShareRebateBo req); 24 int addBrand(UnionShareRebateBo req);
25 int updateBrand(UnionShareRebateBo req); 25 int updateBrand(UnionShareRebateBo req);
26 26
27 - List<UnionShareRebateBo> queryRebateList(List<UnionSknRebateBo> req);  
28 - UnionShareRebateBo querySknRebate(UnionSknRebateBo req); 27 + List<UnionSknRebateBo> queryRebateList(List<UnionSknRebateBo> req);
  28 + UnionSknRebateBo querySknRebate(UnionSknRebateBo req);
  29 + UnionSknRebateBo querySknRebate(Integer skn, Integer brand, String rebatesRatioDefault);
29 JSONArray queryAllBrandList(); 30 JSONArray queryAllBrandList();
30 } 31 }
@@ -2,7 +2,10 @@ package com.yoho.unions.server.service.impl; @@ -2,7 +2,10 @@ package com.yoho.unions.server.service.impl;
2 2
3 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
  5 +import com.yoho.core.config.ConfigReader;
5 import com.yoho.core.rest.client.ServiceCaller; 6 import com.yoho.core.rest.client.ServiceCaller;
  7 +import com.yoho.error.ServiceError;
  8 +import com.yoho.error.exception.ServiceException;
6 import com.yoho.product.model.BrandBo; 9 import com.yoho.product.model.BrandBo;
7 import com.yoho.product.model.ProductBo; 10 import com.yoho.product.model.ProductBo;
8 import com.yoho.product.request.BaseRequest; 11 import com.yoho.product.request.BaseRequest;
@@ -45,6 +48,8 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -45,6 +48,8 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
45 48
46 private Logger logger = LoggerFactory.getLogger(UnionShareRebateServiceImpl.class); 49 private Logger logger = LoggerFactory.getLogger(UnionShareRebateServiceImpl.class);
47 50
  51 + private String NEW_USER_REBATES_RATIO_KEY = "union.newUserRebatesRatio";
  52 +
48 @Autowired 53 @Autowired
49 UnionShareRebateBrandMapper unionShareRebateBrandMapper; 54 UnionShareRebateBrandMapper unionShareRebateBrandMapper;
50 @Autowired 55 @Autowired
@@ -52,6 +57,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -52,6 +57,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
52 @Autowired 57 @Autowired
53 UnionShareRebateLogMapper unionShareRebateLogMapper; 58 UnionShareRebateLogMapper unionShareRebateLogMapper;
54 59
  60 + @Resource(name = "core-config-reader")
  61 + private ConfigReader configReader;
  62 +
55 @Resource 63 @Resource
56 ServiceCaller serviceCaller; 64 ServiceCaller serviceCaller;
57 65
@@ -148,6 +156,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -148,6 +156,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
148 @Override 156 @Override
149 public UnionShareRebateBo querySknById(int id) { 157 public UnionShareRebateBo querySknById(int id) {
150 UnionShareRebateSkn rebateSkn= unionShareRebateSknMapper.selectByPrimaryKey(id); 158 UnionShareRebateSkn rebateSkn= unionShareRebateSknMapper.selectByPrimaryKey(id);
  159 + if (rebateSkn == null) {
  160 + return null;
  161 + }
151 UnionShareRebateBo result = new UnionShareRebateBo(); 162 UnionShareRebateBo result = new UnionShareRebateBo();
152 BeanUtils.copyProperties(rebateSkn, result); 163 BeanUtils.copyProperties(rebateSkn, result);
153 return result; 164 return result;
@@ -155,6 +166,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -155,6 +166,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
155 @Override 166 @Override
156 public UnionShareRebateBo querySkn(int skn) { 167 public UnionShareRebateBo querySkn(int skn) {
157 UnionShareRebateSkn rebateSkn= unionShareRebateSknMapper.selectBySkn(skn); 168 UnionShareRebateSkn rebateSkn= unionShareRebateSknMapper.selectBySkn(skn);
  169 + if (rebateSkn == null) {
  170 + return null;
  171 + }
158 UnionShareRebateBo result = new UnionShareRebateBo(); 172 UnionShareRebateBo result = new UnionShareRebateBo();
159 BeanUtils.copyProperties(rebateSkn, result); 173 BeanUtils.copyProperties(rebateSkn, result);
160 return result; 174 return result;
@@ -163,6 +177,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -163,6 +177,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
163 @Override 177 @Override
164 public UnionShareRebateBo queryBrandById(int id) { 178 public UnionShareRebateBo queryBrandById(int id) {
165 UnionShareRebateBrand rebateBrand= unionShareRebateBrandMapper.selectByPrimaryKey(id); 179 UnionShareRebateBrand rebateBrand= unionShareRebateBrandMapper.selectByPrimaryKey(id);
  180 + if (rebateBrand == null) {
  181 + return null;
  182 + }
166 UnionShareRebateBo result = new UnionShareRebateBo(); 183 UnionShareRebateBo result = new UnionShareRebateBo();
167 BeanUtils.copyProperties(rebateBrand, result); 184 BeanUtils.copyProperties(rebateBrand, result);
168 return result; 185 return result;
@@ -170,6 +187,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -170,6 +187,9 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
170 @Override 187 @Override
171 public UnionShareRebateBo queryBrand(int brand) { 188 public UnionShareRebateBo queryBrand(int brand) {
172 UnionShareRebateBrand rebateBrand= unionShareRebateBrandMapper.selectByBrand(brand); 189 UnionShareRebateBrand rebateBrand= unionShareRebateBrandMapper.selectByBrand(brand);
  190 + if (rebateBrand == null) {
  191 + return null;
  192 + }
173 UnionShareRebateBo result = new UnionShareRebateBo(); 193 UnionShareRebateBo result = new UnionShareRebateBo();
174 BeanUtils.copyProperties(rebateBrand, result); 194 BeanUtils.copyProperties(rebateBrand, result);
175 return result; 195 return result;
@@ -246,14 +266,104 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu @@ -246,14 +266,104 @@ public class UnionShareRebateServiceImpl implements IUnionShareRebateService,IBu
246 } 266 }
247 267
248 @Override 268 @Override
249 - public List<UnionShareRebateBo> queryRebateList(List<UnionSknRebateBo> req){  
250 - return null; 269 + public List<UnionSknRebateBo> queryRebateList(List<UnionSknRebateBo> req){
  270 + if (CollectionUtils.isEmpty(req)) {
  271 + return new ArrayList<>();
  272 + }
  273 + Set<Integer> skns = new HashSet<>();
  274 + Set<Integer> brands = new HashSet<>();
  275 + req.forEach(r->{
  276 + skns.add(r.getSkn());
  277 + brands.add(r.getBrand());
  278 + });
  279 + List<UnionShareRebateSkn> sknList=unionShareRebateSknMapper.selectListBySkns(skns);
  280 + List<UnionShareRebateBrand> brandList=unionShareRebateBrandMapper.selectListByBrands(brands);
  281 + Map<Integer, UnionShareRebateSkn> sknMap = sknList.stream().collect(Collectors.toMap(UnionShareRebateSkn::getSkn, skn -> skn));
  282 + Map<Integer, UnionShareRebateBrand> brandMap = brandList.stream().collect(Collectors.toMap(UnionShareRebateBrand::getBrand, b->b));
  283 + List<UnionSknRebateBo> result = new ArrayList<>();
  284 + String rebatesRatioDefault=configReader.getString(NEW_USER_REBATES_RATIO_KEY, "6");
  285 + req.forEach(r->{
  286 + UnionSknRebateBo rebatePercent=getProductRebatePercentBo(r.getSkn(), r.getBrand(), true, sknMap, brandMap, rebatesRatioDefault);
  287 + result.add(rebatePercent);
  288 + });
  289 + return result;
251 } 290 }
252 291
253 @Override 292 @Override
254 - public UnionShareRebateBo querySknRebate(UnionSknRebateBo req) {  
255 - return null; 293 + public UnionSknRebateBo querySknRebate(UnionSknRebateBo bo) {
  294 + String rebatesRatioDefault=configReader.getString(NEW_USER_REBATES_RATIO_KEY, "6");
  295 + UnionSknRebateBo rebatePercent=getProductRebatePercentBo(bo.getSkn(), bo.getBrand(),false,null,null, rebatesRatioDefault);
  296 + return rebatePercent;
256 } 297 }
  298 +
  299 + @Override
  300 + public UnionSknRebateBo querySknRebate(Integer skn,Integer brand,String rebatesRatioDefault ) {
  301 + UnionSknRebateBo rebatePercent=getProductRebatePercentBo(skn, brand,false,null,null, rebatesRatioDefault);
  302 + return rebatePercent;
  303 + }
  304 +
  305 + private UnionSknRebateBo getProductRebatePercentBo(Integer skn,Integer brand,boolean hasQuery,Map<Integer, UnionShareRebateSkn> sknMap,Map<Integer, UnionShareRebateBrand> brandMap ,String rebatesRatioDefault) {
  306 + logger.info("getProductRebatePercentBo start.skn is {},brand is {},rebatesRatioDefault is {},hasQuery is {}.",skn,brand,rebatesRatioDefault,hasQuery);
  307 +
  308 + if (skn==null||(hasQuery && (sknMap == null || brandMap == null))) {
  309 + throw new ServiceException(ServiceError.PARAM_ERROR);
  310 + }
  311 + int rebatesRatio = Integer.valueOf(rebatesRatioDefault)*100;//默认设置是百分点
  312 + UnionShareRebateSkn shareRebateSkn = hasQuery?sknMap.get(skn):unionShareRebateSknMapper.selectBySkn(skn);
  313 + boolean rebateState = true;
  314 + boolean brandStateCheck = false;
  315 + boolean brandRebateGet = false;
  316 + StringBuilder vidBuilder = new StringBuilder();
  317 + if (shareRebateSkn != null) {
  318 + vidBuilder.append(shareRebateSkn.getId()).append(":").append(shareRebateSkn.getLogId());
  319 + //是否返佣状态:1-根据品牌返佣状态判断是否返佣,2-返佣,3-不返佣
  320 + if (shareRebateSkn.getState() == 1) {
  321 + brandStateCheck = true;
  322 + }else if (shareRebateSkn.getState() == 3) {
  323 + rebateState = false;//不返佣
  324 + }
  325 + if (shareRebateSkn.getType() == 1) {
  326 + //返佣比例获取:1-获取品牌设置的返佣比例,2自定义返佣比例
  327 + brandRebateGet = true;
  328 + }else {
  329 + rebatesRatio = shareRebateSkn.getRebate();
  330 + vidBuilder.append(":").append(rebatesRatio);
  331 + }
  332 + }
  333 +
  334 + UnionShareRebateBrand rebateBrand = null;
  335 + if (rebateState&&(shareRebateSkn == null || brandStateCheck || brandRebateGet)) {
  336 + //未设置优先skn返佣、skn是否返佣根据品牌返佣状态判断、skn返佣比例根据品牌设置比例
  337 + rebateBrand = hasQuery?brandMap.get(brand):unionShareRebateBrandMapper.selectByBrand(brand);
  338 + }
  339 + if (rebateBrand != null) {
  340 + vidBuilder.append("-").append(rebateBrand.getId()).append(":").append(rebateBrand.getLogId());
  341 + if ((shareRebateSkn == null || brandStateCheck)&&rebateBrand.getState()==2) {
  342 + //1-品牌返佣,2-品牌不返佣
  343 + rebateState = false;//不返佣
  344 + }
  345 + if (rebateState&&(shareRebateSkn == null||brandRebateGet)&&rebateBrand.getType() == 2) {
  346 + //1-默认比例,2-自定义
  347 + rebatesRatio = rebateBrand.getRebate();//万分点
  348 + vidBuilder.append(":").append(rebatesRatio);
  349 + }
  350 + }
  351 + UnionSknRebateBo bo = new UnionSknRebateBo();
  352 + bo.setSkn(skn);
  353 + bo.setBrand(brand);
  354 + bo.setVid(vidBuilder.toString());
  355 +
  356 + if (!rebateState) {
  357 + //不返佣
  358 + bo.setRebatePercent(new BigDecimal(0));
  359 + logger.info("getProductRebatePercentBo.skn is {},brand is {},hasQuery is {},rebatesRatio is 0,vid is {}.",skn,brand,hasQuery,bo.getVid());
  360 + return bo;
  361 + }
  362 + logger.info("getProductRebatePercentBo.skn is {},brand is {},hasQuery is {},rebatesRatio is {},vid is {}.",skn,brand,hasQuery,rebatesRatio,bo.getVid());
  363 + bo.setRebatePercent(new BigDecimal(rebatesRatio).divide(new BigDecimal(100)));
  364 + return bo;
  365 + }
  366 +
257 @Override 367 @Override
258 public JSONArray queryAllBrandList() { 368 public JSONArray queryAllBrandList() {
259 try { 369 try {
@@ -34,6 +34,7 @@ import com.yoho.unions.constant.SendModelEnum; @@ -34,6 +34,7 @@ import com.yoho.unions.constant.SendModelEnum;
34 import com.yoho.unions.dal.*; 34 import com.yoho.unions.dal.*;
35 import com.yoho.unions.dal.model.*; 35 import com.yoho.unions.dal.model.*;
36 import com.yoho.unions.helper.SendMessageHelper; 36 import com.yoho.unions.helper.SendMessageHelper;
  37 +import com.yoho.unions.server.service.IUnionShareRebateService;
37 import org.apache.commons.collections.CollectionUtils; 38 import org.apache.commons.collections.CollectionUtils;
38 import org.apache.commons.lang3.StringUtils; 39 import org.apache.commons.lang3.StringUtils;
39 import org.apache.poi.hssf.record.ContinueRecord; 40 import org.apache.poi.hssf.record.ContinueRecord;
@@ -156,11 +157,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -156,11 +157,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
156 UnionShareYohoNewUidMapper unionShareYohoNewUidMapper; 157 UnionShareYohoNewUidMapper unionShareYohoNewUidMapper;
157 158
158 @Autowired 159 @Autowired
159 - UnionShareRebateBrandMapper unionShareRebateBrandMapper;  
160 - @Autowired  
161 - UnionShareRebateSknMapper unionShareRebateSknMapper;  
162 - @Autowired  
163 - UnionShareRebateLogMapper unionShareRebateLogMapper; 160 + IUnionShareRebateService unionShareRebateService;
164 161
165 @Resource 162 @Resource
166 RedisValueCache redisValueCache; 163 RedisValueCache redisValueCache;
@@ -3393,55 +3390,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -3393,55 +3390,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
3393 3390
3394 3391
3395 private BigDecimal getProductRebates(UnionShareOrdersProduct product,String rebatesRatioDefault) { 3392 private BigDecimal getProductRebates(UnionShareOrdersProduct product,String rebatesRatioDefault) {
3396 -  
3397 - int rebatesRatio = Integer.valueOf(rebatesRatioDefault)*100;//默认设置是百分点  
3398 - UnionShareRebateSkn shareRebateSkn = unionShareRebateSknMapper.selectBySkn(product.getProductSkn());  
3399 - boolean rebateState = true;  
3400 - boolean brandStateCheck = false;  
3401 - boolean brandRebateGet = false;  
3402 - StringBuilder vidBuilder = new StringBuilder();  
3403 - if (shareRebateSkn != null) {  
3404 - vidBuilder.append(shareRebateSkn.getId()).append(":").append(shareRebateSkn.getLogId());  
3405 - //是否返佣状态:1-根据品牌返佣状态判断是否返佣,2-返佣,3-不返佣  
3406 - if (shareRebateSkn.getState() == 1) {  
3407 - brandStateCheck = true;  
3408 - }else if (shareRebateSkn.getState() == 3) {  
3409 - rebateState = false;//不返佣  
3410 - }  
3411 - if (shareRebateSkn.getType() == 1) {  
3412 - //返佣比例获取:1-获取品牌设置的返佣比例,2自定义返佣比例  
3413 - brandRebateGet = true;  
3414 - }else {  
3415 - rebatesRatio = shareRebateSkn.getRebate();  
3416 - vidBuilder.append(":").append(rebatesRatio);  
3417 - }  
3418 - }  
3419 -  
3420 - UnionShareRebateBrand rebateBrand = null;  
3421 - if (rebateState&&(shareRebateSkn == null || brandStateCheck || brandRebateGet)) {  
3422 - //未设置优先skn返佣、skn是否返佣根据品牌返佣状态判断、skn返佣比例根据品牌设置比例  
3423 - rebateBrand = unionShareRebateBrandMapper.selectByBrand(product.getBrand());  
3424 - }  
3425 - if (rebateBrand != null) {  
3426 - vidBuilder.append("-").append(rebateBrand.getId()).append(":").append(rebateBrand.getLogId());  
3427 - if ((shareRebateSkn == null || brandStateCheck)&&rebateBrand.getState()==2) {  
3428 - //1-品牌返佣,2-品牌不返佣  
3429 - rebateState = false;//不返佣  
3430 - }  
3431 - if (rebateState&&(shareRebateSkn == null||brandRebateGet)&&rebateBrand.getType() == 2) {  
3432 - //1-默认比例,2-自定义  
3433 - rebatesRatio = rebateBrand.getRebate();//万分点  
3434 - vidBuilder.append(":").append(rebatesRatio);  
3435 - }  
3436 - }  
3437 - product.setVid(vidBuilder.toString());  
3438 - if (!rebateState) {  
3439 - //不返佣  
3440 - product.setAmount(new BigDecimal(0));  
3441 - return product.getAmount();  
3442 - }  
3443 -  
3444 - BigDecimal productAmount=(new BigDecimal(rebatesRatio).divide(new BigDecimal(10000)).multiply(product.getPrice())).setScale(2,BigDecimal.ROUND_DOWN); 3393 + UnionSknRebateBo rebateBo=unionShareRebateService.querySknRebate(product.getProductSkn(),product.getBrand(),rebatesRatioDefault);
  3394 + product.setVid(rebateBo.getVid());
  3395 + BigDecimal productAmount=(rebateBo.getRebatePercent().divide(new BigDecimal(100)).multiply(product.getPrice())).setScale(2,BigDecimal.ROUND_DOWN);
3445 product.setAmount(productAmount); 3396 product.setAmount(productAmount);
3446 return productAmount; 3397 return productAmount;
3447 } 3398 }