Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
freemud.be.toolbox
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈宁
freemud.be.toolbox
Commits
140b96c9
Commit
140b96c9
authored
Aug 06, 2020
by
陈宁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# dev UserCoupons
parent
acf2c0d5
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
652 additions
and
38 deletions
+652
-38
Freemud.BE.Toolbox.Testing/JsonOpertionTest.cs
+19
-5
Freemud.BE.Toolbox.WebApi/Controllers/RequestResourceController.cs
+8
-0
Freemud.BE.Toolbox.WebApi/Infrastructure/Helpers/DatetimeHelper.cs
+19
-0
Freemud.BE.Toolbox.WebApi/Model/Request/GetUserCouponsRequest.cs
+1
-1
Freemud.BE.Toolbox.WebApi/Proxy/FmCouponProxy.cs
+1
-1
Freemud.BE.Toolbox.WebApi/Services/IRequestResourceService.cs
+2
-0
Freemud.BE.Toolbox.WebApi/Services/Impl/RequestResourceService.cs
+66
-11
freemud.be.toolboxview/src/router/index.js
+0
-2
freemud.be.toolboxview/src/views/requestresource/CanDaoStoreSearch.vue
+2
-2
freemud.be.toolboxview/src/views/requestresource/CouponProductSearch.vue
+2
-8
freemud.be.toolboxview/src/views/requestresource/ProductExtensionSearch.vue
+0
-5
freemud.be.toolboxview/src/views/requestresource/ProductSearch.vue
+2
-2
freemud.be.toolboxview/src/views/requestresource/UserCoupons.vue
+530
-1
No files found.
Freemud.BE.Toolbox.Testing/JsonOpertionTest.cs
View file @
140b96c9
...
...
@@ -15,22 +15,36 @@ namespace Freemud.BE.Toolbox.Testing
[
TestMethod
]
public
void
MyTestMethod
()
{
var
json
=
"{\"statusCode\":100,\"couponlist\":[{\"code\":\"
385438604009450\",\"couponType\":0,\"codeInfo\":{\"act_id\":\"P120520200522102932\",\"code\":\"385438604009450\",\"ebcode\":\"0000000559\",\"vdata\":\"2020-06-30\",\"act_name\":\"麦乐鸡买一送一[剩1]\",\"act_desc\":\"\",\"ebname\":\"趋佳\",\"products\":[{\"pid\":\"900250\",\"number\":1,\"payment\":{\"paid\":0,\"remaining\":1150},\"price_act\":1150,\"price_original\":2300,\"name\":\"麦乐鸡买一送一\",\"mcd_productCode\":\"123470777\"}],\"availableTimes\":1},\"statusCode\":100},{\"code\":\"385438604009450aq\",\"couponType\":0
,\"msg\":\"码不存在\",\"statusCode\":11}]}"
;
var
json
=
"{\"statusCode\":100,\"couponlist\":[{\"code\":\"
946263595558700\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"908146008329394\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"937760374178244\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"977349403192840\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"997550944669829\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"998106443575095\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"958144187358792\",\"couponType\":0,\"codeInfo\":{},\"msg\":\"码不存在\",\"statusCode\":11},{\"code\":\"978271103217015\",\"couponType\":0,\"codeInfo\":{}
,\"msg\":\"码不存在\",\"statusCode\":11}]}"
;
Console
.
WriteLine
(
json
);
var
jo
=
JObject
.
Parse
(
json
);
var
coupons
=
JArray
.
Parse
(
jo
[
"couponlist"
].
ToString
());
var
pids
=
new
List
<
string
>();
foreach
(
var
c
in
coupons
)
{
if
(
c
[
"codeInfo"
]
!=
null
)
{
pids
.
Add
(
c
[
"codeInfo"
][
"products"
][
0
][
"mcd_productCode"
].
ToString
());
}
Console
.
WriteLine
(
c
[
"codeInfo"
]);
Console
.
WriteLine
(
c
[
"codeInfo"
].
ToString
().
Equals
(
"{}"
));
//if (c["codeInfo"] != null)
//{
// pids.Add(c["codeInfo"]["products"][0]["mcd_productCode"].ToString());
//}
}
Console
.
WriteLine
(
JsonConvert
.
SerializeObject
(
pids
));
}
[
TestMethod
]
public
void
askldjaslkdj
()
{
var
url
=
"https://open.miniapp.mcdonalds.com.cn/wechat/card/show_user_wallet?unionid=A&tag=B"
;
Console
.
WriteLine
(
url
);
Console
.
WriteLine
(
new
Uri
(
url
).
AbsolutePath
);
Console
.
WriteLine
(
new
Uri
(
url
).
LocalPath
);
Console
.
WriteLine
(
new
Uri
(
url
).
PathAndQuery
);
}
}
}
Freemud.BE.Toolbox.WebApi/Controllers/RequestResourceController.cs
View file @
140b96c9
...
...
@@ -17,12 +17,20 @@ namespace Freemud.BE.Toolbox.WebApi.Controllers
this
.
requestResourceService
=
requestResourceService
;
}
[
HttpPost
(
"get-coupon"
)]
public
async
Task
<
IActionResult
>
GetCouponInfo
([
FromBody
]
GetCouponInfoRequest
request
)
{
return
Ok
(
data
:
await
requestResourceService
.
GetCouponInfo
(
request
));
}
[
HttpPost
(
"get-user-coupon"
)]
public
async
Task
<
IActionResult
>
GetUserCouponInfo
([
FromBody
]
GetUserCouponsRequest
request
)
{
return
Ok
(
data
:
await
requestResourceService
.
GetUserCoupons
(
request
));
}
[
HttpPost
(
"get-product"
)]
public
async
Task
<
IActionResult
>
GetProductInfo
([
FromBody
]
GetProductInfoRequest
request
)
{
...
...
Freemud.BE.Toolbox.WebApi/Infrastructure/Helpers/DatetimeHelper.cs
0 → 100644
View file @
140b96c9
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Freemud.BE.Toolbox.WebApi.Infrastructure.Helpers
{
public
static
class
DatetimeHelper
{
/// <summary>
/// Unix时间戳-->DateTime
/// </summary>
/// <param name="timestamp">Unix时间戳</param>
public
static
DateTime
ToDateTimeAtSeconds
(
long
timestamp
)
{
return
TimeZone
.
CurrentTimeZone
.
ToLocalTime
(
new
DateTime
(
1970
,
1
,
1
)).
AddSeconds
(
timestamp
);
}
}
}
Freemud.BE.Toolbox.WebApi/Model/Request/GetUserCouponsRequest.cs
View file @
140b96c9
...
...
@@ -8,7 +8,7 @@ namespace Freemud.BE.Toolbox.WebApi.Model.Request
public
class
GetUserCouponsRequest
:
BaseRequestResourceRequest
{
/// <summary>
/// 手机号 / MemberId
/ UnionId
/// 手机号 / MemberId
/// </summary>
public
string
Terms
{
get
;
set
;
}
...
...
Freemud.BE.Toolbox.WebApi/Proxy/FmCouponProxy.cs
View file @
140b96c9
...
...
@@ -89,7 +89,7 @@ namespace Freemud.BE.Toolbox.WebApi.Proxy
public
async
Task
<
RequestResourceResponse
>
GetArchCardCoupons
(
string
env
,
string
channel
,
string
memberId
)
{
var
url
=
string
.
Format
(
GetUrl
(
env
,
"Archcard"
,
"getArchCardList"
),
memberId
,
channel
);
var
headers
=
GetArchCardRequestHeader
(
url
);
var
headers
=
GetArchCardRequestHeader
(
new
Uri
(
url
).
PathAndQuery
);
var
response
=
await
HttpHeper
.
Get
(
url
,
headers
);
return
new
RequestResourceResponse
...
...
Freemud.BE.Toolbox.WebApi/Services/IRequestResourceService.cs
View file @
140b96c9
...
...
@@ -11,6 +11,8 @@ namespace Freemud.BE.Toolbox.WebApi.Services
{
Task
<
List
<
RequestResourceResponse
>>
GetCouponInfo
(
GetCouponInfoRequest
request
);
Task
<
List
<
RequestResourceResponse
>>
GetUserCoupons
(
GetUserCouponsRequest
request
);
Task
<
List
<
RequestResourceResponse
>>
GetProductInfo
(
GetProductInfoRequest
request
);
Task
<
List
<
RequestResourceResponse
>>
GetStoreInfo
(
GetStoreInfoRequest
request
);
...
...
Freemud.BE.Toolbox.WebApi/Services/Impl/RequestResourceService.cs
View file @
140b96c9
...
...
@@ -55,8 +55,13 @@ namespace Freemud.BE.Toolbox.WebApi.Services
// 查询券码对应商品信息
var
jo
=
JObject
.
Parse
(
coupons
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"couponlist"
))
{
var
jCoupons
=
JArray
.
Parse
(
jo
[
"couponlist"
].
ToString
());
var
jCouponsPids
=
jCoupons
.
Where
(
d
=>
d
[
"codeInfo"
]
!=
null
).
Select
(
d
=>
d
[
"codeInfo"
][
"products"
][
0
][
"mcd_productCode"
].
ToString
()).
ToList
();
var
jCouponsPids
=
jCoupons
.
Where
(
d
=>
d
[
"codeInfo"
]
!=
null
&&
d
[
"codeInfo"
].
ToString
()
!=
"{}"
).
Select
(
d
=>
d
[
"codeInfo"
][
"products"
][
0
][
"mcd_productCode"
].
ToString
()).
ToList
();
if
(
jCouponsPids
?.
Any
()
??
false
)
{
var
getProductInfoRequest
=
new
GetProductInfoRequest
{
Env
=
request
.
Env
,
...
...
@@ -69,6 +74,16 @@ namespace Freemud.BE.Toolbox.WebApi.Services
var
couponProducts
=
await
fmProductProxy
.
GetProductBaseInfos
(
getProductInfoRequest
);
return
new
List
<
RequestResourceResponse
>
{
coupons
,
couponProducts
};
}
else
{
return
new
List
<
RequestResourceResponse
>
{
coupons
,
new
RequestResourceResponse
{
Name
=
"获取商品信息"
,
ResponseError
=
"无需商品需要查询"
}
};
}
}
else
{
return
new
List
<
RequestResourceResponse
>
{
coupons
,
new
RequestResourceResponse
{
Name
=
"获取商品信息"
,
ResponseError
=
"无需商品需要查询"
}
};
}
}
#
endregion
...
...
@@ -113,26 +128,30 @@ namespace Freemud.BE.Toolbox.WebApi.Services
else
{
var
userIdentityInfo
=
await
userRepository
.
GetUserIdentityInfo
(
request
.
Env
,
request
.
Terms
);
logger
.
LogInformation
(
$"[GetUserCoupons] userIdentityInfo:
{
JsonConvert
.
SerializeObject
(
userIdentityInfo
)}
"
);
if
(
userIdentityInfo
==
null
)
{
result
.
Add
(
new
RequestResourceResponse
{
Name
=
"查询用户信息失败"
,
ResponseError
=
"查询用户信息失败"
});
}
else
{
logger
.
LogInformation
(
$"[GetUserCoupons] userIdentityInfo:
{
JsonConvert
.
SerializeObject
(
userIdentityInfo
)}
"
);
var
archCardsResponse
=
await
fmCouponProxy
.
GetArchCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
MemberId
);
var
wechatCardsResponse
=
await
fmCouponProxy
.
GetWechatCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
UnionId
);
var
vendorCardsResponse
=
await
fmCouponProxy
.
GetVendorCardCoupons
(
request
.
Env
,
request
.
Channel
,
userIdentityInfo
.
UnionId
);
var
userCards
=
new
List
<
UserCardAdapter
>();
logger
.
LogInformation
(
$"[GetUserCoupons] archCardsResponse:
{
JsonConvert
.
SerializeObject
(
archCardsResponse
)}
"
);
logger
.
LogInformation
(
$"[GetUserCoupons] wechatCardsResponse:
{
JsonConvert
.
SerializeObject
(
wechatCardsResponse
)}
"
);
logger
.
LogInformation
(
$"[GetUserCoupons] vendorCardsResponse:
{
JsonConvert
.
SerializeObject
(
vendorCardsResponse
)}
"
);
#
region
解析麦钱包券
{
var
jo
=
JObject
.
Parse
(
archCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
...
...
@@ -156,7 +175,6 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
解析微信券
{
var
jo
=
JObject
.
Parse
(
wechatCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
...
...
@@ -180,7 +198,6 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
解析商家券
{
var
jo
=
JObject
.
Parse
(
vendorCardsResponse
.
ResponseContent
);
if
(
jo
.
ContainsKey
(
"data"
))
{
...
...
@@ -193,8 +210,8 @@ namespace Freemud.BE.Toolbox.WebApi.Services
CardId
=
c
[
"card_id"
].
ToString
(),
Code
=
c
[
"code"
].
ToString
(),
CardType
=
EnumCardType
.
VendorCard
,
StartDate
=
$"
{
Date
Time
.
Parse
(
c
[
"begin_time"
].
ToString
(
)):
yyyy
/
MM
/
dd
}
"
,
EndDate
=
$"
{
Date
Time
.
Parse
(
c
[
"end_time"
].
ToString
(
)):
yyyy
/
MM
/
dd
}
"
,
StartDate
=
$"
{
Date
timeHelper
.
ToDateTimeAtSeconds
(
long
.
Parse
(
c
[
"begin_time"
].
ToString
()
)):
yyyy
/
MM
/
dd
}
"
,
EndDate
=
$"
{
Date
timeHelper
.
ToDateTimeAtSeconds
(
long
.
Parse
(
c
[
"end_time"
].
ToString
()
)):
yyyy
/
MM
/
dd
}
"
,
//AvailableTimeDesc = c.GetAvailableTimeDesc()
}));
}
...
...
@@ -209,17 +226,45 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
获取券码及对应商品信息
if
(
userCards
.
Any
())
{
// 微信测试券与正是券, 皆为正式环境的券码 & 商品服务
var
wechatCouponCodes
=
userCards
.
Where
(
d
=>
d
.
CardType
.
Equals
(
EnumCardType
.
WeChat
)).
Select
(
d
=>
d
.
Code
).
ToList
();
if
(
wechatCouponCodes
?.
Any
()
??
false
)
{
var
getWechatCouponInfoRequest
=
new
GetCouponInfoRequest
{
Channel
=
request
.
Channel
,
Env
=
ToolboxConstants
.
ENV_PROD
,
StoreId
=
request
.
StoreId
,
Time
=
request
.
Time
,
CouponCode
=
string
.
Join
(
','
,
wechatCouponCodes
)
};
var
couponResponses
=
await
GetCouponInfo
(
getWechatCouponInfoRequest
);
couponResponses
[
0
].
Name
=
"获取券码信息 - 微信券"
;
couponResponses
[
1
].
Name
=
"获取商品信息 - 微信券"
;
result
.
AddRange
(
couponResponses
);
}
// 麦钱包 & 商家券信息获取
var
couponCodes
=
userCards
.
Where
(
d
=>
!
d
.
CardType
.
Equals
(
EnumCardType
.
WeChat
)).
Select
(
d
=>
d
.
Code
).
ToList
();
if
(
couponCodes
?.
Any
()
??
false
)
{
var
getCouponInfoRequest
=
new
GetCouponInfoRequest
{
Channel
=
request
.
Channel
,
Env
=
request
.
Env
,
StoreId
=
request
.
StoreId
,
Time
=
request
.
Time
,
CouponCode
=
string
.
Join
(
','
,
userCards
.
Select
(
d
=>
d
.
Code
).
ToList
()
)
CouponCode
=
string
.
Join
(
','
,
couponCodes
)
};
var
couponInfoResponse
=
await
GetCouponInfo
(
getCouponInfoRequest
);
result
.
AddRange
(
couponInfoResponse
);
var
couponResponses
=
await
GetCouponInfo
(
getCouponInfoRequest
);
couponResponses
[
0
].
Name
=
"获取券码信息 - 麦钱包券&商家券"
;
couponResponses
[
1
].
Name
=
"获取商品信息 - 麦钱包券&商家券"
;
result
.
AddRange
(
couponResponses
);
}
}
#
endregion
}
...
...
@@ -276,6 +321,11 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
商品
/// <summary>
/// 商品信息查询
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
async
Task
<
List
<
RequestResourceResponse
>>
GetProductInfo
(
GetProductInfoRequest
request
)
{
var
products
=
await
fmProductProxy
.
GetProductBaseInfos
(
request
);
...
...
@@ -288,6 +338,11 @@ namespace Freemud.BE.Toolbox.WebApi.Services
#
region
门店
/// <summary>
/// 门店信息查询
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public
async
Task
<
List
<
RequestResourceResponse
>>
GetStoreInfo
(
GetStoreInfoRequest
request
)
{
var
result
=
new
List
<
RequestResourceResponse
>();
...
...
freemud.be.toolboxview/src/router/index.js
View file @
140b96c9
...
...
@@ -10,7 +10,6 @@ import CanDaoStoreSearch from '../views/requestresource/CanDaoStoreSearch.vue'
import
CouponFreeze
from
'../views/requestresource/CouponFreeze.vue'
import
CouponProductSearch
from
'../views/requestresource/CouponProductSearch.vue'
import
OrderSearch
from
'../views/requestresource/OrderSearch.vue'
import
ProductExtensionSearch
from
'../views/requestresource/ProductExtensionSearch.vue'
import
ProductSearch
from
'../views/requestresource/ProductSearch.vue'
import
UserCoupons
from
'../views/requestresource/UserCoupons.vue'
...
...
@@ -35,7 +34,6 @@ const routes = [
{
path
:
'coupon-freeze'
,
component
:
CouponFreeze
},
{
path
:
'coupon-product'
,
component
:
CouponProductSearch
},
{
path
:
'order'
,
component
:
OrderSearch
},
{
path
:
'product-exentsion'
,
component
:
ProductExtensionSearch
},
{
path
:
'product'
,
component
:
ProductSearch
},
{
path
:
'user-coupons'
,
component
:
UserCoupons
}
]
...
...
freemud.be.toolboxview/src/views/requestresource/CanDaoStoreSearch.vue
View file @
140b96c9
...
...
@@ -30,7 +30,7 @@
<AutoComplete
v-model=
"terms"
:data=
"[1450026, 1450217, 99998, 99995, 99992]"
placeholder=
"门店号(eg. 1450026) / 经纬度(eg. 113.937133
7890625,22.575050354003906
)"
placeholder=
"门店号(eg. 1450026) / 经纬度(eg. 113.937133
,22.575050
)"
clearable
></AutoComplete>
</FormItem>
...
...
@@ -200,7 +200,7 @@ export default {
channel
:
'delivery'
,
env
:
'dev'
,
time
:
new
Date
(),
terms
:
'
113.9371337890625,22.575050354003906
'
,
terms
:
''
,
metaData
:
[],
vData
:
[],
retCandaos
:
[],
...
...
freemud.be.toolboxview/src/views/requestresource/CouponProductSearch.vue
View file @
140b96c9
...
...
@@ -169,12 +169,10 @@ export default {
channel
:
'delivery'
,
env
:
'prod'
,
time
:
''
,
couponCode
:
'
385438604009450,527577357365398,QQQ
'
,
storeId
:
'
99998
'
,
couponCode
:
''
,
storeId
:
''
,
metaData
:
[],
vData
:
[],
retCoupons
:
[],
retProducts
:
[],
cmOptions
:
{
lineNumbers
:
true
,
readOnly
:
true
,
...
...
@@ -244,8 +242,6 @@ export default {
}
})
this
.
retCoupons
=
coupons
const
products
=
[]
const
responseProducts
=
JSON
.
parse
(
data
[
1
].
responseContent
)
responseProducts
.
data
.
products
.
forEach
(
p
=>
{
...
...
@@ -269,8 +265,6 @@ export default {
products
.
push
({
id
:
p
.
pid
,
name
:
p
.
name
,
data
:
data
})
})
this
.
retProducts
=
products
// 组装数据
const
vdata
=
[]
coupons
.
forEach
(
coup
=>
{
...
...
freemud.be.toolboxview/src/views/requestresource/ProductExtensionSearch.vue
deleted
100644 → 0
View file @
acf2c0d5
<
template
>
<div>
<h1>
product-extension-search
</h1>
</div>
</
template
>
freemud.be.toolboxview/src/views/requestresource/ProductSearch.vue
View file @
140b96c9
...
...
@@ -292,8 +292,8 @@ export default {
channel
:
'delivery'
,
env
:
'dev'
,
time
:
''
,
productId
:
'
123473149,123470098,123472924,123471941,123472439,123470930,123
'
,
storeId
:
'
1450217
'
,
productId
:
''
,
storeId
:
''
,
metaData
:
[],
vData
:
[],
cmOptions
:
{
...
...
freemud.be.toolboxview/src/views/requestresource/UserCoupons.vue
View file @
140b96c9
<
template
>
<div
class=
"rr-user-coupons"
>
<Form
:label-width=
"80"
>
<Row>
<Col
span=
"12"
>
<FormItem
label=
"渠道"
>
<RadioGroup
type=
"button"
v-model=
"channel"
>
<Radio
label=
"delivery"
>
<Icon
type=
"md-bicycle"
/>
麦乐送
</Radio>
<Radio
label=
"mcoffee"
>
<Icon
type=
"md-cafe"
/>
麦咖啡
</Radio>
<Radio
label=
"kiosk"
>
<Icon
type=
"md-ice-cream"
/>
甜品站
</Radio>
</RadioGroup>
</FormItem>
</Col>
<Col
span=
"12"
>
<FormItem
label=
"环境"
>
<RadioGroup
type=
"button"
v-model=
"env"
>
<Radio
label=
"dev"
>
开发环境
</Radio>
<Radio
label=
"prod"
>
生产环境
</Radio>
</RadioGroup>
</FormItem>
</Col>
<Col
span=
"12"
>
<FormItem
label=
"门店号"
>
<AutoComplete
v-model=
"storeId"
:data=
"[1450026, 1450217, 99998, 99995, 99992]"
placeholder=
"门店编号"
clearable
></AutoComplete>
</FormItem>
</Col>
<Col
span=
"12"
>
<FormItem
label=
"用户"
>
<Input
type=
"text"
v-model=
"userTerms"
placeholder=
"手机号 / MemberId"
clearable
></Input>
</FormItem>
</Col>
<Col
span=
"12"
>
<FormItem
label=
"时间"
>
<TimePicker
v-model=
"time"
format=
"HH:mm:ss"
placeholder=
"时间"
style=
"width: 168px"
></TimePicker>
</FormItem>
</Col>
<Col
span=
"12"
>
<FormItem>
<Button
type=
"primary"
icon=
"ios-search"
:loading=
"loadingSearch"
@
click=
"search()"
>
<span
v-if=
"!loadingSearch"
>
查 询
</span>
<span
v-else
>
查询中
</span>
</Button>
</FormItem>
</Col>
</Row>
</Form>
<div
class=
"resource-result"
>
<Tabs
:animated=
"false"
>
<TabPane
label=
"结果"
icon=
"md-list-box"
>
<Row
class=
"coupon-line"
:gutter=
"16"
></Row>
<Collapse
simple
v-if=
"!vError"
>
<Panel
v-for=
"item in vData"
:key=
"item.type"
:class=
"['card-panel-'+item.type]"
>
{{
item
.
name
}}
(
{{
item
.
data
.
length
}}
张)
<div
slot=
"content"
>
<div
v-if=
"item.data.length"
>
<Row
v-for=
"data in item.data"
:key=
"data.card.code"
class=
"coupon-line"
:gutter=
"16"
>
<Col
span=
"8"
>
<Card
dis-hover
>
<p
slot=
"title"
>
<a
href=
"javascript:;"
slot=
"title"
>
卡
<Icon
type=
"md-return-right"
/>
</a>
<span>
{{
data
.
card
.
code
}}
</span>
</p>
<Table
border
size=
"small"
:columns=
"colCoupons"
:data=
"data.card.data"
:show-header=
"false"
>
<template
slot-scope=
"
{ row }" slot="name">
<div
class=
"xxx"
>
<strong>
{{
row
.
name
}}
</strong>
<Tag
color=
"geekblue"
>
{{
row
.
field
}}
</Tag>
</div>
</
template
>
<
template
slot-scope=
"{ row }"
slot=
"val"
>
<span>
{{
row
.
val
}}
</span>
</
template
>
</Table>
</Card>
</Col>
<Col
span=
"8"
>
<Card
dis-hover
v-if=
"data.coupon"
>
<p
slot=
"title"
>
<a
href=
"javascript:;"
slot=
"title"
>
券
<Icon
type=
"md-return-right"
/>
</a>
<span>
{{data.coupon.couponName}}
</span>
</p>
<Table
v-if=
"data.coupon.ret"
border
size=
"small"
:columns=
"colCoupons"
:data=
"data.coupon.data"
:show-header=
"false"
>
<
template
slot-scope=
"{ row }"
slot=
"name"
>
<div
class=
"xxx"
>
<strong>
{{
row
.
name
}}
</strong>
<Tag
color=
"geekblue"
>
{{
row
.
field
}}
</Tag>
</div>
</
template
>
<
template
slot-scope=
"{ row }"
slot=
"val"
>
<div>
<h1>
user-coupons
</h1>
{{
row
.
val
}}
<Tooltip
v-if=
"row.descriptor"
max-width=
"200"
placement=
"right"
transfer
>
<span
style=
"color:#ed4014"
>
(
{{
row
.
descriptor
.
memo
}}
)
</span>
<Icon
type=
"md-information-circle"
/>
<div
slot=
"content"
>
{{
row
.
descriptor
.
desc
}}
</div>
</Tooltip>
</div>
</
template
>
</Table>
<Alert
banner
type=
"warning"
v-else
>
{{ data.coupon.data }}
</Alert>
</Card>
<Alert
banner
type=
"warning"
v-else
>
无数据
</Alert>
</Col>
<Col
span=
"8"
>
<div
v-if=
"data.product"
>
<Card
dis-hover
>
<p
slot=
"title"
>
<a
href=
"javascript:;"
slot=
"title"
>
商品
<Icon
type=
"md-return-right"
/>
</a>
<span>
{{data.product.name}}({{data.product.id}})
</span>
</p>
<Table
border
size=
"small"
:columns=
"colCoupons"
:data=
"data.product.data"
:show-header=
"false"
>
<
template
slot-scope=
"{ row }"
slot=
"name"
>
<div
class=
"xxx"
>
<strong>
{{
row
.
name
}}
</strong>
<Tag
color=
"geekblue"
>
{{
row
.
field
}}
</Tag>
</div>
</
template
>
<
template
slot-scope=
"{ row }"
slot=
"val"
>
<div>
{{
row
.
val
}}
<Tooltip
v-if=
"row.descriptor"
max-width=
"200"
placement=
"right"
transfer
>
<span
style=
"color:#ed4014"
>
(
{{
row
.
descriptor
.
memo
}}
)
</span>
<Icon
type=
"md-information-circle"
/>
<div
slot=
"content"
>
{{
row
.
descriptor
.
desc
}}
</div>
</Tooltip>
</div>
</
template
>
</Table>
</Card>
</div>
<Alert
banner
type=
"warning"
v-else
>
无数据
</Alert>
</Col>
</Row>
</div>
<Alert
banner
type=
"warning"
v-else
>
无数据
</Alert>
</div>
</Panel>
</Collapse>
<div
v-else
>
<Alert
banner
type=
"warning"
>
<p>
* {{this.vError}}
</p>
<p>
1)手机号不对或用户还未注册过麦当劳小程序
</p>
</Alert>
</div>
</TabPane>
<TabPane
label=
"元信息"
icon=
"md-code"
>
<div
class=
"resource-result-metadata-panel"
>
<Alert
type=
"warning"
show-icon
>
<Icon
type=
"ios-bulb-outline"
slot=
"icon"
></Icon>
<b>
1) 微信测试券
&
正式券, 皆连接正式环境券码
&
商品服务
</b>
</Alert>
<div
v-for=
"item in metaData"
:key=
"item.name"
class=
"resource-result-metadata-item"
>
<span
class=
"resource-result-metadata-item-title"
>
{{item.name}}
</span>
<codemirror
:value=
"buildMetaData(item)"
:options=
"cmOptions"
></codemirror>
</div>
</div>
</TabPane>
</Tabs>
</div>
</div>
</template>
<
script
>
// require component And styles And Themes
import
{
codemirror
}
from
'vue-codemirror'
import
'codemirror/mode/javascript/javascript.js'
import
'codemirror/lib/codemirror.css'
import
'codemirror/theme/the-matrix.css'
export
default
{
components
:
{
codemirror
},
data
()
{
return
{
loadingSearch
:
false
,
channel
:
'delivery'
,
env
:
'dev'
,
time
:
''
,
userTerms
:
''
,
storeId
:
''
,
metaData
:
[],
vData
:
[],
vError
:
''
,
cmOptions
:
{
lineNumbers
:
true
,
readOnly
:
true
,
tabSize
:
2
,
model
:
'text/javascript'
,
theme
:
'the-matrix'
},
colCoupons
:
[{
slot
:
'name'
},
{
slot
:
'val'
}]
}
},
created
()
{
this
.
time
=
this
.
_moment
().
format
(
'HH:mm:ss'
)
},
methods
:
{
async
search
()
{
if
(
!
this
.
storeId
)
{
this
.
$Message
.
warning
(
'请输入门店号'
)
return
}
if
(
!
this
.
userTerms
)
{
this
.
$Message
.
warning
(
'请输入用户信息'
)
return
}
this
.
loadingSearch
=
true
const
params
=
{
env
:
this
.
env
,
channel
:
this
.
channel
,
terms
:
this
.
userTerms
,
storeId
:
this
.
storeId
,
time
:
this
.
time
}
const
{
data
:
response
}
=
await
this
.
$http
.
post
(
'/requestresource/get-user-coupon'
,
params
)
if
(
response
.
code
!==
200
)
{
this
.
$Message
.
error
(
response
.
message
)
}
else
{
if
(
response
.
data
.
length
===
1
)
{
this
.
vError
=
response
.
data
[
0
].
responseError
}
else
{
this
.
metaData
=
response
.
data
this
.
bindData
(
response
.
data
)
}
}
this
.
loadingSearch
=
false
},
buildMetaData
(
data
)
{
return
'================ URL ================
\
r
\
n'
+
data
.
url
+
'
\
n
\
n'
+
'================ HEADERS ============
\
r
\
n'
+
JSON
.
stringify
(
data
.
requestHeaders
,
null
,
'
\
t'
)
+
'
\
r
\
n'
+
'================ DATA ===============
\
r
\
n'
+
JSON
.
stringify
(
data
.
requestBody
,
null
,
'
\
t'
)
+
'
\
r
\
n'
+
'================ RESPONSE ===============
\
r
\
n'
+
JSON
.
stringify
(
JSON
.
parse
(
data
.
responseContent
),
null
,
'
\
t'
)
},
bindData
(
data
)
{
// 麦钱包券
const
archCards
=
[]
const
responseArchCards
=
JSON
.
parse
(
data
[
0
].
responseContent
)
responseArchCards
.
data
.
card_list
.
forEach
(
c
=>
{
const
data
=
[
{
name
:
'卡号'
,
field
:
'cardId'
,
val
:
c
.
card_id
},
{
name
:
'券号'
,
field
:
'code'
,
val
:
c
.
card_code
},
{
name
:
'开始时间'
,
field
:
'couponType'
,
val
:
c
.
begin_date
},
{
name
:
'结束时间'
,
field
:
'vdata'
,
val
:
c
.
end_date
}
]
archCards
.
push
({
type
:
20
,
cardId
:
c
.
card_id
,
code
:
c
.
card_code
,
data
})
})
// 微信券
const
wechatCards
=
[]
const
responseWechatCards
=
JSON
.
parse
(
data
[
1
].
responseContent
)
responseWechatCards
.
data
.
card_list
.
forEach
(
c
=>
{
const
data
=
[
{
name
:
'卡号'
,
field
:
'cardId'
,
val
:
c
.
card_id
},
{
name
:
'券号'
,
field
:
'code'
,
val
:
c
.
code
},
{
name
:
'开始时间'
,
field
:
'couponType'
,
val
:
c
.
begin_time
},
{
name
:
'结束时间'
,
field
:
'vdata'
,
val
:
c
.
end_time
}
]
wechatCards
.
push
({
type
:
10
,
cardId
:
c
.
card_id
,
code
:
c
.
code
,
data
})
})
// 商家券
const
vendorCards
=
[]
const
responseVendorCards
=
JSON
.
parse
(
data
[
2
].
responseContent
)
responseVendorCards
.
data
.
card_list
.
forEach
(
c
=>
{
const
data
=
[
{
name
:
'卡号'
,
field
:
'cardId'
,
val
:
c
.
card_id
},
{
name
:
'券号'
,
field
:
'code'
,
val
:
c
.
code
},
{
name
:
'开始时间'
,
field
:
'couponType'
,
val
:
c
.
begin_time
},
{
name
:
'结束时间'
,
field
:
'vdata'
,
val
:
c
.
end_time
}
]
vendorCards
.
push
({
type
:
30
,
cardId
:
c
.
card_id
,
code
:
c
.
code
,
data
})
})
// 非码券码
const
c1
=
this
.
parseCoupons
(
data
[
3
].
responseContent
)
const
c2
=
this
.
parseCoupons
(
data
[
5
]
?
data
[
5
].
responseContent
:
''
)
const
coupons
=
c1
.
concat
(
c2
)
// 商品信息
const
p1
=
this
.
parseProducts
(
data
[
4
].
responseContent
)
const
p2
=
this
.
parseProducts
(
data
[
6
]
?
data
[
6
].
responseContent
:
''
)
const
products
=
p1
.
concat
(
p2
)
// 组装数据
const
vdata
=
[]
vdata
.
push
(
this
.
setVData
(
10
,
'微信券'
,
wechatCards
,
coupons
,
products
))
vdata
.
push
(
this
.
setVData
(
20
,
'麦钱包券'
,
archCards
,
coupons
,
products
))
vdata
.
push
(
this
.
setVData
(
30
,
'商家券'
,
vendorCards
,
coupons
,
products
))
this
.
vData
=
vdata
console
.
info
(
this
.
vData
)
},
setVData
(
type
,
name
,
cards
,
coupons
,
products
)
{
const
data
=
[]
cards
.
forEach
(
card
=>
{
const
coupon
=
this
.
_
.
find
(
coupons
,
{
couponCode
:
card
.
code
})
if
(
coupon
.
ret
)
{
const
product
=
this
.
_
.
find
(
products
,
{
id
:
parseInt
(
coupon
.
productId
)
})
data
.
push
({
card
,
coupon
,
product
})
}
else
{
data
.
push
({
card
,
coupon
})
}
})
return
{
type
,
name
,
data
}
},
parseCoupons
(
content
)
{
const
coupons
=
[]
if
(
content
)
{
const
responseCoupon
=
JSON
.
parse
(
content
)
// console.info(responseCoupon)
responseCoupon
.
couponlist
.
forEach
(
c
=>
{
if
(
c
.
statusCode
===
100
&&
c
.
codeInfo
!=
null
)
{
const
data
=
[
{
name
:
'券号'
,
field
:
'code'
,
val
:
c
.
codeInfo
.
code
},
{
name
:
'电子凭证码类型'
,
field
:
'couponType'
,
val
:
c
.
couponType
},
{
name
:
'优惠券过期时间'
,
field
:
'vdata'
,
val
:
c
.
codeInfo
.
vdata
},
{
name
:
'活动号'
,
field
:
'act_id'
,
val
:
c
.
codeInfo
.
act_id
},
{
name
:
'活动名称'
,
field
:
'act_name'
,
val
:
c
.
codeInfo
.
act_name
},
{
name
:
'活动描述'
,
field
:
'act_desc'
,
val
:
c
.
codeInfo
.
act_desc
},
{
name
:
'代金券优惠(非代金券不返回)'
,
field
:
'amount '
,
val
:
c
.
codeInfo
.
amount
},
{
name
:
'代金券门槛(非代金券不返回)'
,
field
:
'minamount'
,
val
:
c
.
codeInfo
.
minamount
},
{
name
:
'对应商品编号'
,
field
:
'mcd_productCode'
,
val
:
c
.
codeInfo
.
products
[
0
].
mcd_productCode
},
{
name
:
'mcd_tenderCode'
,
field
:
'mcd_tenderCode'
,
val
:
c
.
codeInfo
.
products
[
0
].
mcd_tenderCode
}
]
data
.
forEach
(
d
=>
{
d
.
descriptor
=
this
.
buildCouponDescriptor
(
d
.
field
,
d
.
val
)
})
coupons
.
push
({
ret
:
true
,
couponCode
:
c
.
code
,
couponName
:
c
.
codeInfo
.
act_name
,
productId
:
c
.
codeInfo
.
products
[
0
].
mcd_productCode
,
data
:
data
})
}
else
{
coupons
.
push
({
ret
:
false
,
couponCode
:
c
.
code
,
data
:
c
.
msg
})
}
})
}
return
coupons
},
parseProducts
(
content
)
{
const
products
=
[]
if
(
content
)
{
const
responseProducts
=
JSON
.
parse
(
content
)
responseProducts
.
data
.
products
.
forEach
(
p
=>
{
const
data
=
[
{
name
:
'编号'
,
field
:
'pid'
,
val
:
p
.
pid
},
{
name
:
'名称'
,
field
:
'name'
,
val
:
p
.
name
},
{
name
:
'customerCode'
,
field
:
'customerCode'
,
val
:
p
.
customerCode
},
{
name
:
'业务类型'
,
field
:
'businessType'
,
val
:
p
.
businessType
},
{
name
:
'价格'
,
field
:
'finalPrice'
,
val
:
p
.
finalPrice
},
{
name
:
'外带价格'
,
field
:
'finalPriceTakeout'
,
val
:
p
.
finalPriceTakeout
},
{
name
:
'原价'
,
field
:
'originalPrice'
,
val
:
p
.
originalPrice
},
{
name
:
'外带原价'
,
field
:
'originalPriceTakeout'
,
val
:
p
.
originalPriceTakeout
},
{
name
:
'状态'
,
field
:
'status'
,
val
:
p
.
status
},
{
name
:
'菜品类型'
,
field
:
'type'
,
val
:
p
.
type
}
]
data
.
forEach
(
d
=>
{
d
.
descriptor
=
this
.
buildProductDescriptor
(
d
.
field
,
d
.
val
)
})
products
.
push
({
id
:
p
.
pid
,
name
:
p
.
name
,
data
:
data
})
})
}
return
products
},
buildCouponDescriptor
(
field
,
val
)
{
let
memo
=
''
let
desc
=
''
if
(
field
===
'couponType'
)
{
switch
(
parseInt
(
val
))
{
case
0
:
memo
=
'商品券'
break
case
1
:
memo
=
'代金券'
break
default
:
break
}
desc
=
'0)商品券, 1)代金券;'
}
if
(
memo
||
desc
)
{
return
{
memo
,
desc
}
}
return
null
},
buildProductDescriptor
(
field
,
val
)
{
let
memo
=
''
let
desc
=
''
if
(
field
===
'businessType'
)
{
if
(
val
===
'1'
)
{
memo
=
'饮品'
}
desc
=
'1)饮品, 2)非饮品'
}
else
if
(
field
===
'status'
)
{
switch
(
parseInt
(
val
))
{
case
1
:
memo
=
'下架'
break
case
2
:
memo
=
'上架'
break
case
3
:
memo
=
'售罄'
break
default
:
break
}
desc
=
'1)下架, 2)上架, 3)售罄'
}
else
if
(
field
===
'type'
)
{
switch
(
parseInt
(
val
))
{
case
1
:
memo
=
'普通商品'
break
case
2
:
memo
=
'附加商品'
break
case
3
:
memo
=
'组合商品'
break
case
4
:
memo
=
'固定套餐'
break
case
5
:
memo
=
'组合套餐'
break
case
6
:
memo
=
'多规格套餐'
break
default
:
break
}
desc
=
'1)普通商品, 2)附加商品, 3)组合商品, 4)固定套餐, 5)组合套餐, 6)多规格套餐'
}
if
(
memo
||
desc
)
{
return
{
memo
,
desc
}
}
return
null
}
}
}
</
script
>
<
style
lang=
"less"
scope
>
.rr-user-coupons
{
.ivu-collapse
>
.ivu-collapse-item
{
margin-bottom
:
10px
;
border-width
:
3px
!important
;
border-style
:
solid
!important
;
}
.card-panel-10
{
border-color
:
rgb
(
7
,
193
,
96
)
!important
;
}
.card-panel-20
{
border-color
:
rgb
(
219
,
0
,
7
)
!important
;
}
.card-panel-30
{
border-color
:
rgb
(
0
,
120
,
185
)
!important
;
}
}
.coupon-line
{
margin-bottom
:
15px
;
.xxx
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
}
.ivu-table-cell
{
padding-right
:
0px
;
}
}
</
style
>
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