2c7d8ec064 feat(channel): 新增电话充值不同类型方法
- 在 Xinwang 类中添加了多个新的充值类型方法,包括 ydcz、ydcz_cjkc、ltcz、ltcz_cjkc、dxcz 和 dxcz_cjkc- 这些新方法通过设置不同的 isp_type 属性来区分不同的充值类型
- 修改了 dhcz 方法,支持根据 isp_type 进行充值类型判断
- 优化了 notify 方法中的状态处理逻辑- 在 order 控制器中修复了 other_param 相关的逻辑错误
- 在 merchant 视图中添加了复冲次数输入框
2025-06-21 18:48:04 +08:00

188 lines
4.8 KiB
PHP

<?php
namespace app\channel\service\system;
/**
* 浦上亚婕服务
* Class Bodingcheng
* @package app\channel\service
*/
class Xinwang extends Core
{
# 这几个可以后台设置
protected $host = '';
protected $mid = '';
protected $token = '';
protected $api = 'api/phoneOrder';
protected $isp_type = false;
# 电话充值
public function dhcz($param)
{
$check = array
(
'mobile' => 'tel',
'cash' => 'money',
'teltype' => 'teltype',
);
$param['teltype'] = 1;
if($this->isp_type){
$param['teltype'] = $this->isp_type;
}else{
if (isset($param['isp']) && $param['isp']) {
if($param['isp'] == 1){
$param['teltype'] = 2;
}else if($param['isp'] == 2){
$param['teltype'] = 3;
}else{
$param['teltype'] = 1;
}
}
}
$this->api = 'api/v2/order/audit/add';
return $this->submit($param, $check);
}
public function ydcz($param)
{
$this->isp_type = 2;
return $this->dhcz($param);
}
public function ydcz_cjkc($param)
{
$this->isp_type = 2;
return $this->dhcz($param);
}
public function ltcz($param)
{
$this->isp_type = 3;
return $this->dhcz($param);
}
public function ltcz_cjkc($param)
{
$this->isp_type = 3;
return $this->dhcz($param);
}
public function dxcz($param)
{
$this->isp_type = 1;
return $this->dhcz($param);
}
public function dxcz_cjkc($param)
{
$this->isp_type = 1;
return $this->dhcz($param);
}
# 通知处理 主要返回状态 2是成功 3是失败
public function notify($data)
{
$request = $data;
$result = array();
$result['cash'] = 1;
if ($data['status'] == 1) {
$result['status'] = 2;
} elseif ($data['status'] == 2 || $data['status'] == 3) {
$result['status'] = 3;
} else {
$result['status'] = 4;
}
if (isset($data['pay_orderid']) && $data['pay_orderid']) {
# 流水号
$data['s_number'] = $result['s_number'] = $data['pay_orderid'];
}
$result['yes'] = 'success';
$result['data'] = $data;
return $result;
}
# 数据响应格式处理
public function response($data)
{
$log['type'] = 'response';
$log['data'] = $data;
$log['config'] = $this->data;
$this->log($log);
$array = $this->json_decode($data);
if (!$array) {
$msg = 'error';
} elseif (isset($array['code']) && $array['code'] == '200') {
# 正确
$msg = 'ok';
} else {
# 错误
$msg = isset($array['msg']) ? $array['msg'] : 'error';
}
return array
(
'msg' => $msg,
'data' => $data,
'array' => $array,
);
}
# 查询接口
public function query($param)
{
}
# 提交数据
private function submit($param, $check)
{
$param = $this->param($param, $check);
if (is_string($param) || (is_array($param) && $param['status'] == 1)) {
return $param;
}
$request = $param['detail'];
$request['mchid'] = $this->mid;
$request['orderid'] = $param['order'];
$request['notify'] = $this->getNotify($param['order'], 1);
$request['timeout'] = $this->getGid($param['cash']);
$request['rand'] = rand(100000, 999999);
$request['sign'] = $this->_sign($request);
$url = $this->host . $this->api;
$response = $this->curl('post', $url, $request);
$response = $this->response($response);
//$response['data'] = '';
//$response['msg'] = 'ok';
$channel_order_id = '';
if(isset($response['array']['orderid']) && $response['array']['orderid']){
$channel_order_id = $response['array']['orderid'];
}
$this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']);
return $response['msg'];
}
private function _sign($request)
{
ksort($request);
$signature_string = '';
foreach ($request as $k => $v) {
if (isset($request[$v]) && $request[$v]) {
$signature_string .= $v . '=' . $request[$v] . '&';
// $signature_string .= $request[$v];
}
}
//$signature_string = substr($signature_string, 0, -1);
$signature_string .= 'key='. $this->token;
return md5($signature_string);
}
}