Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
Z
zion
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
zion
Commits
f843177d
提交
f843177d
authored
10月 28, 2019
作者:
zhengfg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改sql
上级
ea177a69
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
125 行增加
和
38 行删除
+125
-38
ZionApplication.java
src/main/java/com/diaoyun/zion/ZionApplication.java
+2
-4
ZaraSpider.java
...java/com/diaoyun/zion/chinafrica/bis/impl/ZaraSpider.java
+16
-1
TbCfCouponController.java
...oyun/zion/chinafrica/controller/TbCfCouponController.java
+6
-0
TbCfIssueCouponDao.java
...a/com/diaoyun/zion/chinafrica/dao/TbCfIssueCouponDao.java
+1
-0
TbCfCouponEntity.java
.../com/diaoyun/zion/chinafrica/entity/TbCfCouponEntity.java
+13
-0
TbCfIssueCouponEntityExtends.java
.../zion/chinafrica/entity/TbCfIssueCouponEntityExtends.java
+8
-0
TbCfIssueCouponService.java
...aoyun/zion/chinafrica/service/TbCfIssueCouponService.java
+1
-1
TbCfIssueCouponServiceImpl.java
...n/chinafrica/service/impl/TbCfIssueCouponServiceImpl.java
+7
-0
TbCfCouponDao.xml
src/main/resources/mapper/TbCfCouponDao.xml
+4
-4
TbCfIssueCouponDao.xml
src/main/resources/mapper/TbCfIssueCouponDao.xml
+51
-20
ZionApplicationTests.java
src/test/java/com/diaoyun/zion/ZionApplicationTests.java
+16
-8
没有找到文件。
src/main/java/com/diaoyun/zion/ZionApplication.java
浏览文件 @
f843177d
package
com
.
diaoyun
.
zion
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.cache.annotation.EnableCaching
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@SpringBootApplication
@EnableCaching
...
...
@@ -19,9 +19,7 @@ public class ZionApplication extends SpringBootServletInitializer {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ZionApplication
.
class
,
args
);
}
@Test
public
void
test
()
throws
Exception
{
}
}
src/main/java/com/diaoyun/zion/chinafrica/bis/impl/ZaraSpider.java
浏览文件 @
f843177d
...
...
@@ -7,6 +7,8 @@ import com.diaoyun.zion.master.util.HttpClientUtil;
import
com.diaoyun.zion.master.util.JsoupUtil
;
import
com.diaoyun.zion.master.util.SpiderUtil
;
import
com.diaoyun.zion.master.util.TranslateHelper
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
org.slf4j.Logger
;
...
...
@@ -36,7 +38,7 @@ public class ZaraSpider implements IItemSpider {
/**
* Massimo Dutti 数据爬虫
* @see com.diaoyun.zion.chinafrica.service.impl.SpiderServiceImpl#
judgeUrlType
修改商品详情页路径
* @see com.diaoyun.zion.chinafrica.service.impl.SpiderServiceImpl# 修改商品详情页路径
* @see JsoupUtil#getZaraJsonData 返回截取到的主要商品数据
* @see SpiderUtil#formatZaraProductResponse 格式化数据方法
* @param targetUrl 接收的商品详情路径
...
...
@@ -53,4 +55,17 @@ public class ZaraSpider implements IItemSpider {
return
resultObj
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
targetUrl
=
"https://www.nike.com/cn/t/air-max-90-betrue-%E7%94%B7%E5%AD%90%E8%BF%90%E5%8A%A8%E9%9E%8B-dgC1X4/CJ5482-100"
;
String
content
=
HttpClientUtil
.
getContentByUrl
(
targetUrl
,
PlatformEnum
.
NIKE
.
getValue
());
JSONObject
detail
=
JsoupUtil
.
getItemDetailByName
(
content
,
"window.INITIAL_REDUX_STATE"
);
System
.
err
.
println
(
detail
);
JSONObject
object
=
detail
.
getJSONObject
(
"Threads"
).
getJSONObject
(
"products"
).
getJSONObject
(
"CJ5482-100"
);
String
fullPrice
=
object
.
getString
(
"fullPrice"
);
String
currentPrice
=
object
.
getString
(
"currentPrice"
);
System
.
out
.
println
(
fullPrice
);
System
.
out
.
println
(
currentPrice
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/controller/TbCfCouponController.java
浏览文件 @
f843177d
...
...
@@ -9,6 +9,7 @@ import com.diaoyun.zion.chinafrica.service.TbCfIssueCouponService;
import
com.diaoyun.zion.chinafrica.vo.UserCouponVo
;
import
com.diaoyun.zion.master.base.Result
;
import
com.diaoyun.zion.master.common.RedisCache
;
import
com.diaoyun.zion.master.enums.ResultCodeEnum
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
...
...
@@ -57,5 +58,10 @@ public class TbCfCouponController {
public
Result
<
CouponItem
>
queryCouponByUserId
(
@ApiParam
(
"用户Id"
)
@PathVariable
(
"userId"
)
String
userId
)
{
return
tbCfIssueCouponService
.
queryCouponByUserId
(
userId
);
}
@ApiOperation
(
"更改优惠券状态"
)
@GetMapping
(
"/changCouponStatus/{userId}/{couponId}"
)
public
Result
changCouponStatus
(
@ApiParam
(
"用户Id"
)
@PathVariable
(
"userId"
)
String
userId
,
@ApiParam
(
"优惠券Id"
)
@PathVariable
(
"couponId"
)
String
couponId
){
return
tbCfIssueCouponService
.
changeCouponStatus
(
userId
,
couponId
);
}
}
src/main/java/com/diaoyun/zion/chinafrica/dao/TbCfIssueCouponDao.java
浏览文件 @
f843177d
...
...
@@ -15,4 +15,5 @@ import java.util.List;
public
interface
TbCfIssueCouponDao
extends
BaseDao
<
TbCfIssueCouponEntity
>
{
List
<
TbCfIssueCouponEntityExtends
>
queryCouponByUserId
(
String
userId
);
int
changeCouponStatus
(
String
userId
,
String
couponId
);
}
src/main/java/com/diaoyun/zion/chinafrica/entity/TbCfCouponEntity.java
浏览文件 @
f843177d
...
...
@@ -17,6 +17,11 @@ import java.util.Date;
@ApiModel
public
class
TbCfCouponEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 优惠券标题
*/
@ApiModelProperty
(
"优惠券标题"
)
private
String
userId
;
/**
* 优惠券id
...
...
@@ -410,4 +415,12 @@ public class TbCfCouponEntity implements Serializable {
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
}
src/main/java/com/diaoyun/zion/chinafrica/entity/TbCfIssueCouponEntityExtends.java
浏览文件 @
f843177d
...
...
@@ -11,7 +11,15 @@ public class TbCfIssueCouponEntityExtends extends TbCfIssueCouponEntity {
private
String
start
;
private
String
end
;
private
Integer
status
;
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
void
setStart
(
Date
start
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy/MM/dd"
);
...
...
src/main/java/com/diaoyun/zion/chinafrica/service/TbCfIssueCouponService.java
浏览文件 @
f843177d
...
...
@@ -76,6 +76,6 @@ public interface TbCfIssueCouponService {
int
deleteBatch
(
String
[]
couponIssuetableIds
);
Result
<
CouponItem
>
queryCouponByUserId
(
String
userId
);
Result
changeCouponStatus
(
String
userId
,
String
couponId
);
}
src/main/java/com/diaoyun/zion/chinafrica/service/impl/TbCfIssueCouponServiceImpl.java
浏览文件 @
f843177d
...
...
@@ -7,6 +7,7 @@ import com.diaoyun.zion.chinafrica.entity.TbCfIssueCouponEntity;
import
com.diaoyun.zion.chinafrica.entity.TbCfIssueCouponEntityExtends
;
import
com.diaoyun.zion.chinafrica.service.TbCfIssueCouponService
;
import
com.diaoyun.zion.master.base.Result
;
import
com.diaoyun.zion.master.enums.ResultCodeEnum
;
import
com.diaoyun.zion.master.util.IdUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -77,4 +78,10 @@ public class TbCfIssueCouponServiceImpl implements TbCfIssueCouponService {
couponItem
.
setCouponList
(
list
);
return
new
Result
<>(
couponItem
);
}
@Override
public
Result
changeCouponStatus
(
String
userId
,
String
couponId
)
{
int
i
=
tbCfIssueCouponDao
.
changeCouponStatus
(
userId
,
couponId
);
return
new
Result
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
}
}
src/main/resources/mapper/TbCfCouponDao.xml
浏览文件 @
f843177d
...
...
@@ -221,7 +221,7 @@
left join tb_cf_issue_coupon t3 on t3.coupon_id=t2.coupon_id
where ((t1.user_id=#{userId} and t1.enable_flag=1 )
or (t3.user_id=#{userId} and t3.enable_flag=1))
and t2.status=1 and (
<![CDATA[ t2.valid_start_time<=
#{nowTime}]]>
and
<![CDATA[t2.valid_end_time>=#{nowTime}
]]>
)
and t2.status=1 and (
<![CDATA[ t2.valid_start_time<=
now()]]>
and
<![CDATA[t2.valid_end_time>=now()
]]>
)
</select>
<!--更改优惠券统计-->
...
...
@@ -288,14 +288,14 @@
from tb_cf_coupon t2 left join tb_cf_coupon_category t4 ON t2.coupon_category_id= t4.coupon_category_id
left join tb_cf_take_coupon t1 on t1.coupon_id=t2.coupon_id
left join tb_cf_issue_coupon t3 on t3.coupon_id=t2.coupon_id
where ((t1.user_id=#{userId} and
<![CDATA[ t2.valid_end_time<
#{nowTime}
]]>
and t1.enable_flag=1)
or (t3.user_id=#{userId} and
<![CDATA[ t2.valid_end_time<
#{nowTime}
]]>
and t3.enable_flag=1))
where ((t1.user_id=#{userId} and
<![CDATA[ t2.valid_end_time<
now()
]]>
and t1.enable_flag=1)
or (t3.user_id=#{userId} and
<![CDATA[ t2.valid_end_time<
now()
]]>
and t3.enable_flag=1))
</select>
<!--根据优惠券种类获取发放中的优惠券-->
<select
id=
"getCouponByCategory"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity"
>
select * from tb_cf_coupon where coupon_category_id=#{couponCategoryId} and
<![CDATA[ start_time<=
#{nowTime}]]>
and
<![CDATA[end_time>=#{nowTime}
]]>
and status=1;
<![CDATA[ start_time<=
now()]]>
and
<![CDATA[end_time>=now()
]]>
and status=1;
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/TbCfIssueCouponDao.xml
浏览文件 @
f843177d
...
...
@@ -58,26 +58,51 @@
limit #{offset}, #{limit}
</if>
</select>
<!--查询用户有效的优惠券-->
<select
id=
"queryCouponByUserId"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfIssueCouponEntityExtends"
>
select
a.coupon_issuetable_id,
a.coupon_id,
b.coupon_category_id,
c.coupon_category_name,
b.coupon_title,
b.with_amount amount,
b.deduct_amount money,
b.valid_start_time start,
b.valid_end_time end,
a.user_id,
a.nick,
a.create_time,
a.enable_flag,
a.issue_id
from tb_cf_issue_coupon a LEFT join tb_cf_coupon b ON a.coupon_id=b.coupon_id
LEFT JOIN tb_cf_coupon_category c on b.coupon_category_id=c.coupon_category_id
WHERE a.user_id = #{user_id} and b.status=1
</select>
select
a.coupon_issuetable_id,
a.coupon_id,
b.coupon_category_id,
c.coupon_category_name,
b.coupon_title,
b.with_amount amount,
b.deduct_amount money,
b.valid_start_time start,
b.valid_end_time end,
a.enable_flag status,
a.user_id,
a.nick,
a.create_time,
a.enable_flag,
a.issue_id
from tb_cf_issue_coupon a LEFT join tb_cf_coupon b ON a.coupon_id=b.coupon_id
LEFT JOIN tb_cf_coupon_category c on b.coupon_category_id=c.coupon_category_id
WHERE a.user_id = #{user_id} and a.enable_flag=1 and b.status=1
</select>
<!--查询用户已使用的优惠券-->
<select
id=
"queryCouponByUserIdAndUsed"
resultType=
"com.diaoyun.zion.chinafrica.entity.TbCfIssueCouponEntityExtends"
>
select
a.coupon_issuetable_id,
a.coupon_id,
b.coupon_category_id,
c.coupon_category_name,
b.coupon_title,
b.with_amount amount,
b.deduct_amount money,
b.valid_start_time start,
b.valid_end_time end,
a.enable_flag status,
a.user_id,
a.nick,
a.create_time,
a.enable_flag,
a.issue_id
from tb_cf_issue_coupon a LEFT join tb_cf_coupon b ON a.coupon_id=b.coupon_id
LEFT JOIN tb_cf_coupon_category c on b.coupon_category_id=c.coupon_category_id
WHERE a.user_id = #{user_id} and a.enable_flag=0 or b.status=0
</select>
<select
id=
"queryTotal"
resultType=
"int"
>
select count(*) from tb_cf_issue_coupon
WHERE 1=1
...
...
@@ -117,7 +142,13 @@
</set>
where coupon_issuetable_id = #{couponIssuetableId}
</update>
<update
id=
"changeCouponStatus"
parameterType=
"com.diaoyun.zion.chinafrica.entity.TbCfIssueCouponEntity"
>
UPDATE tb_cf_issue_coupon
SET enable_flag = 0
WHERE
user_id = #{userId}
AND coupon_id = #{couponId}
</update>
<delete
id=
"delete"
>
delete from tb_cf_issue_coupon where coupon_issuetable_id = #{value}
</delete>
...
...
src/test/java/com/diaoyun/zion/ZionApplicationTests.java
浏览文件 @
f843177d
package
com
.
diaoyun
.
zion
;
import
com.diaoyun.zion.chinafrica.constant.KeyConstant
;
import
com.diaoyun.zion.chinafrica.enums.PlatformEnum
;
import
com.diaoyun.zion.chinafrica.service.SpiderService
;
import
com.diaoyun.zion.chinafrica.service.TbCfCouponService
;
import
com.diaoyun.zion.chinafrica.service.impl.TbCfOrderServiceImpl
;
import
com.diaoyun.zion.master.thread.TaskLimitSemaphore
;
import
com.diaoyun.zion.master.util.
*
;
import
com.
google.gson.Gson
;
import
com.diaoyun.zion.master.util.
AESUtils
;
import
com.
diaoyun.zion.master.util.IdUtil
;
import
com.stripe.exception.StripeException
;
import
freemarker.template.Configuration
;
import
org.apache.http.
*
;
import
org.apache.http.
NameValuePair
;
import
org.apache.http.client.CookieStore
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.junit.Test
;
...
...
@@ -20,15 +18,14 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.annotation.Resource
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.net.URISyntaxException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.
*
;
import
java.util.concurrent.
atomic.AtomicInteger
;
import
java.util.concurrent.
ExecutionException
;
import
java.util.concurrent.
TimeoutException
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
...
...
@@ -438,4 +435,15 @@ public class ZionApplicationTests {
String
a
=
AESUtils
.
encrypt
(
KeyConstant
.
AES_KEY
,
"sk_live_YbAVymUjl4ZEVGfzeyHyRTKM00JviD18nI"
);
System
.
out
.
println
(
a
);
}
@Test
public
void
test
(){
redisTemplate
.
opsForValue
().
set
(
"hello"
,
"helloworld"
);
Object
hello
=
redisTemplate
.
opsForValue
().
get
(
"hello"
);
System
.
out
.
println
(
hello
);
redisTemplate
.
delete
(
"hello"
);
System
.
out
.
println
(
"==============="
+
redisTemplate
.
opsForValue
().
get
(
"hello"
));
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论