切换导航条
此项目
正在载入...
登录
郭盛
/
community
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Cool
5 years ago
提交
ae5672226eb8f0dcc964c6f638cf665614e85966
1 个父辈
4dc5f78f
1 个管道 的构建
通过
耗费 5 秒
店铺申请接口调试
变更
5
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
143 行增加
和
0 行删除
application/api/controller/Store.php
application/api/model/Store.php
application/common.php
application/extra/site.php
public/api.html
application/api/controller/Store.php
0 → 100644
查看文件 @
ae56722
<?php
namespace
app\api\controller
;
use
addons\litestore\model\Litestoreorder
;
use
app\api\model\LitestoreBanner
;
use
app\api\model\LitestoreGoodsSpec
;
use
app\api\model\UserSearch
;
use
app\common\controller\Api
;
use
EasyWeChat\Foundation\Application
;
use
EasyWeChat\Payment\Order
;
use
think\Db
;
use
think\Exception
;
use
think\exception\PDOException
;
use
think\Request
;
/**
* 店铺接口
*/
class
Store
extends
Api
{
protected
$noNeedLogin
=
[];
protected
$noNeedRight
=
[
'*'
];
protected
$store_model
;
protected
$goods_model
;
protected
$banner_model
;
protected
$spec_model
;
protected
$search_model
;
protected
$favorite_model
;
protected
$comment_model
;
protected
$good_model
;
protected
$follow_model
;
protected
$user_id
;
public
function
__construct
(
Request
$request
,
LitestoreBanner
$banner
,
\app\api\model\LitestoreGoods
$goods
,
LitestoreGoodsSpec
$spec
,
UserSearch
$search
,
\app\api\model\Store
$store
)
{
parent
::
__construct
(
$request
);
$this
->
banner_model
=
$banner
;
$this
->
goods_model
=
$goods
;
$this
->
spec_model
=
$spec
;
$this
->
search_model
=
$search
;
$this
->
store_model
=
$store
;
$this
->
user_id
=
$this
->
auth
->
id
;
}
/**
* 店铺申请
* @ApiWeigh (3)
*
* @ApiTitle (店铺申请)
* @ApiSummary (店铺申请)
* @ApiMethod (POST)
* @ApiRoute (/api/store/store_add)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="store_name", type="integer", required=true, description="店铺名称")
* @ApiParams (name="house_ids", type="string", sample="店铺1id,店铺2id", required=true, description="入驻社区")
* @ApiParams (name="job", type="string", sample="[{'name':'职位名称1','number':'招聘人数1'},{'name':'职位名称2','number':'招聘人数2'}]", required=true, description="招聘职位")
* @ApiParams (name="industry_id", type="string", required=true, description="行业/关键词id")
* @ApiParams (name="name", type="string", required=true, description="联系人姓名")
* @ApiParams (name="mobile", type="string", required=true, description="联系人手机号")
* @ApiParams (name="license", type="string", required=true, description="营业执照")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public
function
store_add
()
{
// $param = (new RecruitValidate())->goCheck('add');
$order_sn
=
$param
[
'order_sn'
]
=
get_order_sn
();
$pay_data
=
[];
if
(
$this
->
auth
->
end_time
>
time
())
{
$param
[
'status'
]
=
2
;
}
else
{
$param
[
'status'
]
=
1
;
// 获取小程序配置
$options
=
\config
(
'miniprogram.basic'
);
$app
=
new
Application
(
$options
);
$payment
=
$app
->
payment
;
// 获取支付参数
$attributes
=
[
'body'
=>
'发布招募合伙人'
,
'out_trade_no'
=>
$order_sn
,
'total_fee'
=>
1
,
// $param['money'] * 100
'spbill_create_ip'
=>
request
()
->
ip
(),
// 可选,如不传该参数,SDK 将会自动获取相应 IP 地址
'notify_url'
=>
url
(
'index/ajax/notify'
,[],
true
,
true
),
// 支付结果通知网址,如果不设置则会使用配置里的默认地址
'trade_type'
=>
'JSAPI'
,
// 请对应换成你的支付方式对应的值类型
'openid'
=>
Db
::
name
(
'third'
)
->
where
(
'user_id'
,
$this
->
auth
->
id
)
->
value
(
'openid'
),
];
$order
=
new
Order
(
$attributes
);
$order_result
=
$payment
->
pay
(
$order
);
if
(
$order_result
[
'return_code'
]
==
'SUCCESS'
&&
$order_result
[
'result_code'
]
==
'SUCCESS'
)
{
$prepayId
=
$order_result
->
prepay_id
;
}
else
{
$this
->
error
(
$order_result
[
'return_msg'
]);
}
}
Db
::
startTrans
();
$result
=
false
;
$result_invite
=
true
;
try
{
$param
[
'user_id'
]
=
$this
->
auth
->
id
;
$result
=
$this
->
store_model
->
add
(
$param
);
$id
=
$this
->
store_model
->
id
;
Db
::
commit
();
}
catch
(
PDOException
$e
)
{
Db
::
rollback
();
$this
->
error
(
$e
->
getMessage
());
}
catch
(
Exception
$e
)
{
Db
::
rollback
();
$this
->
error
(
$e
->
getMessage
());
}
if
(
!
$result
||
!
$result_invite
)
{
$this
->
error
(
'申请提交失败'
);
}
$this
->
success
(
'申请提交成功'
,[
'id'
=>
$id
,
'status'
=>
$param
[
'status'
],
'pay_data'
=>
$pay_data
]);
}
}
\ No newline at end of file
...
...
application/api/model/Store.php
0 → 100644
查看文件 @
ae56722
<?php
namespace
app\api\model
;
class
Store
extends
Base
{
}
\ No newline at end of file
...
...
application/common.php
查看文件 @
ae56722
...
...
@@ -362,3 +362,13 @@ if (!function_exists('hsv2rgb')) {
];
}
}
if
(
!
function_exists
(
'get_order_sn'
))
{
function
get_order_sn
()
{
// 获取毫秒
$micro
=
explode
(
'.'
,
explode
(
' '
,
microtime
())[
0
])[
1
];
return
date
(
'YmdHis'
)
.
substr
(
$micro
,
0
,
5
)
.
rand
(
0
,
9
);
}
}
\ No newline at end of file
...
...
application/extra/site.php
查看文件 @
ae56722
...
...
@@ -36,4 +36,5 @@ return array (
'mail_verify_type'
=>
'2'
,
'mail_from'
=>
'10000@qq.com'
,
'contact'
=>
'联系我们联系我们022-12345678'
,
'settled'
=>
'上架入驻协议'
,
);
\ No newline at end of file
...
...
public/api.html
查看文件 @
ae56722
此 diff 太大无法显示。
请
注册
或
登录
后发表评论