Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit 93c71cc7
由
zxt@theyeasy.com
编写于
Jan 05, 2018
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge branch 'zxt'
2 个父辈
db536657
853ac8a9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
74 行增加
和
53 行删除
WebContent/WEB-INF/classes/wx.pay.properties
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
src/com/w1hd/zzhnc/model/Lotterylog.java
src/com/w1hd/zzhnc/service/ActivityService.java
src/com/w1hd/zzhnc/service/GoodsService.java
src/com/w1hd/zzhnc/service/PrizeService.java
src/com/w1hd/zzhnc/util/PageResults.java
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
WebContent/WEB-INF/classes/wx.pay.properties
查看文件 @
93c71cc
mch_appid
=
wx
64e56457ec5c6338
mchid
=
149
358131
2
key
=
Bnzihl9t8zId5qKL70bmKDuUpPklMpXB
mch_appid
=
wx
be75806d33ab8a2e
mchid
=
149
601438
2
key
=
glSPm08OiR82CfXyZ3HQECFeiwS7np5t
spbill_create_ip
=
127.0.0.1
cert_file
=
/theyeasy/weixin_cert/zzhnc_apiclient_cert.p12
#
cert_file
=
C:
\\
weixin_cert
\\
zzhnc_apiclient_cert.p12
\ No newline at end of file
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
93c71cc
...
...
@@ -13,6 +13,7 @@ import javax.servlet.ServletException;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.poi.hslf.record.Sound
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Controller
;
...
...
@@ -27,6 +28,7 @@ import org.theyeasy.weixin.util.WxMiniUtil;
import
com.beust.jcommander.internal.Maps
;
import
com.w1hd.zzhnc.controller.pc.BaseController
;
import
com.w1hd.zzhnc.dao.LotteryLogDao
;
import
com.w1hd.zzhnc.model.Activity
;
import
com.w1hd.zzhnc.model.Articles
;
import
com.w1hd.zzhnc.model.Banner
;
...
...
@@ -45,6 +47,8 @@ import com.w1hd.zzhnc.util.RedisUtil;
import
com.w1hd.zzhnc.vo.Vo_msg
;
import
com.wordnik.swagger.annotations.ApiOperation
;
import
tk.mybatis.mapper.entity.Example
;
@Controller
@RequestMapping
(
"/wxmini"
)
public
class
WxMiniController
extends
BaseController
{
...
...
@@ -317,23 +321,32 @@ public class WxMiniController extends BaseController {
}
@Autowired
LotteryLogDao
lotteryLogDao
;
/** 中奖 */
@RequestMapping
(
value
=
"/prizes/kill"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
prizesKill
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
Integer
logId
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
if
(
logId
==
0
)
{
return
new
Vo_msg
(-
1
,
null
,
"不好意思你没中奖"
);
}
if
(
logId
==
-
1
)
{
return
new
Vo_msg
(-
1
,
null
,
"你已经中过奖了"
);
Integer
changes
=
prizeService
.
changes
(
fans
.
getId
());
if
(
changes
>
0
)
{
Integer
logId
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
Lotterylog
log
=
prizeService
.
getLog
(
logId
);
return
new
Vo_msg
(
0
,
log
);
}
Lotterylog
log
=
prizeService
.
getLog
(
logId
);
return
new
Vo_msg
(
0
,
log
);
return
new
Vo_msg
(-
1
,
null
,
"你没有抽奖机会了"
);
}
@RequestMapping
(
value
=
"/prizes/changes"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
changes
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
Integer
changes
=
prizeService
.
changes
(
fans
.
getId
());
return
new
Vo_msg
(
0
,
changes
);
}
/** 获取奖品列表 */
@RequestMapping
(
value
=
"/prizes/all"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
...
...
@@ -346,14 +359,14 @@ public class WxMiniController extends BaseController {
RedisTemplate
<
String
,
Long
>
redisTemplate
;
/** 核销奖品 */
@ApiOperation
(
value
=
"二维码地址"
)
@ApiOperation
(
value
=
"二维码地址"
)
@RequestMapping
(
value
=
"/prizes/sqr"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
scanQr
()
{
long
timeMillis
=
System
.
currentTimeMillis
();
redisTemplate
.
opsForValue
().
set
(
PRIZE_KEY_TIME
+
timeMillis
,
timeMillis
);
redisTemplate
.
expire
(
PRIZE_KEY_TIME
+
timeMillis
,
300
,
TimeUnit
.
SECONDS
);
return
timeMillis
;
return
new
Vo_msg
(
0
,
timeMillis
,
"这个二维码是真的"
)
;
}
/** 核销奖品 */
...
...
src/com/w1hd/zzhnc/model/Lotterylog.java
查看文件 @
93c71cc
...
...
@@ -20,6 +20,15 @@ public class Lotterylog implements Serializable {
private
Integer
turn
;
private
Integer
prizeId
;
private
Date
createdtime
;
private
Date
updatetime
;
public
Date
getUpdatetime
()
{
return
updatetime
;
}
public
void
setUpdatetime
(
Date
updatetime
)
{
this
.
updatetime
=
updatetime
;
}
public
Integer
getId
()
{
return
id
;
...
...
src/com/w1hd/zzhnc/service/ActivityService.java
查看文件 @
93c71cc
...
...
@@ -109,7 +109,7 @@ public class ActivityService {
List
<
Lotterylog_Vo
>
list
=
logDao
.
getLotteryLogList
((
page
-
1
)
*
pagesize
,
pagesize
,
turn
,
keyword
,
status
);
int
total
=
logDao
.
getLotteryLogCount
(
turn
,
status
);
BigDecimal
bMny
=
logDao
.
getSumMny
(
turn
,
status
);
int
mny
=
bMny
==
null
?
0
:
bMny
.
int
Value
();
double
mny
=
bMny
==
null
?
0
:
bMny
.
double
Value
();
pageResults
.
setPage
(
page
);
pageResults
.
setPageSize
(
pagesize
);
...
...
src/com/w1hd/zzhnc/service/GoodsService.java
查看文件 @
93c71cc
...
...
@@ -69,7 +69,7 @@ public class GoodsService {
if
(
"副食"
.
equals
(
key
)
||
"小商品"
.
equals
(
key
)
||
"服装"
.
equals
(
key
)
||
"汽摩配件"
.
equals
(
key
))
{
c
.
andEqualTo
(
"categoryName"
,
key
);
}
else
{
c
.
andCondition
(
" (description like \"%"
+
key
+
"%\" or name like \"%"
+
key
+
"%\"
)"
);
c
.
andCondition
(
" (description like \"%"
+
key
+
"%\" or name like \"%"
+
key
+
"%\" or seller_name like \"%"
+
key
+
"%\" or seller_address like \"%"
+
key
+
"%\"
)"
);
}
}
...
...
@@ -79,6 +79,7 @@ public class GoodsService {
}
c
.
andEqualTo
(
"deleted"
,
false
);
ex
.
setOrderByClause
(
"share_count desc,page_views desc"
);
RowBounds
row
=
new
RowBounds
((
page
-
1
)
*
size
,
size
);
List
<
Goods
>
list
=
goodsDao
.
selectByExampleAndRowBounds
(
ex
,
row
);
int
count
=
goodsDao
.
selectCountByExample
(
ex
);
...
...
src/com/w1hd/zzhnc/service/PrizeService.java
查看文件 @
93c71cc
此文件的差异被折叠,
点击展开。
src/com/w1hd/zzhnc/util/PageResults.java
查看文件 @
93c71cc
...
...
@@ -19,7 +19,7 @@ public class PageResults<T> {
private
int
pageSize
;
private
int
sum
;
private
Number
sum
;
private
String
customfiled1
;
//自定义字段1
...
...
@@ -82,17 +82,13 @@ public class PageResults<T> {
this
.
rows
=
rows
;
}
public
int
getSum
()
{
public
Number
getSum
()
{
return
sum
;
}
public
void
setSum
(
int
sum
)
{
public
void
setSum
(
Number
sum
)
{
this
.
sum
=
sum
;
}
}
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
查看文件 @
93c71cc
...
...
@@ -162,16 +162,18 @@ public class WxMiniServiceImpl implements WxMiniService {
// 指定城市范围
String
city
=
activitySetting
.
getCity
();
// 粉丝城市
String
fansCity
=
fans
.
getProvince
();
if
(
Strings
.
isNullOrEmpty
(
city
)
||
Strings
.
isNullOrEmpty
(
fansCity
)
||
!
fansCity
.
startsWith
(
city
))
{
if
(
null
==
fansCity
||
fansCity
==
"null"
||
fansCity
.
length
()
<
1
)
fansCity
=
"未授权"
;
String
msg
=
"红包活动仅限【"
+
city
+
"】,您的省份【"
+
fansCity
+
"】不在本次活动范围内,不能参与抽奖哦~~/玫瑰/玫瑰"
;
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
msg
);
saveChatLog
(
fans
.
getId
(),
content
,
msg
,
fans
.
getGoodsId
(),
ChatLogReplyType
.
自动回复
,
""
,
""
);
return
respMessage
;
}
String
fansCity
=
fans
.
getCity
();
if
(
fans
.
getId
()
!=
7
)
// TODO 测试
if
(
Strings
.
isNullOrEmpty
(
city
)
||
Strings
.
isNullOrEmpty
(
fansCity
)
||
!
fansCity
.
startsWith
(
city
))
{
if
(
null
==
fansCity
||
fansCity
==
"null"
||
fansCity
.
length
()
<
1
)
fansCity
=
"未授权"
;
String
msg
=
"红包活动仅限【"
+
city
+
"】,您的省份【"
+
fansCity
+
"】不在本次活动范围内,不能参与抽奖哦~~/玫瑰/玫瑰"
;
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
msg
);
saveChatLog
(
fans
.
getId
(),
content
,
msg
,
fans
.
getGoodsId
(),
ChatLogReplyType
.
自动回复
,
""
,
""
);
return
respMessage
;
}
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
activitySetting
.
getReplyWait
());
saveChatLog
(
fans
.
getId
(),
content
,
activitySetting
.
getReplyWait
(),
fans
.
getGoodsId
(),
...
...
@@ -181,34 +183,35 @@ public class WxMiniServiceImpl implements WxMiniService {
Prize
temp
=
null
;
Lotterylog
log
=
null
;
/** 执行抽奖核心 */
fansService
.
getCountParentFansId
(
fans
.
getId
());
int
fansCount
=
fansService
.
getCountParentFansId
(
fans
.
getId
());
if
(
fansCount
==
activitySetting
.
getShareCount
())
{
Integer
changes
=
prizeService
.
changes
(
fans
.
getId
());
if
(
changes
>
0
)
{
Integer
randomKill
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
if
(
randomKill
<
1
)
{
RedisUtil
.
remove
(
"PRIZE_KILL_FANSID_"
+
fans
.
getId
());
Integer
kill
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
if
(
kill
>
0
)
{
log
=
prizeService
.
getLog
(
kill
);
Method
method
=
activitySetting
.
getClass
().
getMethod
(
"getP"
+
log
.
getPrizeId
());
temp
=
(
Prize
)
method
.
invoke
(
activitySetting
,
null
);
}
}
log
=
prizeService
.
getLog
(
randomKill
);
}
if
(
fans
.
getId
()
==
7
)
{
sussess
=
true
;
temp
=
new
Prize
();
temp
.
setIsMoney
(
true
);
temp
.
setMixMoney
(
100
);
temp
.
setMaxMoney
(
110
);
temp
.
setName
(
"测试红包"
);
log
=
new
Lotterylog
();
log
.
setMny
(
new
BigDecimal
(
1.0
));
}
Vo_msg
msg
=
new
Vo_msg
(-
1
,
null
,
"未知错误."
);
int
mny
=
0
;
if
(
sussess
&&
temp
!=
null
&&
temp
.
getIsMoney
())
{
if
(
sussess
&&
temp
!=
null
&&
temp
.
getIsMoney
())
{
mny
=
(
int
)
log
.
getMny
().
doubleValue
()
*
100
;
msg
=
wxPayService
.
payMoney
(
"pay"
+
DateTime
.
now
().
getMillis
(),
fromUserName
,
mny
,
"来自【华南城的】的红包奖励"
);
sussess
=
(
msg
.
code
==
0
);
activityService
.
updateActivity
(
activitySetting
);
activityService
.
addLotteryLog
(
fans
.
getId
(),
new
BigDecimal
(
mny
*
0.01
),
sussess
==
true
?
1
:
0
,
activitySetting
.
getTurn
(),
temp
.
getName
());
activityService
.
addLotteryLog
(
fans
.
getId
(),
new
BigDecimal
(
mny
*
0.01
),
sussess
==
true
?
1
:
0
,
activitySetting
.
getTurn
(),
temp
.
getName
());
}
}
if
(
sussess
)
{
// 已中奖
if
(
temp
.
getIsMoney
())
{
RedisUtil
.
set
(
"zzhnc_lottery_fansid_"
+
fans
.
getId
(),
"1"
,
10
*
60
);
...
...
@@ -221,8 +224,9 @@ public class WxMiniServiceImpl implements WxMiniService {
WxMiniUtil
.
sendCustomMsgLink
(
fromUserName
,
activitySetting
.
getLotteryTitle
(),
activitySetting
.
getLotterySubTitle
(),
url
,
"http://mini.weiyisz.com/zzhnc/res/images/redpackage.png"
);
}
else
{
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
"恭喜获得["
+
temp
.
getName
()
+
"] 请到【我的奖品出兑换奖品】"
);
}
else
{
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
"恭喜获得["
+
temp
.
getName
()
+
"] 请到【我的奖品出兑换奖品】"
);
saveChatLog
(
fans
.
getId
(),
content
,
activitySetting
.
getReplySucceed
(),
fans
.
getGoodsId
(),
ChatLogReplyType
.
自动回复
,
""
,
""
);
}
...
...
@@ -382,7 +386,6 @@ public class WxMiniServiceImpl implements WxMiniService {
newurl
,
"http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg"
);
return
sendResult
;
}
catch
(
WxErrorException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
""
;
...
...
@@ -400,7 +403,6 @@ public class WxMiniServiceImpl implements WxMiniService {
"http://mini.weiyisz.com/zzhnc/res/images/confirm.jpg"
);
return
sendResult
;
}
catch
(
WxErrorException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
""
;
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论