From fa9ebdc484f223ddfd992746bc699df0004f41fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 11:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/auth/ali/AliAuthService.java | 7 ++ .../com/ruoyi/common/auth/ali/AliConfig.java | 27 ++++---- .../ruoyi/common/auth/wx/WxAuthService.java | 12 ++++ .../core/domain/model/AliLoginBody.java | 25 ++++++++ .../common/core/domain/model/WxLoginBody.java | 3 +- .../web/service/SysLoginService.java | 59 +++++++++++++---- .../domain/dto/BillDailyAmountQuery.java | 23 +++++++ .../ruoyi/ss/payBill/domain/PayBillQuery.java | 10 +++ .../payBill/domain/vo/PayDailyAmountVO.java | 28 ++++++++ .../ss/payBill/mapper/PayBillMapper.java | 7 ++ .../ruoyi/ss/payBill/mapper/PayBillMapper.xml | 17 +++++ .../ss/payBill/service/PayBillService.java | 6 ++ .../service/impl/PayBillServiceImpl.java | 6 ++ .../ruoyi/ss/refund/domain/RefundQuery.java | 14 ++++ .../ss/refund/domain/enums/RefundStatus.java | 11 ++++ .../ruoyi/ss/refund/mapper/RefundMapper.java | 6 ++ .../ruoyi/ss/refund/mapper/RefundMapper.xml | 22 +++++++ .../ss/refund/service/RefundService.java | 7 ++ .../service/impl/RefundServiceImpl.java | 7 ++ .../ruoyi/ss/user/service/ISmUserService.java | 7 ++ .../user/service/impl/SmUserServiceImpl.java | 10 +++ .../web/controller/app/AppAuthController.java | 18 ++++++ .../controller/ss/SmDashboardController.java | 64 ++++++++++++++++--- .../src/main/resources/application-dev.yml | 3 +- 24 files changed, 363 insertions(+), 36 deletions(-) create mode 100644 smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/AliLoginBody.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/dto/BillDailyAmountQuery.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/vo/PayDailyAmountVO.java diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java index 6ac89b5d..7e331d64 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliAuthService.java @@ -1,5 +1,6 @@ package com.ruoyi.common.auth.ali; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -10,6 +11,12 @@ import org.springframework.stereotype.Service; @Service public class AliAuthService { + @Autowired + private AliConfig aliConfig; + public String getOpenId(String loginCode) { + // TODO + return null; + } } diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java index 7f3eaa35..35336408 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/ali/AliConfig.java @@ -16,17 +16,18 @@ import org.springframework.stereotype.Component; @Data public class AliConfig { -// @Value("${ali.appId}") -// private String appId; -// -// @Value("${ali.privateKey}") -// private String privateKey; -// -// @Bean -// public AlipayConfig alipayConfig() { -// AlipayConfig config = new AlipayConfig(); -// config.setAppId(appId); -// config.setPrivateKey(privateKey); -// return config; -// } + @Value("${ali.appId}") + private String appId; + + @Value("${ali.privateKey}") + private String privateKey; + + @Bean + public AlipayConfig alipayConfig() { + AlipayConfig config = new AlipayConfig(); + config.setAppId(appId); + config.setPrivateKey(privateKey); + + return config; + } } diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/wx/WxAuthService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/wx/WxAuthService.java index 2ac57c50..a9189582 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/wx/WxAuthService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/auth/wx/WxAuthService.java @@ -34,6 +34,18 @@ public class WxAuthService { return JSON.parseObject(body, WxMaJscode2SessionResult.class); } + public String getOpenId(String loginCode) { + if (loginCode == null) { + return null; + } + // 通过登录授权码获取到用户信息 + WxMaJscode2SessionResult wxMaJscode2SessionResult = this.wxJsCode2Session(loginCode); + if (wxMaJscode2SessionResult == null) { + return null; + } + return wxMaJscode2SessionResult.getOpenid(); + } + /** * 通过微信手机号授权码获取微信手机号 * @param mobileCode 微信手机号授权码 diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/AliLoginBody.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/AliLoginBody.java new file mode 100644 index 00000000..d7834f59 --- /dev/null +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/AliLoginBody.java @@ -0,0 +1,25 @@ +package com.ruoyi.common.core.domain.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * 微信登录body + * @author 辉 + * 2024/3/8 + */ +@Data +@ApiModel +public class AliLoginBody { + +// @ApiModelProperty("用于获取手机号的授权码,首次登录必填") +// private String mobileCode; + + @NotBlank(message = "登录授权码不允许为空") + @ApiModelProperty("my.getAuthCode获取的登录授权码,用于获取openId,必填") + private String loginCode; +} diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/WxLoginBody.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/WxLoginBody.java index bba95f35..57f061c7 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/WxLoginBody.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/model/WxLoginBody.java @@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; /** @@ -18,7 +19,7 @@ public class WxLoginBody { @ApiModelProperty("用于获取手机号的授权码,首次登录必填") private String mobileCode; - @NotNull(message = "登录授权码不允许为空") + @NotBlank(message = "登录授权码不允许为空") @ApiModelProperty("wx.login获取的登录授权码,用于获取openId,必填") private String loginCode; } diff --git a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 3970c519..2c03767d 100644 --- a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -5,6 +5,7 @@ import javax.annotation.Resource; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.common.auth.ali.AliAuthService; import com.ruoyi.common.core.domain.entity.SmUser; import com.ruoyi.common.core.domain.model.WxLoginBody; import com.ruoyi.common.enums.UserStatus; @@ -15,6 +16,7 @@ import com.ruoyi.common.auth.wx.AccessTokenUtil; import com.ruoyi.common.auth.wx.WxAuthService; import com.ruoyi.ss.account.domain.Account; import com.ruoyi.ss.store.service.StoreService; +import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.ISmUserService; import com.ruoyi.ss.account.service.AccountService; import com.ruoyi.ss.account.domain.enums.AccountType; @@ -91,6 +93,9 @@ public class SysLoginService @Autowired private ISysConfigService sysConfigService; + @Autowired + private AliAuthService aliAuthService; + /** * 登录验证 * @@ -263,7 +268,7 @@ public class SysLoginService public String wxLogin(WxLoginBody body) { // 通过openId查询用户 - String openId = this.getWxOpenId(body.getLoginCode()); + String openId = wxAuthService.getOpenId(body.getLoginCode()); ServiceUtil.assertion(openId == null, "获取微信openId失败"); SmUser user = smUserService.selectSmUserByWxOpenId(openId); @@ -307,7 +312,7 @@ public class SysLoginService * 注册微信用户 * @param openId 微信OpenId */ - private SmUser registerWx(String openId, String mobile) { + private SmUserVO registerWx(String openId, String mobile) { if (StringUtils.isBlank(openId)) { return null; } @@ -315,7 +320,7 @@ public class SysLoginService String name = "微信" + openId.substring(openId.length() - 4); // 添加用户 - SmUser newUser = new SmUser(); + SmUserVO newUser = new SmUserVO(); newUser.setUserName(name); newUser.setWxOpenId(openId); newUser.setPhonenumber(mobile); @@ -339,15 +344,47 @@ public class SysLoginService return this.appLogin(username, password); } - public String getWxOpenId(String loginCode) { - if (loginCode == null) { - return null; + public String aliLogin(WxLoginBody body) { + // 通过支付宝openId查询用户 + String openId = aliAuthService.getOpenId(body.getLoginCode()); + ServiceUtil.assertion(openId == null, "获取支付宝openId失败"); + + SmUserVO user = smUserService.selectSmUserByAliOpenId(openId); + + // 若用户不存在,则使用openId进行注册 + if (user == null || Objects.equals(user.getDelFlag(), UserStatus.DELETED.getCode())) { + // 获取手机号 + boolean loginWithPhone = sysConfigService.getBoolean(ConfigKey.ARRIVAL_DELAY); + String mobile = null; + if (loginWithPhone && StringUtils.hasText(body.getMobileCode())) { + mobile = wxAuthService.getWxPhoneNumber(body.getMobileCode()); + } + // 用户注册 + user = registerWx(openId, mobile); } - // 通过登录授权码获取到用户信息 - WxMaJscode2SessionResult wxMaJscode2SessionResult = wxAuthService.wxJsCode2Session(loginCode); - if (wxMaJscode2SessionResult == null) { - return null; + ServiceUtil.assertion(user == null, "用户不存在"); + + Authentication authentication = null; + try { + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getUserId(), Constants.CUSTOM_LOGIN_WX); + // 用户名和密码等信息保存在一个上下文中,只要是同一线程等会就能拿到用户名和密码,也就是能在loadUserByUsername(String username)方法中进行密码验证等 + AuthenticationContextHolder.setContext(authenticationToken); + // 把用户登录类型放在上下文中的details属性中,在UserDetailsServiceImpl.loadUserByUsername中获取 + authenticationToken.setDetails(Constants.USER_TYPE_WX); + // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername + authentication = authenticationManager.authenticate(authenticationToken); } - return wxMaJscode2SessionResult.getOpenid(); + catch (Exception e) { + if (e instanceof BadCredentialsException) { + throw new UserPasswordNotMatchException(); //抛出账号或者密码错误的异常 + } else { + throw new ServiceException(e.getMessage()); //抛出其他异常 + } + } finally { + AuthenticationContextHolder.clearContext(); + } + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); + return tokenService.createToken(loginUser); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/dto/BillDailyAmountQuery.java b/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/dto/BillDailyAmountQuery.java new file mode 100644 index 00000000..4fd6a120 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/dto/BillDailyAmountQuery.java @@ -0,0 +1,23 @@ +package com.ruoyi.dashboard.domain.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; + +/** + * @author wjh + * 2024/12/3 + */ +@Data +public class BillDailyAmountQuery { + + @ApiModelProperty("日期(起始)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate dateStart; + + @ApiModelProperty("日期(结束)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate dateEnd; +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillQuery.java index 7465cc56..1be13010 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/PayBillQuery.java @@ -2,7 +2,9 @@ package com.ruoyi.ss.payBill.domain; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; @@ -30,4 +32,12 @@ public class PayBillQuery extends PayBill{ @ApiModelProperty("支付订单ID列表") private List payIds; + + @ApiModelProperty("支付日期(开始)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate payDateStart; + + @ApiModelProperty("支付日期(结束)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate payDateEnd; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/vo/PayDailyAmountVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/vo/PayDailyAmountVO.java new file mode 100644 index 00000000..8ae4eff4 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/domain/vo/PayDailyAmountVO.java @@ -0,0 +1,28 @@ +package com.ruoyi.ss.payBill.domain.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDate; + +/** + * @author wjh + * 2024/12/2 + */ +@Data +public class PayDailyAmountVO { + + @ApiModelProperty("日期") + private LocalDate date; + + @ApiModelProperty("总金额") + private BigDecimal total; + + @ApiModelProperty("退款总金额") + private BigDecimal refund; + + @ApiModelProperty("总实收金额") + private BigDecimal received; + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.java index 4c0ba039..73fba248 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.java @@ -1,8 +1,10 @@ package com.ruoyi.ss.payBill.mapper; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.ss.payBill.domain.PayBill; import com.ruoyi.ss.payBill.domain.PayBillQuery; import com.ruoyi.ss.payBill.domain.PayBillVO; +import com.ruoyi.ss.payBill.domain.vo.PayDailyAmountVO; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; @@ -91,4 +93,9 @@ public interface PayBillMapper * 记录(转移)已退款金额 */ int recordRefundAmount(@Param("payId") Long payId, @Param("amount") BigDecimal amount); + + /** + * 按日查询支付单金额 + */ + List selectDailyAmount(@Param("query") PayBillQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml index 834acdf6..f194902b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/mapper/PayBillMapper.xml @@ -37,6 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and spb.status = #{query.status} and spb.create_time >= #{query.startCreateTime} and spb.create_time <= #{query.endCreateTime} + and date(spb.pay_time) >= date(#{query.payDateStart}) + and date(spb.pay_time) <= date(#{query.payDateEnd}) and spb.status in @@ -79,6 +81,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where spb.pay_no = #{payNo} + + + + + + insert into ss_pay_bill diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/PayBillService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/PayBillService.java index 979c31b5..155a1b80 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/PayBillService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/PayBillService.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.payBill.service; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.ss.payBill.domain.PayBill; import com.ruoyi.ss.payBill.domain.PayBillQuery; import com.ruoyi.ss.payBill.domain.PayBillVO; @@ -139,4 +140,9 @@ public interface PayBillService * 查询支付结果 */ PayResultVO getPayResult(String payNo); + + /** + * 按日查询支付金额 + */ + List selectDailyAmount(PayBillQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java index 0959cc26..0f5c4e1c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/payBill/service/impl/PayBillServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.payBill.service.impl; import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.enums.RedisLockKey; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.pay.syb.enums.SybTrxStatus; import com.ruoyi.common.pay.syb.service.SybPayService; @@ -495,6 +496,11 @@ public class PayBillServiceImpl implements PayBillService return getPayResult(bill); } + @Override + public List selectDailyAmount(PayBillQuery query) { + return payBillMapper.selectDailyAmount(query); + } + private boolean closeById(Long payId) { if (payId == null) { return false; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/RefundQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/RefundQuery.java index 3cbf5be8..c29fa495 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/RefundQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/RefundQuery.java @@ -2,6 +2,10 @@ package com.ruoyi.ss.refund.domain; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.util.List; /** * @author wjh @@ -13,4 +17,14 @@ public class RefundQuery extends Refund { @ApiModelProperty("订单收款人ID") private Long billMchId; + @ApiModelProperty("创建日期(起始)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate createDateStart; + + @ApiModelProperty("创建日期(结束)") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate createDateEnd; + + @ApiModelProperty("状态列表") + private List statusList; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/enums/RefundStatus.java b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/enums/RefundStatus.java index 8115ef13..dfa0a7d2 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/enums/RefundStatus.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/domain/enums/RefundStatus.java @@ -1,8 +1,11 @@ package com.ruoyi.ss.refund.domain.enums; +import com.ruoyi.common.utils.collection.CollectionUtils; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.List; + /** * @author wjh * 2024/7/9 @@ -18,4 +21,12 @@ public enum RefundStatus { private final String status; private final String desc; + public static List asList(RefundStatus ...statuses) { + return CollectionUtils.map( RefundStatus::getStatus, statuses); + } + + public static List successList() { + return asList(REFUND_SUCCESS, REFUNDING); + } + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.java index 5ea74393..3ca0fe2c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.refund.mapper; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.ss.refund.domain.Refund; import com.ruoyi.ss.refund.domain.RefundQuery; import com.ruoyi.ss.refund.domain.RefundVO; @@ -69,4 +70,9 @@ public interface RefundMapper * 条件更新 */ int updateByQuery(@Param("data") Refund data, @Param("query") RefundQuery query); + + /** + * 按日查询退款金额 + */ + List selectDailyAmount(@Param("query") RefundQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml index d4b3acbd..fa465da2 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml @@ -38,6 +38,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sr.user_name like concat('%', #{query.userName}, '%') and sr.bst_type = #{query.bstType} and sr.channel_id = #{query.channelId} + and date(sr.create_time) >= #{query.createDateStart} + and date(sr.create_time) <= #{query.createDateEnd} + + and sr.status in + + #{item} + + + + + + + insert into ss_refund diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/RefundService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/RefundService.java index a2226248..a414cb49 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/RefundService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/RefundService.java @@ -1,5 +1,7 @@ package com.ruoyi.ss.refund.service; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; +import com.ruoyi.dashboard.domain.dto.BillDailyAmountQuery; import com.ruoyi.ss.refund.domain.Refund; import com.ruoyi.ss.refund.domain.RefundQuery; import com.ruoyi.ss.refund.domain.RefundVO; @@ -93,4 +95,9 @@ public interface RefundService * 刷新退款结果 */ int refreshResult(RefundVO refund); + + /** + * 统计退款金额 + */ + List selectDailyAmount(RefundQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/impl/RefundServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/impl/RefundServiceImpl.java index 5983da8f..7241f94e 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/impl/RefundServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/service/impl/RefundServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.ss.refund.service.impl; +import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.pay.syb.enums.SybTrxStatus; import com.ruoyi.common.pay.syb.service.SybPayService; @@ -24,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.support.TransactionTemplate; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; @@ -259,4 +261,9 @@ public class RefundServiceImpl implements RefundService return 1; } + + @Override + public List selectDailyAmount(RefundQuery query) { + return refundMapper.selectDailyAmount(query); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java index ed3a1160..6c5a4372 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/ISmUserService.java @@ -261,4 +261,11 @@ public interface ISmUserService * @param info @return */ UserRealNameVO riskRealName(RiskInfoVO info); + + /** + * + * @param openId + * @return + */ + SmUserVO selectSmUserByAliOpenId(String openId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java index fdf7b02d..dd937189 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/SmUserServiceImpl.java @@ -627,6 +627,16 @@ public class SmUserServiceImpl implements ISmUserService return this.realName(dto); } + /** + * @param openId + * @return + */ + @Override + public SmUserVO selectSmUserByAliOpenId(String openId) { + // TODO + return null; + } + private int selectCountByPhone(String phone) { return smUserMapper.selectCountByPhone(phone); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAuthController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAuthController.java index ddf763d8..92f7381e 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAuthController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAuthController.java @@ -57,4 +57,22 @@ public class AppAuthController extends BaseController { ajax.put(Constants.TOKEN, token); return ajax; } + + /** + * 前台用户支付宝登录 + * @return token + */ + @Log(title = "支付宝授权登录", businessType = BusinessType.OTHER) + @ApiOperation("支付宝授权登录") + @PostMapping("/aliLogin") + public AjaxResult aliLogin(@RequestBody @Validated WxLoginBody body) + { + AjaxResult ajax = AjaxResult.success(); + // 生成令牌 + String token = loginService.aliLogin(body); + ajax.put(Constants.TOKEN, token); + return ajax; + } + + } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java index e0f075fa..6c1b67a3 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java @@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.ValidGroup; import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.dashboard.domain.dto.BillDailyAmountQuery; import com.ruoyi.dashboard.service.DashboardService; import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery; import com.ruoyi.ss.balancePeriod.service.ISmBalancePeriodService; @@ -13,6 +14,13 @@ import com.ruoyi.ss.bonus.domain.BonusQuery; import com.ruoyi.ss.bonus.service.BonusService; import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService; import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery; +import com.ruoyi.ss.payBill.domain.PayBillQuery; +import com.ruoyi.ss.payBill.domain.enums.PayBillStatus; +import com.ruoyi.ss.payBill.domain.vo.PayDailyAmountVO; +import com.ruoyi.ss.payBill.service.PayBillService; +import com.ruoyi.ss.refund.domain.RefundQuery; +import com.ruoyi.ss.refund.domain.enums.RefundStatus; +import com.ruoyi.ss.refund.service.RefundService; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; import com.ruoyi.ss.transactionBill.domain.vo.TransactionDailyAmountVO; import com.ruoyi.ss.transactionBill.service.TransactionBillService; @@ -22,12 +30,16 @@ import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo; import com.ruoyi.dashboard.domain.vo.BriefVo; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.validation.annotation.Validated; 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.math.BigDecimal; +import java.time.LocalDate; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -55,6 +67,12 @@ public class SmDashboardController extends BaseController { @Autowired private BonusService bonusService; + @Autowired + private PayBillService payBillService; + + @Autowired + private RefundService refundService; + /** * 舆情分析数据 */ @@ -136,20 +154,46 @@ public class SmDashboardController extends BaseController { } /** - * 按天统计订单金额数据 + * 按天统计支付订单金额数据 */ @GetMapping("/billDailyAmount") - public AjaxResult getBillDailyAmount(TransactionBillQuery query) { - List list = transactionBillService.selectDailyAmount(query); - if (query.getStartDate() != null && query.getEndDate() != null) { - CollectionUtils.fillVoids(list, TransactionDailyAmountVO::getDate, (date) -> { - TransactionDailyAmountVO vo = new TransactionDailyAmountVO(); + public AjaxResult getBillDailyAmount(BillDailyAmountQuery query) { + PayBillQuery payQuery = new PayBillQuery(); + payQuery.setPayDateStart(query.getDateStart()); + payQuery.setPayDateEnd(query.getDateEnd()); + payQuery.setStatusList(PayBillStatus.payedList()); + List payList = payBillService.selectDailyAmount(payQuery); + + RefundQuery refundQuery = new RefundQuery(); + refundQuery.setCreateDateStart(query.getDateStart()); + refundQuery.setCreateDateEnd(query.getDateEnd()); + refundQuery.setStatusList(RefundStatus.successList()); + List refundList = refundService.selectDailyAmount(refundQuery); + + List list = new ArrayList<>(); + if (query.getDateStart() != null && query.getDateEnd() != null) { + list = CollectionUtils.fillVoids(list, PayDailyAmountVO::getDate, (date) -> { + PayDailyAmountVO vo = new PayDailyAmountVO(); vo.setDate(date); - vo.setTotal(BigDecimal.ZERO); - vo.setRefund(BigDecimal.ZERO); - vo.setReceived(BigDecimal.ZERO); + + LocalDateDecimalVO pay = payList.stream().filter(item -> date.isEqual(item.getKey())).findFirst().orElse(null); + if (pay == null) { + vo.setTotal(BigDecimal.ZERO); + } else { + vo.setTotal(pay.getValue()); + } + + LocalDateDecimalVO refund = refundList.stream().filter(item -> date.isEqual(item.getKey())).findFirst().orElse(null); + if (refund == null) { + vo.setRefund(BigDecimal.ZERO); + } else { + vo.setRefund(refund.getValue()); + } + + vo.setReceived(vo.getTotal().subtract(vo.getRefund())); + return vo; - }, query.getStartDate(), query.getEndDate()); + }, query.getDateStart(), query.getDateEnd()); } return success(list); } diff --git a/smart-switch-web/src/main/resources/application-dev.yml b/smart-switch-web/src/main/resources/application-dev.yml index eebf34f4..013ef4d0 100644 --- a/smart-switch-web/src/main/resources/application-dev.yml +++ b/smart-switch-web/src/main/resources/application-dev.yml @@ -136,6 +136,7 @@ tm: liveness: returnUrl: http://192.168.2.40:3001/liveness +# 支付宝小程序 ali: appId: 2021004193649611 - privateSecret: 123 + privateKey: D:\project\smart-switch\alipayPublicKey_RSA2.txt