|
|
@@ -26,19 +26,19 @@ class TaxiUserWithdraw extends AdminController
|
|
|
!empty(input('name')) && $where[]
|
|
|
= ['name', 'like', '%' . input('name') . '%'];
|
|
|
!empty(input('keyword')) && $where[]
|
|
|
- = ['mobile', 'like', '%'.input('keyword').'%'];
|
|
|
+ = ['mobile', 'like', '%' . input('keyword') . '%'];
|
|
|
|
|
|
$withdraw = model('common/TaxiUsersWithdraw');
|
|
|
- $list = $withdraw->where($where)->order(['created_at'=>'desc'])->with(['user','taxiUser'])
|
|
|
- ->paginate(input('limit'),false);
|
|
|
+ $list = $withdraw->where($where)->order(['created_at' => 'desc'])->with(['user', 'taxiUser'])
|
|
|
+ ->paginate(input('limit'), false);
|
|
|
//return IResponse::paginate();
|
|
|
return IResponse::success([
|
|
|
- 'total' => $list->total(),
|
|
|
- 'totalRow' => [
|
|
|
- 'wait'=>$withdraw->where($where)->where(['status'=>10])->order(['created_at'=>'desc'])->sum('amount'),
|
|
|
- 'success'=>$withdraw->where($where)->where(['status'=>20])->order(['created_at'=>'desc'])->sum('amount')
|
|
|
+ 'total' => $list->total(),
|
|
|
+ 'totalRow' => [
|
|
|
+ 'wait' => $withdraw->where($where)->where(['status' => 10])->order(['created_at' => 'desc'])->sum('amount'),
|
|
|
+ 'success' => $withdraw->where($where)->where(['status' => 20])->order(['created_at' => 'desc'])->sum('amount')
|
|
|
],
|
|
|
- 'list' => $list->getCollection(),
|
|
|
+ 'list' => $list->getCollection(),
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -63,65 +63,60 @@ class TaxiUserWithdraw extends AdminController
|
|
|
// 更新信息
|
|
|
$withdraw->updateBy($id, $params);
|
|
|
Db::startTrans();
|
|
|
-// try {
|
|
|
- // 通过
|
|
|
- $withdraw->status = $params['status'];
|
|
|
- $withdraw->remittance_time = $params['status'] ==20? time() : 0;
|
|
|
- $withdraw-> arrival_amount = $params['status'] ==20? $withdraw['amount'] : 0;
|
|
|
- if(!$withdraw->save()){
|
|
|
- Db::rollback();
|
|
|
- IResponse::failure('提现审核失败');
|
|
|
- }
|
|
|
|
|
|
- // 拒绝退款
|
|
|
- if($params['status'] == 30){
|
|
|
- // 查用户
|
|
|
- $user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
- if(empty($user)){
|
|
|
- Db::rollback();
|
|
|
- IResponse::failure('司机账户错误,请联系管理员处理');
|
|
|
- }
|
|
|
+ // 通过
|
|
|
+ $withdraw->status = $params['status'];
|
|
|
+ $withdraw->remittance_time = $params['status'] == 20 ? time() : 0;
|
|
|
+ $withdraw->arrival_amount = $params['status'] == 20 ? $withdraw['amount'] : 0;
|
|
|
+ if (!$withdraw->save()) {
|
|
|
+ Db::rollback();
|
|
|
+ IResponse::failure('提现审核失败');
|
|
|
+ }
|
|
|
|
|
|
- // 写入资金记录
|
|
|
- $Users = new Users();
|
|
|
- $Users->changePartnership($user['id'], $withdraw['amount'], '资产余额提现失败退还', 20,true);
|
|
|
+ // 拒绝退款
|
|
|
+ if ($params['status'] == 30) {
|
|
|
+ // 查用户
|
|
|
+ $user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
+ if (empty($user)) {
|
|
|
+ Db::rollback();
|
|
|
+ IResponse::failure('司机账户错误,请联系管理员处理');
|
|
|
}
|
|
|
- // 打款到账
|
|
|
- else if ($params['status'] == 20){
|
|
|
- $wechat = sys_config('', 'wechat');
|
|
|
- $config = [
|
|
|
- // 前面的appid什么的也得保留哦
|
|
|
- 'app_id' => $wechat['mini_appid'],
|
|
|
- 'mch_id' => $wechat['pay_mch_id'],
|
|
|
- 'key' => $wechat['pay_secret_key'],
|
|
|
- // 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
|
|
- 'cert_path' => $wechat['cert_path'], // XXX: 绝对路径!!!!
|
|
|
- 'key_path' => $wechat['key_path'], // XXX: 绝对路径!!!!
|
|
|
- ];
|
|
|
- $user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
- // 创建应用实例
|
|
|
- $app = Factory::payment($config);
|
|
|
- $result = $app->transfer->toBalance([
|
|
|
- 'partner_trade_no' => $withdraw['order_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
|
|
- 'openid' => $user['open_id'],
|
|
|
- 'check_name' => 'FORCE_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
|
|
- 're_user_name' => $withdraw['real_name'], // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
|
|
|
- 'amount' => $withdraw['amount'] * 100, // 企业付款金额,单位为分
|
|
|
- 'desc' => '司机用户提现', // 企业付款操作说明信息。必填
|
|
|
- ]);
|
|
|
- $result = $result['return_code'] == 'SUCCESS' && $result['result_code'] != 'FAIL';
|
|
|
- if(!$result){
|
|
|
- Db::rollback();
|
|
|
- IResponse::failure('打款失败,请联系管理员或核对账户');
|
|
|
- }
|
|
|
+
|
|
|
+ // 写入资金记录
|
|
|
+ $Users = new Users();
|
|
|
+ $Users->changePartnership($user['id'], $withdraw['amount'], '资产余额提现失败退还', 20, true);
|
|
|
+ } // 打款到账
|
|
|
+ else if ($params['status'] == 20) {
|
|
|
+ $wechat = sys_config('', 'wechat');
|
|
|
+ $config = [
|
|
|
+ // 前面的appid什么的也得保留哦
|
|
|
+ 'app_id' => $wechat['mini_appid'],
|
|
|
+ 'mch_id' => $wechat['pay_mch_id'],
|
|
|
+ 'key' => $wechat['pay_secret_key'],
|
|
|
+ // 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
|
|
+ 'cert_path' => $wechat['cert_path'], // XXX: 绝对路径!!!!
|
|
|
+ 'key_path' => $wechat['key_path'], // XXX: 绝对路径!!!!
|
|
|
+ ];
|
|
|
+ $user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
+ // 创建应用实例
|
|
|
+ $app = Factory::payment($config);
|
|
|
+ $result = $app->transfer->toBalance([
|
|
|
+ 'partner_trade_no' => $withdraw['order_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
|
|
+ 'openid' => $user['open_id'],
|
|
|
+ 'check_name' => 'FORCE_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
|
|
|
+ 're_user_name' => $withdraw['real_name'], // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
|
|
|
+ 'amount' => $withdraw['amount'] * 100, // 企业付款金额,单位为分
|
|
|
+ 'desc' => '司机用户提现', // 企业付款操作说明信息。必填
|
|
|
+ ]);
|
|
|
+ $result = $result['return_code'] == 'SUCCESS' && $result['result_code'] != 'FAIL';
|
|
|
+ if (!$result) {
|
|
|
+ Db::rollback();
|
|
|
+ IResponse::failure('打款失败,请联系管理员或核对账户');
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
|
|
|
- Db::commit();
|
|
|
-// } catch (\Exception $e) {
|
|
|
-// Db::rollback();
|
|
|
-// //var_dump($e);
|
|
|
-// IResponse::failure('审核错误:'.$e->getMessage());
|
|
|
-// }
|
|
|
|
|
|
return IResponse::success('审核成功');
|
|
|
}
|
|
|
@@ -129,59 +124,59 @@ class TaxiUserWithdraw extends AdminController
|
|
|
/**
|
|
|
* 删除
|
|
|
*
|
|
|
+ * @param $id
|
|
|
+ * @return \think\response\Json
|
|
|
* @author 许祖兴 < zuxing.xu@lettered.cn>
|
|
|
* @date 2020/6/11 14:26
|
|
|
*
|
|
|
- * @param $id
|
|
|
- * @return \think\response\Json
|
|
|
*/
|
|
|
public function delete($id)
|
|
|
{
|
|
|
model('common/UsersWithdraw')->deleteBy($id);
|
|
|
- return IResponse::success([],'删除提现申请单成功');
|
|
|
+ return IResponse::success([], '删除提现申请单成功');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户批量操作
|
|
|
*
|
|
|
+ * @return mixed
|
|
|
* @author 许祖兴 < zuxing.xu@lettered.cn>
|
|
|
* @date 2020/6/11 14:34
|
|
|
*
|
|
|
- * @return mixed
|
|
|
*/
|
|
|
- public function plectron(){
|
|
|
+ public function plectron()
|
|
|
+ {
|
|
|
// 收参数
|
|
|
$params = $this->request->param();
|
|
|
|
|
|
- foreach (str2arr($params['ids']) as $id){
|
|
|
+ foreach (str2arr($params['ids']) as $id) {
|
|
|
$withdraw = model('common/UsersWithdraw')->getBy($id);
|
|
|
- if ($this->request->isDelete()){
|
|
|
+ if ($this->request->isDelete()) {
|
|
|
$withdraw->deleteBy($id);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 等待审核状态下才做更新
|
|
|
- if ($withdraw['status'] == 10){
|
|
|
+ if ($withdraw['status'] == 10) {
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- if(!$withdraw->allowField(true)->updateBy($id, $params)){
|
|
|
- Db::rollback();
|
|
|
- continue;
|
|
|
+ if (!$withdraw->allowField(true)->updateBy($id, $params)) {
|
|
|
+ Db::rollback();
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
// 拒绝退款
|
|
|
- if($params['status'] == 30){
|
|
|
+ if ($params['status'] == 30) {
|
|
|
// 查用户
|
|
|
$user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
- if(empty($user)){
|
|
|
+ if (empty($user)) {
|
|
|
Db::rollback();
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 写入资金记录
|
|
|
$Users = new Users();
|
|
|
- $Users->changePartnership($user['id'], $withdraw['amount'], '资产余额提现失败退还', 20,true);
|
|
|
- }
|
|
|
- // 打款到账
|
|
|
- else if ($params['status'] == 20){
|
|
|
+ $Users->changePartnership($user['id'], $withdraw['amount'], '资产余额提现失败退还', 20, true);
|
|
|
+ } // 打款到账
|
|
|
+ else if ($params['status'] == 20) {
|
|
|
$wechat = sys_config('', 'wechat');
|
|
|
$config = [
|
|
|
// 前面的appid什么的也得保留哦
|
|
|
@@ -189,8 +184,8 @@ class TaxiUserWithdraw extends AdminController
|
|
|
'mch_id' => $wechat['pay_mch_id'],
|
|
|
'key' => $wechat['pay_secret_key'],
|
|
|
// 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
|
|
- 'cert_path' => $wechat['cert_path'], // XXX: 绝对路径!!!!
|
|
|
- 'key_path' => $wechat['key_path'], // XXX: 绝对路径!!!!
|
|
|
+ 'cert_path' => $wechat['cert_path'], // XXX: 绝对路径!!!!
|
|
|
+ 'key_path' => $wechat['key_path'], // XXX: 绝对路径!!!!
|
|
|
];
|
|
|
$user = model('common/Users')->getBy($withdraw['user_id']);
|
|
|
// 创建应用实例
|
|
|
@@ -204,12 +199,12 @@ class TaxiUserWithdraw extends AdminController
|
|
|
'desc' => '司机用户提现', // 企业付款操作说明信息。必填
|
|
|
]);
|
|
|
$result = $result['return_code'] == 'SUCCESS' && $result['result_code'] != 'FAIL';
|
|
|
- if(!$result){
|
|
|
+ if (!$result) {
|
|
|
Db::rollback();
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- } catch (\Exception $exception){
|
|
|
+ } catch (\Exception $exception) {
|
|
|
Db::rollback();
|
|
|
}
|
|
|
|
|
|
@@ -217,6 +212,6 @@ class TaxiUserWithdraw extends AdminController
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- return IResponse::success([],'操作成功');
|
|
|
+ return IResponse::success([], '操作成功');
|
|
|
}
|
|
|
}
|