Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
c1288de2
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c1288de2
编写于
8月 14, 2021
作者:
有
有来技术
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(common-web): 引入Apache HttpClient替换Feign原生的HttpURLConnection修复feign转发请求头拦截器写入输出流报错
Closes I40PH7
上级
0e814242
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
34 addition
and
63 deletion
+34
-63
README.md
README.md
+3
-1
docs/nacos/DEFAULT_GROUP.zip
docs/nacos/DEFAULT_GROUP.zip
+0
-0
mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java
...va/com/youlai/mall/oms/service/impl/OrderServiceImpl.java
+7
-7
mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java
.../main/java/com/youlai/mall/ums/api/MemberFeignClient.java
+2
-15
mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java
.../com/youlai/mall/ums/controller/app/MemberController.java
+5
-25
youlai-common/common-web/pom.xml
youlai-common/common-web/pom.xml
+7
-3
youlai-common/common-web/src/main/java/com/youlai/common/web/config/FeignConfig.java
...c/main/java/com/youlai/common/web/config/FeignConfig.java
+9
-12
youlai-common/common-web/src/main/resources/META-INF/spring.factories
...n/common-web/src/main/resources/META-INF/spring.factories
+1
-0
未找到文件。
README.md
浏览文件 @
c1288de2
...
...
@@ -61,7 +61,7 @@
| 微服务后台 |
[
youlai-mall
](
https://gitee.com/youlaitech/youlai-mall
)
| 微信小程序 |
[
youlai-mall-weapp
](
https://gitee.com/youlaitech/youlai-mall-weapp
)
|
| 管理前端 |
[
youlai-mall-admin
](
https://gitee.com/youlaitech/youlai-mall-admin
)
|APP应用 |
[
youlai-mall-app
](
https://gitee.com/youlaitech/youlai-mall-app
)
|
#### 项目结构
#### 项目结构
```
lua
youlai
-
mall
...
...
@@ -174,6 +174,8 @@ youlai-mall
## 联系信息
因为微信交流群满200人只能通过邀请进入,如果想进入交流群学习可添加以下开发人员,备注“
**有来**
“由其拉进群。
| !
[](
https://gitee.com/haoxr/image/raw/master/default/113__6c5ed5b1b73ea9cd4cf32848ed350c07_b9b214638a2a406e52dbf51e9bf9a2ef.png
)
| !
[](
https://gitee.com/haoxr/image/raw/master/hxr.jpg
)
| !
[](
https://gitee.com/haoxr/image/raw/master/huawei.jpg
)
| !
[](
https://gitee.com/haoxr/image/raw/master/default/1625149769(1
)
.png) |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| !
[](
https://gitee.com/haoxr/image/raw/master/default/7488479b1e2c193b04b56d1e0ff640c.jpg
)
| !
[
image-20210701232803265
](
https://gitee.com/haoxr/image/raw/master/default/image-20210701232803265.png
)
| !
[](
https://gitee.com/haoxr/image/raw/master/default/20210701234946.png
)
| !
[](
https://gitee.com/haoxr/image/raw/master/default/image-20210702002909113.png
)
|
\ No newline at end of file
docs/nacos/DEFAULT_GROUP.zip
浏览文件 @
c1288de2
无法预览此类型文件
mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/OrderServiceImpl.java
浏览文件 @
c1288de2
...
...
@@ -138,7 +138,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
orderConfirmVO
.
setAddresses
(
addresses
);
},
threadPoolExecutor
);
// 生成唯一标识,防止订单重复提交
CompletableFuture
<
Void
>
orderTokenCompletableFuture
=
CompletableFuture
.
runAsync
(()
->
{
String
orderToken
=
businessNoGenerator
.
generate
(
BusinessTypeEnum
.
ORDER
);
...
...
@@ -155,6 +154,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
* 订单提交
*/
@Override
@GlobalTransactional
public
OrderSubmitVO
submit
(
OrderSubmitDTO
submitDTO
)
{
log
.
info
(
"=======================订单提交=======================\n订单提交信息:{}"
,
submitDTO
);
// 订单重复提交校验
...
...
@@ -311,15 +311,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
if
(!
OrderStatusEnum
.
PENDING_PAYMENT
.
getCode
().
equals
(
order
.
getStatus
()))
{
throw
new
BizException
(
"支付失败,请检查订单状态"
);
}
Long
userId
=
JwtUtils
.
getUserId
();
T
result
;
switch
(
payTypeEnum
)
{
case
WEIXIN_JSAPI:
result
=
(
T
)
wxJsapiPay
(
appId
,
order
,
userId
);
result
=
(
T
)
wxJsapiPay
(
appId
,
order
);
break
;
default
:
case
BALANCE:
result
=
(
T
)
balancePay
(
order
,
userId
);
result
=
(
T
)
balancePay
(
order
);
}
// 扣减库存
...
...
@@ -334,10 +333,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
return
result
;
}
private
Boolean
balancePay
(
OmsOrder
order
,
Long
userId
)
{
private
Boolean
balancePay
(
OmsOrder
order
)
{
// 扣减余额
Long
payAmount
=
order
.
getPayAmount
();
Result
<?>
deductBalanceResult
=
memberFeignClient
.
deductBalance
(
userId
,
payAmount
);
Result
<?>
deductBalanceResult
=
memberFeignClient
.
deductBalance
(
payAmount
);
if
(!
Result
.
isSuccess
(
deductBalanceResult
))
{
throw
new
BizException
(
"扣减账户余额失败"
);
}
...
...
@@ -353,7 +352,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
return
Boolean
.
TRUE
;
}
private
WxPayUnifiedOrderV3Result
.
JsapiResult
wxJsapiPay
(
String
appId
,
OmsOrder
order
,
Long
userId
)
{
private
WxPayUnifiedOrderV3Result
.
JsapiResult
wxJsapiPay
(
String
appId
,
OmsOrder
order
)
{
Long
userId
=
JwtUtils
.
getUserId
();
Result
<
UmsMember
>
userInfoResult
=
memberFeignClient
.
getUserEntityById
(
userId
);
if
(!
Result
.
isSuccess
(
userInfoResult
))
{
throw
new
BizException
(
"用户查询失败"
);
...
...
mall-ums/ums-api/src/main/java/com/youlai/mall/ums/api/MemberFeignClient.java
浏览文件 @
c1288de2
...
...
@@ -34,24 +34,11 @@ public interface MemberFeignClient {
@GetMapping
(
"/app-api/v1/members/openid/{openid}"
)
Result
<
UmsMember
>
getByOpenid
(
@PathVariable
String
openid
);
/**
* 修改会员积分
*/
@PutMapping
(
"/app-api/v1/members/{id}/points"
)
<
T
>
Result
<
T
>
updatePoint
(
@PathVariable
Long
id
,
@RequestParam
Integer
num
);
/**
* 扣减会员余额
*/
@PutMapping
(
"/app-api/v1/members/{id}/deduct-balance"
)
<
T
>
Result
<
T
>
deductBalance
(
@PathVariable
Long
id
,
@RequestParam
Long
balance
);
/**
* 获取会员余额
*/
@GetMapping
(
"/app-api/v1/members/{id}/balance"
)
Result
<
Long
>
getBalance
(
@PathVariable
Long
id
);
@PutMapping
(
"/app-api/v1/members/current/balances/_deduct"
)
<
T
>
Result
<
T
>
deductBalance
(
@RequestParam
Long
balances
);
/**
* 添加浏览记录
*/
...
...
mall-ums/ums-boot/src/main/java/com/youlai/mall/ums/controller/app/MemberController.java
浏览文件 @
c1288de2
...
...
@@ -88,7 +88,6 @@ public class MemberController {
}
@ApiOperation
(
value
=
"修改会员"
)
@ApiImplicitParam
(
name
=
"member"
,
value
=
"实体JSON对象"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"UmsMember"
)
@PutMapping
(
"/{id}"
)
public
<
T
>
Result
<
T
>
add
(
@PathVariable
Long
id
,
@RequestBody
UmsMember
user
)
{
boolean
status
=
iUmsMemberService
.
updateById
(
user
);
...
...
@@ -110,10 +109,6 @@ public class MemberController {
@ApiOperation
(
value
=
"修改会员积分"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"会员ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"num"
,
value
=
"积分数量"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"Integer"
)
})
@PutMapping
(
"/{id}/points"
)
public
<
T
>
Result
<
T
>
updatePoint
(
@PathVariable
Long
id
,
@RequestParam
Integer
num
)
{
UmsMember
user
=
iUmsMemberService
.
getById
(
id
);
...
...
@@ -123,31 +118,16 @@ public class MemberController {
}
@ApiOperation
(
value
=
"扣减会员余额"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"会员ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"balance"
,
value
=
"会员余额"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"Long"
)
})
@PutMapping
(
"/{id}/deduct-balance"
)
public
<
T
>
Result
<
T
>
updateBalance
(
@PathVariable
Long
id
,
@RequestParam
Long
balance
)
{
@PutMapping
(
"/current/balances/_deduct"
)
public
<
T
>
Result
<
T
>
deductBalance
(
@RequestParam
Long
balances
)
{
Long
userId
=
JwtUtils
.
getUserId
();
boolean
result
=
iUmsMemberService
.
update
(
new
LambdaUpdateWrapper
<
UmsMember
>()
.
setSql
(
"balance = balance - "
+
balance
)
.
eq
(
UmsMember:
:
getId
,
i
d
)
.
setSql
(
"balance = balance - "
+
balance
s
)
.
eq
(
UmsMember:
:
getId
,
userI
d
)
);
return
Result
.
judge
(
result
);
}
@ApiOperation
(
value
=
"获取会员余额"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"会员ID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}/balance"
)
public
Result
<
Long
>
updateBalance
(
@PathVariable
Long
id
)
{
Long
balance
=
0L
;
UmsMember
user
=
iUmsMemberService
.
getById
(
id
);
if
(
user
!=
null
)
{
balance
=
user
.
getBalance
();
}
return
Result
.
success
(
balance
);
}
@ApiOperation
(
value
=
"添加浏览历史"
)
@PostMapping
(
"/view/history"
)
public
<
T
>
Result
<
T
>
addProductViewHistory
(
@RequestBody
ProductHistoryVO
product
)
{
...
...
youlai-common/common-web/pom.xml
浏览文件 @
c1288de2
...
...
@@ -54,11 +54,15 @@
<artifactId>
dozer-core
</artifactId>
</dependency>
<!--TODO feign远程调用返回报错-->
<!-- <dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-core
</artifactId>
</dependency>-->
</dependency>
<dependency>
<groupId>
io.github.openfeign
</groupId>
<artifactId>
feign-httpclient
</artifactId>
</dependency>
</dependencies>
</project>
youlai-common/common-web/src/main/java/com/youlai/common/web/config/FeignConfig.java
浏览文件 @
c1288de2
/*
package
com.youlai.common.web.config
;
import
feign.RequestInterceptor
;
...
...
@@ -12,36 +12,33 @@ import org.springframework.web.servlet.DispatcherServlet;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Enumeration
;
*/
/**
* Feign相关配置类
*
*
* @author Gadfly
* @since 2021-08-06 9:47
*/
/*
*/
@Configuration
public
class
FeignConfig
{
*/
/**
/**
* 让DispatcherServlet向子线程传递RequestContext
*
* @param servlet servlet
* @return 注册bean
*//*
*/
@Bean
public
ServletRegistrationBean
<
DispatcherServlet
>
dispatcherRegistration
(
DispatcherServlet
servlet
)
{
servlet
.
setThreadContextInheritable
(
true
);
return
new
ServletRegistrationBean
<>(
servlet
,
"/**"
);
}
*/
/**
/**
* 覆写拦截器,在feign发送请求前取出原来的header并转发
*
* @return 拦截器
*/
/*
*/
@Bean
public
RequestInterceptor
requestInterceptor
()
{
...
...
@@ -62,4 +59,4 @@ public class FeignConfig {
};
}
}
*/
youlai-common/common-web/src/main/resources/META-INF/spring.factories
浏览文件 @
c1288de2
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.youlai.common.web.config.WebMvcConfig,\
com.youlai.common.web.config.FeignConfig,\
com.youlai.common.web.exception.GlobalExceptionHandler,\
com.youlai.common.web.aspect.LoginLogAspect
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录