Browse Source

提交抢单工短信登录/推送信息修改/clientId绑定

cangku
Houpn 3 years ago
parent
commit
9f49d48465
  1. 5
      hiver-admin/src/main/resources/application.yml
  2. 17
      hiver-core/pom.xml
  3. 5
      hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java
  4. 10
      hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java
  5. 24
      hiver-core/src/main/java/cc/hiver/core/common/constant/WorkerConstant.java
  6. 58
      hiver-core/src/main/java/cc/hiver/core/common/utils/SecurityUtil.java
  7. 69
      hiver-core/src/main/java/cc/hiver/core/common/vo/TokenWorker.java
  8. 7
      hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java
  9. 20
      hiver-core/src/main/java/cc/hiver/core/entity/Worker.java
  10. 33
      hiver-core/src/main/java/cc/hiver/core/service/JPushService.java
  11. 6
      hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java
  12. 14
      hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java
  13. 29
      hiver-core/src/main/java/cc/hiver/core/vo/WorkerDetailVO.java
  14. 46
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java
  15. 12
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PushController.java
  16. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java
  17. 128
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerAuthController.java
  18. 44
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java
  19. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/OrderXd.java
  20. 56
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/OrderVO.java
  21. 13
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/OrderServiceImpl.java
  22. 4
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java

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

@ -245,6 +245,7 @@ captcha:
- /hiver/auth/resetByMobile # 手机重置密码 - /hiver/auth/resetByMobile # 手机重置密码
- /hiver/user/changeMobile # 更换绑定手机 - /hiver/user/changeMobile # 更换绑定手机
- /hiver/app/v1/member/quickLogin # 会员快捷登录注册接口 - /hiver/app/v1/member/quickLogin # 会员快捷登录注册接口
- /hiver/auth/worker/app/smsLogin #运送员登录接口
# Email验证码验证 # Email验证码验证
email: email:
- /hiver/auth/resetByEmail # 邮件重置密码 - /hiver/auth/resetByEmail # 邮件重置密码
@ -288,6 +289,8 @@ ignored:
- /hiver/app/** - /hiver/app/**
- /hiver/thorui/** - /hiver/thorui/**
- /hiver/order/** - /hiver/order/**
# 发送短信验证码不能拦截
- /hiver/auth/worker/app/sendLoginSms
# 限流及黑名单不拦截的路径 # 限流及黑名单不拦截的路径
limitUrls: limitUrls:
- /**/*.js - /**/*.js
@ -355,4 +358,4 @@ logging:
max-file-size: 5MB max-file-size: 5MB
jpush: jpush:
appKey: 130f556e8473c9b558777fe3 appKey: 130f556e8473c9b558777fe3
masterSecret: 2b4e5196dfc40a78db36480d masterSecret: 2b4e5196dfc40a78db36480d

17
hiver-core/pom.xml

@ -148,5 +148,22 @@
<artifactId>jiguang-common</artifactId> <artifactId>jiguang-common</artifactId>
<version>1.1.12</version> <version>1.1.12</version>
</dependency> </dependency>
<!-- 阿里依赖 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.3</version>
</dependency>
<!-- 由于SpringBoot自带的jackson的API不如fastjson好用,所以又引入了依赖 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

5
hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java

@ -135,4 +135,9 @@ public interface CommonConstant {
* *
*/ */
Integer STATUS_NO = 0; Integer STATUS_NO = 0;
/**
* 运送员短信验证码key前缀
*/
String PRE_YS_SMS = "HIVER_PRE_YS_SMS:";
} }

10
hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java

@ -87,4 +87,14 @@ public interface SecurityConstant {
* 会员token前缀key * 会员token前缀key
*/ */
String MEMBER_TOKEN = "HIVER_MEMBER_TOKEN:"; String MEMBER_TOKEN = "HIVER_MEMBER_TOKEN:";
/**
* 运送员token前缀key
*/
String WORKER_TOKEN = "HIVER_WORKER_TOKEN:";
/**
* 运送员交互token前缀key
*/
String TOKEN_WORKER_PRE = "HIVER_TOKEN_WORKER_PRE:";
} }

24
hiver-core/src/main/java/cc/hiver/core/common/constant/WorkerConstant.java

@ -0,0 +1,24 @@
package cc.hiver.core.common.constant;
/**
* 用户常量
*
* @author Yazhi Li
*/
public interface WorkerConstant {
/**
* 抢单工正常抢单状态
*/
Integer WORKER_STATUS_NORMAL = 1;
/**
* 抢单工不可接单状态(押金不足)
*/
Integer USER_STATUS_LOCK = 2;
/**
* 抢单工禁用状态(管理员直接禁用)
*/
Integer USER_STATUS_DISABLE = 3;
}

58
hiver-core/src/main/java/cc/hiver/core/common/utils/SecurityUtil.java

@ -3,15 +3,18 @@ package cc.hiver.core.common.utils;
import cc.hiver.core.common.constant.CommonConstant; import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.SecurityConstant; import cc.hiver.core.common.constant.SecurityConstant;
import cc.hiver.core.common.constant.UserConstant; import cc.hiver.core.common.constant.UserConstant;
import cc.hiver.core.common.constant.WorkerConstant;
import cc.hiver.core.common.exception.HiverException; import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.redis.RedisTemplateHelper; import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.vo.TokenMember; import cc.hiver.core.common.vo.TokenMember;
import cc.hiver.core.common.vo.TokenUser; import cc.hiver.core.common.vo.TokenUser;
import cc.hiver.core.common.vo.TokenWorker;
import cc.hiver.core.config.properties.HiverAppTokenProperties; import cc.hiver.core.config.properties.HiverAppTokenProperties;
import cc.hiver.core.config.properties.HiverTokenProperties; import cc.hiver.core.config.properties.HiverTokenProperties;
import cc.hiver.core.dao.DepartmentDao; import cc.hiver.core.dao.DepartmentDao;
import cc.hiver.core.dao.MemberDao; import cc.hiver.core.dao.MemberDao;
import cc.hiver.core.dao.UserDao; import cc.hiver.core.dao.UserDao;
import cc.hiver.core.dao.WorkerDao;
import cc.hiver.core.dao.mapper.PermissionMapper; import cc.hiver.core.dao.mapper.PermissionMapper;
import cc.hiver.core.dao.mapper.UserRoleMapper; import cc.hiver.core.dao.mapper.UserRoleMapper;
import cc.hiver.core.entity.*; import cc.hiver.core.entity.*;
@ -75,6 +78,9 @@ public class SecurityUtil {
@Autowired @Autowired
private RedisTemplateHelper redisTemplate; private RedisTemplateHelper redisTemplate;
@Autowired
private WorkerDao workerDao;
/** /**
* -------------------ToB------------------------- * -------------------ToB-------------------------
*/ */
@ -452,4 +458,56 @@ public class SecurityUtil {
member.setId(tokenMember.getId()); member.setId(tokenMember.getId());
return member; return member;
} }
public String getAppYSToken(Worker worker, Boolean saveLogin) {
if (worker == null) {
throw new HiverException("worker不能为空");
}
if (WorkerConstant.USER_STATUS_DISABLE.equals(worker.getWorkerStatus())) {
throw new HiverException("账户被禁用,请联系管理员");
}
Boolean saved = false;
if (saveLogin == null || saveLogin) {
saved = true;
if (!tokenProperties.getRedis()) {
tokenProperties.setTokenExpireTime(tokenProperties.getSaveLoginTime() * 60 * 24);
}
}
// 生成token
String token;
TokenWorker tokenWorker;
if (appTokenProperties.getRedis()) {
// redis
token = IdUtil.simpleUUID();
tokenWorker = new TokenWorker(worker, saved);
String key = SecurityConstant.WORKER_TOKEN + tokenWorker.getWorkerName();
// 单平台登录 之前的token失效
if (appTokenProperties.getSpl()) {
String oldToken = redisTemplate.get(key);
if (StrUtil.isNotBlank(oldToken)) {
redisTemplate.delete(SecurityConstant.TOKEN_WORKER_PRE + oldToken);
}
}
redisTemplate.set(key, token, appTokenProperties.getTokenExpireTime(), TimeUnit.DAYS);
redisTemplate.set(SecurityConstant.TOKEN_WORKER_PRE + token, new Gson().toJson(tokenWorker), appTokenProperties.getTokenExpireTime(), TimeUnit.DAYS);
} else {
// JWT
tokenWorker = new TokenWorker(worker, saved);
token = SecurityConstant.TOKEN_SPLIT + Jwts.builder()
// 主题 放入会员信息
.setSubject(new Gson().toJson(tokenWorker))
// 失效时间
.setExpiration(new Date(System.currentTimeMillis() + appTokenProperties.getTokenExpireTime() * 60 * 1000))
// 签名算法和密钥
.signWith(SignatureAlgorithm.HS512, SecurityConstant.JWT_SIGN_KEY)
.compact();
}
// 记录日志使用
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(tokenWorker, null, null);
SecurityContextHolder.getContext().setAuthentication(authentication);
return token;
}
} }

