Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
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
1
Merge Requests
1
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
冯佳佳
Automat
Commits
0912e712
Commit
0912e712
authored
Oct 13, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
b89f39eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
217 additions
and
12 deletions
+217
-12
libs/__init__.py
+8
-0
models/models.py
+27
-3
myapps/sukang24h/api/rent_portal.py
+92
-8
myapps/sukang24h/api/tally_portal.py
+15
-0
utils/error_code.py
+75
-1
No files found.
libs/__init__.py
0 → 100644
View file @
0912e712
#!usr/bin/.env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@file: __init__.py.py
"""
\ No newline at end of file
models/models.py
View file @
0912e712
...
...
@@ -121,7 +121,7 @@ class Rent(Base):
id
=
Column
(
INTEGER
(
10
),
primary_key
=
True
)
rent_no
=
Column
(
VARCHAR
(
40
),
nullable
=
False
,
index
=
True
,
comment
=
'租借单号'
)
machine_
id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
index
=
True
,
comment
=
'机柜id'
)
machine_
no
=
Column
(
String
(
40
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
index
=
True
,
comment
=
'机柜id'
)
user_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
index
=
True
,
comment
=
'用户id'
)
place_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
index
=
True
,
comment
=
'场所id'
)
total
=
Column
(
INTEGER
(
10
),
server_default
=
text
(
"'0'"
),
comment
=
'应收金额'
)
...
...
@@ -134,8 +134,6 @@ class Rent(Base):
add_time
=
Column
(
TIMESTAMP
,
nullable
=
False
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
),
comment
=
'下单时间'
)
pay_time
=
Column
(
TIMESTAMP
,
comment
=
'支付时间'
)
is_take
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'是否取货'
)
take_time
=
Column
(
TIMESTAMP
,
comment
=
'取货时间'
)
is_over
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'是否完结'
)
is_cancel
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'是否取消交易'
)
refund_no
=
Column
(
VARCHAR
(
191
),
comment
=
'退款单号'
)
...
...
@@ -146,6 +144,32 @@ class Rent(Base):
updated_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
class
RentDetail
(
Base
):
__tablename__
=
'rent_detail'
id
=
Column
(
INTEGER
(
10
),
primary_key
=
True
,
unique
=
True
)
rent_no
=
Column
(
String
(
40
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'订单编号'
)
user_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
index
=
True
,
comment
=
'用户id'
)
machine_no
=
Column
(
String
(
20
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'机柜id'
)
hatch_no
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
comment
=
'机柜仓口号'
)
production_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'商品id'
)
is_take
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'是否取货'
)
name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
titile
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
brand_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'品牌ID'
)
brand_name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
cate_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分类ID'
)
cate_name
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
price
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'价格'
)
img
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
))
tags
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
comment
=
'商品标签'
)
content
=
Column
(
Text
(
collation
=
'utf8mb4_unicode_ci'
),
comment
=
'商品内容'
)
summary
=
Column
(
Text
(
collation
=
'utf8mb4_unicode_ci'
),
comment
=
'商品描述'
)
status
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'1正常 2删除'
)
created_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP"
))
updated_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
class
SalePlan
(
Base
):
__tablename__
=
'sale_plan'
...
...
myapps/sukang24h/api/rent_portal.py
View file @
0912e712
...
...
@@ -17,11 +17,11 @@ from flask import Blueprint, request, jsonify, g
from
config.commen_config
import
USER_RENT_PREPAY_ID
,
RENT_SALE_LOCK
from
config.wechat_config
import
platform_appid_config_list
,
pay_config_list
from
models.base_model
import
db
from
models.models
import
Machine
,
Hatch
,
Rent
from
models.models
import
Machine
,
Hatch
,
Rent
,
WxUser
,
RentDetail
from
service.rent_service
import
RentService
from
service.wechat_service
import
WeChatPayService
from
utils.error_code
import
Param_Invalid_Error
,
MACHINE_NOT_EXIST_ERROR
,
HATCH_NOT_EXIST_ERROR
,
\
HATCH_NOT_ALL_EXIST_ERROR
,
WE_MINIAPP_PAY_FAIL
HATCH_NOT_ALL_EXIST_ERROR
,
WE_MINIAPP_PAY_FAIL
,
NO_RENT_RECORD
from
utils.my_redis_cache
import
redis_client
from
utils.my_response
import
BaseResponse
...
...
@@ -33,13 +33,13 @@ rent_route = Blueprint('rent', __name__)
@rent_route.route
(
"rent"
,
methods
=
[
"POST"
])
def
create_rent
():
json_data
=
request
.
get_json
()
machine_no
=
json_data
[
"machine_no"
]
hatch_nos
=
json_data
[
"hatch_nos"
]
user
=
g
.
user
#
machine_no = json_data["machine_no"]
#
hatch_nos = json_data["hatch_nos"]
#
user = g.user
machine_no
=
'1636127865'
hatch_nos
=
[
1
]
user
=
WxUser
.
query
.
filter_by
(
id
=
user_id
)
.
first
()
user
=
WxUser
.
query
.
filter_by
(
id
=
1
)
.
first
()
# 验证机柜是否存在
machine
=
Machine
.
query
.
filter_by
(
machine_no
=
machine_no
)
.
first
()
...
...
@@ -62,7 +62,7 @@ def create_rent():
rent_no
=
RentService
.
create_order_no
()
# 配置微信订单数据
wechat_service
=
WeChatPayService
(
app_id
=
platform_appid_config_list
[
g
.
user
.
platform
],
wechat_service
=
WeChatPayService
(
app_id
=
platform_appid_config_list
[
user
.
platform
],
config_name
=
pay_config_list
[
machine
.
mch_platform
])
pay_data
=
{
'body'
:
'灰兔智能租借押金'
,
# 商品描述
...
...
@@ -72,7 +72,7 @@ def create_rent():
'openid'
:
user
.
openid
,
'timeStamp'
:
str
(
int
(
time
.
time
())),
'attach'
:
{
"hatch_nos"
:
json_data
[
"number"
]
,
"hatch_nos"
:
hatch_nos
,
"machine_no"
:
machine_no
,
"user_id"
:
user
.
id
,
"machine_id"
:
machine
.
id
,
...
...
@@ -191,3 +191,87 @@ def wx_pay_callback():
redis_client
.
delete
(
RENT_SALE_LOCK
+
str
(
rent
.
machine_id
))
return
xmltodict
.
unparse
({
'xml'
:
response_data
},
pretty
=
True
),
header
@rent_route.route
(
"/detail_info"
,
methods
=
[
"POST"
])
def
get_rent_detail
():
json_data
=
request
.
get_json
()
rent_no
=
json_data
[
"rent_no"
]
rent_info
=
Rent
.
query
.
filter_by
(
rent_no
=
rent_no
)
.
first
()
if
not
rent_info
:
return
jsonify
(
NO_RENT_RECORD
)
rent_detail
=
RentDetail
.
query
.
filter_by
(
rent_no
=
rent_no
,
status
=
1
)
.
all
()
if
not
rent_detail
:
rent_detail
=
[]
return_data
=
{}
return_data
[
"rent_no"
]
=
rent_info
.
rent_no
return_data
[
"machine_no"
]
=
rent_info
.
machine_no
return_data
[
"user_id"
]
=
rent_info
.
user_id
return_data
[
"place_id"
]
=
rent_info
.
place_id
return_data
[
"total"
]
=
rent_info
.
total
return_data
[
"real_total"
]
=
rent_info
.
real_total
return_data
[
"add_time"
]
=
rent_info
.
add_time
return_data
[
"pay_time"
]
=
rent_info
.
pay_time
detail_data
=
[]
for
i
in
rent_detail
:
tmp_data
=
{}
tmp_data
[
"hatch_no"
]
=
i
.
hatch_no
tmp_data
[
"production_id"
]
=
i
.
production_id
tmp_data
[
"is_take"
]
=
i
.
is_take
tmp_data
[
"name"
]
=
i
.
name
tmp_data
[
"titile"
]
=
i
.
titile
tmp_data
[
"brand_id"
]
=
i
.
brand_id
tmp_data
[
"brand_name"
]
=
i
.
brand_name
tmp_data
[
"cate_id"
]
=
i
.
cate_id
tmp_data
[
"cate_name"
]
=
i
.
cate_name
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"content"
]
=
i
.
content
tmp_data
[
"summary"
]
=
i
.
summary
tmp_data
[
"tags"
]
=
i
.
tags
detail_data
.
append
(
tmp_data
)
return_data
[
"detail_data"
]
=
detail_data
return
BaseResponse
(
data
=
return_data
)
@rent_route.route
(
"/detail_record"
,
methods
=
[
"POST"
])
def
get_rent_detail_record
():
json_data
=
request
.
get_json
()
page
=
int
(
json_data
[
'page'
])
limit
=
int
(
json_data
[
'limit'
])
user_id
=
g
.
user
.
id
rent_detail
=
RentDetail
.
query
.
filter
(
RentDetail
.
user_id
==
user_id
,
RentDetail
.
status
!=
-
1
)
.
order_by
(
RentDetail
.
id
.
desc
())
.
offset
(
(
page
-
1
)
*
limit
)
.
limit
(
limit
)
.
all
()
if
not
rent_detail
:
rent_detail
=
[]
detail_data
=
[]
for
i
in
rent_detail
:
tmp_data
=
{}
tmp_data
[
"hatch_no"
]
=
i
.
hatch_no
tmp_data
[
"production_id"
]
=
i
.
production_id
tmp_data
[
"is_take"
]
=
i
.
is_take
tmp_data
[
"name"
]
=
i
.
name
tmp_data
[
"titile"
]
=
i
.
titile
tmp_data
[
"brand_id"
]
=
i
.
brand_id
tmp_data
[
"brand_name"
]
=
i
.
brand_name
tmp_data
[
"cate_id"
]
=
i
.
cate_id
tmp_data
[
"cate_name"
]
=
i
.
cate_name
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"content"
]
=
i
.
content
tmp_data
[
"summary"
]
=
i
.
summary
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"created_at"
]
=
i
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H-
%
M-
%
S"
)
detail_data
.
append
(
tmp_data
)
return
BaseResponse
(
data
=
detail_data
)
myapps/sukang24h/api/tally_portal.py
0 → 100644
View file @
0912e712
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@file: tally_portal.py
"""
import
logging
from
flask
import
Blueprint
logger
=
logging
.
getLogger
(
__name__
)
tally_route
=
Blueprint
(
'tally'
,
__name__
)
\ No newline at end of file
utils/error_code.py
View file @
0912e712
...
...
@@ -12,7 +12,6 @@ Param_Invalid_Error = {
"error_message"
:
"params is invalid, 参数无效"
}
# 用户相关 10开头
TOKEN_NOT_VALID_ERROR
=
{
"error_code"
:
"1001"
,
"error_message"
:
"无效的token"
...
...
@@ -196,3 +195,78 @@ HATCH_NOT_ALL_EXIST_ERROR = {
"error_code"
:
"5008"
,
"error_message"
:
"no all hatch, 存在已售出商品"
}
### 订单相关
RENT_ORDER_NOT_BACK_ERROR
=
{
"error_code"
:
'6101'
,
"error_message"
:
"有未归还的订单"
}
RENT_ORDER_NOT_TAKE_ERROR
=
{
"error_code"
:
'6102'
,
"error_message"
:
"有未取货的订单"
}
RENT_ORDER_NUMBER_MAX
=
{
"error_code"
:
'6103'
,
"error_message"
:
"订单数量达到上限"
}
TAKE_CODE_NOT_VALID
=
{
"error_code"
:
'6104'
,
"error_message"
:
"取货码错误请确认手机号及取货码是否匹配"
}
CODE_CANCEL_ERROR
=
{
"error_code"
:
'6105'
,
"error_message"
:
"取货码已取消"
}
CODE_USED_ERROR
=
{
"error_code"
:
'6108'
,
"error_message"
:
"取货码已使用"
}
NO_POWER_ERROR
=
{
"error_code"
:
'6106'
,
"error_message"
:
"没有可租借设备"
}
NO_RENT_RECORD
=
{
"error_code"
:
'6107'
,
"error_message"
:
"订单不存在"
}
CODE_USED_ERROR
=
{
"error_code"
:
'6108'
,
"error_message"
:
"取货码已使用"
}
RENT_ORDER_NUMBER_LIMIT
=
{
"error_code"
:
'6109'
,
"error_message"
:
"机柜只允许租借一台"
}
REFUND_NOT_RENT_INFO
=
{
"error_code"
:
"6301"
,
"error_message"
:
"没有该订单信息"
}
REFUND_BACK_TIME_ERROR
=
{
"error_code"
:
"6302"
,
"error_message"
:
"归还时间异常"
}
REFUND_NOT_PRODUCTION_INFO
=
{
"error_code"
:
"6303"
,
"error_message"
:
"没有该讲解器信息"
}
REFUND_MONEY_IS_ZERO
=
{
"error_code"
:
"6304"
,
"error_message"
:
"退款金额为零"
}
REFUND_NO_DUPLICATE
=
{
"error_code"
:
"6305"
,
"error_message"
:
"退款单号重复"
}
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