Эх сурвалжийг харах

律师端代码 删除废弃的控制层

ldz 3 долоо хоног өмнө
parent
commit
ae5e205efb

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LawyerUserVo.java

@@ -316,6 +316,9 @@ public class LawyerUserVo implements Serializable {
     @ApiModelProperty(value = "专业领域")
     private String expertiseAreaInfo;
 
+    @ApiModelProperty(value = "律所地址")
+    private String addressNew;
+
 
 
 }

+ 4 - 5
alien-entity/src/main/java/shop/alien/mapper/LawyerUserMapper.java

@@ -104,13 +104,15 @@ Integer updateLawyerUser(LawyerUser user);
            "user.practice_start_date, " +
            "user.address, " +
            "firm.firm_name AS firmName, " +
-           "firm.payment_account AS paymentNum, " +
+           "firmTwo.payment_account AS paymentNum, " +
+           "firmTwo.address AS addressNew, " +
            "GROUP_CONCAT(area.problem_scenario_id SEPARATOR ',') AS problemScenarioId, " +
            "GROUP_CONCAT(a.name SEPARATOR ',') AS scenarioNames, " +
            "(SELECT GROUP_CONCAT(id SEPARATOR ',') FROM lawyer_legal_problem_scenario WHERE level = 1) AS firstLevelScenarioId, " +
            "(SELECT GROUP_CONCAT(name SEPARATOR ',') FROM lawyer_legal_problem_scenario WHERE level = 1) AS firstLevelScenario " +
            "FROM lawyer_user user " +
            "LEFT JOIN law_firm firm ON firm.id = user.firm_id " +
+           "LEFT JOIN law_firm_payment firmTwo ON firmTwo.firm_id = user.firm_id " +
            "LEFT JOIN lawyer_service_area area ON area.lawyer_user_id = user.id " +
            "LEFT JOIN lawyer_legal_problem_scenario a ON a.id = area.problem_scenario_id " +
            "<where>" +
@@ -121,10 +123,7 @@ Integer updateLawyerUser(LawyerUser user);
            "a.delete_flag = 0" +
            "</where>" +
            "GROUP BY " +
-           "user.id, user.phone, user.name, user.firm_id, user.head_img, " +
-           "user.personal_introduction, user.order_receiving_status, user.practice_start_date, " +
-           "firm.firm_name, firm.payment_account " +
-           "LIMIT 1 " +
+           "user.id" +
            "</script>")
    LawyerUserVo selectInfo(@Param("lawyerId") Integer lawyerId);
 

+ 2 - 1
alien-lawyer/src/main/java/shop/alien/lawyer/config/MyBatisFieldHandler.java

