Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit ef39e9b8
由
zxt@theyeasy.com
编写于
Jan 03, 2018
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改商品核销接口
1 个父辈
2e6cbf3d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
53 行增加
和
30 行删除
src/com/w1hd/zzhnc/controller/pc/UploadController.java
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
src/com/w1hd/zzhnc/service/GoodsService.java
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
src/com/w1hd/zzhnc/controller/pc/UploadController.java
查看文件 @
ef39e9b
...
...
@@ -243,7 +243,7 @@ public class UploadController extends BaseController {
FileCopyUtils
.
copy
(
mf
.
getBytes
(),
path
);
// 把图片复制到本地
}
returnPath
=
"http://
mini.weiyisz
.com/zzhnc/res/upload/"
+
imageType
+
"/"
+
newFileName
;
returnPath
=
"http://
dvmini.w1hd
.com/zzhnc/res/upload/"
+
imageType
+
"/"
+
newFileName
;
System
.
out
.
println
(
returnPath
);
/* } */
}
catch
(
Exception
e
)
{
...
...
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
ef39e9b
...
...
@@ -7,12 +7,14 @@ import java.net.URLEncoder;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -41,11 +43,14 @@ import com.w1hd.zzhnc.service.PrizeService;
import
com.w1hd.zzhnc.util.PageResults
;
import
com.w1hd.zzhnc.util.RedisUtil
;
import
com.w1hd.zzhnc.vo.Vo_msg
;
import
com.wordnik.swagger.annotations.ApiOperation
;
@Controller
@RequestMapping
(
"/wxmini"
)
public
class
WxMiniController
extends
BaseController
{
public
static
final
String
PRIZE_KEY_TIME
=
RedisUtil
.
PROJECTNAME
.
concat
(
"_"
).
concat
(
"PRIZE_KEY_TIME_"
);
@Autowired
FansService
fansService
;
@Autowired
...
...
@@ -100,19 +105,18 @@ public class WxMiniController extends BaseController {
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GET
)
// 购房助手登录 double lng,double lat
public
@ResponseBody
Vo_msg
login
(
@RequestParam
(
value
=
"code"
)
String
code
,
@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
)
{
@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
);
// 取openid
WxMiniSessionInfo
sessionInfo
=
WxMiniUtil
.
jscode2session
(
code
);
// 添加粉丝记录
Fans
fans
=
fansService
.
addFans
(
sessionInfo
,
shareId
,
nickname
,
logo
,
lng
,
lat
,
fansId
);
Fans
fans
=
fansService
.
addFans
(
sessionInfo
,
shareId
,
nickname
,
logo
,
lng
,
lat
,
fansId
);
if
(
fans
!=
null
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"miniOpenId"
,
sessionInfo
.
getOpenid
());
map
.
put
(
"fansId"
,
fans
.
getId
());
return
new
Vo_msg
(
0
,
map
);
}
else
{
return
new
Vo_msg
(-
1
,
"登录失败,服务器异常"
);
...
...
@@ -296,7 +300,7 @@ public class WxMiniController extends BaseController {
}
/** 查看我的奖品 */
@RequestMapping
(
value
=
"/prizes"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/prizes
/my
"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
prizes
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
...
...
@@ -318,7 +322,7 @@ public class WxMiniController extends BaseController {
@ResponseBody
public
Object
prizesKill
(
@RequestParam
(
value
=
"openId"
)
String
openId
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
Integer
logId
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
Integer
logId
=
prizeService
.
randomKill
(
fans
.
getId
(),
0
);
if
(
logId
==
0
)
{
return
new
Vo_msg
(-
1
,
null
,
"不好意思你没中奖"
);
}
...
...
@@ -338,10 +342,26 @@ public class WxMiniController extends BaseController {
return
prizeList
;
}
@Autowired
RedisTemplate
<
String
,
Long
>
redisTemplate
;
/** 核销奖品 */
@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
;
}
/** 核销奖品 */
@RequestMapping
(
value
=
"/prizes/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
prizes
(
@RequestParam
(
value
=
"openId"
)
String
openId
,
@PathVariable
(
value
=
"id"
)
Integer
id
)
{
public
Object
prizes
(
@RequestParam
(
value
=
"openId"
)
String
openId
,
@RequestParam
(
value
=
"timeMillis"
)
Long
timeMillis
,
@RequestParam
(
value
=
"localMillis"
)
Long
localMillis
,
@PathVariable
(
value
=
"id"
)
Integer
id
)
{
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
return
prizeService
.
updateLotteryLog
(
id
,
fans
.
getId
());
}
...
...
@@ -356,14 +376,16 @@ public class WxMiniController extends BaseController {
@RequestMapping
(
value
=
"/goods/share/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
goodsShare
(
@RequestParam
(
value
=
"openId"
)
String
openId
,
@PathVariable
(
value
=
"id"
)
Integer
id
)
{
PageResults
<
Goods
>
seacrh
=
goodsService
.
seacrh
(
id
,
null
,
null
,
null
,
null
);
Goods
goods
=
seacrh
.
getRows
().
get
(
0
);
goods
.
setShareCount
(
goods
.
getShareCount
()
+
1
);
goodsService
.
update
(
goods
);
if
(
id
>
0
)
{
PageResults
<
Goods
>
seacrh
=
goodsService
.
seacrh
(
id
,
null
,
null
,
null
,
null
);
Goods
goods
=
seacrh
.
getRows
().
get
(
0
);
goods
.
setShareCount
(
goods
.
getShareCount
()
+
1
);
goodsService
.
update
(
goods
);
}
Fans
fans
=
fansService
.
getFansByMiniOpenid
(
openId
);
fans
.
setShareCount
(
fans
.
getShareCount
()
+
1
);
fansService
.
updateFans
(
fans
);
return
new
Vo_msg
(
0
,
seacrh
);
return
new
Vo_msg
(
0
,
null
);
}
}
src/com/w1hd/zzhnc/service/GoodsService.java
查看文件 @
ef39e9b
...
...
@@ -62,7 +62,7 @@ public class GoodsService {
public
PageResults
<
Goods
>
seacrh
(
Integer
id
,
String
key
,
Integer
sellerId
,
Integer
page
,
Integer
size
)
{
Example
ex
=
new
Example
(
Goods
.
class
);
Criteria
c
=
ex
.
createCriteria
();
if
(
id
!=
null
&&
id
>
0
)
{
if
(
id
!=
null
&&
id
>
0
)
{
return
goods
(
id
);
}
else
{
if
(!
Strings
.
isNullOrEmpty
(
key
))
{
...
...
src/org/theyeasy/weixin/service/impl/WxMiniServiceImpl.java
查看文件 @
ef39e9b
...
...
@@ -184,30 +184,31 @@ public class WxMiniServiceImpl implements WxMiniService {
fansService
.
getCountParentFansId
(
fans
.
getId
());
int
fansCount
=
fansService
.
getCountParentFansId
(
fans
.
getId
());
if
(
fansCount
==
activitySetting
.
getShareCount
())
{
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
);
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
);
}
}
}
Vo_msg
msg
=
new
Vo_msg
(-
1
,
null
,
"未知错误."
);
int
mny
=
0
;
if
(
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
());
}
else
{
sussess
=
true
;
}
activityService
.
updateActivity
(
activitySetting
);
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
);
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论