小智根据手机号查询登录信息

小智根据手机号查询登录信息
master
siontion 6 months ago
parent 67fb4a6efd
commit ec2d7bf71d

2
.gitignore vendored

@ -34,3 +34,5 @@ build/
### VS Code ###
.vscode/
nxhs-service/src/main/resources/application.yml
*.yml

@ -36,6 +36,13 @@ public class CommonResult<T> implements Serializable {
result.msg = "";
return result;
}
public static <T> CommonResult<T> success(T data, String message) {
CommonResult<T> result = new CommonResult<>();
result.code = 200;
result.data = data;
result.msg = message;
return result;
}
public static boolean isSuccess(Integer code) {
return Objects.equals(code, 200);

@ -162,6 +162,32 @@ public class CommonUtil {
}
});
}
public static String dateNow(String pattern) {
Date date = new Date();
if (pattern == null && "".equals(pattern)) {
return null;
} else {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
String dateString = formatter.format(date);
return dateString;
}
}
public static String padRight(String src, int len, char ch) {
int diff = len - src.length();
if (diff <= 0) {
return src;
} else {
char[] charr = new char[len];
System.arraycopy(src.toCharArray(), 0, charr, diff, src.length());
for(int i = 0; i < diff; ++i) {
charr[i] = ch;
}
return new String(charr);
}
}
public static void main(String[] args) {

@ -0,0 +1,23 @@
package cc.yunxi.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(15000);
factory.setReadTimeout(5000);
return factory;
}
}

@ -0,0 +1,58 @@
package cc.yunxi.controller;
import cc.yunxi.aspect.UserTypeAnnotation;
import cc.yunxi.common.domain.CommonResult;
import cc.yunxi.common.domain.PageDTO;
import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.dto.WxLoginDTO;
import cc.yunxi.domain.dto.ZSGLoginDTO;
import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.po.ClientAccountDetail;
import cc.yunxi.domain.query.ClientAccountQuery;
import cc.yunxi.domain.query.ClientQuery;
import cc.yunxi.domain.vo.client.ClientAccountRespVO;
import cc.yunxi.domain.vo.client.ClientRespVO;
import cc.yunxi.domain.vo.client.ClientUpdateVO;
import cc.yunxi.enums.UserTypeEnum;
import cc.yunxi.service.IClientService;
import cc.yunxi.service.impl.CommonService;
import cc.yunxi.utils.UserContext;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
*
* </p>
*
* @author ccongli
* @since 2024-02-28 06:08:09
*/
@Api(tags = "小智登录接口")
@RestController
@RequiredArgsConstructor
@Slf4j
public class EntranceController {
private final CommonService commonService;
@ApiOperation("小智系统请求用户登录接口")
@RequestMapping("/login_name")
public CommonResult<ZSGLoginDTO> ZSG_Login(@RequestParam(name="loginName",required = true) String loginName) {
ZSGLoginDTO zsgLoginDTO = commonService.loginByZSG(loginName);
return CommonResult.success(zsgLoginDTO,"请求成功");
}
}

@ -0,0 +1,76 @@
package cc.yunxi.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
@ApiModel(description = "小程序认证实体")
public class ZSGLoginDTO {
@ApiModelProperty(value = "序号")
private Long id;
@ApiModelProperty(value = "登陆名称")
private String loginName;
@ApiModelProperty(value = "状态 0:正常 1:冻结 2:删除")
private Integer stat;
@ApiModelProperty(value = "角色 2:设备管理员 4:清运员 9:普通用户")
private Integer role;
@ApiModelProperty(value = "积分")
private Integer score;
//
// @ApiModelProperty(value = "loginType")
// @NotBlank(message = "登陆类型:1手机号登陆 2网络登陆(小程序) ")
// private String loginType;
//
// @ApiModelProperty(value = "devid")
// @NotBlank(message = "设备id 默认为1代表没有配置文件")
// private String devid;
//
// @ApiModelProperty(value = "clientId")
// @NotBlank(message = "小智客户端id")
// private String clientId;
//
// @ApiModelProperty(value = "clientType")
// @NotBlank(message = "小智客户端类型")
// private String clientType;
//
// @ApiModelProperty(value = "clientVersion")
// @NotBlank(message = "小智客户端版本")
// private String clientVersion;
//
// @ApiModelProperty(value = "appid")
// @NotBlank(message = "小程序id")
// private String appid;
//
// @ApiModelProperty(value = "devsn")
// @NotBlank(message = "设备编码")
// private String devsn;
//
// @ApiModelProperty(value = "devType")
// @NotBlank(message = "设备类型")
// private String devType;
//
// @ApiModelProperty(value = "test")
// @NotBlank(message = "测试模式 1为测试模式")
// private String test;
//
// @ApiModelProperty(value = "ltn")
// @NotBlank(message = "登陆类型描述 手机号登陆 网络登陆")
// private String ltn;
//
// @ApiModelProperty(value = "ac")
// @NotBlank(message = "ac版本1")
// private String ac;
//
// @ApiModelProperty(value = "acc")
// @NotBlank(message = "ac版本2")
// private String acc;
}

@ -0,0 +1,96 @@
package cc.yunxi.domain.po;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("base_bill_rule")
@ApiModel(value = "BillRule", description = "单据规则")
public class BillRule {
@TableId(value = "f_id", type = IdType.ASSIGN_ID)
@ApiModelProperty("主键id")
private String id;
/**
*
*/
@TableField("f_full_name")
@ApiModelProperty("单据名称")
private String fullName;
/**
*
*/
@TableField("f_en_code")
@ApiModelProperty("单据编码")
private String enCode;
/**
*
*/
@TableField("f_prefix")
@ApiModelProperty("单据前缀")
private String prefix;
/**
*
*/
@TableField("f_date_format")
@ApiModelProperty("日期格式")
private String dateFormat;
/**
*
*/
@TableField("f_digit")
@ApiModelProperty("流水位数")
private Integer digit;
/**
*
*/
@TableField("f_start_number")
@ApiModelProperty("流水起始")
private String startNumber;
/**
*
*/
@TableField("f_example")
@ApiModelProperty("流水范例")
private String example;
/**
*
*/
@TableField("f_this_number")
@ApiModelProperty("当前流水号")
private Integer thisNumber;
/**
*
*/
@TableField("f_output_number")
@ApiModelProperty("输出流水号")
private String outputNumber;
/**
*
*/
@TableField("f_category")
@ApiModelProperty("分类")
private String category;
}