69
hiver-core/src/main/java/cc/hiver/core/common/vo/TokenWorker.java

@ -0,0 +1,69 @@
package cc.hiver.core.common.vo;
import cc.hiver.core.entity.Member;
import cc.hiver.core.entity.Worker;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.io.Serializable;
import java.util.Collection;
/**
* 会员令牌前端
* @author Yazhi Li
*/
@Data
@AllArgsConstructor
public class TokenWorker implements UserDetails, Serializable {
private String workerId;
private String workerName;
private String mobile;
private String signPerson;
private Boolean platform;
public TokenWorker(Worker worker,Boolean platform) {
this.workerId = worker.getWorkerId();
this.platform = platform;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
@Override
public String getPassword() {
return null;
}
@Override
public String getUsername() {
return null;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/WorkerDao.java → hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java

@ -1,8 +1,9 @@
package cc.hiver.mall.dao; package cc.hiver.core.dao;
import cc.hiver.core.base.HiverBaseDao; import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.mall.entity.Worker; import cc.hiver.core.entity.Worker;
public interface WorkerDao extends HiverBaseDao<Worker, String> { public interface WorkerDao extends HiverBaseDao<Worker, String> {
Worker findByMobile(String mobile);
} }

20
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Worker.java → hiver-core/src/main/java/cc/hiver/core/entity/Worker.java

@ -1,4 +1,4 @@
package cc.hiver.mall.entity; package cc.hiver.core.entity;
import cc.hiver.core.common.utils.SnowFlakeUtil; import cc.hiver.core.common.utils.SnowFlakeUtil;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
@ -131,14 +131,28 @@ public class Worker implements Serializable {
* 人员标识 * 人员标识
*/ */
@ApiModelProperty("人员标识 1-扛包工 2-快递员") @ApiModelProperty("人员标识 1-扛包工 2-快递员")
@Column(name = "signPerson") @Column(name = "sign_Person")
private String signPerson; private String signPerson;
/** /**
* 所属公司 * 所属公司
*/ */
@ApiModelProperty("所属公司") @ApiModelProperty("所属公司")
@Column(name = "ownerCompany") @Column(name = "owner_Company")
private String ownerCompany; private String ownerCompany;
/**
* 描述
*/
@ApiModelProperty("人员运送内容标准")
@Column(name = "remark")
private String remark;
/**
* 描述
*/
@ApiModelProperty("记录扛包工推送机器id")
@Column(name = "client_Id")
private String clientId;
} }

33
hiver-core/src/main/java/cc/hiver/core/service/JPushService.java

@ -1,36 +1,7 @@
package cc.hiver.core.service; package cc.hiver.core.service;
import org.springframework.beans.factory.annotation.Autowired; public interface JPushService {
import org.springframework.stereotype.Service;
import cn.jpush.api.JPushClient; void sendPushNotification(String registrationId, String message);
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.notification.Notification;
@Service
public class JPushService {
private final JPushClient jPushClient;
@Autowired
public JPushService(JPushClient jPushClient) {
this.jPushClient = jPushClient;
}
public void sendPushNotification(String registrationId, String message) {
PushPayload payload = PushPayload.newBuilder()
.setPlatform(cn.jpush.api.push.model.Platform.all())
.setAudience(cn.jpush.api.push.model.audience.Audience.registrationId(registrationId))
.setNotification(Notification.alert(message))
.build();
try {
PushResult result = jPushClient.sendPush(payload);
System.out.println("Push result: " + result);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/WorkerService.java → hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java

@ -1,8 +1,8 @@
package cc.hiver.mall.service; package cc.hiver.core.service;
import cc.hiver.core.base.HiverBaseService; import cc.hiver.core.base.HiverBaseService;
import cc.hiver.core.common.vo.SearchVo; import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.mall.entity.Worker; import cc.hiver.core.entity.Worker;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -25,4 +25,6 @@ public interface WorkerService extends HiverBaseService<Worker, String> {
*/ */
Page<Worker> findByCondition(Worker worker, SearchVo searchVo, Pageable pageable); Page<Worker> findByCondition(Worker worker, SearchVo searchVo, Pageable pageable);
Worker findByMobile(String mobile);
} }

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/WorkerServiceImpl.java → hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java

@ -1,10 +1,10 @@
package cc.hiver.mall.serviceimpl; package cc.hiver.core.serviceimpl;
import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.SearchVo; import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.mall.dao.WorkerDao; import cc.hiver.core.dao.WorkerDao;
import cc.hiver.mall.entity.Worker; import cc.hiver.core.entity.Worker;
import cc.hiver.mall.service.WorkerService; import cc.hiver.core.service.WorkerService;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -93,4 +93,10 @@ public class WorkerServiceImpl implements WorkerService {
} }
}, pageable); }, pageable);
} }
@Override
public Worker findByMobile(String mobile) {
Worker worker = workerDao.findByMobile(mobile);
return worker;
}
} }

