微信小程序分类查询(优惠券错误)完成
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.atguigu.ssyx.activity.api;
|
||||
|
||||
import com.atguigu.ssyx.activity.service.ActivityInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ClassName: ActivityInfoController
|
||||
* Package: com.atguigu.ssyx.activity.api
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/9/26 14:12
|
||||
*/
|
||||
@Api(tags = "促销与优惠券接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/activity")
|
||||
@Slf4j
|
||||
public class ActivityApiController {
|
||||
|
||||
@Resource
|
||||
private ActivityInfoService activityInfoService;
|
||||
|
||||
@ApiOperation(value = "根据skuId列表获取促销信息")
|
||||
@PostMapping("inner/findActivity")
|
||||
public Map<Long, List<String>> findActivity(@RequestBody List<Long> skuIdList) {
|
||||
return activityInfoService.findActivity(skuIdList);
|
||||
}
|
||||
}
|
@@ -19,7 +19,27 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface ActivityInfoMapper extends BaseMapper<ActivityInfo> {
|
||||
|
||||
/**
|
||||
* 查询商品获取规则数据
|
||||
*
|
||||
* @param skuId
|
||||
* @return
|
||||
*/
|
||||
List<ActivityRule> selectActivityRuleList(Long skuId);
|
||||
|
||||
/**
|
||||
* 查询两张表判断 activity_info 和 activity_sku,编写SQL语句实现
|
||||
*
|
||||
* @param skuIdList
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectSkuIdListExist(@Param("skuIdList") List<Long> skuIdList);
|
||||
|
||||
/**
|
||||
* 根据skuId进行查询,查询sku对应活动里面规则列表
|
||||
*
|
||||
* @param skuId
|
||||
* @return
|
||||
*/
|
||||
List<ActivityRule> findActivityRule(Long skuId);
|
||||
}
|
||||
|
@@ -61,4 +61,12 @@ public interface ActivityInfoService extends IService<ActivityInfo> {
|
||||
* @return
|
||||
*/
|
||||
List<ActivityRule> findActivityRule(Long skuId);
|
||||
|
||||
/**
|
||||
* 根据skuId列表获取促销信息
|
||||
*
|
||||
* @param skuIdList
|
||||
* @return
|
||||
*/
|
||||
Map<Long, List<String>> findActivity(List<Long> skuIdList);
|
||||
}
|
||||
|
@@ -207,4 +207,32 @@ public class ActivityInfoServiceImpl extends ServiceImpl<ActivityInfoMapper, Act
|
||||
}
|
||||
return ruleDesc.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据skuId列表获取促销信息
|
||||
*
|
||||
* @param skuIdList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, List<String>> findActivity(List<Long> skuIdList) {
|
||||
Map<Long, List<String>> result = new HashMap<>();
|
||||
//skuIdList遍历,得到每个skuId
|
||||
skuIdList.forEach(skuId -> {
|
||||
//根据skuId进行查询,查询sku对应活动里面规则列表
|
||||
List<ActivityRule> activityRuleList = baseMapper.findActivityRule(skuId);
|
||||
//数据封装,规则名称
|
||||
if (!CollectionUtils.isEmpty(activityRuleList)) {
|
||||
List<String> ruleList = new ArrayList<>();
|
||||
//把规则名称处理
|
||||
for (ActivityRule activityRule : activityRuleList) {
|
||||
ruleList.add(this.getRuleDesc(activityRule));
|
||||
}
|
||||
result.put(skuId, ruleList);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user