commit
d8f09b6039
@ -9,7 +9,8 @@
|
||||
##### 交流 qq 1群 961316482(已满)
|
||||
##### 交流 qq 2群 875294241(已满)
|
||||
##### 交流 qq 3群 263785057(已满)
|
||||
##### 交流 qq 4群 674617534
|
||||
##### 交流 qq 4群 674617534 (已满)
|
||||
##### 交流 qq 5群 594675235
|
||||
|
||||
##### 体验 公众号/小程序/APP 体验,扫描二维码
|
||||
|
||||
@ -164,8 +165,8 @@ PS:手机验证码为 ‘111111’
|
||||
##### 交流 qq 1群 961316482(已满)
|
||||
##### 交流 qq 2群 875294241(已满)
|
||||
##### 交流 qq 3群 263785057(已满)
|
||||
##### 交流 qq 4群 674617534
|
||||
|
||||
##### 交流 qq 4群 674617534(已满)
|
||||
##### 交流 qq 5群 594675235
|
||||
|
||||
### 附录
|
||||
有人有自己的学习视频、学习记录文档、希望宣传关联开源项目等均可以私聊仓库所有者。
|
||||
|
@ -1,96 +0,0 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import cn.lili.modules.member.service.StoreCollectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员收藏接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 2:32 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员收藏接口")
|
||||
@RequestMapping("/buyer/member/collection")
|
||||
public class MemberCollectionController {
|
||||
|
||||
/**
|
||||
* 会员商品收藏
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsCollectionService goodsCollectionService;
|
||||
/**
|
||||
* 会员店铺
|
||||
*/
|
||||
@Autowired
|
||||
private StoreCollectionService storeCollectionService;
|
||||
|
||||
/**
|
||||
* 商品收藏关键字
|
||||
*/
|
||||
private String goods="GOODS";
|
||||
|
||||
@ApiOperation(value = "查询会员收藏列表")
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺")
|
||||
@GetMapping("/{type}")
|
||||
public ResultMessage<Object> goodsList(@PathVariable String type, PageVO page) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.goodsCollection(page));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.storeCollection(page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@PostMapping("/add/{type}/{id}")
|
||||
public ResultMessage<Object> addGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.addGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.addStoreCollection(id));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@DeleteMapping(value = "/delete/{type}/{id}")
|
||||
public ResultMessage<Object> deleteGoodsCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(goodsCollectionService.deleteGoodsCollection(id));
|
||||
}
|
||||
return ResultUtil.data(storeCollectionService.deleteStoreCollection(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询会员是否收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "id", value = "值", dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/isCollection/{type}/{id}")
|
||||
public ResultMessage<Boolean> isCollection(@PathVariable String type,
|
||||
@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
if (goods.equals(type)) {
|
||||
return ResultUtil.data(this.goodsCollectionService.isCollection(id));
|
||||
}
|
||||
return ResultUtil.data(this.storeCollectionService.isCollection(id));
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员收藏接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 2:32 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员商品收藏接口")
|
||||
@RequestMapping("/buyer/member/collection")
|
||||
public class MemberCollectionGoodsController {
|
||||
|
||||
/**
|
||||
* 会员商品收藏
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsCollectionService goodsCollectionService;
|
||||
|
||||
@ApiOperation(value = "查询会员收藏列表")
|
||||
@GetMapping("/GOODS")
|
||||
public ResultMessage<Object> goodsList(PageVO page) {
|
||||
return ResultUtil.data(goodsCollectionService.goodsCollection(page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@PostMapping("/add/GOODS/{id}")
|
||||
public ResultMessage<Object> addGoodsCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(goodsCollectionService.addGoodsCollection(id));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@DeleteMapping(value = "/delete/GOODS/{id}")
|
||||
public ResultMessage<Object> deleteGoodsCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(goodsCollectionService.deleteGoodsCollection(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询会员是否收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺"),
|
||||
@ApiImplicitParam(name = "id", value = "值", dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/isCollection/GOODS/{id}")
|
||||
public ResultMessage<Boolean> isCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(this.goodsCollectionService.isCollection(id));
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.service.StoreCollectionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 买家端,会员收藏接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 2:32 下午
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,会员店铺收藏接口")
|
||||
@RequestMapping("/buyer/member/storeCollection")
|
||||
public class MemberCollectionStoreController {
|
||||
|
||||
/**
|
||||
* 会员店铺
|
||||
*/
|
||||
@Autowired
|
||||
private StoreCollectionService storeCollectionService;
|
||||
|
||||
@ApiOperation(value = "查询会员收藏列表")
|
||||
@GetMapping("/STORE")
|
||||
public ResultMessage<Object> goodsList(PageVO page) {
|
||||
return ResultUtil.data(storeCollectionService.storeCollection(page));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@PostMapping("/add/STORE/{id}")
|
||||
public ResultMessage<Object> addGoodsCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(storeCollectionService.addStoreCollection(id));
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除会员收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "num", value = "值", dataType = "Long", paramType = "path")
|
||||
})
|
||||
@DeleteMapping(value = "/delete/STORE/{id}")
|
||||
public ResultMessage<Object> deleteGoodsCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(storeCollectionService.deleteStoreCollection(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询会员是否收藏")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "值", dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/isCollection/STORE/{id}")
|
||||
public ResultMessage<Boolean> isCollection(@NotNull(message = "值不能为空") @PathVariable String id) {
|
||||
return ResultUtil.data(this.storeCollectionService.isCollection(id));
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class ConnectBuyerWebController {
|
||||
|
||||
|
||||
@GetMapping("/login/web/{type}")
|
||||
@ApiOperation(value = "WEB信任登录授权")
|
||||
@ApiOperation(value = "WEB信任登录授权,包含PC、WAP")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "type", value = "登录方式:QQ,微信,微信_PC",
|
||||
allowableValues = "QQ,WECHAT,WECHAT_PC", paramType = "path")
|
||||
@ -75,25 +75,13 @@ public class ConnectBuyerWebController {
|
||||
return connectUtil.getResult(state);
|
||||
}
|
||||
|
||||
@GetMapping("/register/auto")
|
||||
@ApiOperation(value = "WEB信任登录授权")
|
||||
public ResultMessage<Token> webAuthorize() {
|
||||
Token token = memberService.autoRegister();
|
||||
return ResultUtil.data(token);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "unionID登录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "openId", value = "openid", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "type", value = "联合类型", required = true,
|
||||
allowableValues = "WECHAT,QQ,ALIPAY,WEIBO,APPLE", paramType = "query"),
|
||||
@ApiImplicitParam(name = "uniAccessToken", value = "联合登陆返回的accessToken", required = true, paramType = "query")
|
||||
})
|
||||
@ApiOperation(value = "APP-unionID登录")
|
||||
@GetMapping("/app/login")
|
||||
public ResultMessage<Token> unionLogin(ConnectAuthUser authUser, @RequestHeader("uuid") String uuid) {
|
||||
try {
|
||||
return ResultUtil.data(connectService.appLoginCallback(authUser, uuid));
|
||||
return ResultUtil.data(connectService.unionLoginCallback(authUser, uuid));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("unionID登录错误", e);
|
||||
}
|
||||
return null;
|
||||
|
@ -9,12 +9,18 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.WithdrawalSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.entity.vo.WithdrawalSettingVO;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||
import cn.lili.modules.verification.service.VerificationService;
|
||||
import cn.lili.modules.wallet.entity.dos.MemberWallet;
|
||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -25,7 +31,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
@ -56,6 +61,9 @@ public class MemberWalletBuyerController {
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询会员预存款余额")
|
||||
public ResultMessage<MemberWalletVO> get() {
|
||||
@ -66,6 +74,31 @@ public class MemberWalletBuyerController {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/withdrawalSettingVO")
|
||||
@ApiOperation(value = "获取提现设置VO")
|
||||
public ResultMessage<Object> minPrice() {
|
||||
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||
|
||||
WithdrawalSettingVO withdrawalSettingVO = new WithdrawalSettingVO();
|
||||
withdrawalSettingVO.setMinPrice(withdrawalSetting.getMinPrice());
|
||||
withdrawalSettingVO.setFee(withdrawalSetting.getFee());
|
||||
withdrawalSettingVO.setType(withdrawalSetting.getType());
|
||||
return ResultUtil.data(withdrawalSettingVO);
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping(value = "/withdrawal")
|
||||
@ApiOperation(value = "会员中心余额提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query"),
|
||||
@ApiImplicitParam(name = "realName", value = "真实姓名", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "connectNumber", value = "第三方登录账号", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Boolean> withdrawal(@Max(value = 9999, message = "充值金额单次最多允许提现9999元") Double price, @RequestParam String realName, @RequestParam String connectNumber) {
|
||||
return ResultUtil.data(memberWalletService.applyWithdrawal(price, realName, connectNumber));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/set-password")
|
||||
@ApiOperation(value = "设置支付密码")
|
||||
@ApiImplicitParams({
|
||||
@ -122,18 +155,4 @@ public class MemberWalletBuyerController {
|
||||
return memberWalletService.checkPassword();
|
||||
}
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping(value = "/withdrawal")
|
||||
@ApiOperation(value = "会员中心余额提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Boolean> withdrawal(
|
||||
@Max(value = 9999, message = "提现金额单次最多允许提现9999元")
|
||||
@Min(value = 1, message = "提现金额单次最少提现金额为1元")
|
||||
Double price) {
|
||||
return ResultUtil.data(memberWalletService.applyWithdrawal(price));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ spring:
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://192.168.0.116:8000
|
||||
url: http://192.168.0.108:8000
|
||||
cache:
|
||||
type: redis
|
||||
# Redis
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
host: 192.168.0.108
|
||||
port: 30379
|
||||
password: lilishop
|
||||
lettuce:
|
||||
pool:
|
||||
@ -60,7 +60,7 @@ spring:
|
||||
default-datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://192.168.0.108:30306/kuaidi100?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: lilishop
|
||||
maxActive: 50
|
||||
@ -241,16 +241,16 @@ lili:
|
||||
sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6
|
||||
#域名
|
||||
domain:
|
||||
pc: http://192.168.0.116:8888
|
||||
wap: http://192.168.0.116:8888
|
||||
seller: http://192.168.0.116:8888
|
||||
admin: http://192.168.0.116:8888
|
||||
pc: http://192.168.0.108:8888
|
||||
wap: http://192.168.0.108:8888
|
||||
seller: http://192.168.0.108:8888
|
||||
admin: http://192.168.0.108:8888
|
||||
#api地址
|
||||
api:
|
||||
buyer: https://z171l91606.51mypc.cn
|
||||
base: http://192.168.0.116:8888
|
||||
manager: http://192.168.0.116:8888
|
||||
seller: http://192.168.0.116:8888
|
||||
base: http://192.168.0.108:8888
|
||||
manager: http://192.168.0.108:8888
|
||||
seller: http://192.168.0.108:8888
|
||||
|
||||
# jwt 细节设定
|
||||
jwt-setting:
|
||||
@ -269,7 +269,7 @@ lili:
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-name: elasticsearch
|
||||
cluster-nodes: 127.0.0.1:9200
|
||||
cluster-nodes: 192.168.0.108:30920
|
||||
index:
|
||||
number-of-replicas: 0
|
||||
number-of-shards: 3
|
||||
@ -301,7 +301,7 @@ lili:
|
||||
after-sale-topic: lili_after_sale_topic
|
||||
after-sale-group: lili_after_sale_group
|
||||
rocketmq:
|
||||
name-server: 127.0.0.1:9876
|
||||
name-server: 192.168.0.108:30876
|
||||
isVIPChannel: false
|
||||
producer:
|
||||
group: lili_group
|
||||
@ -310,7 +310,7 @@ rocketmq:
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9001/xxl-job-admin
|
||||
addresses: http://192.168.0.108:9001/xxl-job-admin
|
||||
executor:
|
||||
appname: xxl-job-executor-lilishop
|
||||
address:
|
||||
|
@ -0,0 +1,21 @@
|
||||
package cn.lili.event;
|
||||
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
|
||||
/**
|
||||
* 会员联合登录消息
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 7:13 下午
|
||||
*/
|
||||
public interface MemberConnectLoginEvent {
|
||||
|
||||
/**
|
||||
* 会员联合登录
|
||||
*
|
||||
* @param member 会员
|
||||
* @param authUser 第三方登录
|
||||
*/
|
||||
void memberConnectLogin(Member member, ConnectAuthUser authUser);
|
||||
}
|
@ -1,25 +1,58 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.event.MemberConnectLoginEvent;
|
||||
import cn.lili.event.MemberLoginEvent;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 会员自身业务
|
||||
* 会员登录,会员第三方登录
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-01-11 11:08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MemberExecute implements MemberLoginEvent {
|
||||
public class MemberExecute implements MemberLoginEvent, MemberConnectLoginEvent {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
@Autowired
|
||||
private ConnectService connectService;
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@Override
|
||||
public void memberLogin(Member member) {
|
||||
memberService.updateMemberLoginTime(member.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memberConnectLogin(Member member, ConnectAuthUser authUser) {
|
||||
log.info("unionid:"+authUser.getToken().getUnionId());
|
||||
log.info("openid:"+authUser.getUuid());
|
||||
//保存UnionID
|
||||
if (StrUtil.isNotBlank(authUser.getToken().getUnionId())) {
|
||||
connectService.loginBindUser(member.getId(), authUser.getToken().getUnionId(), authUser.getSource());
|
||||
}
|
||||
//保存OpenID
|
||||
if (StrUtil.isNotBlank(authUser.getUuid())) {
|
||||
log.info("authUser.getSource():"+authUser.getSource());
|
||||
log.info("authUser.getType():"+authUser.getType());
|
||||
SourceEnum sourceEnum = SourceEnum.getSourceEnum(ConnectEnum.valueOf(authUser.getSource()), ClientTypeEnum.valueOf(authUser.getType()));
|
||||
connectService.loginBindUser(member.getId(), authUser.getUuid(), sourceEnum.name());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.event.MemberWithdrawalEvent;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -14,14 +17,31 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2020-07-03 11:20
|
||||
*/
|
||||
@Service
|
||||
public class MemberWalletExecute implements MemberRegisterEvent {
|
||||
public class MemberWalletExecute implements MemberWithdrawalEvent {
|
||||
|
||||
@Autowired
|
||||
private MemberWalletService memberWalletService;
|
||||
|
||||
@Override
|
||||
public void memberRegister(Member member) {
|
||||
// 有些情况下,会同时创建一个member_id的两条数据
|
||||
// memberWalletService.save(member.getId(),member.getUsername());
|
||||
public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
|
||||
switch (WithdrawStatusEnum.valueOf(memberWithdrawalMessage.getStatus())) {
|
||||
case VIA_AUDITING:
|
||||
memberWalletService.withdrawal(memberWithdrawalMessage.getMemberWithdrawApplyId());
|
||||
break;
|
||||
case SUCCESS:
|
||||
//提现成功扣减冻结金额
|
||||
memberWalletService.reduceFrozen(
|
||||
new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现成功,余额提现", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
break;
|
||||
case ERROR:
|
||||
//需要从冻结金额扣减到余额
|
||||
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现失败,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
break;
|
||||
case FAIL_AUDITING:
|
||||
//需要从冻结金额扣减到余额
|
||||
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -179,60 +178,30 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
||||
public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
|
||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||
noticeMessageDTO.setMemberId(memberWithdrawalMessage.getMemberId());
|
||||
//如果提现状态为申请则发送申请提现站内消息
|
||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.APPLY.name())) {
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_CREATE);
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//发送提现申请成功消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
}
|
||||
//如果提现状态为通过则发送审核通过站内消息
|
||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.VIA_AUDITING.name())) {
|
||||
//如果提现到余额
|
||||
if (memberWithdrawalMessage.getDestination().equals(MemberWithdrawalDestinationEnum.WALLET.name())) {
|
||||
//组织参数
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
switch (WithdrawStatusEnum.valueOf(memberWithdrawalMessage.getStatus())) {
|
||||
case APPLY:
|
||||
//如果提现状态为申请则发送申请提现站内消息
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_CREATE);
|
||||
break;
|
||||
case FAIL_AUDITING:
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_AUDIT_ERROR);
|
||||
break;
|
||||
case SUCCESS:
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_SUCCESS);
|
||||
//发送提现成功消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
||||
params.put("expenditure", "0");
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_CHANGE);
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//发送余额变动消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
}
|
||||
//如果提现到微信
|
||||
if (memberWithdrawalMessage.getDestination().equals(MemberWithdrawalDestinationEnum.WECHAT.name())) {
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_WEICHAT_SUCCESS);
|
||||
//发送提现成功消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
|
||||
params.put("income", "0");
|
||||
params.put("expenditure", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_CHANGE);
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//发送余额变动消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
}
|
||||
}
|
||||
//如果提现状态为拒绝则发送审核拒绝站内消息
|
||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.FAIL_AUDITING.name())) {
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_ERROR);
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//发送提现申请成功消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
break;
|
||||
case ERROR:
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_ERROR);
|
||||
break;
|
||||
case VIA_AUDITING:
|
||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_AUDIT_SUCCESS);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
||||
noticeMessageDTO.setParameter(params);
|
||||
//发送提现申请消息
|
||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.lili.listener;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.*;
|
||||
import cn.lili.event.impl.ImTalkExecute;
|
||||
import cn.lili.modules.connect.entity.dto.MemberConnectLoginMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.MemberSign;
|
||||
import cn.lili.modules.member.entity.dto.MemberPointMessage;
|
||||
@ -55,10 +56,10 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
*/
|
||||
@Autowired
|
||||
private List<MemberLoginEvent> memberLoginEvents;
|
||||
|
||||
@Autowired
|
||||
private List<MemberInfoChangeEvent> memberInfoChangeEvents;
|
||||
|
||||
@Autowired
|
||||
private List<MemberConnectLoginEvent> memberConnectLoginEvents;
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageExt messageExt) {
|
||||
@ -77,7 +78,7 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//用户登录
|
||||
case MEMBER_LOGIN:
|
||||
|
||||
for (MemberLoginEvent memberLoginEvent : memberLoginEvents) {
|
||||
@ -139,6 +140,20 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
}
|
||||
break;
|
||||
//用户第三方登录
|
||||
case MEMBER_CONNECT_LOGIN:
|
||||
for (MemberConnectLoginEvent memberConnectLoginEvent : memberConnectLoginEvents) {
|
||||
try {
|
||||
MemberConnectLoginMessage memberConnectLoginMessage = JSONUtil.toBean(new String(messageExt.getBody()), MemberConnectLoginMessage.class);
|
||||
memberConnectLoginEvent.memberConnectLogin(memberConnectLoginMessage.getMember(), memberConnectLoginMessage.getConnectAuthUser());
|
||||
} catch (Exception e) {
|
||||
log.error("会员{},在{}业务中,状态修改事件执行异常",
|
||||
new String(messageExt.getBody()),
|
||||
memberConnectLoginEvent.getClass().getName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -51,10 +51,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@ -440,7 +436,7 @@
|
||||
<dependency>
|
||||
<groupId>com.huaweicloud</groupId>
|
||||
<artifactId>esdk-obs-java</artifactId>
|
||||
<version>${huaweicloud.version}</version>
|
||||
<version>${huaweicloud-obs.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
|
@ -31,7 +31,7 @@ public enum ClientTypeEnum {
|
||||
*/
|
||||
UNKNOWN("未知");
|
||||
|
||||
private final String clientName;
|
||||
private String clientName;
|
||||
|
||||
ClientTypeEnum(String des) {
|
||||
this.clientName = des;
|
||||
|
@ -148,6 +148,7 @@ public enum ResultCode {
|
||||
CLERK_ALREADY_EXIT_ERROR(20030, "店员已经存在"),
|
||||
CLERK_DISABLED_ERROR(20031, "店员已禁用"),
|
||||
CLERK_CURRENT_SUPPER(20032, "无法删除当前登录店员"),
|
||||
CANT_EDIT_CLERK_SHOPKEEPER(20033, "无法在店员管理编辑店员信息"),
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
@ -257,9 +258,10 @@ public enum ResultCode {
|
||||
WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT(34006, "冻结金额不足,无法处理提现申请请求!"),
|
||||
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
|
||||
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
|
||||
WALLET_EXIT_ERROR(34000, "钱包已存在,无法重复创建"),
|
||||
WALLET_APPLY_ERROR(34005, "提现申请异常!"),
|
||||
WALLET_WITHDRAWAL_AMOUNT_ERROR(34006, "申请提现金额异常!"),
|
||||
WALLET_EXIT_ERROR(34005, "钱包已存在,无法重复创建"),
|
||||
WALLET_APPLY_ERROR(34006, "提现申请异常!"),
|
||||
WALLET_APPLY_MIN_PRICE_ERROR(34007, "提现最低提现金额错误!"),
|
||||
WALLET_WITHDRAWAL_AMOUNT_ERROR(34008, "申请提现金额异常!"),
|
||||
/**
|
||||
* 评价
|
||||
*/
|
||||
|
@ -59,6 +59,18 @@ public class GlobalControllerExceptionHandler {
|
||||
message += ":" + serviceException.getMsg();
|
||||
}
|
||||
|
||||
// 对一些特殊异常处理,不再打印error级别的日志
|
||||
assert serviceException.getResultCode() != null;
|
||||
if (serviceException.getResultCode().equals(ResultCode.DEMO_SITE_EXCEPTION)) {
|
||||
log.debug("[DEMO_SITE_EXCEPTION]:{}", serviceException.getResultCode().message(), e);
|
||||
return ResultUtil.error(code, message);
|
||||
}
|
||||
if (serviceException.getResultCode().equals(ResultCode.USER_AUTH_EXPIRED)) {
|
||||
log.debug("403 :{}", serviceException.getResultCode().message(), e);
|
||||
return ResultUtil.error(code, message);
|
||||
}
|
||||
|
||||
|
||||
log.error("全局异常[ServiceException]:{}-{}", serviceException.getResultCode().code(), serviceException.getResultCode().message(), e);
|
||||
return ResultUtil.error(code, message);
|
||||
|
||||
|
@ -183,7 +183,6 @@ public class HttpClientUtils {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
log.error("Get错误", e);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ package cn.lili.modules.connect.config;
|
||||
public enum ConnectAuthEnum implements ConnectAuth {
|
||||
|
||||
/**
|
||||
* 微信开放平台
|
||||
* 微信公众号登录
|
||||
*/
|
||||
WECHAT {
|
||||
@Override
|
||||
@ -32,6 +32,7 @@ public enum ConnectAuthEnum implements ConnectAuth {
|
||||
|
||||
/**
|
||||
* 微信开放平台
|
||||
* 微信PC登录
|
||||
*/
|
||||
WECHAT_PC {
|
||||
@Override
|
||||
|
@ -67,6 +67,12 @@ public class ConnectAuthUser implements Serializable {
|
||||
* 用户来源
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 例如:PC、WAP、小程序
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 用户授权的token信息
|
||||
*/
|
||||
@ -81,4 +87,9 @@ public class ConnectAuthUser implements Serializable {
|
||||
*/
|
||||
private ConnectAuthEnum connectEnum;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cn.lili.modules.connect.entity.dto;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 会员联合登录消息
|
||||
*/
|
||||
@Data
|
||||
public class MemberConnectLoginMessage {
|
||||
|
||||
private Member member;
|
||||
private ConnectAuthUser connectAuthUser;
|
||||
}
|
@ -15,8 +15,6 @@ public enum ConnectEnum {
|
||||
WEIBO("微博联合登录"),
|
||||
//只存放unionid
|
||||
WECHAT("微信联合登录"),
|
||||
WECHAT_OPEN_ID("微信openid登录"),
|
||||
WECHAT_MP_OPEN_ID("微信openid登录"),
|
||||
ALIPAY("支付宝登录"),
|
||||
APPLE("苹果登录");
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
package cn.lili.modules.connect.entity.enums;
|
||||
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
|
||||
/**
|
||||
* 联合登陆-渠道枚举
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v4.0
|
||||
* @since 2020/11/25 18:20
|
||||
*/
|
||||
public enum SourceEnum {
|
||||
|
||||
WECHAT_PC_OPEN_ID("微信PC应用 openid登录"),
|
||||
WECHAT_OFFIACCOUNT_OPEN_ID("微信公众号 openid登录"),
|
||||
WECHAT_MP_OPEN_ID("微信小程序 openid登录"),
|
||||
WECHAT_APP_OPEN_ID("微信APP openid登录"),
|
||||
|
||||
QQ_APP_OPEN_ID("QQ APP openid登录"),
|
||||
QQ_PC_OPEN_ID("QQ PC应用 openid登录"),
|
||||
QQ_H5_OPEN_ID("QQ H5应用 openid登录"),
|
||||
|
||||
APPLE_OPEN_ID("苹果 openid登录"),
|
||||
;
|
||||
|
||||
|
||||
private final String description;
|
||||
|
||||
SourceEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public static SourceEnum getSourceEnum(ConnectEnum source, ClientTypeEnum type) {
|
||||
switch (source) {
|
||||
case WECHAT:
|
||||
switch (type) {
|
||||
case APP:
|
||||
return WECHAT_APP_OPEN_ID;
|
||||
case WECHAT_MP:
|
||||
return WECHAT_MP_OPEN_ID;
|
||||
case PC:
|
||||
return WECHAT_PC_OPEN_ID;
|
||||
case H5:
|
||||
return WECHAT_OFFIACCOUNT_OPEN_ID;
|
||||
}
|
||||
break;
|
||||
case QQ:
|
||||
switch (type) {
|
||||
case APP:
|
||||
return QQ_APP_OPEN_ID;
|
||||
case PC:
|
||||
return QQ_PC_OPEN_ID;
|
||||
case H5:
|
||||
return QQ_H5_OPEN_ID;
|
||||
}
|
||||
break;
|
||||
case APPLE:
|
||||
return APPLE_OPEN_ID;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
@ -12,9 +14,9 @@ import cn.lili.modules.connect.entity.dto.AuthToken;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.GlobalAuthUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
@ -67,7 +69,8 @@ public class BaseAuthQQRequest extends BaseAuthRequest {
|
||||
.uuid(openId)
|
||||
.gender(AuthUserGender.getRealGender(object.getString("gender")))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.source(ConnectEnum.QQ.name())
|
||||
.type(ClientTypeEnum.PC.name())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
@ -10,8 +12,9 @@ import cn.lili.modules.connect.entity.dto.AuthToken;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
@ -56,10 +59,11 @@ public class BaseAuthWeChatPCRequest extends BaseAuthRequest {
|
||||
.nickname(object.getString("nickname"))
|
||||
.avatar(object.getString("headimgurl"))
|
||||
.location(location)
|
||||
.uuid(authToken.getUnionId())
|
||||
.uuid(authToken.getOpenId())
|
||||
.gender(AuthUserGender.getWechatRealGender(object.getString("sex")))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.source(ConnectEnum.WECHAT.name())
|
||||
.type(ClientTypeEnum.PC.name())
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -112,6 +116,7 @@ public class BaseAuthWeChatPCRequest extends BaseAuthRequest {
|
||||
*/
|
||||
@Override
|
||||
public String authorize(String state) {
|
||||
|
||||
return UrlBuilder.fromBaseUrl(source.authorize())
|
||||
.queryParam("response_type", "code")
|
||||
.queryParam("appid", config.getClientId())
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lili.modules.connect.request;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.common.utils.UrlBuilder;
|
||||
import cn.lili.modules.connect.config.AuthConfig;
|
||||
import cn.lili.modules.connect.config.ConnectAuthEnum;
|
||||
@ -10,9 +12,10 @@ import cn.lili.modules.connect.entity.dto.AuthToken;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.enums.AuthResponseStatus;
|
||||
import cn.lili.modules.connect.entity.enums.AuthUserGender;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.exception.AuthException;
|
||||
import cn.lili.modules.connect.util.GlobalAuthUtils;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
@ -61,7 +64,8 @@ public class BaseAuthWeChatRequest extends BaseAuthRequest {
|
||||
.uuid(openId)
|
||||
.gender(AuthUserGender.getWechatRealGender(object.getString("sex")))
|
||||
.token(authToken)
|
||||
.source(source.toString())
|
||||
.source(ConnectEnum.WECHAT.name())
|
||||
.type(ClientTypeEnum.H5.name())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -28,27 +28,14 @@ public interface ConnectService extends IService<Connect> {
|
||||
*/
|
||||
String CONNECT_TYPE = "CONNECT_TYPE";
|
||||
|
||||
/**
|
||||
* 联合登陆
|
||||
*
|
||||
* @param type 类型
|
||||
* @param unionid unionid
|
||||
* @param longTerm 是否长时间有效
|
||||
* @param uuid UUID
|
||||
* @return token
|
||||
* @throws NoPermissionException 不允许操作
|
||||
*/
|
||||
Token unionLoginCallback(String type, String unionid, String uuid, boolean longTerm) throws NoPermissionException;
|
||||
|
||||
/**
|
||||
* 联合登陆对象直接登录
|
||||
*
|
||||
* @param type 第三方登录类型
|
||||
* @param authUser 第三方登录返回封装类
|
||||
* @param uuid 用户uuid
|
||||
* @return token
|
||||
*/
|
||||
Token unionLoginCallback(String type, ConnectAuthUser authUser, String uuid);
|
||||
Token unionLoginCallback(ConnectAuthUser authUser, String uuid);
|
||||
|
||||
/**
|
||||
* 绑定
|
||||
@ -86,15 +73,6 @@ public interface ConnectService extends IService<Connect> {
|
||||
return CachePrefix.CONNECT_AUTH.getPrefix() + type + uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* app联合登录 回调
|
||||
*
|
||||
* @param authUser 登录对象
|
||||
* @param uuid uuid
|
||||
* @return token
|
||||
*/
|
||||
Token appLoginCallback(ConnectAuthUser authUser, String uuid);
|
||||
|
||||
|
||||
/**
|
||||
* 微信一键登录
|
||||
@ -119,4 +97,12 @@ public interface ConnectService extends IService<Connect> {
|
||||
* @param userId 会员id
|
||||
*/
|
||||
void deleteByMemberId(String userId);
|
||||
|
||||
/**
|
||||
* 绑定第三方平台用户
|
||||
* @param userId 用户ID
|
||||
* @param unionId 第三方平台用户ID
|
||||
* @param type 平台类型
|
||||
*/
|
||||
void loginBindUser(String userId, String unionId, String type);
|
||||
}
|
@ -1,25 +1,26 @@
|
||||
package cn.lili.modules.connect.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.context.ThreadContextHolder;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.token.Token;
|
||||
import cn.lili.common.utils.CookieUtil;
|
||||
import cn.lili.common.utils.HttpUtils;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.dto.AuthToken;
|
||||
import cn.lili.modules.connect.entity.dto.ConnectAuthUser;
|
||||
import cn.lili.modules.connect.entity.dto.MemberConnectLoginMessage;
|
||||
import cn.lili.modules.connect.entity.dto.WechatMPLoginParams;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.mapper.ConnectMapper;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
@ -31,13 +32,14 @@ import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -49,7 +51,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.security.Security;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 联合登陆接口实现
|
||||
@ -71,65 +72,20 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
/**
|
||||
* RocketMQ 配置
|
||||
* RocketMQ
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* RocketMQ配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Token unionLoginCallback(String type, String unionid, String uuid, boolean longTerm) throws NoPermissionException {
|
||||
|
||||
try {
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Connect::getUnionId, unionid);
|
||||
queryWrapper.eq(Connect::getUnionType, type);
|
||||
//查询绑定关系
|
||||
Connect connect = this.getOne(queryWrapper);
|
||||
if (connect == null) {
|
||||
throw new NoPermissionException("未绑定用户");
|
||||
}
|
||||
//查询会员
|
||||
Member member = memberService.getById(connect.getUserId());
|
||||
//如果未绑定会员,则把刚才查询到的联合登录表数据删除
|
||||
if (member == null) {
|
||||
this.remove(queryWrapper);
|
||||
throw new NoPermissionException("未绑定用户");
|
||||
}
|
||||
return memberTokenGenerate.createToken(member, longTerm);
|
||||
} catch (NoPermissionException e) {
|
||||
log.error("联合登陆失败:", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Token unionLoginCallback(String type, ConnectAuthUser authUser, String uuid) {
|
||||
|
||||
Token token;
|
||||
try {
|
||||
token = this.unionLoginCallback(type, authUser.getUuid(), uuid, false);
|
||||
} catch (NoPermissionException e) {
|
||||
if (AUTO_REGION) {
|
||||
token = memberService.autoRegister(authUser);
|
||||
return token;
|
||||
} else {
|
||||
//写入cookie
|
||||
CookieUtil.addCookie(CONNECT_COOKIE, uuid, 1800, ThreadContextHolder.getHttpResponse());
|
||||
CookieUtil.addCookie(CONNECT_TYPE, type, 1800, ThreadContextHolder.getHttpResponse());
|
||||
//自动登录失败,则把信息缓存起来
|
||||
cache.put(ConnectService.cacheKey(type, uuid), authUser, 30L, TimeUnit.MINUTES);
|
||||
throw new ServiceException(ResultCode.USER_NOT_BINDING);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("联合登陆异常:", e);
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
return token;
|
||||
public Token unionLoginCallback(ConnectAuthUser authUser, String uuid) {
|
||||
return this.unionLoginCallback(authUser, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,6 +93,8 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
Connect connect = new Connect(authUser.getId(), unionId, type);
|
||||
this.save(connect);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,16 +119,6 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Token appLoginCallback(ConnectAuthUser authUser, String uuid) {
|
||||
try {
|
||||
return this.unionLoginCallback(authUser.getSource(), authUser.getUuid(), uuid, true);
|
||||
} catch (NoPermissionException e) {
|
||||
return memberService.autoRegister(authUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@ -226,40 +174,30 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Token phoneMpBindAndLogin(String sessionKey, WechatMPLoginParams params, String openId, String unionId) {
|
||||
String encryptedData = params.getEncryptedData();
|
||||
String iv = params.getIv();
|
||||
JSONObject userInfo = this.getUserInfo(encryptedData, sessionKey, iv);
|
||||
log.info("联合登陆返回:{}", userInfo.toString());
|
||||
String phone = (String) userInfo.get("purePhoneNumber");
|
||||
try {
|
||||
String encryptedData = params.getEncryptedData();
|
||||
String iv = params.getIv();
|
||||
JSONObject userInfo = this.getUserInfo(encryptedData, sessionKey, iv);
|
||||
log.info("联合登陆返回:{}", userInfo.toString());
|
||||
String phone = (String) userInfo.get("purePhoneNumber");
|
||||
|
||||
//手机号登录
|
||||
LambdaQueryWrapper<Member> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(Member::getMobile, phone);
|
||||
Member member = memberService.getOne(lambdaQueryWrapper);
|
||||
//如果不存在会员,则进行绑定微信openid 和 unionid,并且登录
|
||||
if (member != null) {
|
||||
bindMpMember(openId, unionId, member);
|
||||
return memberTokenGenerate.createToken(member, true);
|
||||
ConnectAuthUser connectAuthUser = new ConnectAuthUser();
|
||||
connectAuthUser.setUuid(openId);
|
||||
connectAuthUser.setNickname(params.getNickName());
|
||||
connectAuthUser.setAvatar(params.getImage());
|
||||
connectAuthUser.setUsername("m" + phone);
|
||||
connectAuthUser.setPhone(phone);
|
||||
connectAuthUser.setSource(ConnectEnum.WECHAT.name());
|
||||
connectAuthUser.setType(ClientTypeEnum.WECHAT_MP.name());
|
||||
|
||||
AuthToken authToken = new AuthToken();
|
||||
authToken.setUnionId(unionId);
|
||||
connectAuthUser.setToken(authToken);
|
||||
return this.unionLoginCallback(connectAuthUser, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//如果没有会员,则根据手机号注册会员
|
||||
Member newMember = new Member("m" + phone, "111111", phone, params.getNickName(), params.getImage());
|
||||
memberService.save(newMember);
|
||||
newMember = memberService.findByUsername(newMember.getUsername());
|
||||
|
||||
//判定有没有邀请人并且写入
|
||||
UserContext.settingInviter(newMember.getId(), cache);
|
||||
|
||||
bindMpMember(openId, unionId, newMember);
|
||||
|
||||
|
||||
//判定有没有邀请人并且写入
|
||||
UserContext.settingInviter(newMember.getId(), cache);
|
||||
|
||||
|
||||
// 发送会员注册信息
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), newMember));
|
||||
return memberTokenGenerate.createToken(newMember, true);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -280,47 +218,86 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员绑定 绑定微信小程序
|
||||
* <p>
|
||||
* 如果openid 已经绑定其他账号,则这里不作处理,如果未绑定,则绑定最新的会员
|
||||
* 这样,微信小程序注册之后,其他app 公众号页面,都可以实现绑定自动登录功能
|
||||
* </p>
|
||||
* 成功登录,则检测cookie中的信息,进行会员绑定
|
||||
*
|
||||
* @param openId 微信openid
|
||||
* @param unionId 微信unionid
|
||||
* @param member 会员
|
||||
* @param userId 用户ID
|
||||
* @param unionId 第三方用户ID
|
||||
* @param type 类型
|
||||
*/
|
||||
private void bindMpMember(String openId, String unionId, Member member) {
|
||||
|
||||
|
||||
//如果unionid 不为空 则为账号绑定unionid
|
||||
if (CharSequenceUtil.isNotEmpty(unionId)) {
|
||||
LambdaQueryWrapper<Connect> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lambdaQueryWrapper.eq(Connect::getUnionId, unionId);
|
||||
lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT.name());
|
||||
List<Connect> connects = this.list(lambdaQueryWrapper);
|
||||
if (connects.isEmpty()) {
|
||||
Connect connect = new Connect();
|
||||
connect.setUnionId(unionId);
|
||||
connect.setUserId(member.getId());
|
||||
connect.setUnionType(ConnectEnum.WECHAT.name());
|
||||
this.save(connect);
|
||||
}
|
||||
}//如果openid 不为空 则为账号绑定openid
|
||||
if (CharSequenceUtil.isNotEmpty(openId)) {
|
||||
LambdaQueryWrapper<Connect> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(Connect::getUnionId, openId);
|
||||
lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name());
|
||||
List<Connect> connects = this.list(lambdaQueryWrapper);
|
||||
if (connects.isEmpty()) {
|
||||
Connect connect = new Connect();
|
||||
connect.setUnionId(openId);
|
||||
connect.setUserId(member.getId());
|
||||
connect.setUnionType(ConnectEnum.WECHAT_MP_OPEN_ID.name());
|
||||
this.save(connect);
|
||||
}
|
||||
@Override
|
||||
public void loginBindUser(String userId, String unionId, String type) {
|
||||
Connect connect = this.queryConnect(
|
||||
ConnectQueryDTO.builder().unionId(unionId).unionType(type).build()
|
||||
);
|
||||
//如果未绑定则直接绑定
|
||||
if (connect == null) {
|
||||
connect = new Connect(userId, unionId, type);
|
||||
this.save(connect);
|
||||
//如果已绑定不是当前用户信息则删除绑定信息,重新绑定
|
||||
} else if (!connect.getUserId().equals(userId)) {
|
||||
this.removeById(connect.getId());
|
||||
this.loginBindUser(userId, unionId, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 第三方联合登陆
|
||||
* 1.判断是否使用开放平台
|
||||
* 1.1如果使用开放平台则使用UnionId进行登录
|
||||
* 1.2如果不适用开放平台则使用OpenId进行登录
|
||||
* <p>
|
||||
* 2.用户登录后判断绑定OpenId
|
||||
*
|
||||
* @param authUser 第三方登录封装类
|
||||
* @param longTerm 是否长时间有效
|
||||
* @return token
|
||||
* @throws NoPermissionException 不允许操作
|
||||
*/
|
||||
private Token unionLoginCallback(ConnectAuthUser authUser, boolean longTerm) {
|
||||
|
||||
|
||||
try {
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<Connect>();
|
||||
//使用UnionId登录
|
||||
if (StrUtil.isNotBlank(authUser.getToken().getUnionId())) {
|
||||
queryWrapper.eq(Connect::getUnionId, authUser.getToken().getUnionId())
|
||||
.eq(Connect::getUnionType, authUser.getSource());
|
||||
} else {
|
||||
//使用OpenID登录
|
||||
SourceEnum sourceEnum = SourceEnum.getSourceEnum(ConnectEnum.valueOf(authUser.getType()), ClientTypeEnum.valueOf(authUser.getSource()));
|
||||
queryWrapper.eq(Connect::getUnionId, authUser.getToken().getUnionId())
|
||||
.eq(Connect::getUnionType, sourceEnum.name());
|
||||
}
|
||||
|
||||
//查询绑定关系
|
||||
Connect connect = this.getOne(queryWrapper);
|
||||
Member member = new Member();
|
||||
if (connect == null) {
|
||||
member = memberService.autoRegister(authUser);
|
||||
} else {
|
||||
//查询会员
|
||||
member = memberService.getById(connect.getUserId());
|
||||
//如果未绑定会员,则把刚才查询到的联合登录表数据删除
|
||||
if (member == null) {
|
||||
this.remove(queryWrapper);
|
||||
member = memberService.autoRegister(authUser);
|
||||
}
|
||||
}
|
||||
|
||||
//发送用户第三方登录消息
|
||||
MemberConnectLoginMessage memberConnectLoginMessage = new MemberConnectLoginMessage();
|
||||
memberConnectLoginMessage.setMember(member);
|
||||
memberConnectLoginMessage.setConnectAuthUser(authUser);
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_CONNECT_LOGIN.name();
|
||||
//发送用户第三方登录消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberConnectLoginMessage), RocketmqSendCallbackBuilder.commonCallback());
|
||||
|
||||
return memberTokenGenerate.createToken(member, longTerm);
|
||||
} catch (Exception e) {
|
||||
log.error("联合登陆失败:", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -392,4 +369,6 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_ERROR);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -66,6 +66,7 @@ public class ConnectUtil {
|
||||
|
||||
/**
|
||||
* 回调地址获取
|
||||
*
|
||||
* @param connectAuthEnum 用户枚举
|
||||
* @return 回调地址
|
||||
*/
|
||||
@ -75,9 +76,11 @@ public class ConnectUtil {
|
||||
|
||||
/**
|
||||
* 登录回调
|
||||
* 此方法处理第三方登录回调
|
||||
* 场景:PC、WAP(微信公众号)
|
||||
*
|
||||
* @param type
|
||||
* @param callback
|
||||
* @param type 类型
|
||||
* @param callback 回调参数
|
||||
* @param httpServletResponse
|
||||
* @param httpServletRequest
|
||||
* @throws IOException
|
||||
@ -89,9 +92,8 @@ public class ConnectUtil {
|
||||
//联合登陆处理,如果响应正常,则录入响应结果到redis
|
||||
if (response.ok()) {
|
||||
ConnectAuthUser authUser = response.getData();
|
||||
Token token;
|
||||
try {
|
||||
token = connectService.unionLoginCallback(type, authUser, callback.getState());
|
||||
Token token = connectService.unionLoginCallback(authUser, callback.getState());
|
||||
resultMessage = ResultUtil.data(token);
|
||||
} catch (ServiceException e) {
|
||||
throw new ServiceException(ResultCode.ERROR, e.getMessage());
|
||||
@ -112,7 +114,7 @@ public class ConnectUtil {
|
||||
try {
|
||||
httpServletResponse.sendRedirect(url);
|
||||
} catch (Exception e) {
|
||||
log.error("登录回调错误",e);
|
||||
log.error("登录回调错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +167,7 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthWeChatPCRequest(AuthConfig.builder()
|
||||
@ -178,10 +181,10 @@ public class ConnectUtil {
|
||||
break;
|
||||
}
|
||||
case QQ:
|
||||
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.QQ_CONNECT.name());
|
||||
QQConnectSetting qqConnectSetting = JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class);
|
||||
|
||||
for (QQConnectSettingItem qqConnectSettingItem : qqConnectSetting.getQqConnectSettingItemList()) {
|
||||
if (qqConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthQQRequest(AuthConfig.builder()
|
||||
|
@ -32,10 +32,11 @@ public class Distribution extends BaseEntity {
|
||||
public Distribution(String memberId, String memberName, DistributionApplyDTO distributionApplyDTO) {
|
||||
this.memberId = memberId;
|
||||
this.memberName = memberName;
|
||||
distributionOrderCount=0;
|
||||
this.distributionOrderCount=0;
|
||||
this.rebateTotal=0D;
|
||||
this.canRebate=0D;
|
||||
this.commissionFrozen=0D;
|
||||
this.distributionStatus = DistributionStatusEnum.APPLY.name();
|
||||
commissionFrozen=0D;
|
||||
canRebate=0D;
|
||||
BeanUtil.copyProperties(distributionApplyDTO, this);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
* @param commissionFrozen 分销金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set commission_frozen = (commission_frozen+#{commissionFrozen}) " +
|
||||
", rebate_total=(rebate_total+#{commissionFrozen}) WHERE id = #{distributionId}")
|
||||
@Update("UPDATE li_distribution set commission_frozen = (IFNULL(commission_frozen,0)+#{commissionFrozen}) " +
|
||||
", rebate_total=(IFNULL(rebate_total,0)+#{commissionFrozen}) WHERE id = #{distributionId}")
|
||||
void subCanRebate(Double commissionFrozen, String distributionId);
|
||||
|
||||
/**
|
||||
@ -29,9 +29,9 @@ public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
* @param commissionFrozen 分销金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set commission_frozen = (commission_frozen+#{commissionFrozen}) " +
|
||||
", rebate_total=(rebate_total+#{commissionFrozen}) " +
|
||||
", distribution_order_count=(distribution_order_count+1) WHERE id = #{distributionId}")
|
||||
@Update("UPDATE li_distribution set commission_frozen = (IFNULL(commission_frozen,0)+#{commissionFrozen}) " +
|
||||
", rebate_total=(IFNULL(rebate_total,0)+#{commissionFrozen}) " +
|
||||
", distribution_order_count=(IFNULL(distribution_order_count,0)+1) WHERE id = #{distributionId}")
|
||||
void addCanRebate(Double commissionFrozen, String distributionId);
|
||||
|
||||
}
|
@ -83,7 +83,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
||||
memberWithdrawalMessage.setPrice(applyMoney);
|
||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
@ -147,7 +146,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
//组织会员提现审核消息
|
||||
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
||||
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
|
||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class HuaweiFilePlugin implements FilePlugin {
|
||||
* @return
|
||||
*/
|
||||
private ObsClient getObsClient() {
|
||||
return new ObsClient(ossSetting.getHuaweicloudOBSAccessKey(), ossSetting.getHuaweicloudOBSSecretKey(), ossSetting.getAliyunOSSEndPoint());
|
||||
return new ObsClient(ossSetting.getHuaweicloudOBSAccessKey(), ossSetting.getHuaweicloudOBSSecretKey(), ossSetting.getHuaweicloudOBSEndPoint());
|
||||
}
|
||||
|
||||
|
||||
@ -72,14 +72,17 @@ public class HuaweiFilePlugin implements FilePlugin {
|
||||
public String inputStreamUpload(InputStream inputStream, String key) {
|
||||
ObsClient obsClient = getObsClient();
|
||||
try {
|
||||
obsClient.putObject(new PutObjectRequest(ossSetting.getHuaweicloudOBSBucketName(), key, inputStream));
|
||||
PutObjectRequest putObjectRequest=new PutObjectRequest(ossSetting.getHuaweicloudOBSBucketName(), key, inputStream);
|
||||
obsClient.putObject(putObjectRequest);
|
||||
} catch (ObsException obsException) {
|
||||
obsException.printStackTrace();
|
||||
throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
|
||||
} finally {
|
||||
try {
|
||||
// 关闭OBS连接
|
||||
obsClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("OBS关闭连接报错!" + e.getMessage());
|
||||
throw new ServiceException(ResultCode.OSS_EXCEPTION_ERROR);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.entity.dos;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
@ -219,7 +220,7 @@ public class Goods extends BaseEntity {
|
||||
this.mobileIntro = goodsDTO.getMobileIntro();
|
||||
this.goodsVideo = goodsDTO.getGoodsVideo();
|
||||
this.price = goodsDTO.getPrice();
|
||||
if (goodsDTO.getGoodsParamsDTOList() != null && goodsDTO.getGoodsParamsDTOList().isEmpty()) {
|
||||
if (CollectionUtil.isNotEmpty(goodsDTO.getGoodsParamsDTOList())){
|
||||
this.params = JSONUtil.toJsonStr(goodsDTO.getGoodsParamsDTOList());
|
||||
}
|
||||
//如果立即上架则
|
||||
|
@ -10,7 +10,6 @@ import cn.lili.modules.system.entity.dto.GoodsSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -39,7 +38,7 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(List<String> goodsGalleryList, String goodsId) {
|
||||
//删除原来商品相册信息
|
||||
this.baseMapper.delete(new UpdateWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
this.baseMapper.delete(new QueryWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
//确定好图片选择器后进行处理
|
||||
int i = 0;
|
||||
for (String origin : goodsGalleryList) {
|
||||
@ -83,6 +82,6 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
*/
|
||||
@Override
|
||||
public void removeByGoodsId(String goodsId) {
|
||||
this.baseMapper.delete(new UpdateWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
this.baseMapper.delete(new QueryWrapper<GoodsGallery>().eq("goods_id", goodsId));
|
||||
}
|
||||
}
|
@ -133,7 +133,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
//获取商品ID列表
|
||||
List<String> list = this.baseMapper.getGoodsIdByStoreId(storeId);
|
||||
//下架店铺下的商品
|
||||
updateGoodsMarketAble(list, GoodsStatusEnum.DOWN, "店铺关闭");
|
||||
this.updateGoodsMarketAbleByStoreId(storeId, GoodsStatusEnum.DOWN, "店铺关闭");
|
||||
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("下架商品",
|
||||
rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.DOWN.name(), JSONUtil.toJsonStr(list)));
|
||||
|
@ -312,9 +312,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
map.put("data", goodsSkuDetail);
|
||||
|
||||
//获取分类
|
||||
String[] split = goodsSkuDetail.getCategoryPath().split(",");
|
||||
map.put("wholesaleList", wholesaleService.findByGoodsId(goodsSkuDetail.getGoodsId()));
|
||||
map.put("categoryName", categoryService.getCategoryNameByIds(Arrays.asList(split)));
|
||||
map.put("wholesaleList", GoodsSalesModeEnum.WHOLESALE.name().equals(goodsVO.getSalesModel()) ? wholesaleService.findByGoodsId(goodsSkuDetail.getGoodsId()) : Collections.emptyList());
|
||||
map.put("categoryName", CharSequenceUtil.isNotEmpty(goodsIndex.getCategoryNamePath()) ? goodsIndex.getCategoryNamePath().split(",") : null);
|
||||
|
||||
//获取规格信息
|
||||
map.put("specs", this.groupBySkuAndSpec(goodsVO.getSkuList()));
|
||||
|
@ -21,6 +21,13 @@ public interface ImTalkService extends IService<ImTalk> {
|
||||
*/
|
||||
ImTalk getTalkByUser(String userId1);
|
||||
|
||||
/**
|
||||
* 获取与某人的聊天
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
ImTalkVO getTalkByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 置顶消息
|
||||
*
|
||||
|
@ -77,16 +77,61 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
if(otherStore != null){
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
this.save(imTalk);
|
||||
}
|
||||
return imTalk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImTalkVO getTalkByUserId(String userId) {
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
//登录用户的Id
|
||||
String selfId = "";
|
||||
//查看当前用户角色对Id进行赋值
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
selfId = currentUser.getStoreId();
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
selfId = currentUser.getId();
|
||||
}
|
||||
//小数在前保证永远是同一个对话
|
||||
String finalSelfId = selfId;
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
ImTalk imTalk = this.getOne(queryWrapper);
|
||||
//如果没有聊天,则创建聊天
|
||||
if (imTalk == null) {
|
||||
//当自己为店铺时
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
Store selfStore = storeService.getById(selfId);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId);
|
||||
if(other == null){
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(other,selfStore);
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
//没有这个店铺信息
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
this.save(imTalk);
|
||||
}
|
||||
return new ImTalkVO(imTalk,currentUser.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起聊天后,如果聊天不可见为true,则需要修正
|
||||
*
|
||||
|
@ -1,15 +1,9 @@
|
||||
package cn.lili.modules.member.mapper;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 浏览历史数据处理层
|
||||
@ -23,10 +17,21 @@ public interface FootprintMapper extends BaseMapper<FootPrint> {
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
*/
|
||||
|
||||
@Delete("DELETE FROM li_foot_print WHERE id IN ("+
|
||||
"SELECT l2.id FROM (" +
|
||||
"SELECT l3.id FROM li_foot_print l3 WHERE l3.member_id=${memberId} ORDER BY id DESC LIMIT 100,100) l2)")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Delete("DELETE li_foot_print " +
|
||||
"FROM li_foot_print " +
|
||||
"LEFT JOIN ( " +
|
||||
" SELECT id " +
|
||||
" FROM ( " +
|
||||
" SELECT id " +
|
||||
" FROM li_foot_print " +
|
||||
" WHERE member_id = ${memberId} " +
|
||||
" ORDER BY create_time DESC " +
|
||||
" LIMIT 1 " +
|
||||
" ) AS keep " +
|
||||
") AS latest_footprints " +
|
||||
"ON li_foot_print.id = latest_footprints.id " +
|
||||
"WHERE li_foot_print.member_id = ${memberId} AND latest_footprints.id IS NULL; ")
|
||||
void deleteLastFootPrint(String memberId);
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ import cn.lili.modules.member.entity.vo.QRLoginResultVo;
|
||||
import cn.lili.modules.member.entity.vo.QRCodeLoginSessionVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.elasticsearch.monitor.os.OsStats;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -183,12 +184,12 @@ public interface MemberService extends IService<Member> {
|
||||
IPage<MemberVO> getMemberPage(MemberSearchVO memberSearchVO, PageVO page);
|
||||
|
||||
|
||||
/**
|
||||
* 一键注册会员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Token autoRegister();
|
||||
// /**
|
||||
// * 一键注册会员
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// Token autoRegister();
|
||||
|
||||
/**
|
||||
* 一键注册会员
|
||||
@ -196,7 +197,7 @@ public interface MemberService extends IService<Member> {
|
||||
* @param authUser 联合登录用户
|
||||
* @return Token
|
||||
*/
|
||||
Token autoRegister(ConnectAuthUser authUser);
|
||||
Member autoRegister(ConnectAuthUser authUser);
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
|
@ -149,6 +149,11 @@ public class ClerkServiceImpl extends ServiceImpl<ClerkMapper, Clerk> implements
|
||||
public Clerk updateClerk(ClerkEditDTO clerkEditDTO) {
|
||||
Clerk clerk = this.getById(clerkEditDTO.getId());
|
||||
if (clerk != null) {
|
||||
//编辑店主限制
|
||||
if(clerk.getShopkeeper()){
|
||||
throw new ServiceException(ResultCode.CANT_EDIT_CLERK_SHOPKEEPER);
|
||||
}
|
||||
|
||||
//校验当前店员是否是当前店铺的
|
||||
if (!clerk.getStoreId().equals(UserContext.getCurrentUser().getStoreId())) {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
|
@ -239,7 +239,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Token autoRegister(ConnectAuthUser authUser) {
|
||||
public Member autoRegister(ConnectAuthUser authUser) {
|
||||
|
||||
if (CharSequenceUtil.isEmpty(authUser.getNickname())) {
|
||||
authUser.setNickname("临时昵称");
|
||||
@ -251,11 +251,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
String username = UuidUtils.getUUID();
|
||||
Member member = new Member(username, UuidUtils.getUUID(), authUser.getAvatar(), authUser.getNickname(),
|
||||
authUser.getGender() != null ? Convert.toInt(authUser.getGender().getCode()) : 0);
|
||||
registerHandler(member);
|
||||
member.setPassword(DEFAULT_PASSWORD);
|
||||
//绑定登录方式
|
||||
loginBindUser(member, authUser.getUuid(), authUser.getSource());
|
||||
return memberTokenGenerate.createToken(member, false);
|
||||
// 发送会员注册信息
|
||||
registerHandler(member);
|
||||
|
||||
return member;
|
||||
} catch (ServiceException e) {
|
||||
log.error("自动注册服务抛出异常:", e);
|
||||
throw e;
|
||||
@ -265,12 +265,12 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Token autoRegister() {
|
||||
ConnectAuthUser connectAuthUser = this.checkConnectUser();
|
||||
return this.autoRegister(connectAuthUser);
|
||||
}
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public Token autoRegister() {
|
||||
// ConnectAuthUser connectAuthUser = this.checkConnectUser();
|
||||
// return this.autoRegister(connectAuthUser);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Token refreshToken(String refreshToken) {
|
||||
@ -308,7 +308,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
//保存会员
|
||||
this.save(member);
|
||||
|
||||
|
||||
// 发送会员注册信息
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("new member register", rocketmqCustomProperties.getMemberTopic(), MemberTagsEnum.MEMBER_REGISTER.name(), member));
|
||||
}
|
||||
@ -572,23 +571,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功登录,则检测cookie中的信息,进行会员绑定
|
||||
*
|
||||
* @param member 会员
|
||||
* @param unionId unionId
|
||||
* @param type 状态
|
||||
*/
|
||||
private void loginBindUser(Member member, String unionId, String type) {
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().unionId(unionId).unionType(type).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
connect = new Connect(member.getId(), unionId, type);
|
||||
connectService.save(connect);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功登录,则检测cookie中的信息,进行会员绑定
|
||||
*
|
||||
@ -627,42 +609,42 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测是否可以绑定第三方联合登陆
|
||||
* 返回null原因
|
||||
* 包含原因1:redis中已经没有联合登陆信息 2:已绑定其他账号
|
||||
*
|
||||
* @return 返回对象则代表可以进行绑定第三方会员,返回null则表示联合登陆无法继续
|
||||
*/
|
||||
private ConnectAuthUser checkConnectUser() {
|
||||
//获取cookie存储的信息
|
||||
String uuid = CookieUtil.getCookie(ConnectService.CONNECT_COOKIE, ThreadContextHolder.getHttpRequest());
|
||||
String connectType = CookieUtil.getCookie(ConnectService.CONNECT_TYPE, ThreadContextHolder.getHttpRequest());
|
||||
|
||||
//如果联合登陆存储了信息
|
||||
if (CharSequenceUtil.isNotEmpty(uuid) && CharSequenceUtil.isNotEmpty(connectType)) {
|
||||
//枚举 联合登陆类型获取
|
||||
ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(connectType);
|
||||
|
||||
ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
|
||||
if (connectAuthUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_OVERDUE_CONNECT_ERROR);
|
||||
}
|
||||
//检测是否已经绑定过用户
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().unionType(connectType).unionId(connectAuthUser.getUuid()).build()
|
||||
);
|
||||
//没有关联则返回true,表示可以继续绑定
|
||||
if (connect == null) {
|
||||
connectAuthUser.setConnectEnum(authInterface);
|
||||
return connectAuthUser;
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_BANDING_ERROR);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.USER_CONNECT_NOT_EXIST_ERROR);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 检测是否可以绑定第三方联合登陆
|
||||
// * 返回null原因
|
||||
// * 包含原因1:redis中已经没有联合登陆信息 2:已绑定其他账号
|
||||
// *
|
||||
// * @return 返回对象则代表可以进行绑定第三方会员,返回null则表示联合登陆无法继续
|
||||
// */
|
||||
// private ConnectAuthUser checkConnectUser() {
|
||||
// //获取cookie存储的信息
|
||||
// String uuid = CookieUtil.getCookie(ConnectService.CONNECT_COOKIE, ThreadContextHolder.getHttpRequest());
|
||||
// String connectType = CookieUtil.getCookie(ConnectService.CONNECT_TYPE, ThreadContextHolder.getHttpRequest());
|
||||
//
|
||||
// //如果联合登陆存储了信息
|
||||
// if (CharSequenceUtil.isNotEmpty(uuid) && CharSequenceUtil.isNotEmpty(connectType)) {
|
||||
// //枚举 联合登陆类型获取
|
||||
// ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(connectType);
|
||||
//
|
||||
// ConnectAuthUser connectAuthUser = getConnectAuthUser(uuid, connectType);
|
||||
// if (connectAuthUser == null) {
|
||||
// throw new ServiceException(ResultCode.USER_OVERDUE_CONNECT_ERROR);
|
||||
// }
|
||||
// //检测是否已经绑定过用户
|
||||
// Connect connect = connectService.queryConnect(
|
||||
// ConnectQueryDTO.builder().unionType(connectType).unionId(connectAuthUser.getUuid()).build()
|
||||
// );
|
||||
// //没有关联则返回true,表示可以继续绑定
|
||||
// if (connect == null) {
|
||||
// connectAuthUser.setConnectEnum(authInterface);
|
||||
// return connectAuthUser;
|
||||
// } else {
|
||||
// throw new ServiceException(ResultCode.USER_CONNECT_BANDING_ERROR);
|
||||
// }
|
||||
// } else {
|
||||
// throw new ServiceException(ResultCode.USER_CONNECT_NOT_EXIST_ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public long getMemberNum(MemberSearchVO memberSearchVO) {
|
||||
|
@ -48,10 +48,11 @@ public enum NoticeMessageNodeEnum {
|
||||
* 用户余额
|
||||
*/
|
||||
WALLET_CHANGE("余额账户变更通知"),
|
||||
WALLET_WITHDRAWAL_CREATE("提现申请提交成功通知"),
|
||||
WALLET_WITHDRAWAL_CREATE("余额提现申请提交成功通知"),
|
||||
WALLET_WITHDRAWAL_SUCCESS("余额提现成功通知"),
|
||||
WALLET_WITHDRAWAL_WEICHAT_SUCCESS("微信提现成功通知"),
|
||||
WALLET_WITHDRAWAL_ERROR("提现申请驳回通知");
|
||||
WALLET_WITHDRAWAL_ERROR("余额提现申请失败通知"),
|
||||
WALLET_WITHDRAWAL_AUDIT_ERROR("余额提现申请驳回通知"),
|
||||
WALLET_WITHDRAWAL_AUDIT_SUCCESS("余额提现申请通过通知");
|
||||
|
||||
|
||||
private final String description;
|
||||
|
@ -54,7 +54,7 @@ public class NoticeMessageServiceImpl extends ServiceImpl<NoticeMessageTemplateM
|
||||
NoticeMessage noticeMessage = this.getOne(
|
||||
new LambdaQueryWrapper<NoticeMessage>()
|
||||
.eq(NoticeMessage::getNoticeNode
|
||||
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()));
|
||||
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()),false);
|
||||
//如果通知类站内信开启的情况下
|
||||
if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) {
|
||||
MemberMessage memberMessage = new MemberMessage();
|
||||
|
@ -259,7 +259,7 @@ public class CheckDataRender implements CartRenderStep {
|
||||
*/
|
||||
private void preSaleModel(TradeDTO tradeDTO) {
|
||||
// 寻找同goods下销售模式为批发的商品
|
||||
Map<String, List<CartSkuVO>> goodsGroup = tradeDTO.getSkuList().stream().filter(i -> i.getGoodsSku().getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())).collect(Collectors.groupingBy(i -> i.getGoodsSku().getGoodsId()));
|
||||
Map<String, List<CartSkuVO>> goodsGroup = tradeDTO.getCheckedSkuList().stream().filter(i -> i.getGoodsSku().getSalesModel().equals(GoodsSalesModeEnum.WHOLESALE.name())).collect(Collectors.groupingBy(i -> i.getGoodsSku().getGoodsId()));
|
||||
if (CollUtil.isNotEmpty(goodsGroup)) {
|
||||
goodsGroup.forEach((k, v) -> {
|
||||
// 获取购买总数
|
||||
|
@ -71,7 +71,7 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
&& !freightTemplate.getFreightTemplateChildList().isEmpty()) {
|
||||
//店铺模版免运费则跳过
|
||||
if (freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())) {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
//运费模版
|
||||
|
@ -145,13 +145,15 @@ public class CashierSupport {
|
||||
|
||||
/**
|
||||
* 用户提现
|
||||
* @param paymentMethodEnum 支付渠道
|
||||
*
|
||||
* @param paymentMethodEnum 支付渠道
|
||||
* @param memberWithdrawApply 用户提现申请
|
||||
*/
|
||||
public void transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply){
|
||||
public boolean transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply) {
|
||||
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());
|
||||
payment.transfer(memberWithdrawApply);
|
||||
return payment.transfer(memberWithdrawApply);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收银台参数
|
||||
*
|
||||
|
@ -114,7 +114,7 @@ public interface Payment {
|
||||
/**
|
||||
* 提现
|
||||
*/
|
||||
default void transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
default boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
throw new ServiceException(ResultCode.PAY_ERROR);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.domain.*;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
||||
import com.alipay.api.response.AlipayTradeRefundResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -238,7 +237,7 @@ public class AliPayPlugin implements Payment {
|
||||
* @param memberWithdrawApply 会员提现申请
|
||||
*/
|
||||
@Override
|
||||
public void transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
||||
model.setOutBizNo(SnowFlake.createStr("T"));
|
||||
model.setRemark("用户提现");
|
||||
@ -255,10 +254,10 @@ public class AliPayPlugin implements Payment {
|
||||
model.setOrderTitle("用户提现");
|
||||
//交互退款
|
||||
try {
|
||||
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model,null);
|
||||
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model, null);
|
||||
log.error("支付宝退款,参数:{},支付宝响应:{}", JSONUtil.toJsonStr(model), JSONUtil.toJsonStr(alipayFundTransUniTransferResponse));
|
||||
if (alipayFundTransUniTransferResponse.isSuccess()) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
log.error(alipayFundTransUniTransferResponse.getSubMsg());
|
||||
}
|
||||
@ -266,6 +265,7 @@ public class AliPayPlugin implements Payment {
|
||||
log.error("用户提现异常:", e);
|
||||
throw new ServiceException(ResultCode.PAY_ERROR);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@ import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.member.entity.dto.ConnectQueryDTO;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
@ -39,12 +40,17 @@ import cn.lili.modules.payment.kit.plugin.wechat.model.*;
|
||||
import cn.lili.modules.payment.service.PaymentService;
|
||||
import cn.lili.modules.payment.service.RefundLogService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.WithdrawalSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem;
|
||||
import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.atp.Switch;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -173,7 +179,7 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
try {
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId()).unionType(ConnectEnum.WECHAT.name()).build()
|
||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId()).unionType(SourceEnum.WECHAT_OFFIACCOUNT_OPEN_ID.name()).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
return null;
|
||||
@ -378,7 +384,7 @@ public class WechatPlugin implements Payment {
|
||||
|
||||
try {
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId()).unionType(ConnectEnum.WECHAT_MP_OPEN_ID.name()).build()
|
||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId()).unionType(SourceEnum.WECHAT_MP_OPEN_ID.name()).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
return null;
|
||||
@ -475,17 +481,43 @@ public class WechatPlugin implements Payment {
|
||||
* @param memberWithdrawApply 会员提现申请
|
||||
*/
|
||||
@Override
|
||||
public void transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
|
||||
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||
try {
|
||||
WechatPaymentSetting setting = wechatPaymentSetting();
|
||||
//获取提现设置
|
||||
WithdrawalSetting withdrawalSetting = new Gson().fromJson(settingService.get(SettingEnum.WITHDRAWAL_SETTING.name()).getSettingValue(), WithdrawalSetting.class);
|
||||
|
||||
//获取用户OPENID
|
||||
WechatConnectSetting wechatConnectSetting = new Gson().fromJson(settingService.get(SettingEnum.WECHAT_CONNECT.name()).getSettingValue(), WechatConnectSetting.class);
|
||||
String source = "";
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getAppId().equals(withdrawalSetting.getWechatAppId())) {
|
||||
switch (wechatConnectSettingItem.getClientType()) {
|
||||
case "PC":
|
||||
source = SourceEnum.WECHAT_PC_OPEN_ID.name();
|
||||
break;
|
||||
case "H5":
|
||||
source = SourceEnum.WECHAT_OFFIACCOUNT_OPEN_ID.name();
|
||||
break;
|
||||
case "MP":
|
||||
source = SourceEnum.WECHAT_MP_OPEN_ID.name();
|
||||
break;
|
||||
case "APP":
|
||||
source = SourceEnum.WECHAT_APP_OPEN_ID.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取微信设置
|
||||
WechatPaymentSetting wechatPaymentSetting = wechatPaymentSetting();
|
||||
//获取用户openId
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId())
|
||||
.unionType(ConnectEnum.WECHAT_OPEN_ID.name()).build()
|
||||
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
|
||||
.unionType(source).build()
|
||||
);
|
||||
//根据自身情况设置AppId,此处我存放的是服务号的APPID,下方的openID需要对应此处的APPID配置
|
||||
//构建提现,发起申请
|
||||
TransferModel transferModel = new TransferModel()
|
||||
.setAppid(setting.getServiceAppId())
|
||||
.setAppid(withdrawalSetting.getWechatAppId())
|
||||
.setOut_batch_no(SnowFlake.createStr("T"))
|
||||
.setBatch_name("用户提现")
|
||||
.setBatch_remark("用户提现")
|
||||
@ -499,10 +531,6 @@ public class WechatPlugin implements Payment {
|
||||
transferDetailInput.setTransfer_amount(CurrencyUtil.fen(memberWithdrawApply.getApplyMoney()));
|
||||
transferDetailInput.setTransfer_remark("用户提现");
|
||||
transferDetailInput.setOpenid(connect.getUnionId());
|
||||
// transferDetailInput.setUserName(
|
||||
// "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45");
|
||||
// transferDetailInput.setUserIdCard(
|
||||
// "8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f");
|
||||
transferDetailListList.add(transferDetailInput);
|
||||
}
|
||||
transferModel.setTransfer_detail_list(transferDetailListList);
|
||||
@ -511,17 +539,21 @@ public class WechatPlugin implements Payment {
|
||||
RequestMethodEnums.POST,
|
||||
WechatDomain.CHINA.toString(),
|
||||
WechatApiEnum.TRANSFER_BATCHES.toString(),
|
||||
setting.getMchId(),
|
||||
setting.getSerialNumber(),
|
||||
wechatPaymentSetting.getMchId(),
|
||||
wechatPaymentSetting.getSerialNumber(),
|
||||
null,
|
||||
setting.getApiclient_key(),
|
||||
wechatPaymentSetting.getApiclient_key(),
|
||||
JSONUtil.toJsonStr(transferModel)
|
||||
);
|
||||
log.info("微信提现响应 {}", response);
|
||||
String body = response.getBody();
|
||||
JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||
return jsonObject.getStr("batch_id") != null ? true : false;
|
||||
//根据自身业务进行接下来的任务处理
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
.getTitle()
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("填充部门信息异常", e);
|
||||
log.debug("权限部门信息异常", e);
|
||||
}
|
||||
}
|
||||
if (!CharSequenceUtil.isEmpty(adminUser.getRoleIds())) {
|
||||
@ -97,7 +97,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("填充部门信息异常", e);
|
||||
log.debug("权限色信息异常", e);
|
||||
}
|
||||
}
|
||||
result.add(adminUserVO);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.lili.modules.permission.serviceimpl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
@ -9,7 +8,9 @@ import cn.lili.modules.permission.repository.SystemLogRepository;
|
||||
import cn.lili.modules.permission.service.SystemLogService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
@ -82,25 +83,22 @@ public class SystemLogServiceImpl implements SystemLogService {
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(operatorName)) {
|
||||
nativeSearchQueryBuilder.withFilter(QueryBuilders.wildcardQuery("username", "*" + operatorName + "*"));
|
||||
nativeSearchQueryBuilder.withQuery(QueryBuilders.matchQuery("username", operatorName));
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(key)) {
|
||||
BoolQueryBuilder filterBuilder = new BoolQueryBuilder();
|
||||
filterBuilder.should(QueryBuilders.wildcardQuery("requestUrl", "*" + key + "*"))
|
||||
.should(QueryBuilders.wildcardQuery("requestParam", "*" + key + "*"))
|
||||
.should(QueryBuilders.wildcardQuery("responseBody", "*" + key + "*"))
|
||||
.should(QueryBuilders.wildcardQuery("name", "*" + key + "*"));
|
||||
nativeSearchQueryBuilder.withFilter(filterBuilder);
|
||||
MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery(key, "requestUrl", "requestParam", "responseBody", "name");
|
||||
multiMatchQueryBuilder.fuzziness(Fuzziness.AUTO);
|
||||
nativeSearchQueryBuilder.withFilter(multiMatchQueryBuilder);
|
||||
}
|
||||
//时间有效性判定
|
||||
if (searchVo.getConvertStartDate() != null && searchVo.getConvertEndDate() != null) {
|
||||
BoolQueryBuilder filterBuilder = new BoolQueryBuilder();
|
||||
//大于方法
|
||||
filterBuilder.must(
|
||||
filterBuilder.filter(
|
||||
QueryBuilders.rangeQuery("createTime")
|
||||
.gte(DateUtil.format(searchVo.getConvertStartDate(), "dd/MM/yyyy"))
|
||||
.lte(DateUtil.format(searchVo.getConvertEndDate(), "dd/MM/yyyy")).format("dd/MM/yyyy||yyyy"));
|
||||
.gte(searchVo.getConvertStartDate().getTime())
|
||||
.lte(searchVo.getConvertEndDate().getTime()));
|
||||
|
||||
nativeSearchQueryBuilder.withFilter(filterBuilder);
|
||||
}
|
||||
|
@ -293,6 +293,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
|
||||
LambdaUpdateWrapper<MemberCoupon> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(MemberCoupon::getId, memberCouponIds);
|
||||
updateWrapper.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.NEW.name());
|
||||
updateWrapper.set(MemberCoupon::getConsumptionTime, null);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
public void deleteIndex(Map<String, Object> queryFields) {
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
for (Map.Entry<String, Object> entry : queryFields.entrySet()) {
|
||||
boolQueryBuilder.filter(QueryBuilders.termsQuery(entry.getKey(), entry.getValue()));
|
||||
boolQueryBuilder.filter(QueryBuilders.termsQuery(entry.getKey(), entry.getValue().toString()));
|
||||
}
|
||||
|
||||
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest();
|
||||
|
@ -15,6 +15,7 @@ import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
|
||||
import cn.lili.modules.search.entity.dto.ParamOptions;
|
||||
import cn.lili.modules.search.entity.dto.SelectorOptions;
|
||||
import cn.lili.modules.search.service.EsGoodsSearchService;
|
||||
import cn.lili.modules.search.utils.SqlFilter;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
@ -81,7 +82,10 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
|
||||
|
||||
@Override
|
||||
public SearchPage<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
|
||||
if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword())) {
|
||||
|
||||
//如果搜索词不为空,且明显不是sql注入,那么就将搜索词加入热搜词
|
||||
//PS:线上环境运行很多客户反馈被sql攻击,写在了搜索热词里,这里控制命中关键字就不做热词统计,如果线上比较严格可以调用关键词替换,不过不建议这么做
|
||||
if (CharSequenceUtil.isNotBlank(searchDTO.getKeyword()) && !SqlFilter.hit(searchDTO.getKeyword())) {
|
||||
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword());
|
||||
}
|
||||
NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo);
|
||||
|
@ -0,0 +1,59 @@
|
||||
package cn.lili.modules.search.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* sql 关键字过滤
|
||||
*
|
||||
* @author liushuai(liushuai711 @ gmail.com)
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2023/3/22 17:27
|
||||
*/
|
||||
|
||||
public class SqlFilter {
|
||||
|
||||
private static final Set<String> SQL_KEYWORDS = new HashSet<>(Arrays.asList(
|
||||
"SELECT", "FROM", "WHERE", "AND", "OR", "NOT", "INSERT", "UPDATE", "DELETE", "CREATE",
|
||||
"TABLE", "INDEX", "VIEW", "DROP", "ALTER", "COLUMN", "ADD", "SET", "GROUP", "BY",
|
||||
"HAVING", "ORDER", "ASC", "DESC", "LIKE", "IN", "BETWEEN", "IS", "NULL", "TRUE", "FALSE",
|
||||
"JOIN", "LEFT", "RIGHT", "INNER", "OUTER", "FULL", "ON", "AS", "DISTINCT", "COUNT",
|
||||
"MAX", "MIN", "SUM", "AVG"
|
||||
));
|
||||
|
||||
|
||||
/**
|
||||
* 关键字命中
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public static Boolean hit(String sql) {
|
||||
String[] tokens = sql.split("\\s+");
|
||||
for (String token : tokens) {
|
||||
if (!SQL_KEYWORDS.contains(token.toUpperCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字替换
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public static String filterSql(String sql) {
|
||||
String[] tokens = sql.split("\\s+");
|
||||
StringBuilder filteredSql = new StringBuilder();
|
||||
for (String token : tokens) {
|
||||
if (!SQL_KEYWORDS.contains(token.toUpperCase())) {
|
||||
filteredSql.append(token).append(" ");
|
||||
}
|
||||
}
|
||||
return filteredSql.toString().trim();
|
||||
}
|
||||
}
|
@ -235,11 +235,16 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
public boolean disable(String id) {
|
||||
Store store = this.getById(id);
|
||||
if (store != null) {
|
||||
store.setStoreDisable(StoreStatusEnum.CLOSED.value());
|
||||
|
||||
LambdaUpdateWrapper<Store> storeLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
storeLambdaUpdateWrapper.eq(Store::getId, id);
|
||||
storeLambdaUpdateWrapper.set(Store::getStoreDisable, StoreStatusEnum.CLOSED.value());
|
||||
boolean update = this.update(storeLambdaUpdateWrapper);
|
||||
//下架所有此店铺商品
|
||||
goodsService.underStoreGoods(id);
|
||||
return this.updateById(store);
|
||||
if (update) {
|
||||
goodsService.underStoreGoods(id);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
throw new ServiceException(ResultCode.STORE_NOT_EXIST);
|
||||
|
@ -15,7 +15,28 @@ public class WithdrawalSetting implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3872782530832122976L;
|
||||
/**
|
||||
* 提现是否需要申请
|
||||
* 提现最低金额
|
||||
*/
|
||||
private Double minPrice;
|
||||
/**
|
||||
* 提现手续费
|
||||
*/
|
||||
private Double fee;
|
||||
/**
|
||||
* 提现类型 WECHAT\ALI
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 提现是否需要审核
|
||||
*/
|
||||
private Boolean apply;
|
||||
|
||||
/**
|
||||
* 微信提现-渠道使用的APPID
|
||||
*/
|
||||
private String wechatAppId;
|
||||
/**
|
||||
* 微信APPID渠道
|
||||
*/
|
||||
private String wechatAppIdSource;
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package cn.lili.modules.system.entity.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户提现设置VO
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2023/3/1
|
||||
*/
|
||||
@Data
|
||||
public class WithdrawalSettingVO {
|
||||
|
||||
/**
|
||||
* 提现最低金额
|
||||
*/
|
||||
@ApiModelProperty(value = "minPrice")
|
||||
private Double minPrice;
|
||||
/**
|
||||
* 提现手续费
|
||||
*/
|
||||
@ApiModelProperty(value = "提现手续费")
|
||||
private Double fee;
|
||||
/**
|
||||
* 提现类型 WECHAT\ALI
|
||||
*/
|
||||
@ApiModelProperty(value = "提现类型 WECHAT、ALI")
|
||||
private String type;
|
||||
|
||||
}
|
@ -56,8 +56,14 @@ public class MemberWithdrawApply extends BaseEntity {
|
||||
@ApiModelProperty(value = "sn")
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 支付宝提现时必填
|
||||
*/
|
||||
@ApiModelProperty(value = "真实姓名")
|
||||
private String realName;
|
||||
/**
|
||||
* 支付宝登录账号
|
||||
*/
|
||||
@ApiModelProperty(value = "第三方平台账号")
|
||||
private String connectNumber;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.lili.modules.wallet.entity.dto;
|
||||
|
||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ -13,6 +12,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class MemberWithdrawalMessage {
|
||||
|
||||
@ApiModelProperty(value = "提现申请ID")
|
||||
private String memberWithdrawApplyId;
|
||||
|
||||
@ApiModelProperty(value = "金额")
|
||||
private Double price;
|
||||
|
||||
@ -22,9 +24,4 @@ public class MemberWithdrawalMessage {
|
||||
@ApiModelProperty(value = "提现状态")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* @see MemberWithdrawalDestinationEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "提现到哪里")
|
||||
private String destination;
|
||||
}
|
||||
|
@ -18,7 +18,15 @@ public enum WithdrawStatusEnum {
|
||||
/**
|
||||
* 审核未通过
|
||||
*/
|
||||
FAIL_AUDITING("审核未通过");
|
||||
FAIL_AUDITING("审核未通过"),
|
||||
/**
|
||||
* 提现成功
|
||||
*/
|
||||
SUCCESS("提现成功"),
|
||||
/**
|
||||
* 提现失败
|
||||
*/
|
||||
ERROR("提现失败");
|
||||
|
||||
private String description;
|
||||
|
||||
|
@ -3,10 +3,10 @@ package cn.lili.modules.wallet.service;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.wallet.entity.dos.MemberWallet;
|
||||
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 会员预存款业务层
|
||||
@ -80,7 +80,7 @@ public interface MemberWalletService extends IService<MemberWallet> {
|
||||
Boolean checkPassword();
|
||||
|
||||
/**
|
||||
* 会员注册添加会员预存款
|
||||
* 会员注册添加会员余额钱包
|
||||
*
|
||||
* @param memberId 会员id
|
||||
* @param memberName 会员名称
|
||||
@ -92,16 +92,18 @@ public interface MemberWalletService extends IService<MemberWallet> {
|
||||
* 用户提现
|
||||
*
|
||||
* @param price 提现金额
|
||||
* @param realName 真实姓名
|
||||
* @param connectNumber 第三方账号
|
||||
* @return 是否提现成功
|
||||
*/
|
||||
Boolean applyWithdrawal(Double price);
|
||||
Boolean applyWithdrawal(Double price, String realName, String connectNumber);
|
||||
|
||||
/**
|
||||
* 提现公共方法,此方法供前端用户提现和后端提现使用
|
||||
* 提现公共方法
|
||||
*
|
||||
* @param memberWithdrawApply 会员零钱提现申请
|
||||
* @param withdrawApplyId 会员零钱提现Id
|
||||
* @return 操作状态
|
||||
*/
|
||||
Boolean withdrawal(MemberWithdrawApply memberWithdrawApply);
|
||||
Boolean withdrawal(String withdrawApplyId);
|
||||
|
||||
}
|
@ -23,7 +23,6 @@ import cn.lili.modules.wallet.entity.dos.WalletLog;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||
import cn.lili.modules.wallet.mapper.MemberWalletMapper;
|
||||
@ -248,76 +247,107 @@ public class MemberWalletServiceImpl extends ServiceImpl<MemberWalletMapper, Mem
|
||||
|
||||
/**
|
||||
* 提现方法
|
||||
* 1、先执行平台逻辑,平台逻辑成功后扣减第三方余额,顺序问题为了防止第三方提现成功,平台逻辑失败导致第三方零钱已提现,而我们商城余额未扣减
|
||||
* 2、如果余额扣减失败 则抛出异常,事务回滚
|
||||
* 1、提现申请冻结用户的余额。
|
||||
* 2、判断是否需要平台审核。不需要审核则直接调用第三方提现,需要审核则审核通过后调用第三方提现
|
||||
*
|
||||
* @param price 提现金额
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean applyWithdrawal(Double price) {
|
||||
public Boolean applyWithdrawal(Double price, String realName, String connectNumber) {
|
||||
|
||||
if (price == null || price <= 0 || price > 1000000) {
|
||||
throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_AMOUNT_ERROR);
|
||||
}
|
||||
|
||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
|
||||
//校验金额是否满足提现,因为是从余额扣减,所以校验的是余额
|
||||
MemberWalletVO memberWalletVO = this.getMemberWallet(authUser.getId());
|
||||
if (memberWalletVO.getMemberWallet() < price) {
|
||||
throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT);
|
||||
}
|
||||
//获取提现设置
|
||||
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||
|
||||
//判断金额是否小于最低提现金额
|
||||
if (price < withdrawalSetting.getMinPrice()) {
|
||||
throw new ServiceException(ResultCode.WALLET_APPLY_MIN_PRICE_ERROR.message());
|
||||
}
|
||||
|
||||
//构建审核参数
|
||||
MemberWithdrawApply memberWithdrawApply = new MemberWithdrawApply();
|
||||
memberWithdrawApply.setMemberId(authUser.getId());
|
||||
memberWithdrawApply.setMemberName(authUser.getNickName());
|
||||
memberWithdrawApply.setApplyMoney(price);
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
|
||||
memberWithdrawApply.setSn("W" + SnowFlake.getId());
|
||||
//校验该次提现是否需要审核,如果未进行配置 默认是需要审核
|
||||
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||
if (setting != null) {
|
||||
//如果不需要审核则审核自动通过
|
||||
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||
if (Boolean.FALSE.equals(withdrawalSetting.getApply())) {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
memberWithdrawApply.setInspectRemark("系统自动审核通过");
|
||||
//校验金额是否满足提现,因为是从余额扣减,所以校验的是余额
|
||||
MemberWalletVO memberWalletVO = this.getMemberWallet(memberWithdrawApply.getMemberId());
|
||||
if (memberWalletVO.getMemberWallet() < price) {
|
||||
throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT);
|
||||
}
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
//微信零钱提现
|
||||
Boolean result = withdrawal(memberWithdrawApply);
|
||||
if (Boolean.TRUE.equals(result)) {
|
||||
this.reduce(new MemberWalletUpdateDTO(price, authUser.getId(), "余额提现成功", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
}
|
||||
} else {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
|
||||
//扣减余额到冻结金额
|
||||
this.reduceWithdrawal(new MemberWalletUpdateDTO(price, authUser.getId(), "提现金额已冻结,审核成功后到账", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
}
|
||||
//发送余额提现申请消息
|
||||
memberWithdrawApply.setRealName(realName);
|
||||
memberWithdrawApply.setConnectNumber(connectNumber);
|
||||
|
||||
memberWithdrawalMessage.setMemberId(authUser.getId());
|
||||
memberWithdrawalMessage.setPrice(price);
|
||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
//判断提现是否需要审核
|
||||
if (withdrawalSetting.getApply()) {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
|
||||
} else {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
}
|
||||
return memberWithdrawApplyService.save(memberWithdrawApply);
|
||||
|
||||
memberWithdrawApply.setSn("W" + SnowFlake.getId());
|
||||
|
||||
//添加提现申请记录
|
||||
memberWithdrawApplyService.save(memberWithdrawApply);
|
||||
|
||||
//扣减余额到冻结金额
|
||||
this.reduceWithdrawal(new MemberWalletUpdateDTO(price, authUser.getId(), "提现金额已冻结", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
|
||||
//发送余额提现申请消息
|
||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
|
||||
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
|
||||
memberWithdrawalMessage.setMemberId(authUser.getId());
|
||||
memberWithdrawalMessage.setPrice(price);
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean withdrawal(MemberWithdrawApply memberWithdrawApply) {
|
||||
public Boolean withdrawal(String withdrawApplyId) {
|
||||
MemberWithdrawApply memberWithdrawApply = memberWithdrawApplyService.getById(withdrawApplyId);
|
||||
memberWithdrawApply.setInspectTime(new Date());
|
||||
//保存或者修改零钱提现
|
||||
this.memberWithdrawApplyService.saveOrUpdate(memberWithdrawApply);
|
||||
//TODO 做成配置项目
|
||||
cashierSupport.transfer(PaymentMethodEnum.WECHAT, memberWithdrawApply);
|
||||
//获取提现设置
|
||||
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||
|
||||
//调用提现方法
|
||||
boolean result = true;
|
||||
//如果微信提现失败 则抛出异常 回滚数据
|
||||
if (!result) {
|
||||
throw new ServiceException(ResultCode.WALLET_ERROR_INSUFFICIENT);
|
||||
if ("WECHAT".equals(withdrawalSetting.getType())) {
|
||||
result = cashierSupport.transfer(PaymentMethodEnum.WECHAT, memberWithdrawApply);
|
||||
} else if ("ALI".equals(withdrawalSetting.getType())) {
|
||||
result = cashierSupport.transfer(PaymentMethodEnum.ALIPAY, memberWithdrawApply);
|
||||
}
|
||||
|
||||
//成功则扣减冻结金额
|
||||
//失败则恢复冻结金额
|
||||
|
||||
if (result) {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.SUCCESS.name());
|
||||
} else {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.ERROR.name());
|
||||
}
|
||||
//修改提现申请
|
||||
this.memberWithdrawApplyService.updateById(memberWithdrawApply);
|
||||
|
||||
//发送余额提现申请消息
|
||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
|
||||
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
|
||||
memberWithdrawalMessage.setMemberId(memberWithdrawApply.getMemberId());
|
||||
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
|
||||
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
|
||||
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,7 @@ import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||
import cn.lili.modules.wallet.entity.vo.MemberWithdrawApplyQueryVO;
|
||||
@ -69,36 +66,18 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
|
||||
//如果审核通过 则微信直接提现,反之则记录审核状态
|
||||
if (Boolean.TRUE.equals(result)) {
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
//提现,微信提现成功后扣减冻结金额
|
||||
Boolean bool = memberWalletService.withdrawal(memberWithdrawApply);
|
||||
if (Boolean.TRUE.equals(bool)) {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
//保存修改审核记录
|
||||
this.updateById(memberWithdrawApply);
|
||||
//记录日志
|
||||
memberWalletService.reduceFrozen(
|
||||
new MemberWalletUpdateDTO(memberWithdrawApply.getApplyMoney(), memberWithdrawApply.getMemberId(), "审核通过,余额提现", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()))
|
||||
;
|
||||
} else {
|
||||
//如果提现失败则无法审核
|
||||
throw new ServiceException(ResultCode.WALLET_APPLY_ERROR);
|
||||
}
|
||||
|
||||
} else {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||
//如果审核拒绝 审核备注必填
|
||||
if (StringUtils.isEmpty(remark)) {
|
||||
throw new ServiceException(ResultCode.WALLET_REMARK_ERROR);
|
||||
}
|
||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||
//保存修改审核记录
|
||||
this.updateById(memberWithdrawApply);
|
||||
//需要从冻结金额扣减到余额
|
||||
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawApply.getApplyMoney(), memberWithdrawApply.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||
|
||||
}
|
||||
//发送审核消息
|
||||
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
|
||||
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
|
||||
memberWithdrawalMessage.setMemberId(memberWithdrawApply.getMemberId());
|
||||
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
|
||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
|
||||
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
|
@ -138,13 +138,13 @@ public class WechatMessageServiceImpl extends ServiceImpl<WechatMessageMapper, W
|
||||
List<WechatMessageData> msg = new ArrayList<>();
|
||||
//新订单消息提示
|
||||
msg.add(new WechatMessageData(
|
||||
"待支付",
|
||||
"您有新订单需要支付",
|
||||
"订单支付成功通知",
|
||||
"订单支付成功通知",
|
||||
"如有问题,请联系在线客服",
|
||||
"OPENTM207498902",
|
||||
WechatMessageItemEnums.MEMBER_NAME.name() + "," + WechatMessageItemEnums.ORDER_SN.name() + "," +
|
||||
WechatMessageItemEnums.PRICE.name() + "," + WechatMessageItemEnums.GOODS_INFO.name(),
|
||||
OrderStatusEnum.UNPAID));
|
||||
OrderStatusEnum.UNDELIVERED));
|
||||
//已发货
|
||||
msg.add(new WechatMessageData(
|
||||
"订单发货",
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.lili.modules.wechat.util;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -48,7 +47,7 @@ public class WechatMessageData {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String createData() {
|
||||
public Map<String, Map<String, String>> createData() {
|
||||
|
||||
Map<String, Map<String, String>> dataMap = new LinkedHashMap<>();
|
||||
|
||||
@ -62,7 +61,7 @@ public class WechatMessageData {
|
||||
//拼接备注
|
||||
dataMap.put("remark", createValue(this.remark));
|
||||
|
||||
return JSONUtil.toJsonStr(dataMap);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.modules.connect.entity.Connect;
|
||||
import cn.lili.modules.connect.entity.enums.ConnectEnum;
|
||||
import cn.lili.modules.connect.entity.enums.SourceEnum;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.member.entity.dto.ConnectQueryDTO;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
@ -100,14 +101,13 @@ public class WechatMessageUtil {
|
||||
//发送url
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
|
||||
|
||||
Map<String, String> map = new HashMap<>(4);
|
||||
Map<String, Object> map = new HashMap<>(4);
|
||||
//用户id
|
||||
map.put("touser", connect.getUnionId());
|
||||
//模版id
|
||||
map.put("template_id", wechatMessage.getCode());
|
||||
//模版中所需数据
|
||||
String postParams = createData(order, wechatMessage);
|
||||
map.put("data", postParams);
|
||||
map.put("data", createData(order, wechatMessage));
|
||||
|
||||
log.info("参数内容:" + JSONUtil.toJsonStr(map));
|
||||
String content = HttpUtil.post(url, JSONUtil.toJsonStr(map));
|
||||
@ -119,7 +119,7 @@ public class WechatMessageUtil {
|
||||
if (!"0".equals(errcode)) {
|
||||
log.error("消息发送失败:" + errorMessage);
|
||||
log.error("消息发送请求token:" + token);
|
||||
log.error("消息发送请求:" + postParams);
|
||||
log.error("消息发送请求:" + map.get("data"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public class WechatMessageUtil {
|
||||
}
|
||||
|
||||
Connect connect = connectService.queryConnect(
|
||||
ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(ConnectEnum.WECHAT_MP_OPEN_ID.name()).build()
|
||||
ConnectQueryDTO.builder().userId(order.getMemberId()).unionType(SourceEnum.WECHAT_MP_OPEN_ID.name()).build()
|
||||
);
|
||||
if (connect == null) {
|
||||
return;
|
||||
@ -164,8 +164,7 @@ public class WechatMessageUtil {
|
||||
//模版id
|
||||
map.put("template_id", wechatMPMessage.getCode());
|
||||
//模版中所需数据
|
||||
Map<String, Map<String, String>> postParams = createData(order, wechatMPMessage);
|
||||
map.put("data", postParams);
|
||||
map.put("data", createData(order, wechatMPMessage));
|
||||
map.put("page", "pages/order/orderDetail?sn=" + order.getSn());
|
||||
log.info("参数内容:" + JSONUtil.toJsonStr(map));
|
||||
String content = null;
|
||||
@ -182,7 +181,7 @@ public class WechatMessageUtil {
|
||||
if (!"0".equals(errcode)) {
|
||||
log.error("消息发送失败:" + errorMessage);
|
||||
log.error("消息发送请求token:" + token);
|
||||
log.error("消息发送请求:" + postParams);
|
||||
log.error("消息发送请求:" + map.get("data"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +192,7 @@ public class WechatMessageUtil {
|
||||
* @param wechatMessage
|
||||
* @return
|
||||
*/
|
||||
private String createData(Order order, WechatMessage wechatMessage) {
|
||||
private Map<String, Map<String, String>> createData(Order order, WechatMessage wechatMessage) {
|
||||
WechatMessageData wechatMessageData = new WechatMessageData();
|
||||
wechatMessageData.setFirst(wechatMessage.getFirst());
|
||||
wechatMessageData.setRemark(wechatMessage.getRemark());
|
||||
|
@ -30,7 +30,11 @@ public enum MemberTagsEnum {
|
||||
/**
|
||||
* 会员积分变动
|
||||
*/
|
||||
MEMBER_POINT_CHANGE("会员积分变动");
|
||||
MEMBER_POINT_CHANGE("会员积分变动"),
|
||||
/**
|
||||
* 会员使用联合登录
|
||||
*/
|
||||
MEMBER_CONNECT_LOGIN("会员使用联合登录");
|
||||
|
||||
private final String description;
|
||||
|
||||
|
@ -19,6 +19,11 @@
|
||||
<artifactId>framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -46,7 +46,7 @@ public class ImTalkController {
|
||||
@GetMapping(value = "/by/user/{userId}")
|
||||
@ApiOperation(value = "查看与某人聊天详情")
|
||||
public ResultMessage<ImTalkVO> getByUser(@PathVariable String userId) {
|
||||
return ResultUtil.data(new ImTalkVO(imTalkService.getTalkByUser(userId),userId));
|
||||
return ResultUtil.data(imTalkService.getTalkByUserId(userId));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/top")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.wechat;
|
||||
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
@ -26,6 +27,7 @@ public class WechatMPMessageManagerController {
|
||||
@Autowired
|
||||
private WechatMPMessageService wechatMPMessageService;
|
||||
|
||||
@DemoSite
|
||||
@GetMapping(value = "/init")
|
||||
@ApiOperation(value = "初始化微信小程序消息订阅")
|
||||
public ResultMessage init() {
|
||||
@ -50,6 +52,7 @@ public class WechatMPMessageManagerController {
|
||||
return new ResultUtil<IPage<WechatMPMessage>>().setData(data);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增微信小程序消息订阅")
|
||||
public ResultMessage<WechatMPMessage> save(WechatMPMessage wechatMPMessage) {
|
||||
@ -58,6 +61,7 @@ public class WechatMPMessageManagerController {
|
||||
return new ResultUtil<WechatMPMessage>().setData(wechatMPMessage);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation(value = "更新微信小程序消息订阅")
|
||||
public ResultMessage<WechatMPMessage> update(@PathVariable String id, WechatMPMessage wechatMPMessage) {
|
||||
@ -65,6 +69,7 @@ public class WechatMPMessageManagerController {
|
||||
return new ResultUtil<WechatMPMessage>().setData(wechatMPMessage);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiOperation(value = "删除微信小程序消息订阅")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.wechat;
|
||||
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
@ -31,6 +32,7 @@ public class WechatMessageManageController {
|
||||
|
||||
@GetMapping(value = "/init")
|
||||
@ApiOperation(value = "初始化微信消息")
|
||||
@DemoSite
|
||||
public ResultMessage init() {
|
||||
wechatMessageService.init();
|
||||
return ResultUtil.success();
|
||||
@ -51,6 +53,7 @@ public class WechatMessageManageController {
|
||||
return ResultUtil.data(data);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增微信消息")
|
||||
public ResultMessage<WechatMessage> save(WechatMessage wechatMessage) {
|
||||
@ -59,6 +62,7 @@ public class WechatMessageManageController {
|
||||
return ResultUtil.data(wechatMessage);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation(value = "更新微信消息")
|
||||
public ResultMessage<WechatMessage> update(@PathVariable String id, WechatMessage wechatMessage) {
|
||||
@ -66,6 +70,7 @@ public class WechatMessageManageController {
|
||||
return ResultUtil.data(wechatMessage);
|
||||
}
|
||||
|
||||
@DemoSite
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiOperation(value = "删除微信消息")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List ids) {
|
||||
|
4
pom.xml
4
pom.xml
@ -26,7 +26,7 @@
|
||||
<images-version>1</images-version>
|
||||
<alipay-sdk-version>4.22.32.ALL</alipay-sdk-version>
|
||||
<mybatis-plus-version>3.5.1</mybatis-plus-version>
|
||||
<Hutool-version>5.8.0</Hutool-version>
|
||||
<Hutool-version>5.8.14</Hutool-version>
|
||||
<TinyPinyin-verions>2.0.3.RELEASE</TinyPinyin-verions>
|
||||
<jasypt-version>3.0.4</jasypt-version>
|
||||
<neetl-version>2.9.10</neetl-version>
|
||||
@ -61,7 +61,7 @@
|
||||
<spring-boot-admin>2.3.1</spring-boot-admin>
|
||||
<owasp-java-html-sanitizer>20211018.2</owasp-java-html-sanitizer>
|
||||
<minio.version>8.0.3</minio.version>
|
||||
<huaweicloud.version>3.21.8</huaweicloud.version>
|
||||
<huaweicloud-obs.version>3.20.6.2</huaweicloud-obs.version>
|
||||
<cos.version>5.6.97</cos.version>
|
||||
<tencentcloud.version>3.1.693</tencentcloud.version>
|
||||
<kuaidi100-api.version>1.0.11</kuaidi100-api.version>
|
||||
|
Loading…
x
Reference in New Issue
Block a user