Compare commits
18 Commits
dccbeac0c2
...
d8d3bd97dd
Author | SHA1 | Date |
---|---|---|
|
d8d3bd97dd | |
|
f41b9a53d2 | |
|
64de27cc8c | |
|
75cdc9ea16 | |
|
bce9420d55 | |
|
1eeec91626 | |
|
9cd8da3803 | |
|
a3241b83ff | |
|
dc3a45b274 | |
|
5c3ea94803 | |
|
872cf65750 | |
|
a938a05b72 | |
|
aae00a4bb9 | |
|
50c89af2c2 | |
|
f75eae71a4 | |
|
d23497bdc5 | |
|
1941c2617c | |
|
3b83ab28ed |
|
@ -16,6 +16,25 @@
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 微信支付依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||||
|
<artifactId>wechatpay-apache-httpclient</artifactId>
|
||||||
|
<version>0.4.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
<version>4.40.30.ALL</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alipay.sdk</groupId>
|
<groupId>com.alipay.sdk</groupId>
|
||||||
<artifactId>alipay-easysdk</artifactId>
|
<artifactId>alipay-easysdk</artifactId>
|
||||||
|
@ -46,12 +65,6 @@
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 评论区模块-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl-comment</artifactId>
|
|
||||||
<version>3.8.8</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mcwl</groupId>
|
<groupId>com.mcwl</groupId>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mcwl;
|
package com.mcwl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.mcwl.pay.config.AliConfig;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
import org.springframework.amqp.support.converter.MessageConverter;
|
import org.springframework.amqp.support.converter.MessageConverter;
|
||||||
|
@ -8,6 +9,7 @@ import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class MemberController {
|
||||||
return AjaxResult.warn("用户不存在");
|
return AjaxResult.warn("用户不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
Member member = memberService.rechargePoints(userId, amount * 10);
|
Member member = memberService.rechargePoints(userId, amount * 100);
|
||||||
|
|
||||||
// 返回充值积分
|
// 返回充值积分
|
||||||
if (!Optional.ofNullable(member).isPresent()) {
|
if (!Optional.ofNullable(member).isPresent()) {
|
||||||
|
@ -124,4 +124,20 @@ public class MemberController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费积分
|
||||||
|
*/
|
||||||
|
@GetMapping("consumePoints/{consumePoints}")
|
||||||
|
public AjaxResult consumePoints(@PathVariable Double consumePoints) {
|
||||||
|
|
||||||
|
if (consumePoints == null || consumePoints <= 0) {
|
||||||
|
return AjaxResult.warn("消费积分不能为空或小于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
memberService.consumePoints(consumePoints);
|
||||||
|
return AjaxResult.success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,8 @@
|
||||||
package com.mcwl.web.controller.pay;
|
package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alipay.easysdk.factory.Factory;
|
import com.alipay.easysdk.factory.Factory;
|
||||||
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
||||||
import com.mcwl.common.JSONUtils;
|
import com.mcwl.common.JSONUtils;
|
||||||
|
@ -8,9 +10,11 @@ import com.mcwl.common.annotation.Anonymous;
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.alipay.easysdk.kernel.Config;
|
import com.alipay.easysdk.kernel.Config;
|
||||||
|
@ -20,9 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -48,12 +50,15 @@ public class OrderTradeController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AliPayIntegration aliPayIntegration;
|
private AliPayIntegration aliPayIntegration;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(OrderTrade orderTrade)
|
public TableDataInfo list(OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
@ -63,8 +68,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public AjaxResult add(@RequestBody OrderTrade orderTrade)
|
public AjaxResult add(@RequestBody OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
@ -79,8 +83,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@PostMapping("/upda")
|
@PostMapping("/upda")
|
||||||
public AjaxResult upda(@RequestBody OrderTrade orderTrade)
|
public AjaxResult upda(@RequestBody OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
@ -95,8 +98,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult remove(@RequestBody IdsParam ids)
|
public AjaxResult remove(@RequestBody IdsParam ids) {
|
||||||
{
|
|
||||||
orderTradeService.deleteMallProductByIds(ids);
|
orderTradeService.deleteMallProductByIds(ids);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -105,14 +107,23 @@ public class OrderTradeController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 支付接口
|
* 支付接口
|
||||||
*
|
*
|
||||||
* @param tradeEntity 订单实体
|
* @param orderTradeDto 订单实体
|
||||||
* @param response 响应
|
* @param response 响应
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@Anonymous
|
||||||
@PostMapping("/doPay")
|
@PostMapping("/doPay")
|
||||||
public void doPay(@RequestBody OrderTrade tradeEntity, HttpServletResponse response) throws Exception {
|
public void doPay(@RequestBody OrderTradeDto orderTradeDto, HttpServletResponse response) throws Exception {
|
||||||
String qrUrl = aliPayIntegration.pay(tradeEntity);
|
String qrUrl = null;
|
||||||
|
|
||||||
|
String type = orderTradeDto.getType();
|
||||||
|
|
||||||
|
if ("member".equalsIgnoreCase(type)) {
|
||||||
|
qrUrl = aliPayIntegration.memberPay(orderTradeDto);
|
||||||
|
} else if ("points".equalsIgnoreCase(type)) {
|
||||||
|
qrUrl = aliPayIntegration.pointsPay(orderTradeDto.getPaymentAmount());
|
||||||
|
}
|
||||||
|
|
||||||
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +147,7 @@ public class OrderTradeController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付回调接口
|
* 支付回调接口
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -155,23 +167,56 @@ public class OrderTradeController extends BaseController {
|
||||||
// System.out.println(name + " = " + request.getParameter(name));
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
String tradeNo = params.get("out_trade_no");
|
|
||||||
String gmtPayment = params.get("gmt_payment");
|
|
||||||
String alipayTradeNo = params.get("trade_no");
|
|
||||||
// 支付宝验签
|
// 支付宝验签
|
||||||
if (Factory.Payment.Common().verifyNotify(params)) {
|
if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
|
// System.out.println("交易名称: " + params.get("subject"));
|
||||||
|
// System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
|
// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
|
// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
|
// System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
|
// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
|
// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
|
// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
// 验签通过
|
// 验签通过
|
||||||
System.out.println("交易名称: " + params.get("subject"));
|
|
||||||
System.out.println("交易状态: " + params.get("trade_status"));
|
String code = params.get("out_trade_no"); // 商户订单号
|
||||||
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
// 获取订单后缀
|
||||||
System.out.println("商户订单号: " + params.get("out_trade_no"));
|
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
||||||
System.out.println("交易金额: " + params.get("total_amount"));
|
String orderTradeJson = redisCache.getCacheObject(code);
|
||||||
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
|
||||||
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
orderTradeService.orderHandler(orderTrade, suffix, params);
|
||||||
|
|
||||||
// 更新订单状态
|
// 更新订单状态
|
||||||
|
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
||||||
|
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
|
// // 支付宝交易凭证号
|
||||||
|
// orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
|
// orderTrade.setTransactionId(1);
|
||||||
|
// orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
|
// orderTrade.setOrderStatus(3);
|
||||||
|
// orderTrade.setPayStatus(2);
|
||||||
|
// String totalAmountStr = params.get("total_amount");
|
||||||
|
// if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
|
// BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
|
// orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
|
// }
|
||||||
|
// String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
|
// if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
|
// BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
|
// orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
|
// }
|
||||||
|
// orderTradeService.save(orderTrade);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
// 验签失败
|
||||||
|
System.out.println("验签失败");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 验签失败
|
||||||
|
System.out.println("验签失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.mcwl.web.controller.pay;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alipay.easysdk.factory.Factory;
|
|
||||||
import com.alipay.easysdk.kernel.Config;
|
|
||||||
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝支付
|
|
||||||
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class AliPayIntegration {
|
|
||||||
@Autowired
|
|
||||||
private Config config;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用支付宝预下订单接口
|
|
||||||
*
|
|
||||||
* @param tradeEntity 订单实体
|
|
||||||
* @return 二维码url
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public String pay(OrderTrade tradeEntity) throws Exception {
|
|
||||||
Factory.setOptions(config);
|
|
||||||
//调用支付宝的接口
|
|
||||||
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
|
||||||
.preCreate(tradeEntity.getUserName(),
|
|
||||||
tradeEntity.getCode(),
|
|
||||||
tradeEntity.getPaymentAmount().toString());
|
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
|
||||||
//参照官方文档响应示例,解析返回结果
|
|
||||||
String httpBodyStr = payResponse.getHttpBody();
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
|
||||||
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.mcwl.web.controller.pay.WxPay;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.mcwl.web.controller.pay.WxPay.util.PayUtil;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/wx/pay")
|
||||||
|
public class WxPayController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预支付下单
|
||||||
|
*
|
||||||
|
* @param orderSn 订单号
|
||||||
|
* @param total 分
|
||||||
|
* @param description 描述
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getPay")
|
||||||
|
public String getPay(String orderSn, int total, String description) {
|
||||||
|
PayUtil payUtil = new PayUtil();
|
||||||
|
try {
|
||||||
|
return payUtil.requestwxChatPay(orderSn, total, description, "oYgFI91D00GpCwccdnKDR4KNxI4k");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付回调
|
||||||
|
@PostMapping(value = "/returnNotify")
|
||||||
|
public Map returnNotify(@RequestBody JSONObject jsonObject) {
|
||||||
|
// v3 私钥
|
||||||
|
String key = "xxxxx";
|
||||||
|
String json = jsonObject.toString();
|
||||||
|
String associated_data = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.associated_data");
|
||||||
|
String ciphertext = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.ciphertext");
|
||||||
|
String nonce = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.nonce");
|
||||||
|
try {
|
||||||
|
String decryptData = new AesUtil(key.getBytes(StandardCharsets.UTF_8)).decryptToString(associated_data.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext);
|
||||||
|
System.out.println("decryptData = " + decryptData);
|
||||||
|
//TODO 业务校验
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
HashMap<String, String> stringStringHashMap = new HashMap<>();
|
||||||
|
stringStringHashMap.put("code", "200");
|
||||||
|
stringStringHashMap.put("message", "返回成功");
|
||||||
|
// 返回这个说明应答成功
|
||||||
|
return stringStringHashMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.mcwl.web.controller.pay.WxPay.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付配置
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface DirectConnection {
|
||||||
|
|
||||||
|
//支付成功后的回调地址
|
||||||
|
String NOTIFY_URL = "";
|
||||||
|
|
||||||
|
//商户号
|
||||||
|
String MCH_ID = "";
|
||||||
|
|
||||||
|
//商户证书序列号
|
||||||
|
String MCH_SERIAL_NO = "";
|
||||||
|
|
||||||
|
//V3密钥
|
||||||
|
String API_3KEY = "";
|
||||||
|
|
||||||
|
//小程序或者公众号的ApId
|
||||||
|
String APP_ID = "";
|
||||||
|
|
||||||
|
// 商户证书序列号对应的证书秘钥
|
||||||
|
String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDOsZnx5Nh4qK7O" +
|
||||||
|
"vzbDOQu5UMtSdoZWyqOC+gFNVAB7aPAzQwgN7OAUt7G8synPRdovQ/l116dZ0ZiX" +
|
||||||
|
"XQX3Le8/o5szRH6LxpqcpFMaZg2N/HOydyTMaHI0wnZIc9BXR8aaXl7uVQnydF40" +
|
||||||
|
"FoWicge6vTCXOyjirTpS2PGKy9+hu0vx7GbX1NUDl2hNXkH54pdWn5eof1fnbh/V" +
|
||||||
|
"45q/OS7d9qnpYfs1ff+0nA==";
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.mcwl.web.controller.pay.WxPay.util;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
import javax.crypto.spec.GCMParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回调签名工具类
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AesUtil {
|
||||||
|
|
||||||
|
static final int KEY_LENGTH_BYTE = 32;
|
||||||
|
static final int TAG_LENGTH_BIT = 128;
|
||||||
|
private final byte[] aesKey;
|
||||||
|
|
||||||
|
public AesUtil(byte[] key) {
|
||||||
|
if (key.length != KEY_LENGTH_BYTE) {
|
||||||
|
throw new IllegalArgumentException("无效的ApiV3Key,长度必须为32个字节");
|
||||||
|
}
|
||||||
|
this.aesKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext) throws GeneralSecurityException, IOException {
|
||||||
|
try {
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||||
|
SecretKeySpec key = new SecretKeySpec(aesKey, "AES");
|
||||||
|
GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, key, spec);
|
||||||
|
cipher.updateAAD(associatedData);
|
||||||
|
return new String(cipher.doFinal(Base64.getDecoder().decode(ciphertext)), "utf-8");
|
||||||
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
} catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
package com.mcwl.web.controller.pay.WxPay.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.mcwl.web.controller.pay.WxPay.config.DirectConnection;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.exception.HttpCodeException;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.exception.NotFoundException;
|
||||||
|
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付工具类
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/6
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PayUtil {
|
||||||
|
|
||||||
|
private CloseableHttpClient httpClient;
|
||||||
|
private CertificatesManager certificatesManager;
|
||||||
|
private Verifier verifier;
|
||||||
|
private PrivateKey merchantPrivateKey;
|
||||||
|
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
merchantPrivateKey = PemUtil.loadPrivateKey(new ByteArrayInputStream(DirectConnection.privateKey.getBytes("utf-8")));
|
||||||
|
// 获取证书管理器实例
|
||||||
|
certificatesManager = CertificatesManager.getInstance();
|
||||||
|
// 向证书管理器增加需要自动更新平台证书的商户信息
|
||||||
|
certificatesManager.putMerchant(DirectConnection.MCH_ID, new WechatPay2Credentials(DirectConnection.MCH_ID,
|
||||||
|
new PrivateKeySigner(DirectConnection.MCH_SERIAL_NO, merchantPrivateKey)),
|
||||||
|
DirectConnection.API_3KEY.getBytes(StandardCharsets.UTF_8));
|
||||||
|
// 从证书管理器中获取verifier
|
||||||
|
verifier = certificatesManager.getVerifier(DirectConnection.MCH_ID);
|
||||||
|
httpClient = WechatPayHttpClientBuilder.create()
|
||||||
|
.withMerchant(DirectConnection.MCH_ID, DirectConnection.MCH_SERIAL_NO, merchantPrivateKey)
|
||||||
|
.withValidator(new WechatPay2Validator(certificatesManager.getVerifier(DirectConnection.MCH_ID)))
|
||||||
|
.build();
|
||||||
|
} catch (IOException | GeneralSecurityException | HttpCodeException | NotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一下单,获取到 prepay_id,然后获取签名。
|
||||||
|
*/
|
||||||
|
public String requestwxChatPay(String orderSn, int total, String description, String openid) throws Exception {
|
||||||
|
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi");
|
||||||
|
httpPost.addHeader("Accept", "application/json");
|
||||||
|
httpPost.addHeader("Content-type", "application/json; charset=utf-8");
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
//组合请求参数JSON格式
|
||||||
|
ObjectNode rootNode = objectMapper.createObjectNode();
|
||||||
|
rootNode.put("mchid", DirectConnection.MCH_ID)
|
||||||
|
.put("appid", DirectConnection.APP_ID)
|
||||||
|
.put("notify_url", DirectConnection.NOTIFY_URL + "returnNotify")
|
||||||
|
.put("description", description)
|
||||||
|
.put("out_trade_no", orderSn);
|
||||||
|
rootNode.putObject("amount")
|
||||||
|
// total:金额,以分为单位,假如是10块钱,那就要写 1000
|
||||||
|
.put("total", total)
|
||||||
|
.put("currency", "CNY");
|
||||||
|
rootNode.putObject("payer")
|
||||||
|
// openid:用户在该小程序或者公众号下的openid
|
||||||
|
.put("openid", openid);
|
||||||
|
try {
|
||||||
|
objectMapper.writeValue(bos, rootNode);
|
||||||
|
httpPost.setEntity(new StringEntity(bos.toString("UTF-8"), "UTF-8"));
|
||||||
|
//获取预支付ID
|
||||||
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||||
|
String bodyAsString = EntityUtils.toString(response.getEntity());
|
||||||
|
//微信成功响应
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
if (statusCode == 200) {
|
||||||
|
//时间戳
|
||||||
|
String timestamp = System.currentTimeMillis() / 1000 + "";
|
||||||
|
//随机字符串
|
||||||
|
String nonce = RandomUtil.randomString(32);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
// Appid
|
||||||
|
builder.append(DirectConnection.APP_ID).append("\n");
|
||||||
|
// 时间戳
|
||||||
|
builder.append(timestamp).append("\n");
|
||||||
|
// 随机字符串
|
||||||
|
builder.append(nonce).append("\n");
|
||||||
|
JsonNode jsonNode = objectMapper.readTree(bodyAsString);
|
||||||
|
// 预支付会话ID
|
||||||
|
builder.append("prepay_id=").append(jsonNode.get("prepay_id").textValue()).append("\n");
|
||||||
|
//获取签名
|
||||||
|
String sign = this.sign(builder.toString().getBytes("utf-8"), merchantPrivateKey);
|
||||||
|
JSONObject jsonMap = new JSONObject();
|
||||||
|
jsonMap.put("noncestr", nonce);
|
||||||
|
jsonMap.put("timestamp", timestamp);
|
||||||
|
jsonMap.put("prepayid", jsonNode.get("prepay_id").textValue());
|
||||||
|
jsonMap.put("sign", sign);
|
||||||
|
jsonMap.put("appid", DirectConnection.APP_ID);
|
||||||
|
jsonMap.put("partnerid", DirectConnection.MCH_ID);
|
||||||
|
return jsonMap.toJSONString();//响应签名数据,前端拿着响应数据调起微信SDK
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算签名
|
||||||
|
*/
|
||||||
|
private String sign(byte[] message, PrivateKey yourPrivateKey) {
|
||||||
|
try {
|
||||||
|
Signature sign = Signature.getInstance("SHA256withRSA");
|
||||||
|
sign.initSign(yourPrivateKey);
|
||||||
|
sign.update(message);
|
||||||
|
return Base64.getEncoder().encodeToString(sign.sign());
|
||||||
|
} catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
* @apiNote
|
* @apiNote
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RequestMapping("like")
|
@RequestMapping("/like")
|
||||||
@RestController
|
@RestController
|
||||||
public class MallProductLikeController {
|
public class MallProductLikeController {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.service.ModelCommentLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelCommentService;
|
||||||
|
import com.mcwl.resource.service.ModelLikeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.web.controller.resource
|
||||||
|
* @Filename:ModelCommentcontroller
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 11:36
|
||||||
|
*/
|
||||||
|
@RequestMapping("/ModelComment")
|
||||||
|
@RestController
|
||||||
|
public class ModelCommentController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelLikeService modelLikeService;
|
||||||
|
@Autowired
|
||||||
|
private ModelCommentService modelCommentService;
|
||||||
|
@Autowired
|
||||||
|
private ModelCommentLikeService modelCommentLikeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型点赞/取消
|
||||||
|
*/
|
||||||
|
@GetMapping("/imageLike/{imageId}")
|
||||||
|
public AjaxResult like(@PathVariable Long imageId) {
|
||||||
|
modelLikeService.like(imageId);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型评论发布
|
||||||
|
*/
|
||||||
|
@PostMapping("/comment")
|
||||||
|
public AjaxResult comment(@RequestBody ModelComment modelComment) {
|
||||||
|
modelCommentService.comment(modelComment);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型评论点赞/取消
|
||||||
|
*/
|
||||||
|
@GetMapping("/commentLike/{commentId}")
|
||||||
|
public AjaxResult commentLike(@PathVariable Long commentId) {
|
||||||
|
modelCommentLikeService.like(commentId);
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.oss.OssUtil;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||||
|
import com.mcwl.resource.service.ModelImageCommentLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelImageLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/modelImage")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ModelImageController {
|
||||||
|
|
||||||
|
private final ModelImageService modelImageService;
|
||||||
|
|
||||||
|
private final ModelImageLikeService modelImageLikeService;
|
||||||
|
|
||||||
|
private final ModelImageCommentLikeService modelImageCommentLikeService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片上传
|
||||||
|
*/
|
||||||
|
@GetMapping("/upload")
|
||||||
|
public AjaxResult upload(MultipartFile file) {
|
||||||
|
|
||||||
|
return AjaxResult.success("上传成功", OssUtil.uploadMultipartFile(file));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片发布
|
||||||
|
*/
|
||||||
|
@PostMapping("/publish")
|
||||||
|
public AjaxResult publish(@RequestBody ModelImageRes modelImageRes) {
|
||||||
|
modelImageService.publish(modelImageRes);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片点赞/取消
|
||||||
|
*/
|
||||||
|
@GetMapping("/imageLike/{imageId}")
|
||||||
|
public AjaxResult like(@PathVariable Long imageId) {
|
||||||
|
modelImageLikeService.like(imageId);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片评论发布
|
||||||
|
*/
|
||||||
|
@PostMapping("/comment")
|
||||||
|
public AjaxResult comment(@RequestBody ModelImageCommentRes modelImageCommentRes) {
|
||||||
|
modelImageService.comment(modelImageCommentRes);
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片评论点赞/取消
|
||||||
|
*/
|
||||||
|
@GetMapping("/commentLike/{commentId}")
|
||||||
|
public AjaxResult commentLike(@PathVariable Long commentId) {
|
||||||
|
modelImageCommentLikeService.like(commentId);
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.mcwl.web.controller.resource;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.web.controller.common.OssUtil;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.web.controller.resource
|
||||||
|
* @Filename:MallProductController
|
||||||
|
* @Description 商品
|
||||||
|
* @Date:2024/12/31 10:48
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/WorkFlow")
|
||||||
|
public class WorkFlowController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* 图片
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/file")
|
||||||
|
public AjaxResult Malifile(@RequestParam MultipartFile file){
|
||||||
|
|
||||||
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
|
return AjaxResult.success(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* zip
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/zipUrlFile")
|
||||||
|
public AjaxResult zipUrlFile(@RequestParam MultipartFile file){
|
||||||
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
|
return AjaxResult.success(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* 下载zip
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/zipUrl")
|
||||||
|
public AjaxResult zipUrl(@RequestParam MultipartFile file){
|
||||||
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
|
return AjaxResult.success(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @PostMapping("/add")
|
||||||
|
// public AjaxResult
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.mcwl.web.controller.system;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.system.domain.vo.AdviceVo;
|
||||||
|
import com.mcwl.system.service.ISysAdviceService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("system/advice")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SysAdviceController {
|
||||||
|
|
||||||
|
private final ISysAdviceService sysAdviceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据当前用户获取新消息提醒
|
||||||
|
*/
|
||||||
|
@GetMapping("getUserNewMsg")
|
||||||
|
public AjaxResult getUserNewMsg() {
|
||||||
|
List<AdviceVo> adviceVo = sysAdviceService.getUserNewMsg();
|
||||||
|
return AjaxResult.success(adviceVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据当前用户获取系统公告
|
||||||
|
*/
|
||||||
|
@GetMapping("getUserSystemNotice")
|
||||||
|
public AjaxResult getUserSystemNotice() {
|
||||||
|
List<AdviceVo> adviceVo = sysAdviceService.getUserSystemNotice();
|
||||||
|
return AjaxResult.success(adviceVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据当前用户获取所有消息
|
||||||
|
*/
|
||||||
|
@GetMapping("getUserAllMsg")
|
||||||
|
public AjaxResult getUserAllMsg() {
|
||||||
|
List<AdviceVo> adviceVo = sysAdviceService.getUserAllMsg();
|
||||||
|
return AjaxResult.success(adviceVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有消息
|
||||||
|
*/
|
||||||
|
@GetMapping("getAllMsg")
|
||||||
|
public AjaxResult getAllMsg() {
|
||||||
|
List<AdviceVo> adviceVo = sysAdviceService.getAllMsg();
|
||||||
|
return AjaxResult.success(adviceVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -269,4 +269,16 @@ public class SysUserController extends BaseController
|
||||||
userService.updateUserInfo(sysUser);
|
userService.updateUserInfo(sysUser);
|
||||||
return AjaxResult.success("修改成功");
|
return AjaxResult.success("修改成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证
|
||||||
|
* @param sysUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateIdCard")
|
||||||
|
public AjaxResult updateIdCard(@RequestBody SysUser sysUser){
|
||||||
|
|
||||||
|
return userService.updateIdCard(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ import com.mcwl.system.domain.SysUserThirdAccount;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.system.service.ISysUserThirdAccountService;
|
import com.mcwl.system.service.ISysUserThirdAccountService;
|
||||||
import com.mcwl.system.service.IWXService;
|
import com.mcwl.system.service.IWXService;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -59,13 +60,6 @@ public class WXController {
|
||||||
@Resource
|
@Resource
|
||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
@Anonymous
|
|
||||||
@PostMapping("/test")
|
|
||||||
public AjaxResult test(@RequestParam MultipartFile file){
|
|
||||||
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
|
||||||
return AjaxResult.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码登录用uuid生成
|
* 扫码登录用uuid生成
|
||||||
|
|
|
@ -183,5 +183,5 @@ mall:
|
||||||
appId: 9021000135682614
|
appId: 9021000135682614
|
||||||
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQxmQGcaiKjOhayWi+zNTvpp8B5YT8jFFkjLzrD+W+T2Dwf2GfFR4p95zsCJxYeoLWdghMPA6/GMFrLbuVFpaEjuTm4icqA9N8n5d3W0j7gh+wMjZoqyJclAIeb09ut7rY6mWzilA9kWmZnUG7MOWIU70RVRYrfJectCFw/odM9lG4XIVe13X2h+1ecTQyQzLWmnvKFCfo7dQjE7fIYiWfud1ZGUneNs3u73pNWMB6ThGTTCbs0atcgM3fYOg3q7fTxIu9VcaUCJiJ/kNbL9sVEyOrSyx2f2o6w06zdEaOiQFsuDeS8QPYGMg7pf42wAfqCO6hqxQiQT5vp1hvB0o1AgMBAAECggEAIhaEYLwMSispXo8D2cES9iaOU/z91hUX6Qv2Q4anuqqoEZh8nN91Db6etTjFz1NxURvTklelxTsH97t56n26DRY0MWTYgd0Kw9Iz8MeOpKGb4nnAM97vpUq4QQBGfLRIC2ENdzu+7vA5JBFR88hsky/cWaNmJ/EbJauIIDneE7GigMR2HF7kfzdZzOBN4ZEh/ef5NKeCnEieRJJhWRgrgNXVZ44Tqi67AM7ey9pyUtBe7fgzxXtrWXBN9yKaVxxSXm3KJXFQqA6mcilFVZaxMNlAySc4MPTW8lq0ozOCOCunoeIphNz/OVIxGu3/voXFXlBfOKqOkYMVZxMY6OrvtQKBgQD0nIlXK4VW72VaGpz9kxQkRNzJV/yqaqet1GOSlPM2l0RCRFOVVdnvbQdHGPe6+HxHL1dh5MP8T/aHoP+4UXkkQCc8moS2FZxJvFH2QTSZBcSSdGL7GMpROqs38J+XlJzrhNcB20lrW6D7yMeQa4YEcXwdbD8Er/YaIqODBWYYewKBgQCXg+16RLDArciwwhf0TBWZPor2iYFDdwU5UPu7CKOhU1MLfQhG85gGpXHjB6G8cMUi/ezxh/FEl+sWOZegpkPwL5/BQS9tNYWIaC4kipPF/a5Up4DMYUHVAuuPwNqqXpvgU+rGjCns0wtPRnjrkghLkc3oTSID7o7pzUwIk2whDwKBgAys3+EIfExY82OL5X6uVGjcuKQmTw11oWK8krxRw5iclgjpCXu/ix+BAtOIU634mlgF9/02oYE9k4TLrvSaJDDgsifNyfq1e/fGLmkYT+VuCxWbulVQn4s+AwlPCrYMGWWK6KlL9638fYcOjGjLaZJpXwkXRtyzUYlhKh/r87JpAoGBAIavRp2mi/xrPvgpQQPv0k9L8llfOCHRnjoqC+thrZsNp8eRmJcBmMVnskofEZ2iHQuS71pw/n58EQTLo0ayJbhPjVJL8K3CovXzrfjbmqqoa5xi3bJQTiXdF6rMw1QpD6Uk05E1LVuQ6v/IZFr7kBYlAQWb8z3NhQq+bPU+nyLvAoGAGpBbSM8gPzdWQqkHoos0icu3cj0GhN3MU7+1Eb/rsXyh/lk5wtZTEnHjwhdUOUtwVNjvrv7CzA7unhOoaM6YcE/Zpd4zt8pjqH1Mhds7UHf4Xg+A+J4G6meYnhSwfBpOub02ncsqfBlXE0qhFv6AvcMewWndyLb8EYaUUXTYkG0=
|
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQxmQGcaiKjOhayWi+zNTvpp8B5YT8jFFkjLzrD+W+T2Dwf2GfFR4p95zsCJxYeoLWdghMPA6/GMFrLbuVFpaEjuTm4icqA9N8n5d3W0j7gh+wMjZoqyJclAIeb09ut7rY6mWzilA9kWmZnUG7MOWIU70RVRYrfJectCFw/odM9lG4XIVe13X2h+1ecTQyQzLWmnvKFCfo7dQjE7fIYiWfud1ZGUneNs3u73pNWMB6ThGTTCbs0atcgM3fYOg3q7fTxIu9VcaUCJiJ/kNbL9sVEyOrSyx2f2o6w06zdEaOiQFsuDeS8QPYGMg7pf42wAfqCO6hqxQiQT5vp1hvB0o1AgMBAAECggEAIhaEYLwMSispXo8D2cES9iaOU/z91hUX6Qv2Q4anuqqoEZh8nN91Db6etTjFz1NxURvTklelxTsH97t56n26DRY0MWTYgd0Kw9Iz8MeOpKGb4nnAM97vpUq4QQBGfLRIC2ENdzu+7vA5JBFR88hsky/cWaNmJ/EbJauIIDneE7GigMR2HF7kfzdZzOBN4ZEh/ef5NKeCnEieRJJhWRgrgNXVZ44Tqi67AM7ey9pyUtBe7fgzxXtrWXBN9yKaVxxSXm3KJXFQqA6mcilFVZaxMNlAySc4MPTW8lq0ozOCOCunoeIphNz/OVIxGu3/voXFXlBfOKqOkYMVZxMY6OrvtQKBgQD0nIlXK4VW72VaGpz9kxQkRNzJV/yqaqet1GOSlPM2l0RCRFOVVdnvbQdHGPe6+HxHL1dh5MP8T/aHoP+4UXkkQCc8moS2FZxJvFH2QTSZBcSSdGL7GMpROqs38J+XlJzrhNcB20lrW6D7yMeQa4YEcXwdbD8Er/YaIqODBWYYewKBgQCXg+16RLDArciwwhf0TBWZPor2iYFDdwU5UPu7CKOhU1MLfQhG85gGpXHjB6G8cMUi/ezxh/FEl+sWOZegpkPwL5/BQS9tNYWIaC4kipPF/a5Up4DMYUHVAuuPwNqqXpvgU+rGjCns0wtPRnjrkghLkc3oTSID7o7pzUwIk2whDwKBgAys3+EIfExY82OL5X6uVGjcuKQmTw11oWK8krxRw5iclgjpCXu/ix+BAtOIU634mlgF9/02oYE9k4TLrvSaJDDgsifNyfq1e/fGLmkYT+VuCxWbulVQn4s+AwlPCrYMGWWK6KlL9638fYcOjGjLaZJpXwkXRtyzUYlhKh/r87JpAoGBAIavRp2mi/xrPvgpQQPv0k9L8llfOCHRnjoqC+thrZsNp8eRmJcBmMVnskofEZ2iHQuS71pw/n58EQTLo0ayJbhPjVJL8K3CovXzrfjbmqqoa5xi3bJQTiXdF6rMw1QpD6Uk05E1LVuQ6v/IZFr7kBYlAQWb8z3NhQq+bPU+nyLvAoGAGpBbSM8gPzdWQqkHoos0icu3cj0GhN3MU7+1Eb/rsXyh/lk5wtZTEnHjwhdUOUtwVNjvrv7CzA7unhOoaM6YcE/Zpd4zt8pjqH1Mhds7UHf4Xg+A+J4G6meYnhSwfBpOub02ncsqfBlXE0qhFv6AvcMewWndyLb8EYaUUXTYkG0=
|
||||||
publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApHkjwHnoUnZuqbas+ZputyWIfU2WKBFKd+wFwlCZytpQhVA16CGAMCGpgjxUPpqbmOtPy74y0wxmDHB9IaYOVsVmi2SAl1IqfxwUSIllbdvbjBvZFAIQlPa8U/zHJPgdGNHDt/Bwqp5uB0OkcGLB9PYyAXBEKiu6zdTsiZloUrPwgnBRJ0iNHYiWo/oOYD9KfopLA+D1nQjqq8m3ShZe46ecMo6ZCHtQI/HtgL/EGga5KY2zOUi0Wwviu8w79RjjzfdsDkzu5VnBdaSru4awDyiF9nAF+uPgA4ZOdLKkpoEANwuIorDW8tT69Gwh+mYx9sDJMxJf7XOekdPbymomiwIDAQAB
|
publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApHkjwHnoUnZuqbas+ZputyWIfU2WKBFKd+wFwlCZytpQhVA16CGAMCGpgjxUPpqbmOtPy74y0wxmDHB9IaYOVsVmi2SAl1IqfxwUSIllbdvbjBvZFAIQlPa8U/zHJPgdGNHDt/Bwqp5uB0OkcGLB9PYyAXBEKiu6zdTsiZloUrPwgnBRJ0iNHYiWo/oOYD9KfopLA+D1nQjqq8m3ShZe46ecMo6ZCHtQI/HtgL/EGga5KY2zOUi0Wwviu8w79RjjzfdsDkzu5VnBdaSru4awDyiF9nAF+uPgA4ZOdLKkpoEANwuIorDW8tT69Gwh+mYx9sDJMxJf7XOekdPbymomiwIDAQAB
|
||||||
notifyUrl: https://702bc39c.r27.cpolar.top/web/pay/notify
|
notifyUrl: https://253d7236.r27.cpolar.top/web/pay/notify
|
||||||
gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do
|
gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl</artifactId>
|
|
||||||
<version>3.8.8</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>mcwl-comment</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<description>
|
|
||||||
评论模块
|
|
||||||
</description>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 通用工具-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- <!– 资源中心–>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.mcwl</groupId>-->
|
|
||||||
<!-- <artifactId>mcwl-resource</artifactId>-->
|
|
||||||
<!-- <version>3.8.8</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
|
||||||
<version>${mybatis-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mcwl</groupId>
|
|
||||||
<artifactId>mcwl-resource</artifactId>
|
|
||||||
<version>3.8.8</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -341,7 +341,26 @@
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
|
<!-- <artifactId>fastjson</artifactId>-->
|
||||||
|
<!-- <version>1.2.15</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -47,5 +47,10 @@ public class CacheConstants
|
||||||
*/
|
*/
|
||||||
public static final String WX_OPENID_KEY = "wx_openid:";
|
public static final String WX_OPENID_KEY = "wx_openid:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
public static final String WE_CHAT = "we_chat";
|
public static final String WE_CHAT = "we_chat";
|
||||||
|
|
||||||
|
public static final String ID_CARD_COUNT = "id_card_count:";
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,6 @@ public class SysUser extends BaseEntity
|
||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/** 钱包 */
|
|
||||||
private Long wallet;
|
|
||||||
|
|
||||||
/** 帐号状态(0正常 1停用) */
|
/** 帐号状态(0正常 1停用) */
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
@ -98,6 +95,27 @@ public class SysUser extends BaseEntity
|
||||||
/** 简介 */
|
/** 简介 */
|
||||||
private String brief;
|
private String brief;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证
|
||||||
|
*/
|
||||||
|
private String idCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请人id
|
||||||
|
*/
|
||||||
|
private Long inviterUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免费用户积分
|
||||||
|
*/
|
||||||
|
private Double freePoints;
|
||||||
|
|
||||||
|
|
||||||
public SysUser()
|
public SysUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -231,6 +249,22 @@ public class SysUser extends BaseEntity
|
||||||
return delFlag;
|
return delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdCard() {
|
||||||
|
return idCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdCard(String idCard) {
|
||||||
|
this.idCard = idCard;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDelFlag(String delFlag)
|
public void setDelFlag(String delFlag)
|
||||||
{
|
{
|
||||||
this.delFlag = delFlag;
|
this.delFlag = delFlag;
|
||||||
|
@ -314,6 +348,22 @@ public class SysUser extends BaseEntity
|
||||||
this.brief = brief;
|
this.brief = brief;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getInviterUserId() {
|
||||||
|
return inviterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInviterUserId(Long inviterUserId) {
|
||||||
|
this.inviterUserId = inviterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getFreePoints() {
|
||||||
|
return freePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFreePoints(Double freePoints) {
|
||||||
|
this.freePoints = freePoints;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SysUser{" +
|
return "SysUser{" +
|
||||||
|
@ -336,6 +386,10 @@ public class SysUser extends BaseEntity
|
||||||
", postIds=" + Arrays.toString(postIds) +
|
", postIds=" + Arrays.toString(postIds) +
|
||||||
", roleId=" + roleId +
|
", roleId=" + roleId +
|
||||||
", brief='" + brief + '\'' +
|
", brief='" + brief + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", idCard='" + idCard + '\'' +
|
||||||
|
", inviterUserId=" + inviterUserId +
|
||||||
|
", freePoints=" + freePoints +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,328 @@
|
||||||
|
package com.mcwl.common.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.HttpDelete;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.client.methods.HttpPut;
|
||||||
|
import org.apache.http.conn.ClientConnectionManager;
|
||||||
|
import org.apache.http.conn.scheme.Scheme;
|
||||||
|
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||||
|
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||||
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验实名认证信息
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/8
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class HttpUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doGet(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post form
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param bodys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
Map<String, String> bodys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bodys != null) {
|
||||||
|
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||||
|
|
||||||
|
for (String key : bodys.keySet()) {
|
||||||
|
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
|
||||||
|
}
|
||||||
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
|
||||||
|
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
request.setEntity(formEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post String
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post stream
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put String
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put stream
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doDelete(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||||
|
StringBuilder sbUrl = new StringBuilder();
|
||||||
|
sbUrl.append(host);
|
||||||
|
if (!StringUtils.isBlank(path)) {
|
||||||
|
sbUrl.append(path);
|
||||||
|
}
|
||||||
|
if (null != querys) {
|
||||||
|
StringBuilder sbQuery = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> query : querys.entrySet()) {
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbQuery.append("&");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append(query.getValue());
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(query.getKey())) {
|
||||||
|
sbQuery.append(query.getKey());
|
||||||
|
if (!StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append("=");
|
||||||
|
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbUrl.append("?").append(sbQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sbUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpClient wrapClient(String host) {
|
||||||
|
HttpClient httpClient = new DefaultHttpClient();
|
||||||
|
if (host.startsWith("https://")) {
|
||||||
|
sslClient(httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sslClient(HttpClient httpClient) {
|
||||||
|
try {
|
||||||
|
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||||
|
X509TrustManager tm = new X509TrustManager() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.init(null, new TrustManager[]{tm}, null);
|
||||||
|
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
|
||||||
|
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
|
ClientConnectionManager ccm = httpClient.getConnectionManager();
|
||||||
|
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||||
|
registry.register(new Scheme("https", 443, ssf));
|
||||||
|
} catch (KeyManagementException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.mcwl.common.utils;
|
||||||
|
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份证校验
|
||||||
|
*
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/8
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
public class VerifyCard {
|
||||||
|
|
||||||
|
public static String idCard(String name, String card) {
|
||||||
|
String host = "https://kzidcardv1.market.alicloudapi.com";
|
||||||
|
String path = "/api-mall/api/id_card/check";
|
||||||
|
String method = "POST";
|
||||||
|
String appcode = "680661d47eb740bcb85472cec9774ecf";
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||||
|
headers.put("Authorization", "APPCODE " + appcode);
|
||||||
|
//根据API的要求,定义相对应的Content-Type
|
||||||
|
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
Map<String, String> querys = new HashMap<String, String>();
|
||||||
|
Map<String, String> bodys = new HashMap<String, String>();
|
||||||
|
bodys.put("name", name);
|
||||||
|
bodys.put("idcard", card);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* 重要提示如下:
|
||||||
|
* HttpUtils请从
|
||||||
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
||||||
|
* 下载
|
||||||
|
*
|
||||||
|
* 相应的依赖请参照
|
||||||
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||||
|
*/
|
||||||
|
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||||
|
System.out.println(response.toString());
|
||||||
|
//获取response的body
|
||||||
|
//System.out.println(EntityUtils.toString(response.getEntity()));
|
||||||
|
return EntityUtils.toString(response.getEntity());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,14 @@
|
||||||
package com.mcwl.memberCenter.consumer;
|
package com.mcwl.memberCenter.consumer;
|
||||||
|
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.system.domain.SysAdvice;
|
||||||
|
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||||
|
import com.mcwl.system.service.ISysAdviceService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
@ -11,6 +17,7 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分消费者
|
* 积分消费者
|
||||||
|
@ -20,16 +27,27 @@ import java.io.IOException;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EmptyPointsRemindConsumer {
|
public class EmptyPointsRemindConsumer {
|
||||||
|
|
||||||
private final MemberService memberService;
|
private final ISysAdviceService sysAdviceService;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分清零提醒
|
* 积分清零提醒
|
||||||
*/
|
*/
|
||||||
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
|
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
|
||||||
public void emptyPointsRemind(Member Member, Channel channel, Message message) {
|
public void emptyPointsRemind(Member member, Channel channel, Message message) {
|
||||||
try {
|
try {
|
||||||
// TODO 发送短信提醒用户积分即将清零
|
SysUser sysUser = sysUserService.selectUserByUserName("admin");
|
||||||
log.info("获取到积分清零提醒的数据:{}", Member);
|
SysAdvice sysAdvice = new SysAdvice();
|
||||||
|
sysAdvice.setSenderId(sysUser.getUserId());
|
||||||
|
sysAdvice.setReceiverId(member.getUserId());
|
||||||
|
sysAdvice.setType(AdviceEnum.NEW_MESSAGE_REMIND);
|
||||||
|
sysAdvice.setTitle("积分清零提醒");
|
||||||
|
sysAdvice.setContent("您的积分即将清零,请及时消费");
|
||||||
|
sysAdvice.setCreateBy(sysUser.getUserName());
|
||||||
|
sysAdvice.setUpdateBy(sysUser.getUserName());
|
||||||
|
sysAdvice.setUpdateTime(new Date());
|
||||||
|
sysAdviceService.save(sysAdvice);
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("处理积分清零提醒消息时出错: {}", e.getMessage(), e);
|
log.error("处理积分清零提醒消息时出错: {}", e.getMessage(), e);
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package com.mcwl.memberCenter.consumer;
|
package com.mcwl.memberCenter.consumer;
|
||||||
|
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.system.domain.SysAdvice;
|
||||||
|
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||||
|
import com.mcwl.system.service.ISysAdviceService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -19,6 +24,9 @@ import java.io.IOException;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MemberBillingConsumer {
|
public class MemberBillingConsumer {
|
||||||
|
|
||||||
|
private final ISysAdviceService sysAdviceService;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员账单
|
* 会员账单
|
||||||
|
@ -27,7 +35,14 @@ public class MemberBillingConsumer {
|
||||||
public void memberBillingQueue(Member member, Channel channel, Message message) {
|
public void memberBillingQueue(Member member, Channel channel, Message message) {
|
||||||
try {
|
try {
|
||||||
// TODO 发送短信提醒用户会员账单,如果支付成功,更新last_payment_date,并重新计算end_date(start_date + 1个月)
|
// TODO 发送短信提醒用户会员账单,如果支付成功,更新last_payment_date,并重新计算end_date(start_date + 1个月)
|
||||||
log.info("获取到会员账单的数据:{}", member);
|
SysUser sysUser = sysUserService.selectUserByUserName("admin");
|
||||||
|
SysAdvice sysAdvice = new SysAdvice();
|
||||||
|
sysAdvice.setSenderId(sysUser.getUserId());
|
||||||
|
sysAdvice.setReceiverId(member.getUserId());
|
||||||
|
sysAdvice.setType(AdviceEnum.NEW_MESSAGE_REMIND);
|
||||||
|
sysAdvice.setTitle("会员账单");
|
||||||
|
sysAdvice.setContent("您的会员即将到期,请及时支付");
|
||||||
|
sysAdviceService.save(sysAdvice);
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("处理会员账单消息时出错: {}", e.getMessage(), e);
|
log.error("处理会员账单消息时出错: {}", e.getMessage(), e);
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.mcwl.memberCenter.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("mem_recharge_record")
|
||||||
|
public class RechargeRecord extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值金额
|
||||||
|
*/
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取到的积分
|
||||||
|
*/
|
||||||
|
private Double points;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.memberCenter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值记录 Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RechargeRecordMapper extends BaseMapper<RechargeRecord> {
|
||||||
|
}
|
|
@ -35,4 +35,10 @@ public interface MemberService extends IService<Member> {
|
||||||
Member rechargePoints(Long userId, Double points);
|
Member rechargePoints(Long userId, Double points);
|
||||||
|
|
||||||
Member latestSubscription(Long userId);
|
Member latestSubscription(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费积分
|
||||||
|
* @param consumePoints 消费积分
|
||||||
|
*/
|
||||||
|
void consumePoints(Double consumePoints);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mcwl.memberCenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface RechargeRecordService extends IService<RechargeRecord> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,26 +1,24 @@
|
||||||
package com.mcwl.memberCenter.service.impl;
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.exception.ServiceException;
|
import com.mcwl.common.exception.ServiceException;
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.*;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
|
||||||
import com.mcwl.memberCenter.domain.Promotion;
|
|
||||||
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||||
import com.mcwl.memberCenter.enums.MemberEnum;
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
|
import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
|
||||||
import com.mcwl.memberCenter.enums.PromotionEnum;
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
import com.mcwl.memberCenter.mapper.MemberMapper;
|
import com.mcwl.memberCenter.mapper.MemberMapper;
|
||||||
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
import com.mcwl.memberCenter.service.*;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
|
||||||
import com.mcwl.memberCenter.service.PromotionService;
|
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -37,6 +35,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
|
|
||||||
private final PromotionMapper promotionMapper;
|
private final PromotionMapper promotionMapper;
|
||||||
|
|
||||||
|
private final MemberConsumeService memberConsumeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) {
|
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) {
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
@ -172,6 +172,60 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void consumePoints(Double consumePoints) {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
Member member = this.getUseUserMemberByUserId(userId);
|
||||||
|
// 用户的免费积分
|
||||||
|
Double freePoints = sysUser.getFreePoints();
|
||||||
|
// 会员积分
|
||||||
|
Double memberPoints = 0.0;
|
||||||
|
if (member != null) {
|
||||||
|
memberPoints = member.getPoints();
|
||||||
|
}
|
||||||
|
// 获取用户的总积分
|
||||||
|
double points = freePoints + memberPoints;
|
||||||
|
if (points < consumePoints) {
|
||||||
|
throw new ServiceException("积分不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存消费记录
|
||||||
|
saveMemberConsume(consumePoints, userId, points);
|
||||||
|
|
||||||
|
// 先扣除会员的积分
|
||||||
|
if (member != null) {
|
||||||
|
double mp = member.getPoints() - consumePoints;
|
||||||
|
if (mp >= 0) {
|
||||||
|
member.setPoints(mp);
|
||||||
|
consumePoints = 0.0;
|
||||||
|
} else {
|
||||||
|
member.setPoints(0D);
|
||||||
|
consumePoints = consumePoints - memberPoints;
|
||||||
|
}
|
||||||
|
baseMapper.updateById(member);
|
||||||
|
}
|
||||||
|
// consumePoints有剩余再扣除用户的积分
|
||||||
|
if (consumePoints > 0) {
|
||||||
|
sysUser.setFreePoints(freePoints - consumePoints);
|
||||||
|
sysUserService.updateUser(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveMemberConsume(Double consumePoints, Long userId, double points) {
|
||||||
|
MemberConsume memberConsume = new MemberConsume();
|
||||||
|
memberConsume.setUserId(userId);
|
||||||
|
memberConsume.setConsumePoints(consumePoints);
|
||||||
|
memberConsume.setRemainingPoints(points - consumePoints);
|
||||||
|
memberConsume.setConsumeTime(new Date());
|
||||||
|
memberConsume.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
memberConsume.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
memberConsume.setUpdateTime(new Date());
|
||||||
|
memberConsumeService.save(memberConsume);
|
||||||
|
}
|
||||||
|
|
||||||
private List<Member> getUseUserMember(Long userId) {
|
private List<Member> getUseUserMember(Long userId) {
|
||||||
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
||||||
// subscriptionStatus 不为 "过期" 或 "待支付"
|
// subscriptionStatus 不为 "过期" 或 "待支付"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
|
import com.mcwl.memberCenter.mapper.RechargeRecordMapper;
|
||||||
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.RechargeRecordService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RechargeRecordServiceImpl extends ServiceImpl<RechargeRecordMapper, RechargeRecord> implements RechargeRecordService {
|
||||||
|
|
||||||
|
}
|
|
@ -2,13 +2,17 @@ package com.mcwl.memberCenter.task;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.enums.MemberEnum;
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,6 +23,8 @@ public class UserMemberTask {
|
||||||
|
|
||||||
private final MemberService memberService;
|
private final MemberService memberService;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
private final RabbitTemplate rabbitTemplate;
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,14 +47,23 @@ public class UserMemberTask {
|
||||||
/**
|
/**
|
||||||
* 清空积分 每月月底前两天
|
* 清空积分 每月月底前两天
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
public void emptyPointsTsk() {
|
public void emptyPointsTsk() {
|
||||||
List<Member> memberList = memberService.getUseUserMember();
|
List<Member> memberList = memberService.getUseUserMember();
|
||||||
|
List<Long> userIdList = new ArrayList<>();
|
||||||
|
List<SysUser> sysUserList = new ArrayList<>();
|
||||||
if (memberList == null || memberList.isEmpty()) {
|
if (memberList == null || memberList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Member member : memberList) {
|
for (Member member : memberList) {
|
||||||
member.setPoints(0.0);
|
member.setPoints(0.0);
|
||||||
member.setUpdateTime(new Date());
|
member.setUpdateTime(new Date());
|
||||||
|
userIdList.add(member.getUserId());
|
||||||
|
}
|
||||||
|
sysUserList = sysUserService.listByIds(userIdList);
|
||||||
|
for (SysUser sysUser : sysUserList) {
|
||||||
|
sysUser.setFreePoints(0.0);
|
||||||
|
sysUserService.updateUser(sysUser);
|
||||||
}
|
}
|
||||||
memberService.updateBatchById(memberList);
|
memberService.updateBatchById(memberList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,23 @@
|
||||||
<artifactId>mcwl-common</artifactId>
|
<artifactId>mcwl-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-myInvitation</artifactId>
|
||||||
|
<version>3.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-memberCenter</artifactId>
|
||||||
|
<version>3.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
@ -36,6 +53,12 @@
|
||||||
<groupId>com.mcwl</groupId>
|
<groupId>com.mcwl</groupId>
|
||||||
<artifactId>mcwl-system</artifactId>
|
<artifactId>mcwl-system</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-resource</artifactId>
|
||||||
|
<version>3.8.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.mcwl.pay.config;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@Component
|
||||||
|
public class AliConfig {
|
||||||
|
@Value("${mall.mgt.aliPayConfig.appId}")
|
||||||
|
private String appId;
|
||||||
|
@Value("${mall.mgt.aliPayConfig.privateKey}")
|
||||||
|
private String privateKey;
|
||||||
|
@Value("${mall.mgt.aliPayConfig.publicKey}")
|
||||||
|
private String publicKey;
|
||||||
|
@Value("${mall.mgt.aliPayConfig.gatewayUrl}")
|
||||||
|
private String gatewayUrl;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.mcwl.pay.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderTradeDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
private Integer productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付金额
|
||||||
|
*/
|
||||||
|
private Double paymentAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单类型 member/points
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动id
|
||||||
|
*/
|
||||||
|
private Long promotionId;
|
||||||
|
}
|
|
@ -3,10 +3,9 @@ package com.mcwl.pay.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.domain.PaymentResult;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -25,4 +24,7 @@ public interface OrderTradeService extends IService<OrderTrade> {
|
||||||
|
|
||||||
int updateMallProduct(OrderTrade orderTrade);
|
int updateMallProduct(OrderTrade orderTrade);
|
||||||
|
|
||||||
|
|
||||||
|
void orderHandler(OrderTrade orderTrade, String suffix, Map<String, String> params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,31 @@
|
||||||
package com.mcwl.pay.service.impl;
|
package com.mcwl.pay.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
|
import com.mcwl.common.utils.DateUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.memberCenter.service.RechargeRecordService;
|
||||||
|
import com.mcwl.myInvitation.domain.Commission;
|
||||||
|
import com.mcwl.myInvitation.domain.Consume;
|
||||||
|
import com.mcwl.myInvitation.service.CommissionService;
|
||||||
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.domain.PaymentResult;
|
|
||||||
import com.mcwl.pay.domain.enums.PaymentStatus;
|
|
||||||
import com.mcwl.pay.mapper.OrderTradeMapper;
|
import com.mcwl.pay.mapper.OrderTradeMapper;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
|
import com.mcwl.resource.domain.enums.OrderTypeEnum;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.system.service.impl.SysUserServiceImpl;
|
import com.mcwl.system.service.impl.SysUserServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -30,14 +38,32 @@ import java.util.Objects;
|
||||||
@Service
|
@Service
|
||||||
public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTrade> implements OrderTradeService {
|
public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTrade> implements OrderTradeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderTradeMapper orderTradeMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserServiceImpl userExtensionService;
|
private SysUserServiceImpl userExtensionService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderTradeService orderTradeService;
|
private OrderTradeService orderTradeService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderTradeMapper orderTradeMapper;
|
private CommissionService commissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConsumeService consumeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RechargeRecordService rechargeRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
||||||
|
@ -96,6 +122,109 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
return orderTradeMapper.updateById(orderTrade);
|
return orderTradeMapper.updateById(orderTrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void orderHandler(OrderTrade orderTrade, String suffix, Map<String, String> params) {
|
||||||
|
this.orderHandler(orderTrade, params);
|
||||||
|
if (OrderTypeEnum.POINTS.getName().equals(suffix)) {
|
||||||
|
pointsHandler(orderTrade, params);
|
||||||
|
} else if (OrderTypeEnum.MEMBER.getName().equals(suffix)) {
|
||||||
|
Long promotionId = redisCache.getCacheObject(params.get("out_trade_no") + "promotionId");
|
||||||
|
memberHandler(orderTrade, promotionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pointsHandler(OrderTrade orderTrade, Map<String, String> params) {
|
||||||
|
|
||||||
|
// 获取支付金额
|
||||||
|
String amount = params.get("buyer_pay_amount");
|
||||||
|
Double points = Double.parseDouble(amount) * 100;
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
SysUser user = sysUserService.selectUserById(userId);
|
||||||
|
user.setFreePoints(user.getFreePoints() + points);
|
||||||
|
sysUserService.updateUser(user);
|
||||||
|
|
||||||
|
// 添加充值记录
|
||||||
|
RechargeRecord rechargeRecord = new RechargeRecord();
|
||||||
|
rechargeRecord.setUserId(userId);
|
||||||
|
rechargeRecord.setCode(orderTrade.getCode());
|
||||||
|
rechargeRecord.setAmount(Double.parseDouble(amount));
|
||||||
|
rechargeRecord.setPoints(points);
|
||||||
|
rechargeRecord.setCreateBy(user.getUserName());
|
||||||
|
rechargeRecord.setUpdateBy(user.getUserName());
|
||||||
|
rechargeRecord.setUpdateTime(new Date());
|
||||||
|
rechargeRecordService.save(rechargeRecord);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void memberHandler(OrderTrade orderTrade, Long promotionId) {
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
Integer memberLevelId = orderTrade.getProductId();
|
||||||
|
String paymentMethod = "aliPay";
|
||||||
|
|
||||||
|
memberService.createUserMember(userId, memberLevelId.longValue(), paymentMethod, promotionId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void productHandler(OrderTrade orderTrade) {
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
double amount = 0.0;
|
||||||
|
// 通过sysUser获取邀请人id
|
||||||
|
Long inviterUserId = sysUser.getInviterUserId();
|
||||||
|
if (Objects.nonNull(inviterUserId)) {
|
||||||
|
amount = 0.5; // 固定0.5元提成
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 保存消费表
|
||||||
|
Consume consume = new Consume();
|
||||||
|
consume.setUserId(userId);
|
||||||
|
consume.setAmount(Double.valueOf(orderTrade.getPaymentAmount()));
|
||||||
|
consume.setConsumeDate(orderTrade.getOrderTime());
|
||||||
|
consume.setCreateBy(orderTrade.getUserName());
|
||||||
|
consume.setUpdateBy(orderTrade.getUserName());
|
||||||
|
consume.setCreateTime(new Date());
|
||||||
|
consume.setUpdateTime(new Date());
|
||||||
|
consume.setRemark("购买商品");
|
||||||
|
consumeService.save(consume);
|
||||||
|
|
||||||
|
|
||||||
|
// 保存提成表
|
||||||
|
Commission commission = new Commission();
|
||||||
|
commission.setConsumeId(inviterUserId);
|
||||||
|
commission.setAmount(amount);
|
||||||
|
commission.setPayStatus(0);
|
||||||
|
commission.setCreateBy(sysUser.getUserName());
|
||||||
|
commission.setUpdateBy(sysUser.getUserName());
|
||||||
|
commission.setCreateTime(new Date());
|
||||||
|
commission.setUpdateTime(new Date());
|
||||||
|
commission.setRemark("提成");
|
||||||
|
commissionService.save(commission);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void orderHandler(OrderTrade orderTrade, Map<String, String> params) {
|
||||||
|
// 更新订单状态
|
||||||
|
// 支付宝交易凭证号
|
||||||
|
orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
|
orderTrade.setTransactionId(1);
|
||||||
|
orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
|
orderTrade.setOrderStatus(3);
|
||||||
|
orderTrade.setPayStatus(2);
|
||||||
|
String totalAmountStr = params.get("total_amount");
|
||||||
|
if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
|
BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
|
orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
|
}
|
||||||
|
String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
|
if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
|
BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
|
orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
|
}
|
||||||
|
orderTradeService.save(orderTrade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型评论
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@TableName("model_comment")
|
||||||
|
public class ModelComment extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型id
|
||||||
|
*/
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父评论id
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞数
|
||||||
|
*/
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型评论点赞
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@TableName("model_comment_like")
|
||||||
|
public class ModelCommentLike extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型评论id
|
||||||
|
*/
|
||||||
|
private Long modelCommentId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
package com.mcwl.resource.domain;
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**图片表
|
/**图片表
|
||||||
|
@ -16,47 +19,66 @@ import lombok.NoArgsConstructor;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("model_image")
|
@TableName("model_image")
|
||||||
public class ModelImage {
|
public class ModelImage extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主键ID
|
* 主键ID
|
||||||
*/
|
*/
|
||||||
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 图片地址(最多8张,切割)
|
* 图片地址(最多8张,切割)
|
||||||
*/
|
*/
|
||||||
private Long image_paths;
|
private String imagePaths;
|
||||||
/**
|
/**
|
||||||
* 是否添加水印
|
* 是否添加水印
|
||||||
*/
|
*/
|
||||||
private Long has_watermark;
|
private Integer hasWatermark;
|
||||||
/**
|
/**
|
||||||
* 是否会员下载
|
* 是否会员下载
|
||||||
*/
|
*/
|
||||||
private Long is_member_download;
|
private Integer isMemberDownload;
|
||||||
/**
|
/**
|
||||||
* 是否不可下载
|
* 是否不可下载
|
||||||
*/
|
*/
|
||||||
private Long is_not_downloadable;
|
private Integer isNotDownloadable;
|
||||||
/**
|
/**
|
||||||
* 是否隐藏生成信息
|
* 是否隐藏生成信息
|
||||||
*/
|
*/
|
||||||
private Long hide_gen_info;
|
private Integer hideGenInfo;
|
||||||
/**
|
/**
|
||||||
* 图片标题(最多30字)
|
* 图片标题(最多30字)
|
||||||
*/
|
*/
|
||||||
private Long title;
|
private String title;
|
||||||
/**
|
/**
|
||||||
* 图片标签(多个,切割)
|
* 图片标签(多个,切割)
|
||||||
*/
|
*/
|
||||||
private Long tags;
|
private String tags;
|
||||||
/**
|
/**
|
||||||
* 描述信息(最多500)
|
* 描述信息(最多500)
|
||||||
*/
|
*/
|
||||||
private Long description;
|
private String description;
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 在线生成数
|
||||||
*/
|
*/
|
||||||
private Long del_flag;
|
private Integer onlineGenNum;
|
||||||
|
/**
|
||||||
|
* 下载数
|
||||||
|
*/
|
||||||
|
private Integer downloadNum;
|
||||||
|
/**
|
||||||
|
* 返图数
|
||||||
|
*/
|
||||||
|
private Integer returnNum;
|
||||||
|
/**
|
||||||
|
* 点赞数
|
||||||
|
*/
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片评论
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("model_image_comment")
|
||||||
|
public class ModelImageComment extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片id
|
||||||
|
*/
|
||||||
|
private Long modelImageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父评论id
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞数
|
||||||
|
*/
|
||||||
|
private Integer likeNum;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片评论点赞
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("model_image_comment_like")
|
||||||
|
public class ModelImageCommentLike extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片评论id
|
||||||
|
*/
|
||||||
|
private Long modelImageCommentId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片点赞表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ModelImageLike extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片id
|
||||||
|
*/
|
||||||
|
private Long modelImageId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.mcwl.resource.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型点赞表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@TableName("model_like")
|
||||||
|
public class ModelLike extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型id
|
||||||
|
*/
|
||||||
|
private Long modelId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.mcwl.resource.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ModelImageCommentRes {
|
||||||
|
/**
|
||||||
|
* 图片id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "图片id不能为空")
|
||||||
|
private Long modelImageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "评论内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父评论id
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.mcwl.resource.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ModelImageRes {
|
||||||
|
/**
|
||||||
|
* 图片地址(最多8张,切割)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "图片地址不能为空")
|
||||||
|
private String imagePaths;
|
||||||
|
/**
|
||||||
|
* 是否添加水印
|
||||||
|
*/
|
||||||
|
private Integer hasWatermark;
|
||||||
|
/**
|
||||||
|
* 是否会员下载
|
||||||
|
*/
|
||||||
|
private Integer isMemberDownload;
|
||||||
|
/**
|
||||||
|
* 是否不可下载
|
||||||
|
*/
|
||||||
|
private Integer isNotDownloadable;
|
||||||
|
/**
|
||||||
|
* 是否隐藏生成信息
|
||||||
|
*/
|
||||||
|
private Integer hideGenInfo;
|
||||||
|
/**
|
||||||
|
* 图片标题(最多30字)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "图片标题不能为空")
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 图片标签(多个,切割)
|
||||||
|
*/
|
||||||
|
private String tags;
|
||||||
|
/**
|
||||||
|
* 描述信息(最多500)
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,10 @@ package com.mcwl.resource.domain.enums;
|
||||||
* @Date:2025/1/6 19:51
|
* @Date:2025/1/6 19:51
|
||||||
*/
|
*/
|
||||||
public enum OrderTypeEnum {
|
public enum OrderTypeEnum {
|
||||||
TIME("time"), NUM("num");
|
TIME("time"),
|
||||||
|
NUM("num"),
|
||||||
|
POINTS("points"),
|
||||||
|
MEMBER("member");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelCommentLike;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.mapper
|
||||||
|
* @Filename:ModelCommentLikeMapper
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:02
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ModelCommentLikeMapper extends BaseMapper<ModelCommentLike> {
|
||||||
|
ModelCommentLike getLikeComment(@Param("userId") Long userId, @Param("commentId") Long commentId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.mapper
|
||||||
|
* @Filename:ModelCommentMapper
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:04
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ModelCommentMapper extends BaseMapper<ModelComment> {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ModelImageCommentLikeMapper extends BaseMapper<ModelImageCommentLike> {
|
||||||
|
ModelImageCommentLike getLikeImageComment(Long userId, Long commentId);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ModelImageCommentMapper extends BaseMapper<ModelImageComment> {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ModelImageLikeMapper extends BaseMapper<ModelImageLike> {
|
||||||
|
ModelImageLike getLikeImage(Long userId, Long imageId);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ModelImageMapper extends BaseMapper<ModelImage> {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.ModelLike;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.mapper
|
||||||
|
* @Filename:ModelLikeMapper
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:05
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ModelLikeMapper extends BaseMapper<ModelLike> {
|
||||||
|
ModelLike getLike(@Param("userId") Long userId, @Param("modelId") Long modelId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.WorkFlow;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface WorkFlowMapper extends BaseMapper<WorkFlow> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mcwl.resource.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.resource.domain.WorkFlowVersion;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流版本 业务实现层
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface WorkFlowVersionMapper extends BaseMapper<WorkFlowVersion> {
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelCommentLike;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service
|
||||||
|
* @Filename:ModelCommentLikeService
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 11:58
|
||||||
|
*/
|
||||||
|
public interface ModelCommentLikeService extends IService<ModelCommentLike> {
|
||||||
|
void like(Long commentId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service
|
||||||
|
* @Filename:ModelCommentService
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 11:58
|
||||||
|
*/
|
||||||
|
public interface ModelCommentService extends IService<ModelComment> {
|
||||||
|
void comment(ModelComment modelComment);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ModelImageCommentLikeService extends IService<ModelImageCommentLike> {
|
||||||
|
void like(Long commentId);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ModelImageCommentService extends IService<ModelImageComment> {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ModelImageLikeService extends IService<ModelImageLike> {
|
||||||
|
|
||||||
|
void like(Long imageId);
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ModelImageService extends IService<ModelImage> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布
|
||||||
|
* @param modelImageRes 发布对象
|
||||||
|
*/
|
||||||
|
void publish(ModelImageRes modelImageRes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论
|
||||||
|
* @param modelImageCommentRes 评论对象
|
||||||
|
*/
|
||||||
|
void comment(ModelImageCommentRes modelImageCommentRes);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.resource.domain.ModelLike;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service
|
||||||
|
* @Filename:ModelLikeService
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 11:57
|
||||||
|
*/
|
||||||
|
public interface ModelLikeService extends IService<ModelLike> {
|
||||||
|
|
||||||
|
|
||||||
|
void like(Long imageId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流 业务层
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface WorkFlowService {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.resource.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流版本 业务层
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface WorkFlowVersionService {
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**模型 业务实现层
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
* @Package:com.mcwl.resource.service.impl
|
* @Package:com.mcwl.resource.service.impl
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.domain.ModelCommentLike;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
|
import com.mcwl.resource.mapper.ModelCommentLikeMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelCommentMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
|
import com.mcwl.resource.service.ModelCommentLikeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service.impl
|
||||||
|
* @Filename:ModelCommentLikeServiceImpl
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMapper,ModelCommentLike> implements ModelCommentLikeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelCommentMapper modelCommentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void like(Long commentId) {
|
||||||
|
ModelComment modelComment = modelCommentMapper.selectById(commentId);
|
||||||
|
if (Objects.isNull(modelComment)) {
|
||||||
|
throw new ServiceException("该评论不存在");
|
||||||
|
}
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
ModelCommentLike modelCommentLike = baseMapper.getLikeComment(userId, commentId);
|
||||||
|
if (Objects.nonNull(modelCommentLike)) {
|
||||||
|
if (Objects.equals(modelCommentLike.getDelFlag(), "0")) {
|
||||||
|
modelCommentLike.setDelFlag("1");
|
||||||
|
modelComment.setLikeNum(modelComment.getLikeNum() - 1);
|
||||||
|
} else {
|
||||||
|
modelCommentLike.setDelFlag("0");
|
||||||
|
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
|
||||||
|
}
|
||||||
|
// 更新点赞记录
|
||||||
|
baseMapper.updateById(modelCommentLike);
|
||||||
|
// 更新图片评论点赞数
|
||||||
|
modelCommentMapper.updateById(modelComment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加点赞记录
|
||||||
|
modelCommentLike = new ModelCommentLike();
|
||||||
|
modelCommentLike.setUserId(userId);
|
||||||
|
modelCommentLike.setModelCommentId(commentId);
|
||||||
|
modelCommentLike.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelCommentLike.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelCommentLike.setUpdateTime(new Date());
|
||||||
|
baseMapper.insert(modelCommentLike);
|
||||||
|
|
||||||
|
// 更新模型点赞数
|
||||||
|
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
|
||||||
|
modelCommentMapper.updateById(modelComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.mapper.ModelCommentMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
|
import com.mcwl.resource.service.ModelCommentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service.impl
|
||||||
|
* @Filename:ModelCommentServiceImpl
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, ModelComment> implements ModelCommentService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelCommentMapper modelCommentMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelImageMapper modelImageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void comment(ModelComment modelComment) {
|
||||||
|
Long parentId = modelComment.getParentId();
|
||||||
|
ModelComment mic = modelCommentMapper.selectById(parentId);
|
||||||
|
|
||||||
|
if (Objects.nonNull(parentId) && Objects.isNull(mic)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modelComment.setUserId(SecurityUtils.getUserId());
|
||||||
|
modelComment.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelComment.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelComment.setUpdateTime(new Date());
|
||||||
|
modelCommentMapper.insert(modelComment);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentLikeMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
|
import com.mcwl.resource.service.ModelImageCommentLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelImageCommentService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageCommentLikeMapper, ModelImageCommentLike> implements ModelImageCommentLikeService {
|
||||||
|
|
||||||
|
private final ModelImageCommentMapper modelImageCommentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void like(Long commentId) {
|
||||||
|
ModelImageComment modelImageComment = modelImageCommentMapper.selectById(commentId);
|
||||||
|
if (Objects.isNull(modelImageComment)) {
|
||||||
|
throw new ServiceException("该评论不存在");
|
||||||
|
}
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
ModelImageCommentLike modelImageCommentLike = baseMapper.getLikeImageComment(userId, commentId);
|
||||||
|
if (Objects.nonNull(modelImageCommentLike)) {
|
||||||
|
if (Objects.equals(modelImageCommentLike.getDelFlag(), "0")) {
|
||||||
|
modelImageCommentLike.setDelFlag("1");
|
||||||
|
modelImageComment.setLikeNum(modelImageComment.getLikeNum() - 1);
|
||||||
|
} else {
|
||||||
|
modelImageCommentLike.setDelFlag("0");
|
||||||
|
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
||||||
|
}
|
||||||
|
// 更新点赞记录
|
||||||
|
baseMapper.updateById(modelImageCommentLike);
|
||||||
|
// 更新图片评论点赞数
|
||||||
|
modelImageCommentMapper.updateById(modelImageComment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加点赞记录
|
||||||
|
modelImageCommentLike = new ModelImageCommentLike();
|
||||||
|
modelImageCommentLike.setUserId(userId);
|
||||||
|
modelImageCommentLike.setModelImageCommentId(commentId);
|
||||||
|
modelImageCommentLike.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageCommentLike.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageCommentLike.setUpdateTime(new Date());
|
||||||
|
baseMapper.insert(modelImageCommentLike);
|
||||||
|
|
||||||
|
// 更新图片点赞数
|
||||||
|
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
|
||||||
|
modelImageCommentMapper.updateById(modelImageComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
|
import com.mcwl.resource.service.ModelImageCommentService;
|
||||||
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentMapper, ModelImageComment> implements ModelImageCommentService {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageLike;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageLikeMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
|
import com.mcwl.resource.service.ModelImageLikeService;
|
||||||
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper, ModelImageLike> implements ModelImageLikeService {
|
||||||
|
|
||||||
|
private final ModelImageMapper modelImageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void like(Long imageId) {
|
||||||
|
ModelImage modelImage = modelImageMapper.selectById(imageId);
|
||||||
|
if (Objects.isNull(modelImage)) {
|
||||||
|
throw new ServiceException("该图片不存在或已下架");
|
||||||
|
}
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
ModelImageLike modelImageLike = baseMapper.getLikeImage(userId, imageId);
|
||||||
|
if (Objects.nonNull(modelImageLike)) {
|
||||||
|
if (Objects.equals(modelImageLike.getDelFlag(), "0")) {
|
||||||
|
modelImageLike.setDelFlag("1");
|
||||||
|
modelImage.setLikeNum(modelImage.getLikeNum() - 1);
|
||||||
|
} else {
|
||||||
|
modelImageLike.setDelFlag("0");
|
||||||
|
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||||
|
}
|
||||||
|
// 更新点赞记录
|
||||||
|
baseMapper.updateById(modelImageLike);
|
||||||
|
// 更新图片点赞数
|
||||||
|
modelImageMapper.updateById(modelImage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加点赞记录
|
||||||
|
modelImageLike = new ModelImageLike();
|
||||||
|
modelImageLike.setUserId(userId);
|
||||||
|
modelImageLike.setModelImageId(imageId);
|
||||||
|
modelImageLike.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageLike.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageLike.setUpdateTime(new Date());
|
||||||
|
baseMapper.insert(modelImageLike);
|
||||||
|
|
||||||
|
// 更新图片点赞数
|
||||||
|
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
|
||||||
|
modelImageMapper.updateById(modelImage);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageCommentRes;
|
||||||
|
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageCommentMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelImageMapper;
|
||||||
|
import com.mcwl.resource.service.ModelImageService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelImage> implements ModelImageService {
|
||||||
|
|
||||||
|
private final ModelImageCommentMapper modelImageCommentMapper;
|
||||||
|
|
||||||
|
private final ModelImageMapper modelImageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void comment(ModelImageCommentRes modelImageCommentRes) {
|
||||||
|
Long parentId = modelImageCommentRes.getParentId();
|
||||||
|
ModelImageComment mic = modelImageCommentMapper.selectById(parentId);
|
||||||
|
|
||||||
|
if (Objects.nonNull(parentId) && Objects.isNull(mic)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelImageComment modelImageComment = new ModelImageComment();
|
||||||
|
BeanUtil.copyProperties(modelImageCommentRes, modelImageComment);
|
||||||
|
modelImageComment.setUserId(SecurityUtils.getUserId());
|
||||||
|
modelImageComment.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageComment.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelImageComment.setUpdateTime(new Date());
|
||||||
|
modelImageCommentMapper.insert(modelImageComment);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void publish(ModelImageRes modelImageRes) {
|
||||||
|
|
||||||
|
ModelImage modelImage = new ModelImage();
|
||||||
|
BeanUtil.copyProperties(modelImageRes, modelImage);
|
||||||
|
modelImage.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelImage.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelImage.setUpdateTime(new Date());
|
||||||
|
modelImage.setStatus(3);
|
||||||
|
modelImageMapper.insert(modelImage);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.*;
|
||||||
|
import com.mcwl.resource.domain.vo.MallProductVo;
|
||||||
|
import com.mcwl.resource.mapper.MallProductMapper;
|
||||||
|
import com.mcwl.resource.mapper.ModelLikeMapper;
|
||||||
|
import com.mcwl.resource.service.ModelLikeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import springfox.documentation.swagger2.mappers.ModelMapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.resource.service.impl
|
||||||
|
* @Filename:ModelLikeServiceImpl
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/1/12 12:05
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike> implements ModelLikeService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MallProductMapper mallProductMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void like(Long modelId) {
|
||||||
|
ModelProduct model = mallProductMapper.selectById(modelId);
|
||||||
|
if (Objects.isNull(model)) {
|
||||||
|
throw new ServiceException("该模型不存在或已下架");
|
||||||
|
}
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
ModelLike modelLike = baseMapper.getLike(userId, modelId);
|
||||||
|
if (Objects.nonNull(modelLike)) {
|
||||||
|
if (Objects.equals(modelLike.getDelFlag(), "0")) {
|
||||||
|
modelLike.setDelFlag("1");
|
||||||
|
model.setNumbers(model.getNumbers() - 1);
|
||||||
|
} else {
|
||||||
|
modelLike.setDelFlag("0");
|
||||||
|
model.setNumbers(model.getNumbers() + 1);
|
||||||
|
}
|
||||||
|
// 更新点赞记录
|
||||||
|
baseMapper.updateById(modelLike);
|
||||||
|
// 更新图片点赞数
|
||||||
|
mallProductMapper.updateById(model);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加点赞记录
|
||||||
|
modelLike = new ModelLike();
|
||||||
|
modelLike.setUserId(userId);
|
||||||
|
modelLike.setModelId(modelId);
|
||||||
|
modelLike.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
modelLike.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
modelLike.setUpdateTime(new Date());
|
||||||
|
baseMapper.insert(modelLike);
|
||||||
|
|
||||||
|
// 更新图片点赞数
|
||||||
|
model.setNumbers(model.getNumbers() + 1);
|
||||||
|
mallProductMapper.updateById(model);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**模型版本 业务实现层
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
* @Package:com.mcwl.resource.service.impl
|
* @Package:com.mcwl.resource.service.impl
|
||||||
|
|
|
@ -71,9 +71,8 @@ public class SysUserAttentionServiceImpl implements SysUserAttentionService {
|
||||||
public SysUserInfo selectUserInfo() {
|
public SysUserInfo selectUserInfo() {
|
||||||
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId))
|
return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId))
|
||||||
.download(mallProductMapper.sumNumber(userId))
|
// .download(mallProductMapper.sumNumber(userId))
|
||||||
.likeCount(mallProductLikeMapper.countLike(userId))
|
.likeCount(mallProductLikeMapper.countLike(userId))
|
||||||
.attention(sysUserAttentionMapper.selectAttentionCount(userId)).build();
|
.attention(sysUserAttentionMapper.selectAttentionCount(userId)).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**活动 业务实现层
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
* @Package:com.mcwl.resource.service
|
* @Package:com.mcwl.resource.service
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.mcwl.resource.service.WorkFlowService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流 业务实现层
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WorkFlowServiceImpl implements WorkFlowService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
|
import com.mcwl.resource.service.WorkFlowService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作流版本 业务实现层
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/1/9
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WorkFlowVersionServiceImpl implements WorkFlowService {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.ModelCommentLikeMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getLikeComment" resultType="com.mcwl.resource.domain.ModelCommentLike">
|
||||||
|
select id,
|
||||||
|
user_id,
|
||||||
|
model_comment_id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
del_flag,
|
||||||
|
remark where user_id = #{userId} and model_comment_id = #{commentId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.ModelImageCommentLikeMapper">
|
||||||
|
|
||||||
|
<resultMap type="modelImageCommentLike" id="ModelImageCommentLikeResult">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="modelImageCommentId" column="model_image_comment_id"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="selectModelImageCommentLikeVo">
|
||||||
|
select id,
|
||||||
|
user_id,
|
||||||
|
model_image_comment_id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
del_flag,
|
||||||
|
remark
|
||||||
|
from model_image_comment_like
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="getLikeImageComment" resultMap="ModelImageCommentLikeResult">
|
||||||
|
<include refid="selectModelImageCommentLikeVo"/>
|
||||||
|
where user_id = #{userId}
|
||||||
|
and model_image_comment_id = #{imageId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.ModelImageLikeMapper">
|
||||||
|
|
||||||
|
<resultMap type="modelImageLike" id="ModelImageLikeResult">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="modelImageId" column="model_image_id"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="selectModelImageLikeVo">
|
||||||
|
select id,
|
||||||
|
user_id,
|
||||||
|
model_image_id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
del_flag,
|
||||||
|
remark
|
||||||
|
from model_image_like
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="getLikeImage" resultMap="ModelImageLikeResult">
|
||||||
|
<include refid="selectModelImageLikeVo"/>
|
||||||
|
where user_id = #{userId}
|
||||||
|
and model_image_id = #{imageId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.resource.mapper.ModelLikeMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getLike" resultType="com.mcwl.resource.domain.ModelLike">
|
||||||
|
select id,
|
||||||
|
user_id,
|
||||||
|
model_id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
del_flag,
|
||||||
|
remark where user_id = #{userId} and model_id = #{modelId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.mcwl.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息通知
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_advice")
|
||||||
|
public class SysAdvice extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者id
|
||||||
|
*/
|
||||||
|
private Long senderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者id
|
||||||
|
*/
|
||||||
|
private Long receiverId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型 表示新消息提醒,系统公告等
|
||||||
|
*/
|
||||||
|
private AdviceEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已读 0 是 1 否
|
||||||
|
*/
|
||||||
|
private String isRead;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.mcwl.system.domain.enums;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知枚举
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum AdviceEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新消息提醒
|
||||||
|
*/
|
||||||
|
NEW_MESSAGE_REMIND("newMessageRemind", "新消息提醒"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统公告
|
||||||
|
*/
|
||||||
|
SYSTEM_NOTICE("systemNotice", "系统公告"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件提醒
|
||||||
|
*/
|
||||||
|
EMAIL_REMIND("emailRemind", "邮件提醒"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信提醒
|
||||||
|
*/
|
||||||
|
SMS_REMIND("smsRemind", "短信提醒"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送提醒
|
||||||
|
*/
|
||||||
|
PUSH_REMIND("pushRemind", "推送提醒"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点赞提醒
|
||||||
|
*/
|
||||||
|
LIKE_REMIND("likeRemind", "点赞提醒"),
|
||||||
|
/**
|
||||||
|
* 评论提醒
|
||||||
|
*/
|
||||||
|
COMMENT_REMIND("commentRemind", "评论提醒"),
|
||||||
|
/**
|
||||||
|
* 私信提醒
|
||||||
|
*/
|
||||||
|
PRIVATE_MESSAGE_REMIND("privateMessageRemind", "私信提醒");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
@EnumValue
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.mcwl.system.domain.vo;
|
||||||
|
|
||||||
|
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AdviceVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息类型 表示新消息提醒,系统公告等
|
||||||
|
*/
|
||||||
|
private AdviceEnum type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已读 0 是 1 否
|
||||||
|
*/
|
||||||
|
private String isRead;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.system.domain.SysAdvice;
|
||||||
|
import com.mcwl.system.domain.SysConfig;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息通知
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysAdviceMapper extends BaseMapper<SysAdvice> {
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.mcwl.system.mapper;
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -133,5 +132,10 @@ public interface SysUserMapper
|
||||||
|
|
||||||
SysUser selectUserInfoById(@Param("userId") Long userId);
|
SysUser selectUserInfoById(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
void updateIdCard(SysUser sysUser);
|
||||||
|
|
||||||
|
SysUser selectByIdCard(@Param("idCard") String idCard);
|
||||||
|
|
||||||
|
List<SysUser> listByIds(List<Long> userIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.system.domain.SysAdvice;
|
||||||
|
import com.mcwl.system.domain.SysConfig;
|
||||||
|
import com.mcwl.system.domain.vo.AdviceVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息通知 服务层
|
||||||
|
*
|
||||||
|
* @author mcwl
|
||||||
|
*/
|
||||||
|
public interface ISysAdviceService extends IService<SysAdvice> {
|
||||||
|
|
||||||
|
List<AdviceVo> getUserNewMsg();
|
||||||
|
|
||||||
|
List<AdviceVo> getUserSystemNotice();
|
||||||
|
|
||||||
|
List<AdviceVo> getUserAllMsg();
|
||||||
|
|
||||||
|
List<AdviceVo> getAllMsg();
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.mcwl.system.service;
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -213,4 +214,8 @@ public interface ISysUserService
|
||||||
|
|
||||||
SysUser selectUserInfoById(Long userId);
|
SysUser selectUserInfoById(Long userId);
|
||||||
|
|
||||||
|
AjaxResult updateIdCard(SysUser sysUser);
|
||||||
|
|
||||||
|
List<SysUser> listByIds(List<Long> userIdList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.system.domain.SysAdvice;
|
||||||
|
import com.mcwl.system.domain.SysUserThirdAccount;
|
||||||
|
import com.mcwl.system.domain.enums.AdviceEnum;
|
||||||
|
import com.mcwl.system.domain.vo.AdviceVo;
|
||||||
|
import com.mcwl.system.mapper.SysAdviceMapper;
|
||||||
|
import com.mcwl.system.service.ISysAdviceService;
|
||||||
|
import com.mcwl.system.service.IWXService;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息管理 业务层处理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysAdviceServiceImpl extends ServiceImpl<SysAdviceMapper, SysAdvice> implements ISysAdviceService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AdviceVo> getUserNewMsg() {
|
||||||
|
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||||
|
.eq(SysAdvice::getReceiverId, userId)
|
||||||
|
.eq(SysAdvice::getType, AdviceEnum.NEW_MESSAGE_REMIND));
|
||||||
|
|
||||||
|
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AdviceVo> getUserSystemNotice() {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||||
|
.eq(SysAdvice::getReceiverId, userId)
|
||||||
|
.eq(SysAdvice::getType, AdviceEnum.SYSTEM_NOTICE));
|
||||||
|
|
||||||
|
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AdviceVo> getUserAllMsg() {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
List<SysAdvice> sysAdvices = baseMapper.selectList(lambdaQuery()
|
||||||
|
.eq(SysAdvice::getReceiverId, userId));
|
||||||
|
|
||||||
|
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AdviceVo> getAllMsg() {
|
||||||
|
|
||||||
|
List<SysAdvice> sysAdvices = baseMapper.selectList(null);
|
||||||
|
|
||||||
|
return BeanUtil.copyToList(sysAdvices, AdviceVo.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
package com.mcwl.system.service.impl;
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.mcwl.common.annotation.DataScope;
|
import com.mcwl.common.annotation.DataScope;
|
||||||
|
import com.mcwl.common.constant.CacheConstants;
|
||||||
import com.mcwl.common.constant.UserConstants;
|
import com.mcwl.common.constant.UserConstants;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysRole;
|
import com.mcwl.common.core.domain.entity.SysRole;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.exception.ServiceException;
|
import com.mcwl.common.exception.ServiceException;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.common.utils.VerifyCard;
|
||||||
import com.mcwl.common.utils.bean.BeanValidators;
|
import com.mcwl.common.utils.bean.BeanValidators;
|
||||||
import com.mcwl.common.utils.spring.SpringUtils;
|
import com.mcwl.common.utils.spring.SpringUtils;
|
||||||
import com.mcwl.system.domain.SysPost;
|
import com.mcwl.system.domain.SysPost;
|
||||||
|
@ -30,6 +34,7 @@ import javax.validation.Validator;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +47,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
|
@ -600,6 +608,53 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.selectUserInfoById(userId);
|
return userMapper.selectUserInfoById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult updateIdCard(SysUser sysUser) {
|
||||||
|
|
||||||
|
//获取次数
|
||||||
|
Integer s = redisCache.getCacheObject(CacheConstants.ID_CARD_COUNT + sysUser.getUserId());
|
||||||
|
Integer count = 0;
|
||||||
|
if (s != null){
|
||||||
|
|
||||||
|
if (3<=s){
|
||||||
|
|
||||||
|
return AjaxResult.error("次数上限");
|
||||||
|
}else {
|
||||||
|
//次数+1
|
||||||
|
s++;
|
||||||
|
count = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//存入次数
|
||||||
|
redisCache.setCacheObject(CacheConstants.ID_CARD_COUNT+sysUser.getUserId(),count,1, TimeUnit.DAYS);
|
||||||
|
|
||||||
|
//查看身份证是否唯一
|
||||||
|
SysUser user = userMapper.selectByIdCard(sysUser.getIdCard());
|
||||||
|
if (user != null){
|
||||||
|
return AjaxResult.error("该信息已绑定");
|
||||||
|
}
|
||||||
|
//校验
|
||||||
|
String s1 = VerifyCard.idCard(sysUser.getName(), sysUser.getIdCard());
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(s1);
|
||||||
|
Integer code = jsonObject.getInteger("code");
|
||||||
|
if (code != 200){
|
||||||
|
|
||||||
|
return AjaxResult.error(jsonObject.getString("msg"));
|
||||||
|
}
|
||||||
|
log.info("实名认证校验的结果:{}",s1);
|
||||||
|
//修改数据库
|
||||||
|
userMapper.updateIdCard(sysUser);
|
||||||
|
|
||||||
|
return AjaxResult.success("实名认证成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysUser> listByIds(List<Long> userIdList) {
|
||||||
|
return userMapper.listByIds(userIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机密码
|
* 生成随机密码
|
||||||
* @param length
|
* @param length
|
||||||
|
@ -618,5 +673,4 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,28 @@
|
||||||
<mapper namespace="com.mcwl.system.mapper.SysUserMapper">
|
<mapper namespace="com.mcwl.system.mapper.SysUserMapper">
|
||||||
|
|
||||||
<resultMap type="SysUser" id="SysUserResult">
|
<resultMap type="SysUser" id="SysUserResult">
|
||||||
<id property="userId" column="user_id"/>
|
<id property="userId" column="user_id" />
|
||||||
<result property="deptId" column="dept_id"/>
|
<result property="deptId" column="dept_id" />
|
||||||
<result property="userName" column="user_name"/>
|
<result property="userName" column="user_name" />
|
||||||
<result property="nickName" column="nick_name"/>
|
<result property="nickName" column="nick_name" />
|
||||||
<result property="email" column="email"/>
|
<result property="email" column="email" />
|
||||||
<result property="phonenumber" column="phonenumber"/>
|
<result property="phonenumber" column="phonenumber" />
|
||||||
<result property="sex" column="sex"/>
|
<result property="sex" column="sex" />
|
||||||
<result property="avatar" column="avatar"/>
|
<result property="avatar" column="avatar" />
|
||||||
<result property="password" column="password"/>
|
<result property="password" column="password" />
|
||||||
<result property="wallet" column="wallet"/>
|
<result property="status" column="status" />
|
||||||
<result property="status" column="status"/>
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="delFlag" column="del_flag"/>
|
<result property="loginIp" column="login_ip" />
|
||||||
<result property="loginIp" column="login_ip"/>
|
<result property="loginDate" column="login_date" />
|
||||||
<result property="loginDate" column="login_date"/>
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time" />
|
||||||
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="updateTime" column="update_time"/>
|
<result property="remark" column="remark" />
|
||||||
<result property="remark" column="remark"/>
|
<result property="inviterUserId" column="inviter_user_id" />
|
||||||
<association property="dept" javaType="SysDept" resultMap="deptResult"/>
|
<result property="freePoints" column="free_points" />
|
||||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||||
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="deptResult" type="SysDept">
|
<resultMap id="deptResult" type="SysDept">
|
||||||
|
@ -39,255 +40,220 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="RoleResult" type="SysRole">
|
<resultMap id="RoleResult" type="SysRole">
|
||||||
<id property="roleId" column="role_id"/>
|
<id property="roleId" column="role_id" />
|
||||||
<result property="roleName" column="role_name"/>
|
<result property="roleName" column="role_name" />
|
||||||
<result property="roleKey" column="role_key"/>
|
<result property="roleKey" column="role_key" />
|
||||||
<result property="roleSort" column="role_sort"/>
|
<result property="roleSort" column="role_sort" />
|
||||||
<result property="dataScope" column="data_scope"/>
|
<result property="dataScope" column="data_scope" />
|
||||||
<result property="status" column="role_status"/>
|
<result property="status" column="role_status" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select u.user_id,
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.inviter_user_id, u.free_points,
|
||||||
u.dept_id,
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||||
u.user_name,
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||||
u.nick_name,
|
|
||||||
u.email,
|
|
||||||
u.avatar,
|
|
||||||
u.phonenumber,
|
|
||||||
u.password,
|
|
||||||
u.sex,
|
|
||||||
u.wallet,
|
|
||||||
u.status,
|
|
||||||
u.del_flag,
|
|
||||||
u.login_ip,
|
|
||||||
u.login_date,
|
|
||||||
u.create_by,
|
|
||||||
u.create_time,
|
|
||||||
u.remark,
|
|
||||||
d.dept_id,
|
|
||||||
d.parent_id,
|
|
||||||
d.ancestors,
|
|
||||||
d.dept_name,
|
|
||||||
d.order_num,
|
|
||||||
d.leader,
|
|
||||||
d.status as dept_status,
|
|
||||||
r.role_id,
|
|
||||||
r.role_name,
|
|
||||||
r.role_key,
|
|
||||||
r.role_sort,
|
|
||||||
r.data_scope,
|
|
||||||
r.status as role_status
|
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
u
|
where u.del_flag = '0'
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
<if test="userId != null and userId != 0">
|
||||||
where u.del_flag = '0'
|
AND u.user_id = #{userId}
|
||||||
<if test="userId != null and userId != 0">
|
</if>
|
||||||
AND u.user_id = #{userId}
|
<if test="userName != null and userName != ''">
|
||||||
</if>
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
<if test="userName != null and userName != ''">
|
</if>
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
<if test="status != null and status != ''">
|
||||||
</if>
|
AND u.status = #{status}
|
||||||
<if test="status != null and status != ''">
|
</if>
|
||||||
AND u.status = #{status}
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
</if>
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
</if>
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
</if>
|
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
</if>
|
||||||
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
</if>
|
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
</if>
|
||||||
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
<if test="deptId != null and deptId != 0">
|
||||||
</if>
|
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
||||||
<if test="deptId != null and deptId != 0">
|
</if>
|
||||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
<!-- 数据范围过滤 -->
|
||||||
ancestors) ))
|
${params.dataScope}
|
||||||
</if>
|
</select>
|
||||||
<!-- 数据范围过滤 -->
|
|
||||||
${params.dataScope}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
where u.del_flag = '0'
|
||||||
<if test="userName != null and userName != ''">
|
<if test="userName != null and userName != ''">
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
</if>
|
</if>
|
||||||
<!-- 数据范围过滤 -->
|
<!-- 数据范围过滤 -->
|
||||||
${params.dataScope}
|
${params.dataScope}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||||
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
|
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
|
||||||
ur.role_id = #{roleId})
|
<if test="userName != null and userName != ''">
|
||||||
<if test="userName != null and userName != ''">
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
</if>
|
||||||
</if>
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
</if>
|
||||||
</if>
|
<!-- 数据范围过滤 -->
|
||||||
<!-- 数据范围过滤 -->
|
${params.dataScope}
|
||||||
${params.dataScope}
|
</select>
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.user_name = #{userName} and u.del_flag = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserByPhone" resultMap="SysUserResult">
|
||||||
|
<include refid="selectUserVo"/>
|
||||||
|
where u.phonenumber = #{phone} and u.del_flag = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserInfoById" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||||
|
select user_id,avatar,brief,nick_name,name from sys_user where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
<select id="selectByIdCard" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||||
|
select * from sys_user where id_card = #{idCard}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="listByIds" resultMap="SysUserResult">
|
||||||
<include refid="selectUserVo"/>
|
<include refid="selectUserVo"/>
|
||||||
where u.user_name = #{userName} and u.del_flag = '0'
|
where u.user_id in
|
||||||
</select>
|
<foreach collection="list" item="userId" open="(" separator="," close=")">
|
||||||
|
|
||||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
|
||||||
<include refid="selectUserVo"/>
|
|
||||||
where u.user_id = #{userId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
|
||||||
select user_id, user_name
|
|
||||||
from sys_user
|
|
||||||
where user_name = #{userName}
|
|
||||||
and del_flag = '0' limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
|
||||||
select user_id, phonenumber
|
|
||||||
from sys_user
|
|
||||||
where phonenumber = #{phonenumber}
|
|
||||||
and del_flag = '0' limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
|
||||||
select user_id, email
|
|
||||||
from sys_user
|
|
||||||
where email = #{email}
|
|
||||||
and del_flag = '0' limit 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectUserByPhone" resultMap="SysUserResult">
|
|
||||||
<include refid="selectUserVo"/>
|
|
||||||
where u.phonenumber = #{phone} and u.del_flag = '0'
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectUserInfoById" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
|
||||||
select user_id, avatar, brief, nick_name
|
|
||||||
from sys_user
|
|
||||||
where user_id = #{userId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
|
||||||
insert into sys_user(
|
|
||||||
<if test="userId != null and userId != 0">user_id,</if>
|
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
|
||||||
<if test="userName != null and userName != ''">user_name,</if>
|
|
||||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
|
||||||
<if test="email != null and email != ''">email,</if>
|
|
||||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
|
||||||
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
|
||||||
<if test="sex != null and sex != ''">sex,</if>
|
|
||||||
<if test="password != null and password != ''">password,</if>
|
|
||||||
<if test="wallet != null and wallet != ''">wallet,</if>
|
|
||||||
<if test="status != null and status != ''">status,</if>
|
|
||||||
|
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
|
||||||
create_time
|
|
||||||
)values(
|
|
||||||
<if test="userId != null and userId != ''">#{userId},</if>
|
|
||||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
|
||||||
<if test="userName != null and userName != ''">#{userName},</if>
|
|
||||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
|
||||||
<if test="email != null and email != ''">#{email},</if>
|
|
||||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
|
||||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
|
||||||
<if test="sex != null and sex != ''">#{sex},</if>
|
|
||||||
<if test="password != null and password != ''">#{password},</if>
|
|
||||||
<if test="wallet != null and wallet != ''">#{wallet},</if>
|
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateUser" parameterType="SysUser">
|
|
||||||
update sys_user
|
|
||||||
<set>
|
|
||||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
|
||||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
||||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
|
||||||
<if test="email != null ">email = #{email},</if>
|
|
||||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
|
||||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
|
||||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
|
||||||
<if test="password != null and password != ''">password = #{password},</if>
|
|
||||||
<if test="wallet != null and wallet != ''">wallet = #{wallet},</if>
|
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
|
||||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
|
||||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
update_time = sysdate()
|
|
||||||
</set>
|
|
||||||
where user_id = #{userId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="updateUserStatus" parameterType="SysUser">
|
|
||||||
update sys_user
|
|
||||||
set status = #{status}
|
|
||||||
where user_id = #{userId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="updateUserAvatar" parameterType="SysUser">
|
|
||||||
update sys_user
|
|
||||||
set avatar = #{avatar}
|
|
||||||
where user_name = #{userName}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="resetUserPwd" parameterType="SysUser">
|
|
||||||
update sys_user
|
|
||||||
set password = #{password}
|
|
||||||
where user_name = #{userName}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<update id="updateUserInfo">
|
|
||||||
update sys_user
|
|
||||||
set nick_name = #{nickName},
|
|
||||||
avatar = #{avatar},
|
|
||||||
brief = #{brief}
|
|
||||||
where user_id = #{userId}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteUserById" parameterType="Long">
|
|
||||||
update sys_user
|
|
||||||
set del_flag = '2'
|
|
||||||
where user_id = #{userId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteUserByIds" parameterType="Long">
|
|
||||||
update sys_user set del_flag = '2' where user_id in
|
|
||||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
|
||||||
#{userId}
|
#{userId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
|
insert into sys_user(
|
||||||
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||||
|
<if test="email != null and email != ''">email,</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||||
|
<if test="sex != null and sex != ''">sex,</if>
|
||||||
|
<if test="password != null and password != ''">password,</if>
|
||||||
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">#{userName},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||||
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||||
|
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||||
|
<if test="sex != null and sex != ''">#{sex},</if>
|
||||||
|
<if test="password != null and password != ''">#{password},</if>
|
||||||
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateUser" parameterType="SysUser">
|
||||||
|
update sys_user
|
||||||
|
<set>
|
||||||
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
|
<if test="email != null ">email = #{email},</if>
|
||||||
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
|
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||||
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||||
|
<if test="password != null and password != ''">password = #{password},</if>
|
||||||
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
|
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||||
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="freePoints != null">free_points = #{freePoints},</if>
|
||||||
|
update_time = sysdate()
|
||||||
|
</set>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateUserStatus" parameterType="SysUser">
|
||||||
|
update sys_user set status = #{status} where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateUserAvatar" parameterType="SysUser">
|
||||||
|
update sys_user set avatar = #{avatar} where user_name = #{userName}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="resetUserPwd" parameterType="SysUser">
|
||||||
|
update sys_user set password = #{password} where user_name = #{userName}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateUserInfo">
|
||||||
|
update sys_user set nick_name = #{nickName},
|
||||||
|
avatar = #{avatar},
|
||||||
|
brief = #{brief}
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateIdCard">
|
||||||
|
update sys_user set name = #{name},
|
||||||
|
id_card = #{idCard}
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteUserById" parameterType="Long">
|
||||||
|
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteUserByIds" parameterType="Long">
|
||||||
|
update sys_user set del_flag = '2' where user_id in
|
||||||
|
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -240,7 +240,6 @@
|
||||||
<module>mcwl-resource</module>
|
<module>mcwl-resource</module>
|
||||||
<module>mcwl-memberCenter</module>
|
<module>mcwl-memberCenter</module>
|
||||||
<module>mcwl-pay</module>
|
<module>mcwl-pay</module>
|
||||||
<module>mcwl-comment</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue