提交 a05d7e1a authored 作者: 李秋林's avatar 李秋林

新增功能:员工登录、活动数据查询;

上级 27f1d12e
...@@ -226,6 +226,12 @@ ...@@ -226,6 +226,12 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
<version>${spring-cloud-gateway.version}</version> <version>${spring-cloud-gateway.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -3,8 +3,10 @@ package com.wangxiaolu.promotion; ...@@ -3,8 +3,10 @@ package com.wangxiaolu.promotion;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.context.request.RequestContextListener;
@EnableAsync @EnableAsync
@EnableConfigurationProperties @EnableConfigurationProperties
...@@ -15,6 +17,10 @@ public class WangxiaoluPromotionServiceApplication { ...@@ -15,6 +17,10 @@ public class WangxiaoluPromotionServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(WangxiaoluPromotionServiceApplication.class, args); SpringApplication.run(WangxiaoluPromotionServiceApplication.class, args);
} }
@Bean
public RequestContextListener requestContextListener(){
return new RequestContextListener();
}
} }
package com.wangxiaolu.promotion.controller.activity.employee;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeQueryTemActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-05-29 14
* @describe : 员工查询促销员活动上报信息
*/
@Slf4j
@RestController
@RequestMapping("/activity/employee/query")
public class EmployeeQueryTemActivityController {
@Autowired
EmployeeQueryTemActivityService employeeQueryTemActivityService;
@GetMapping("/all")
public R findActivitys(@RequestHeader String loginQcId) {
List<TemporaryActivityReportedDto> dtos = employeeQueryTemActivityService.getEmployeeApproveActivitys(loginQcId);
return R.success(dtos);
}
}
...@@ -49,8 +49,17 @@ public class TemporaryActivityCoreController { ...@@ -49,8 +49,17 @@ public class TemporaryActivityCoreController {
if (!isClockIn && Objects.isNull((clockVo.getId()))) { if (!isClockIn && Objects.isNull((clockVo.getId()))) {
throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null); throw new ParamException(RCode.CLOCK_DETAIL_ERROR, null);
} }
Date clockTime = new Date();
// 根据打卡经纬度判断与打卡店铺的距离,距离超过100米不能打卡
tempActivityCoreService.clockStoreCalDistance(clockVo.getStoreQcId(),clockVo.getId(),clockVo.getClockCoordinates());
/**
* todo redis打卡-限制重复提交
* todo 后续添加,基于redis
*/
Date clockTime = new Date();
TemporaryClockDto dto = new TemporaryClockDto(clockVo.getClockType(), clockVo.getId(), clockVo.getTemporaryId(), clockVo.getTemporaryName()); TemporaryClockDto dto = new TemporaryClockDto(clockVo.getClockType(), clockVo.getId(), clockVo.getTemporaryId(), clockVo.getTemporaryName());
// 上班卡、午休下班卡、午休上班卡、下班卡 // 上班卡、午休下班卡、午休上班卡、下班卡
if (isClockIn) { if (isClockIn) {
......
package com.wangxiaolu.promotion.controller.user;
import com.wangxiaolu.promotion.pojo.user.vo.UserLoginParam;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.service.user.WangxlEmployeeQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : liqiulin
* @date : 2024-05-28 19
* @describe : 王小卤员工登录接口
*/
@RestController
@RequestMapping("/user/employee")
public class WangxlEmployeeLoginController {
@Autowired
WangxlEmployeeQueryService wangxlEmployeeQueryService;
@PostMapping("/login")
public R wangxlEmployeelogin(@RequestBody UserLoginParam userLoginParam) {
userLoginParam.validate();
String token = wangxlEmployeeQueryService.employeeLoginVerify(userLoginParam);
return R.success(token);
}
}
package com.wangxiaolu.promotion.controller.user; package com.wangxiaolu.promotion.controller.user.qince;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto; import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo; import com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo;
......
package com.wangxiaolu.promotion.controller.user; package com.wangxiaolu.promotion.controller.user.qince;
import com.wangxiaolu.promotion.result.basedata.R; import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.service.user.QinCeDataTaskService; import com.wangxiaolu.promotion.service.user.QinCeDataTaskService;
......
package com.wangxiaolu.promotion.domain.activity.dao;
import com.wangxiaolu.promotion.pojo.user.dto.PromotionManageEmployeeDto;
/**
* @author : liqiulin
* @date : 2024-05-29 13
* @describe :
*/
public interface PromotionManageEmployeeDao {
PromotionManageEmployeeDto selectOneByEmployeeNo(String employeeNo);
}
package com.wangxiaolu.promotion.domain.activity.dao; package com.wangxiaolu.promotion.domain.activity.dao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryActivityWrapper;
import com.wangxiaolu.promotion.pojo.PageInfo; import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
...@@ -35,4 +36,6 @@ public interface TemporaryActivityReportedDao { ...@@ -35,4 +36,6 @@ public interface TemporaryActivityReportedDao {
* 根据ID修改 * 根据ID修改
*/ */
void updateById(TemporaryActivityReportedDto temActDto); void updateById(TemporaryActivityReportedDto temActDto);
List<TemporaryActivityReportedDto> findListToEmployee(TemporaryActivityWrapper tw);
} }
package com.wangxiaolu.promotion.domain.activity.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.activity.dao.PromotionManageEmployeeDao;
import com.wangxiaolu.promotion.domain.activity.mapper.PromotionManageEmployeeMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.PromotionManageEmployeeDO;
import com.wangxiaolu.promotion.pojo.user.dto.PromotionManageEmployeeDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-05-29 13
* @describe :
*/
@Service
public class PromotionManageEmployeeDaoImpl implements PromotionManageEmployeeDao {
@Autowired
PromotionManageEmployeeMapper promotionManageEmployeeMapper;
@Override
public PromotionManageEmployeeDto selectOneByEmployeeNo(String employeeNo) {
LambdaQueryWrapper<PromotionManageEmployeeDO> lqw = new LambdaQueryWrapper();
lqw.eq(PromotionManageEmployeeDO::getEmployeeNo,employeeNo);
PromotionManageEmployeeDO promotionManageEmployeeDO = promotionManageEmployeeMapper.selectOne(lqw);
return transitionDto(promotionManageEmployeeDO);
}
private PromotionManageEmployeeDto transitionDto(PromotionManageEmployeeDO employeeDO) {
PromotionManageEmployeeDto dto = null;
if (Objects.isNull(employeeDO)) {
return dto;
}
dto = new PromotionManageEmployeeDto();
BeanUtils.copyProperties(employeeDO, dto);
return dto;
}
}
...@@ -99,6 +99,19 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport ...@@ -99,6 +99,19 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport
temporaryActivityReportedMapper.updateById(rDo); temporaryActivityReportedMapper.updateById(rDo);
} }
/**
* 员工查询、
* @param tw
* @return
*/
@Override
public List<TemporaryActivityReportedDto> findListToEmployee(TemporaryActivityWrapper tw) {
LambdaQueryWrapper<TemporaryActivityReportedDO> qw = buildQueryList(tw);
qw.orderByDesc(TemporaryActivityReportedDO::getApproveStatus);
List<TemporaryActivityReportedDO> dos = temporaryActivityReportedMapper.selectList(qw);
return transitionDtos(dos);
}
private LambdaQueryWrapper<TemporaryActivityReportedDO> buildQueryList(TemporaryActivityWrapper tw) { private LambdaQueryWrapper<TemporaryActivityReportedDO> buildQueryList(TemporaryActivityWrapper tw) {
LambdaQueryWrapper<TemporaryActivityReportedDO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TemporaryActivityReportedDO> queryWrapper = new LambdaQueryWrapper<>();
...@@ -111,6 +124,12 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport ...@@ -111,6 +124,12 @@ public class TemporaryActivityReportedDaoImpl implements TemporaryActivityReport
if (!StringUtils.isEmpty(tw.getApproveStatus())){ if (!StringUtils.isEmpty(tw.getApproveStatus())){
queryWrapper.eq(TemporaryActivityReportedDO::getApproveStatus, tw.getApproveStatus()); queryWrapper.eq(TemporaryActivityReportedDO::getApproveStatus, tw.getApproveStatus());
} }
if (!StringUtils.isEmpty(tw.getApproverId())){
queryWrapper.eq(TemporaryActivityReportedDO::getApproverId, tw.getApproverId());
}
if (!StringUtils.isEmpty(tw.getNotApproveStatus())){
queryWrapper.ne(TemporaryActivityReportedDO::getApproveStatus, tw.getNotApproveStatus());
}
// 默认创建日期倒序排列 // 默认创建日期倒序排列
queryWrapper.orderByDesc(TemporaryActivityReportedDO::getCreateDate); queryWrapper.orderByDesc(TemporaryActivityReportedDO::getCreateDate);
......
package com.wangxiaolu.promotion.domain.activity.mapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.PromotionManageEmployeeDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author a02200059
* @description 针对表【promotion_manage_employee(促销平台管理后台员工信息)】的数据库操作Mapper
* @createDate 2024-05-29 13:24:59
* @Entity com.wangxiaolu.promotion.domain.activity.mapper.entity.PromotionManageEmployeeDO
*/
@Repository
@Mapper
public interface PromotionManageEmployeeMapper extends BaseMapper<PromotionManageEmployeeDO> {
}
package com.wangxiaolu.promotion.domain.activity.mapper.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import com.sun.openpisces.Stroker;
import lombok.Data;
/**
* 促销平台管理后台员工信息
* @TableName promotion_manage_employee
*/
@TableName(value ="promotion_manage_employee")
@Data
public class PromotionManageEmployeeDO implements Serializable {
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 勤策的员工唯一标识
*/
private String qcId;
/**
* 姓名
*/
private String name;
/**
* 员工工号
*/
private String employeeNo;
/**
* 密码
*/
private String passwork;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
...@@ -48,9 +48,9 @@ public class TemporaryActivityReportedDO implements Serializable { ...@@ -48,9 +48,9 @@ public class TemporaryActivityReportedDO implements Serializable {
private String storeAddr; private String storeAddr;
/** /**
* 关联—审核人员id * 关联—审核人员qc_id
*/ */
private Long approverId; private String approverId;
/** /**
* 关联—审核人员姓名 * 关联—审核人员姓名
......
...@@ -30,4 +30,15 @@ public class TemporaryActivityWrapper { ...@@ -30,4 +30,15 @@ public class TemporaryActivityWrapper {
* 关联enum类 TemActApproveStatus * 关联enum类 TemActApproveStatus
*/ */
private String approveStatus; private String approveStatus;
/**
* 关联—审核人员qc_id
*/
private String approverId;
/**
* 不查询的审批状态(审批中、审批通过、退回……)
* 关联enum类 TemActApproveStatus
*/
private String notApproveStatus;
} }
...@@ -51,9 +51,10 @@ public class TemporaryActivityReportedDto { ...@@ -51,9 +51,10 @@ public class TemporaryActivityReportedDto {
private String storeAddr; private String storeAddr;
/** /**
* 关联—审核人员id * 关联—审核人员qc_id
*
*/ */
private Long approverId; private String approverId;
/** /**
* 关联—审核人员姓名 * 关联—审核人员姓名
......
package com.wangxiaolu.promotion.pojo.user.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-05-29 13
* @describe :
*/
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Data
public class PromotionManageEmployeeDto {
/**
* 主键id
*/
private Integer id;
/**
* 勤策的员工唯一标识
*/
private String qcId;
/**
* 姓名
*/
private String name;
/**
* 员工工号
*/
private String employeeNo;
/**
* 密码
*/
private String passwork;
}
package com.wangxiaolu.promotion.pojo.user.vo; package com.wangxiaolu.promotion.pojo.user.vo;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
...@@ -18,7 +21,12 @@ import javax.validation.constraints.NotBlank; ...@@ -18,7 +21,12 @@ import javax.validation.constraints.NotBlank;
@Accessors(chain = true) @Accessors(chain = true)
public class UserLoginParam { public class UserLoginParam {
@NotBlank(message = "登录名不可为空")
String loginName; String loginName;
String password; String password;
public void validate(){
if (StringUtils.isBlank(loginName) || StringUtils.isBlank(password)){
throw new ParamException(RCode.LOGIN_PARAM_ERROR,null);
}
}
} }
package com.wangxiaolu.promotion.service.activity.employee;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-05-30 11
* @describe : 员工查询促销员活动上报信息
*/
public interface EmployeeQueryTemActivityService {
List<TemporaryActivityReportedDto> getEmployeeApproveActivitys(String employeeQcId);
}
package com.wangxiaolu.promotion.service.activity.employee.impl;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryActivityWrapper;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeQueryTemActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-05-30 11
* @describe : 员工查询促销员活动上报信息
*/
@Service
@Slf4j
public class EmployeeQueryTemActivityServiceImpl implements EmployeeQueryTemActivityService{
@Autowired
TemporaryActivityReportedDao temporaryActivityReportedDao;
@Override
public List<TemporaryActivityReportedDto> getEmployeeApproveActivitys(String employeeQcId) {
TemporaryActivityWrapper tw = new TemporaryActivityWrapper()
.setApproverId(employeeQcId)
.setNotApproveStatus(TemActApproveStatus.SUBMITTED.name());
return temporaryActivityReportedDao.findListToEmployee(tw);
}
}
...@@ -29,4 +29,13 @@ public interface TemporaryActivityCoreService { ...@@ -29,4 +29,13 @@ public interface TemporaryActivityCoreService {
* 活动上报数据修改审批状态 * 活动上报数据修改审批状态
*/ */
void activityReportedSubmit(Long id); void activityReportedSubmit(Long id);
/**
* 根据店铺或打卡记录中的店铺,判断打卡距离
*
* @param storeQcId 店铺-勤策-id
* @param id 打卡记录id
* @param clockCoordinates 打卡经纬度
*/
void clockStoreCalDistance(String storeQcId, Long id, String clockCoordinates);
} }
package com.wangxiaolu.promotion.service.activity.temporary.impl; package com.wangxiaolu.promotion.service.activity.temporary.impl;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityLogDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityLogDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityPhotoDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao; import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao;
import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao; import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao;
import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper; import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
...@@ -19,12 +21,17 @@ import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto; ...@@ -19,12 +21,17 @@ import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto; import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService;
import com.wangxiaolu.promotion.utils.OkHttp;
import com.wangxiaolu.promotion.utils.QinCeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -35,7 +42,8 @@ import java.util.Objects; ...@@ -35,7 +42,8 @@ import java.util.Objects;
@Service @Service
@Slf4j @Slf4j
public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreService { public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreService {
@Autowired
QinCeUtils qinCeUtils;
@Autowired @Autowired
private TemporaryActivityReportedDao temporaryActivityReportedDao; private TemporaryActivityReportedDao temporaryActivityReportedDao;
...@@ -69,8 +77,13 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -69,8 +77,13 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
throw new FlowException(RCode.DATA_HAVE_ERROR, null); throw new FlowException(RCode.DATA_HAVE_ERROR, null);
} }
// 查询上报人负责人
WxTemporaryInfoDto wxTemporaryInfoDto = temporaryInfoDao.selectOneById(temActDto.getTemporaryId());
// 初始化任务状态:已保存 // 初始化任务状态:已保存
temActDto.setApproveStatus(TemActApproveStatus.SUBMITTED); temActDto.setApproveStatus(TemActApproveStatus.SUBMITTED);
temActDto.setApproverId(wxTemporaryInfoDto.getChargerQcId());
temActDto.setApproveName(wxTemporaryInfoDto.getChargerName());
// 根据storeQcId查询店铺信息,进行店铺信息补充 // 根据storeQcId查询店铺信息,进行店铺信息补充
QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(new StoreWrapper().setQcId(temActDto.getStoreQcId())); QinCeClienteleStoreDto storeDto = qinCeClienteleStoreDao.getOneStore(new StoreWrapper().setQcId(temActDto.getStoreQcId()));
...@@ -130,7 +143,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -130,7 +143,7 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
public void activityReportedSubmit(Long id) { public void activityReportedSubmit(Long id) {
// 判断此id任务是否存在,并且是否满足提交审批条件 // 判断此id任务是否存在,并且是否满足提交审批条件
TemporaryActivityReportedDto reportedDto = temporaryActivityReportedDao.findOneById(id); TemporaryActivityReportedDto reportedDto = temporaryActivityReportedDao.findOneById(id);
if (Objects.isNull(reportedDto)){ if (Objects.isNull(reportedDto)) {
throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null); throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null);
} }
...@@ -153,6 +166,43 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe ...@@ -153,6 +166,43 @@ public class TemporaryActivityCoreServiceImpl implements TemporaryActivityCoreSe
tempActivityLogDao.save(reportedDto.getTemporaryId(), reportedDto.getTemporaryName(), LogType.t_3, updateDto.getId(), updateDto); tempActivityLogDao.save(reportedDto.getTemporaryId(), reportedDto.getTemporaryName(), LogType.t_3, updateDto.getId(), updateDto);
} }
/**
* 根据店铺或打卡记录中的店铺,判断打卡距离
* 经度,范围为 -180~180,负数表示西经;纬度,范围为 -90~90,负数表示南纬
*
* @param storeQcId 店铺-勤策-id
* @param id 打卡记录id
* @param clockCoordinates 打卡经纬度
*/
@Override
public void clockStoreCalDistance(String storeQcId, Long id, String clockCoordinates) {
if (Objects.nonNull(id)) {
TemporaryClockDto clockDto = temporaryActivityClockDao.selectOne(new TemporaryClockWrapper().setId(id));
storeQcId = clockDto.getStoreQcId();
}
clockStoreCalDistanceByStoreQcId(storeQcId, clockCoordinates);
}
private void clockStoreCalDistanceByStoreQcId(String storeQcId, String clockCoordinates) {
// 查询组织架构参数、创建url
String[] clockCoordinateArr = clockCoordinates.split(",");
List<Map> paramList = qinCeUtils.queryCalDistanceParam(storeQcId, clockCoordinateArr[0], clockCoordinateArr[1]);
String url = qinCeUtils.builderUrlList(QinCeUtils.CAL_DISTANCE, paramList);
// 发起请求、接收结果
JSONObject resultJson = OkHttp.postQC(url, paramList);
String rData = resultJson.getString("response_data");
if (StringUtils.isBlank(rData) || !rData.contains(storeQcId)) {
throw new ParamException(RCode.PRO_NOT_QC_STORE_CLOCK_DISTANCE, null);
}
Long distance = JSONObject.parseArray(rData).getJSONObject(0).getLong("distance");
log.info("[打卡] 判断打卡距离,勤策-id:{},打卡距离:{},打卡经纬度:{}", storeQcId, distance, clockCoordinates);
// todo 判断打卡距离
// if (distance > 100L) {
// throw new ParamException(RCode.PRO_FAR_QC_STORE_CLOCK_DISTANCE, null);
// }
}
/** /**
* 推广活动照片保存 * 推广活动照片保存
* *
......
package com.wangxiaolu.promotion.service.user;
import com.wangxiaolu.promotion.pojo.user.vo.UserLoginParam;
/**
* @author : liqiulin
* @date : 2024-05-29 13
* @describe :
*/
public interface WangxlEmployeeQueryService {
String employeeLoginVerify(UserLoginParam userLoginParam);
}
...@@ -39,7 +39,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService { ...@@ -39,7 +39,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_ORGANIZATION, params); String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_ORGANIZATION, params);
// 发起请求、接收结果 // 发起请求、接收结果
JSONObject resultJson = OkHttp.post(url, params); JSONObject resultJson = OkHttp.postQC(url, params);
JSONArray responseDatas = resultJson.getJSONArray("response_data"); JSONArray responseDatas = resultJson.getJSONArray("response_data");
if (responseDatas.size() <= 0) { if (responseDatas.size() <= 0) {
...@@ -57,7 +57,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService { ...@@ -57,7 +57,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_EMPLOYEE, params); String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_EMPLOYEE, params);
// 发起请求、接收结果 // 发起请求、接收结果
JSONObject resultJson = OkHttp.post(url, params); JSONObject resultJson = OkHttp.postQC(url, params);
JSONArray responseDatas = resultJson.getJSONArray("response_data"); JSONArray responseDatas = resultJson.getJSONArray("response_data");
if (responseDatas.size() <= 0) { if (responseDatas.size() <= 0) {
...@@ -86,7 +86,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService { ...@@ -86,7 +86,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_SHORE, params); String url = qinCeUtils.builderUrl(QinCeUtils.QUERY_SHORE, params);
// 发起请求、接收结果 // 发起请求、接收结果
JSONObject resultJson = OkHttp.post(url, params); JSONObject resultJson = OkHttp.postQC(url, params);
JSONArray responseDatas = resultJson.getJSONArray("response_data"); JSONArray responseDatas = resultJson.getJSONArray("response_data");
if (responseDatas.size() <= 0) { if (responseDatas.size() <= 0) {
log.error("勤策-同步终端store数据,未查询到数据"); log.error("勤策-同步终端store数据,未查询到数据");
......
package com.wangxiaolu.promotion.service.user.impl;
import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.common.util.JwtUtils;
import com.wangxiaolu.promotion.common.util.MD5Utils;
import com.wangxiaolu.promotion.domain.activity.dao.PromotionManageEmployeeDao;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.user.dto.PromotionManageEmployeeDto;
import com.wangxiaolu.promotion.pojo.user.vo.UserLoginParam;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.user.WangxlEmployeeQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-05-29 13
* @describe :
*/
@Service
@Slf4j
public class WangxlEmployeeQueryServiceImpl implements WangxlEmployeeQueryService {
@Autowired
RedisCache redisCache;
@Autowired
JwtUtils jwtUtils;
@Autowired
PromotionManageEmployeeDao promotionManageEmployeeDao;
@Override
public String employeeLoginVerify(UserLoginParam userLoginParam) {
PromotionManageEmployeeDto employeeDto = promotionManageEmployeeDao.selectOneByEmployeeNo(userLoginParam.getLoginName());
if (Objects.isNull(employeeDto)){
throw new ParamException(RCode.LOGIN_PARAM_ERROR,null);
}
if (!MD5Utils.getSaltverifyMD5(userLoginParam.getPassword(),employeeDto.getPasswork())){
throw new ParamException(RCode.LOGIN_PASSWORD_ERROR,null);
}
log.info("促销员管理后台登录成功,工号:{}", userLoginParam.getLoginName());
String loginToken = jwtUtils.getEmployeeToken(userLoginParam.getLoginName(), userLoginParam.getPassword());
redisCache.addToJsonToMinute(RedisKeys.UserKeys.TEMPORARY_TOKEN.getKey()+loginToken,employeeDto,360);
return loginToken;
}
}
...@@ -45,7 +45,7 @@ public class WeChatUserQueryServiceImpl implements WeChatUserQueryService { ...@@ -45,7 +45,7 @@ public class WeChatUserQueryServiceImpl implements WeChatUserQueryService {
log.info("微信-促销员{}登录成功(openId、手机号),openId:{},phone:{}", temDto.getName(), openId, phone); log.info("微信-促销员{}登录成功(openId、手机号),openId:{},phone:{}", temDto.getName(), openId, phone);
// 生成一个token // 生成一个token
temporaryToken = jwtUtils.getTemporaryToken(openId, phone); temporaryToken = jwtUtils.getTemporaryToken(openId, phone);
redisCache.addToJsonToDays(RedisKeys.UserKeys.TEMPORARY_TOKEN.getKey()+temporaryToken,temDto,1); redisCache.addToJsonToMinute(RedisKeys.UserKeys.TEMPORARY_TOKEN.getKey()+temporaryToken,temDto,360);
} else { } else {
log.info("微信-促销员登录失败,当前信息未注册(openId、手机号),openId:{},phone:{}", openId, phone); log.info("微信-促销员登录失败,当前信息未注册(openId、手机号),openId:{},phone:{}", openId, phone);
} }
......
...@@ -2,8 +2,7 @@ package com.wangxiaolu.promotion.utils; ...@@ -2,8 +2,7 @@ package com.wangxiaolu.promotion.utils;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.exception.APIException;
import java.util.Map;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -12,12 +11,18 @@ import java.util.Map; ...@@ -12,12 +11,18 @@ import java.util.Map;
*/ */
public class OkHttp { public class OkHttp {
public static JSONObject post(String url, Map<String, Object> params) { /**
String requestBody = HttpUtil.createPost(url).contentType("application/json;charset=utf-8").body(JSONObject.toJSONString(params)).execute().body(); * 勤策 post请求
* @param url
* @param params
* @return
*/
public static JSONObject postQC(String url, Object params) {
String requestBody = HttpUtil.createPost(url).contentType("application/json;charset=utf-8").header("","").body(JSONObject.toJSONString(params)).execute().body();
JSONObject resultJson = JSONObject.parseObject(requestBody); JSONObject resultJson = JSONObject.parseObject(requestBody);
String returnCode = resultJson.getString("return_code"); String returnCode = resultJson.getString("return_code");
if (!"0".equals(returnCode)) { if (!"0".equals(returnCode)) {
throw new RuntimeException("OkHttp.post请求error,详情:" + requestBody); throw new APIException("OkHttp.post请求error,详情:" + requestBody);
} }
return resultJson; return resultJson;
} }
......
...@@ -7,9 +7,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -7,9 +7,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.UUID;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -40,6 +38,8 @@ public class QinCeUtils { ...@@ -40,6 +38,8 @@ public class QinCeUtils {
public static final String QUERY_EMPLOYEE = "/api/employee/v3/queryEmployee/"; public static final String QUERY_EMPLOYEE = "/api/employee/v3/queryEmployee/";
// 终端(商店)列表 // 终端(商店)列表
public static final String QUERY_SHORE = "/api/store/v1/queryStore/"; public static final String QUERY_SHORE = "/api/store/v1/queryStore/";
// 客户位置偏差查询
public static final String CAL_DISTANCE = "/api/cmLocation/v1/calDistance/";
public String builderUrl(String sidepath, Map<String, Object> params) { public String builderUrl(String sidepath, Map<String, Object> params) {
String msgId = UUID.randomUUID().toString(); String msgId = UUID.randomUUID().toString();
...@@ -50,6 +50,15 @@ public class QinCeUtils { ...@@ -50,6 +50,15 @@ public class QinCeUtils {
return builder.toString(); return builder.toString();
} }
public String builderUrlList(String sidepath, List<Map> paramList) {
String msgId = UUID.randomUUID().toString();
Long currentTimeMillis = System.currentTimeMillis();
String digest = getDigest(paramList, currentTimeMillis);
StringBuilder builder = new StringBuilder().append(OPEN_API).append(sidepath).append(OPEN_ID).append("/").append(currentTimeMillis).append("/").append(digest).append("/").append(msgId);
return builder.toString();
}
/** /**
* 查询[部门]参数 * 查询[部门]参数
*/ */
...@@ -123,6 +132,19 @@ public class QinCeUtils { ...@@ -123,6 +132,19 @@ public class QinCeUtils {
return params; return params;
} }
/**
* 客户位置偏差查询 参数
* longitude:经度
* latitude:纬度
*/
public List<Map> queryCalDistanceParam(String storeQcId, String longitude, String latitude) {
Map<String, Object> params = new HashMap<>();
params.put("qince_customer_id", storeQcId);
params.put("longitude", longitude);
params.put("latitude", latitude);
return Arrays.asList(params);
}
private String getDigest(Map<String, Object> params, Long currentTimeMillis) { private String getDigest(Map<String, Object> params, Long currentTimeMillis) {
String json = ""; String json = "";
if (!CollectionUtils.isEmpty(params)) { if (!CollectionUtils.isEmpty(params)) {
...@@ -132,4 +154,13 @@ public class QinCeUtils { ...@@ -132,4 +154,13 @@ public class QinCeUtils {
return digest; return digest;
} }
private String getDigest(List<Map> paramList, Long currentTimeMillis) {
String json = "";
if (!CollectionUtils.isEmpty(paramList)) {
json = JSONObject.toJSONString(paramList);
}
String digest = DigestUtils.md5Hex(json + "|" + APP_KEY + "|" + currentTimeMillis);
return digest;
}
} }
...@@ -41,6 +41,8 @@ wx: ...@@ -41,6 +41,8 @@ wx:
msgDataFormat: JSON msgDataFormat: JSON
temporary: temporary:
token_secret: sXwHPj#U#xmim^ts token_secret: sXwHPj#U#xmim^ts
employee:
token_secret: xZq%kXASSPD$UtL
tengxunyun: tengxunyun:
# 腾讯云个人账号信息 # 腾讯云个人账号信息
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wangxiaolu.promotion.domain.activity.mapper.PromotionManageEmployeeMapper">
<resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.activity.mapper.entity.PromotionManageEmployeeDO">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="employeeNo" column="employee_no" jdbcType="VARCHAR"/>
<result property="passwork" column="passwork" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,name,employee_no,
passwork
</sql>
</mapper>
package com.wangxiaolu.promotion.controller.user; package com.wangxiaolu.promotion.controller.user;
import com.wangxiaolu.promotion.controller.user.qince.QinCeDataTaskController;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.*;
/** /**
* @author : liqiulin * @author : liqiulin
* @date : 2024-03-29 17 * @date : 2024-03-29 17
......
package com.wangxiaolu.promotion.service.activity.temporary.impl;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author : liqiulin
* @date : 2024-05-28 15
* @describe :
*/
@SpringBootTest
@RunWith(SpringRunner.class)
class TemporaryActivityCoreServiceImplTest {
@Autowired
TemporaryActivityCoreServiceImpl temporaryActivityCoreService;
@Test
void clockStoreCalDistance() {
temporaryActivityCoreService.clockStoreCalDistance("7552853602498153022",null,"116.608403,40.113349");
}
}
\ No newline at end of file
...@@ -34,7 +34,7 @@ class OkHttpTest { ...@@ -34,7 +34,7 @@ class OkHttpTest {
System.out.println(url); System.out.println(url);
// 发起请求 // 发起请求
JSONObject resultJson = OkHttp.post(url, params); JSONObject resultJson = OkHttp.postQC(url, params);
JSONArray responseDatas = resultJson.getJSONArray("response_data"); JSONArray responseDatas = resultJson.getJSONArray("response_data");
for (Object responseData : responseDatas) { for (Object responseData : responseDatas) {
System.out.println(responseData); System.out.println(responseData);
...@@ -54,7 +54,7 @@ class OkHttpTest { ...@@ -54,7 +54,7 @@ class OkHttpTest {
System.out.println(url); System.out.println(url);
// 发起请求 // 发起请求
JSONObject resultJson = OkHttp.post(url, params); JSONObject resultJson = OkHttp.postQC(url, params);
JSONArray responseDatas = resultJson.getJSONArray("response_data"); JSONArray responseDatas = resultJson.getJSONArray("response_data");
for (Object responseData : responseDatas) { for (Object responseData : responseDatas) {
System.out.println(responseData); System.out.println(responseData);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论