Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
7023b205
Unverified
Commit
7023b205
authored
Nov 17, 2019
by
staney
Committed by
GitHub
Nov 17, 2019
Browse files
Merge pull request #1 from linlinjava/master
同步更新代码
parents
c6ab92f9
506a8c01
Changes
66
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/AliyunSmsSender.java
0 → 100644
View file @
7023b205
package
org.linlinjava.litemall.core.notify
;
import
com.aliyuncs.CommonRequest
;
import
com.aliyuncs.CommonResponse
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
/*
* 阿里云短信服务
*/
public
class
AliyunSmsSender
implements
SmsSender
{
private
final
Log
logger
=
LogFactory
.
getLog
(
AliyunSmsSender
.
class
);
private
String
regionId
;
private
String
accessKeyId
;
private
String
accessKeySecret
;
private
String
sign
;
public
String
getRegionId
()
{
return
regionId
;
}
public
void
setRegionId
(
String
regionId
)
{
this
.
regionId
=
regionId
;
}
public
String
getAccessKeyId
()
{
return
accessKeyId
;
}
public
void
setAccessKeyId
(
String
accessKeyId
)
{
this
.
accessKeyId
=
accessKeyId
;
}
public
String
getAccessKeySecret
()
{
return
accessKeySecret
;
}
public
void
setAccessKeySecret
(
String
accessKeySecret
)
{
this
.
accessKeySecret
=
accessKeySecret
;
}
public
String
getSign
()
{
return
sign
;
}
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
@Override
public
SmsResult
send
(
String
phone
,
String
content
)
{
SmsResult
smsResult
=
new
SmsResult
();
smsResult
.
setSuccessful
(
false
);
return
smsResult
;
}
@Override
public
SmsResult
sendWithTemplate
(
String
phone
,
String
templateId
,
String
[]
params
)
{
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
this
.
regionId
,
this
.
accessKeyId
,
this
.
accessKeySecret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setMethod
(
MethodType
.
POST
);
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
this
.
regionId
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
phone
);
request
.
putQueryParameter
(
"SignName"
,
this
.
sign
);
request
.
putQueryParameter
(
"TemplateCode"
,
templateId
);
/*
NOTE:阿里云短信和腾讯云短信这里存在不一致
腾讯云短信模板参数是数组,因此短信模板形式如 “短信参数{1}, 短信参数{2}”
阿里云短信模板参数是JSON,因此短信模板形式如“短信参数{param1}, 短信参数{param2}”
为了保持统一,我们假定阿里云短信里面的参数是code,code1,code2...
如果开发者在阿里云短信申请的模板参数是其他命名,请开发者自行调整这里的代码,或者直接写死。
*/
String
templateParam
=
"{}"
;
if
(
params
.
length
==
1
){
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"code"
,
params
[
0
]);
templateParam
=
JacksonUtil
.
toJson
(
data
);
}
else
if
(
params
.
length
>
1
){
Map
<
String
,
String
>
data
=
new
HashMap
<>();
data
.
put
(
"code"
,
params
[
0
]);
for
(
int
i
=
1
;
i
<
params
.
length
;
i
++){
data
.
put
(
"code"
+
i
,
params
[
i
]);
}
templateParam
=
JacksonUtil
.
toJson
(
data
);
}
request
.
putQueryParameter
(
"TemplateParam"
,
templateParam
);
try
{
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
SmsResult
smsResult
=
new
SmsResult
();
smsResult
.
setSuccessful
(
true
);
smsResult
.
setResult
(
response
);
return
smsResult
;
}
catch
(
ServerException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
SmsResult
smsResult
=
new
SmsResult
();
smsResult
.
setSuccessful
(
false
);
return
smsResult
;
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyService.java
View file @
7023b205
...
...
@@ -66,8 +66,7 @@ public class NotifyService {
return
;
}
int
templateId
=
Integer
.
parseInt
(
templateIdStr
);
smsSender
.
sendWithTemplate
(
phoneNumber
,
templateId
,
params
);
smsSender
.
sendWithTemplate
(
phoneNumber
,
templateIdStr
,
params
);
}
/**
...
...
@@ -82,9 +81,7 @@ public class NotifyService {
if
(
smsSender
==
null
)
return
null
;
int
templateId
=
Integer
.
parseInt
(
getTemplateId
(
notifyType
,
smsTemplate
));
return
smsSender
.
sendWithTemplate
(
phoneNumber
,
templateId
,
params
);
return
smsSender
.
sendWithTemplate
(
phoneNumber
,
getTemplateId
(
notifyType
,
smsTemplate
),
params
);
}
/**
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/SmsSender.java
View file @
7023b205
...
...
@@ -13,10 +13,9 @@ public interface SmsSender {
/**
* 通过短信模版发送短信息
*
* @param phone 接收通知的电话号码
* @param phone 接收通知的电话号码
* @param templateId 通知模板ID
* @param params 通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
*/
SmsResult
sendWithTemplate
(
String
phone
,
in
t
templateId
,
String
[]
params
);
SmsResult
sendWithTemplate
(
String
phone
,
Str
in
g
templateId
,
String
[]
params
);
}
\ No newline at end of file
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/TencentSmsSender.java
View file @
7023b205
...
...
@@ -15,6 +15,7 @@ public class TencentSmsSender implements SmsSender {
private
final
Log
logger
=
LogFactory
.
getLog
(
TencentSmsSender
.
class
);
private
SmsSingleSender
sender
;
private
String
sign
;
public
SmsSingleSender
getSender
()
{
return
sender
;
...
...
@@ -38,13 +39,15 @@ public class TencentSmsSender implements SmsSender {
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
SmsResult
smsResult
=
new
SmsResult
();
smsResult
.
setSuccessful
(
false
);
return
smsResult
;
}
@Override
public
SmsResult
sendWithTemplate
(
String
phone
,
in
t
templateId
,
String
[]
params
)
{
public
SmsResult
sendWithTemplate
(
String
phone
,
Str
in
g
templateId
,
String
[]
params
)
{
try
{
SmsSingleSenderResult
result
=
sender
.
sendWithParam
(
"86"
,
phone
,
templateId
,
params
,
""
,
""
,
""
);
SmsSingleSenderResult
result
=
sender
.
sendWithParam
(
"86"
,
phone
,
Integer
.
parseInt
(
templateId
)
,
params
,
this
.
sign
,
""
,
""
);
logger
.
debug
(
result
);
SmsResult
smsResult
=
new
SmsResult
();
...
...
@@ -55,6 +58,12 @@ public class TencentSmsSender implements SmsSender {
logger
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
SmsResult
smsResult
=
new
SmsResult
();
smsResult
.
setSuccessful
(
false
);
return
smsResult
;
}
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyAutoConfiguration.java
View file @
7023b205
package
org.linlinjava.litemall.core.notify.config
;
import
com.github.qcloudsms.SmsSingleSender
;
import
org.linlinjava.litemall.core.notify.AliyunSmsSender
;
import
org.linlinjava.litemall.core.notify.NotifyService
;
import
org.linlinjava.litemall.core.notify.TencentSmsSender
;
import
org.linlinjava.litemall.core.notify.WxTemplateSender
;
...
...
@@ -33,7 +34,13 @@ public class NotifyAutoConfiguration {
NotifyProperties
.
Sms
smsConfig
=
properties
.
getSms
();
if
(
smsConfig
.
isEnable
())
{
notifyService
.
setSmsSender
(
tencentSmsSender
());
if
(
smsConfig
.
getActive
().
equals
(
"tencent"
))
{
notifyService
.
setSmsSender
(
tencentSmsSender
());
}
else
if
(
smsConfig
.
getActive
().
equals
(
"aliyun"
))
{
notifyService
.
setSmsSender
(
aliyunSmsSender
());
}
notifyService
.
setSmsTemplate
(
smsConfig
.
getTemplate
());
}
...
...
@@ -65,7 +72,21 @@ public class NotifyAutoConfiguration {
public
TencentSmsSender
tencentSmsSender
()
{
NotifyProperties
.
Sms
smsConfig
=
properties
.
getSms
();
TencentSmsSender
smsSender
=
new
TencentSmsSender
();
smsSender
.
setSender
(
new
SmsSingleSender
(
smsConfig
.
getAppid
(),
smsConfig
.
getAppkey
()));
NotifyProperties
.
Sms
.
Tencent
tencent
=
smsConfig
.
getTencent
();
smsSender
.
setSender
(
new
SmsSingleSender
(
tencent
.
getAppid
(),
tencent
.
getAppkey
()));
smsSender
.
setSign
(
smsConfig
.
getSign
());
return
smsSender
;
}
@Bean
public
AliyunSmsSender
aliyunSmsSender
()
{
NotifyProperties
.
Sms
smsConfig
=
properties
.
getSms
();
AliyunSmsSender
smsSender
=
new
AliyunSmsSender
();
NotifyProperties
.
Sms
.
Aliyun
aliyun
=
smsConfig
.
getAliyun
();
smsSender
.
setSign
(
smsConfig
.
getSign
());
smsSender
.
setRegionId
(
aliyun
.
getRegionId
());
smsSender
.
setAccessKeyId
(
aliyun
.
getAccessKeyId
());
smsSender
.
setAccessKeySecret
(
aliyun
.
getAccessKeySecret
());
return
smsSender
;
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyProperties.java
View file @
7023b205
...
...
@@ -95,8 +95,10 @@ public class NotifyProperties {
public
static
class
Sms
{
private
boolean
enable
;
private
int
appid
;
private
String
appkey
;
private
String
active
;
private
String
sign
;
private
Tencent
tencent
;
private
Aliyun
aliyun
;
private
List
<
Map
<
String
,
String
>>
template
=
new
ArrayList
<>();
public
boolean
isEnable
()
{
...
...
@@ -107,28 +109,95 @@ public class NotifyProperties {
this
.
enable
=
enable
;
}
public
int
getAppid
()
{
return
appid
;
public
List
<
Map
<
String
,
String
>>
getTemplate
()
{
return
template
;
}
public
void
set
Appid
(
int
appid
)
{
this
.
appid
=
appid
;
public
void
set
Template
(
List
<
Map
<
String
,
String
>>
template
)
{
this
.
template
=
template
;
}
public
String
getA
ppkey
()
{
return
a
ppkey
;
public
String
getA
ctive
()
{
return
a
ctive
;
}
public
void
setA
ppkey
(
String
a
ppkey
)
{
this
.
a
ppkey
=
appkey
;
public
void
setA
ctive
(
String
a
ctive
)
{
this
.
a
ctive
=
active
;
}
public
List
<
Map
<
String
,
String
>>
getTemplate
()
{
return
template
;
public
String
getSign
()
{
return
sign
;
}
public
void
setTemplate
(
List
<
Map
<
String
,
String
>>
template
)
{
this
.
template
=
template
;
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
public
Tencent
getTencent
()
{
return
tencent
;
}
public
void
setTencent
(
Tencent
tencent
)
{
this
.
tencent
=
tencent
;
}
public
Aliyun
getAliyun
()
{
return
aliyun
;
}
public
void
setAliyun
(
Aliyun
aliyun
)
{
this
.
aliyun
=
aliyun
;
}
public
static
class
Tencent
{
private
int
appid
;
private
String
appkey
;
public
int
getAppid
()
{
return
appid
;
}
public
void
setAppid
(
int
appid
)
{
this
.
appid
=
appid
;
}
public
String
getAppkey
()
{
return
appkey
;
}
public
void
setAppkey
(
String
appkey
)
{
this
.
appkey
=
appkey
;
}
}
public
static
class
Aliyun
{
private
String
regionId
;
private
String
accessKeyId
;
private
String
accessKeySecret
;
public
String
getRegionId
()
{
return
regionId
;
}
public
void
setRegionId
(
String
regionId
)
{
this
.
regionId
=
regionId
;
}
public
String
getAccessKeyId
()
{
return
accessKeyId
;
}
public
void
setAccessKeyId
(
String
accessKeyId
)
{
this
.
accessKeyId
=
accessKeyId
;
}
public
String
getAccessKeySecret
()
{
return
accessKeySecret
;
}
public
void
setAccessKeySecret
(
String
accessKeySecret
)
{
this
.
accessKeySecret
=
accessKeySecret
;
}
}
}
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/task/Task.java
0 → 100644
View file @
7023b205
package
org.linlinjava.litemall.core.task
;
import
java.util.concurrent.Delayed
;
import
java.util.concurrent.TimeUnit
;
public
abstract
class
Task
implements
Delayed
,
Runnable
{
private
String
id
=
""
;
private
long
start
=
0
;
public
Task
(
String
id
,
long
delayInMilliseconds
){
this
.
id
=
id
;
this
.
start
=
System
.
currentTimeMillis
()
+
delayInMilliseconds
;
}
public
String
getId
()
{
return
id
;
}
@Override
public
long
getDelay
(
TimeUnit
unit
)
{
long
diff
=
this
.
start
-
System
.
currentTimeMillis
();
return
unit
.
convert
(
diff
,
TimeUnit
.
MILLISECONDS
);
}
@Override
public
int
compareTo
(
Delayed
o
)
{
return
(
int
)(
this
.
getDelay
(
TimeUnit
.
MILLISECONDS
)
-
o
.
getDelay
(
TimeUnit
.
MILLISECONDS
));
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
)
return
false
;
if
(!(
o
instanceof
Task
))
{
return
false
;
}
Task
t
=
(
Task
)
o
;
return
this
.
id
.
equals
(
t
.
getId
());
}
@Override
public
int
hashCode
()
{
return
this
.
id
.
hashCode
();
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/task/TaskService.java
0 → 100644
View file @
7023b205
package
org.linlinjava.litemall.core.task
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.concurrent.DelayQueue
;
import
java.util.concurrent.Executors
;
@Component
public
class
TaskService
{
private
TaskService
taskService
;
private
DelayQueue
<
Task
>
delayQueue
=
new
DelayQueue
<
Task
>();
@PostConstruct
private
void
init
()
{
taskService
=
this
;
Executors
.
newSingleThreadExecutor
().
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(
true
)
{
try
{
Task
task
=
delayQueue
.
take
();
task
.
run
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
});
}
public
void
addTask
(
Task
task
){
if
(
delayQueue
.
contains
(
task
)){
return
;
}
delayQueue
.
add
(
task
);
}
public
void
removeTask
(
Task
task
){
delayQueue
.
remove
(
task
);
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/util/BeanUtil.java
0 → 100644
View file @
7023b205
package
org.linlinjava.litemall.core.util
;
import
org.springframework.beans.BeansException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
@Component
public
class
BeanUtil
implements
ApplicationContextAware
{
protected
static
ApplicationContext
context
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
context
=
applicationContext
;
}
public
static
Object
getBean
(
String
name
)
{
return
context
.
getBean
(
name
);
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
c
){
return
context
.
getBean
(
c
);
}
}
litemall-core/src/main/java/org/linlinjava/litemall/core/util/JacksonUtil.java
View file @
7023b205
package
org.linlinjava.litemall.core.util
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -161,4 +162,13 @@ public class JacksonUtil {
return
null
;
}
public
static
String
toJson
(
Object
data
)
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
return
objectMapper
.
writeValueAsString
(
data
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
litemall-core/src/main/resources/application-core.yml
View file @
7023b205
...
...
@@ -25,8 +25,10 @@ litemall:
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms
:
enable
:
false
appid
:
111111111
appkey
:
xxxxxxxxxxxxxx
# 如果是腾讯云短信,则设置active的值tencent
# 如果是阿里云短信,则设置active的值aliyun
active
:
tencent
sign
:
litemall
template
:
-
name
:
paySucceed
templateId
:
156349
...
...
@@ -36,6 +38,14 @@ litemall:
templateId
:
158002
-
name
:
refund
templateId
:
159447
tencent
:
appid
:
111111111
appkey
:
xxxxxxxxxxxxxx
aliyun
:
regionId
:
xxx
accessKeyId
:
xxx
accessKeySecret
:
xxx
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
...
...
@@ -102,10 +112,10 @@ litemall:
# 腾讯对象存储配置信息
# 请参考 https://cloud.tencent.com/document/product/436/6249
tencent
:
secretId
:
111111
secretKey
:
xxxxxx
region
:
xxxxxx
bucketName
:
litemall
secretId
:
AKIDOccMr856uoU1Tsa2MQL5aqseBUWRrb5i
secretKey
:
XqtgEhIdrupTs4ygaWlkUUXv3w3FiwuD
region
:
ap-shanghai
bucketName
:
vytech-1300096589
# 七牛云对象存储配置信息
qiniu
:
endpoint
:
http://pd5cb6ulu.bkt.clouddn.com
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/TaskTest.java
0 → 100644
View file @
7023b205
package
org.linlinjava.litemall.core
;
import
com.google.common.primitives.Ints
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.linlinjava.litemall.core.task.Task
;
import
org.linlinjava.litemall.core.task.TaskService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.task.SyncTaskExecutor
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Objects
;
import
java.util.concurrent.Delayed
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.TimeUnit
;
@WebAppConfiguration
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
TaskTest
{
private
final
Log
logger
=
LogFactory
.
getLog
(
TaskTest
.
class
);
@Autowired
private
TaskService
taskService
;
private
class
DemoTask
extends
Task
{
DemoTask
(
String
id
,
long
delayInMilliseconds
){
super
(
id
,
delayInMilliseconds
);
}
@Override
public
void
run
()
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
now
=
df
.
format
(
LocalDateTime
.
now
());
System
.
out
.
println
(
"task id="
+
this
.
getId
()
+
" at time="
+
now
);
}
}
@Test
public
void
test
()
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
now
=
df
.
format
(
LocalDateTime
.
now
());
System
.
out
.
println
(
"start at time="
+
now
);
taskService
.
addTask
(
new
DemoTask
(
"3"
,
1000
));
taskService
.
addTask
(
new
DemoTask
(
"2"
,
2000
));
taskService
.
addTask
(
new
DemoTask
(
"1"
,
3000
));
taskService
.
addTask
(
new
DemoTask
(
"4"
,
1500
));
taskService
.
addTask
(
new
DemoTask
(
"5"
,
2500
));
taskService
.
addTask
(
new
DemoTask
(
"6"
,
3500
));
try
{
Thread
.
sleep
(
10
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
test1
()
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
now
=
df
.
format
(
LocalDateTime
.
now
());
System
.
out
.
println
(
"start at time="
+
now
);
taskService
.
addTask
(
new
DemoTask
(
"3"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"2"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"1"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"4"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"5"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"6"
,
0
));
try
{
Thread
.
sleep
(
10
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
litemall-db/src/main/java/org/linlinjava/litemall/db/service/CouponVerifyService.java
View file @
7023b205
...
...
@@ -25,10 +25,20 @@ public class CouponVerifyService {
* @param checkedGoodsPrice
* @return
*/
public
LitemallCoupon
checkCoupon
(
Integer
userId
,
Integer
couponId
,
BigDecimal
checkedGoodsPrice
)
{
public
LitemallCoupon
checkCoupon
(
Integer
userId
,
Integer
couponId
,
Integer
userCouponId
,
BigDecimal
checkedGoodsPrice
)
{
LitemallCoupon
coupon
=
couponService
.
findById
(
couponId
);
LitemallCouponUser
couponUser
=
couponUserService
.
queryOne
(
userId
,
couponId
);
if
(
coupon
==
null
||
couponUser
==
null
)
{
if
(
coupon
==
null
)
{
return
null
;
}
LitemallCouponUser
couponUser
=
couponUserService
.
findById
(
userCouponId
);
if
(
couponUser
==
null
)
{
couponUser
=
couponUserService
.
queryOne
(
userId
,
couponId
);
}
else
if
(!
couponId
.
equals
(
couponUser
.
getCouponId
()))
{
return
null
;
}
if
(
couponUser
==
null
)
{
return
null
;
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallOrderService.java
View file @
7023b205
...
...
@@ -126,10 +126,8 @@ public class LitemallOrderService {
}
public
List
<
LitemallOrder
>
queryUnpaid
(
int
minutes
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
expired
=
now
.
minusMinutes
(
minutes
);
LitemallOrderExample
example
=
new
LitemallOrderExample
();
example
.
or
().
andOrderStatusEqualTo
(
OrderUtil
.
STATUS_CREATE
).
andAddTimeLessThan
(
expired
).
andDeletedEqualTo
(
false
);
example
.
or
().
andOrderStatusEqualTo
(
OrderUtil
.
STATUS_CREATE
).
andDeletedEqualTo
(
false
);
return
litemallOrderMapper
.
selectByExample
(
example
);
}
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/util/OrderUtil.java
View file @
7023b205
...
...
@@ -30,6 +30,8 @@ public class OrderUtil {
public
static
final
Short
STATUS_REFUND
=
202
;
public
static
final
Short
STATUS_REFUND_CONFIRM
=
203
;
public
static
final
Short
STATUS_AUTO_CONFIRM
=
402
;
public
static
final
Short
STATUS_PAY_GROUPON
=
200
;
public
static
final
Short
STATUS_TIMEOUT_GROUPON
=
204
;
public
static
String
orderStatusText
(
LitemallOrder
order
)
{
...
...
@@ -47,6 +49,10 @@ public class OrderUtil {
return
"已取消(系统)"
;
}
if
(
status
==
200
)
{
return
"已付款团购"
;
}
if
(
status
==
201
)
{
return
"已付款"
;
}
...
...
@@ -59,6 +65,10 @@ public class OrderUtil {
return
"已退款"
;
}
if
(
status
==
204
)
{
return
"已超时团购"
;
}
if
(
status
==
301
)
{
return
"已发货"
;
}
...
...
@@ -86,10 +96,10 @@ public class OrderUtil {
}
else
if
(
status
==
102
||
status
==
103
)
{
// 如果订单已经取消或是已完成,则可删除
handleOption
.
setDelete
(
true
);
}
else
if
(
status
==
201
)
{
}
else
if
(
status
==
200
||
status
==
201
)
{
// 如果订单已付款,没有发货,则可退款
handleOption
.
setRefund
(
true
);
}
else
if
(
status
==
202
)
{
}
else
if
(
status
==
202
||
status
==
204
)
{
// 如果订单申请退款中,没有相关操作
}
else
if
(
status
==
203
)
{
// 如果订单已经退款,则可删除
...
...
@@ -144,6 +154,12 @@ public class OrderUtil {
return
OrderUtil
.
STATUS_CREATE
==
litemallOrder
.
getOrderStatus
().
shortValue
();
}
public
static
boolean
hasPayed
(
LitemallOrder
order
)
{
return
OrderUtil
.
STATUS_CREATE
!=
order
.
getOrderStatus
().
shortValue
()
&&
OrderUtil
.
STATUS_CANCEL
!=
order
.
getOrderStatus
().
shortValue
()
&&
OrderUtil
.
STATUS_AUTO_CANCEL
!=
order
.
getOrderStatus
().
shortValue
();
}
public
static
boolean
isPayStatus
(
LitemallOrder
litemallOrder
)
{
return
OrderUtil
.
STATUS_PAY
==
litemallOrder
.
getOrderStatus
().
shortValue
();
}
...
...
litemall-vue/.env.deployment
View file @
7023b205
...
...
@@ -2,4 +2,4 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = 'http://118.24.0.153:8080/'
\ No newline at end of file
VUE_APP_BASE_API = 'http://122.51.199.160:8080/'
\ No newline at end of file
litemall-vue/src/api/api.js
View file @
7023b205
...
...
@@ -300,6 +300,14 @@ export function orderPrepay(data) {
data
})
}
const
OrderH5pay
=
'
wx/order/h5pay
'
;
// h5支付
export
function
orderH5pay
(
data
)
{
return
request
({
url
:
OrderH5pay
,
method
:
'
post
'
,
data
});
}
export
const
OrderList
=
'
wx/order/list
'
;
//订单列表
export
function
orderList
(
query
)
{
return
request
({
...
...
litemall-vue/src/views/login/forget/index.vue
View file @
7023b205
...
...
@@ -11,7 +11,7 @@
placeholder=
"请输入短信验证码"
>
<div
slot=
"rightIcon"
@
click=
"getCode"
class=
"getCode red"
>
<countdown
v-if=
"counting"
:time=
"60000"
@
countdown
end=
"countdownend"
>
<countdown
v-if=
"counting"
:time=
"60000"
@
end=
"countdownend"
>
<template
slot-scope=
"props"
>
{{
+
props
.
seconds
||
60
}}
秒后获取
</
template
>
</countdown>
<span
v-else
>
获取验证码
</span>
...
...
litemall-vue/src/views/login/register-submit/index.vue
View file @
7023b205
...
...
@@ -2,7 +2,7 @@
<md-field-group
class=
"register_submit"
>
<md-field
v-model=
"code"
icon=
"mobile"
placeholder=
"请输入验证码"
>
<div
slot=
"rightIcon"
@
click=
"getCode"
class=
"getCode red"
>
<countdown
v-if=
"counting"
:time=
"60000"
@
countdown
end=
"countdownend"
>
<countdown
v-if=
"counting"
:time=
"60000"
@
end=
"countdownend"
>
<template
slot-scope=
"props"
>
{{
+
props
.
seconds
||
60
}}
秒后获取
</
template
>
</countdown>
<span
v-else
>
获取验证码
</span>
...
...
litemall-vue/src/views/order/checkout.vue
View file @
7023b205
...
...
@@ -105,7 +105,7 @@ export default {
methods
:
{
onSubmit
()
{
const
{
AddressId
,
CartId
,
CouponId
}
=
getLocalStorage
(
'
AddressId
'
,
'
CartId
'
,
'
CouponId
'
);
const
{
AddressId
,
CartId
,
CouponId
,
UserCouponId
}
=
getLocalStorage
(
'
AddressId
'
,
'
CartId
'
,
'
CouponId
'
,
'
UserCouponId
'
);
if
(
AddressId
===
null
)
{
Toast
.
fail
(
'
请设置收货地址
'
);
...
...
@@ -119,6 +119,7 @@ export default {
addressId
:
AddressId
,
cartId
:
CartId
,
couponId
:
CouponId
,
userCouponId
:
UserCouponId
,
grouponLinkId
:
0
,
grouponRulesId
:
0
,
message
:
this
.
message
...
...
@@ -155,15 +156,17 @@ export default {
getCoupons
()
{
const
{
AddressId
,
CartId
,
CouponId
}
=
getLocalStorage
(
'
AddressId
'
,
'
CartId
'
,
'
CouponId
'
);
couponSelectList
({
cartId
:
CartId
,
grouponRulesId
:
0
}).
then
(
res
=>
{
var
cList
=
res
.
data
.
data
var
cList
=
res
.
data
.
data
.
list
;
this
.
coupons
=
[]
this
.
disabledCoupons
=
[];
for
(
var
i
=
0
;
i
<
cList
.
length
;
i
++
){
var
c
=
cList
[
i
]
var
coupon
=
{
id
:
c
.
id
,
cid
:
c
.
cid
,
name
:
c
.
name
,
condition
:
c
.
min
,
condition
:
'
满
'
+
c
.
min
+
'
元可用
'
,
value
:
c
.
discount
*
100
,
description
:
c
.
desc
,
startAt
:
new
Date
(
c
.
startTime
).
getTime
()
/
1000
,
...
...
@@ -171,11 +174,10 @@ export default {
valueDesc
:
c
.
discount
,
unitDesc
:
'
元
'
}
this
.
coupons
.
push
(
coupon
)
if
(
c
.
id
===
this
.
couponId
){
this
.
chosenCoupon
=
i
;
break
;
if
(
c
.
available
)
{
this
.
coupons
.
push
(
coupon
);
}
else
{
this
.
disabledCoupons
.
push
(
coupon
);
}
}
...
...
@@ -183,9 +185,9 @@ export default {
})
},
init
()
{
const
{
AddressId
,
CartId
,
CouponId
}
=
getLocalStorage
(
'
AddressId
'
,
'
CartId
'
,
'
CouponId
'
);
const
{
AddressId
,
CartId
,
CouponId
,
UserCouponId
}
=
getLocalStorage
(
'
AddressId
'
,
'
CartId
'
,
'
CouponId
'
,
'
UserCouponId
'
);
cartCheckout
({
cartId
:
CartId
,
addressId
:
AddressId
,
couponId
:
CouponId
,
grouponRulesId
:
0
}).
then
(
res
=>
{
cartCheckout
({
cartId
:
CartId
,
addressId
:
AddressId
,
couponId
:
CouponId
,
userCouponId
:
UserCouponId
,
grouponRulesId
:
0
}).
then
(
res
=>
{
var
data
=
res
.
data
.
data
this
.
checkedGoodsList
=
data
.
checkedGoodsList
;
...
...
@@ -198,7 +200,7 @@ export default {
this
.
goodsTotalPrice
=
data
.
goodsTotalPrice
;
this
.
orderTotalPrice
=
data
.
orderTotalPrice
;
setLocalStorage
({
AddressId
:
data
.
addressId
,
CartId
:
data
.
cartId
,
CouponId
:
data
.
couponId
});
setLocalStorage
({
AddressId
:
data
.
addressId
,
CartId
:
data
.
cartId
,
CouponId
:
data
.
couponId
,
UserCouponId
:
data
.
userCouponId
});
});
},
...
...
@@ -207,11 +209,12 @@ export default {
this
.
chosenCoupon
=
index
;
if
(
index
===
-
1
){
setLocalStorage
({
CouponId
:
-
1
});
setLocalStorage
({
CouponId
:
-
1
,
UserCouponId
:
-
1
});
}
else
{
const
couponId
=
this
.
coupons
[
index
].
id
;
setLocalStorage
({
CouponId
:
couponId
});
const
couponId
=
this
.
coupons
[
index
].
cid
;
const
userCouponId
=
this
.
coupons
[
index
].
id
;
setLocalStorage
({
CouponId
:
couponId
,
UserCouponId
:
userCouponId
});
}
this
.
init
()
...
...
@@ -226,7 +229,7 @@ export default {
[
SubmitBar
.
name
]:
SubmitBar
,
[
Card
.
name
]:
Card
,
[
Field
.
name
]:
Field
,
[
Tag
.
name
]:
Field
,
[
Tag
.
name
]:
Tag
,
[
CouponCell
.
name
]:
CouponCell
,
[
CouponList
.
name
]:
CouponList
,
[
Popup
.
name
]:
Popup
...
...
Prev
1
2
3
4
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment