diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml
index 639fa094..f221972a 100644
--- a/hiver-admin/src/main/resources/application.yml
+++ b/hiver-admin/src/main/resources/application.yml
@@ -245,6 +245,7 @@ captcha:
- /hiver/auth/resetByMobile # 手机重置密码
- /hiver/user/changeMobile # 更换绑定手机
- /hiver/app/v1/member/quickLogin # 会员快捷登录注册接口
+ - /hiver/auth/worker/app/smsLogin #运送员登录接口
# Email验证码验证
email:
- /hiver/auth/resetByEmail # 邮件重置密码
@@ -288,6 +289,8 @@ ignored:
- /hiver/app/**
- /hiver/thorui/**
- /hiver/order/**
+ # 发送短信验证码不能拦截
+ - /hiver/auth/worker/app/sendLoginSms
# 限流及黑名单不拦截的路径
limitUrls:
- /**/*.js
@@ -355,4 +358,4 @@ logging:
max-file-size: 5MB
jpush:
appKey: 130f556e8473c9b558777fe3
- masterSecret: 2b4e5196dfc40a78db36480d
\ No newline at end of file
+ masterSecret: 2b4e5196dfc40a78db36480d
diff --git a/hiver-core/pom.xml b/hiver-core/pom.xml
index 6939a04e..812d8bbe 100644
--- a/hiver-core/pom.xml
+++ b/hiver-core/pom.xml
@@ -148,5 +148,22 @@
jiguang-common
1.1.12
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.5.3
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.62
+
+
+ com.aliyun
+ aliyun-java-sdk-dysmsapi
+ 1.0.0
+
\ No newline at end of file
diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java
index 09c228e9..3d98643f 100644
--- a/hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java
+++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/CommonConstant.java
@@ -135,4 +135,9 @@ public interface CommonConstant {
* 否
*/
Integer STATUS_NO = 0;
+
+ /**
+ * 运送员短信验证码key前缀
+ */
+ String PRE_YS_SMS = "HIVER_PRE_YS_SMS:";
}
diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java
index bb9ed3b5..6f02d0a7 100644
--- a/hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java
+++ b/hiver-core/src/main/java/cc/hiver/core/common/constant/SecurityConstant.java
@@ -87,4 +87,14 @@ public interface SecurityConstant {
* 会员token前缀key
*/
String MEMBER_TOKEN = "HIVER_MEMBER_TOKEN:";
+
+ /**
+ * 运送员token前缀key
+ */
+ String WORKER_TOKEN = "HIVER_WORKER_TOKEN:";
+
+ /**
+ * 运送员交互token前缀key
+ */
+ String TOKEN_WORKER_PRE = "HIVER_TOKEN_WORKER_PRE:";
}
diff --git a/hiver-core/src/main/java/cc/hiver/core/common/constant/WorkerConstant.java b/hiver-core/src/main/java/cc/hiver/core/common/constant/WorkerConstant.java
new file mode 100644
index 00000000..2caf5638
--- /dev/null
+++ b/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;
+
+}
diff --git a/hiver-core/src/main/java/cc/hiver/core/common/utils/SecurityUtil.java b/hiver-core/src/main/java/cc/hiver/core/common/utils/SecurityUtil.java
index 9e9c2bbb..92a89806 100644
--- a/hiver-core/src/main/java/cc/hiver/core/common/utils/SecurityUtil.java
+++ b/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.SecurityConstant;
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.redis.RedisTemplateHelper;
import cc.hiver.core.common.vo.TokenMember;
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.HiverTokenProperties;
import cc.hiver.core.dao.DepartmentDao;
import cc.hiver.core.dao.MemberDao;
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.UserRoleMapper;
import cc.hiver.core.entity.*;
@@ -75,6 +78,9 @@ public class SecurityUtil {
@Autowired
private RedisTemplateHelper redisTemplate;
+ @Autowired
+ private WorkerDao workerDao;
+
/**
* -------------------ToB-------------------------
*/
@@ -452,4 +458,56 @@ public class SecurityUtil {
member.setId(tokenMember.getId());
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;
+
+ }
}
diff --git a/hiver-core/src/main/java/cc/hiver/core/common/vo/TokenWorker.java b/hiver-core/src/main/java/cc/hiver/core/common/vo/TokenWorker.java
new file mode 100644
index 00000000..8cca3e9d
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/WorkerDao.java b/hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java
similarity index 51%
rename from hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/WorkerDao.java
rename to hiver-core/src/main/java/cc/hiver/core/dao/WorkerDao.java
index a0c25d30..206af23d 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/WorkerDao.java
+++ b/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.mall.entity.Worker;
+import cc.hiver.core.entity.Worker;
public interface WorkerDao extends HiverBaseDao {
-
+ Worker findByMobile(String mobile);
}
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Worker.java b/hiver-core/src/main/java/cc/hiver/core/entity/Worker.java
similarity index 91%
rename from hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Worker.java
rename to hiver-core/src/main/java/cc/hiver/core/entity/Worker.java
index d3b542c2..3946cdcb 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Worker.java
+++ b/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 com.baomidou.mybatisplus.annotation.FieldFill;
@@ -131,14 +131,28 @@ public class Worker implements Serializable {
* 人员标识
*/
@ApiModelProperty("人员标识 1-扛包工 2-快递员")
- @Column(name = "signPerson")
+ @Column(name = "sign_Person")
private String signPerson;
/**
* 所属公司
*/
@ApiModelProperty("所属公司")
- @Column(name = "ownerCompany")
+ @Column(name = "owner_Company")
private String ownerCompany;
+ /**
+ * 描述
+ */
+ @ApiModelProperty("人员运送内容标准")
+ @Column(name = "remark")
+ private String remark;
+
+ /**
+ * 描述
+ */
+ @ApiModelProperty("记录扛包工推送机器id")
+ @Column(name = "client_Id")
+ private String clientId;
+
}
diff --git a/hiver-core/src/main/java/cc/hiver/core/service/JPushService.java b/hiver-core/src/main/java/cc/hiver/core/service/JPushService.java
index c113b9a6..e2d89d66 100644
--- a/hiver-core/src/main/java/cc/hiver/core/service/JPushService.java
+++ b/hiver-core/src/main/java/cc/hiver/core/service/JPushService.java
@@ -1,36 +1,7 @@
package cc.hiver.core.service;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+public interface JPushService {
-import cn.jpush.api.JPushClient;
-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;
+ void sendPushNotification(String registrationId, String message);
-@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();
- }
- }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/WorkerService.java b/hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java
similarity index 85%
rename from hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/WorkerService.java
rename to hiver-core/src/main/java/cc/hiver/core/service/WorkerService.java
index 9997eada..11ab52c1 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/WorkerService.java
+++ b/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.common.vo.SearchVo;
-import cc.hiver.mall.entity.Worker;
+import cc.hiver.core.entity.Worker;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -25,4 +25,6 @@ public interface WorkerService extends HiverBaseService {
*/
Page findByCondition(Worker worker, SearchVo searchVo, Pageable pageable);
+ Worker findByMobile(String mobile);
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/WorkerServiceImpl.java b/hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java
similarity index 91%
rename from hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/WorkerServiceImpl.java
rename to hiver-core/src/main/java/cc/hiver/core/serviceimpl/WorkerServiceImpl.java
index 3696f014..4eb44dbb 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/WorkerServiceImpl.java
+++ b/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.vo.SearchVo;
-import cc.hiver.mall.dao.WorkerDao;
-import cc.hiver.mall.entity.Worker;
-import cc.hiver.mall.service.WorkerService;
+import cc.hiver.core.dao.WorkerDao;
+import cc.hiver.core.entity.Worker;
+import cc.hiver.core.service.WorkerService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
@@ -93,4 +93,10 @@ public class WorkerServiceImpl implements WorkerService {
}
}, pageable);
}
+
+ @Override
+ public Worker findByMobile(String mobile) {
+ Worker worker = workerDao.findByMobile(mobile);
+ return worker;
+ }
}
diff --git a/hiver-core/src/main/java/cc/hiver/core/vo/WorkerDetailVO.java b/hiver-core/src/main/java/cc/hiver/core/vo/WorkerDetailVO.java
new file mode 100644
index 00000000..69652113
--- /dev/null
+++ b/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;
+
+
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java
index 860a880b..818b1147 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java
+++ b/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.redis.RedisTemplateHelper;
+import cc.hiver.core.common.utils.BeanUtils;
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.Result;
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.pojo.vo.OrderVO;
import cc.hiver.mall.service.OrderService;
-import cc.hiver.mall.service.WorkerService;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -25,8 +27,6 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
import javax.validation.Valid;
import java.util.List;
@@ -51,8 +51,6 @@ public class OrderController {
@Autowired
private WorkerService workerService;
- @Autowired
- private DeleteMapper deleteMapper;
@Autowired
private RedisTemplateHelper redisTemplate;
@@ -60,8 +58,6 @@ public class OrderController {
@Autowired
private SecurityUtil securityUtil;
- @PersistenceContext
- private EntityManager entityManager;
/**
@@ -173,7 +169,7 @@ public class OrderController {
* 该接口即可展示实时物流管理页面,可复用
*/
@RequestMapping(value = "/ow/getAllByCondition", method = RequestMethod.GET)
- @ApiOperation(value = "多条件分页获取订单列表")
+ @ApiOperation(value = "多条件分页获取订单列表-实时物流管理")
public Result> getAllByCondition(OrderXd order,
SearchVo searchVo,
PageVo pageVo) {
@@ -199,4 +195,36 @@ public class OrderController {
List list = orderService.findByCondition(orderxd);
return new ResultUtil>().setData(list);
}
+
+
+ /**
+ * 待抢单的订单类型
+ *
+ * 该方法用于返回app端要抢单的展示列表信息
+ * 1.需要根据订单工所在区域进行查询显示是否为所在区域订单信息
+ * 2.显示的订单信息为未被抢单的订单信息
+ *
+ * key值定义暂定以区域为类型进行查询
+ *
+ * */
+ @RequestMapping(value = "/app/getAll/{id}", method = RequestMethod.POST)
+ @ApiOperation(value = "获取可抢单订单列表-App")
+ public Result> 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 list = orderService.findByCondition(orderxd);
+ return new ResultUtil>().setData(list);
+ }
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PushController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PushController.java
index 5364f7f6..97ab3512 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PushController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/PushController.java
@@ -1,22 +1,30 @@
package cc.hiver.mall.controller;
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.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;
@RestController
+@RequestMapping(value = "/hiver/app/Msg/")
+@Api(tags = "消息推送APP接口")
public class PushController {
- private final JPushService jPushService;
+ @Autowired
+ private JPushService jPushService;
@Autowired
- public PushController(JPushService jPushService) {
+ public PushController(JPushServiceImpl jPushService) {
this.jPushService = jPushService;
}
@GetMapping("/push")
+ @ApiOperation(value = "推送消息")
public String pushNotification(@RequestParam String registrationId, @RequestParam String message) {
jPushService.sendPushNotification(registrationId, message);
return "Push request sent!";
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java
index ee4dfee4..000f8694 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SalesOrderController.java
@@ -30,7 +30,7 @@ import java.math.BigDecimal;
@Slf4j
@RestController
-@Api(tags = "销售订单接口")
+@Api(tags = "销售订单接口(废弃)")
@RequestMapping(value = "/hiver/app/sales/")
@Transactional
public class SalesOrderController {
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerAuthController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerAuthController.java
new file mode 100644
index 00000000..5a646fe7
--- /dev/null
+++ b/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("发送短信验证码成功");
+ }
+ }
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java
index 5d0b498a..e5df865d 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/WorkerController.java
@@ -1,18 +1,24 @@
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.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.Result;
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.Worker;
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.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -23,9 +29,11 @@ import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
import javax.validation.Valid;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
/**
* 订单工管理接口
@@ -39,28 +47,12 @@ import javax.validation.Valid;
@CacheConfig(cacheNames = "worker")
@Transactional
public class WorkerController {
- public static final String WORKER = "worker::";
@Autowired
private WorkerService workerService;
@Autowired
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)
@ApiOperation(value = "多条件分页获取订单列表")
public Result> getByCondition(Worker worker,
@@ -116,9 +108,8 @@ public class WorkerController {
@ApiOperation(value = "修改抢单工信息", notes = "需要通过下单编号获取订单信息")
public Result edit(Worker u,
@RequestParam(required = false) String[] roleIds) {
-
//修改抢单工信息时如涉及到充值押金情况,需要更新余额且重置应缴
- if(u.getDepoNum()>0){
+ if(u.getDepoNum() != null && u.getDepoNum()>0){
Recharge recharge = new Recharge();
@@ -161,5 +152,4 @@ public class WorkerController {
//redisTemplate.delete(WORKER + worker.getWorkerId());
return ResultUtil.success("操作成功");
}
-
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/OrderXd.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/OrderXd.java
index f79da646..f218ca3b 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/OrderXd.java
+++ b/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.SnowFlakeUtil;
+import cc.hiver.core.entity.Worker;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/OrderVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/OrderVO.java
new file mode 100644
index 00000000..4395d386
--- /dev/null
+++ b/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;
+
+}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/OrderServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/OrderServiceImpl.java
index 1a00e23d..6363fe35 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/OrderServiceImpl.java
+++ b/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.vo.SearchVo;
+import cc.hiver.core.entity.Worker;
import cc.hiver.mall.dao.OrderDao;
import cc.hiver.mall.entity.OrderXd;
-import cc.hiver.mall.entity.Worker;
import cc.hiver.mall.service.OrderService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
@@ -199,6 +199,8 @@ public class OrderServiceImpl implements OrderService {
Path orderByWorkerField = root.get("orderByWorker");
Path createTimeField = root.get("createTime");
Path regionField = root.get("region");
+ Path transCompanyField = root.get("transCompany");
+
List list = new ArrayList<>();
@@ -206,6 +208,13 @@ public class OrderServiceImpl implements OrderService {
if (StrUtil.isNotBlank(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())) {
list.add(cb.equal(orderLogisticsField,order.getOrderLogistics()));
@@ -215,7 +224,7 @@ public class OrderServiceImpl implements OrderService {
if(StrUtil.isNotBlank(order.getOrderByWorker())){
list.add(cb.equal(orderByWorkerField,order.getOrderByWorker()));
}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) {
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java
index 1140c364..1b15ac20 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SendMessageServiceImpl.java
@@ -1,6 +1,6 @@
package cc.hiver.mall.serviceimpl;
-import cc.hiver.core.service.JPushService;
+import cc.hiver.core.serviceimpl.JPushServiceImpl;
import cc.hiver.mall.service.SendMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
public class SendMessageServiceImpl implements SendMessageService {
@Autowired
- JPushService jPushService;
+ JPushServiceImpl jPushService;
@Override
public void handleSendAppMessage() {