店员价格

This commit is contained in:
admin
2024-08-19 17:18:33 +08:00
parent c75809a8ce
commit 6eeca40527
13 changed files with 431 additions and 22 deletions

View File

@@ -93,7 +93,7 @@ public class PlayOrderInfoController {
orderInfoService.updateStateTo1("2", CustomSecurityContextHolder.getUserId(), vo.getAcceptBy(), vo.getOrderId());
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.selectById(vo.getAcceptBy());
PlayOrderInfoEntity orderInfo = orderInfoService.selectOrderInfoById(vo.getOrderId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(orderInfo.getCommodityId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(orderInfo.getCommodityId(), clerkUserInfo.getLevelId());
wxCustomMpService.sendCreateOrderMessage(clerkUserInfo.getTenantId(), clerkUserInfo.getOpenid(), clerkUserInfo.getNickname(), orderInfo.getOrderNo(), orderInfo.getId(), String.valueOf(orderInfo.getPurchaserTime()), orderInfo.getOrderMoney().toString(), commodityInfo.getCommodityName());
return R.ok("操作成功");
}

View File

@@ -1,19 +1,27 @@
package com.starry.admin.modules.shop.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkLevelInfoService;
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
import com.starry.admin.modules.shop.module.entity.PlayCommodityInfoEntity;
import com.starry.admin.modules.shop.module.vo.PlayCommodityInfoAddVo;
import com.starry.admin.modules.shop.module.vo.PlayCommodityInfoUpdateVo;
import com.starry.admin.modules.shop.module.vo.PlayCommodityInfoReturnVo;
import com.starry.admin.modules.shop.service.IPlayCommodityAndLevelInfoService;
import com.starry.admin.modules.shop.service.IPlayCommodityInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,6 +37,26 @@ public class PlayCommodityInfoController {
@Resource
private IPlayCommodityInfoService playCommodityInfoService;
@Resource
private IPlayClerkLevelInfoService playClerkLevelInfoService;
@Resource
private IPlayCommodityAndLevelInfoService playCommodityAndLevelInfoService;
@GetMapping("/getTableName")
public R getTableName() {
List<Map<String, String>> result = new ArrayList<>();
List<PlayClerkLevelInfoEntity> levelInfoEntities = playClerkLevelInfoService.selectAll();
for (PlayClerkLevelInfoEntity levelInfoEntity : levelInfoEntities) {
HashMap<String, String> item = new HashMap<>();
item.put("prop", levelInfoEntity.getId());
item.put("name", levelInfoEntity.getName());
result.add(item);
}
return R.ok(result);
}
/**
* 查询服务项目类型
*/
@@ -37,8 +65,18 @@ public class PlayCommodityInfoController {
List<Map<String, Object>> result = new ArrayList<>();
List<PlayCommodityInfoEntity> list = playCommodityInfoService.selectByType();
for (PlayCommodityInfoEntity entity : list) {
List<Map<String, Object>> itemCommodityInfo = new ArrayList<>();
Map<String, Object> map = BeanUtil.beanToMap(entity);
map.put("children", playCommodityInfoService.selectByPId(entity.getId()));
List<PlayCommodityInfoReturnVo> commodityInfoEntities = ConvertUtil.entityToVoList(playCommodityInfoService.selectByPId(entity.getId()), PlayCommodityInfoReturnVo.class);
for (PlayCommodityInfoReturnVo commodityInfoEntity : commodityInfoEntities) {
Map<String, Object> item = BeanUtil.beanToMap(commodityInfoEntity);
for (PlayClerkLevelInfoEntity playClerkLevelInfoEntity : playClerkLevelInfoService.selectAll()) {
PlayCommodityAndLevelInfoEntity entity1 = playCommodityAndLevelInfoService.queryById(commodityInfoEntity.getId(), playClerkLevelInfoEntity.getId());
item.put(playClerkLevelInfoEntity.getId(), entity1 == null ? "未设置价格" : entity1.getPrice());
}
itemCommodityInfo.add(item);
}
map.put("children", itemCommodityInfo);
result.add(map);
}
return R.ok(result);
@@ -48,10 +86,31 @@ public class PlayCommodityInfoController {
* 修改服务项目类型
*/
@PostMapping("/updateInfo")
public R updateInfo(@Validated @RequestBody PlayCommodityInfoUpdateVo vo) {
PlayCommodityInfoEntity entity = playCommodityInfoService.selectPlayCommodityInfoById(vo.getId());
BeanUtil.copyProperties(vo, entity);
playCommodityInfoService.update(entity);
public R updateInfo(@RequestBody String s) {
JSONObject jsonObject = JSON.parseObject(s);
if (!jsonObject.containsKey("id")) {
throw new CustomException("请求参数错误,id不能为空");
}
System.out.println(s);
for (PlayClerkLevelInfoEntity playClerkLevelInfoEntity : playClerkLevelInfoService.selectAll()) {
if (!jsonObject.containsKey(playClerkLevelInfoEntity.getId())) {
throw new CustomException("请求参数错误");
}
double price = 0.0;
try {
price = Double.parseDouble(jsonObject.getString(playClerkLevelInfoEntity.getId()));
} catch (RuntimeException e) {
throw new CustomException("请求参数错误,价格格式为空");
}
PlayCommodityAndLevelInfoEntity entity = playCommodityAndLevelInfoService.queryById(jsonObject.getString("id"), playClerkLevelInfoEntity.getId());
if (entity == null) {
entity = new PlayCommodityAndLevelInfoEntity();
entity.setCommodityId(jsonObject.getString("id"));
entity.setLevelId(playClerkLevelInfoEntity.getId());
}
entity.setPrice(new BigDecimal(price));
this.playCommodityAndLevelInfoService.saveOrUpdate(entity);
}
return R.ok("成功");
}

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
/**
* 服务项目和店员等级数据Mapper接口
*
* @author admin
* @since 2024-08-16
*/
public interface PlayCommodityAndLevelInfoMapper extends BaseMapper<PlayCommodityAndLevelInfoEntity> {
}

View File

@@ -15,14 +15,24 @@ import org.apache.ibatis.annotations.Select;
public interface PlayCommodityInfoMapper extends MPJBaseMapper<PlayCommodityInfoEntity> {
// /**
// * 查询服务项目信息
// *
// * @param id UUID
// * @return 项目信息
// */
// @Select("select t.id as commodityId,t.price as commodityPrice,t.item_name as serviceDuration,t1.item_name as commodityName from play_commodity_info t left join play_commodity_info t1 on t.p_id = t1.id where t.id = #{id} limit 1")
// PlayCommodityInfoVo queryCommodityInfo(String id);
/**
* 查询服务项目信息
*
* @param id UUID
* @return 项目信息
*/
@Select("select t.id as commodityId,t.price as commodityPrice,t.item_name as serviceDuration,t1.item_name as commodityName from play_commodity_info t left join play_commodity_info t1 on t.p_id = t1.id where t.id = #{id} limit 1")
PlayCommodityInfoVo queryCommodityInfo(String id);
@Select("select t.id as commodityId,t3.price as commodityPrice,t.item_name as serviceDuration,t1.item_name as commodityName from play_commodity_info t left join play_commodity_info t1 on t.p_id = t1.id left join play_commodity_and_level_info t3 ON t3.commodity_id = t1.id where t3.price is not null and t.id = #{id} and t3.level_id = #{levelId} limit 1")
PlayCommodityInfoVo queryCommodityInfo(String id, String levelId);
}

View File

@@ -0,0 +1,52 @@
package com.starry.admin.modules.shop.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 服务项目和店员等级数据对象 play_commodity_and_level_info
*
* @author admin
* @since 2024-08-16
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_commodity_and_level_info")
public class PlayCommodityAndLevelInfoEntity extends BaseEntity<PlayCommodityAndLevelInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 商品ID
*/
private String commodityId;
/**
* 店员等级ID
*/
private String levelId;
/**
* 服务单价
*/
private BigDecimal price;
/**
* 排序
*/
private Long sort;
}

View File

@@ -0,0 +1,58 @@
package com.starry.admin.modules.shop.module.vo;
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
import lombok.Data;
import java.util.List;
/**
* @author admin
* @since 2024/8/18 下午7:59
**/
@Data
public class PlayCommodityInfoReturnVo {
/**
* UUID
*/
private String id;
/**
* Pid
**/
private String pId;
/**
* 租户ID
*/
private String tenantId;
/**
* 项目类型
*/
private String itemType;
/**
* 项目名称
*/
private String itemName;
/**
* 服务时长(文字描述信息,不参与订单计算)
*/
private String serviceDuration;
/**
* 启用状态(0:停用,1:启用)
*/
private String enableStace;
/**
* 排序
**/
private Integer sort;
}

View File

@@ -0,0 +1,73 @@
package com.starry.admin.modules.shop.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
import java.util.List;
/**
* 服务项目和店员等级数据Service接口
*
* @author admin
* @since 2024-08-16
*/
public interface IPlayCommodityAndLevelInfoService extends IService<PlayCommodityAndLevelInfoEntity> {
PlayCommodityAndLevelInfoEntity queryById(String commodityId,String levelId);
/**
* 查询服务项目和店员等级数据
*
* @return 服务项目和店员等级数据
*/
List<PlayCommodityAndLevelInfoEntity> selectAll();
/**
* 查询服务项目和店员等级数据
*
* @param id 服务项目和店员等级数据主键
* @return 服务项目和店员等级数据
*/
PlayCommodityAndLevelInfoEntity selectPlayCommodityAndLevelInfoById(String id);
/**
* 查询服务项目和店员等级数据列表
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 服务项目和店员等级数据集合
*/
IPage<PlayCommodityAndLevelInfoEntity> selectPlayCommodityAndLevelInfoByPage(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo);
/**
* 新增服务项目和店员等级数据
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 结果
*/
boolean create(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo);
/**
* 修改服务项目和店员等级数据
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 结果
*/
boolean update(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo);
/**
* 批量删除服务项目和店员等级数据
*
* @param ids 需要删除的服务项目和店员等级数据主键集合
* @return 结果
*/
int deletePlayCommodityAndLevelInfoByIds(String[] ids);
/**
* 删除服务项目和店员等级数据信息
*
* @param id 服务项目和店员等级数据主键
* @return 结果
*/
int deletePlayCommodityAndLevelInfoById(String id);
}

View File

@@ -25,14 +25,24 @@ public interface IPlayCommodityInfoService extends IService<PlayCommodityInfoEnt
*/
void initPlayCommodityInfo(String tenantId);
/**
* 查询服务项目
*
* @param id UUID
* @return 服务项目
*/
PlayCommodityInfoVo queryCommodityInfo(String id);
* @param id 服务项目ID
* @param levelId 店员等级ID
* @return PlayCommodityInfoVo
* @author admin
**/
PlayCommodityInfoVo queryCommodityInfo(String id, String levelId);
// /**
// * 查询服务项目
// *
// * @param id UUID
// * @return 服务项目
// */
// PlayCommodityInfoVo queryCommodityInfo(String id);
/**
* 查询服务项目
*

View File

@@ -0,0 +1,112 @@
package com.starry.admin.modules.shop.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.shop.mapper.PlayCommodityAndLevelInfoMapper;
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
import com.starry.admin.modules.shop.service.IPlayCommodityAndLevelInfoService;
import com.starry.common.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 服务项目和店员等级数据Service业务层处理
*
* @author admin
* @since 2024-08-16
*/
@Service
public class PlayCommodityAndLevelInfoServiceImpl extends ServiceImpl<PlayCommodityAndLevelInfoMapper, PlayCommodityAndLevelInfoEntity> implements IPlayCommodityAndLevelInfoService {
@Resource
private PlayCommodityAndLevelInfoMapper playCommodityAndLevelInfoMapper;
@Override
public PlayCommodityAndLevelInfoEntity queryById(String commodityId, String levelId) {
LambdaQueryWrapper<PlayCommodityAndLevelInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlayCommodityAndLevelInfoEntity::getCommodityId, commodityId);
queryWrapper.eq(PlayCommodityAndLevelInfoEntity::getLevelId, levelId);
return playCommodityAndLevelInfoMapper.selectOne(queryWrapper);
}
@Override
public List<PlayCommodityAndLevelInfoEntity> selectAll() {
return this.baseMapper.selectList(new LambdaQueryWrapper<>());
}
/**
* 查询服务项目和店员等级数据
*
* @param id 服务项目和店员等级数据主键
* @return 服务项目和店员等级数据
*/
@Override
public PlayCommodityAndLevelInfoEntity selectPlayCommodityAndLevelInfoById(String id) {
return this.baseMapper.selectById(id);
}
/**
* 查询服务项目和店员等级数据列表
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 服务项目和店员等级数据
*/
@Override
public IPage<PlayCommodityAndLevelInfoEntity> selectPlayCommodityAndLevelInfoByPage(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
Page<PlayCommodityAndLevelInfoEntity> page = new Page<>(1, 10);
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayCommodityAndLevelInfoEntity>());
}
/**
* 新增服务项目和店员等级数据
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 结果
*/
@Override
public boolean create(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
if (StrUtil.isBlankIfStr(playCommodityAndLevelInfo.getId())) {
playCommodityAndLevelInfo.setId(IdUtils.getUuid());
}
return save(playCommodityAndLevelInfo);
}
/**
* 修改服务项目和店员等级数据
*
* @param playCommodityAndLevelInfo 服务项目和店员等级数据
* @return 结果
*/
@Override
public boolean update(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
return updateById(playCommodityAndLevelInfo);
}
/**
* 批量删除服务项目和店员等级数据
*
* @param ids 需要删除的服务项目和店员等级数据主键
* @return 结果
*/
@Override
public int deletePlayCommodityAndLevelInfoByIds(String[] ids) {
return playCommodityAndLevelInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除服务项目和店员等级数据信息
*
* @param id 服务项目和店员等级数据主键
* @return 结果
*/
@Override
public int deletePlayCommodityAndLevelInfoById(String id) {
return playCommodityAndLevelInfoMapper.deleteById(id);
}
}

View File

@@ -108,14 +108,23 @@ public class PlayCommodityInfoServiceImpl extends ServiceImpl<PlayCommodityInfoM
}
@Override
public PlayCommodityInfoVo queryCommodityInfo(String id) {
PlayCommodityInfoVo vo = this.baseMapper.queryCommodityInfo(id);
public PlayCommodityInfoVo queryCommodityInfo(String id, String levelId) {
PlayCommodityInfoVo vo = this.baseMapper.queryCommodityInfo(id,levelId);
if (vo == null) {
throw new CustomException("服务项目不存在");
}
return vo;
}
// @Override
// public PlayCommodityInfoVo queryCommodityInfo(String id) {
// PlayCommodityInfoVo vo = this.baseMapper.queryCommodityInfo(id);
// if (vo == null) {
// throw new CustomException("服务项目不存在");
// }
// return vo;
// }
/**
* 查询服务项目
*
@@ -133,7 +142,6 @@ public class PlayCommodityInfoServiceImpl extends ServiceImpl<PlayCommodityInfoM
@Override
public List<PlayCommodityInfoEntity> selectByPId(String pId) {
LambdaQueryWrapper<PlayCommodityInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PlayCommodityInfoEntity::getPId, pId);
return this.baseMapper.selectList(lambdaQueryWrapper);

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.util.StrUtil;
import com.starry.admin.common.aspect.CustomUserLogin;
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.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.shop.module.vo.PlayCommodityInfoVo;
import com.starry.admin.modules.shop.service.IPlayCommodityInfoService;
@@ -39,6 +41,9 @@ public class WxCouponController {
@Resource
IPlayCouponDetailsService couponDetailsService;
@Resource
IPlayClerkUserInfoService playClerkUserInfoService;
@Resource
IPlayCouponInfoService couponInfoService;
@@ -103,7 +108,8 @@ public class WxCouponController {
@PostMapping("/custom/queryByOrder")
public R queryByOrder(@Validated @RequestBody WxCouponOrderQueryVo vo) {
List<PlayCouponDetailsReturnVo> list = couponDetailsService.selectByCustomId(ThreadLocalRequestDetail.getCustomUserInfo().getId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId());
PlayClerkUserInfoEntity clerkUserInfo = playClerkUserInfoService.queryByUserId(vo.getClerkId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId(),clerkUserInfo.getLevelId());
// 优惠券列表
List<WxCouponOrderReturnVo> couponReturnVos = new ArrayList<>();
for (PlayCouponDetailsReturnVo couponDetails : list) {

View File

@@ -288,7 +288,9 @@ public class WxCustomController {
@PostMapping("/order/commodity")
public R commodityToOrdder(@Validated @RequestBody PlayOrderInfoCommodityAdd vo) {
String customId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId());
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClerkId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId(), clerkUserInfo.getLevelId());
for (String couponId : vo.getCouponIds()) {
PlayCouponInfoEntity couponInfo = playCouponInfoService.selectPlayCouponInfoById(couponId);
@@ -300,7 +302,7 @@ public class WxCustomController {
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(customId);
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClerkId());
BigDecimal money = commodityInfo.getCommodityPrice().multiply(new BigDecimal(vo.getCommodityQuantity()));
if (money.compareTo(customUserInfo.getAccountBalance()) > 0) {
@@ -331,7 +333,7 @@ public class WxCustomController {
// 验证当前顾客余额是否充足
String customId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(customId);
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId());
PlayCommodityInfoVo commodityInfo = playCommodityInfoService.queryCommodityInfo(vo.getCommodityId(), vo.getLevelId());
BigDecimal money = commodityInfo.getCommodityPrice().multiply(new BigDecimal(vo.getCommodityQuantity()));
if (money.compareTo(customUserInfo.getAccountBalance()) > 0) {
throw new ServiceException("余额不足", 998);

View File

@@ -14,6 +14,9 @@ public class WxCouponOrderQueryVo {
private String commodityId;
private String clerkId;
/**
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
*/