发送短信增加社区、B端大客户账号逻辑
This commit is contained in:
parent
b111ca56df
commit
b30fddd5f0
18
sql/v2.1.sql
18
sql/v2.1.sql
@ -45,3 +45,21 @@ CREATE TABLE `xhpc_tradebill_internet_check_record`
|
||||
ROW_FORMAT = DYNAMIC
|
||||
AUTO_INCREMENT = 34670
|
||||
;
|
||||
|
||||
ALTER TABLE `xhpc_app_user` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `is_refund`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`;
|
||||
ALTER TABLE `xhpc_community_personnel` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `is_refund_application` int(10) NULL DEFAULT 0 COMMENT '是否有退款订单审核(0无 1有)' AFTER `remark`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `soc` int(10) NULL DEFAULT NULL COMMENT '用户设置的SOC' AFTER `is_refund_application`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像地址' AFTER `soc`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `weixin_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `avatar`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `alipay_open_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL AFTER `weixin_open_id`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `weixin_login` int(10) NULL DEFAULT 0 COMMENT '微信是否登录(0未登录 1已登录)' AFTER `alipay_open_id`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `alipay_login` int(10) NULL DEFAULT 0 COMMENT '支付宝是否登录(0未登录 1已登录)' AFTER `weixin_login`;
|
||||
ALTER TABLE `xhpc_customers_personnel` ADD COLUMN `is_refund` int(4) NULL DEFAULT 0 COMMENT '是否退款 0 不退款 1 退款' AFTER `soc`;
|
||||
@ -0,0 +1,24 @@
|
||||
package com.xhpc.common.api;
|
||||
|
||||
import com.xhpc.common.api.factory.UserTypeFallbackFactory;
|
||||
import com.xhpc.common.core.constant.ServiceNameConstants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 10:23
|
||||
*/
|
||||
@FeignClient(contextId ="userTypeService",value = ServiceNameConstants.XHPC_USER, fallbackFactory = UserTypeFallbackFactory.class)
|
||||
public interface UserTypeService {
|
||||
|
||||
/**
|
||||
* 根据手机号(账号),用户id和类型 获取用户信息
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/common/getUser")
|
||||
R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType);
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.xhpc.common.api.factory;
|
||||
|
||||
import com.xhpc.common.api.UserTypeService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 10:27
|
||||
*/
|
||||
@Component
|
||||
public class UserTypeFallbackFactory implements FallbackFactory<UserTypeService> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserTypeFallbackFactory.class);
|
||||
@Override
|
||||
public UserTypeService create(Throwable cause) {
|
||||
logger.error("用户服务调用失败:{} //fallback", cause.getMessage());
|
||||
return new UserTypeService() {
|
||||
@Override
|
||||
public R getUser(String phone, Long userId, Integer userType) {
|
||||
return R.fail("用户信息获取失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.xhpc.common.util;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 16:48
|
||||
*/
|
||||
public class UserTypeUtil {
|
||||
//c端用户
|
||||
public static final String USER = "C";
|
||||
//流量端用户
|
||||
public static final String INTERNET = "L";
|
||||
//社区端用户
|
||||
public static final String COMMUNIT = "ST";
|
||||
//B端大客户
|
||||
public static final String CUSTOMERS = "BE";
|
||||
|
||||
//c端用户
|
||||
public static final Integer USER_TYPE = 0;
|
||||
//流量端用户
|
||||
public static final Integer INTERNET_TYPE = 1;
|
||||
//社区端用户
|
||||
public static final Integer COMMUNIT_TYPE = 2;
|
||||
//B端大客户
|
||||
public static final Integer CUSTOMERS_TYPE = 3;
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.xhpc.general;
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
||||
@ -6,12 +6,14 @@ import com.xhpc.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.xhpc.general.mapper")
|
||||
@EnableScheduling
|
||||
public class XhpcGeneralApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -1,8 +1,11 @@
|
||||
package com.xhpc.general.controller;
|
||||
|
||||
import com.xhpc.common.api.UserTypeService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.general.service.IXhpcSmsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -20,7 +23,8 @@ public class XhpcSmsController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcSmsService xhpcSmsService;
|
||||
|
||||
@Autowired
|
||||
private UserTypeService userTypeService;
|
||||
/**
|
||||
* 注册获取手机号验证码
|
||||
*/
|
||||
@ -33,7 +37,20 @@ public class XhpcSmsController extends BaseController {
|
||||
signatureName = "小华充电";
|
||||
templateId = "SMS_226786362";
|
||||
|
||||
return xhpcSmsService.getLogonPhoneCode(phone, signatureName, templateId);
|
||||
if(phone !=null || "".equals(phone)){
|
||||
if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
|
||||
//C端用户
|
||||
return xhpcSmsService.getLogonPhoneCode(phone, signatureName, templateId);
|
||||
}else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) || UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
|
||||
R user = userTypeService.getUser(phone, null, null);
|
||||
if(user !=null && user.getData() !=null){
|
||||
Map<String, Object> map = (Map<String, Object>)user.getData();
|
||||
return xhpcSmsService.getLogonPhoneCode(map.get("phone").toString(), signatureName, templateId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("1003", "请输入正确的手机号或账号");
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getList")
|
||||
@ -83,4 +100,9 @@ public class XhpcSmsController extends BaseController {
|
||||
Object messageInfo = xhpcSmsService.getAliyunShortMessageInfo();
|
||||
return AjaxResult.success(messageInfo);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String phone="ST18123374";
|
||||
System.out.println(phone.substring(0,2));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
package com.xhpc.user.controller;
|
||||
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.user.dto.MechanismDto;
|
||||
import com.xhpc.user.service.IXhpcCommonService;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公共的内
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 10:34
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/common")
|
||||
public class XhpcCommonController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcCommonService xhpcCommonService;
|
||||
|
||||
/**
|
||||
* 根据手机号(账号),用户id和类型 获取用户信息
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getUser")
|
||||
public AjaxResult getMechanism(String phone,Long userId,Integer userType) {
|
||||
|
||||
if(phone !=null || "".equals(phone)){
|
||||
if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
|
||||
//C端用户
|
||||
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,0));
|
||||
}else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2))){
|
||||
//社区用户
|
||||
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,2));
|
||||
}else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
|
||||
//大客户用户
|
||||
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,3));
|
||||
}
|
||||
}else{
|
||||
return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType));
|
||||
}
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.xhpc.user.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -35,4 +36,37 @@ public class XhpcCommunityPersonnel extends BaseEntity {
|
||||
private Integer status;
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 是否有退款订单审核(0无 1有)
|
||||
*/
|
||||
private Integer isRefundApplication;
|
||||
|
||||
private Integer soc;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* weixin_open_id
|
||||
*/
|
||||
@Length(max = 50, message = "openId不能超过50位")
|
||||
private String weixinOpenId;
|
||||
|
||||
/**
|
||||
* alipay_open_id
|
||||
*/
|
||||
@Length(max = 50, message = "openId不能超过50位")
|
||||
private String alipayOpenId;
|
||||
|
||||
/**
|
||||
* 微信是否登录(0未登录 1已登录)
|
||||
*/
|
||||
private Integer weixinLogin;
|
||||
|
||||
/**
|
||||
* 支付宝是否登录(0未登录 1已登录)
|
||||
*/
|
||||
private Integer alipayLogin;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xhpc.user.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -36,4 +37,36 @@ public class XhpcCustomersPersonnel extends BaseEntity {
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 是否有退款订单审核(0无 1有)
|
||||
*/
|
||||
private Integer isRefundApplication;
|
||||
|
||||
private Integer soc;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* weixin_open_id
|
||||
*/
|
||||
@Length(max = 50, message = "openId不能超过50位")
|
||||
private String weixinOpenId;
|
||||
|
||||
/**
|
||||
* alipay_open_id
|
||||
*/
|
||||
@Length(max = 50, message = "openId不能超过50位")
|
||||
private String alipayOpenId;
|
||||
|
||||
/**
|
||||
* 微信是否登录(0未登录 1已登录)
|
||||
*/
|
||||
private Integer weixinLogin;
|
||||
|
||||
/**
|
||||
* 支付宝是否登录(0未登录 1已登录)
|
||||
*/
|
||||
private Integer alipayLogin;
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.xhpc.user.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 11:12
|
||||
*/
|
||||
public interface XhpcCommonMapper {
|
||||
|
||||
|
||||
/**
|
||||
* C端用户信息
|
||||
*/
|
||||
Map<String, Object> getAppUser(@Param("phone") String phone,@Param("userId")Long userId);
|
||||
|
||||
/**
|
||||
* 社区端用户信息
|
||||
*/
|
||||
Map<String, Object> getCommunityUser(@Param("phone") String phone,@Param("userId")Long userId);
|
||||
|
||||
/**
|
||||
* B端用户信息
|
||||
*/
|
||||
Map<String, Object> getCustomersUser(@Param("phone") String phone,@Param("userId")Long userId);
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.xhpc.user.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 11:10
|
||||
*/
|
||||
public interface IXhpcCommonService {
|
||||
|
||||
/**
|
||||
* 根据用户手机号获取用户信息
|
||||
*/
|
||||
Map<String, Object> getLandUser(String phone,Long userId,Integer type);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.xhpc.user.service.impl;
|
||||
|
||||
import com.xhpc.user.mapper.XhpcCommonMapper;
|
||||
import com.xhpc.user.service.IXhpcCommonService;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2021/12/29 11:11
|
||||
*/
|
||||
@Service
|
||||
public class XhpcCommonServiceImpl implements IXhpcCommonService {
|
||||
|
||||
@Autowired
|
||||
private XhpcCommonMapper xhpcCommonMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getLandUser(String phone,Long userId, Integer type) {
|
||||
if(type==0){
|
||||
return xhpcCommonMapper.getAppUser(phone,userId);
|
||||
}else if(type==2){
|
||||
return xhpcCommonMapper.getCommunityUser(phone,userId);
|
||||
}else if(type==3){
|
||||
return xhpcCommonMapper.getCustomersUser(phone,userId);
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
<?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.xhpc.user.mapper.XhpcCommonMapper">
|
||||
|
||||
|
||||
<select id="getAppUser" resultType="map">
|
||||
select
|
||||
app_user_id as appUserId,
|
||||
phone as phone,
|
||||
is_refund_application as isRefundApplication,
|
||||
is_refund as isRefund,
|
||||
soc as soc,
|
||||
balance as balance,
|
||||
avatar as avatar,
|
||||
status,
|
||||
weixin_open_id as weixinlogin,
|
||||
alipay_open_id as alipayLogin,
|
||||
weixin_login as weixinOpenId,
|
||||
alipay_login as alipayLogin,
|
||||
del_flag delFlag,
|
||||
concat(0) as userType,
|
||||
create_time as createTime
|
||||
from xhpc_app_user
|
||||
where del_flag=0
|
||||
<if test="phone !=null and phone !=''">
|
||||
and phone =#{phone}
|
||||
</if>
|
||||
<if test="userId !=null">
|
||||
and app_user_id =#{userId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCommunityUser" resultType="map">
|
||||
select
|
||||
community_personnel_id as appUserId,
|
||||
account as account,
|
||||
phone as phone,
|
||||
is_refund_application as isRefundApplication,
|
||||
is_refund as isRefund,
|
||||
soc as soc,
|
||||
surplus_money as balance,
|
||||
avatar as avatar,
|
||||
status,
|
||||
weixin_open_id as weixinlogin,
|
||||
alipay_open_id as alipayLogin,
|
||||
weixin_login as weixinOpenId,
|
||||
alipay_login as alipayLogin,
|
||||
del_flag delFlag,
|
||||
concat(2) as userType,
|
||||
create_time as createTime
|
||||
from xhpc_community_personnel
|
||||
where del_flag=0
|
||||
<if test="phone !=null and phone !=''">
|
||||
and account =#{phone}
|
||||
</if>
|
||||
<if test="userId !=null">
|
||||
and community_personnel_id =#{userId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCustomersUser" resultType="map">
|
||||
select
|
||||
customers_personnel_id as appUserId,
|
||||
account as account,
|
||||
phone as phone,
|
||||
is_refund_application as isRefundApplication,
|
||||
is_refund as isRefund,
|
||||
soc as soc,
|
||||
surplus_money as balance,
|
||||
avatar as avatar,
|
||||
status,
|
||||
weixin_open_id as weixinlogin,
|
||||
alipay_open_id as alipayLogin,
|
||||
weixin_login as weixinOpenId,
|
||||
alipay_login as alipayLogin,
|
||||
del_flag delFlag,
|
||||
concat(3) as userType,
|
||||
create_time as createTime
|
||||
from xhpc_customers_personnel
|
||||
where del_flag=0
|
||||
<if test="phone !=null and phone !=''">
|
||||
and account =#{phone}
|
||||
</if>
|
||||
<if test="userId !=null">
|
||||
and customers_personnel_id =#{userId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user