Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
48f71334
Commit
48f71334
authored
May 12, 2020
by
彭祥礼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
院线通提交订单
parent
3f407358
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
767 additions
and
18 deletions
+767
-18
apply-net/src/main/java/com/winsun/controller/YxtCardController.java
+0
-0
common/pom.xml
+16
-0
common/src/main/java/com/winsun/bean/Bill.java
+7
-8
common/src/main/java/com/winsun/bean/PayRequest.java
+114
-0
common/src/main/java/com/winsun/bean/YxtOrder.java
+3
-3
common/src/main/java/com/winsun/bean/YxtOrderDetail.java
+6
-0
common/src/main/java/com/winsun/bean/YxtSalesLimit.java
+44
-0
common/src/main/java/com/winsun/mapper/YxtSalesLimitMapper.java
+17
-0
common/src/main/java/com/winsun/utils/CommonPropertiesUtil.java
+76
-0
common/src/main/java/com/winsun/utils/ConvertMapBean.java
+54
-0
common/src/main/java/com/winsun/utils/HTTPSClient.java
+0
-0
common/src/main/java/com/winsun/utils/MD5Util.java
+46
-0
common/src/main/java/com/winsun/utils/MD5Utils.java
+6
-7
common/src/main/java/com/winsun/utils/PropertiesInit.java
+68
-0
common/src/main/java/com/winsun/utils/Sha1Util.java
+45
-0
common/src/main/java/com/winsun/utils/WXPayUtil.java
+176
-0
common/src/main/java/com/winsun/utils/WxConfig.java
+89
-0
No files found.
apply-net/src/main/java/com/winsun/controller/YxtCardController.java
View file @
48f71334
This diff is collapsed.
Click to expand it.
common/pom.xml
View file @
48f71334
...
@@ -92,5 +92,20 @@
...
@@ -92,5 +92,20 @@
<groupId>
com.baomidou
</groupId>
<groupId>
com.baomidou
</groupId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
20190722
</version>
</dependency>
<dependency>
<groupId>
dom4j
</groupId>
<artifactId>
dom4j
</artifactId>
<version>
1.6.1
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
common/src/main/java/com/winsun/bean/Bill.java
View file @
48f71334
package
com
.
winsun
.
bean
;
package
com
.
winsun
.
bean
;
import
java.io.Serializable
;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.IdType
;
import
com.baomidou.mybatisplus.enums.IdType
;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
@TableName
(
"hhr_bill"
)
@TableName
(
"hhr_bill"
)
@Data
@Data
...
@@ -63,17 +62,17 @@ public class Bill implements Serializable{
...
@@ -63,17 +62,17 @@ public class Bill implements Serializable{
/**
/**
* 不含税金额
* 不含税金额
*/
*/
private
d
ouble
amount
;
private
D
ouble
amount
;
/**
/**
* 含税金额
* 含税金额
*/
*/
private
d
ouble
taxAmount
;
private
D
ouble
taxAmount
;
/**
/**
* 税点
* 税点
*/
*/
private
d
ouble
taxPoint
;
private
D
ouble
taxPoint
;
/**
/**
* 创建时间
* 创建时间
...
@@ -83,5 +82,5 @@ public class Bill implements Serializable{
...
@@ -83,5 +82,5 @@ public class Bill implements Serializable{
/**
/**
* 删除标记
* 删除标记
*/
*/
private
int
delFlag
;
private
Integer
delFlag
;
}
}
common/src/main/java/com/winsun/bean/PayRequest.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
bean
;
import
java.io.Serializable
;
/**
* 〈微信统一下单参数〉
*
* @author PXL
* @create 2020/5/12 15:17
*/
public
class
PayRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
7878937183538920548L
;
private
String
appid
;
private
String
mch_id
;
private
String
nonce_str
;
private
String
sign
;
private
String
body
;
private
String
out_trade_no
;
private
String
total_fee
;
private
String
spbill_create_ip
;
private
String
notify_url
;
private
String
openid
;
private
String
trade_type
;
public
String
getAppid
()
{
return
appid
;
}
public
void
setAppid
(
String
appid
)
{
this
.
appid
=
appid
;
}
public
String
getMch_id
()
{
return
mch_id
;
}
public
void
setMch_id
(
String
mch_id
)
{
this
.
mch_id
=
mch_id
;
}
public
String
getNonce_str
()
{
return
nonce_str
;
}
public
void
setNonce_str
(
String
nonce_str
)
{
this
.
nonce_str
=
nonce_str
;
}
public
String
getSign
()
{
return
sign
;
}
public
void
setSign
(
String
sign
)
{
this
.
sign
=
sign
;
}
public
String
getBody
()
{
return
body
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
public
String
getOut_trade_no
()
{
return
out_trade_no
;
}
public
void
setOut_trade_no
(
String
out_trade_no
)
{
this
.
out_trade_no
=
out_trade_no
;
}
public
String
getTotal_fee
()
{
return
total_fee
;
}
public
void
setTotal_fee
(
String
total_fee
)
{
this
.
total_fee
=
total_fee
;
}
public
String
getSpbill_create_ip
()
{
return
spbill_create_ip
;
}
public
void
setSpbill_create_ip
(
String
spbill_create_ip
)
{
this
.
spbill_create_ip
=
spbill_create_ip
;
}
public
String
getNotify_url
()
{
return
notify_url
;
}
public
void
setNotify_url
(
String
notify_url
)
{
this
.
notify_url
=
notify_url
;
}
public
String
getTrade_type
()
{
return
trade_type
;
}
public
void
setTrade_type
(
String
trade_type
)
{
this
.
trade_type
=
trade_type
;
}
public
String
getOpenid
()
{
return
openid
;
}
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
}
common/src/main/java/com/winsun/bean/YxtOrder.java
View file @
48f71334
...
@@ -55,7 +55,7 @@ public class YxtOrder implements Serializable {
...
@@ -55,7 +55,7 @@ public class YxtOrder implements Serializable {
@TableField
(
"update_date"
)
@TableField
(
"update_date"
)
private
Date
updateDate
;
private
Date
updateDate
;
/**
/**
*是否删除(1.已删除,
2
.不删除)
*是否删除(1.已删除,
0
.不删除)
*/
*/
@TableField
(
"del_flag"
)
@TableField
(
"del_flag"
)
private
Integer
delFlag
;
private
Integer
delFlag
;
...
@@ -70,7 +70,7 @@ public class YxtOrder implements Serializable {
...
@@ -70,7 +70,7 @@ public class YxtOrder implements Serializable {
@TableField
(
"unit_price"
)
@TableField
(
"unit_price"
)
private
Double
unitPrice
;
private
Double
unitPrice
;
/**
/**
*订单类型
*订单类型
(1.电子订单,2.实体订单)
*/
*/
@TableField
(
"order_type"
)
@TableField
(
"order_type"
)
private
String
orderType
;
private
String
orderType
;
...
@@ -80,7 +80,7 @@ public class YxtOrder implements Serializable {
...
@@ -80,7 +80,7 @@ public class YxtOrder implements Serializable {
@TableField
(
"address_id"
)
@TableField
(
"address_id"
)
private
Integer
addressId
;
private
Integer
addressId
;
/**
/**
* 快递状态(0:无须快递,1
:寄出,2
:已寄出)
* 快递状态(0:无须快递,1
待寄出:,2:寄出,3
:已寄出)
*/
*/
@TableField
(
"express_state"
)
@TableField
(
"express_state"
)
private
Integer
expressState
;
private
Integer
expressState
;
...
...
common/src/main/java/com/winsun/bean/YxtOrderDetail.java
View file @
48f71334
...
@@ -32,4 +32,10 @@ public class YxtOrderDetail implements Serializable {
...
@@ -32,4 +32,10 @@ public class YxtOrderDetail implements Serializable {
*/
*/
@TableField
(
"yxt_id"
)
@TableField
(
"yxt_id"
)
private
Integer
yxtId
;
private
Integer
yxtId
;
/**
*
*/
@TableField
(
"is_del"
)
private
Integer
isDel
;
}
}
common/src/main/java/com/winsun/bean/YxtSalesLimit.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
bean
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableId
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.baomidou.mybatisplus.enums.IdType
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* 〈用户购买记录表〉
*
* @author PXL
* @create 2020/5/12 10:43
*/
@Data
@TableName
(
"hhr_yxt_sales_limit"
)
public
class
YxtSalesLimit
implements
Serializable
{
private
static
final
long
serialVersionUID
=
8980324270129957305L
;
/**
*
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
*购买人id
*/
@TableField
(
"open_id"
)
private
String
openId
;
/**
*购买数量
*/
@TableField
(
"sales_num"
)
private
Integer
salesNum
;
/**
*
*/
@TableField
(
"update_date"
)
private
Date
updateDate
;
}
common/src/main/java/com/winsun/mapper/YxtSalesLimitMapper.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.winsun.bean.YxtSalesLimit
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Component
;
/**
* 〈用户购买记录〉
*
* @author PXL
* @create 2020/5/12 10:48
*/
@Mapper
@Component
public
interface
YxtSalesLimitMapper
extends
BaseMapper
<
YxtSalesLimit
>
{
}
common/src/main/java/com/winsun/utils/CommonPropertiesUtil.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Iterator
;
import
java.util.Properties
;
import
java.util.Set
;
/**
* .properties文件解析工具
*
*
*
*/
@Slf4j
public
class
CommonPropertiesUtil
{
private
static
CommonPropertiesUtil
instance
=
null
;
private
CommonPropertiesUtil
()
{
}
public
static
CommonPropertiesUtil
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
CommonPropertiesUtil
();
}
return
instance
;
}
/**
* 解析传入的文件
*
* @param ls
* @return
*/
public
static
Properties
parseProp
(
String
ls
)
{
Properties
properties
=
new
Properties
();
// 20081105 直接使用getInstance()取得文件的路径
InputStream
is
=
getInstance
().
getClass
().
getResourceAsStream
(
ls
);
try
{
properties
.
load
(
is
);
}
catch
(
IOException
e
)
{
}
finally
{
try
{
if
(
is
!=
null
)
is
.
close
();
}
catch
(
IOException
e
)
{
}
}
return
properties
;
}
/**
* 直接解析.properties文件返回文件的数据结构
*
* @param ls
* @return
*/
public
static
Set
<
java
.
util
.
Map
.
Entry
<
Object
,
Object
>>
getEntrySet
(
String
ls
)
{
return
parseProp
(
ls
).
entrySet
();
}
public
static
void
main
(
String
[]
args
)
{
Set
<
java
.
util
.
Map
.
Entry
<
Object
,
Object
>>
set
=
getEntrySet
(
"/log4j.properties"
);
Iterator
<
java
.
util
.
Map
.
Entry
<
Object
,
Object
>>
itr
=
set
.
iterator
();
while
(
itr
.
hasNext
()){
java
.
util
.
Map
.
Entry
<
Object
,
Object
>
obj
=
itr
.
next
();
log
.
info
(
obj
.
getValue
().
toString
());
}
}
}
common/src/main/java/com/winsun/utils/ConvertMapBean.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
com.winsun.bean.PayRequest
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Map与JavaBean相互转化
* @author 董有沛
* @date 2018年1月19日
*
*/
public
class
ConvertMapBean
{
//JavaBean转换为Map
public
static
Map
<
String
,
Object
>
bean2map
(
Object
bean
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
//获取指定类(Person)的BeanInfo 对象
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
PayRequest
.
class
,
Object
.
class
);
//获取所有的属性描述器
PropertyDescriptor
[]
pds
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
pd:
pds
){
String
key
=
pd
.
getName
();
Method
getter
=
pd
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
bean
);
map
.
put
(
key
,
value
);
}
return
map
;
}
//Map转换为JavaBean
public
static
<
T
>
T
map2bean
(
Map
<
String
,
Object
>
map
,
Class
<
T
>
clz
)
throws
Exception
{
//创建JavaBean对象
T
obj
=
clz
.
newInstance
();
//获取指定类的BeanInfo对象
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
clz
,
Object
.
class
);
//获取所有的属性描述器
PropertyDescriptor
[]
pds
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
pd:
pds
){
Object
value
=
map
.
get
(
pd
.
getName
());
Method
setter
=
pd
.
getWriteMethod
();
setter
.
invoke
(
obj
,
value
);
}
return
obj
;
}
}
common/src/main/java/com/winsun/utils/HTTPSClient.java
0 → 100644
View file @
48f71334
This diff is collapsed.
Click to expand it.
common/src/main/java/com/winsun/utils/MD5Util.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
java.security.MessageDigest
;
public
class
MD5Util
{
private
static
String
byteArrayToHexString
(
byte
[]
b
)
{
StringBuffer
resultSb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++)
{
resultSb
.
append
(
byteToHexString
(
b
[
i
]));
}
return
resultSb
.
toString
();
}
private
static
String
byteToHexString
(
byte
b
)
{
int
n
=
b
;
if
(
n
<
0
)
{
n
+=
256
;
}
int
d1
=
n
/
16
;
int
d2
=
n
%
16
;
return
hexDigits
[
d1
]
+
hexDigits
[
d2
];
}
public
static
String
MD5Encode
(
String
origin
,
String
charsetname
)
{
String
resultString
=
null
;
try
{
resultString
=
new
String
(
origin
);
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
if
((
charsetname
==
null
)
||
(
""
.
equals
(
charsetname
)))
{
resultString
=
byteArrayToHexString
(
md
.
digest
(
resultString
.
getBytes
()));
}
else
{
resultString
=
byteArrayToHexString
(
md
.
digest
(
resultString
.
getBytes
(
charsetname
)));
}
}
catch
(
Exception
localException
)
{}
return
resultString
;
}
private
static
final
String
[]
hexDigits
=
{
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
};
}
common/src/main/java/com/winsun/utils/MD5Utils.java
View file @
48f71334
package
com
.
winsun
.
utils
;
package
com
.
winsun
.
utils
;
import
java.math.BigInteger
;
import
lombok.extern.slf4j.Slf4j
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
import
org.apache.shiro.util.ByteSource
;
import
org.apache.shiro.util.ByteSource
;
import
lombok.extern.slf4j.Slf4j
;
import
java.math.BigInteger
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
@Slf4j
@Slf4j
public
class
MD5Utils
{
public
class
MD5Utils
{
...
@@ -23,7 +22,7 @@ public class MD5Utils {
...
@@ -23,7 +22,7 @@ public class MD5Utils {
* 循环次数
* 循环次数
*/
*/
public
final
static
int
hashIterations
=
1024
;
public
final
static
int
hashIterations
=
1024
;
/**
/**
* shiro密码加密工具类
* shiro密码加密工具类
*
*
...
...
common/src/main/java/com/winsun/utils/PropertiesInit.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 加载系统配置
* @author czl
* @date 2014-3-21
*/
@Slf4j
public
class
PropertiesInit
{
private
static
boolean
initFlag
=
false
;
/**
* 系统配置保存集合
*/
private
static
Map
<
String
,
String
>
propertiesMap
=
null
;
/**
* 初始化系统配置
*/
public
static
synchronized
void
initProperties
(){
if
(
initFlag
){
return
;
}
log
.
info
(
"initProperties.."
);
initFlag
=
true
;
propertiesMap
=
new
HashMap
<
String
,
String
>();
String
[]
pros
=
new
String
[]{
"/META-INF/config/application.properties"
,
"/META-INF/config/zjinfoDetail.properties"
};
Set
<
Map
.
Entry
<
Object
,
Object
>>
set
=
null
;
Iterator
<
Map
.
Entry
<
Object
,
Object
>>
itr
=
null
;
Map
.
Entry
<
Object
,
Object
>
obj
=
null
;
String
tempkey
=
null
;
String
tempValue
=
null
;
for
(
int
i
=
0
;
i
<
pros
.
length
;
i
++)
{
set
=
CommonPropertiesUtil
.
getEntrySet
(
pros
[
i
]);
itr
=
set
.
iterator
();
while
(
itr
.
hasNext
()){
obj
=
itr
.
next
();
tempkey
=
(
String
)
obj
.
getKey
();
tempValue
=
(
String
)
obj
.
getValue
();
propertiesMap
.
put
(
tempkey
,
tempValue
);
}
}
}
/**
* 获取系统配置值
* @param key
* @return
*/
public
static
String
getProperties
(
String
key
){
return
propertiesMap
.
get
(
key
);
}
public
static
void
main
(
String
[]
args
)
{
initProperties
();
log
.
info
(
getProperties
(
"cookieMaxAge"
));
}
}
common/src/main/java/com/winsun/utils/Sha1Util.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
java.security.MessageDigest
;
import
java.util.Random
;
public
class
Sha1Util
{
// 生成微信签名
public
static
String
getSha1
(
String
str
)
{
if
((
str
==
null
)
||
(
str
.
length
()
==
0
))
{
return
null
;
}
char
[]
hexDigits
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
try
{
MessageDigest
mdTemp
=
MessageDigest
.
getInstance
(
"SHA1"
);
mdTemp
.
update
(
str
.
getBytes
());
byte
[]
md
=
mdTemp
.
digest
();
int
j
=
md
.
length
;
char
[]
buf
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
byte
byte0
=
md
[
i
];
buf
[(
k
++)]
=
hexDigits
[(
byte0
>>>
4
&
0xF
)];
buf
[(
k
++)]
=
hexDigits
[(
byte0
&
0xF
)];
}
return
new
String
(
buf
);
}
catch
(
Exception
e
)
{
}
return
null
;
}
// 获取随机字符串
public
static
String
getNonceStr
()
{
Random
random
=
new
Random
();
return
MD5Util
.
MD5Encode
(
String
.
valueOf
(
random
.
nextInt
(
10000
)),
"UTF-8"
);
}
// 获取时间戳
public
static
String
getTimeStamp
()
{
return
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
}
}
common/src/main/java/com/winsun/utils/WXPayUtil.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.transform.OutputKeys
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.dom.DOMSource
;
import
javax.xml.transform.stream.StreamResult
;
import
java.io.StringWriter
;
import
java.util.*
;
public
class
WXPayUtil
{
/**
* 将Map转换为XML格式的字符串
*
* @param data Map类型数据
* @return XML格式的字符串
* @throws Exception
*/
public
static
String
mapToXml
(
Map
<
String
,
Object
>
data
)
throws
Exception
{
DocumentBuilderFactory
documentBuilderFactory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
documentBuilder
=
documentBuilderFactory
.
newDocumentBuilder
();
org
.
w3c
.
dom
.
Document
document
=
documentBuilder
.
newDocument
();
org
.
w3c
.
dom
.
Element
root
=
document
.
createElement
(
"xml"
);
document
.
appendChild
(
root
);
for
(
String
key:
data
.
keySet
())
{
String
value
=
data
.
get
(
key
).
toString
();
if
(
value
==
null
)
{
value
=
""
;
}
value
=
value
.
trim
();
org
.
w3c
.
dom
.
Element
filed
=
document
.
createElement
(
key
);
filed
.
appendChild
(
document
.
createTextNode
(
value
));
root
.
appendChild
(
filed
);
}
TransformerFactory
tf
=
TransformerFactory
.
newInstance
();
Transformer
transformer
=
tf
.
newTransformer
();
DOMSource
source
=
new
DOMSource
(
document
);
transformer
.
setOutputProperty
(
OutputKeys
.
ENCODING
,
"UTF-8"
);
transformer
.
setOutputProperty
(
OutputKeys
.
INDENT
,
"yes"
);
StringWriter
writer
=
new
StringWriter
();
StreamResult
result
=
new
StreamResult
(
writer
);
transformer
.
transform
(
source
,
result
);
String
output
=
writer
.
getBuffer
().
toString
();
//.replaceAll("\n|\r", "");
try
{
writer
.
close
();
}
catch
(
Exception
ex
)
{
}
return
output
;
}
/**
* Map转换成Xml
* @param map
* @return
*/
public
static
String
map2Xmlstring
(
Map
<
String
,
Object
>
map
){
StringBuffer
sb
=
new
StringBuffer
(
""
);
sb
.
append
(
"<xml>"
);
Set
<
String
>
set
=
map
.
keySet
();
for
(
Iterator
<
String
>
it
=
set
.
iterator
();
it
.
hasNext
();){
String
key
=
it
.
next
();
Object
value
=
map
.
get
(
key
);
sb
.
append
(
"<"
).
append
(
key
).
append
(
">"
);
sb
.
append
(
value
);
sb
.
append
(
"</"
).
append
(
key
).
append
(
">"
);
// sb.append("\n");
}
sb
.
append
(
"</xml>"
);
return
sb
.
toString
();
}
/**
* Xml string转换成Map
* @param xmlStr
* @return
*/
public
static
Map
<
String
,
Object
>
xmlString2Map
(
String
xmlStr
){
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Document
doc
;
try
{
doc
=
DocumentHelper
.
parseText
(
xmlStr
);
Element
el
=
doc
.
getRootElement
();
map
=
recGetXmlElementValue
(
el
,
map
);
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
}
return
map
;
}
/**
* 循环解析xml
* @param ele
* @param map
* @return
*/
@SuppressWarnings
({
"unchecked"
})
private
static
Map
<
String
,
Object
>
recGetXmlElementValue
(
Element
ele
,
Map
<
String
,
Object
>
map
){
List
<
Element
>
eleList
=
ele
.
elements
();
if
(
eleList
.
size
()
==
0
)
{
map
.
put
(
ele
.
getName
(),
ele
.
getTextTrim
());
return
map
;
}
else
{
for
(
Iterator
<
Element
>
iter
=
eleList
.
iterator
();
iter
.
hasNext
();)
{
Element
innerEle
=
iter
.
next
();
recGetXmlElementValue
(
innerEle
,
map
);
}
return
map
;
}
}
/**
* 微信支付签名算法sign
* @param characterEncoding
* @param parameters
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
String
createSign
(
String
characterEncoding
,
SortedMap
<
Object
,
Object
>
parameters
){
StringBuffer
sb
=
new
StringBuffer
();
Set
es
=
parameters
.
entrySet
();
//所有参与传参的参数按照accsii排序(升序)
Iterator
it
=
es
.
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
String
k
=
(
String
)
entry
.
getKey
();
Object
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
)
&&
!
"sign"
.
equals
(
k
)
&&
!
"key"
.
equals
(
k
))
{
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
sb
.
append
(
"key="
+
WxConfig
.
KEY
);
// sb.append("key=" + "WINSUN123456xyjl987654wxpay55555");
System
.
out
.
println
(
sb
.
toString
());
String
sign
=
MD5Util
.
MD5Encode
(
sb
.
toString
(),
characterEncoding
).
toUpperCase
(
Locale
.
ENGLISH
);
System
.
out
.
println
(
sign
);
return
sign
;
}
/**
* 微信支付签名算法sign
* @param characterEncoding
* @param parameters
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
String
createSignNoKey
(
String
characterEncoding
,
SortedMap
<
Object
,
Object
>
parameters
){
StringBuffer
sb
=
new
StringBuffer
();
Set
es
=
parameters
.
entrySet
();
//所有参与传参的参数按照accsii排序(升序)
Iterator
it
=
es
.
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
String
k
=
(
String
)
entry
.
getKey
();
Object
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
)
&&
!
"sign"
.
equals
(
k
)
&&
!
"key"
.
equals
(
k
))
{
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
String
sign
=
MD5Util
.
MD5Encode
(
sb
.
toString
(),
characterEncoding
).
toUpperCase
();
return
sign
;
}
}
common/src/main/java/com/winsun/utils/WxConfig.java
0 → 100644
View file @
48f71334
package
com
.
winsun
.
utils
;
/**
* 微信请求地址配置及微信参数类
* @author 董有沛
* @date 2017-03-31
*/
public
class
WxConfig
{
/**************公众号参数信息*************/
// 公众号appid 校园服务号
public
static
final
String
APPID
=
"wx0641dc1dc4d34384"
;
// 公众号秘钥 secret 校园服务号
public
static
final
String
APPSECRET
=
"3b43b46fc94d4e98588ee6ad992fa5c7"
;
public
static
final
String
headUrl
=
"http://dianyuanjiangli.com"
;
public
static
final
String
KEY
=
"WINSUN123456xyjl987654wxpay88888"
;
public
static
final
String
MAC_ID
=
"1498149672"
;
public
static
final
String
NOTIFY_URL
=
"http://dianyuanjiangli.com/xyjl/yx/wxpay/yxt!payNotify.action"
;
// // 公众号appid 网讯测试服务号
// public static final String APPID = "wxfc18f5186b729d15";
//
// // 公众号秘钥 secret 网讯测试服务号
// public static final String APPSECRET = "122278f3fb555468848ff040620505ad";
//
// public static final String headUrl = "http://167460x6b0.51mypc.cn";
//
// public static final String KEY = "WINSUN123456xyjl987654wxpay55555";
//
// public static final String MAC_ID = "1346602601";
//
// public static final String NOTIFY_URL = "http://167460x6b0.51mypc.cn/xyjl/yx/wxpay/yxt!payNotify.action";
/**************消息类型**************/
// 文本类型
public
static
final
String
MSG_TEXT
=
"text"
;
// 图片类型
public
static
final
String
MSG_IMAGE
=
"image"
;
// 语音类型
public
static
final
String
MSG_VOICE
=
"voice"
;
// 视频类型
public
static
final
String
MSG_VIDEO
=
"video"
;
// 小视频类型
public
static
final
String
MSG_SHORT_VIDEO
=
"shortvideo"
;
// 位置类型
public
static
final
String
MSG_LOCATION
=
"location"
;
// 链接类型
public
static
final
String
MSG_LINK
=
"link"
;
// 事件类型
public
static
final
String
MSG_EVENT
=
"event"
;
/****************事件类型******************/
// 订阅事件
public
static
final
String
EVENT_SUBSCRIBE
=
"subscribe"
;
// 取消订阅事件
public
static
final
String
EVENT_UNSUBSCRIBE
=
"unsubscribe"
;
// 扫带参数的二维码事件 ps: 只有用户已关注了公众号,事件类型才是scan,未关注时,事件类型是subscribe
public
static
final
String
EVENT_SCAN
=
"SCAN"
;
// 上报位置事件
public
static
final
String
EVENT_LOCATION
=
"LOCATION"
;
// 自定义菜单的拉取消息事件
public
static
final
String
EVENT_CLICK
=
"CLICK"
;
// 自定义菜单的链接跳转事件
public
static
final
String
EVENT_VIEW
=
"VIEW"
;
/****************微信接口地址******************/
// accessToken生成
public
static
String
ACCESS_TOKEN_URL
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+
APPID
+
"&secret="
+
APPSECRET
;
// 临时二维码
public
static
String
TEMPORARY_CODE_URL
=
"https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="
;
// 永久二维码生成
public
static
String
PERMANENT_CODE_URL
=
"https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="
;
// 使用请求二维码返回ticket换取二维码图片 ps:(ticket需UrlEncode)
public
static
String
TICKET_CODE_URL
=
"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
;
// 授权地址
public
static
String
OAuth
=
"https://open.weixin.qq.com/connect/oauth2/authorize?appid="
+
APPID
+
"&redirect_uri=&response_type=code&scope=&state=#wechat_redirect"
;
/***********************/
public
static
String
commonUrl
=
"http://open.weixin.qq.com/connect/oauth2/authorize?appid="
+
APPID
+
"&redirect_uri=&response_type=code&scope=snsapi_base&state=frommenu#wechat_redirect"
;
}
Write
Preview
Markdown
is supported
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