diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java index 49878ee4..7298a0ed 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/xhpc/system/api/model/LoginUser.java @@ -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; + } } diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java index 3bba1fe5..d3134b9c 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/xhpc/common/security/service/TokenService.java @@ -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 diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index c42e327d..170a77b6 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -129,7 +129,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc //桩的统计、该时段金额 List> list =new ArrayList<>(); LoginUser logUser = logUserUtils.getLogUser(request); - String tenantId = logUser.getTenantId(); + String tenantId = logUser.getSysUser().getTenantId(); if(userId !=1) { Map landUser = xhpcChargingStationMapper.getLandUser(userId); if(landUser !=null){ diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 0d529603..5b0749d2 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -89,7 +89,7 @@ and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{operatorId}) - and tenant_id=#{tenantId} + and cs.tenant_id=#{tenantId} diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/RefundOrderService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/RefundOrderService.java index f92201a7..4cf37ebc 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/RefundOrderService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/RefundOrderService.java @@ -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); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index 51c91e69..ffb4c08a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -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> listPage = xhpcHistoryOrderService.getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId); + List> 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 { } } } - } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index ed09318c..9f138fa1 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -75,7 +75,7 @@ public interface XhpcHistoryOrderMapper { * 历史订单记录(PC) * @return */ - List> 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> 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); /** * 获取费率时段 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index 7d702184..f43c8742 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -53,14 +53,14 @@ public interface IXhpcHistoryOrderService { * 历史订单记录(PC) * @return */ - List> 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> 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; /** diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index bfbe5cde..47e5fdfa 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -203,7 +203,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis } @Override - public List> 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> 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> list = getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId); + List> 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"); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 07a985bb..36096618 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -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); + logger.info("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"+openids); + logger.info("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSource()); + logger.info("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"+refundTypes); + logger.info("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getUserId().toString()); + logger.info("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getTenantId()); R r = refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款"); logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getCode()); logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getData()); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index b978617b..4b69630b 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -700,6 +700,9 @@ ) ut on ut.history_order_id = ho.history_order_id where ho.status =0 and ho.del_flag=0 + + and ho.confirm_Result =#{confirmResult} + and ho.type=#{type} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index 3614ed82..d11205eb 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -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 list = iXhpcRefundOrderService.moneyPage(); if(list !=null && list.size()>0){ diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java index c3df224e..0a334b97 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundOrderController.java @@ -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{ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index 23e3fc39..a1095c55 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -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); + } + + /** * 注销账号 */ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index 88051eb5..6ef1341e 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -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 map = (Map)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 map = (Map)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, "服务器繁忙,请稍后再试"); + } } /** diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index 3edacf9c..ea508282 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -8,108 +8,114 @@