Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
caosy
/
fun-golf-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
edd6c015
authored
Aug 04, 2018
by
chongli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信小程序
parent
e1206855
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
363 additions
and
35 deletions
src/main/java/com/ctrip/fun/golf/api/payment/CommuneOrderNotifyController.java
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherGetLogDao.java
src/main/java/com/ctrip/fun/golf/domain/basic/VoucherGetLog.java
src/main/java/com/ctrip/fun/golf/domain/order/CommuneOrderItem.java
src/main/java/com/ctrip/fun/golf/domain/payment/WxPayUtil.java
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
src/main/java/com/ctrip/fun/golf/service/order/CommuneOrderService.java
src/main/java/com/ctrip/fun/golf/service/payment/CommuneNotifyService.java
src/main/java/com/ctrip/fun/golf/service/user/UserService.java
src/main/resources/debug/payment.properties
src/main/resources/development/payment.properties
src/main/resources/order.spring.xml
src/main/resources/production/payment.properties
src/main/resources/test/payment.properties
src/main/resources/uat/payment.properties
src/main/java/com/ctrip/fun/golf/api/payment/CommuneOrderNotifyController.java
View file @
edd6c015
...
...
@@ -5,8 +5,10 @@ package com.ctrip.fun.golf.api.payment;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.ctrip.fun.golf.service.payment.AbstractNotifyService
;
import
com.ctrip.fun.golf.service.payment.CommuneNotifyService
;
...
...
@@ -25,5 +27,16 @@ public class CommuneOrderNotifyController extends AbstractNotifyController {
protected
AbstractNotifyService
getNotifyService
()
{
return
communeNotifyService
;
}
/**
* 支付通知
*
* @param createPayOrderRequestBean CreatePayOrderRequestBean
* @throws Exception
*/
@ResponseBody
@RequestMapping
(
value
=
"/notifyForMiniApp"
,
method
=
RequestMethod
.
POST
)
public
String
notify
(
@RequestBody
String
xml
)
throws
Exception
{
return
communeNotifyService
.
notifyForMiniApp
(
xml
);
}
}
src/main/java/com/ctrip/fun/golf/dao/basic/VoucherGetLogDao.java
View file @
edd6c015
package
com
.
ctrip
.
fun
.
golf
.
dao
.
basic
;
import
java.util.List
;
import
com.ctrip.fun.golf.dao.GenericHibernateDao
;
import
com.ctrip.fun.golf.domain.basic.VoucherGetLog
;
public
class
VoucherGetLogDao
extends
GenericHibernateDao
<
VoucherGetLog
,
Integer
>
{
public
List
<
VoucherGetLog
>
queryVoucherGetLogListByShareId
(
String
shareid
)
{
String
hsql
=
"from VoucherGetLog t where t.shareid='"
+
shareid
+
"'"
;
return
this
.
getEntities
(
hsql
);
}
}
src/main/java/com/ctrip/fun/golf/domain/basic/VoucherGetLog.java
View file @
edd6c015
...
...
@@ -47,7 +47,7 @@ public class VoucherGetLog implements Serializable {
/**
* 抢券时间
*/
private
Date
get
Time
;
private
Date
create
Time
;
@Id
@GeneratedValue
(
strategy
=
IDENTITY
)
...
...
@@ -72,9 +72,9 @@ public class VoucherGetLog implements Serializable {
}
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"
get
Time"
,
nullable
=
false
,
length
=
19
)
public
Date
get
Get
Time
()
{
return
get
Time
;
@Column
(
name
=
"
create
Time"
,
nullable
=
false
,
length
=
19
)
public
Date
get
Create
Time
()
{
return
create
Time
;
}
public
void
setId
(
Integer
id
)
{
...
...
@@ -93,7 +93,7 @@ public class VoucherGetLog implements Serializable {
this
.
voucherid
=
voucherid
;
}
public
void
set
GetTime
(
Date
get
Time
)
{
this
.
getTime
=
get
Time
;
public
void
set
CreateTime
(
Date
create
Time
)
{
this
.
createTime
=
create
Time
;
}
}
src/main/java/com/ctrip/fun/golf/domain/order/CommuneOrderItem.java
View file @
edd6c015
...
...
@@ -84,6 +84,11 @@ public class CommuneOrderItem implements java.io.Serializable {
*/
@Column
(
name
=
"communeYears"
)
private
Integer
communeYears
;
@Column
(
name
=
"recommendUid"
)
private
String
recommendUid
;
public
Integer
getId
()
{
return
id
;
...
...
@@ -172,6 +177,14 @@ public class CommuneOrderItem implements java.io.Serializable {
public
void
setCommuneYears
(
Integer
communeYears
)
{
this
.
communeYears
=
communeYears
;
}
public
String
getRecommendUid
()
{
return
recommendUid
;
}
public
void
setRecommendUid
(
String
recommendUid
)
{
this
.
recommendUid
=
recommendUid
;
}
...
...
src/main/java/com/ctrip/fun/golf/domain/payment/WxPayUtil.java
0 → 100644
View file @
edd6c015
package
com
.
ctrip
.
fun
.
golf
.
domain
.
payment
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.io.Writer
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.parsers.ParserConfigurationException
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Node
;
import
org.w3c.dom.NodeList
;
import
org.xml.sax.SAXException
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.core.util.QuickWriter
;
import
com.thoughtworks.xstream.io.HierarchicalStreamWriter
;
import
com.thoughtworks.xstream.io.xml.PrettyPrintWriter
;
import
com.thoughtworks.xstream.io.xml.XppDriver
;
/**
* 微信支付,工具类
*
* @author muyunfei
*
*<p>Modification History:</p>
*<p>Date Author Description</p>
*<p>------------------------------------------------------------------</p>
*<p>11 30, 2016 muyunfei 新建</p>
*/
public
class
WxPayUtil
{
/**
* 签名
* 第一步,设所有发送或者接收到的数据为集合M,将集合M内非空参数值的参数按照参数名ASCII码从小到大排序(字典序),
* 使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串stringA。
* 特别注意以下重要规则:
* ◆ 参数名ASCII码从小到大排序(字典序);
* ◆ 如果参数的值为空不参与签名;
* ◆ 参数名区分大小写;
* ◆ 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。
* ◆ 微信接口可能增加字段,验证签名时必须支持增加的扩展字段
* 第二步,在stringA最后拼接上key得到stringSignTemp字符串,并对stringSignTemp进行MD5运算,再将得到的字符串所有字符转换为大写,得到sign值signValue。
* key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
* @param map
* @return
* @throws UnsupportedEncodingException
*/
public
static
String
getSign
(
Map
<
String
,
Object
>
map
)
throws
UnsupportedEncodingException
{
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
map
.
entrySet
()){
//参数为空不参与签名
if
(
entry
.
getValue
()!=
""
){
list
.
add
(
entry
.
getKey
()
+
"="
+
entry
.
getValue
());
}
}
int
size
=
list
.
size
();
String
[]
arrayToSort
=
list
.
toArray
(
new
String
[
size
]);
Arrays
.
sort
(
arrayToSort
,
String
.
CASE_INSENSITIVE_ORDER
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
sb
.
append
(
arrayToSort
[
i
]);
if
(
i
!=
size
-
1
){
sb
.
append
(
"&"
);
}
}
String
result
=
sb
.
toString
();
result
+=
"&key="
+
Configure
.
getKey
();
//Util.log("Sign Before MD5:" + result);
result
=
MD5
.
MD5Encode
(
result
).
toUpperCase
();
//Util.log("Sign Result:" + result);
return
result
;
}
/**
* 签名算法
* @param o 要参与签名的数据对象
* @return 签名
* @throws IllegalAccessException
*/
public
static
String
getSign
(
Object
o
)
throws
IllegalAccessException
{
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>();
Class
cls
=
o
.
getClass
();
Field
[]
fields
=
cls
.
getDeclaredFields
();
for
(
Field
f
:
fields
)
{
f
.
setAccessible
(
true
);
if
(
f
.
get
(
o
)
!=
null
&&
f
.
get
(
o
)
!=
""
)
{
list
.
add
(
f
.
getName
()
+
"="
+
f
.
get
(
o
)
);
}
}
int
size
=
list
.
size
();
String
[]
arrayToSort
=
list
.
toArray
(
new
String
[
size
]);
Arrays
.
sort
(
arrayToSort
,
String
.
CASE_INSENSITIVE_ORDER
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
sb
.
append
(
arrayToSort
[
i
]);
if
(
i
!=
size
-
1
){
sb
.
append
(
"&"
);
}
}
String
result
=
sb
.
toString
();
result
+=
"&key="
+
Configure
.
getKey
();
result
=
MD5
.
MD5Encode
(
result
).
toUpperCase
();
return
result
;
}
/**
* 生成随机字符串
* @param length
* @return
*/
public
static
String
getRandomString2
(
int
length
){
Random
random
=
new
Random
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
length
;
++
i
){
int
number
=
random
.
nextInt
(
3
);
long
result
=
0
;
switch
(
number
){
case
0
:
result
=
Math
.
round
(
Math
.
random
()
*
25
+
65
);
sb
.
append
(
String
.
valueOf
((
char
)
result
));
break
;
case
1
:
result
=
Math
.
round
(
Math
.
random
()
*
25
+
97
);
sb
.
append
(
String
.
valueOf
((
char
)
result
));
break
;
case
2
:
sb
.
append
(
String
.
valueOf
(
new
Random
().
nextInt
(
10
)));
break
;
}
}
return
sb
.
toString
();
}
/**
* 获取xml信息
* @param xmlString
* @return
* @throws ParserConfigurationException
* @throws IOException
* @throws SAXException
*/
public
static
Map
<
String
,
Object
>
getMapFromXML
(
String
xmlString
)
throws
ParserConfigurationException
,
IOException
,
SAXException
{
//这里用Dom的方式解析回包的最主要目的是防止API新增回包字段
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
InputStream
is
=
null
;
if
(
xmlString
!=
null
&&
!
xmlString
.
trim
().
equals
(
""
))
{
is
=
new
ByteArrayInputStream
(
xmlString
.
getBytes
(
"utf-8"
));
}
Document
document
=
builder
.
parse
(
is
);
//获取到document里面的全部结点
NodeList
allNodes
=
document
.
getFirstChild
().
getChildNodes
();
Node
node
;
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
int
i
=
0
;
while
(
i
<
allNodes
.
getLength
())
{
node
=
allNodes
.
item
(
i
);
if
(
node
instanceof
Element
){
map
.
put
(
node
.
getNodeName
(),
node
.
getTextContent
());
}
i
++;
}
return
map
;
}
/**
* 扩展xstream使其支持CDATA
* 内部类XppDriver
*/
private
static
XStream
xstream
=
new
XStream
(
new
XppDriver
()
{
public
HierarchicalStreamWriter
createWriter
(
Writer
out
)
{
return
new
PrettyPrintWriter
(
out
)
{
// 对所有xml节点的转换都增加CDATA标记
boolean
cdata
=
true
;
public
void
startNode
(
String
name
,
Class
clazz
)
{
super
.
startNode
(
name
,
clazz
);
}
protected
void
writeText
(
QuickWriter
writer
,
String
text
)
{
if
(
cdata
)
{
//writer.write("<![CDATA[");
writer
.
write
(
text
);
//writer.write("]]>");
}
else
{
writer
.
write
(
text
);
}
}
};
}
});
}
src/main/java/com/ctrip/fun/golf/service/basic/VoucherService.java
View file @
edd6c015
...
...
@@ -3,12 +3,15 @@ package com.ctrip.fun.golf.service.basic;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -715,20 +718,47 @@ public class VoucherService {
//被分享用户抢券
public
Response
<
String
>
getSharedVoucherForMiniApps
(
VoucherGetLogBean
voucherGetLogBean
)
{
Response
<
String
>
response
=
new
Response
<
String
>();
//分享的券标记为已经使用
//1:分享是否已经过期
VoucherShareLog
voucherShareLog
=
voucherShareLogDao
.
findById
(
Integer
.
parseInt
(
voucherGetLogBean
.
getShareid
()));
voucherShareLog
.
getCreateTime
();
Date
date
=
new
Date
();
if
(
date
.
getTime
()
>
DateUtil
.
addDateField
(
voucherShareLog
.
getCreateTime
(),
Calendar
.
DAY_OF_MONTH
,
1
).
getTime
()){
response
.
setStatus
(
2
);
response
.
setMessage
(
"分享已过期"
);
response
.
setBody
(
"fail"
);
return
response
;
}
//是否已经抢过券
List
<
VoucherGetLog
>
list
=
voucherGetLogDao
.
queryVoucherGetLogListByShareId
(
voucherGetLogBean
.
getShareid
());
if
(
list
!=
null
&&
list
.
size
()>
0
){
response
.
setStatus
(
3
);
response
.
setMessage
(
"不能重复抢券"
);
response
.
setBody
(
"fail"
);
return
response
;
}
//要抢的的券已经被人提前抢了
Voucher
voucher
=
voucherDao
.
findById
(
voucherGetLogBean
.
getVoucherid
());
if
(
voucher
.
getUsed
()==
1
){
response
.
setStatus
(
4
);
response
.
setMessage
(
"券已被抢"
);
response
.
setBody
(
"fail"
);
return
response
;
}
//非社员不能抢,后面加
//分享的券标记为已经使用
voucherDao
.
updateVoucherIsShared
(
voucherGetLogBean
.
getVoucherid
());
//抢券人增加一张券
Voucher
newVoucher
=
new
Voucher
();
BeanConverter
.
copyProperties
(
newVoucher
,
voucher
);
newVoucher
.
setUid
(
voucherGetLogBean
.
getUid
());
newVoucher
.
setUsed
(
0
);
newVoucher
.
setIsShare
(
0
);
newVoucher
.
setSource
(
VoucherSourceEnum
.
RULE_FRIEND_PRESENT
.
getValue
());
voucherDao
.
save
(
newVoucher
);
//抢券表中增加一条记录
VoucherGetLog
voucherGetLog
=
new
VoucherGetLog
();
BeanConverter
.
copyProperties
(
voucherGetLog
,
voucherGetLogBean
);
voucherGetLog
.
set
Get
Time
(
new
Date
());
voucherGetLog
.
set
Create
Time
(
new
Date
());
voucherGetLogDao
.
save
(
voucherGetLog
);
//设置状态
response
.
setStatus
(
1
);
...
...
src/main/java/com/ctrip/fun/golf/service/order/CommuneOrderService.java
View file @
edd6c015
...
...
@@ -79,6 +79,9 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
private
String
communeBaseNotifyUrl
;
private
String
communeBaseNotifyUrlForMiniApp
;
private
ClientConfigDao
clientConfigDao
=
null
;
...
...
@@ -145,8 +148,8 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
checkOrderItem
(
communeOrderBean
);
}
//用于订单支付成功之后,做一些发放优惠券之类的活动
public
void
executeOrderActive
(
Order
order
){
ClientConfig
clientConfig
=
clientConfigDao
.
getByType
(
commune_voucher_send
);
public
void
executeOrderActive
(
String
uid
,
String
voucherSendType
){
ClientConfig
clientConfig
=
clientConfigDao
.
getByType
(
voucherSendType
);
//社员订单赠送优惠券配置:431_sendBeginTime_sendEndTime(规则id_开始发送时间_结束发送方式)
String
commune_voucher
=
clientConfig
.
getMessage
();
JSONObject
jsobj
=
JSONObject
.
parseObject
(
commune_voucher
);
...
...
@@ -156,7 +159,7 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
Date
now
=
new
Date
();
if
(
sendBeginTime
.
getTime
()<
now
.
getTime
()&&
now
.
getTime
()<
sendEndTime
.
getTime
()){
VoucherRule
voucherRule
=
this
.
getVoucherRuleDao
().
findById
(
Integer
.
parseInt
(
jsobj
.
getString
(
"id"
)));
this
.
getVoucherDao
().
sendVoucherToSpecificUsers
(
voucherRule
,
"'"
+
order
.
getUid
()
+
"'"
,
voucherRule
.
getQuantity
());
this
.
getVoucherDao
().
sendVoucherToSpecificUsers
(
voucherRule
,
"'"
+
uid
+
"'"
,
voucherRule
.
getQuantity
());
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
...
...
@@ -222,6 +225,7 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
orderItem
.
setDistrictId
(
communeOrderBean
.
getDistrictId
());
//社员续费 add by caosy
orderItem
.
setCommuneYears
(
communeOrderBean
.
getCommuneYears
());
orderItem
.
setRecommendUid
(
communeOrderBean
.
getRecommendUid
());
communeOrderItemDao
.
save
(
orderItem
);
}
...
...
@@ -231,22 +235,33 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
if
(
this
.
beforePlaceOrder
(
communeOrderBean
))
{
Order
order
=
this
.
saveOrder
(
communeOrderBean
);
this
.
saveOrderItems
(
communeOrderBean
,
order
.
getOrderId
());
UserExt
userExt
=
getUserExtDao
().
getByUid
(
communeOrderBean
.
getUid
());
//便于生产测试,下单的钱将变成配置的,如果下单金额等于360,则是续费,使用续费配置的金额;如果下单金额等于980,就是充值,则使用充值配置
ClientConfig
clientConfig
=
clientConfigDao
.
getByType
(
"communeMoneyConfig"
);
String
communeMoneyConfig
=
clientConfig
.
getMessage
();
JSONObject
jsobj
=
JSONObject
.
parseObject
(
communeMoneyConfig
);
int
communeOrderMoney
=
0
;
if
(
communeOrderBean
.
getAmount
().
intValue
()==
360
){
communeOrderMoney
=
jsobj
.
getInteger
(
"xuFeiMoney"
);
}
else
{
communeOrderMoney
=
jsobj
.
getInteger
(
"chongZhiMoney"
);
}
String
prepay_id
=
this
.
xiaDan
(
userExt
.
getMiniAppOpenId
(),
order
.
getOrderNo
()+
""
,
communeOrderMoney
*
100
);
JSONObject
json
=
this
.
sign
(
prepay_id
);
return
json
;
}
UserExt
userExt
=
getUserExtDao
().
getByUid
(
communeOrderBean
.
getUid
());
String
prepay_id
=
this
.
xiaDan
(
userExt
.
getMiniAppOpenId
());
JSONObject
json
=
this
.
sign
(
prepay_id
);
return
json
;
return
null
;
}
private
String
xiaDan
(
String
openid
)
throws
Exception
{
private
String
xiaDan
(
String
openid
,
String
orderNo
,
int
communeOrderMoney
)
throws
Exception
{
OrderInfo
order
=
new
OrderInfo
();
order
.
setAppid
(
Configure
.
getAppID
());
order
.
setMch_id
(
Configure
.
getMch_id
());
order
.
setNonce_str
(
RandomStringGenerator
.
getRandomStringByLength
(
32
));
order
.
setBody
(
"
dfdfdf
"
);
order
.
setOut_trade_no
(
RandomStringGenerator
.
getRandomStringByLength
(
32
)
);
order
.
setTotal_fee
(
1
);
order
.
setBody
(
"
会员充值
"
);
order
.
setOut_trade_no
(
orderNo
);
order
.
setTotal_fee
(
communeOrderMoney
);
order
.
setSpbill_create_ip
(
"123.57.218.54"
);
order
.
setNotify_url
(
"https://www.see-source.com/weixinpay/PayResult"
);
order
.
setNotify_url
(
communeBaseNotifyUrlForMiniApp
);
order
.
setTrade_type
(
"JSAPI"
);
order
.
setOpenid
(
openid
);
order
.
setSign_type
(
"MD5"
);
...
...
@@ -294,8 +309,6 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
getUserExtDao
().
setUserExtVipGradeCommune
(
order
.
getUid
());
operationMessageService
.
executeSendMessageOfVipCommune
(
order
,
91
);
communeInviteActivityService
.
updateCommuneInviteActivityData
(
order
.
getOrderId
());
//首充会员发放优惠券
this
.
executeOrderActive
(
order
);
}
else
{
getUserExtDao
().
setUserExtVipGradeRenewCommune
(
order
.
getUid
());
operationMessageService
.
executeSendMessageOfVipCommune
(
order
,
110
);
...
...
@@ -547,7 +560,15 @@ public class CommuneOrderService extends AbstractOrderService<CommuneOrderBean,
public
void
setCommuneBaseNotifyUrl
(
String
communeBaseNotifyUrl
)
{
this
.
communeBaseNotifyUrl
=
communeBaseNotifyUrl
;
}
public
String
getCommuneBaseNotifyUrlForMiniApp
()
{
return
communeBaseNotifyUrlForMiniApp
;
}
public
void
setCommuneBaseNotifyUrlForMiniApp
(
String
communeBaseNotifyUrlForMiniApp
)
{
this
.
communeBaseNotifyUrlForMiniApp
=
communeBaseNotifyUrlForMiniApp
;
}
public
BigDecimal
getCOMMUNE_AMOUNT
()
{
return
COMMUNE_AMOUNT
;
}
...
...
src/main/java/com/ctrip/fun/golf/service/payment/CommuneNotifyService.java
View file @
edd6c015
...
...
@@ -2,12 +2,21 @@
* Copyright 2014 CTRIP Co.,Ltd. All rights reserved.
*/
package
com
.
ctrip
.
fun
.
golf
.
service
.
payment
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
javax.xml.parsers.ParserConfigurationException
;
import
org.springframework.util.CollectionUtils
;
import
org.xml.sax.SAXException
;
import
com.ctrip.fun.common.core.util.DateUtil
;
import
com.ctrip.fun.common.vo.order.OrderCategoryEnum
;
import
com.ctrip.fun.common.vo.payment.NotifyResponseBean
;
import
com.ctrip.fun.golf.dao.basic.VoucherDao
;
import
com.ctrip.fun.golf.dao.basic.VoucherRuleDao
;
import
com.ctrip.fun.golf.dao.client.ClientConfigDao
;
...
...
@@ -17,14 +26,11 @@ import com.ctrip.fun.golf.domain.basic.VoucherRule;
import
com.ctrip.fun.golf.domain.client.ClientConfig
;
import
com.ctrip.fun.golf.domain.order.CommuneOrderItem
;
import
com.ctrip.fun.golf.domain.order.Order
;
import
com.ctrip.fun.golf.domain.payment.WxPayUtil
;
import
com.ctrip.fun.golf.service.basic.OperationMessageService
;
import
com.ctrip.fun.golf.service.market.CommuneInviteActivityService
;
import
com.ctrip.fun.golf.service.order.CommuneOrderService
;
public
class
CommuneNotifyService
extends
AbstractNotifyService
{
private
CommuneOrderService
communeOrderService
=
null
;
private
OperationMessageService
operationMessageService
;
...
...
@@ -38,7 +44,35 @@ public class CommuneNotifyService extends AbstractNotifyService {
public
String
notifyForMiniApp
(
String
xml
)
throws
Exception
{
Map
<
String
,
Object
>
notifyMap
=
WxPayUtil
.
getMapFromXML
(
xml
);
if
(
notifyMap
.
get
(
"return_code"
).
equals
(
"SUCCESS"
)){
if
(
notifyMap
.
get
(
"result_code"
).
equals
(
"SUCCESS"
)){
String
ordersSn
=
notifyMap
.
get
(
"out_trade_no"
).
toString
();
//商户订单号
//根据订单号查询订单,修改订单相关信息
Order
order
=
this
.
getOrderDao
().
getOrderByOrderNo
(
Long
.
parseLong
(
ordersSn
));
CommuneOrderItem
communeOrderItem
=
communeOrderItemDao
.
getByOrderId
(
order
.
getOrderId
()).
get
(
0
);
String
uid
=
order
.
getUid
();
//下单人id
String
recommendUid
=
communeOrderItem
.
getRecommendUid
();
//推荐人id
this
.
doPaySuccess
(
order
);
//执行发券规则
if
(
OrderCategoryEnum
.
COMMUNE
.
getKey
()
==
order
.
getOrderCategory
()){
if
(
order
.
getAmount
().
intValue
()==
980
){
//1:执行充值人的小程序优惠
communeOrderService
.
executeOrderActive
(
uid
,
"chongzhiren_voucher_send_980"
);
//1:执行推荐人的小程序优惠
communeOrderService
.
executeOrderActive
(
recommendUid
,
"tuijianren_voucher_send_980"
);
}
else
if
(
order
.
getAmount
().
intValue
()==
360
){
//1:执行充值人的小程序优惠
communeOrderService
.
executeOrderActive
(
uid
,
"chongzhiren_voucher_send_360"
);
//1:执行推荐人的小程序优惠
communeOrderService
.
executeOrderActive
(
recommendUid
,
"tuijianren_voucher_send_360"
);
}
}
}
}
return
null
;
}
@Override
...
...
@@ -48,8 +82,6 @@ public class CommuneNotifyService extends AbstractNotifyService {
// 更新公社活动推广相关数据
communeInviteActivityService
.
updateCommuneInviteActivityData
(
order
.
getOrderId
());
sendMessage
(
order
,
91
);
//社员首次充值发放优惠券
communeOrderService
.
executeOrderActive
(
order
);
}
else
{
getUserExtDao
().
setUserExtVipGradeRenewCommune
(
order
.
getUid
());
sendMessage
(
order
,
110
);
...
...
src/main/java/com/ctrip/fun/golf/service/user/UserService.java
View file @
edd6c015
...
...
@@ -1234,7 +1234,7 @@ public class UserService {
public
MiniAppLoginResultBean
miniAppLoginByDynamicPassword
(
MiniAppLoginBean
request
)
{
this
.
checkMobileNo
(
request
.
getUserMobilePhone
());
UserVerifyCode
userVerifyCode
=
this
.
userVerifyCodeDao
.
checkVerifyCode
(
request
.
getUserMobilePhone
(),
VerifyType
.
REQISTER
.
getValue
(),
request
.
getUserMobilePhone
(),
VerifyType
.
VERIFY_CODE
.
getValue
(),
Integer
.
parseInt
(
request
.
getVerifyCode
()));
if
(
userVerifyCode
==
null
)
{
throw
new
UserException
(
302
,
"验证码不正确或验证码过期"
);
...
...
src/main/resources/debug/payment.properties
View file @
edd6c015
...
...
@@ -8,6 +8,7 @@ payment.courseBaseNotifyUrl=http://112.65.124.86:18081/fun-common-soa/notify/cou
payment.tourBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/tourOrder
payment.rechargeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/rechargeOrder
payment.communeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/communeOrder
payment.communeBaseNotifyUrlForMiniApp
=
http://112.65.124.86:18081/fun-common-soa/notify/notifyForMiniApp
payment.vipmemberBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/vipmemberOrder
payment.eventActivityBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/eventActivityOrder
payment.mallBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/mallOrder
...
...
src/main/resources/development/payment.properties
View file @
edd6c015
...
...
@@ -8,6 +8,7 @@ payment.courseBaseNotifyUrl=http://112.65.124.86:18081/fun-common-soa/notify/cou
payment.tourBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/tourOrder
payment.rechargeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/rechargeOrder
payment.communeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/communeOrder
payment.communeBaseNotifyUrlForMiniApp
=
http://112.65.124.86:18081/fun-common-soa/notify/notifyForMiniApp
payment.vipmemberBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/vipmemberOrder
payment.eventActivityBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/eventActivityOrder
payment.mallBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/mallOrder
...
...
src/main/resources/order.spring.xml
View file @
edd6c015
...
...
@@ -193,6 +193,7 @@
<property
name=
"jobUtil"
ref=
"jobUtil"
></property>
<property
name=
"overTimeMinute"
value=
"${payment.longOvertime}"
></property>
<property
name=
"communeBaseNotifyUrl"
value=
"${payment.communeBaseNotifyUrl}"
></property>
<property
name=
"communeBaseNotifyUrlForMiniApp"
value=
"${payment.communeBaseNotifyUrlForMiniApp}"
></property>
<property
name=
"COMMUNE_AMOUNT"
value=
"${communeAmount}"
></property>
<property
name=
"COMMUNE_AMOUNT2"
value=
"${communeAmount2}"
></property>
<property
name=
"clientConfigDao"
ref=
"clientConfigDao"
></property>
...
...
src/main/resources/production/payment.properties
View file @
edd6c015
...
...
@@ -10,6 +10,7 @@ payment.courseBaseNotifyUrl=http\://api.iwanoutdoor.com/fun-common-soa/notify/co
payment.tourBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/tourOrder
payment.rechargeBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/rechargeOrder
payment.communeBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/communeOrder
payment.communeBaseNotifyUrlForMiniApp
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/notifyForMiniApp
payment.vipmemberBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/vipmemberOrder
payment.eventActivityBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/eventActivityOrder
payment.mallBaseNotifyUrl
=
http
\:
//api.iwanoutdoor.com/fun-common-soa/notify/mallOrder
...
...
src/main/resources/test/payment.properties
View file @
edd6c015
...
...
@@ -8,6 +8,7 @@ payment.courseBaseNotifyUrl=http://112.65.124.86:18081/fun-common-soa/notify/cou
payment.tourBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/tourOrder
payment.rechargeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/rechargeOrder
payment.communeBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/communeOrder
payment.communeBaseNotifyUrlForMiniApp
=
http://112.65.124.86:18081/fun-common-soa/notify/notifyForMiniApp
payment.vipmemberBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/vipmemberOrder
payment.eventActivityBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/eventActivityOrder
payment.mallBaseNotifyUrl
=
http://112.65.124.86:18081/fun-common-soa/notify/mallOrder
...
...
src/main/resources/uat/payment.properties
View file @
edd6c015
...
...
@@ -8,6 +8,7 @@ payment.courseBaseNotifyUrl=http://10.8.55.46:8080/fun-common-soa/notify/courseO
payment.tourBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/tourOrder
payment.rechargeBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/rechargeOrder
payment.communeBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/communeOrder
payment.communeBaseNotifyUrlForMiniApp
=
http://10.8.55.46:8080/fun-common-soa/notify/notifyForMiniApp
payment.vipmemberBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/vipmemberOrder
payment.eventActivityBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/eventActivityOrder
payment.mallBaseNotifyUrl
=
http://10.8.55.46:8080/fun-common-soa/notify/mallOrder
...
...
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