【admin】新增# 1.新增客户联系人登录 2.修改小程序登录逻辑
parent
31357a6529
commit
b8743373c3
|
@ -2,23 +2,28 @@ package com.hcy.admin.service.client.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.hcy.admin.AdminThreadLocal;
|
import com.hcy.admin.AdminThreadLocal;
|
||||||
import com.hcy.admin.service.client.IClientContactsService;
|
import com.hcy.admin.service.client.IClientContactsService;
|
||||||
import com.hcy.admin.service.region.IDevRegionService;
|
import com.hcy.admin.service.region.IDevRegionService;
|
||||||
|
import com.hcy.admin.service.system.ISystemAuthRoleService;
|
||||||
import com.hcy.admin.validate.client.ClientContactsParam;
|
import com.hcy.admin.validate.client.ClientContactsParam;
|
||||||
import com.hcy.admin.validate.common.PageParam;
|
|
||||||
import com.hcy.admin.vo.client.ClientContactsDetailVo;
|
import com.hcy.admin.vo.client.ClientContactsDetailVo;
|
||||||
import com.hcy.admin.vo.client.ClientContactsListVo;
|
import com.hcy.admin.vo.client.ClientContactsListVo;
|
||||||
|
import com.hcy.admin.vo.system.SystemAuthRoleVo;
|
||||||
import com.hcy.common.constant.GlobalConstant;
|
import com.hcy.common.constant.GlobalConstant;
|
||||||
import com.hcy.common.core.PageResult;
|
|
||||||
import com.hcy.common.entity.client.Client;
|
|
||||||
import com.hcy.common.entity.client.ClientContacts;
|
import com.hcy.common.entity.client.ClientContacts;
|
||||||
|
import com.hcy.common.entity.system.SystemAuthAdmin;
|
||||||
|
import com.hcy.common.entity.user.User;
|
||||||
|
import com.hcy.common.enums.user.UserRoleEnum;
|
||||||
|
import com.hcy.common.enums.user.UserTypeEnum;
|
||||||
import com.hcy.common.exception.OperateException;
|
import com.hcy.common.exception.OperateException;
|
||||||
import com.hcy.common.mapper.client.ClientContactsMapper;
|
import com.hcy.common.mapper.client.ClientContactsMapper;
|
||||||
|
import com.hcy.common.mapper.system.SystemAuthAdminMapper;
|
||||||
|
import com.hcy.common.mapper.user.UserMapper;
|
||||||
|
import com.hcy.common.utils.ToolsUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -36,6 +41,15 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
@Resource
|
@Resource
|
||||||
private IDevRegionService regionService;
|
private IDevRegionService regionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SystemAuthAdminMapper systemAuthAdminMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ISystemAuthRoleService iSystemAuthRoleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserMapper userMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户联系人列表
|
* 客户联系人列表
|
||||||
*
|
*
|
||||||
|
@ -81,7 +95,11 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
|
|
||||||
Assert.notNull(model, "数据不存在");
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectById(model.getAdminId());
|
||||||
|
|
||||||
ClientContactsDetailVo vo = new ClientContactsDetailVo();
|
ClientContactsDetailVo vo = new ClientContactsDetailVo();
|
||||||
|
vo.setUsername(systemAuthAdmin.getUsername());
|
||||||
|
vo.setRole(systemAuthAdmin.getRole());
|
||||||
BeanUtils.copyProperties(model, vo);
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
Map<Long, String> regionMap = regionService.getRegionMap();
|
Map<Long, String> regionMap = regionService.getRegionMap();
|
||||||
|
@ -98,14 +116,71 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
* @param clientContactsParam 参数
|
* @param clientContactsParam 参数
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void add(ClientContactsParam clientContactsParam) {
|
public void add(ClientContactsParam clientContactsParam) {
|
||||||
Integer count = clientContactsMapper.checkClientContactsPhoneRepetition(clientContactsParam.getPhone());
|
LambdaQueryWrapper<ClientContacts> queryWrapper = new LambdaQueryWrapper<ClientContacts>()
|
||||||
|
.eq(ClientContacts::getIsDelete, GlobalConstant.NOT_DELETE)
|
||||||
|
.eq(ClientContacts::getPhone, clientContactsParam.getPhone());
|
||||||
|
|
||||||
|
Integer count = clientContactsMapper.selectCount(queryWrapper);
|
||||||
if(count > 0){
|
if(count > 0){
|
||||||
throw new OperateException("已存在客户或联系人相同手机号码");
|
throw new OperateException("已存在客户联系人相同手机号码");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
|
||||||
|
.eq("is_delete", GlobalConstant.NOT_DELETE)
|
||||||
|
.eq("username", clientContactsParam.getUsername())
|
||||||
|
.last("limit 1")), "账号已存在换一个吧!");
|
||||||
|
|
||||||
|
Assert.isNull(userMapper.selectOne(new LambdaQueryWrapper<User>()
|
||||||
|
.eq(User::getMobile,clientContactsParam.getPhone())
|
||||||
|
.last("limit 1")),"该手机号小程序已被注册");
|
||||||
|
|
||||||
|
SystemAuthRoleVo roleVo = iSystemAuthRoleService.detail(clientContactsParam.getRole());
|
||||||
|
Assert.notNull(roleVo, "角色不存在!");
|
||||||
|
Assert.isTrue(roleVo.getIsDisable() <= 0, "当前角色已被禁用!");
|
||||||
|
|
||||||
ClientContacts model = new ClientContacts();
|
ClientContacts model = new ClientContacts();
|
||||||
BeanUtils.copyProperties(clientContactsParam,model);
|
BeanUtils.copyProperties(clientContactsParam,model);
|
||||||
|
|
||||||
|
//新增联系人后台用户
|
||||||
|
String salt = ToolsUtil.randomString(5);
|
||||||
|
String pwd = ToolsUtil.makeMd5(clientContactsParam.getPassword().trim() + salt);
|
||||||
|
String avatar = "/api/static/backend_avatar.png";
|
||||||
|
SystemAuthAdmin admin = new SystemAuthAdmin();
|
||||||
|
admin.setSex(clientContactsParam.getSex());
|
||||||
|
admin.setRole(clientContactsParam.getRole());
|
||||||
|
admin.setPassword(pwd);
|
||||||
|
admin.setNickname(clientContactsParam.getName());
|
||||||
|
admin.setUsername(clientContactsParam.getName());
|
||||||
|
admin.setSalt(salt);
|
||||||
|
admin.setProvinceId(clientContactsParam.getProvinceId());
|
||||||
|
admin.setCityId(clientContactsParam.getCityId());
|
||||||
|
admin.setDistrictId(clientContactsParam.getDistrictId());
|
||||||
|
admin.setAvatar(avatar);
|
||||||
|
admin.setPhone(clientContactsParam.getPhone());
|
||||||
|
admin.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
if(clientContactsParam.getRole() != UserRoleEnum.KH_CGY.getType()){
|
||||||
|
//新增小程序用户
|
||||||
|
Integer sn = this.randMakeSn();
|
||||||
|
User user = new User();
|
||||||
|
user.setSn(sn);
|
||||||
|
user.setType(UserTypeEnum.USER_SIDE.getType());
|
||||||
|
user.setAvatar(avatar);
|
||||||
|
user.setNickname(clientContactsParam.getName());
|
||||||
|
user.setUsername(clientContactsParam.getName());
|
||||||
|
user.setSex(clientContactsParam.getSex());
|
||||||
|
user.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||||
|
user.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
user.setMobile(clientContactsParam.getPhone());
|
||||||
|
userMapper.insert(user);
|
||||||
|
model.setUserId(user.getId().longValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
systemAuthAdminMapper.insert(admin);
|
||||||
|
|
||||||
|
model.setAdminId(admin.getId().longValue());
|
||||||
model.setCreatorId(AdminThreadLocal.getAdminId().longValue());
|
model.setCreatorId(AdminThreadLocal.getAdminId().longValue());
|
||||||
|
|
||||||
clientContactsMapper.insert(model);
|
clientContactsMapper.insert(model);
|
||||||
|
@ -126,20 +201,12 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
|
|
||||||
Assert.notNull(model, "数据不存在!");
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
Integer count = clientContactsMapper.checkEditClientContactsPhoneRepetition(
|
|
||||||
clientContactsParam.getId(),
|
|
||||||
clientContactsParam.getClientId(),
|
|
||||||
clientContactsParam.getPhone());
|
|
||||||
|
|
||||||
if(count > 0){
|
|
||||||
throw new OperateException("已存在客户或联系人相同手机号码");
|
|
||||||
}
|
|
||||||
|
|
||||||
BeanUtils.copyProperties(model,clientContactsParam);
|
BeanUtils.copyProperties(model,clientContactsParam);
|
||||||
clientContactsMapper.updateById(model);
|
clientContactsMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public void editStatus(ClientContactsParam clientContactsParam) {
|
public void editStatus(ClientContactsParam clientContactsParam) {
|
||||||
ClientContacts model = clientContactsMapper.selectOne(
|
ClientContacts model = clientContactsMapper.selectOne(
|
||||||
new QueryWrapper<ClientContacts>()
|
new QueryWrapper<ClientContacts>()
|
||||||
|
@ -151,6 +218,18 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
|
|
||||||
model.setStatus(clientContactsParam.getStatus());
|
model.setStatus(clientContactsParam.getStatus());
|
||||||
|
|
||||||
|
//同步修改账户状态
|
||||||
|
SystemAuthAdmin systemAuthAdmin = systemAuthAdminMapper.selectById(model.getAdminId());
|
||||||
|
systemAuthAdmin.setIsDisable(clientContactsParam.getStatus());
|
||||||
|
|
||||||
|
//同步小程序状态
|
||||||
|
User user = userMapper.selectById(model.getUserId());
|
||||||
|
if(user != null){
|
||||||
|
user.setIsDisable(clientContactsParam.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
userMapper.updateById(user);
|
||||||
|
systemAuthAdminMapper.updateById(systemAuthAdmin);
|
||||||
clientContactsMapper.updateById(model);
|
clientContactsMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,4 +253,24 @@ public class ClientContactsServiceImpl implements IClientContactsService {
|
||||||
clientContactsMapper.updateById(model);
|
clientContactsMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成用户编号
|
||||||
|
*
|
||||||
|
* @return Integer
|
||||||
|
* @author fzr
|
||||||
|
*/
|
||||||
|
private Integer randMakeSn() {
|
||||||
|
Integer sn;
|
||||||
|
while (true) {
|
||||||
|
sn = Integer.parseInt(ToolsUtil.randomInt(8));
|
||||||
|
User snModel = userMapper.selectOne(new QueryWrapper<User>()
|
||||||
|
.select("id,sn,username")
|
||||||
|
.eq("sn", sn)
|
||||||
|
.last("limit 1"));
|
||||||
|
if (snModel == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,21 @@ public class ClientContactsParam implements Serializable {
|
||||||
|
|
||||||
private Long creatorId;
|
private Long creatorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "username参数缺失", groups = {create.class, update.class})
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户密码
|
||||||
|
*/
|
||||||
|
@NotNull(message = "password参数缺失", groups = {create.class})
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
@NotNull(message = "role参数缺失", groups = {create.class, update.class})
|
||||||
|
private Integer role;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.hcy.admin.vo.client;
|
package com.hcy.admin.vo.client;
|
||||||
|
|
||||||
|
import com.hcy.admin.validate.client.ClientContactsParam;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,4 +30,13 @@ public class ClientContactsDetailVo implements Serializable {
|
||||||
private Integer status; // 账户状态 0-正常 1-停用
|
private Integer status; // 账户状态 0-正常 1-停用
|
||||||
private Long creatorId; // 创建人id
|
private Long creatorId; // 创建人id
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
private Integer role;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class ClientContacts implements Serializable {
|
||||||
private Long id; // id
|
private Long id; // id
|
||||||
private Long clientId; // 客户id
|
private Long clientId; // 客户id
|
||||||
private Long userId; // 用户id
|
private Long userId; // 用户id
|
||||||
|
private Long adminId; //后台id
|
||||||
private String name; // 姓名
|
private String name; // 姓名
|
||||||
private Integer sex; // 性别 0-男 1-女
|
private Integer sex; // 性别 0-男 1-女
|
||||||
private String phone; // 联系电话
|
private String phone; // 联系电话
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.hcy.common.enums.user;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户角色枚举
|
||||||
|
*/
|
||||||
|
public enum UserRoleEnum {
|
||||||
|
|
||||||
|
KH_ZGRY(1, "客户-主管人员"),
|
||||||
|
KH_KFRY(2, "客户-客服人员"),
|
||||||
|
PT_GLY(3, "平台-管理员"),
|
||||||
|
PT_KFRY(4, "平台-客服人员"),
|
||||||
|
CK_WLCGY(5, "仓库-物料仓管员"),
|
||||||
|
JX_XCJXY(6, "检修-现场检修员"),
|
||||||
|
WX_CNWXY(7, "维修-厂内维修员"),
|
||||||
|
YW_YWZG(8, "业务-业务主管"),
|
||||||
|
YW_YWY(9, "业务-业务员"),
|
||||||
|
CN_WXZG(10,"厂内-维修主管"),
|
||||||
|
KH_CGY(11,"客户-采购员");
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
UserRoleEnum(int code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取状态码
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @author dabin
|
||||||
|
*/
|
||||||
|
public int getType() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取提示
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
* @author dabin
|
||||||
|
*/
|
||||||
|
public String getDesc() {
|
||||||
|
return this.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<Integer, String> getMap() {
|
||||||
|
Map<Integer, String> map = Maps.newHashMap();
|
||||||
|
for (UserRoleEnum userRoleEnum : UserRoleEnum.values()) {
|
||||||
|
map.put(userRoleEnum.code, userRoleEnum.desc);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,38 +12,4 @@ import org.apache.ibatis.annotations.Select;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ClientContactsMapper extends IBaseMapper<ClientContacts> {
|
public interface ClientContactsMapper extends IBaseMapper<ClientContacts> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验客户联系重复
|
|
||||||
* @param phone 手机号码
|
|
||||||
* @return 数量
|
|
||||||
*/
|
|
||||||
@Select("SELECT\n" +
|
|
||||||
"\tcount(*) \n" +
|
|
||||||
"FROM\n" +
|
|
||||||
"\tla_client_contacts AS cc\n" +
|
|
||||||
"\tLEFT JOIN la_client AS c ON c.id = cc.client_id \n" +
|
|
||||||
"WHERE\n" +
|
|
||||||
"\tc.is_delete = 0 \n" +
|
|
||||||
"\tAND (\n" +
|
|
||||||
"\tcc.phone = #{phone} or c.phone = #{phone})")
|
|
||||||
Integer checkClientContactsPhoneRepetition(@Param("phone") String phone);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验编辑客户联系重复
|
|
||||||
* @param id 联系人id
|
|
||||||
* @param clientId 客户id
|
|
||||||
* @param phone 手机号码
|
|
||||||
* @return 数量
|
|
||||||
*/
|
|
||||||
@Select("SELECT\n" +
|
|
||||||
"\tcount(*) \n" +
|
|
||||||
"FROM\n" +
|
|
||||||
"\tla_client_contacts AS cc\n" +
|
|
||||||
"\tLEFT JOIN la_client AS c ON c.id = cc.client_id \n" +
|
|
||||||
"WHERE\n" +
|
|
||||||
"\tc.is_delete = 0 \n" +
|
|
||||||
"\tAND cc.id != ${id}\n" +
|
|
||||||
"\tAND c.id != ${clientId}\n" +
|
|
||||||
"\tAND (cc.phone = #{phone} OR c.phone = #{phone})")
|
|
||||||
Integer checkEditClientContactsPhoneRepetition(@Param("id") Long id,@Param("clientId") Long clientId,@Param("phone") String phone);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@ import com.hcy.common.entity.system.SystemConfig;
|
||||||
import com.hcy.common.entity.wxpay.SystemWxPayConfig;
|
import com.hcy.common.entity.wxpay.SystemWxPayConfig;
|
||||||
import com.hcy.common.enums.OrderPlayTypeEnum;
|
import com.hcy.common.enums.OrderPlayTypeEnum;
|
||||||
import com.hcy.common.enums.PayChannelEnum;
|
import com.hcy.common.enums.PayChannelEnum;
|
||||||
import com.hcy.common.mapper.pay.DevPayMapper;
|
|
||||||
import com.hcy.common.mapper.system.SystemConfigMapper;
|
import com.hcy.common.mapper.system.SystemConfigMapper;
|
||||||
import com.hcy.common.utils.ConfigUtil;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||||
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
|
import me.chanjar.weixin.mp.config.impl.WxMpMapConfigImpl;
|
||||||
|
@ -33,30 +31,9 @@ import java.util.Map;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class WxPayConfiguration {
|
public class WxPayConfiguration {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DevPayMapper devPayMapper;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SystemConfigMapper systemConfigMapper;
|
private SystemConfigMapper systemConfigMapper;
|
||||||
|
|
||||||
@Bean("mpWxPayService")
|
|
||||||
public WxPayService mpWxPayService() {return getWxPayServiceConfig(PayChannelEnum.MP_CHANNEL.getCode());}
|
|
||||||
|
|
||||||
@Bean("staffWxPayService")
|
|
||||||
public WxPayService staffWxPayService() {
|
|
||||||
return getWxPayServiceConfig(PayChannelEnum.STAFF_CHANNEL.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("oaWxPayService")
|
|
||||||
public WxPayService oaWxPayService() {
|
|
||||||
return getWxPayServiceConfig(PayChannelEnum.OA_CHANNEL.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("h5WxPayService")
|
|
||||||
public WxPayService h5WxPayService() {
|
|
||||||
return getWxPayServiceConfig(PayChannelEnum.H5_CHANNEL.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("wxGzhMpService")
|
@Bean("wxGzhMpService")
|
||||||
public WxMpServiceImpl wxStaffMpService(){
|
public WxMpServiceImpl wxStaffMpService(){
|
||||||
Map<String, String> config = getSystemConfigByChancel(PayChannelEnum.GZH_CHANNEL.getCode());
|
Map<String, String> config = getSystemConfigByChancel(PayChannelEnum.GZH_CHANNEL.getCode());
|
||||||
|
@ -69,32 +46,6 @@ public class WxPayConfiguration {
|
||||||
return wxMpService;
|
return wxMpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WxPayService getWxPayServiceConfig(String chancel){
|
|
||||||
Boolean flag = Boolean.FALSE;
|
|
||||||
WxPayConfig payConfig = new WxPayConfig();
|
|
||||||
DevPay devPay = devPayMapper.getEntityByPayWay(OrderPlayTypeEnum.WECHAT_PAY.getType());
|
|
||||||
String config = devPay.getConfig();
|
|
||||||
SystemWxPayConfig systemWxPayConfig = JSON.parseObject(config, SystemWxPayConfig.class);
|
|
||||||
payConfig.setAppId(StringUtils.trimToNull(this.getSystemConfigByChancel(chancel).get("appId")));
|
|
||||||
payConfig.setMchId(StringUtils.trimToNull(systemWxPayConfig.getMchId()));
|
|
||||||
payConfig.setApiV3Key(StringUtils.trimToNull(systemWxPayConfig.getPaySignKey()));
|
|
||||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientKey())) {
|
|
||||||
payConfig.setPrivateKeyContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientKey()).getBytes());
|
|
||||||
flag = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(systemWxPayConfig.getApiclientCert())) {
|
|
||||||
payConfig.setPrivateCertContent(StringUtils.trimToNull(systemWxPayConfig.getApiclientCert()).getBytes());
|
|
||||||
flag = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
WxPayService wxPayService = new WxPayServiceImpl();
|
|
||||||
if (flag) {
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
}
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> getSystemConfigByChancel(String channel) {
|
private Map<String, String> getSystemConfigByChancel(String channel) {
|
||||||
List<SystemConfig> configs = systemConfigMapper.getAppId(channel);
|
List<SystemConfig> configs = systemConfigMapper.getAppId(channel);
|
||||||
Map<String, String> map = new LinkedHashMap<>();
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.hcy.common.dto.result.OrderPageResultDto;
|
||||||
import com.hcy.common.entity.order.Order;
|
import com.hcy.common.entity.order.Order;
|
||||||
import com.hcy.front.FrontThreadLocal;
|
import com.hcy.front.FrontThreadLocal;
|
||||||
import com.hcy.front.service.order.IOrderService;
|
import com.hcy.front.service.order.IOrderService;
|
||||||
import com.hcy.front.service.system.ISystemDevPayWayService;
|
|
||||||
import com.hcy.front.validate.PageParam;
|
import com.hcy.front.validate.PageParam;
|
||||||
import com.hcy.front.validate.order.OrderCancelParam;
|
import com.hcy.front.validate.order.OrderCancelParam;
|
||||||
import com.hcy.front.validate.order.OrderParam;
|
import com.hcy.front.validate.order.OrderParam;
|
||||||
|
@ -37,8 +36,6 @@ public class OrderController {
|
||||||
@Resource
|
@Resource
|
||||||
IOrderService iOrderService;
|
IOrderService iOrderService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ISystemDevPayWayService systemDevPayWayService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单列表
|
* 订单列表
|
||||||
|
@ -185,8 +182,8 @@ public class OrderController {
|
||||||
@RequestParam("type") String type) {
|
@RequestParam("type") String type) {
|
||||||
Assert.notNull(orderId,"orderId不能为空");
|
Assert.notNull(orderId,"orderId不能为空");
|
||||||
Assert.notNull(type,"type不能为空");
|
Assert.notNull(type,"type不能为空");
|
||||||
Map<String, Object> list = systemDevPayWayService.list(scene, orderId, type);
|
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,9 +10,11 @@ import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
import com.hcy.common.config.GlobalConfig;
|
import com.hcy.common.config.GlobalConfig;
|
||||||
|
import com.hcy.common.constant.GlobalConstant;
|
||||||
import com.hcy.common.entity.system.SystemConfig;
|
import com.hcy.common.entity.system.SystemConfig;
|
||||||
import com.hcy.common.entity.user.User;
|
import com.hcy.common.entity.user.User;
|
||||||
import com.hcy.common.entity.user.UserAuth;
|
import com.hcy.common.entity.user.UserAuth;
|
||||||
|
@ -121,27 +123,10 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失!");
|
Assert.notNull(params.get("code"), "code参数缺失!");
|
||||||
Assert.notNull(params.get("iv"), "phone iv参数缺失!");
|
Assert.notNull(params.get("iv"), "phone iv参数缺失!");
|
||||||
String code = params.get("code");
|
String code = params.get("code");
|
||||||
String avatarUrl = params.getOrDefault("avatarUrl", "/api/static/default_avatar.png");
|
|
||||||
String gender = params.getOrDefault("gender", "0");
|
|
||||||
Integer client = Integer.parseInt(params.getOrDefault("client", "1")); // 客户端来源
|
Integer client = Integer.parseInt(params.getOrDefault("client", "1")); // 客户端来源
|
||||||
Integer channel = Integer.parseInt(params.getOrDefault("channel", "0")); //用户类型:[0=用户端,1=师傅端]
|
Integer channel = Integer.parseInt(params.getOrDefault("channel", "0")); //用户类型:[0=用户端,1=师傅端]
|
||||||
String nickName;
|
|
||||||
if(channel == UserTypeEnum.USER_SIDE.getType()){
|
|
||||||
nickName = "粤好生活会员";
|
|
||||||
}else{
|
|
||||||
nickName = "粤好生活师傅";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/*Map<String, String> config = ConfigUtil.get(PayChannelEnum.GZH_CHANNEL.getCode());
|
|
||||||
WxMpServiceImpl wxMpService = new WxMpServiceImpl();
|
|
||||||
WxMpUserService userService = wxMpService.getUserService();
|
|
||||||
WxMpMapConfigImpl wxMpMapConfig = new WxMpMapConfigImpl();
|
|
||||||
wxMpMapConfig.setAppId(config.getOrDefault("appId", ""));
|
|
||||||
wxMpMapConfig.setSecret(config.getOrDefault("appSecret", ""));
|
|
||||||
wxMpService.setWxMpConfigStorage(wxMpMapConfig);
|
|
||||||
List<WxMpUser> wxMpUsers = userService.userInfoList(userService.userList("").getOpenids());*/
|
|
||||||
|
|
||||||
WxMaService wxMaService = WeChatUtil.mnp(channel);
|
WxMaService wxMaService = WeChatUtil.mnp(channel);
|
||||||
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
||||||
|
|
||||||
|
@ -151,90 +136,37 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
//获取手机号码
|
//获取手机号码
|
||||||
String sessionKey = sessionResult.getSessionKey();
|
String sessionKey = sessionResult.getSessionKey();
|
||||||
String encryptedData = params.get("encryptedData");
|
String encryptedData = params.get("encryptedData");
|
||||||
String iv = params.get("iv");
|
WxMaPhoneNumberInfo phoneNumberInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, params.get("iv"));
|
||||||
WxMaPhoneNumberInfo phoneNumberInfo = wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
|
|
||||||
String mobilePhone = phoneNumberInfo.getPhoneNumber();
|
String mobilePhone = phoneNumberInfo.getPhoneNumber();
|
||||||
|
|
||||||
/*UserAuth userAuth = null;
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|
||||||
if(StringUtil.isNotEmpty(unionId)) {
|
.eq(User::getIsDelete, GlobalConstant.NOT_DELETE)
|
||||||
userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
.eq(User::getMobile, mobilePhone)
|
||||||
.nested(wq -> wq
|
.last("limit 1"));
|
||||||
.eq("openid", openId).or()
|
Assert.notNull(user,"登录失败未在系统注册");
|
||||||
.eq("unionid", unionId)
|
Assert.isFalse(user.getIsDisable() == 1,"当前账号已被停用");
|
||||||
).last("limit 1"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
|
||||||
.nested(wq -> wq
|
|
||||||
.eq("openid", openId).or()
|
|
||||||
).last("limit 1"));
|
|
||||||
}*/
|
|
||||||
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
|
||||||
.nested(wq -> wq
|
|
||||||
.eq("openid", openId)
|
|
||||||
).last("limit 1"));
|
|
||||||
|
|
||||||
User user = null;
|
UserAuth userAuth = userAuthMapper.selectOne(new LambdaQueryWrapper<UserAuth>()
|
||||||
Integer userId;
|
.eq(UserAuth::getUserId,user.getId())
|
||||||
if (StringUtil.isNotNull(userAuth)) {
|
.last("limit 1"));
|
||||||
user = userMapper.selectOne(new QueryWrapper<User>()
|
|
||||||
.eq("id", userAuth.getUserId())
|
|
||||||
.eq("is_delete", 0)
|
|
||||||
.last("limit 1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtil.isNull(user)) {
|
//第一次登录小程序
|
||||||
Integer sn = this.randMakeSn();
|
if(userAuth == null){
|
||||||
User model = new User();
|
UserAuth auth = new UserAuth();
|
||||||
model.setSn(sn);
|
auth.setUserId(user.getId());
|
||||||
model.setType(channel);
|
auth.setOpenid(openId);
|
||||||
model.setAvatar(avatarUrl);
|
auth.setUnionid(unionId);
|
||||||
model.setNickname(nickName.equals("") ? "用户" + sn : nickName);
|
auth.setClient(client);
|
||||||
model.setUsername("u" + sn);
|
auth.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
model.setSex(Integer.parseInt(gender));
|
auth.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
model.setChannel(client);
|
userAuthMapper.insert(auth);
|
||||||
model.setLastLoginIp(IpUtil.getHostIp());
|
}else{
|
||||||
model.setLastLoginTime(System.currentTimeMillis() / 1000);
|
|
||||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
|
||||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
|
||||||
model.setMobile(mobilePhone);
|
|
||||||
userMapper.insert(model);
|
|
||||||
user = model;
|
|
||||||
userId = model.getId();
|
|
||||||
|
|
||||||
if (StringUtil.isNull(userAuth)) {
|
|
||||||
UserAuth auth = new UserAuth();
|
|
||||||
auth.setUserId(model.getId());
|
|
||||||
auth.setOpenid(openId);
|
|
||||||
auth.setUnionid(unionId);
|
|
||||||
auth.setClient(client);
|
|
||||||
auth.setCreateTime(System.currentTimeMillis() / 1000);
|
|
||||||
auth.setUpdateTime(System.currentTimeMillis() / 1000);
|
|
||||||
userAuthMapper.insert(auth);
|
|
||||||
} else {
|
|
||||||
userAuth.setUserId(model.getId());
|
|
||||||
userAuth.setUpdateTime(System.currentTimeMillis() / 1000);
|
|
||||||
userAuth.setClient(client);
|
|
||||||
userAuthMapper.updateById(userAuth);
|
|
||||||
}
|
|
||||||
|
|
||||||
//新用户注册领取当前正在派发的优惠券
|
|
||||||
couponService.registerUserGetCoupon(userId);
|
|
||||||
} else {
|
|
||||||
// 更新微信标识
|
// 更新微信标识
|
||||||
userId = user.getId();
|
|
||||||
if (StringUtil.isEmpty(userAuth.getUnionid()) && StringUtil.isNotEmpty(sessionResult.getUnionid())) {
|
if (StringUtil.isEmpty(userAuth.getUnionid()) && StringUtil.isNotEmpty(sessionResult.getUnionid())) {
|
||||||
userAuth.setUnionid(sessionResult.getUnionid());
|
userAuth.setUnionid(sessionResult.getUnionid());
|
||||||
userAuthMapper.updateById(userAuth);
|
userAuthMapper.updateById(userAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新用户信息
|
|
||||||
if (StringUtil.isEmpty(user.getAvatar()) && StringUtil.isNotEmpty(avatarUrl)) {
|
|
||||||
user.setAvatar(avatarUrl);
|
|
||||||
user.setNickname(nickName);
|
|
||||||
user.setSex(Integer.parseInt(gender));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新登录信息
|
// 更新登录信息
|
||||||
user.setLastLoginIp(IpUtil.getHostIp());
|
user.setLastLoginIp(IpUtil.getHostIp());
|
||||||
user.setLastLoginTime(System.currentTimeMillis() / 1000);
|
user.setLastLoginTime(System.currentTimeMillis() / 1000);
|
||||||
|
@ -242,17 +174,15 @@ public class LoginServiceImpl implements ILoginService {
|
||||||
userMapper.updateById(user);
|
userMapper.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置token
|
||||||
String token = ToolsUtil.makeToken();
|
String token = ToolsUtil.makeToken();
|
||||||
|
|
||||||
String tokenTime = systemConfigMapper.getTokenTime();
|
String tokenTime = systemConfigMapper.getTokenTime();
|
||||||
int seconds= Integer.parseInt(tokenTime)*60*60*24;
|
int seconds= Integer.parseInt(tokenTime) * 60 * 60 * 24;
|
||||||
RedisUtil.set(FrontConfig.frontendTokenKey + token, userId, seconds);
|
RedisUtil.set(FrontConfig.frontendTokenKey + token, user.getId(), seconds);
|
||||||
|
|
||||||
String mobile = StringUtil.isNull(user.getMobile()) ? "" : user.getMobile();
|
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
Map<String, Object> response = new LinkedHashMap<>();
|
||||||
response.put("id", userId);
|
response.put("id", user.getId());
|
||||||
response.put("isBindMobile", !mobile.equals(""));
|
response.put("isBindMobile", !user.getMobile().equals(""));
|
||||||
response.put("token", token);
|
response.put("token", token);
|
||||||
return response;
|
return response;
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
|
|
Loading…
Reference in New Issue