店员价格
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import com.starry.admin.common.aspect.ClerkUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
|
||||
import com.starry.admin.modules.shop.service.IPlayCommodityAndLevelInfoService;
|
||||
import com.starry.admin.modules.shop.service.IPlayCommodityInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayCommodityReturnVo;
|
||||
import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,6 +34,25 @@ public class WxClerkCommodityController {
|
||||
@Resource
|
||||
private IPlayCommodityInfoService playCommodityInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayCommodityAndLevelInfoService iPlayCommodityAndLevelInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
|
||||
@GetMapping("/custom/queryClerkAllCommodityByLevel")
|
||||
public R queryClerkAllCommodityByLevel(@RequestParam("id") String levelId) {
|
||||
List<PlayCommodityAndLevelInfoEntity> levelInfoEntities = iPlayCommodityAndLevelInfoService.selectAll();
|
||||
List<PlayCommodityReturnVo> tree = playCommodityInfoService.selectTree();
|
||||
if (levelId == null || levelId.isEmpty()) {
|
||||
return R.ok(tree);
|
||||
}
|
||||
tree = formatPlayCommodityReturnVoTree(tree, levelInfoEntities, levelId);
|
||||
tree = formatPlayCommodityReturnVoTree(tree);
|
||||
return R.ok(tree);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 顾客查询所有店员所有服务项目
|
||||
@@ -33,23 +60,67 @@ public class WxClerkCommodityController {
|
||||
* @return 店员所有服务项目
|
||||
*/
|
||||
@GetMapping("/custom/queryClerkAllCommodity")
|
||||
public R customQueryClerkAllCommodity() {
|
||||
public R customQueryClerkAllCommodity(@RequestParam("id") String clerkId) {
|
||||
if (clerkId == null || clerkId.isEmpty()) {
|
||||
throw new CustomException("请求参数异常,id不能为空");
|
||||
}
|
||||
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(clerkId);
|
||||
List<PlayCommodityAndLevelInfoEntity> levelInfoEntities = iPlayCommodityAndLevelInfoService.selectAll();
|
||||
List<PlayCommodityReturnVo> tree = playCommodityInfoService.selectTree();
|
||||
tree = formatPlayCommodityReturnVoTree(tree, levelInfoEntities, clerkUserInfo.getLevelId());
|
||||
tree = formatPlayCommodityReturnVoTree(tree);
|
||||
return R.ok(tree);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 顾客查询所有店员所有服务项目
|
||||
* 店员查询自己的服务项目
|
||||
*
|
||||
* @return 店员所有服务项目
|
||||
*/
|
||||
@ClerkUserLogin
|
||||
@GetMapping("/clerk/queryAllCommodity")
|
||||
public R clerkQueryAllCommodity() {
|
||||
String levelId = ThreadLocalRequestDetail.getClerkUserInfo().getLevelId();
|
||||
List<PlayCommodityAndLevelInfoEntity> levelInfoEntities = iPlayCommodityAndLevelInfoService.selectAll();
|
||||
List<PlayCommodityReturnVo> tree = playCommodityInfoService.selectTree();
|
||||
tree = formatPlayCommodityReturnVoTree(tree, levelInfoEntities, levelId);
|
||||
tree = formatPlayCommodityReturnVoTree(tree);
|
||||
return R.ok(tree);
|
||||
}
|
||||
|
||||
|
||||
public List<PlayCommodityReturnVo> formatPlayCommodityReturnVoTree(List<PlayCommodityReturnVo> tree, List<PlayCommodityAndLevelInfoEntity> levelInfoEntities, String levelId) {
|
||||
Iterator<PlayCommodityReturnVo> it = tree.iterator();
|
||||
while (it.hasNext()) {
|
||||
PlayCommodityReturnVo item = it.next();
|
||||
//查找当前服务项目对应的价格
|
||||
for (PlayCommodityAndLevelInfoEntity levelInfoEntity : levelInfoEntities) {
|
||||
if (item.getId().equals(levelInfoEntity.getCommodityId()) && levelId.equals(levelInfoEntity.getLevelId())) {
|
||||
item.setPrice(levelInfoEntity.getPrice());
|
||||
}
|
||||
}
|
||||
//如果未设置价格,删除元素
|
||||
if (!"00".equals(item.getPId()) && item.getPrice() == null) {
|
||||
it.remove();
|
||||
}
|
||||
formatPlayCommodityReturnVoTree(item.getChild(), levelInfoEntities, levelId);
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
public List<PlayCommodityReturnVo> formatPlayCommodityReturnVoTree(List<PlayCommodityReturnVo> tree) {
|
||||
Iterator<PlayCommodityReturnVo> it = tree.iterator();
|
||||
while (it.hasNext()) {
|
||||
PlayCommodityReturnVo item = it.next();
|
||||
if ("00".equals(item.getPId()) && item.getChild().isEmpty()) {
|
||||
it.remove();
|
||||
}
|
||||
formatPlayCommodityReturnVoTree(item.getChild());
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class WxCouponController {
|
||||
@PostMapping("/custom/queryByOrder")
|
||||
public R queryByOrder(@Validated @RequestBody WxCouponOrderQueryVo vo) {
|
||||
List<PlayCouponDetailsReturnVo> list = couponDetailsService.selectByCustomId(ThreadLocalRequestDetail.getCustomUserInfo().getId());
|
||||
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.queryByUserId(vo.getClerkId());
|
||||
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.selectById(vo.getClerkId());
|
||||
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId(),clerkUserInfo.getLevelId());
|
||||
// 优惠券列表
|
||||
List<WxCouponOrderReturnVo> couponReturnVos = new ArrayList<>();
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.util.List;
|
||||
public class PlayCommodityReturnVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String pId;
|
||||
/**
|
||||
* 项目类型
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user