Browse Source

对接拼团数据

master
wangfukang 4 weeks ago
parent
commit
41b157f146
  1. 6
      hiver-admin/src/main/resources/application.yml
  2. 2
      hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java
  3. 4
      hiver-core/src/main/java/cc/hiver/core/entity/Worker.java
  4. 2
      hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java
  5. 24
      hiver-core/src/main/java/cc/hiver/core/serviceimpl/UserServiceImpl.java
  6. 19
      hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java
  7. 3
      hiver-core/src/main/java/cc/hiver/core/vo/WorkerQueryVO.java
  8. 36
      hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java
  9. 54
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java
  10. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerRelaPriceController.java
  11. 10
      hiver-modules/hiver-social/src/main/java/cc/hiver/social/controller/WechatController.java
  12. 4
      hiver-modules/hiver-social/src/main/java/cc/hiver/social/handler/WxServerMsgHandler.java

6
hiver-admin/src/main/resources/application.yml

@ -26,7 +26,7 @@ spring:
# 数据源
datasource:
# url: jdbc:mysql://154.8.162.157:3306/hiver_shop?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
url: jdbc:mysql://8.140.253.224:3306/school?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true
url: jdbc:mysql://8.140.253.224:3306/school?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=10
username: root
# Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果) 以下解密结果为123456
password: ENC(87YloapnWG6mLejOa27eLN0afFhCrbAGxoHXXrSUrGJ0trM/BndC2kx/gfoJsXIi)
@ -252,9 +252,9 @@ wx:
templateId: o9YG7vWS8It-mddU2Wnknf1jgzTqZtLeBQRLhF54SXQ
mp:
# 微信公众号的appid
appId: wx415a86fa6c2eff11
appId: wx0a49a4804987aa99
# 信公众号的app secret
secret: b4bf01832f7a640353367d8979409900
secret: c94f47ce35d41f18c46ee628a4328484
# 微信公众号的toke
token: kuaiyidian
# 微信公众号的EncodingAESKey

2
hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java

