Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit 623daae6
由
zxt@theyeasy.com
编写于
Jan 12, 2018
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
抽奖Bug修改
1 个父辈
fc7befd4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
47 行增加
和
30 行删除
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
src/com/w1hd/zzhnc/model/Activity.java
src/com/w1hd/zzhnc/service/ArticleService.java
src/com/w1hd/zzhnc/service/GoodsService.java
src/com/w1hd/zzhnc/service/PrizeService.java
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
623daae
...
...
@@ -4,6 +4,7 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.sql.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.testng.util.Strings
;
import
org.theyeasy.weixin.model.WxMiniSessionInfo
;
import
org.theyeasy.weixin.service.WxMiniService
;
import
org.theyeasy.weixin.util.WxMiniUtil
;
...
...
@@ -31,6 +33,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.enums.ChatLogReplyType
;
import
com.w1hd.zzhnc.model.Activity
;
import
com.w1hd.zzhnc.model.Articles
;
import
com.w1hd.zzhnc.model.Banner
;
...
...
@@ -114,7 +117,7 @@ public class WxMiniController extends BaseController {
@RequestParam
(
value
=
"shareId"
)
Integer
shareId
,
@RequestParam
(
value
=
"fansId"
)
Integer
fansId
,
@RequestParam
(
value
=
"nickname"
)
String
nickname
,
@RequestParam
(
value
=
"logo"
)
String
logo
,
@RequestParam
(
value
=
"lng"
)
double
lng
,
@RequestParam
(
value
=
"lat"
)
double
lat
)
{
logger
.
info
(
"小程序登录:code="
+
code
);
logger
.
info
(
"小程序登录:code="
+
code
+
"分享商品ID:"
+
shareId
+
" 分享者ID:"
+
fansId
);
// 取openid
WxMiniSessionInfo
sessionInfo
=
WxMiniUtil
.
jscode2session
(
code
);
// 添加粉丝记录
...
...
@@ -331,6 +334,18 @@ public class WxMiniController extends BaseController {
@ResponseBody
public
Object
prizesKill
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
Activity
activity
=
activityService
.
getActivitySetting
();
String
city
=
activity
.
getCity
();
// 粉丝城市
String
fansCity
=
fans
.
getCity
();
System
.
out
.
println
(
"活动城市:"
+
city
+
" 粉丝城市:"
+
fansCity
);
if
(
Strings
.
isNullOrEmpty
(
city
)
||
Strings
.
isNullOrEmpty
(
fansCity
)
||
!
fansCity
.
startsWith
(
city
))
{
if
(
null
==
fansCity
||
fansCity
==
"null"
||
fansCity
.
length
()
<
1
)
fansCity
=
"未授权"
;
String
msg
=
"红包活动仅限【"
+
city
+
"】,您的城市【"
+
fansCity
+
"】不在本次活动范围内,不能参与抽奖哦~~"
;
return
new
Vo_msg
(-
1
,
null
,
msg
);
}
// 指定城市范围
Integer
changes
=
prizeService
.
changes
(
fans
.
getId
());
if
(
changes
>
0
)
{
Integer
logId
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
...
...
@@ -344,6 +359,11 @@ public class WxMiniController extends BaseController {
@RequestMapping
(
value
=
"/prizes/changes"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
changes
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Activity
activity
=
activityService
.
getActivitySetting
();
int
compareTo
=
new
Date
(
System
.
currentTimeMillis
()).
compareTo
(
activity
.
getBeginTime
());
if
(
compareTo
<
0
)
{
return
new
Vo_msg
(-
1
,
0
,
"活动还没开始"
);
}
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
Integer
changes
=
prizeService
.
changes
(
fans
.
getId
());
if
(
changes
<
0
)
{
...
...
src/com/w1hd/zzhnc/model/Activity.java
查看文件 @
623daae
...
...
@@ -155,7 +155,6 @@ public class Activity implements Serializable {
public
void
setP1
(
Prize
p1
)
{
this
.
p1
=
p1
;
p1
.
setId
(
1
);
}
public
Prize
getP2
()
{
...
...
@@ -164,7 +163,6 @@ public class Activity implements Serializable {
public
void
setP2
(
Prize
p2
)
{
this
.
p2
=
p2
;
p2
.
setId
(
2
);
}
public
Prize
getP3
()
{
...
...
@@ -173,7 +171,6 @@ public class Activity implements Serializable {
public
void
setP3
(
Prize
p3
)
{
this
.
p3
=
p3
;
p3
.
setId
(
3
);
}
public
Prize
getP4
()
{
...
...
@@ -182,7 +179,6 @@ public class Activity implements Serializable {
public
void
setP4
(
Prize
p4
)
{
this
.
p4
=
p4
;
p4
.
setId
(
4
);
}
...
...
src/com/w1hd/zzhnc/service/ArticleService.java
查看文件 @
623daae
...
...
@@ -129,7 +129,7 @@ public class ArticleService{
public
List
<
Articles
>
getHomeData
()
{
Example
example
=
new
Example
(
Articles
.
class
);
example
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
);
RowBounds
row
=
new
RowBounds
(
0
,
5
);
RowBounds
row
=
new
RowBounds
(
0
,
200
);
example
.
setOrderByClause
(
" id desc "
);
List
<
Articles
>
list
=
articleDao
.
selectByExampleAndRowBounds
(
example
,
row
);
return
list
;
...
...
src/com/w1hd/zzhnc/service/GoodsService.java
查看文件 @
623daae
...
...
@@ -2,6 +2,7 @@ package com.w1hd.zzhnc.service;
import
java.sql.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.ibatis.session.RowBounds
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -24,13 +25,12 @@ public class GoodsService {
@Autowired
GoodsDao
goodsDao
;
final
String
GOODSID_
=
RedisUtil
.
PROJECTNAME
.
concat
(
"_"
).
concat
(
"goods"
);
final
String
GOODSID_
=
RedisUtil
.
PROJECTNAME
.
concat
(
"_"
).
concat
(
"goods
_id
"
);
public
List
<
Goods
>
getHomeData
()
{
Example
ex
=
new
Example
(
Goods
.
class
);
ex
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
).
andEqualTo
(
"isHome"
,
true
);
ex
.
setOrderByClause
(
"page_views desc"
);
RowBounds
r
=
new
RowBounds
(
0
,
10
);
return
goodsDao
.
selectByExample
(
ex
);
}
...
...
@@ -120,6 +120,7 @@ public class GoodsService {
}
goods
.
setPageViews
(
goods
.
getPageViews
()
+
1
);
redisTemplate
.
opsForValue
().
set
(
GOODSID_
+
id
,
goods
);
redisTemplate
.
expire
(
GOODSID_
+
id
,
5
,
TimeUnit
.
DAYS
);
list
.
add
(
goods
);
pageResults
.
setRows
(
list
);
return
pageResults
;
...
...
src/com/w1hd/zzhnc/service/PrizeService.java
查看文件 @
623daae
...
...
@@ -5,6 +5,7 @@ import java.math.RoundingMode;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.apache.ibatis.session.RowBounds
;
...
...
@@ -145,7 +146,7 @@ public class PrizeService {
System
.
out
.
println
(
"抽中一个红包 >"
+
order
);
lotterylog
.
setPrizeUrl
(
order
);
lotterylog
.
setMny
(
mny
);
// lotterylog.setStatus(2
);
lotterylog
.
setStatus
(
1
);
// Fans fans = fansService.getFansById(fansId);
// activityService.sendRedPackage(fans.getMiniopenid(), (int) (mny.doubleValue()
...
...
@@ -156,6 +157,7 @@ public class PrizeService {
lotterylog
.
setTurn
(
setting
.
getTurn
());
lotteryLogDao
.
insert
(
lotterylog
);
redisTemplate
.
opsForValue
().
set
(
LotteryLogID_
+
lotterylog
.
getId
(),
lotterylog
);
redisTemplate
.
expire
(
LotteryLogID_
+
lotterylog
.
getId
(),
5
,
TimeUnit
.
DAYS
);
return
lotterylog
.
getId
();
}
...
...
@@ -204,6 +206,7 @@ public class PrizeService {
lotterylog
.
setStatus
(
2
);
lotterylog
.
setUpdatetime
(
new
Date
());
lotteryLogDao
.
updateByPrimaryKey
(
lotterylog
);
redisTemplate
.
expire
(
LotteryLogID_
+
lotterylog
.
getId
(),
200
,
TimeUnit
.
SECONDS
);
return
lotterylog
;
}
...
...
@@ -226,7 +229,6 @@ public class PrizeService {
count
=
count
-
1
;
return
count
;
}
}
if
(
lotteryLog
==
null
)
{
...
...
@@ -237,15 +239,20 @@ public class PrizeService {
Example
ex
=
new
Example
(
Lotterylog
.
class
);
ex
.
createCriteria
().
andEqualTo
(
"fansid"
,
fansId
);
int
lotteryCount
=
lotteryLogDao
.
selectCountByExample
(
ex
);
if
(
lotteryCount
>
MAX_CHANGES
)
{
if
(
lotteryCount
>
=
MAX_CHANGES
)
{
return
0
;
}
int
shareCount
=
activitySetting
.
getShareCount
();
if
(
shareCount
==
0
)
if
(
shareCount
==
0
)
{
shareCount
=
1
;
}
int
changes
=
fansCount
/
shareCount
;
changes
=
changes
-
lotteryCount
;
return
changes
+
1
;
changes
=
changes
+
1
;
if
(
changes
>
MAX_CHANGES
)
{
changes
=
MAX_CHANGES
;
}
return
changes
;
}
}
...
...
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
查看文件 @
623daae
...
...
@@ -163,7 +163,6 @@ public class WxMiniServiceImpl implements WxMiniService {
String
city
=
activitySetting
.
getCity
();
// 粉丝城市
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
)
...
...
@@ -268,31 +267,25 @@ public class WxMiniServiceImpl implements WxMiniService {
String
eventType
=
requestMap
.
get
(
"Event"
);
// 事件类型,未使用
if
(
eventType
.
equals
(
"user_enter_tempsession"
))
// 用户在小程序进入客服面板
{
// 保存进入会话时传入的参数
String
sessionFrom
=
requestMap
.
get
(
"SessionFrom"
);
String
floorname
=
getSessionFromValue
(
sessionFrom
,
1
);
// 楼盘名称
// 保存粉丝最后一次进入会话的时间
fans
.
setLastEnterTime
(
DateTime
.
now
().
toDate
());
fansDao
.
updateByPrimaryKey
(
fans
);
// for (int i = 1; i < 4; i++) {
// String welcome = getWelcome(1);
//
// sendResult = WxMiniUtil.sendCustomMsgText(fromUserName, welcome);
// saveChatLog(fans.getId(), "进入会话:" + floorname, welcome, fans.getGoodsId(),
// ChatLogReplyType.进入会话, "", "");
// }
List
<
Lotterylog
>
list
=
prizeService
.
getMyMnyLog
(
fans
.
getId
());
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
for
(
Lotterylog
l:
list
)
{
WxMiniUtil
.
sendCustomMsgLink
(
fans
.
getMiniopenid
(),
"请领取红包"
,
"年货会获得的红包,请尽快领取。过期无效。"
,
l
.
getPrizeUrl
(),
"http://mini.weiyisz.com/dvmini/res/images/redpackage.png"
);
System
.
out
.
println
(
"未兑换红包数 :"
+
list
.
size
());
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
for
(
Lotterylog
l
:
list
)
{
System
.
out
.
println
(
l
.
getPrizeUrl
());
WxMiniUtil
.
sendCustomMsgLink
(
fans
.
getMiniopenid
(),
"年货会红包"
,
"恭喜您在抽奖中获得红包,请点击领取"
,
l
.
getPrizeUrl
(),
"http://mini.weiyisz.com/dvmini/res/images/redpackage.png"
);
prizeService
.
updateLotteryLog
(
l
.
getId
(),
fans
.
getId
());
}
}
else
{
String
welcome
=
getWelcome
(
1
);
System
.
out
.
println
(
"welcome:"
+
welcome
);
WxMiniUtil
.
sendCustomMsgText
(
fromUserName
,
welcome
);
}
// 发送欢迎语
}
copyToWxkf
=
false
;
// 事件不要转发给客服系统。
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论