@@ -52,7 +52,8 @@ public class MyBatisFieldHandler implements MetaObjectHandler {
         //字段为实体类名, 不是表字段名
         this.setFieldValByName("updatedTime", new Date(), metaObject);
         if (JwtUtil.hasToken()) {
-            this.setFieldValByName("updatedUserId", Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"), metaObject);
+            this.setFieldValByName("updatedUserId", 0, metaObject);
+//            this.setFieldValByName("updatedUserId", Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"), metaObject);
         } else {
             this.setFieldValByName("updatedUserId", 0, metaObject);
         }

+ 38 - 4
alien-lawyer/src/main/java/shop/alien/lawyer/controller/AliController.java

@@ -1,14 +1,14 @@
 package shop.alien.lawyer.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreAliPayLog;
 import shop.alien.lawyer.util.AliSms;
+import shop.alien.lawyer.util.ali.AliApi;
 
 /**
  * @author ssk
@@ -26,6 +26,10 @@ public class AliController {
 
     private final AliSms aliSmsConfig;
 
+    private final AliApi aliPayConfig;
+
+    private final AliApi aliApi;
+
     @ApiOperation("发送短信")
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)})
@@ -38,4 +42,34 @@ public class AliController {
         }
         return R.fail("短信发送失败");
     }
+
+
+
+
+    @ApiOperation("支付")
+    @ApiOperationSupport(order = 12)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "price", value = "金额", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "subject", value = "类目", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/zhifu")
+    public R<JSONObject> zhifu(@RequestParam(value = "price") String price, @RequestParam(value = "subject") String subject) {
+        return R.data(aliApi.promotionPackagePay(price, subject));
+    }
+
+    @ApiOperation("退款")
+    @ApiOperationSupport(order = 13)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "outTradeNo", value = "订单号", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "refundAmount", value = "退款金额", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "refundReason", value = "退款原因", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "partialRefundCode", value = "部分退款编码", dataType = "String", paramType = "query", required = false)
+    })
+    @GetMapping("/processRefund")
+    public String processRefund(@RequestParam(value = "outTradeNo") String outTradeNo,
+                                @RequestParam(value = "refundAmount") String refundAmount,
+                                @RequestParam(value = "refundReason") String refundReason,
+                                @RequestParam(value = "partialRefundCode") String partialRefundCode) {
+        return aliApi.processRefund(outTradeNo, refundAmount, refundReason, partialRefundCode);
+    }
 }

+ 4 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/controller/LawyerConsultationOrderController.java

@@ -36,10 +36,13 @@ public class LawyerConsultationOrderController {
 
     @Value("${order.coefficient}")
     private String coefficient;
+    @Value("${order.coefficients}")
+    private String coefficients;
 
     private final LawyerConsultationOrderService consultationOrderService;
     private final OrderExpirationService orderExpirationService;
 
+
     @ApiOperation("分页查询咨询订单列表(支持按律师姓名关联查询,返回结果包含律师信息)")
     @ApiOperationSupport(order = 1)
     @ApiImplicitParams({
@@ -251,6 +254,7 @@ public class LawyerConsultationOrderController {
         //如果订单已支付,关闭redis中的记时
         if (request.getPaymentStatus() != null && request.getPaymentStatus() == 1) {
             orderExpirationService.cancelOrderPaymentTimeout(request.getOrderNumber());
+            orderExpirationService.setOrderAcceptTimeout(request.getOrderNumber(), Long.parseLong(coefficients)*60);
         }
         return consultationOrderService.payStatus(request);
     }

+ 17 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/StoreAliPayRefundLogService.java

@@ -0,0 +1,17 @@
+package shop.alien.lawyer.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.store.StoreAliPayRefundLog;
+
+/**
+ * <p>
+ * 支付宝退款记录表 服务类
+ * </p>
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+public interface StoreAliPayRefundLogService extends IService<StoreAliPayRefundLog> {
+
+}
+

+ 22 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/StoreAliPayRefundLogServiceImpl.java

@@ -0,0 +1,22 @@
+package shop.alien.lawyer.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import shop.alien.entity.store.StoreAliPayRefundLog;
+import shop.alien.lawyer.service.StoreAliPayRefundLogService;
+import shop.alien.mapper.StoreAliPayRefundLogMapper;
+
+
+/**
+ * <p>
+ * 支付宝退款记录表 服务实现类
+ * </p>
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Service
+public class StoreAliPayRefundLogServiceImpl extends ServiceImpl<StoreAliPayRefundLogMapper, StoreAliPayRefundLog> implements StoreAliPayRefundLogService {
+
+}
+

+ 252 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/util/ali/AliApi.java

@@ -0,0 +1,252 @@
+package shop.alien.lawyer.util.ali;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.AlipayConfig;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.domain.*;
+import com.alipay.api.request.*;
+import com.alipay.api.response.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import shop.alien.entity.store.*;
+import shop.alien.lawyer.service.StoreAliPayRefundLogService;
+import shop.alien.util.common.UniqueRandomNumGenerator;
+import shop.alien.util.common.UrlEncode;
+import shop.alien.util.system.OSUtil;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * 支付宝相关组件
+ *
+ * @author ssk
+ * @version 1.0
+ * @date 2024/12/10 8:49
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class AliApi {
+
+
+private final StoreAliPayRefundLogService storeAliPayRefundLogService;
+
+    /**
+     * 商家端appId
+     */
+    @Value("${app.business.appId}")
+    private String businessAppId;
+
+    /**
+     * 商家端app私钥
+     */
+    @Value("${app.business.appPrivateKey}")
+    private String businessAppPrivateKey;
+
+    /**
+     * 商家端app公钥
+     */
+    @Value("${app.business.appPublicKey}")
+    private String businessAppPublicKey;
+
+    /**
+     * windows应用公钥证书文件路径
+     */
+    @Value("${app.business.win.appCertPath}")
+    private String businessWinAppCertPath;
+
+    /**
+     * windows支付宝公钥证书文件路径
+     */
+    @Value("${app.business.win.alipayPublicCertPath}")
+    private String businessWinAlipayPublicCertPath;
+
+    /**
+     * windows支付宝根证书文件路径
+     */
+    @Value("${app.business.win.alipayRootCertPath}")
+    private String businessWinAlipayRootCertPath;
+
+    /**
+     * linux应用公钥证书文件路径
+     */
+    @Value("${app.business.linux.appCertPath}")
+    private String businessLinuxAppCertPath;
+
+    /**
+     * linux支付宝公钥证书文件路径
+     */
+    @Value("${app.business.linux.alipayPublicCertPath}")
+    private String businessLinuxAlipayPublicCertPath;
+
+    /**
+     * linux支付宝根证书文件路径
+     */
+    @Value("${app.business.linux.alipayRootCertPath}")
+    private String businessLinuxAlipayRootCertPath;
+
+    /**
+     * 支对称加密算法密钥
+     */
+    @Value("${ali.aes.encryptKey}")
+    private String encryptKey;
+
+
+    /**
+     * 填写阿里配置
+     *
+     * @return AlipayConfig
+     */
+    private AlipayConfig setAlipayConfig(String type) {
+        AlipayConfig alipayConfig = new AlipayConfig();
+        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
+        alipayConfig.setAppId(businessAppId);
+        alipayConfig.setPrivateKey(businessAppPrivateKey);
+        alipayConfig.setFormat("json");
+        alipayConfig.setCharset("UTF-8");
+        alipayConfig.setSignType("RSA2");
+        if ("windows".equals(OSUtil.getOsName())) {
+            alipayConfig.setAppCertPath(businessWinAppCertPath);
+            alipayConfig.setAlipayPublicCertPath(businessWinAlipayPublicCertPath);
+            alipayConfig.setRootCertPath(businessWinAlipayRootCertPath);
+        } else {
+            alipayConfig.setAppCertPath(businessLinuxAppCertPath);
+            alipayConfig.setAlipayPublicCertPath(businessLinuxAlipayPublicCertPath);
+            alipayConfig.setRootCertPath(businessLinuxAlipayRootCertPath);
+        }
+        if ("aes".equals(type)) {
+            alipayConfig.setEncryptType("AES");
+            alipayConfig.setEncryptKey(encryptKey);
+        }
+        return alipayConfig;
+    }
+
+    public JSONObject promotionPackagePay(String price, String subject) {
+        try {
+            JSONObject jsonObject = new JSONObject();
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+            String orderNo = UniqueRandomNumGenerator.generateUniqueCode(19);
+            AlipayClient alipayClient = new DefaultAlipayClient(setAlipayConfig(null));
+            AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+            AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+            model.setOutTradeNo(orderNo);
+            model.setTotalAmount(price);
+            model.setSubject(subject);
+            model.setPassbackParams(UrlEncode.getUrlEncode(dateFormat.toString()));
+            request.setBizModel(model);
+            AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
+            String orderStr = "";
+            if (response.isSuccess()) {
+                orderStr = response.getBody();
+            } else {
+                System.out.println("调用失败 response:" + response);
+                orderStr = "调用失败";
+            }
+            jsonObject.put("orderStr", orderStr);
+            jsonObject.put("orderNo", orderNo);
+            return jsonObject;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 退款
+     *
+     * @param outTradeNo
+     * @param refundAmount
+     * @param refundReason
+     * @return
+     */
+
+    public String processRefund(String outTradeNo, String refundAmount, String refundReason, String partialRefundCode) {
+        try {
+            // TODO 部分退款支付宝接口修改
+            AlipayClient alipayClient = new DefaultAlipayClient(setAlipayConfig(null));
+            AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
+            AlipayTradeRefundModel model = new AlipayTradeRefundModel();
+            model.setOutTradeNo(outTradeNo);
+            model.setRefundAmount(refundAmount);
+            model.setRefundReason(refundReason);
+            if (StringUtils.isNotBlank(partialRefundCode)) {
+                model.setOutRequestNo(partialRefundCode);
+            }
+            request.setBizModel(model);
+            AlipayTradeRefundResponse response = alipayClient.certificateExecute(request);
+            String refundReslut = "";
+            if (response.isSuccess()) {
+                refundReslut = "调用成功";
+                // 保存退款信息进入到退款记录表
+                JSONObject responseBody = JSONObject.parseObject(response.getBody());
+                JSONObject refundResponse = responseBody.getJSONObject("alipay_trade_refund_response");
+                
+                StoreAliPayRefundLog refundLog = new StoreAliPayRefundLog();
+                // 响应基本信息
+                refundLog.setResponseCode(refundResponse.getString("code"));
+                refundLog.setResponseMsg(refundResponse.getString("msg"));
+                // 买家信息
+                refundLog.setBuyerLogonId(refundResponse.getString("buyer_logon_id"));
+                refundLog.setBuyerOpenId(refundResponse.getString("buyer_open_id"));
+                // 资金变动信息
+                refundLog.setFundChange(refundResponse.getString("fund_change"));
+                // 订单信息
+                refundLog.setOutTradeNo(refundResponse.getString("out_trade_no"));
+                refundLog.setTradeNo(refundResponse.getString("trade_no"));
+                // 退款金额信息
+                refundLog.setRefundFee(refundResponse.getString("refund_fee"));
+                refundLog.setSendBackFee(refundResponse.getString("send_back_fee"));
+                // 退款渠道明细(转换为JSON字符串)
+                if (refundResponse.containsKey("refund_detail_item_list")) {
+                    JSONArray refundDetailList = refundResponse.getJSONArray("refund_detail_item_list");
+                    if (refundDetailList != null) {
+                        refundLog.setRefundDetailItemList(JSON.toJSONString(refundDetailList));
+                    }
+                }
+                // 退款时间(字符串转Date)
+                String gmtRefundPayStr = refundResponse.getString("gmt_refund_pay");
+                if (StringUtils.isNotBlank(gmtRefundPayStr)) {
+                    try {
+                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        refundLog.setGmtRefundPay(sdf.parse(gmtRefundPayStr));
+                    } catch (ParseException e) {
+                        log.warn("解析退款时间失败: {}", gmtRefundPayStr, e);
+                    }
+                }
+                // 退款原因和部分退款编号(从请求参数中获取)
+                refundLog.setRefundReason(refundReason);
+                refundLog.setOutRequestNo(partialRefundCode);
+                // 证书和签名信息
+                refundLog.setAlipayCertSn(responseBody.getString("alipay_cert_sn"));
+                refundLog.setSign(responseBody.getString("sign"));
+                // 标准字段
+                refundLog.setDeleteFlag(0);
+                refundLog.setCreatedTime(new Date());
+                
+                storeAliPayRefundLogService.save(refundLog);
+
+            } else {
+                log.warn("AliPayConfig.processRefund ERROR Msg={}", response.getBody());
+                JSONObject jsonObject = JSONObject.parseObject(response.getBody()).getJSONObject("alipay_trade_refund_response");
+                refundReslut =  jsonObject.getString("sub_msg");
+            }
+            return refundReslut;
+        } catch (AlipayApiException e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+
+
+
+
+
+}