29
hiver-core/src/main/java/cc/hiver/core/vo/WorkerDetailVO.java

@ -0,0 +1,29 @@
package cc.hiver.core.vo;
import cc.hiver.core.entity.Worker;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
@ApiModel("抢单工登录后明细")
public class WorkerDetailVO {
/**
* 抢单工详细信息
*/
@ApiModelProperty("抢单工详情")
private Worker worker;
/**
* 当前token
*/
@ApiModelProperty("登录成功token")
private String workerToken;
}

46
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java

@ -2,16 +2,18 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.exception.HiverException; import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.redis.RedisTemplateHelper; import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.utils.BeanUtils;
import cc.hiver.core.common.utils.PageUtil; import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo; import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.core.common.vo.SearchVo; import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.dao.mapper.DeleteMapper; import cc.hiver.core.entity.Worker;
import cc.hiver.core.service.WorkerService;
import cc.hiver.mall.entity.OrderXd; import cc.hiver.mall.entity.OrderXd;
import cc.hiver.mall.pojo.vo.OrderVO;
import cc.hiver.mall.service.OrderService; import cc.hiver.mall.service.OrderService;
import cc.hiver.mall.service.WorkerService;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -25,8 +27,6 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
@ -51,8 +51,6 @@ public class OrderController {
@Autowired @Autowired
private WorkerService workerService; private WorkerService workerService;
@Autowired
private DeleteMapper deleteMapper;
@Autowired @Autowired
private RedisTemplateHelper redisTemplate; private RedisTemplateHelper redisTemplate;
@ -60,8 +58,6 @@ public class OrderController {
@Autowired @Autowired
private SecurityUtil securityUtil; private SecurityUtil securityUtil;
@PersistenceContext
private EntityManager entityManager;
/** /**
@ -173,7 +169,7 @@ public class OrderController {
* 该接口即可展示实时物流管理页面可复用 * 该接口即可展示实时物流管理页面可复用
*/ */
@RequestMapping(value = "/ow/getAllByCondition", method = RequestMethod.GET) @RequestMapping(value = "/ow/getAllByCondition", method = RequestMethod.GET)
@ApiOperation(value = "多条件分页获取订单列表") @ApiOperation(value = "多条件分页获取订单列表-实时物流管理")
public Result<Page<OrderXd>> getAllByCondition(OrderXd order, public Result<Page<OrderXd>> getAllByCondition(OrderXd order,
SearchVo searchVo, SearchVo searchVo,
PageVo pageVo) { PageVo pageVo) {
@ -199,4 +195,36 @@ public class OrderController {
List<OrderXd> list = orderService.findByCondition(orderxd); List<OrderXd> list = orderService.findByCondition(orderxd);
return new ResultUtil<List<OrderXd>>().setData(list); return new ResultUtil<List<OrderXd>>().setData(list);
} }
/**
* 待抢单的订单类型
*
* 该方法用于返回app端要抢单的展示列表信息
* 1.需要根据订单工所在区域进行查询显示是否为所在区域订单信息
* 2.显示的订单信息为未被抢单的订单信息
*
* key值定义暂定以区域为类型进行查询
*
* */
@RequestMapping(value = "/app/getAll/{id}", method = RequestMethod.POST)
@ApiOperation(value = "获取可抢单订单列表-App")
public Result<List<OrderXd>> getAllList(@PathVariable String id) {
Worker worker = workerService.findById(id);
/**
* 实体对象运送方式 物流抢所有的物流的单 快递抢快递员所属公司的单 抢状态未预定的单
* */
OrderVO orderVO = new OrderVO();
if("1".equals(worker.getSignPerson()))
orderVO.setOrderLogistics("1");
else
orderVO.setOrderLogistics("3");
orderVO.setRegion(worker.getRegion());
orderVO.setTransCompany(worker.getOwnerCompany());
orderVO.setOrderStatus(1);
OrderXd orderxd = new OrderXd();
BeanUtils.copyBeanProp(orderxd,orderVO);
List<OrderXd> list = orderService.findByCondition(orderxd);
return new ResultUtil<List<OrderXd>>().setData(list);
}
} }

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

@ -1,22 +1,30 @@
package cc.hiver.mall.controller; package cc.hiver.mall.controller;
import cc.hiver.core.service.JPushService; import cc.hiver.core.service.JPushService;
import cc.hiver.core.serviceimpl.JPushServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value = "/hiver/app/Msg/")
@Api(tags = "消息推送APP接口")
public class PushController { public class PushController {
private final JPushService jPushService; @Autowired
private JPushService jPushService;
@Autowired @Autowired
public PushController(JPushService jPushService) { public PushController(JPushServiceImpl jPushService) {
this.jPushService = jPushService; this.jPushService = jPushService;
} }
@GetMapping("/push") @GetMapping("/push")
@ApiOperation(value = "推送消息")
public String pushNotification(@RequestParam String registrationId, @RequestParam String message) { public String pushNotification(@RequestParam String registrationId, @RequestParam String message) {
jPushService.sendPushNotification(registrationId, message); jPushService.sendPushNotification(registrationId, message);
return "Push request sent!"; return "Push request sent!";

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java

@ -30,7 +30,7 @@ import java.math.BigDecimal;
@Slf4j @Slf4j
@RestController @RestController
@Api(tags = "销售订单接口") @Api(tags = "销售订单接口(废弃)")
@RequestMapping(value = "/hiver/app/sales/") @RequestMapping(value = "/hiver/app/sales/")
@Transactional @Transactional
public class SalesOrderController { public class SalesOrderController {

128
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerAuthController.java

@ -0,0 +1,128 @@
package cc.hiver.mall.controller;
import cc.hiver.core.common.annotation.RateLimiter;
import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.MessageConstant;
import cc.hiver.core.common.constant.SettingConstant;
import cc.hiver.core.common.enums.LogType;
import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.sms.SmsUtil;
import cc.hiver.core.common.utils.*;
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.entity.Worker;
import cc.hiver.core.service.WorkerService;
import cc.hiver.core.vo.WorkerDetailVO;
import cc.hiver.mall.common.constant.WorkerConstant;
import cc.hiver.mall.entity.Recharge;
import cc.hiver.mall.service.RechargeService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.util.concurrent.TimeUnit;
/**
* 订单工管理接口
*
* @author houpn
*/
@Slf4j
@RestController
@Api(tags = "订单工登录接口")
@RequestMapping("/hiver/auth/worker")
@Transactional
public class WorkerAuthController {
@Autowired
private WorkerService workerService;
@Autowired
private RedisTemplateHelper redisTemplate;
@Autowired
private SecurityUtil securityUtil;
@Autowired
private IpInfoUtil ipInfoUtil;
@Autowired
private SmsUtil smsUtil;
@RequestMapping(value = "/app/login/{workerId}", method = RequestMethod.POST)
@ApiOperation(value = "app抢单登录接口")
public Result login(@ApiParam("唯一id标识") @PathVariable String workerId, HttpSession httpSession) {
Worker worker = workerService.get(workerId);
//这儿暂时有bug,启用的时候其实需要判定原状态是启用还是不可接单状态,需要进行逻辑判断
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_NORMAL);
workerService.update(worker);
// 手动更新缓存
//redisTemplate.delete(WORKER + worker.getWorkerId());
return ResultUtil.success("操作成功");
}
@RequestMapping(value = "/app/sendLoginSms/{mobile}", method = RequestMethod.GET)
@ApiOperation(value = "发送登录短信验证码")
@RateLimiter(name = "sendLoginSms", rate = 1, ipLimit = true)
public Result sendLoginSmsCode(@PathVariable String mobile, HttpServletRequest request) {
return sendSms(mobile, MessageConstant.SMS_RANGE_REG, SettingConstant.SMS_TYPE.SMS_COMMON.name(), request);
}
@RequestMapping(value = "/app/smsLogin", method = RequestMethod.POST)
@SystemLog(description = "短信登录", type = LogType.LOGIN)
@ApiOperation(value = "短信登录")
public Result smsLogin(@RequestParam String mobile,@RequestParam String code) {
boolean saveLogin = true;
Worker worker = workerService.findByMobile(mobile);
if (worker == null) {
throw new HiverException("手机号不存在");
}
String accessToken = securityUtil.getAppYSToken(worker, saveLogin);
WorkerDetailVO detailVO = new WorkerDetailVO();
detailVO.setWorker(worker);
detailVO.setWorkerToken(accessToken);
return ResultUtil.data(detailVO);
}
/**
* @param mobile 手机号
* @param range 发送范围 0发送给所有手机号 1只发送给注册手机 2只发送给未注册手机
* @param templateType 短信模版类型 详见SettingConstant
*/
public Result sendSms(String mobile, Integer range, String templateType, HttpServletRequest request) {
if (workerService.findByMobile(mobile) == null) {
return ResultUtil.error("手机号未注册");
} else {
// IP限流 1分钟限1个请求
String key = "sendSms:" + ipInfoUtil.getIpAddr(request);
String value = redisTemplate.get(key);
if (StrUtil.isNotBlank(value)) {
return ResultUtil.error("您发送的太频繁啦,请稍后再试");
}
// 生成6位数验证码
String code = CommonUtil.getRandomNum();
// 缓存验证码
redisTemplate.set(CommonConstant.PRE_SMS + mobile, code, 5L, TimeUnit.MINUTES);
// 发送验证码
smsUtil.sendCode(mobile, code, templateType);
// 请求成功 标记限流
redisTemplate.set(key, "sended", 1L, TimeUnit.MINUTES);
return ResultUtil.success("发送短信验证码成功");
}
}
}

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

@ -1,18 +1,24 @@
package cc.hiver.mall.controller; package cc.hiver.mall.controller;
import cc.hiver.core.common.annotation.RateLimiter;
import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.MessageConstant;
import cc.hiver.core.common.constant.SettingConstant;
import cc.hiver.core.common.enums.LogType;
import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.sms.SmsUtil;
import cc.hiver.core.common.utils.*;
import cc.hiver.core.entity.Worker;
import cc.hiver.core.service.WorkerService;
import cc.hiver.mall.common.constant.WorkerConstant; import cc.hiver.mall.common.constant.WorkerConstant;
import cc.hiver.core.common.redis.RedisTemplateHelper; import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.PageVo; import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.core.common.vo.SearchVo; import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.dao.mapper.DeleteMapper;
import cc.hiver.mall.entity.Recharge; import cc.hiver.mall.entity.Recharge;
import cc.hiver.mall.entity.Worker;
import cc.hiver.mall.service.RechargeService; import cc.hiver.mall.service.RechargeService;
import cc.hiver.mall.service.WorkerService; import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -23,9 +29,11 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.persistence.EntityManager; import javax.servlet.http.HttpServletRequest;
import javax.persistence.PersistenceContext; import javax.servlet.http.HttpSession;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/** /**
* 订单工管理接口 * 订单工管理接口
@ -39,28 +47,12 @@ import javax.validation.Valid;
@CacheConfig(cacheNames = "worker") @CacheConfig(cacheNames = "worker")
@Transactional @Transactional
public class WorkerController { public class WorkerController {
public static final String WORKER = "worker::";
@Autowired @Autowired
private WorkerService workerService; private WorkerService workerService;
@Autowired @Autowired
private RechargeService rechargeService; private RechargeService rechargeService;
@Autowired
private DeleteMapper deleteMapper;
@Autowired
private RedisTemplateHelper redisTemplate;
@Autowired
private SecurityUtil securityUtil;
@PersistenceContext
private EntityManager entityManager;
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
@ApiOperation(value = "多条件分页获取订单列表") @ApiOperation(value = "多条件分页获取订单列表")
public Result<Page<Worker>> getByCondition(Worker worker, public Result<Page<Worker>> getByCondition(Worker worker,
@ -116,9 +108,8 @@ public class WorkerController {
@ApiOperation(value = "修改抢单工信息", notes = "需要通过下单编号获取订单信息") @ApiOperation(value = "修改抢单工信息", notes = "需要通过下单编号获取订单信息")
public Result edit(Worker u, public Result edit(Worker u,
@RequestParam(required = false) String[] roleIds) { @RequestParam(required = false) String[] roleIds) {
//修改抢单工信息时如涉及到充值押金情况,需要更新余额且重置应缴 //修改抢单工信息时如涉及到充值押金情况,需要更新余额且重置应缴
if(u.getDepoNum()>0){ if(u.getDepoNum() != null && u.getDepoNum()>0){
Recharge recharge = new Recharge(); Recharge recharge = new Recharge();
@ -161,5 +152,4 @@ public class WorkerController {
//redisTemplate.delete(WORKER + worker.getWorkerId()); //redisTemplate.delete(WORKER + worker.getWorkerId());
return ResultUtil.success("操作成功"); return ResultUtil.success("操作成功");
} }
} }

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/OrderXd.java

@ -2,6 +2,7 @@ package cc.hiver.mall.entity;
import cc.hiver.core.common.utils.NameUtil; import cc.hiver.core.common.utils.NameUtil;
import cc.hiver.core.common.utils.SnowFlakeUtil; import cc.hiver.core.common.utils.SnowFlakeUtil;
import cc.hiver.core.entity.Worker;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;

56
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/OrderVO.java

@ -0,0 +1,56 @@
package cc.hiver.mall.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "下单")
public class OrderVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 物流方式
*/
@ApiModelProperty("物流方式")
private String orderLogistics;
/**
/**
* 订单是否超时
*/
@ApiModelProperty("订单是否超时")
private Integer timeout;
/**
* 订单状态
*/
@ApiModelProperty("订单状态")
private Integer orderStatus;
/**
* 抢单工编号
*/
@ApiModelProperty("抢单工编号")
private String orderByWorker;
/**
* 订单区域
*/
@ApiModelProperty("订单所属区域")
private String region;
/**
* 运送公司
*/
@ApiModelProperty("运送公司")
private String transCompany;
}

13
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/OrderServiceImpl.java

@ -2,9 +2,9 @@ package cc.hiver.mall.serviceimpl;
import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.SearchVo; import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.entity.Worker;
import cc.hiver.mall.dao.OrderDao; import cc.hiver.mall.dao.OrderDao;
import cc.hiver.mall.entity.OrderXd; import cc.hiver.mall.entity.OrderXd;
import cc.hiver.mall.entity.Worker;
import cc.hiver.mall.service.OrderService; import cc.hiver.mall.service.OrderService;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -199,6 +199,8 @@ public class OrderServiceImpl implements OrderService {
Path<String> orderByWorkerField = root.get("orderByWorker"); Path<String> orderByWorkerField = root.get("orderByWorker");
Path<Date> createTimeField = root.get("createTime"); Path<Date> createTimeField = root.get("createTime");
Path<String> regionField = root.get("region"); Path<String> regionField = root.get("region");
Path<String> transCompanyField = root.get("transCompany");
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
@ -206,6 +208,13 @@ public class OrderServiceImpl implements OrderService {
if (StrUtil.isNotBlank(order.getRegion())) { if (StrUtil.isNotBlank(order.getRegion())) {
list.add(cb.equal(regionField,order.getRegion())); list.add(cb.equal(regionField,order.getRegion()));
} }
//物流公司限制
if (StrUtil.isNotBlank(order.getTransCompany())) {
String[] transCompany = order.getTransCompany().trim().split(",");
list.add(transCompanyField.in(transCompany));
}
//物流方式限制 //物流方式限制
if (StrUtil.isNotBlank(order.getOrderLogistics())) { if (StrUtil.isNotBlank(order.getOrderLogistics())) {
list.add(cb.equal(orderLogisticsField,order.getOrderLogistics())); list.add(cb.equal(orderLogisticsField,order.getOrderLogistics()));
@ -215,7 +224,7 @@ public class OrderServiceImpl implements OrderService {
if(StrUtil.isNotBlank(order.getOrderByWorker())){ if(StrUtil.isNotBlank(order.getOrderByWorker())){
list.add(cb.equal(orderByWorkerField,order.getOrderByWorker())); list.add(cb.equal(orderByWorkerField,order.getOrderByWorker()));
}else{ }else{
list.add(cb.or(cb.isNull(orderByWorkerField),cb.equal(orderByWorkerField,order.getOrderByWorker()))); list.add(cb.or(cb.isNull(orderByWorkerField),cb.equal(orderByWorkerField,"")));
} }
if (order.getTimeout() != null) { if (order.getTimeout() != null) {

4
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java

@ -1,6 +1,6 @@
package cc.hiver.mall.serviceimpl; package cc.hiver.mall.serviceimpl;
import cc.hiver.core.service.JPushService; import cc.hiver.core.serviceimpl.JPushServiceImpl;
import cc.hiver.mall.service.SendMessageService; import cc.hiver.mall.service.SendMessageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
public class SendMessageServiceImpl implements SendMessageService { public class SendMessageServiceImpl implements SendMessageService {
@Autowired @Autowired
JPushService jPushService; JPushServiceImpl jPushService;
@Override @Override
public void handleSendAppMessage() { public void handleSendAppMessage() {

Loading…
Cancel
Save