切换导航条
此项目
正在载入...
登录
root
/
Health
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
sgj
5 years ago
提交
53a0f3ff165de0cb4150923bf8854b1d6ff58b6e
1 个父辈
c82765e2
online
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
291 行增加
和
11 行删除
application/admin/controller/GetCash.php
application/admin/model/GoodsBak.php
application/admin/view/group/add.html
application/api/controller/Common.php
public/assets/js/backend/get_cash.js
application/admin/controller/GetCash.php
查看文件 @
53a0f3f
...
...
@@ -2,7 +2,10 @@
namespace
app\admin\controller
;
use
addons\third\library\Application
;
use
addons\third\Third
;
use
app\common\controller\Backend
;
use
think\Db
;
/**
* 提现审核管理
...
...
@@ -73,4 +76,63 @@ class GetCash extends Backend
}
return
$this
->
view
->
fetch
();
}
public
function
pay
(){
$id
=
input
(
'ids'
);
$info
=
\app\admin\model\GetCash
::
get
(
$id
);
if
(
$info
[
'paytime'
]
!=
0
){
$this
->
error
(
'已支付,请勿重复支付!'
);
}
Db
::
startTrans
();
try
{
$path
=
APP_PATH
.
'cert/'
;
$map
[
'user_id'
]
=
$info
[
'user_id'
];
$openid
=
db
(
'third'
)
->
where
(
$map
)
->
value
(
'openid'
);
$options
=
[
'app_id'
=>
'wxf8b3359982b87214'
,
'payment'
=>
[
'merchant_id'
=>
'1558514191'
,
'key'
=>
'yUKuA7HxasJ3l6m4BaCZrbRhiPapKPAP'
,
'cert_path'
=>
$path
.
'apiclient_cert.pem'
,
'key_path'
=>
$path
.
'apiclient_key.pem'
,
],
];
$money
=
$info
[
'fee'
];
$Wechat
=
new
\EasyWeChat\Foundation\Application
(
$options
);
$merchantPay
=
$Wechat
->
merchant_pay
;
$order
=
cmf_get_order_sn
();
$merchantPayData
=
[
'partner_trade_no'
=>
$order
,
//随机字符串作为订单号,跟红包和支付一个概念。
'openid'
=>
$openid
,
//收款人的openid
'check_name'
=>
'NO_CHECK'
,
//文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
//'re_user_name'=>'张三', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交
'amount'
=>
$money
*
100
,
//单位为分
'desc'
=>
'企业付款'
,
// 'spbill_create_ip' => '192.168.0.1', //发起交易的IP地址
];
$result
=
$merchantPay
->
send
(
$merchantPayData
);
$User
=
new
\app\admin\model\User
();
if
(
$result
[
'result_code'
]
==
'SUCCESS'
){
/*扣除对应金额*/
/*记入现金log*/
$save
[
'paytime'
]
=
time
();
\app\admin\model\GetCash
::
get
(
$id
)
->
save
(
$save
);
Db
::
commit
();
}
else
{
Db
::
rollback
();
$this
->
error
(
$result
[
'err_code_des'
]);
}
/*修改用户支付状态*/
}
catch
(
\Exception
$e
)
{
// 回滚事务
$this
->
error
(
$e
->
getMessage
());
Db
::
rollback
();
}
$this
->
success
(
'付款成功!'
);
}
}
...
...
application/admin/model/GoodsBak.php
查看文件 @
53a0f3f
...
...
@@ -27,7 +27,6 @@ class GoodsBak extends Model
protected
$append
=
[
'goods_avatar_text'
];
protected
static
function
init
()
{
...
...
@@ -45,10 +44,4 @@ class GoodsBak extends Model
}
...
...
application/admin/view/group/add.html
查看文件 @
53a0f3f
...
...
@@ -29,7 +29,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Area_id')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-area_id"
data-rule=
"required"
data-source=
"area/index"
class=
"form-control selectpage"
name=
"row[area_id]"
type=
"text"
value=
""
>
<input
id=
"c-area_id"
data-source=
"area/index"
class=
"form-control selectpage"
name=
"row[area_id]"
type=
"text"
value=
""
>
</div>
</div>
<div
class=
"form-group layer-footer"
>
...
...
application/api/controller/Common.php
查看文件 @
53a0f3f
...
...
@@ -6,25 +6,61 @@ use addons\cms\model\Archives;
use
addons\third\library\Service
;
use
app\admin\model\Area
;
use
app\admin\model\FormId
;
use
app\admin\model\Group
;
use
app\admin\model\Mission
;
use
app\admin\model\MissionJoin
;
use
app\admin\model\Suggest
;
use
app\common\controller\Api
;
use
app\common\library\Auth
;
use
EasyWeChat\Foundation\Application
;
use
fast\Http
;
use
fast\Random
;
use
PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root
;
use
think\Config
;
use
think\Db
;
use
app\common\model\Attachment
;
use
think\Log
;
/**
* 公共接口
*/
class
Common
extends
Api
{
protected
$noNeedLogin
=
[
'getSessionKey'
,
'login'
,
'codeToToken'
,
'notifyx'
];
protected
$noNeedLogin
=
[
'getSessionKey'
,
'login'
,
'
index'
,
'
codeToToken'
,
'notifyx'
];
protected
$noNeedRight
=
'*'
;
public
function
index
(){
$img_url
=
ROOT_PATH
.
'public/assets/img/32px.png'
;
/* dump($img_url);
$media=$this->getMedia($img_url);
dump($media);*/
// exit();
Log
::
init
([
'type'
=>
'File'
,
'path'
=>
APP_PATH
.
'logs/'
]);
$signature
=
$_GET
[
"signature"
];
$timestamp
=
$_GET
[
"timestamp"
];
$nonce
=
$_GET
[
"nonce"
];
$token
=
'bronet'
;
//TOKEN 写自己在微信平台填入的token
$tmpArr
=
array
(
$token
,
$timestamp
,
$nonce
);
sort
(
$tmpArr
,
SORT_STRING
);
$tmpStr
=
implode
(
$tmpArr
);
$tmpStr
=
sha1
(
$tmpStr
);
if
(
$tmpStr
==
$signature
){
}
else
{
return
false
;
}
Log
::
write
(
'验签通过'
);
$this
->
responseMsg
();
}
/**
* @ApiTitle (获取SessionKey)
* @ApiSummary (解密微信加密信息)
...
...
@@ -98,7 +134,7 @@ class Common extends Api
$result
=
[
'openid'
=>
$json
[
'openid'
],
'userinfo'
=>
[
'nickname'
=>
$userInfo
[
'nickName'
],
'nickname'
=>
$userInfo
[
'nickName'
],
],
'access_token'
=>
$json
[
'session_key'
],
'refresh_token'
=>
''
,
...
...
@@ -633,5 +669,170 @@ class Common extends Api
}
}
private
function
checkSignature
(){
$signature
=
$_GET
[
"signature"
];
$timestamp
=
$_GET
[
"timestamp"
];
$nonce
=
$_GET
[
"nonce"
];
$token
=
'bronet'
;
$tmpArr
=
array
(
$token
,
$timestamp
,
$nonce
);
sort
(
$tmpArr
,
SORT_STRING
);
$tmpStr
=
implode
(
$tmpArr
);
$tmpStr
=
sha1
(
$tmpStr
);
if
(
$tmpStr
==
$signature
){
return
true
;
}
else
{
return
false
;
}
}
private
function
responseMsg
()
{
$postStr
=
file_get_contents
(
'php://input'
);
//此处推荐使用file_get_contents('php://input')获取后台post过来的数据
Log
::
write
(
$postStr
);
if
(
!
empty
(
$postStr
)
&&
is_string
(
$postStr
))
{
$postArr
=
json_decode
(
$postStr
,
true
);
Log
::
write
(
$postArr
);
if
(
!
empty
(
$postArr
[
'MsgType'
])
&&
$postArr
[
'MsgType'
]
==
'text'
)
{
//用户发送文本消息
$fromUsername
=
$postArr
[
'FromUserName'
];
//发送者openid
$media_id
=
''
;
//输入想要回复的图片消息的media_id
$data
=
array
(
"touser"
=>
$fromUsername
,
"msgtype"
=>
"image"
,
"image"
=>
array
(
"media_id"
=>
$media_id
)
);
$json
=
json_encode
(
$data
,
JSON_UNESCAPED_UNICODE
);
//php5.4+
$this
->
requestAPI
(
$json
);
}
elseif
(
!
empty
(
$postArr
[
'MsgType'
])
&&
$postArr
[
'MsgType'
]
==
'image'
)
{
//用户发送图文消息
$fromUsername
=
$postArr
[
'FromUserName'
];
//此处为文字回复,不同的回复方式可参考文章顶部第三个链接“回复客户消息”里查看
$content
=
'你好,你的专属海报正在制作中,请稍后回复“1”获取海报'
;
$data
=
array
(
"touser"
=>
$fromUsername
,
"msgtype"
=>
"text"
,
"text"
=>
array
(
"content"
=>
$content
)
);
$json
=
json_encode
(
$data
,
JSON_UNESCAPED_UNICODE
);
//php5.4+
$this
->
requestAPI
(
$json
);
$fromUsername
=
$postArr
[
'FromUserName'
];
//发送者openid
$media_id
=
''
;
//输入想要回复的图片消息的media_id
$data
=
array
(
"touser"
=>
$fromUsername
,
"msgtype"
=>
"image"
,
"image"
=>
array
(
"media_id"
=>
$media_id
)
);
$json
=
json_encode
(
$data
,
JSON_UNESCAPED_UNICODE
);
//php5.4以上版本才可使用
$this
->
requestAPI
(
$json
);
}
elseif
(
$postArr
[
'MsgType'
]
==
'miniprogrampage'
)
{
//用户进入客服
/*获取对应的图片地址*/
$info
=
explode
(
'='
,
$postArr
[
'PagePath'
]);
$num
=
count
(
$info
);
if
(
$num
<=
1
)
{
$id
=
1
;
}
else
{
$id
=
$info
[
$num
-
1
];
}
Log
::
write
(
$num
);
/*查询对应的群信息*/
$image
=
Group
::
get
(
$id
)
->
group_image
;
$image_url
=
ROOT_PATH
.
'public/'
.
$image
;
$media_id
=
$this
->
getMedia
(
$image_url
);
$fromUsername
=
$postArr
[
'FromUserName'
];
//发送者openid
//输入想要回复的图片消息的media_id
$data
=
array
(
"touser"
=>
$fromUsername
,
"msgtype"
=>
"image"
,
"image"
=>
array
(
"media_id"
=>
$media_id
)
);
Log
::
write
(
$data
);
$json
=
json_encode
(
$data
,
JSON_UNESCAPED_UNICODE
);
//php5.4+
$this
->
requestAPI
(
$json
);
exit
();
$fromUsername
=
$postArr
[
'FromUserName'
];
//此处为文字回复,不同的回复方式可参考文章顶部第三个链接“回复客户消息”里查看
$content
=
'你好,你的专属海报正在制作中,请稍后回复“1”获取海报'
;
$data
=
array
(
"touser"
=>
$fromUsername
,
"msgtype"
=>
"text"
,
"text"
=>
array
(
"content"
=>
$content
)
);
$json
=
json_encode
(
$data
,
JSON_UNESCAPED_UNICODE
);
//php5.4+
$this
->
requestAPI
(
$json
);
}
else
{
exit
(
'error'
);
}
}
else
{
echo
"empty"
;
exit
;
}
}
function
requestAPI
(
$json
){
$access_token
=
$this
->
get_accessToken
();
/*
* POST发送https请求客服接口api
*/
$url
=
"https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token="
.
$access_token
;
//以'json'格式发送post的https请求
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
// 发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
FALSE
);
if
(
!
empty
(
$json
)){
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$json
);
}
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers );
$output
=
curl_exec
(
$curl
);
if
(
curl_errno
(
$curl
))
{
echo
'Errno'
.
curl_error
(
$curl
);
//捕抓异常
}
curl_close
(
$curl
);
if
(
$output
==
0
){
echo
'success'
;
exit
;
}
}
function
get_accessToken
(){
$config
=
\config
(
'wechat'
);
$app
=
new
Application
(
$config
);
$accessToken
=
$app
->
access_token
;
// EasyWeChat\Core\AccessToken 实例
$token
=
$accessToken
->
getToken
();
// token 字符串
return
$token
;
}
/**
* 生成永久素材
* @param $access_token
* @param $daka_url
*/
public
function
getMedia
(
$daka_url
)
{
$config
=
\config
(
'wechat'
);
$app
=
new
Application
(
$config
);
$material
=
$app
->
material_temporary
;
$result
=
$material
->
uploadImage
(
$daka_url
);
return
$result
[
'media_id'
];
}
private
function
https_request
(
$url
,
$data
=
null
)
{
$curl
=
curl_init
();
//curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, false);
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
FALSE
);
if
(
!
empty
(
$data
))
{
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
}
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
$output
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
return
$output
;
}
}
...
...
public/assets/js/backend/get_cash.js
查看文件 @
53a0f3f
...
...
@@ -31,7 +31,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
field
:
'paytime'
,
title
:
__
(
'Paytime'
),
operate
:
'RANGE'
,
addclass
:
'datetimerange'
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'user.nickname'
,
title
:
__
(
'User.nickname'
)},
{
field
:
'user.avatar'
,
title
:
__
(
'User.avatar'
),
events
:
Table
.
api
.
events
.
image
,
formatter
:
Table
.
api
.
formatter
.
image
},
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
events
:
Table
.
api
.
events
.
operate
,
formatter
:
Table
.
api
.
formatter
.
operate
}
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
events
:
Table
.
api
.
events
.
operate
,
buttons
:
[
{
name
:
'ajax'
,
title
:
__
(
'支付'
),
classname
:
'btn btn-xs btn-success btn-magic btn-ajax'
,
icon
:
'fa fa-magic'
,
url
:
'get_cash/pay'
,
success
:
function
(
data
,
ret
)
{
Layer
.
alert
(
ret
.
msg
);
//如果需要阻止成功提示,则必须使用return false;
// return false;
},
error
:
function
(
data
,
ret
)
{
console
.
log
(
data
,
ret
);
Layer
.
alert
(
ret
.
msg
);
return
false
;
}
},
],
formatter
:
Table
.
api
.
formatter
.
operate
}
]
]
});
...
...
请
注册
或
登录
后发表评论