@ -13,6 +13,8 @@ public interface WorkerDao extends HiverBaseDao<Worker, String> {
Worker findByUsername(String username);
Worker findByUserId(String userId);
@Modifying
@Query("update Worker w set w.isOnLine=?2 where w.workerId=?1")
void changeOnLine(String id, Integer onLine);

4
hiver-core/src/main/java/cc/hiver/core/entity/Worker.java

@ -153,6 +153,10 @@ public class Worker implements Serializable {
@ApiModelProperty(value = "手上的待接单订单数")
private Integer orderWaitCount;
@Transient
@ApiModelProperty(value = "用户切换校区")
private Integer isChangeArea;
@Transient
@ApiModelProperty(value = "手上的待取货订单数")
private Integer orderGetCount;

2
hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java

@ -28,6 +28,8 @@ public interface WorkerService extends HiverBaseService<Worker, String> {
Worker findByMobile(String mobile);
Worker findByUserId(String userId);
Worker findByWorkerId(String workerId);
List<Worker> getWXByCondition(WorkerQueryVO worker);

24
hiver-core/src/main/java/cc/hiver/core/serviceimpl/UserServiceImpl.java

@ -2,9 +2,7 @@ package cc.hiver.core.serviceimpl;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.UserConstant;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.utils.StringUtils;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.dao.UserDao;
@ -281,11 +279,11 @@ public class UserServiceImpl implements UserService {
final Map<String, Object> resultMap = new HashMap<>();
if (wechatUser != null) {
wechatUser.setOfficialAccountOpenid(openid);
if (!wechatUser.getType().contains(UserConstant.USER_TYPE_CUSTOM)) {
/*if (!wechatUser.getType().contains(UserConstant.USER_TYPE_CUSTOM)) {
// 不包含,赋予下游客户身份
final String newUserType = StringUtils.isEmpty(wechatUser.getType()) ? UserConstant.USER_TYPE_CUSTOM : wechatUser.getType() + ',' + UserConstant.USER_TYPE_CUSTOM;
wechatUser.setType(newUserType);
}
}*/
} else {
try {
// 新增用户信息
@ -293,20 +291,20 @@ public class UserServiceImpl implements UserService {
wechatUser.setUnionid(unionid);
wechatUser.setOfficialAccountOpenid(openid);
wechatUser.setStatus(UserConstant.USER_STATUS_NORMAL);
wechatUser.setType(UserConstant.USER_TYPE_CUSTOM);
wechatUser.setType(UserConstant.USER_TYPE_NORMAL);
wechatUser = save(wechatUser);
// 设置用户角色
final UserRole userRole = new UserRole();
final PageVo pageVo = new PageVo();
pageVo.setPageNumber(1);
pageVo.setPageSize(1);
final Page<Role> roleCustomer = roleService.findByCondition("ROLE_CUSTOMER", PageUtil.initPage(pageVo));
final Role role = roleCustomer.getContent().get(0);
//客户角色
userRole.setRoleId(role.getId());
userRole.setRoleName("客户");
userRole.setUserId(wechatUser.getId());
userRoleService.save(userRole);
// 默认角色
final List<Role> roleList = roleService.findByDefaultRole(true);
if (roleList != null && roleList.size() > 0) {
for (Role role : roleList) {
final UserRole ur = new UserRole().setUserId(wechatUser.getId()).setRoleId(role.getId());
userRoleService.save(ur);
}
}
// 更新客户信息,绑定登录用户
// customerService.updateUserId(wechatVo.getCustomId(),wechatUser.getId());
// 返回当前登录人的信息

19
hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java

@ -23,7 +23,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 用户接口实现
@ -65,6 +67,7 @@ public class WorkerServiceImpl implements WorkerService {
final Path<Date> createTimeField = root.get("createTime");
final Path<Date> signPersonField = root.get("signPerson");
final Path<String> isOnLineField = root.get("isOnLine");
final Path<String> userIdField = root.get("userId");
final List<Predicate> list = new ArrayList<>();
@ -73,6 +76,10 @@ public class WorkerServiceImpl implements WorkerService {
list.add(cb.equal(workerIdField, worker.getWorkerId()));
}
if (CharSequenceUtil.isNotBlank(worker.getUserId())) {
list.add(cb.equal(userIdField, worker.getUserId()));
}
if (CharSequenceUtil.isNotBlank(worker.getSignPerson())) {
list.add(cb.equal(signPersonField, worker.getSignPerson()));
}
@ -130,14 +137,14 @@ public class WorkerServiceImpl implements WorkerService {
for (Worker worker1 : content) {
workerIdList.add(worker1.getWorkerId());
}
// 查询每个拉包工身上的单子数量
/*// 查询每个拉包工身上的单子数量
final List<Map<String, Object>> workerOrderCountList = orderOfCoreService.findWorkerOrderCount(workerIdList);
Map<String,Integer> workerOrderCountMap = new HashMap<>();
for (Map<String, Object> stringIntegerMap : workerOrderCountList) {
String workId = stringIntegerMap.get("workId").toString();
String orderCount = stringIntegerMap.get("orderCount").toString();
workerOrderCountMap.put(workId, Integer.valueOf(orderCount));
}
}*/
return workerPage;
}
@ -147,6 +154,12 @@ public class WorkerServiceImpl implements WorkerService {
return worker;
}
@Override
public Worker findByUserId(String userId) {
final Worker worker = workerDao.findByUserId(userId);
return worker;
}
@Override
public Worker findByWorkerId(String orderId) {
return workerDao.findByWorkerId(orderId);

3
hiver-core/src/main/java/cc/hiver/core/vo/WorkerQueryVO.java

@ -115,4 +115,7 @@ public class WorkerQueryVO extends HiverBasePageQuery {
@ApiModelProperty("后台管理系统标识")
private String adminFlag;
@ApiModelProperty("后台管理系统标识")
private String userId;
}

36
hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java

@ -13,17 +13,12 @@ import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.dao.mapper.DeleteMapper;
import cc.hiver.core.entity.Department;
import cc.hiver.core.entity.Role;
import cc.hiver.core.entity.User;
import cc.hiver.core.entity.UserRole;
import cc.hiver.core.entity.*;
import cc.hiver.core.service.*;
import cc.hiver.core.service.mybatis.IUserRoleService;
import cc.hiver.core.vo.RoleDTO;
import cc.hiver.core.vo.WechatVo;
import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.entity.ShopArea;
import cc.hiver.mall.entity.ShopUser;
import cc.hiver.mall.service.ShopAreaService;
import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.ShopUserService;
@ -76,6 +71,9 @@ public class UserController {
@Autowired
private DepartmentService departmentService;
@Autowired
private WorkerService workerService;
@Autowired
private ShopAreaService shopAreaService;
@ -255,7 +253,7 @@ public class UserController {
u.setMobile(mobile);
userService.update(u);
// 删除缓存
redisTemplate.delete(USER + u.getUsername());
//redisTemplate.delete(USER + u.getUsername());
return ResultUtil.success("修改手机号成功");
}
@ -674,28 +672,8 @@ public class UserController {
// 返回当前登录人的信息
resultMap.put("user", wechatUser);
// 店铺登录的话,根据登录人查询所有关联的店铺(店铺启用,并且在有效期内)
if (UserConstant.USER_TYPE_NORMAL.equals(wechatUser.getType())) {
// 获取
final List<ShopUser> shopUsers = shopUserService.selectByUserId(wechatUser.getId());
if (shopUsers != null && !shopUsers.isEmpty()) {
// 获取店主手机号
for (ShopUser shopUser : shopUsers) {
final Shop shop = shopService.findById(shopUser.getShop().getId());
if (shop != null && shop.getShopOwnerId() != null && StringUtils.isNotEmpty(shop.getShopOwnerId())) {
final User shopOwner = userService.findById(shop.getShopOwnerId());
if (shopOwner != null) {
shopUser.setShopOwnerName(shopOwner.getNickname());
shopUser.setShopOwnerPhone(shopOwner.getMobile());
}
}
}
resultMap.put("shopList", shopUsers);
} else {
return ResultUtil.error("店铺未开通!");
}
}
Worker worker = workerService.findByUserId(wechatUser.getId());
resultMap.put("worker", worker);
return ResultUtil.data(resultMap);
}

54
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java

@ -4,7 +4,9 @@ import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.WorkerConstant;
import cc.hiver.core.common.utils.BeanUtils;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.core.entity.Worker;
import cc.hiver.core.service.WorkerService;
import cc.hiver.core.vo.WorkerAppVO;
@ -57,6 +59,9 @@ public class WorkerController {
@Autowired
private WorkerRelaPriceMapper workerRelaPriceMapper;
@Autowired
private SecurityUtil securityUtil;
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST)
@ApiOperation(value = "多条件分页获取订单列表")
public Result<Page<Worker>> getByCondition(@RequestBody WorkerQueryVO worker) {
@ -91,33 +96,32 @@ public class WorkerController {
}
@RequestMapping(value = "/admin/add", method = RequestMethod.POST)
@ApiOperation(value = "创建配送员")
public Result add(@Valid Worker u) {
// 添加商圈名称
if (StrUtil.isNotBlank(u.getRegion())) {
ShopArea d = shopAreaService.get(u.getRegion());
if (d != null) {
u.setRegionTitle(d.getTitle());
@ApiOperation(value = "创建配送员或切换校区")
public Result<Worker> add(@Valid Worker u) {
final User user = securityUtil.getCurrUser();
Worker worker = workerService.findByUserId(user.getId());
if(worker != null){
if(u.getRegion().equals(worker.getRegion())){
return new ResultUtil<Worker>().setData(worker);
}else{
worker.setRegion(u.getRegion());
workerService.update(worker);
return new ResultUtil<Worker>().setData(worker);
}
}else{
if(u.getIsChangeArea() != null && u.getIsChangeArea() == 0){
return new ResultUtil<Worker>().setData(worker);
}else{
u.setWorkerName(user.getNickname());
u.setUserId(user.getId());
u.setAvgTime(BigDecimal.valueOf(30));
u.setMobile(user.getMobile());
u.setIsOnLine(CommonConstant.OFF_LINE);
u.setScore(BigDecimal.valueOf(5));
workerService.save(u);
return new ResultUtil<Worker>().setData(u);
}
} else {
u.setRegion(null);
u.setRegionTitle("");
}
//更新充值记录
Recharge recharge = new Recharge();
recharge.setRechargeName(u.getWorkerName());
recharge.setRechargeWorkerId(u.getWorkerId());
recharge.setMobile(u.getMobile());
rechargeService.save(recharge);
//更新余额,重置当次应缴
u.setIsOnLine(CommonConstant.ON_LINE);
workerService.save(u);
return ResultUtil.success("创建成功");
}
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST)

12
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerRelaPriceController.java

@ -52,11 +52,13 @@ public class WorkerRelaPriceController {
public Result<WorkerRealPriceVo> getByProductId(@RequestParam String workerId) {
WorkerRealPriceVo workerRealPriceVo = new WorkerRealPriceVo();
Worker worker = workerService.findByWorkerId(workerId);
workerRealPriceVo.setWorkerName(worker.getWorkerName());
workerRealPriceVo.setCardPicture(worker.getCardPicture());
workerRealPriceVo.setHighFloorFee(worker.getHighFloorFee());
final List<WorkerRelaPrice> workerRelaPriceList = workerRelaPriceService.selectByWorkerId(workerId);
workerRealPriceVo.setWorkerRelaPriceList(workerRelaPriceList);
if(worker != null){
workerRealPriceVo.setWorkerName(worker.getWorkerName());
workerRealPriceVo.setCardPicture(worker.getCardPicture());
workerRealPriceVo.setHighFloorFee(worker.getHighFloorFee());
final List<WorkerRelaPrice> workerRelaPriceList = workerRelaPriceService.selectByWorkerId(workerId);
workerRealPriceVo.setWorkerRelaPriceList(workerRelaPriceList);
}
return new ResultUtil<WorkerRealPriceVo>().setData(workerRealPriceVo);
}

10
hiver-modules/hiver-social/src/main/java/cc/hiver/social/controller/WechatController.java

@ -8,6 +8,8 @@ import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.core.service.UserService;
import cc.hiver.mall.service.mybatis.CustomerService;
import cc.hiver.social.entity.Social;
import cc.hiver.social.service.SocialService;
@ -80,6 +82,9 @@ public class WechatController {
@Autowired
private RedisTemplateHelper redisTemplate;
@Autowired
private UserService userService;
@Autowired
private WxMpService wxMpService;
@ -128,6 +133,11 @@ public class WechatController {
String phoneNumber = wechatPhoneService.getPhoneNumber(code);
if (phoneNumber != null) {
final User u = securityUtil.getCurrUser();
u.setMobile(phoneNumber);
userService.update(u);
// 删除缓存
//redisTemplate.delete(USER + u.getUsername());
return ResultUtil.data(phoneNumber);
} else {
return ResultUtil.error(401,"获取手机号失败");

4
hiver-modules/hiver-social/src/main/java/cc/hiver/social/handler/WxServerMsgHandler.java

@ -28,13 +28,13 @@ public class WxServerMsgHandler implements WxMpMessageHandler {
log.info("接收到的消息MsgType:{};Event:{};OpenId:{};FromUser:{};",wxMessage.getMsgType(),wxMessage.getEvent(),wxMessage.getOpenId(),wxMessage.getFromUser());
// 响应的消息内容
String outContent = "";
//判断是否是事件类型
//判断是否是事件类型 用户关注取消关注公众号回调
if(wxMessage.getMsgType().equals(WxConsts.XmlMsgType.EVENT)){
//订阅
final String lang = "zh_CN"; //语言
final WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUser(),lang);
if(wxMessage.getEvent().equals(WxConsts.EventType.SUBSCRIBE)){
outContent = "【快衣店信息推送】欢迎您!致力于帮助服装店主们更好地进行商品管理和营销推广,我们会持续发布实用技巧、成功案例分析等内容。期待与您共同成长,共创辉煌业绩!";
outContent = "【快拾科技】欢迎您!";
log.info("关注公众号的用户信息:user====:{}",user);
userService.subscribeWxServer(user);
}

Loading…
Cancel
Save