最新代码
This commit is contained in:
@@ -20,21 +20,19 @@ import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkDataReviewInfoServiceImpl;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
import com.starry.admin.modules.weichat.entity.*;
|
||||
import com.starry.admin.modules.weichat.service.WxCustomUserService;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import com.starry.common.utils.VerificationCodeUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -67,6 +65,9 @@ public class WxClerkController {
|
||||
@Resource
|
||||
private IPlayClerkCommodityService playClerkCommodityService;
|
||||
|
||||
@Resource
|
||||
private WxCustomUserService customUserService;
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@GetMapping("/user/queryById")
|
||||
@@ -94,7 +95,7 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/sendCode")
|
||||
public R sendCode(@Valid @RequestBody PlayClerkUserSendCodeVo vo) {
|
||||
public R sendCode(@Validated @RequestBody PlayClerkUserSendCodeVo vo) {
|
||||
String codeKey = "login_codes:" + SecurityUtils.getTenantId() + "_" + SecureUtil.md5(vo.getAreaCode() + vo.getPhone());
|
||||
String code = VerificationCodeUtils.getVerificationCode(4);
|
||||
redisCache.setCacheObject(codeKey, code, 5L, TimeUnit.MINUTES);
|
||||
@@ -104,7 +105,7 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/bindCode")
|
||||
public R bindCode(@Valid @RequestBody PlayClerkUserBindCodeVo vo) {
|
||||
public R bindCode(@Validated @RequestBody PlayClerkUserBindCodeVo vo) {
|
||||
String codeKey = "login_codes:" + SecurityUtils.getTenantId() + "_" + SecureUtil.md5(vo.getAreaCode() + vo.getPhone());
|
||||
String code = redisCache.getCacheObject(codeKey);
|
||||
if (code == null || !code.equals(vo.getCode())) {
|
||||
@@ -124,13 +125,13 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/add")
|
||||
public R userAdd(@Valid @RequestBody PlayClerkUserByWxAddVo vo) {
|
||||
public R userAdd(@Validated @RequestBody PlayClerkUserByWxAddVo vo) {
|
||||
String playUserId = ThreadLocalRequestDetail.getClerkUserInfo().getId();
|
||||
PlayClerkUserInfoEntity userInfo = playClerkUserInfoService.selectById(playUserId);
|
||||
if (userInfo == null) {
|
||||
throw new CustomException("系统错误,用户不存在");
|
||||
}
|
||||
if (userInfo.getClerkState().equals("1")) {
|
||||
if ("1".equals(userInfo.getClerkState())) {
|
||||
throw new CustomException("当前用户已经是店员");
|
||||
}
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
@@ -141,6 +142,8 @@ public class WxClerkController {
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setClarkAvatar(userInfo.getAvatar());
|
||||
dataReviewInfo.setClarkNickname(userInfo.getNickname());
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
@@ -150,7 +153,7 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAvatar")
|
||||
public R updateAvatar(@Valid @RequestBody PlayClerkUserAvatarVo vo) {
|
||||
public R updateAvatar(@Validated @RequestBody PlayClerkUserAvatarVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
@@ -161,6 +164,8 @@ public class WxClerkController {
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setClarkAvatar(userInfo.getAvatar());
|
||||
dataReviewInfo.setClarkNickname(userInfo.getNickname());
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
@@ -169,7 +174,7 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAlbum")
|
||||
public R updateAlbum(@Valid @RequestBody PlayClerkUserAlbumVo vo) {
|
||||
public R updateAlbum(@Validated @RequestBody PlayClerkUserAlbumVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
@@ -178,14 +183,17 @@ public class WxClerkController {
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setClarkAvatar(userInfo.getAvatar());
|
||||
dataReviewInfo.setClarkNickname(userInfo.getNickname());
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
}
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateAudio")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkUserAudioVo vo) {
|
||||
public R updateAudio(@Validated @RequestBody PlayClerkUserAudioVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ThreadLocalRequestDetail.getClerkUserInfo();
|
||||
PlayClerkDataReviewInfoEntity dataReviewInfo = new PlayClerkDataReviewInfoEntity();
|
||||
dataReviewInfo.setPlayUserId(userInfo.getId());
|
||||
@@ -194,6 +202,9 @@ public class WxClerkController {
|
||||
if (!dataReviewInfoService.queryList(dataReviewInfo).isEmpty()) {
|
||||
throw new CustomException("已有申请未审核");
|
||||
}
|
||||
dataReviewInfo.setAddTime(new Date());
|
||||
dataReviewInfo.setClarkAvatar(userInfo.getAvatar());
|
||||
dataReviewInfo.setClarkNickname(userInfo.getNickname());
|
||||
dataReviewInfo.setContent(JSONObject.toJSONString(vo));
|
||||
dataReviewInfoService.create(dataReviewInfo);
|
||||
return R.ok("申请成功");
|
||||
@@ -202,7 +213,7 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateOnlineState")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkUserOnlineStateVo vo) {
|
||||
public R updateAudio(@Validated @RequestBody PlayClerkUserOnlineStateVo vo) {
|
||||
String userId = ThreadLocalRequestDetail.getClerkUserInfo().getId();
|
||||
PlayClerkUserInfoEntity entity = new PlayClerkUserInfoEntity();
|
||||
entity.setOnlineState(vo.getOnlineState());
|
||||
@@ -213,15 +224,15 @@ public class WxClerkController {
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateCommodity")
|
||||
public R updateAudio(@Valid @RequestBody PlayClerkCommodityEditVo vo) {
|
||||
playClerkCommodityService.startStopClerkItem(vo.getCommodityType(), vo.getEnablingState());
|
||||
public R updateAudio(@Validated @RequestBody PlayClerkCommodityEditVo vo) {
|
||||
playClerkCommodityService.startStopClerkItem(vo.getCommodityType(), vo.getEnablingState(), ThreadLocalRequestDetail.getClerkUserInfo().getId());
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/user/updateOther")
|
||||
public R updateOther(@Valid @RequestBody PlayClerkUserOtherVo vo) {
|
||||
public R updateOther(@Validated @RequestBody PlayClerkUserOtherVo vo) {
|
||||
PlayClerkUserInfoEntity userInfo = ConvertUtil.entityToVo(vo, PlayClerkUserInfoEntity.class);
|
||||
userInfo.setId(ThreadLocalRequestDetail.getClerkUserInfo().getId());
|
||||
playClerkUserInfoService.update(userInfo);
|
||||
@@ -242,27 +253,28 @@ public class WxClerkController {
|
||||
* 分页获取店员列表
|
||||
*
|
||||
* @param vo PlayClerkUserInfoQueryVo
|
||||
* @return 店员礼列表
|
||||
* @return 店员列表
|
||||
*/
|
||||
|
||||
@PostMapping("/user/queryByPage")
|
||||
public R queryByPage(@RequestBody PlayClerkUserInfoQueryVo vo) {
|
||||
IPage<PlayClerkUserInfoEntity> page = playClerkUserInfoService.selectPlayClerkUserInfoByPage(vo);
|
||||
List<PlayClerkUserListResultVo> resultVos = new ArrayList<>();
|
||||
for (PlayClerkUserInfoEntity record : page.getRecords()) {
|
||||
PlayClerkUserListResultVo item = ConvertUtil.entityToVo(record, PlayClerkUserListResultVo.class);
|
||||
List<String> list = playClerkCommodityService.selectByUser(record.getId()).stream().map(PlayClerkCommodityEntity::getCommodityType).collect(Collectors.toList());
|
||||
item.setCommodity(list);
|
||||
resultVos.add(item);
|
||||
}
|
||||
IPage<PlayClerkUserListResultVo> page = playClerkUserInfoService.selectByPage(vo, customUserService.getLoginUserId());
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
IPage<PlayClerkUserListResultVo> resultPage = new Page<>();
|
||||
resultPage.setRecords(resultVos);
|
||||
// 设置分页参数
|
||||
resultPage.setCurrent(page.getCurrent());
|
||||
resultPage.setSize(page.getSize());
|
||||
resultPage.setTotal(resultVos.size()); // 假设total和实际情况一致
|
||||
return R.ok(resultPage);
|
||||
|
||||
/**
|
||||
* 获取推荐用户列表
|
||||
*
|
||||
* @return 店员列表
|
||||
*/
|
||||
@PostMapping("/user/queryByRecommend")
|
||||
public R queryByRecommend() {
|
||||
PlayClerkUserInfoQueryVo vo = new PlayClerkUserInfoQueryVo();
|
||||
vo.setPageNum(10);
|
||||
vo.setPageSize(9999);
|
||||
vo.setRecommendationState("1");
|
||||
IPage<PlayClerkUserListResultVo> page = playClerkUserInfoService.selectByPage(vo, "");
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,14 +290,17 @@ public class WxClerkController {
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
List<PlayGiftInfoEntity> list = new ArrayList<>();
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物1", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 0, "0"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物2", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 1, "0"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物3", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 2, "1"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物4", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 3, "1"));
|
||||
list.add(new PlayGiftInfoEntity(IdUtil.fastSimpleUUID(), "礼物5", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 4, "1"));
|
||||
|
||||
return R.ok(list);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<PlayGiftInfoVo> list = new ArrayList<>();
|
||||
list.add(new PlayGiftInfoVo(IdUtil.fastSimpleUUID(), "礼物1", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 0, "0"));
|
||||
list.add(new PlayGiftInfoVo(IdUtil.fastSimpleUUID(), "礼物2", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 1, "0"));
|
||||
list.add(new PlayGiftInfoVo(IdUtil.fastSimpleUUID(), "礼物3", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 2, "1"));
|
||||
list.add(new PlayGiftInfoVo(IdUtil.fastSimpleUUID(), "礼物4", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 3, "1"));
|
||||
list.add(new PlayGiftInfoVo(IdUtil.fastSimpleUUID(), "礼物5", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", 4, "1"));
|
||||
result.put("list", list);
|
||||
result.put("obtainedGift", list.size() - 1);
|
||||
result.put("totalGift", list.size());
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -356,6 +371,7 @@ public class WxClerkController {
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人3昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人4昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人5昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时"));
|
||||
entities.add(new PlayClarkUserEvaluateInfoEntity(IdUtil.fastSimpleUUID(), IdUtil.fastSimpleUUID(), "评价人5昵称", "https://live-cloud-cvoon.oss-cn-hangzhou.aliyuncs.com/d8e929c041e94075b93cfc6338a83d4c/2024/04/15/fc09da2f923d46e6951292ff8f34f6aa.png", "评价内容", new Date(), IdUtil.fastSimpleUUID(), "店员昵称", IdUtil.fastSimpleUUID(), "文字语音条", "一小时", 5));
|
||||
|
||||
IPage<PlayClarkUserEvaluateInfoEntity> resultPage = new Page<>();
|
||||
resultPage.setRecords(entities);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkCommodityEntity;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClarkCommodityTreeData;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx/commodity/")
|
||||
public class WxCommodityController {
|
||||
@Resource
|
||||
private IPlayClerkCommodityService clerkCommodityService;
|
||||
|
||||
@GetMapping("/getTree")
|
||||
public R getTree(@RequestParam("userId") String userId) {
|
||||
List<PlayClerkCommodityEntity> commodityEntities = clerkCommodityService.selectByUser(userId);
|
||||
Map<String, List<PlayClerkCommodityEntity>> item = commodityEntities.stream().collect(Collectors.groupingBy(PlayClerkCommodityEntity::getCommodityName));
|
||||
List<PlayClarkCommodityTreeData> result = new ArrayList<>();
|
||||
for (Map.Entry<String, List<PlayClerkCommodityEntity>> entry : item.entrySet()) {
|
||||
PlayClarkCommodityTreeData treeData = new PlayClarkCommodityTreeData(entry.getKey(), entry.getValue());
|
||||
result.add(treeData);
|
||||
}
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.common.oss.service.IOssFileService;
|
||||
import com.starry.admin.modules.system.entity.SysAdministrativeAreaDictInfoEntity;
|
||||
import com.starry.admin.modules.system.service.ISysAdministrativeAreaDictInfoService;
|
||||
import com.starry.admin.modules.weichat.service.WxAccessTokenService;
|
||||
import com.starry.admin.modules.weichat.utils.WxFileUtils;
|
||||
|
||||
@@ -1,15 +1,36 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkLevelInfoService;
|
||||
import com.starry.admin.modules.clear.service.impl.PlayClerkUserInfoServiceImpl;
|
||||
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.balance.service.IPlayBalanceDetailsInfoService;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkCommodityEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserListResultVo;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.follow.service.IPlayCustomFollowInfoService;
|
||||
import com.starry.admin.modules.gift.module.entity.PlayGiftInfoEntity;
|
||||
import com.starry.admin.modules.gift.service.IPlayGiftInfoService;
|
||||
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkFollowStateUpdate;
|
||||
import com.starry.admin.modules.weichat.entity.PlayOrderInfoCommodityAdd;
|
||||
import com.starry.admin.modules.weichat.entity.PlayOrderInfoGiftAdd;
|
||||
import com.starry.admin.modules.weichat.entity.PlayOrderInfoRewardAdd;
|
||||
import com.starry.admin.modules.weichat.service.WxCustomUserService;
|
||||
import com.starry.admin.utils.MoneyUtils;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -21,11 +42,206 @@ public class WxCustomController {
|
||||
|
||||
|
||||
@Resource
|
||||
private PlayClerkUserInfoServiceImpl playClerkUserInfoService;
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayGiftInfoService giftInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkCommodityService clerkCommodityService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayCustomFollowInfoService playCustomFollowInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayClerkCommodityService playClerkCommodityService;
|
||||
|
||||
@Resource
|
||||
private WxCustomUserService customUserService;
|
||||
|
||||
@Resource
|
||||
private IPlayOrderInfoService orderInfoService;
|
||||
|
||||
/**
|
||||
* 根据店员ID查询店员详细信息
|
||||
*
|
||||
* @param id 店员ID
|
||||
* @return 店员详细信息
|
||||
*/
|
||||
@GetMapping("/queryClarkDetailedById")
|
||||
public R queryClarkDetailedById(@RequestParam("id") String id) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(id);
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
PlayClerkUserListResultVo vo = ConvertUtil.entityToVo(entity, PlayClerkUserListResultVo.class);
|
||||
vo.setAddress(entity.getCity());
|
||||
// 查询是否关注,未登录情况下,默认为未关注
|
||||
String loginUserId = customUserService.getLoginUserId();
|
||||
if (StringUtils.isNotEmpty(loginUserId)) {
|
||||
vo.setFollowState(playCustomFollowInfoService.queryFollowState(loginUserId, vo.getId()));
|
||||
}
|
||||
//服务项目
|
||||
vo.setCommodity(playClerkCommodityService.getClerkCommodityList(vo.getId()));
|
||||
return R.ok(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询店员详细信息
|
||||
*/
|
||||
@CustomUserLogin
|
||||
@GetMapping("/queryById")
|
||||
public R queryById() {
|
||||
String userId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(userId);
|
||||
return R.ok(customUserInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打赏店员
|
||||
*/
|
||||
@CustomUserLogin
|
||||
@PostMapping("/order/reward")
|
||||
public R rewardToOrder(@Validated @RequestBody PlayOrderInfoRewardAdd vo) {
|
||||
MoneyUtils.verificationTypeIsNormal(vo.getMoney());
|
||||
String userId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(userId);
|
||||
if (customUserInfo == null) {
|
||||
throw new CustomException("用户身份异常");
|
||||
}
|
||||
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClearId());
|
||||
if (clerkUserInfo == null) {
|
||||
throw new CustomException("打赏对象不存在");
|
||||
}
|
||||
if (new BigDecimal(vo.getMoney()).compareTo(customUserInfo.getAccountBalance()) > 0) {
|
||||
throw new CustomException("余额不足");
|
||||
}
|
||||
// 记录订单信息
|
||||
orderInfoService.createRewardOrder(new BigDecimal(vo.getMoney()), new BigDecimal(vo.getMoney()), userId);
|
||||
|
||||
// 顾客减少余额
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance().subtract(new BigDecimal(vo.getMoney())));
|
||||
playBalanceDetailsInfoService.create("0", customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(new BigDecimal(vo.getMoney())), "打赏", new BigDecimal(vo.getMoney()).multiply(new BigDecimal("-1")));
|
||||
|
||||
// 陪玩增加余额
|
||||
clerkUserInfoService.updateAccountBalanceById(clerkUserInfo.getId(), clerkUserInfo.getAccountBalance().add(new BigDecimal(vo.getMoney())));
|
||||
playBalanceDetailsInfoService.create("1", clerkUserInfo.getId(), clerkUserInfo.getAccountBalance(), clerkUserInfo.getAccountBalance().add(new BigDecimal(vo.getMoney())), "打赏", new BigDecimal(vo.getMoney()).multiply(new BigDecimal("1")));
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
@CustomUserLogin
|
||||
@PostMapping("/order/gift")
|
||||
public R giftToOdder(@Validated @RequestBody PlayOrderInfoGiftAdd vo) {
|
||||
int giftQuantity;
|
||||
try {
|
||||
giftQuantity = Integer.parseInt(vo.getGiftQuantity());
|
||||
} catch (Exception e) {
|
||||
throw new CustomException("礼物数量异常");
|
||||
}
|
||||
if (giftQuantity <= 0 || giftQuantity > 10000) {
|
||||
throw new CustomException("礼物数量必须大于0并且小于1000");
|
||||
}
|
||||
String userId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
|
||||
PlayGiftInfoEntity giftInfo = giftInfoService.selectPlayGiftInfoById(vo.getGiftId());
|
||||
if (giftInfo == null) {
|
||||
throw new CustomException("礼物不存在");
|
||||
}
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(userId);
|
||||
if (customUserInfo == null) {
|
||||
throw new CustomException("用户身份异常");
|
||||
}
|
||||
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClearId());
|
||||
if (clerkUserInfo == null) {
|
||||
throw new CustomException("打赏对象不存在");
|
||||
}
|
||||
BigDecimal money = giftInfo.getPrice().multiply(new BigDecimal(vo.getGiftQuantity()));
|
||||
|
||||
if (money.compareTo(customUserInfo.getAccountBalance()) > 0) {
|
||||
throw new CustomException("账号余额不足");
|
||||
}
|
||||
// 记录订单信息
|
||||
|
||||
orderInfoService.createGiftOrder(vo.getGiftId(), giftInfo.getPrice(), vo.getGiftQuantity(), money, money, userId);
|
||||
|
||||
// 顾客减少余额
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance().subtract(money));
|
||||
playBalanceDetailsInfoService.create("0", customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(money), "赠送礼物", money.multiply(new BigDecimal("-1")));
|
||||
|
||||
// 陪玩增加余额
|
||||
clerkUserInfoService.updateAccountBalanceById(clerkUserInfo.getId(), clerkUserInfo.getAccountBalance().add(money));
|
||||
playBalanceDetailsInfoService.create("1", clerkUserInfo.getId(), clerkUserInfo.getAccountBalance(), clerkUserInfo.getAccountBalance().add(money), "赠送礼物", money.multiply(new BigDecimal("1")));
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
@CustomUserLogin
|
||||
@PostMapping("/order/commodity")
|
||||
public R commodityToOdder(@Validated @RequestBody PlayOrderInfoCommodityAdd vo) {
|
||||
int commodityId;
|
||||
try {
|
||||
commodityId = Integer.parseInt(vo.getCommodityQuantity());
|
||||
} catch (Exception e) {
|
||||
throw new CustomException("礼物数量异常");
|
||||
}
|
||||
if (commodityId <= 0 || commodityId > 10000) {
|
||||
throw new CustomException("购买数量必须大于0并且小于1000");
|
||||
}
|
||||
String userId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
|
||||
|
||||
PlayClerkCommodityEntity clerkCommodity = clerkCommodityService.selectPlayClerkCommodityById(vo.getCommodityId());
|
||||
if (clerkCommodity == null) {
|
||||
throw new CustomException("服务不存在");
|
||||
}
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(userId);
|
||||
if (customUserInfo == null) {
|
||||
throw new CustomException("用户身份异常");
|
||||
}
|
||||
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClearId());
|
||||
if (clerkUserInfo == null) {
|
||||
throw new CustomException("打赏对象不存在");
|
||||
}
|
||||
BigDecimal money = clerkCommodity.getCommodityPrice().multiply(new BigDecimal(vo.getCommodityQuantity()));
|
||||
|
||||
if (money.compareTo(customUserInfo.getAccountBalance()) > 0) {
|
||||
throw new CustomException("余额不足");
|
||||
}
|
||||
// 记录订单信息
|
||||
|
||||
orderInfoService.createOrdinaryOrder("2", "0", clerkCommodity.getCommodityId(), clerkCommodity.getCommodityPrice(), vo.getCommodityQuantity(), money, money, userId);
|
||||
|
||||
// 顾客减少余额
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance().subtract(money));
|
||||
playBalanceDetailsInfoService.create("0", customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(money), "打赏", money.multiply(new BigDecimal("-1")));
|
||||
// 陪玩增加余额
|
||||
clerkUserInfoService.updateAccountBalanceById(clerkUserInfo.getId(), clerkUserInfo.getAccountBalance().add(money));
|
||||
playBalanceDetailsInfoService.create("1", clerkUserInfo.getId(), clerkUserInfo.getAccountBalance(), clerkUserInfo.getAccountBalance().add(money), "下单", money.multiply(new BigDecimal("1")));
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
@CustomUserLogin
|
||||
@PostMapping("/followState/update")
|
||||
public R followStateUpdate(@Validated @RequestBody PlayClerkFollowStateUpdate vo) {
|
||||
PlayClerkUserInfoEntity clerkUserInfo = clerkUserInfoService.selectById(vo.getClearId());
|
||||
if (clerkUserInfo == null) {
|
||||
throw new CustomException("关注对象不存在");
|
||||
}
|
||||
playCustomFollowInfoService.updateFollowState(ThreadLocalRequestDetail.getCustomUserInfo().getId(), vo.getClearId(), vo.getFollowState());
|
||||
return R.ok("修改成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import com.starry.admin.modules.gift.service.IPlayGiftInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayGiftInfoDto;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
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.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx/gift/")
|
||||
public class WxGiftController {
|
||||
@Resource
|
||||
private IPlayGiftInfoService giftInfoService;
|
||||
|
||||
@GetMapping("/listByAll")
|
||||
public R rewardToOrder() {
|
||||
return R.ok(ConvertUtil.entityToVoList(giftInfoService.listByAll(),PlayGiftInfoDto.class));
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.WxUserLoginVo;
|
||||
import com.starry.admin.modules.weichat.entity.WxUserQueryAddressVo;
|
||||
import com.starry.admin.modules.weichat.service.WxCustomMpService;
|
||||
import com.starry.admin.modules.weichat.service.WxCustomUserService;
|
||||
import com.starry.admin.modules.weichat.service.WxOauthService;
|
||||
import com.starry.admin.modules.weichat.service.WxTokenService;
|
||||
import com.starry.common.redis.RedisCache;
|
||||
@@ -20,10 +22,10 @@ import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.starry.common.constant.Constants.*;
|
||||
@@ -41,7 +43,7 @@ public class WxOauthController {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxCustomService wxCustomService;
|
||||
private WxCustomMpService wxCustomMpService;
|
||||
|
||||
@Resource
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
@@ -66,7 +68,7 @@ public class WxOauthController {
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
WxJsapiSignature wxJsapiSignature = wxCustomService.proxyWxMpService().createJsapiSignature(defaultAddress);
|
||||
WxJsapiSignature wxJsapiSignature = wxCustomMpService.proxyWxMpService().createJsapiSignature(defaultAddress);
|
||||
return R.ok(wxJsapiSignature);
|
||||
}
|
||||
|
||||
@@ -77,7 +79,7 @@ public class WxOauthController {
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
String url = wxCustomService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
String url = wxCustomMpService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
return R.ok(url);
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ public class WxOauthController {
|
||||
|
||||
|
||||
@PostMapping("/clark/login")
|
||||
public R clerkLogin(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
public R clerkLogin(@Validated @RequestBody WxUserLoginVo vo) {
|
||||
String userId = wxOauthService.clarkUserLogin(vo.getCode());
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(userId);
|
||||
if (entity == null) {
|
||||
@@ -107,7 +109,7 @@ public class WxOauthController {
|
||||
}
|
||||
|
||||
@PostMapping("/clark/loginById")
|
||||
public R loginById(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
public R loginById(@Validated @RequestBody WxUserLoginVo vo) {
|
||||
PlayClerkUserInfoEntity entity = clerkUserInfoService.selectById(vo.getCode());
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
@@ -139,7 +141,7 @@ public class WxOauthController {
|
||||
if (!StrUtil.isBlankIfStr(vo.getUrl())) {
|
||||
defaultAddress = vo.getUrl();
|
||||
}
|
||||
String url = wxCustomService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
String url = wxCustomMpService.proxyWxMpService().getOAuth2Service().buildAuthorizationUrl(defaultAddress, "snsapi_userinfo", "STATE");
|
||||
return R.ok(url);
|
||||
}
|
||||
|
||||
@@ -150,7 +152,7 @@ public class WxOauthController {
|
||||
|
||||
|
||||
@PostMapping("/custom/login")
|
||||
public R customLogin(@Valid @RequestBody WxUserLoginVo vo) {
|
||||
public R customLogin(@Validated @RequestBody WxUserLoginVo vo) {
|
||||
String userId = wxOauthService.customUserLogin(vo.getCode());
|
||||
PlayCustomUserInfoEntity entity = customUserInfoService.selectById(userId);
|
||||
if (entity == null) {
|
||||
@@ -168,6 +170,24 @@ public class WxOauthController {
|
||||
return R.ok(jsonObject);
|
||||
}
|
||||
|
||||
@PostMapping("/custom/loginById")
|
||||
public R loginById1(@Validated @RequestBody WxUserLoginVo vo) {
|
||||
PlayCustomUserInfoEntity entity = customUserInfoService.selectById(vo.getCode());
|
||||
if (entity == null) {
|
||||
throw new CustomException("用户不存在");
|
||||
}
|
||||
// 缓存租户信息
|
||||
String redisKey = "TENANT_INFO:" + entity.getId();
|
||||
redisCache.setCacheObject(redisKey, entity.getTenantId());
|
||||
JSONObject jsonObject = JSONObject.from(clerkUserInfoService.getVo(new PlayClerkUserInfoEntity()));
|
||||
String tokenValue = tokenService.createWxUserToken(entity.getId());
|
||||
jsonObject.put("tokenValue", TOKEN_PREFIX + tokenValue);
|
||||
jsonObject.put("tokenName", CLERK_USER_LOGIN_TOKEN);
|
||||
jsonObject.put("loginDate", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
customUserInfoService.updateTokenById(entity.getId(), tokenValue);
|
||||
return R.ok(jsonObject);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/custom/logout")
|
||||
@CustomUserLogin
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
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.balance.service.IPlayBalanceDetailsInfoService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.platform.service.impl.SysTenantServiceImpl;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
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.math.BigDecimal;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx/play/")
|
||||
public class WxPlayController {
|
||||
|
||||
|
||||
@Resource
|
||||
private SysTenantServiceImpl tenantService;
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayOrderInfoService orderInfoService;
|
||||
|
||||
|
||||
@CustomUserLogin
|
||||
@GetMapping("/custom/createOrder")
|
||||
public R createOrder(@RequestParam("money") String money) {
|
||||
if (StringUtils.isEmpty(money)) {
|
||||
throw new CustomException("请求参数错误,money不能为空");
|
||||
}
|
||||
|
||||
String tenantId = SecurityUtils.getTenantId();
|
||||
if (StrUtil.isBlankIfStr(tenantId)) {
|
||||
throw new CustomException("系统错误,租户ID不能为空");
|
||||
}
|
||||
SysTenantEntity entity = tenantService.selectSysTenantByTenantId(tenantId);
|
||||
if (entity == null) {
|
||||
throw new CustomException("系统错误,租户ID不能为空");
|
||||
}
|
||||
|
||||
|
||||
String openId = ThreadLocalRequestDetail.getCustomUserInfo().getOpenid();
|
||||
//订单总金额,单位为分
|
||||
int totalFee = getTotalFee(money);
|
||||
// String orderId = IdUtil.fastSimpleUUID();
|
||||
// String body = "body";
|
||||
//
|
||||
// try {
|
||||
// String id = WxPlayUtils.unifiedOrderJSAPI(openId, entity.getAppId(), entity.getMchId(), orderId, "127.0.0.1", body, SecurityUtils.getTenantId(), totalFee);
|
||||
// return R.ok(id);
|
||||
// } catch (Exception e) {
|
||||
// log.error("创建支付订单失败,error=", e);
|
||||
// throw new CustomException("创建支付订单失败," + e.getMessage());
|
||||
// }
|
||||
|
||||
String userId = ThreadLocalRequestDetail.getCustomUserInfo().getId();
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.selectById(userId);
|
||||
if (customUserInfo == null) {
|
||||
throw new CustomException("用户身份异常");
|
||||
}
|
||||
|
||||
orderInfoService.createRechargeOrder(new BigDecimal(totalFee / 100), new BigDecimal(totalFee / 100), userId);
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance().add(new BigDecimal(totalFee / 100)));
|
||||
playBalanceDetailsInfoService.create("1", customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().add(new BigDecimal(totalFee / 100)), "充值", new BigDecimal(totalFee / 100));
|
||||
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param money 金额,单位-元
|
||||
* @return 金额, 单位-分
|
||||
*/
|
||||
public int getTotalFee(String money) {
|
||||
int totalFee;
|
||||
try {
|
||||
totalFee = (int) Float.parseFloat(money) * 100;
|
||||
} catch (Exception e) {
|
||||
throw new CustomException("请求参数错误,money类型异常");
|
||||
}
|
||||
if (totalFee <= 0 || totalFee > 1000000) {
|
||||
throw new CustomException("请求参数错误,单笔支付金额必须大于0,且小于10000");
|
||||
}
|
||||
return totalFee;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkCommodityEntity;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员商品树状数据
|
||||
*/
|
||||
@Data
|
||||
public class PlayClarkCommodityTreeData {
|
||||
|
||||
private String commodityType;
|
||||
|
||||
|
||||
private List<ClarkCommodityInfo> value;
|
||||
|
||||
|
||||
public PlayClarkCommodityTreeData(String commodityType, List<PlayClerkCommodityEntity> value) {
|
||||
this.commodityType = commodityType;
|
||||
this.value = ConvertUtil.entityToVoList(value, ClarkCommodityInfo.class);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ClarkCommodityInfo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String commodityName;
|
||||
|
||||
private BigDecimal commodityPrice;
|
||||
|
||||
private String serviceDuration;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 店员和陪玩关注状态
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayClerkFollowStateUpdate {
|
||||
|
||||
|
||||
/**
|
||||
* 店员用户ID
|
||||
*/
|
||||
@NotBlank(message = "打赏对象不能为空")
|
||||
private String clearId;
|
||||
|
||||
@NotBlank(message = "关注状态不能为空")
|
||||
@Pattern(regexp = "[01]", message = "关注状态必须为0或者1")
|
||||
private String followState;
|
||||
}
|
||||
@@ -82,6 +82,12 @@ public class PlayClerkUserByWxAddVo {
|
||||
@Size(min = 1, max = 5, message = "照片必须为1-5张")
|
||||
private List<String> album;
|
||||
|
||||
|
||||
/**
|
||||
* 个性签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PlayClerkUserLoginResponseVo {
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<String> labels = new ArrayList<>();
|
||||
private List<String> label = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 分类
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PlayClerkUserOtherVo {
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private List<String> labels = new ArrayList<>();
|
||||
private List<String> label = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 分类
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PlayGiftInfoDto {
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 礼物名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 礼物类型(0:盲盒,1:普通礼物)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 礼物图片地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 价格单位
|
||||
*/
|
||||
private String unit;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新增赠礼订单实体
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayOrderInfoCommodityAdd {
|
||||
|
||||
|
||||
/**
|
||||
* 店员用户ID
|
||||
*/
|
||||
@NotBlank(message = "打赏对象不能为空")
|
||||
private String clearId;
|
||||
|
||||
|
||||
@NotBlank(message = "商品ID不能为空")
|
||||
private String commodityId;
|
||||
|
||||
@NotBlank(message = "礼物数量不能为空")
|
||||
private String commodityQuantity;
|
||||
|
||||
|
||||
@NotBlank(message = "微信号不能为空")
|
||||
private String weiChatCode;
|
||||
|
||||
/**
|
||||
* 优惠券ID列表
|
||||
*/
|
||||
private List<String> couponIds;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 新增赠礼订单实体
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Data
|
||||
public class PlayOrderInfoGiftAdd {
|
||||
|
||||
|
||||
/**
|
||||
* 店员用户ID
|
||||
*/
|
||||
@NotBlank(message = "打赏对象不能为空")
|
||||
private String clearId;
|
||||
|
||||
|
||||
@NotBlank(message = "礼物ID不能为空")
|
||||
private String giftId;
|
||||
|
||||
@NotBlank(message = "礼物数量不能为空")
|
||||
private String giftQuantity;
|
||||
|
||||
|
||||
@NotBlank(message = "微信号不能为空")
|
||||
private String weiChatCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 新增打赏订单实体
|
||||
*/
|
||||
@Data
|
||||
public class PlayOrderInfoRewardAdd {
|
||||
|
||||
|
||||
/**
|
||||
* 店员用户ID
|
||||
*/
|
||||
@NotBlank(message = "打赏对象不能为空")
|
||||
private String clearId;
|
||||
/**
|
||||
* 打赏金额
|
||||
*/
|
||||
@NotBlank(message = "打赏金额不能为空")
|
||||
private String money;
|
||||
|
||||
@NotBlank(message = "微信号不能为空")
|
||||
private String weiChatCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.starry.admin.modules.weichat.service;
|
||||
|
||||
|
||||
import com.starry.admin.modules.weichat.controller.WxCustomService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -19,7 +18,7 @@ public class WxAccessTokenService {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxCustomService wxCustomService;
|
||||
private WxCustomMpService wxCustomMpService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,7 +27,7 @@ public class WxAccessTokenService {
|
||||
* @return access_token
|
||||
*/
|
||||
public String getAccessToken() throws WxErrorException {
|
||||
String token = wxCustomService.proxyWxMpService().getAccessToken();
|
||||
String token = wxCustomMpService.proxyWxMpService().getAccessToken();
|
||||
log.error("token = " + token);
|
||||
//缓存业务处理
|
||||
return token;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
package com.starry.admin.modules.weichat.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
@@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WxCustomService {
|
||||
public class WxCustomMpService {
|
||||
|
||||
@Resource
|
||||
private WxMpService wxMpService;
|
||||
@@ -38,4 +38,6 @@ public class WxCustomService {
|
||||
wxMpService.addConfigStorage(entity.getAppId(), config);
|
||||
return wxMpService.switchoverTo(entity.getAppId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.starry.admin.modules.weichat.service;
|
||||
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.common.constant.Constants;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WxCustomUserService {
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
@Resource
|
||||
private WxTokenService tokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前登录顾客ID
|
||||
*
|
||||
* @return 当前登录顾客ID
|
||||
*/
|
||||
public String getLoginUserId() {
|
||||
String userToken = request.getHeader(com.starry.common.constant.Constants.CUSTOM_USER_LOGIN_TOKEN);
|
||||
if (StringUtils.isEmpty(userToken)) {
|
||||
return "";
|
||||
}
|
||||
if (userToken.startsWith(com.starry.common.constant.Constants.TOKEN_PREFIX)) {
|
||||
userToken = userToken.replace(Constants.TOKEN_PREFIX, "");
|
||||
}
|
||||
// 解析token
|
||||
String userId;
|
||||
try {
|
||||
userId = tokenService.getWxUserIdByToken(userToken);
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
PlayCustomUserInfoEntity entity = customUserInfoService.selectById(userId);
|
||||
if (Objects.isNull(entity)) {
|
||||
return "";
|
||||
}
|
||||
return userToken.equals(entity.getToken()) ? userId : "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,10 +5,11 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.admin.modules.clear.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkLevelInfoService;
|
||||
import com.starry.admin.modules.clear.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.weichat.controller.WxCustomService;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
|
||||
@@ -17,6 +18,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -24,7 +26,7 @@ public class WxOauthService {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxCustomService wxCustomService;
|
||||
private WxCustomMpService wxCustomMpService;
|
||||
|
||||
|
||||
@Resource
|
||||
@@ -33,6 +35,12 @@ public class WxOauthService {
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkLevelInfoService playClerkLevelInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayCustomLevelInfoService playCustomLevelInfoService;
|
||||
|
||||
|
||||
/**
|
||||
* 微信用户登录
|
||||
@@ -54,6 +62,7 @@ public class WxOauthService {
|
||||
PlayClerkUserInfoEntity entity = ConvertUtil.entityToVo(userInfo, PlayClerkUserInfoEntity.class);
|
||||
entity.setAvatar(userInfo.getHeadImgUrl());
|
||||
entity.setId(IdUtil.fastSimpleUUID());
|
||||
entity.setLevelId(playClerkLevelInfoService.getDefaultLevel().getId());
|
||||
clerkUserInfoService.create(entity);
|
||||
return entity.getId();
|
||||
} else {
|
||||
@@ -81,7 +90,14 @@ public class WxOauthService {
|
||||
PlayCustomUserInfoEntity entity = ConvertUtil.entityToVo(userInfo, PlayCustomUserInfoEntity.class);
|
||||
entity.setAvatar(userInfo.getHeadImgUrl());
|
||||
PlayCustomUserInfoEntity item = customUserInfoService.selectByOpenid(openId);
|
||||
entity.setId(item != null ? item.getId() : IdUtil.fastSimpleUUID());
|
||||
if (item == null) {
|
||||
entity.setId(IdUtil.fastSimpleUUID());
|
||||
entity.setRegistrationTime(new Date());
|
||||
entity.setLevelId(playCustomLevelInfoService.getDefaultLevel().getId());
|
||||
} else {
|
||||
entity.setId(item.getId());
|
||||
}
|
||||
entity.setLastLoginTime(new Date());
|
||||
customUserInfoService.saveOrUpdate(entity);
|
||||
return entity.getId();
|
||||
}
|
||||
@@ -101,7 +117,7 @@ public class WxOauthService {
|
||||
}
|
||||
synchronized (code.intern()) {
|
||||
try {
|
||||
return wxCustomService.proxyWxMpService().getOAuth2Service().getAccessToken(code);
|
||||
return wxCustomMpService.proxyWxMpService().getOAuth2Service().getAccessToken(code);
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -140,7 +156,7 @@ public class WxOauthService {
|
||||
throw new ServiceException("获取微信授权异常,WxOAuth2AccessToken不能为空");
|
||||
}
|
||||
try {
|
||||
return wxCustomService.proxyWxMpService().getOAuth2Service().getUserInfo(token, null);
|
||||
return wxCustomMpService.proxyWxMpService().getOAuth2Service().getUserInfo(token, null);
|
||||
} catch (WxErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user