@ -26,24 +26,31 @@ public class Recycler {
private String id;
@ApiModelProperty("所属回收站")
@TableField(value = "station_id")
private String stationId;
@ApiModelProperty("回收员姓名")
@TableField(value = "staffs_name")
private String staffsName;
@ApiModelProperty("回收员电话")
@TableField(value = "mobile_phone")
private String mobilePhone;
@ApiModelProperty("头像")
@TableField(value = "head_icon")
private String headIcon;
@ApiModelProperty("性别")
@TableField(value = "gender")
private Integer gender;
@ApiModelProperty("总里程数")
@TableField(value = "recycle_miles")
private Double recycleMiles;
@ApiModelProperty("总订单数")
@TableField(value = "order_total")
private Integer orderTotal;
@ApiModelProperty("好评数")
@ -51,9 +58,11 @@ public class Recycler {
private Integer goodTotal;
@ApiModelProperty("总回收金额")
@TableField(value = "order_amount")
private BigDecimal orderAmount;
@ApiModelProperty("自动接单 (0-否1-是) ")
@TableField(value = "auto_enabled")
private Integer autoEnabled;
@ApiModelProperty("状态 (0-禁用1-启用)")
@ -61,6 +70,7 @@ public class Recycler {
private Integer status;
@ApiModelProperty("wxopenid")
@TableField(value = "openid")
private String openid;
@ApiModelProperty("商户id")

@ -0,0 +1,14 @@
package cc.yunxi.mapper;
import cc.yunxi.domain.po.BillRule;
import cc.yunxi.domain.po.Recycler;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* mapper
*/
@Mapper
public interface BillRuleMapper extends BaseMapper<BillRule> {
}

@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ClientMapper extends BaseMapper<Client> {
String isClientUnit(String phoneNumber);
Client getLatestClientByPhone(String phone);
}

@ -1,14 +1,21 @@
package cc.yunxi.mapper;
import cc.yunxi.domain.po.PriceProduct;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.po.Test;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* mapper
*/
@Mapper
public interface RecyclerMapper extends BaseMapper<Recycler> {
/**
* phone
* @param phone
* @return Price
*/
Recycler getLatestRecycleByPhone(@Param("phone") String phone);
}

@ -0,0 +1,35 @@
package cc.yunxi.service;
import cc.yunxi.domain.po.BillRule;
import cc.yunxi.domain.po.RecycleOrder;
import cc.yunxi.domain.query.RecycleOrderQuery;
import cc.yunxi.domain.vo.recycleorder.dzorder.DZRecycleOrderCreateVO;
import cc.yunxi.domain.vo.recycleorder.shorder.*;
import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderCreateVO;
import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderFinishVO;
import cc.yunxi.enums.OrderTypeEnum;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/**
* <p>
*
* </p>
*
* @author ccongli
* @since 2024-03-01 11:15:39
*/
public interface IBillRuleService extends IService<BillRule> {
/**
*
* @param enCode
* @return BillRule
*/
BillRule getBillRuleByCode(String enCode);
boolean updateById(BillRule billRule);
}

@ -60,6 +60,7 @@ public interface IClientService extends IService<Client> {
* @return Client
*/
Client getClientByMobile(String mobile);
Client getLastestClientByPhone(String phone);
/**
*

@ -78,4 +78,6 @@ public interface IRecyclerService extends IService<Recycler> {
*/
void totalTick(String recyclerId, Double distance, BigDecimal amount);
Recycler getLatestRecycleByPhone(String phone);
}

@ -0,0 +1,39 @@
package cc.yunxi.service;
import cn.hutool.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class RestTemplateToInterface {
@Autowired
private RestTemplate restTemplate;
/**
* exchange
* @return
*/
public String restPost(String url, Integer age, String name){
//header参数
HttpHeaders headers = new HttpHeaders();
String token = "asdfaf2322";
headers.add("authorization", token);
headers.setContentType(MediaType.APPLICATION_JSON);
//放入body中的json参数
JSONObject obj = new JSONObject();
obj.put("age", age);
obj.put("name", name);
//组装
HttpEntity<JSONObject> request = new HttpEntity<>(obj, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, String.class);
String body = responseEntity.getBody();
return body;
}
}

@ -0,0 +1,74 @@
package cc.yunxi.service.impl;
import cc.yunxi.common.domain.LambdaQueryWrapperX;
import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.exception.BusinessLogicException;
import cc.yunxi.common.exception.ForbiddenException;
import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.common.utils.CommonUtil;
import cc.yunxi.domain.dto.LocationDTO;
import cc.yunxi.domain.po.*;
import cc.yunxi.domain.query.RecycleOrderQuery;
import cc.yunxi.domain.vo.recycleorder.dzorder.DZRecycleOrderCreateVO;
import cc.yunxi.domain.vo.recycleorder.shorder.*;
import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderCreateVO;
import cc.yunxi.domain.vo.recycleorder.tmorder.TMRecycleOrderFinishVO;
import cc.yunxi.domain.vo.recycleorderdetail.RecycleOrderDetailCreateVO;
import cc.yunxi.domain.vo.recycleorderdetail.RecycleOrderDetailSaveVO;
import cc.yunxi.enums.BusinessCodeEnum;
import cc.yunxi.enums.OrderStatusEnum;
import cc.yunxi.enums.OrderTypeEnum;
import cc.yunxi.enums.UserTypeEnum;
import cc.yunxi.mapper.BillRuleMapper;
import cc.yunxi.mapper.RecycleOrderMapper;
import cc.yunxi.service.*;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author ccongli
* @since 2024-03-01 11:15:39
*/
@Service
@Validated
@Slf4j
public class BillRuleServiceImpl extends ServiceImpl<BillRuleMapper, BillRule> implements IBillRuleService {
@Override
public BillRule getBillRuleByCode(String enCode) {
LambdaQueryWrapper<BillRule> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BillRule::getEnCode, enCode);
BillRule entity = this.getOne(wrapper);
return entity;
}
@Override
public boolean updateById(BillRule billRule) {
return this.updateById(billRule);
}
}

@ -135,6 +135,11 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
return client;
}
@Override
public Client getLastestClientByPhone(String phone) {
return clientMapper.getLatestClientByPhone(phone);
}
@Override
@Transactional

@ -7,8 +7,10 @@ import cc.yunxi.config.props.WxHsyProperties;
import cc.yunxi.config.props.WxShProperties;
import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.dto.WxLoginDTO;
import cc.yunxi.domain.dto.ZSGLoginDTO;
import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.query.RecyclerQuery;
import cc.yunxi.enums.UserTypeEnum;
import cc.yunxi.service.IClientService;
import cc.yunxi.service.ICommonService;
@ -96,6 +98,32 @@ public class CommonService implements ICommonService {
return userDTO;
}
public ZSGLoginDTO loginByZSG(String loginName) {
ZSGLoginDTO zsgLoginDTO = new ZSGLoginDTO();
Recycler recycler = recyclerService.getLatestRecycleByPhone(loginName);
Client client = clientService.getLastestClientByPhone(loginName);
if (recycler == null) {
if(client != null){
// 设置投递员信息
zsgLoginDTO.setId(Long.parseLong(client.getId()));
zsgLoginDTO.setLoginName(loginName);
zsgLoginDTO.setStat(client.getEnabledMark().equals(1)?0:2);
zsgLoginDTO.setRole(9);
zsgLoginDTO.setScore(client.getMembershipPoint());
}
}else {
// 设置清运员信息
zsgLoginDTO.setId(Long.parseLong(recycler.getId()));
zsgLoginDTO.setLoginName(loginName);
zsgLoginDTO.setStat(0);
zsgLoginDTO.setRole(4);
zsgLoginDTO.setScore(0);
}
return zsgLoginDTO;
}
@Override
public UserDTO loginByRecycler(WxLoginDTO wxLoginDTO) {

@ -4,10 +4,7 @@ import cc.yunxi.common.domain.LambdaQueryWrapperX;
import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.common.utils.CommonUtil;
import cc.yunxi.domain.po.Enterprise;
import cc.yunxi.domain.po.EnterpriseAccountBill;
import cc.yunxi.domain.po.EnterpriseWallet;
import cc.yunxi.domain.po.RecycleStation;
import cc.yunxi.domain.po.*;
import cc.yunxi.domain.query.WalletQuery;
import cc.yunxi.domain.vo.enterprise.WalletVO;
import cc.yunxi.enums.BusinessCodeEnum;
@ -15,6 +12,7 @@ import cc.yunxi.enums.GlobalStatusEnum;
import cc.yunxi.mapper.EnterpriseAccountBillMapper;
import cc.yunxi.mapper.EnterpriseMapper;
import cc.yunxi.mapper.WalletMapper;
import cc.yunxi.service.IBillRuleService;
import cc.yunxi.service.IEnterpriseService;
import cc.yunxi.service.IEnterpriseWalletService;
import cc.yunxi.service.IRecycleStationService;
@ -30,7 +28,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
@ -46,6 +46,9 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
@Autowired
private WalletMapper walletMapper;
@Autowired
private IBillRuleService billRuleService;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean isOrgUser(String phone) {
@ -66,6 +69,8 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
@Transactional(rollbackFor = Exception.class)
public String addWallet(WalletVO walletVO) {
EnterpriseWallet enterpriseWallet = BeanUtils.copyBean(walletVO, EnterpriseWallet.class);
enterpriseWallet.setCode(this.getNumber("LS"));
// 返回内容
walletMapper.insert(enterpriseWallet);
@ -84,5 +89,45 @@ public class EnterpriseWalletServiceImpl extends ServiceImpl<WalletMapper, Enter
return this.page(pageDO, wrapperX);
}
private String getNumber(String enCode) {
StringBuilder strNumber = new StringBuilder();
LambdaQueryWrapper<BillRule> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BillRule::getEnCode, enCode);
BillRule entity = billRuleService.getBillRuleByCode(enCode);
if (entity != null) {
Integer startNumber = Integer.parseInt(entity.getStartNumber());
String dateFor = entity.getDateFormat();
//处理隔天流水号归0
if (entity.getOutputNumber() != null) {
String serialDate;
entity.setThisNumber(entity.getThisNumber() + 1);
if (!"no".equals(dateFor)) {
String thisDate = CommonUtil.dateNow(entity.getDateFormat());
serialDate = entity.getOutputNumber().substring((entity.getOutputNumber().length() - dateFor.length() - entity.getDigit()), (entity.getOutputNumber().length() - entity.getDigit()));
if (!serialDate.equals(thisDate)) {
entity.setThisNumber(0);
}
}
} else {
entity.setThisNumber(0);
}
//拼接单据编码
strNumber.append(entity.getPrefix());
if (!"no".equals(dateFor)) {
strNumber.append(CommonUtil.dateNow(entity.getDateFormat()));
}
strNumber.append(CommonUtil.padRight(String.valueOf((startNumber) + entity.getThisNumber()), entity.getDigit(), '0'));
//更新流水号
entity.setOutputNumber(strNumber.toString());
billRuleService.updateById(entity);
}
return strNumber.toString();
}
}

@ -83,6 +83,11 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
return recycler;
}
@Override
public Recycler getLatestRecycleByPhone(String phone) {
return recyclerMapper.getLatestRecycleByPhone(phone);
}
@Override
public List<Recycler> getRecyclerByIds(Collection<String> recyclerIds) {
LambdaQueryWrapperX<Recycler> wrapperX = new LambdaQueryWrapperX<>();

@ -7,4 +7,8 @@
SELECT idname FROM nx_manager where mobile_phone = #{phoneNumber};
</select>
<select id="getLatestClientByPhone" resultType="Client">
SELECT * FROM nx_client where mobile_phone = #{phone} limit 1;
</select>
</mapper>

@ -1,5 +1,7 @@
<?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="cc.yunxi.mapper.ClientMapper">
<mapper namespace="cc.yunxi.mapper.RecyclerMapper">
<select id="getLatestRecycleByPhone" resultType="Recycler">
SELECT * from nx_recycle_station_staff where mobile_phone= #{phone} LIMIT 1;
</select>
</mapper>

Loading…
Cancel
Save