Просмотр исходного кода

1.删除无用代码
2.修改bug

skyline 2 лет назад
Родитель
Сommit
061a9d7617

+ 7 - 6
admin-web/src/views/admin/refund/index.vue

@@ -179,14 +179,15 @@ const state = reactive({
       {label: '商户退款单号', prop: 'outRefundNo', width: 150, resizable: true,fixed:'left'},
       {label: '商户退款单号', prop: 'outRefundNo', width: 150, resizable: true,fixed:'left'},
       {label: '商户订单号', prop: 'outTradeNo', width: 150, resizable: true,fixed:'left'},
       {label: '商户订单号', prop: 'outTradeNo', width: 150, resizable: true,fixed:'left'},
       {label: '手机号', prop: 'mobilePhone', width: 150, resizable: true,fixed:'left'},
       {label: '手机号', prop: 'mobilePhone', width: 150, resizable: true,fixed:'left'},
-      {label: '退款渠道', prop: 'channel', width: 150,resizable: true},
-      {label: '退款创建(受理)时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 180},
+      // {label: '退款渠道', prop: 'channel', width: 150,resizable: true},
+      {label: '申请时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 180},
       {label: '退款状态', prop: 'status', resizable: true, width: 120},
       {label: '退款状态', prop: 'status', resizable: true, width: 120},
       {label: '退款成功时间', prop: 'successTime', sortable: 'custom', resizable: true, width: 160},
       {label: '退款成功时间', prop: 'successTime', sortable: 'custom', resizable: true, width: 160},
-      {label: '订单金额', prop: 'total', resizable: true, width: 130},
-      {label: '退款金额', prop: 'refund', resizable: true, width: 130},
-      {label: '用户支付币种', prop: 'currency', resizable: true, width: 120},
-      {label: '资金账户', prop: 'fundsAccount', resizable: true, width: 120},
+      {label: '原充值订单金额', prop: 'total', resizable: true, width: 130},
+      {label: '退款申请金额', prop: 'refund', resizable: true, width: 130},
+      {label: '优惠金额', prop: 'discountAmount', resizable: true, width: 130},
+      // {label: '用户支付币种', prop: 'currency', resizable: true, width: 120},
+      // {label: '资金账户', prop: 'fundsAccount', resizable: true, width: 120},
       {label: '退款原因', prop: 'reason', resizable: true, width: 120},
       {label: '退款原因', prop: 'reason', resizable: true, width: 120},
       {label: '微信支付退款单号', prop: 'refundId', resizable: true, width: 150},
       {label: '微信支付退款单号', prop: 'refundId', resizable: true, width: 150},
       {label: '微信支付订单号', prop: 'transactionId', resizable: true, width: 150},
       {label: '微信支付订单号', prop: 'transactionId', resizable: true, width: 150},

+ 3 - 1
admin/src/main/java/com/kym/admin/controller/ActivityController.java

@@ -1,5 +1,6 @@
 package com.kym.admin.controller;
 package com.kym.admin.controller;
 
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.kym.common.R;
 import com.kym.common.R;
 import com.kym.common.annotation.SysLog;
 import com.kym.common.annotation.SysLog;
 import com.kym.entity.admin.queryParams.ActivityQueryParam;
 import com.kym.entity.admin.queryParams.ActivityQueryParam;
@@ -30,8 +31,9 @@ public class ActivityController {
         this.rechargeRightsService = rechargeRightsService;
         this.rechargeRightsService = rechargeRightsService;
     }
     }
 
 
+
     @SysLog(value = "新增活动", ignoreParams = true)
     @SysLog(value = "新增活动", ignoreParams = true)
-    @PostMapping("add")
+    @PostMapping("/add")
     R<?> createActivity(@RequestBody ActivityVo activityVo) {
     R<?> createActivity(@RequestBody ActivityVo activityVo) {
         activityService.createActivity(activityVo);
         activityService.createActivity(activityVo);
         return R.success();
         return R.success();

+ 2 - 2
admin/src/main/java/com/kym/admin/controller/AdminUserController.java

@@ -43,13 +43,13 @@ public class AdminUserController extends IController {
 
 
     @SysLog("登录")
     @SysLog("登录")
     @PostMapping("/login")
     @PostMapping("/login")
-    R adminLogin(@RequestBody JSONObject json) {
+    R<?> adminLogin(@RequestBody JSONObject json) {
         return adminUserService.login(json.getString("mobilePhone"), json.getString("password"));
         return adminUserService.login(json.getString("mobilePhone"), json.getString("password"));
     }
     }
 
 
     @SysLog("登出")
     @SysLog("登出")
     @PostMapping("/logout")
     @PostMapping("/logout")
-    R adminLogout() {
+    R<?> adminLogout() {
         StpUtil.logout();
         StpUtil.logout();
         return R.success();
         return R.success();
     }
     }

+ 0 - 18
admin/src/main/java/com/kym/admin/controller/AdminUserStationController.java

@@ -1,18 +0,0 @@
-package com.kym.admin.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 操作员站点关联表 前端控制器
- * </p>
- *
- * @author skyline
- * @since 2023-09-18
- */
-@RestController
-@RequestMapping("/admin-user-station")
-public class AdminUserStationController {
-
-}

+ 3 - 0
entity/src/main/java/com/kym/entity/miniapp/PayLog.java

@@ -24,6 +24,9 @@ public class PayLog extends BaseEntity implements Serializable {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
+    public static final String STATUS_充值成功 = "SUCCESS";
+
+
     /**
     /**
      * 用户ID
      * 用户ID
      */
      */

+ 10 - 0
entity/src/main/java/com/kym/entity/miniapp/RefundLog.java

@@ -103,4 +103,14 @@ public class RefundLog extends BaseEntity {
      * 退款原因
      * 退款原因
      */
      */
     private String reason;
     private String reason;
+
+    /**
+     * 退款人id
+     */
+    private Long adminUserId;
+
+    /**
+     * 退款人
+     */
+    private String adminUsername;
 }
 }

+ 7 - 1
mapper/src/main/resources/mappers/miniapp/RefundLogMapper.xml

@@ -19,6 +19,8 @@
         <result column="discount_amount" property="discountAmount" />
         <result column="discount_amount" property="discountAmount" />
         <result column="currency" property="currency" />
         <result column="currency" property="currency" />
         <result column="reason" property="reason" />
         <result column="reason" property="reason" />
+        <result column="adminUserId" property="admin_user_id" />
+        <result column="adminUsername" property="admin_username" />
     </resultMap>
     </resultMap>
 
 
     <resultMap id="RefundVoMap" type="com.kym.entity.miniapp.vo.RefundVo">
     <resultMap id="RefundVoMap" type="com.kym.entity.miniapp.vo.RefundVo">
@@ -37,11 +39,13 @@
         <result column="refund" property="refund" />
         <result column="refund" property="refund" />
         <result column="currency" property="currency" />
         <result column="currency" property="currency" />
         <result column="reason" property="reason" />
         <result column="reason" property="reason" />
+        <result column="adminUserId" property="admin_user_id" />
+        <result column="adminUsername" property="admin_username" />
     </resultMap>
     </resultMap>
 
 
     <!-- 通用查询结果列 -->
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
-        id,user_id, refund_id, out_refund_no, transaction_id, out_trade_no, channel, user_received_account, success_time, status, funds_account, total, refund, discount_amount,currency,reason,create_time,update_time
+        id,user_id, refund_id, out_refund_no, transaction_id, out_trade_no, channel, user_received_account, success_time, status, funds_account, total, refund, discount_amount,currency,reason,admin_user_id,admin_username,create_time,update_time
     </sql>
     </sql>
 
 
 
 
@@ -63,6 +67,8 @@
             t1.`channel`,
             t1.`channel`,
             t1.`currency`,
             t1.`currency`,
             t1.`reason`
             t1.`reason`
+            t1.`adminUserId`
+            t1.`adminUsername`
         FROM
         FROM
             t_refund_log t1
             t_refund_log t1
                 LEFT JOIN
                 LEFT JOIN

+ 0 - 18
miniapp/src/main/java/com/kym/miniapp/controller/PayLogController.java

@@ -1,18 +0,0 @@
-package com.kym.miniapp.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 支付日志 前端控制器
- * </p>
- *
- * @author skyline
- * @since 2023-08-12
- */
-@RestController
-@RequestMapping("/pay-log")
-public class PayLogController {
-
-}

+ 0 - 18
miniapp/src/main/java/com/kym/miniapp/controller/RefundLogController.java

@@ -1,18 +0,0 @@
-package com.kym.miniapp.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 退款日志 前端控制器
- * </p>
- *
- * @author skyline
- * @since 2023-09-11
- */
-@RestController
-@RequestMapping("/refund-log")
-public class RefundLogController {
-
-}

+ 0 - 18
miniapp/src/main/java/com/kym/miniapp/controller/UserRechargeRightsController.java

@@ -1,18 +0,0 @@
-package com.kym.miniapp.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 用户充值权益详情表 前端控制器
- * </p>
- *
- * @author skyline
- * @since 2023-10-18
- */
-@RestController
-@RequestMapping("/user-recharge-rights")
-public class UserRechargeRightsController {
-
-}

+ 2 - 1
service/src/main/java/com/kym/service/admin/impl/AdminUserServiceImpl.java

@@ -71,9 +71,10 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
             StpUtil.login(user.getId());
             StpUtil.login(user.getId());
             // 用户名存入session,统一日志读取使用
             // 用户名存入session,统一日志读取使用
             StpUtil.getSession().set("mobilePhone", user.getMobilePhone());
             StpUtil.getSession().set("mobilePhone", user.getMobilePhone());
+            StpUtil.getSession().set("username", user.getUsername());
             user.setLastLoginTime(LocalDateTime.now());
             user.setLastLoginTime(LocalDateTime.now());
             this.updateById(user);
             this.updateById(user);
-            LOGGER.info("用户:" + mobilePhone + "/id:" + user.getId() + "登录");
+            LOGGER.info("操作员:" + mobilePhone + "/id:" + user.getId() + "登录");
             // token在cookie中有隐式返回,这里多做显式返回
             // token在cookie中有隐式返回,这里多做显式返回
             return R.success(Map.of("id", user.getId(), "satoken", StpUtil.getTokenValue()));
             return R.success(Map.of("id", user.getId(), "satoken", StpUtil.getTokenValue()));
         }
         }

+ 1 - 1
service/src/main/java/com/kym/service/miniapp/impl/InvoiceServiceImpl.java

@@ -83,7 +83,7 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
                         .setServiceMoneyDiscount(item.getServiceMoneyDiscount()))
                         .setServiceMoneyDiscount(item.getServiceMoneyDiscount()))
                 .toList();
                 .toList();
 
 
-        // TODO: 2023-11-04 校验开票金额大于0
+        // 校验开票金额大于0
         var totalMoney = orders.stream().mapToInt(ChargeOrder::getTotalMoney).sum();
         var totalMoney = orders.stream().mapToInt(ChargeOrder::getTotalMoney).sum();
         var elecMoney = orders.stream().mapToInt(ChargeOrder::getElecMoney).sum();
         var elecMoney = orders.stream().mapToInt(ChargeOrder::getElecMoney).sum();
         var serviceMoney = orders.stream().mapToInt(ChargeOrder::getServiceMoney).sum();
         var serviceMoney = orders.stream().mapToInt(ChargeOrder::getServiceMoney).sum();

+ 1 - 1
service/src/main/java/com/kym/service/miniapp/impl/UserServiceImpl.java

@@ -94,7 +94,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         if (errorCode == null) {
         if (errorCode == null) {
             // 业务逻辑处理
             // 业务逻辑处理
             var openid = json.getString("openid");
             var openid = json.getString("openid");
-            var session_key = json.getString("session_key");
             var unionid = json.getString("unionid") == null ? "" : json.getString("unionid");
             var unionid = json.getString("unionid") == null ? "" : json.getString("unionid");
             // 判断有没有,没有就新增
             // 判断有没有,没有就新增
             var user = baseMapper.selectOne(new QueryWrapper<User>().eq("openid", openid));
             var user = baseMapper.selectOne(new QueryWrapper<User>().eq("openid", openid));
@@ -182,6 +181,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         // 用户名存入session,统一日志读取使用
         // 用户名存入session,统一日志读取使用
         StpUtil.getSession().set("openid", user.getOpenid());
         StpUtil.getSession().set("openid", user.getOpenid());
         StpUtil.getSession().set("userId", user.getId());
         StpUtil.getSession().set("userId", user.getId());
+        StpUtil.getSession().set("username", user.getUsername());
         StpUtil.getSession().set("mobilePhone", user.getMobilePhone());
         StpUtil.getSession().set("mobilePhone", user.getMobilePhone());
         user.setLastLoginTime(LocalDateTime.now());
         user.setLastLoginTime(LocalDateTime.now());
         updateById(user);
         updateById(user);

+ 7 - 3
service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -394,7 +394,7 @@ public class WxPayServiceImpl implements WxPayService {
         AtomicInteger refundAmount = new AtomicInteger(account.getBalance() - account.getDiscountAmount());
         AtomicInteger refundAmount = new AtomicInteger(account.getBalance() - account.getDiscountAmount());
         var originalRefundAmount = refundAmount.get();
         var originalRefundAmount = refundAmount.get();
         // 充值记录
         // 充值记录
-        var payLogs = payLogService.lambdaQuery().eq(PayLog::getUserId, userId).eq(PayLog::getTradeState, RefundLog.STATUS_退款成功).orderByDesc(PayLog::getSuccessTime).list();
+        var payLogs = payLogService.lambdaQuery().eq(PayLog::getUserId, userId).eq(PayLog::getTradeState, PayLog.STATUS_充值成功).orderByDesc(PayLog::getSuccessTime).list();
         // 充值金额综合不足以支付余额退款
         // 充值金额综合不足以支付余额退款
         if (!CommUtil.isEmptyOrNull(payLogs)) {
         if (!CommUtil.isEmptyOrNull(payLogs)) {
             var total = payLogs.stream().mapToInt(PayLog::getTotal).sum();
             var total = payLogs.stream().mapToInt(PayLog::getTotal).sum();
@@ -443,7 +443,6 @@ public class WxPayServiceImpl implements WxPayService {
             // 不可退金额按退款金额比例放入每笔退款中
             // 不可退金额按退款金额比例放入每笔退款中
 
 
             refundLogList.forEach(LambadaTools.forEachWithIndex((refundLog, index) -> {
             refundLogList.forEach(LambadaTools.forEachWithIndex((refundLog, index) -> {
-//                refundLogList.remove(index.intValue());
                 int discountAmount;
                 int discountAmount;
                 if (index < size) {
                 if (index < size) {
                     discountAmount = account.getDiscountAmount() * (refundLog.getRefund() / originalRefundAmount);
                     discountAmount = account.getDiscountAmount() * (refundLog.getRefund() / originalRefundAmount);
@@ -452,7 +451,6 @@ public class WxPayServiceImpl implements WxPayService {
                     discountAmount = account.getDiscountAmount() - refundLogList.stream().mapToInt(RefundLog::getDiscountAmount).sum();
                     discountAmount = account.getDiscountAmount() - refundLogList.stream().mapToInt(RefundLog::getDiscountAmount).sum();
                 }
                 }
                 refundLog.setDiscountAmount(discountAmount);
                 refundLog.setDiscountAmount(discountAmount);
-//                refundLogList.add(index, refundLog);
                 newRefundLogList.add(index, refundLog);
                 newRefundLogList.add(index, refundLog);
             }));
             }));
 
 
@@ -506,6 +504,8 @@ public class WxPayServiceImpl implements WxPayService {
         refundLog.setChannel(refund.getChannel().name());
         refundLog.setChannel(refund.getChannel().name());
         refundLog.setFundsAccount(refund.getFundsAccount().name());
         refundLog.setFundsAccount(refund.getFundsAccount().name());
         refundLog.setCurrency(refund.getAmount().getCurrency());
         refundLog.setCurrency(refund.getAmount().getCurrency());
+        refundLog.setAdminUserId(StpUtil.getLoginIdAsLong());
+        refundLog.setAdminUsername(StpUtil.getSession().getString("username"));
         refundLogService.updateById(refundLog);
         refundLogService.updateById(refundLog);
 
 
     }
     }
@@ -763,6 +763,10 @@ public class WxPayServiceImpl implements WxPayService {
     @DS("db-miniapp")
     @DS("db-miniapp")
     public void fapiaoApplication(String invoiceId) {
     public void fapiaoApplication(String invoiceId) {
         var invoice = invoiceService.lambdaQuery().eq(Invoice::getId, invoiceId).one();
         var invoice = invoiceService.lambdaQuery().eq(Invoice::getId, invoiceId).one();
+        // 开票状态校验
+        if(!invoice.getStatus().equals(Invoice.STATUS_待开票)){
+            throw new BusinessException("发票状态为开票中或已开票");
+        }
 
 
         // 订单金额+ ,服务费优惠金额- 服务费优惠金额单独一个item,金额为负数
         // 订单金额+ ,服务费优惠金额- 服务费优惠金额单独一个item,金额为负数
         var itemList = new ArrayList<FaPiao.FaPiaoInfomation.IssueItem>();
         var itemList = new ArrayList<FaPiao.FaPiaoInfomation.IssueItem>();