修改退款

This commit is contained in:
yuyang 2022-02-11 19:04:18 +08:00
parent d3d501bdad
commit 222181e656
16 changed files with 247 additions and 162 deletions

View File

@ -77,6 +77,11 @@ public class LoginUser implements Serializable
*/
private SysUser sysUser;
/**
* 是否已过期 0-未启用1-正常2-停用
*/
private Integer status;
public String getToken()
{
return token;
@ -205,4 +210,12 @@ public class LoginUser implements Serializable
public void setUserTypeUtil(String userTypeUtil) {
this.userTypeUtil = userTypeUtil;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -47,6 +47,7 @@ public class TokenService {
loginUser.setUserType(loginUser.getUserType());
loginUser.setOpenId(loginUser.getOpenId());
loginUser.setUserTypeUtil(loginUser.getUserTypeUtil());
loginUser.setStatus(loginUser.getStatus());
refreshToken(loginUser);
// 保存或更新用户token

View File

@ -129,7 +129,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc
//桩的统计该时段金额
List<Map<String, Object>> list =new ArrayList<>();
LoginUser logUser = logUserUtils.getLogUser(request);
String tenantId = logUser.getTenantId();
String tenantId = logUser.getSysUser().getTenantId();
if(userId !=1) {
Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(userId);
if(landUser !=null){

View File

@ -89,7 +89,7 @@
and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId})
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id=#{tenantId}
and cs.tenant_id=#{tenantId}
</if>
</select>

View File

@ -4,6 +4,7 @@ import com.xhpc.common.api.factory.RefundOrderFallbackFactory;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@ -17,6 +18,6 @@ import java.util.Map;
@FeignClient(contextId = "refundOrderService",value = ServiceNameConstants.XHPC_PAYMENT,fallbackFactory = RefundOrderFallbackFactory.class)
public interface RefundOrderService {
@PostMapping("/refund/order/orderCheckOut")
@GetMapping("/refund/order/orderCheckOut")
R sendNotice(@RequestParam(value = "amount") String amount,@RequestParam(value = "openid") String openid,@RequestParam(value = "source") Integer source,@RequestParam(value = "type") String type,@RequestParam(value = "userId") String userId,@RequestParam(value = "tenantId")String tenantId,@RequestParam(value = "remark")String remark);
}

View File

@ -3,6 +3,7 @@ package com.xhpc.order.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.RefundOrderService;
import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
@ -49,7 +50,8 @@ public class XhpcHistoryOrderController extends BaseController {
private IXhpcChargeOrderService chargeOrderService;
@Autowired
private UserTypeService userTypeService;
@Autowired
private RefundOrderService refundOrderService;
private static final Logger logger = LoggerFactory.getLogger(XhpcHistoryOrderController.class);
@ -79,10 +81,10 @@ public class XhpcHistoryOrderController extends BaseController {
*/
@GetMapping("/getListPage")
public TableDataInfo getListPage(String phone,String transactionNumber,@RequestParam("status")Integer status,String chargingStationName,Long operatorId,Integer source,String beginStartTime,String beginEndTime,@RequestParam("userId") Long userId, Integer type,
String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId)
String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId, Integer confirmResult)
{
List<Map<String, Object>> listPage = xhpcHistoryOrderService.getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
List<Map<String, Object>> listPage = xhpcHistoryOrderService.getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
return getDataTable(listPage);
}
@ -123,9 +125,10 @@ public class XhpcHistoryOrderController extends BaseController {
String vinCode,
String overStartTime,
String overEndTime,
Long personnelId) throws IOException {
Long personnelId,
Integer confirmResult) throws IOException {
xhpcHistoryOrderService.export(response, phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
xhpcHistoryOrderService.export(response, phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
}
@ -971,5 +974,4 @@ public class XhpcHistoryOrderController extends BaseController {
}
}
}
}

View File

@ -75,7 +75,7 @@ public interface XhpcHistoryOrderMapper {
* 历史订单记录PC
* @return
*/
List<Map<String,Object>> getListPage(@Param("phone")String phone,@Param("transactionNumber")String transactionNumber,@Param("status")Integer status,@Param("chargingStationName")String chargingStationName,@Param("operatorId")Long operatorId,@Param("source")Integer source,@Param("beginStartTime")String beginStartTime,@Param("beginEndTime")String beginEndTime,@Param("userId")Long userId,@Param("type")Integer type,@Param("number")Integer number,@Param("affiliationOrganization")String affiliationOrganization,@Param("evcsOrderNo")String evcsOrderNo,@Param("plateNum")String plateNum,@Param("internetId")Integer internetId,@Param("internetSerialNumber")String internetSerialNumber,@Param("terminalName")String terminalName,@Param("vinCode")String vinCode,@Param("overStartTime")String overStartTime,@Param("overEndTime")String overEndTime,@Param("personnelId")Long personnelId);
List<Map<String,Object>> getListPage(@Param("phone")String phone,@Param("transactionNumber")String transactionNumber,@Param("status")Integer status,@Param("chargingStationName")String chargingStationName,@Param("operatorId")Long operatorId,@Param("source")Integer source,@Param("beginStartTime")String beginStartTime,@Param("beginEndTime")String beginEndTime,@Param("userId")Long userId,@Param("type")Integer type,@Param("number")Integer number,@Param("affiliationOrganization")String affiliationOrganization,@Param("evcsOrderNo")String evcsOrderNo,@Param("plateNum")String plateNum,@Param("internetId")Integer internetId,@Param("internetSerialNumber")String internetSerialNumber,@Param("terminalName")String terminalName,@Param("vinCode")String vinCode,@Param("overStartTime")String overStartTime,@Param("overEndTime")String overEndTime,@Param("personnelId")Long personnelId,@Param("confirmResult")Integer confirmResult);
/**
* 获取费率时段

View File

@ -53,14 +53,14 @@ public interface IXhpcHistoryOrderService {
* 历史订单记录PC
* @return
*/
List<Map<String,Object>> getListPage(String phone,String transactionNumber,Integer status,String chargingStationName,Long operatorId,Integer source,String beginStartTime,String beginEndTime,Long userId,Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId);
List<Map<String,Object>> getListPage(String phone,String transactionNumber,Integer status,String chargingStationName,Long operatorId,Integer source,String beginStartTime,String beginEndTime,Long userId,Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult);
/**
* 历史订单记录导出PC
* @return
*/
void export(HttpServletResponse response, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId) throws IOException;
void export(HttpServletResponse response, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) throws IOException;
/**

View File

@ -203,7 +203,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
}
@Override
public List<Map<String, Object>> getListPage(String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId) {
public List<Map<String, Object>> getListPage(String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) {
Integer number = 0;
//电话和用户类型都不为null number =3
@ -229,26 +229,26 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
if ("01".equals(landUser.get("userType").toString())) {
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
//运营商看自己的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
} else {
//查询赋值的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 2, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logUserId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 2, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logUserId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
}
}
}
} else {
startPage();
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 0, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 0, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
}
return list;
}
@Override
public void export(HttpServletResponse response, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId) throws IOException {
public void export(HttpServletResponse response, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) throws IOException {
List<Map<String, Object>> list = getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId);
List<Map<String, Object>> list = getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("historyOrderId", "历史订单ID");

View File

@ -643,6 +643,12 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>");
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<balance2>>>>>>>>>>>>>>>>>"+balance2);
logger.info("<<<<<<<<<<<<<<<<openids>>>>>>>>>>>>>>>>>"+openids);
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getSource()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSource());
logger.info("<<<<<<<<<<<<<<<<refundTypes>>>>>>>>>>>>>>>>>"+refundTypes);
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getUserId()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getUserId().toString());
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getTenantId()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getTenantId());
R r = refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getCode());
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getData());

View File

@ -700,6 +700,9 @@
) ut on ut.history_order_id = ho.history_order_id
</if>
where ho.status =0 and ho.del_flag=0
<if test="confirmResult !=null">
and ho.confirm_Result =#{confirmResult}
</if>
<if test="type !=null">
and ho.type=#{type}
</if>

View File

@ -720,13 +720,13 @@ public class XhpcRefundAuditController extends BaseController {
}
/**
* 定时任务1分钟扫描一次退款订单金额小于100自动审核通过
* 定时任务20秒扫描一次退款订单金额小于100自动审核通过
*
*/
@Scheduled(cron = "0 */1 * * * ?")
@Scheduled(cron = "0/20 * * * * ? ")
@GetMapping("/moneyPage")
public void moneyPage(){
logger.info("++++++++++++每1分钟扫描一次退款订单金额小于100,自动审核通过++++++++++++++++");
logger.info("++++++++++++每1分钟扫描一次退款订单金额小于每20秒,自动审核通过++++++++++++++++");
try {
List<Long> list = iXhpcRefundOrderService.moneyPage();
if(list !=null && list.size()>0){

View File

@ -168,13 +168,13 @@ public class XhpcRefundOrderController extends BaseController {
/**
* 自动申请退款
*/
@NoRepeatSubmit
@PostMapping("/orderCheckOut")
@GetMapping("/orderCheckOut")
@ApiOperation(value = "订单自动退款")
public R orderCheckOut(@RequestParam(value = "amount") String amount,@RequestParam(value = "openid") String openid,@RequestParam(value = "source") Integer source,@RequestParam(value = "type") String type,@RequestParam(value = "userId") String userId,@RequestParam(value = "tenantId")String tenantId,@RequestParam(value = "remark")String remark) {
Integer userType = source;
if (UserTypeUtil.CUSTOMERS_TYPE.equals(userType)) {
logger.info("-------------");
logger.info("进入自动申请退款");
logger.info("-------------");
if (UserTypeUtil.CUSTOMERS_TYPE.equals(source)) {
return R.fail("大客户不支持退款");
}
if (StringUtils.isEmpty(amount)) {
@ -197,12 +197,12 @@ public class XhpcRefundOrderController extends BaseController {
}
//是否有实时数据
Long userid = Long.valueOf(userId);
int i = iXhpcRefundOrderService.countXhpcRealTimeOrder(userid, userType, tenantId);
int i = iXhpcRefundOrderService.countXhpcRealTimeOrder(userid, source, tenantId);
if (i > 0) {
return R.fail("车辆正在充电,不能退款");
}
// 是否有异常订单
int j = iXhpcRefundOrderService.countXhpcChargeOrder(userid, userType, tenantId);
int j = iXhpcRefundOrderService.countXhpcChargeOrder(userid, source, tenantId);
if (j > 0) {
return R.fail("你有异常订单未解决,请拨打客服电话进行解决");
}
@ -212,7 +212,7 @@ public class XhpcRefundOrderController extends BaseController {
logger.info("<<<<<<<<<<<<<<<<开始创建退款订单>>>>>>>>>>>>>>>>>");
AjaxResult ajaxResult = iXhpcRefundOrderService.addRefundOrder("" + userid, BigDecimal.valueOf(Double.parseDouble(amount)), type,
orderOutNumber, openid, remark, userType, tenantId);
orderOutNumber, openid, remark, source, tenantId);
if("200".equals(ajaxResult.get("code"))){
return R.ok();
}else{

View File

@ -22,6 +22,7 @@ import com.xhpc.user.service.IXhpcAppUserUserService;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;
import javax.crypto.Cipher;
@ -49,6 +50,9 @@ public class XhpcAppUserController extends BaseController {
@Autowired
private SettingConfigService settingConfigService;
@Autowired
private Environment environment;
/**
* C端用户详情
*/
@ -241,8 +245,8 @@ public class XhpcAppUserController extends BaseController {
* 支付宝授权
*/
@ApiOperation("支付宝授权")
@PostMapping("/alipayEmpower")
public AjaxResult alipayEmpower(@RequestParam String code,String tenantId) throws Exception {
@PostMapping("/alipayEmpowerYu")
public AjaxResult alipayEmpowerYu(@RequestParam String code,String tenantId) throws Exception {
if("".equals(tenantId) || null==tenantId){
tenantId="000000";
}
@ -288,6 +292,51 @@ public class XhpcAppUserController extends BaseController {
return AjaxResult.error("获取失败");
}
/**
* 支付宝授权
*/
@ApiOperation("支付宝授权")
@PostMapping("/alipayEmpower")
public AjaxResult alipayEmpower(@RequestParam String code) throws Exception {
/** 初始化 **/
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
/** 支付宝网关 **/
certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");
/** 应用id如何获取请参考https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/
certAlipayRequest.setAppId(environment.getProperty("ALIPAYAPPID"));
/** 应用私钥, 如何获取请参考https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/
certAlipayRequest.setPrivateKey(environment.getProperty("ALIPAYPRIVATEKEY"));
/** 应用公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setCertPath(environment.getProperty("CERTPATH"));
/** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setAlipayPublicCertPath(environment.getProperty("PUBLICCERTPATH"));
/** 支付宝根证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setRootCertPath(environment.getProperty("ROOTCRETPATH"));
/** 设置签名类型 **/
certAlipayRequest.setSignType("RSA2");
/** 设置请求格式固定值json **/
certAlipayRequest.setFormat("json");
/** 设置编码格式 **/
certAlipayRequest.setCharset("UTF-8");
AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest);
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setGrantType("authorization_code");
// auth_code 前端授权后得到的授权码
request.setCode(code);
AlipaySystemOauthTokenResponse response = alipayClient.certificateExecute(request);
//服务端请求返回RSA2密钥和公钥证书请求方式不同如当面付
// RSA2密钥请求response = alipayClient.execute(request);
// 公钥证书请求请求response = alipayClient.certificateExecute(request);
if (response.isSuccess()) {
System.out.println("调用成功");
} else {
System.out.println("调用失败");
}
return AjaxResult.success(response);
}
/**
* 注销账号
*/

View File

@ -225,17 +225,21 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
return R.fail(HttpStatus.ERROR_STATUS, "用户名不在指定范围");
}
//判断账号
String sub = username.substring(0, 2);
if (UserTypeUtil.COMMUNIT.equals(sub) || UserTypeUtil.CUSTOMERS.equals(sub)){
R user = userTypeService.getUser(username, null, null, null,tenantId);
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
R lognUser = userTypeService.getUser(username, null, null, null,tenantId);
if(lognUser !=null && lognUser.getData() !=null){
String sub = username.substring(0, 2);
if (UserTypeUtil.COMMUNIT.equals(sub) || UserTypeUtil.CUSTOMERS.equals(sub)){
Map<String, Object> map = (Map<String, Object>)lognUser.getData();
LoginUser userInfo = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
long appUserId = Long.parseLong(map.get("appUserId").toString());
sysUser.setUserId(appUserId);
if(map.get("tenantStatus") !=null && "2".equals(map.get("tenantStatus").toString())){
userInfo.setStatus(2);
}else{
userInfo.setStatus(1);
}
userInfo.setSysUser(sysUser);
userInfo.setUsername(username);
userInfo.setOpenId(openid);
@ -260,74 +264,74 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
xhpcAppUserMapper.updateCustomersPersonnel(appUserId,null,openid,null,UserConstants.LOGIN);
}
}
//添加最后一次登录数据
//添加最后一次登录数据
xhpcAppUserMapper.addUserLoginTime(appUserId,username,userInfo.getUserType(),openid,Integer.valueOf(type),null,tenantId,new Date());
redisService.deleteObject("pvToken:" + username);
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
}else{
return R.fail(HttpStatus.DATA_ERROR, "账号不正确,请重新输入");
}
}
// 查询用户信息
XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username);
if (StringUtils.isNull(user)) {
//注册
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setPhone(username);
String password = username.substring(username.length() - 6);
xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password));
xhpcAppUser.setCreateTime(new Date());
// 查询用户信息
XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username);
if (StringUtils.isNull(user)) {
//注册
XhpcAppUser xhpcAppUser = new XhpcAppUser();
xhpcAppUser.setPhone(username);
String password = username.substring(username.length() - 6);
xhpcAppUser.setPassword(SecurityUtils.encryptPassword(password));
xhpcAppUser.setCreateTime(new Date());
if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
xhpcAppUser.setWeixinOpenId(openid);
xhpcAppUser.setWeixinLogin(1);
} else {
xhpcAppUser.setAlipayOpenId(openid);
xhpcAppUser.setAlipayLogin(1);
}
xhpcAppUser.setTenantId(tenantId);
xhpcAppUserMapper.insert(xhpcAppUser);
user = xhpcAppUserMapper.getAppUserByPhone(username);
// 获取登录token
//return R.ok(tokenService.createToken(userInfo));
//return R.fail(HttpStatus.DATA_ERROR, "登录用户:" + username + " 不存在");
}
LoginUser userInfo = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserName(user.getPhone());
sysUser.setUserId(user.getAppUserId());
userInfo.setSysUser(sysUser);
userInfo.setUserType(UserTypeUtil.USER_TYPE);
userInfo.setUsername(username);
userInfo.setOpenId(openid);
userInfo.setUserid(user.getAppUserId());
userInfo.setTenantId(tenantId);
userInfo.setUserTypeUtil(UserTypeUtil.USER);
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + username + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + username + " 已停用");
}
if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
xhpcAppUser.setWeixinOpenId(openid);
xhpcAppUser.setWeixinLogin(1);
if (StringUtils.isEmpty(user.getWeixinOpenId())) {
user.setWeixinOpenId(openid);
}
user.setWeixinLogin(UserConstants.LOGIN);
} else {
xhpcAppUser.setAlipayOpenId(openid);
xhpcAppUser.setAlipayLogin(1);
if (StringUtils.isEmpty(user.getAlipayOpenId())) {
user.setAlipayOpenId(openid);
}
user.setAlipayLogin(UserConstants.LOGIN);
}
xhpcAppUser.setTenantId(tenantId);
xhpcAppUserMapper.insert(xhpcAppUser);
user = xhpcAppUserMapper.getAppUserByPhone(username);
// 获取登录token
//return R.ok(tokenService.createToken(userInfo));
//return R.fail(HttpStatus.DATA_ERROR, "登录用户:" + username + " 不存在");
}
LoginUser userInfo = new LoginUser();
SysUser sysUser = new SysUser();
sysUser.setUserName(user.getPhone());
sysUser.setUserId(user.getAppUserId());
userInfo.setSysUser(sysUser);
userInfo.setUserType(UserTypeUtil.USER_TYPE);
userInfo.setUsername(username);
userInfo.setOpenId(openid);
userInfo.setUserid(user.getAppUserId());
userInfo.setTenantId(tenantId);
userInfo.setUserTypeUtil(UserTypeUtil.USER);
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + username + " 已被删除");
}
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
return R.fail(HttpStatus.DATA_ERROR, "对不起,您的账号:" + username + " 已停用");
}
if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
if (StringUtils.isEmpty(user.getWeixinOpenId())) {
user.setWeixinOpenId(openid);
}
user.setWeixinLogin(UserConstants.LOGIN);
} else {
if (StringUtils.isEmpty(user.getAlipayOpenId())) {
user.setAlipayOpenId(openid);
}
user.setAlipayLogin(UserConstants.LOGIN);
}
xhpcAppUserMapper.update(user);
redisService.deleteObject("pvToken:" + user.getPhone());
xhpcAppUserMapper.update(user);
redisService.deleteObject("pvToken:" + user.getPhone());
//添加最后一次登录数据
xhpcAppUserMapper.addUserLoginTime(user.getAppUserId(),username,userInfo.getUserType(),openid,Integer.valueOf(type),UserConstants.LOGIN,tenantId,new Date());
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
//添加最后一次登录数据
xhpcAppUserMapper.addUserLoginTime(user.getAppUserId(),username,userInfo.getUserType(),openid,Integer.valueOf(type),UserConstants.LOGIN,tenantId,new Date());
// 获取登录token
return R.ok(tokenService.createToken(userInfo));
}else{
return R.fail(HttpStatus.DATA_ERROR, "服务器繁忙,请稍后再试");
}
}
/**

View File

@ -8,108 +8,114 @@
<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 socUser,
balance as balance,
avatar as avatar,
status,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
del_flag delFlag,
concat(0) as userType,
concat("C") as userTypeName,
tenant_id tenantId,
soc_protect socProtect,
create_time as createTime
from xhpc_app_user
where del_flag=0
xau.app_user_id as appUserId,
xau.phone as phone,
xau.is_refund_application as isRefundApplication,
xau.is_refund as isRefund,
xau.soc as socUser,
xau.balance as balance,
xau.avatar as avatar,
xau.status,
xau.weixin_open_id as weixinOpenId,
xau.alipay_open_id as alipayOpenId,
xau.weixin_login as weixinLogin,
xau.alipay_login as alipayLogin,
xau.del_flag delFlag,
concat(0) as userType,
concat("C") as userTypeName,
xau.tenant_id tenantId,
xau.soc_protect socProtect,
ten.status tenantStatus,
xau.create_time as createTime
from xhpc_app_user xau
left join xhpc_tenant ten on ten.tenant_id = xau.tenant_id and ten.is_deleted =0
where xau.del_flag=0
<if test="phone !=null and phone !=''">
and phone =#{phone}
and xau.phone =#{phone}
</if>
<if test="userId !=null">
and app_user_id =#{userId}
and xau.app_user_id =#{userId}
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id =#{tenantId}
and xau.tenant_id =#{tenantId}
</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 socUser,
surplus_money as balance,
avatar as avatar,
status,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
tenant_id tenantId,
del_flag delFlag,
xcp.community_personnel_id as appUserId,
xcp.account as account,
xcp.phone as phone,
xcp.is_refund_application as isRefundApplication,
xcp.is_refund as isRefund,
xcp.soc as socUser,
xcp.surplus_money as balance,
xcp.avatar as avatar,
xcp.status,
xcp.weixin_open_id as weixinOpenId,
xcp.alipay_open_id as alipayOpenId,
xcp.weixin_login as weixinLogin,
xcp.alipay_login as alipayLogin,
xcp.tenant_id tenantId,
xcp.del_flag delFlag,
concat(2) as userType,
soc_protect socProtect,
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("ST") as userTypeName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
create_time as createTime
from xhpc_community_personnel
where del_flag=0
xcp.create_time as createTime
from xhpc_community_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
and account =#{phone}
and xcp.account =#{phone}
</if>
<if test="userId !=null">
and community_personnel_id =#{userId}
and xcp.community_personnel_id =#{userId}
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id =#{tenantId}
and xcp.tenant_id =#{tenantId}
</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 socUser,
surplus_money as balance,
avatar as avatar,
status,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
del_flag delFlag,
tenant_id tenantId,
xcp.customers_personnel_id as appUserId,
xcp.account as account,
xcp.phone as phone,
xcp.is_refund_application as isRefundApplication,
xcp.is_refund as isRefund,
xcp.soc as socUser,
xcp.surplus_money as balance,
xcp.avatar as avatar,
xcp.status,
xcp.weixin_open_id as weixinOpenId,
xcp.alipay_open_id as alipayOpenId,
xcp.weixin_login as weixinLogin,
xcp.alipay_login as alipayLogin,
xcp.del_flag delFlag,
xcp.tenant_id tenantId,
concat(3) as userType,
soc_protect socProtect,
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("BE") as userTypeName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
create_time as createTime
from xhpc_customers_personnel
where del_flag=0
xcp.create_time as createTime
from xhpc_customers_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
and account =#{phone}
and xcp.account =#{phone}
</if>
<if test="userId !=null">
and customers_personnel_id =#{userId}
and xcp.customers_personnel_id =#{userId}
</if>
<if test="tenantId !=null and tenantId !=''">
and tenant_id =#{tenantId}
and xcp.tenant_id =#{tenantId}
</if>
</select>
</mapper>