fixed
This commit is contained in:
@@ -324,50 +324,27 @@
|
||||
</div>
|
||||
<div class="api_hdrquestionnaireanswer_updateHdrquestionnaireanswer_response_result"></div>
|
||||
|
||||
</div><div id="api_hdrquestionnairequestion_getHdrquestionnairequestionList">
|
||||
</div><div id="api_hdrquestionnaireanswer_del">
|
||||
<div class="markdown_content">
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc:获取科室问卷问题(一个问题对应多个答案)
|
||||
*
|
||||
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
* desc: 删除科室问卷答案
|
||||
* author:wh
|
||||
*
|
||||
* 参数:
|
||||
* 带分页
|
||||
* current_page 当前页码
|
||||
* list_rows 每页显示条数 默认15
|
||||
* question 问卷问题
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
*
|
||||
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>:
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
* create_time 创建时间
|
||||
* update_time 更新时间
|
||||
|
||||
* author:wh
|
||||
* api/hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
* id 数据id 必须
|
||||
* api/Hdrquestionnaireanswer/del
|
||||
* api/hdrquestionnaireanswer/del
|
||||
*/
|
||||
```
|
||||
</div>
|
||||
<div>
|
||||
按需填写其它接口参数:
|
||||
<textarea name="" id="api_hdrquestionnairequestion_getHdrquestionnairequestionList_textarea" cols="100" rows="3">/api/hdrquestionnairequestion/getHdrquestionnairequestionList</textarea>
|
||||
<a href='JavaScript:;' onclick="DocObject.api_hdrquestionnairequestion_getHdrquestionnairequestionList()">测试</a>
|
||||
<textarea name="" id="api_hdrquestionnaireanswer_del_textarea" cols="100" rows="3">/api/hdrquestionnaireanswer/del</textarea>
|
||||
<a href='JavaScript:;' onclick="DocObject.api_hdrquestionnaireanswer_del()">测试</a>
|
||||
</div>
|
||||
<div class="api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result"></div>
|
||||
<div class="api_hdrquestionnaireanswer_del_response_result"></div>
|
||||
|
||||
</div><div id="api_hdrquestionnairequestion_addHdrquestionnairequestion">
|
||||
<div class="markdown_content">
|
||||
@@ -421,6 +398,69 @@
|
||||
</div>
|
||||
<div class="api_hdrquestionnairequestion_updateHdrquestionnairequestion_response_result"></div>
|
||||
|
||||
</div><div id="api_hdrquestionnairequestion_del">
|
||||
<div class="markdown_content">
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc: 删除科室问卷问题(一个问题对应多个答案)
|
||||
* author:wh
|
||||
*
|
||||
* 参数:
|
||||
* id 数据id 必须
|
||||
*
|
||||
* api/Hdrquestionnairequestion/del
|
||||
* api/hdrquestionnairequestion/del
|
||||
*/
|
||||
```
|
||||
</div>
|
||||
<div>
|
||||
按需填写其它接口参数:
|
||||
<textarea name="" id="api_hdrquestionnairequestion_del_textarea" cols="100" rows="3">/api/hdrquestionnairequestion/del</textarea>
|
||||
<a href='JavaScript:;' onclick="DocObject.api_hdrquestionnairequestion_del()">测试</a>
|
||||
</div>
|
||||
<div class="api_hdrquestionnairequestion_del_response_result"></div>
|
||||
|
||||
</div><div id="api_hdrquestionnairequestion_getHdrquestionnairequestionList">
|
||||
<div class="markdown_content">
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc:获取科室问卷问题(一个问题对应多个答案)
|
||||
*
|
||||
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
*
|
||||
* 参数:
|
||||
* 带分页
|
||||
* current_page 当前页码
|
||||
* list_rows 每页显示条数 默认15
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
*
|
||||
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>:
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
* create_time 创建时间
|
||||
* update_time 更新时间
|
||||
|
||||
* author:wh
|
||||
* api/hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
*/
|
||||
```
|
||||
</div>
|
||||
<div>
|
||||
按需填写其它接口参数:
|
||||
<textarea name="" id="api_hdrquestionnairequestion_getHdrquestionnairequestionList_textarea" cols="100" rows="3">/api/hdrquestionnairequestion/getHdrquestionnairequestionList</textarea>
|
||||
<a href='JavaScript:;' onclick="DocObject.api_hdrquestionnairequestion_getHdrquestionnairequestionList()">测试</a>
|
||||
</div>
|
||||
<div class="api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result"></div>
|
||||
|
||||
</div><div id="api_hdrregister_addHdrregister">
|
||||
<div class="markdown_content">
|
||||
***
|
||||
@@ -1322,11 +1362,11 @@
|
||||
$('.api_hdrquestionnaireanswer_updateHdrquestionnaireanswer_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnaireanswer_updateHdrquestionnaireanswer_response_result').attr('style','color:green');
|
||||
},'json');
|
||||
}, api_hdrquestionnairequestion_getHdrquestionnairequestionList(){
|
||||
let url = $('#api_hdrquestionnairequestion_getHdrquestionnairequestionList_textarea').val();
|
||||
}, api_hdrquestionnaireanswer_del(){
|
||||
let url = $('#api_hdrquestionnaireanswer_del_textarea').val();
|
||||
$.post(url,{},function(res) {
|
||||
$('.api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result').attr('style','color:green');
|
||||
$('.api_hdrquestionnaireanswer_del_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnaireanswer_del_response_result').attr('style','color:green');
|
||||
},'json');
|
||||
}, api_hdrquestionnairequestion_addHdrquestionnairequestion(){
|
||||
let url = $('#api_hdrquestionnairequestion_addHdrquestionnairequestion_textarea').val();
|
||||
@@ -1340,6 +1380,18 @@
|
||||
$('.api_hdrquestionnairequestion_updateHdrquestionnairequestion_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnairequestion_updateHdrquestionnairequestion_response_result').attr('style','color:green');
|
||||
},'json');
|
||||
}, api_hdrquestionnairequestion_del(){
|
||||
let url = $('#api_hdrquestionnairequestion_del_textarea').val();
|
||||
$.post(url,{},function(res) {
|
||||
$('.api_hdrquestionnairequestion_del_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnairequestion_del_response_result').attr('style','color:green');
|
||||
},'json');
|
||||
}, api_hdrquestionnairequestion_getHdrquestionnairequestionList(){
|
||||
let url = $('#api_hdrquestionnairequestion_getHdrquestionnairequestionList_textarea').val();
|
||||
$.post(url,{},function(res) {
|
||||
$('.api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result').html(JSON.stringify(res, null, "\t"));
|
||||
$('.api_hdrquestionnairequestion_getHdrquestionnairequestionList_response_result').attr('style','color:green');
|
||||
},'json');
|
||||
}, api_hdrregister_addHdrregister(){
|
||||
let url = $('#api_hdrregister_addHdrregister_textarea').val();
|
||||
$.post(url,{},function(res) {
|
||||
|
||||
@@ -226,36 +226,13 @@
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc:获取科室问卷问题(一个问题对应多个答案)
|
||||
*
|
||||
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
* desc: 删除科室问卷答案
|
||||
* author:wh
|
||||
*
|
||||
* 参数:
|
||||
* 带分页
|
||||
* current_page 当前页码
|
||||
* list_rows 每页显示条数 默认15
|
||||
* question 问卷问题
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
*
|
||||
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>:
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
* create_time 创建时间
|
||||
* update_time 更新时间
|
||||
|
||||
* author:wh
|
||||
* api/hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
* id 数据id 必须
|
||||
* api/Hdrquestionnaireanswer/del
|
||||
* api/hdrquestionnaireanswer/del
|
||||
*/
|
||||
```
|
||||
|
||||
@@ -293,6 +270,51 @@
|
||||
*/
|
||||
```
|
||||
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc: 删除科室问卷问题(一个问题对应多个答案)
|
||||
* author:wh
|
||||
*
|
||||
* 参数:
|
||||
* id 数据id 必须
|
||||
*
|
||||
* api/Hdrquestionnairequestion/del
|
||||
* api/hdrquestionnairequestion/del
|
||||
*/
|
||||
```
|
||||
|
||||
***
|
||||
```
|
||||
/**
|
||||
* desc:获取科室问卷问题(一个问题对应多个答案)
|
||||
*
|
||||
* api/Hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
*
|
||||
* 参数:
|
||||
* 带分页
|
||||
* current_page 当前页码
|
||||
* list_rows 每页显示条数 默认15
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
*
|
||||
* 所有字段说明<span style="color: gray">(可能有部分额外字段未在此体现)</span>:
|
||||
* id ID
|
||||
* hdrdepartment_id 所属科室
|
||||
* question 问卷问题
|
||||
* is_common 是否通用:yes=是,no=否
|
||||
* is_only_boy 只适合男:yes=是,no=否
|
||||
* is_only_girl 只适合女:yes=是,no=否
|
||||
* type 选项类型:one=单选,more=多选
|
||||
* create_time 创建时间
|
||||
* update_time 更新时间
|
||||
|
||||
* author:wh
|
||||
* api/hdrquestionnairequestion/getHdrquestionnairequestionList
|
||||
*/
|
||||
```
|
||||
|
||||
***
|
||||
```
|
||||
/**
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
/.git
|
||||
/.idea
|
||||
/composer.lock
|
||||
.git*
|
||||
|
||||
121
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/Algorithm.php
vendored
Normal file
121
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/Algorithm.php
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/27} {17:36}
|
||||
*/
|
||||
|
||||
namespace wanghua\general_utility_tools_php\algorithm;
|
||||
|
||||
|
||||
/**
|
||||
* 常见算法
|
||||
* Class AlgorithmTools
|
||||
* @package wanghua\general_utility_tools_php\tool
|
||||
*/
|
||||
class Algorithm
|
||||
{
|
||||
|
||||
/**
|
||||
* desc:权重随机选择算法
|
||||
*
|
||||
* 使用场景:转盘抽奖等需要指定概率的场景
|
||||
*
|
||||
* author:wh
|
||||
* @param array $weights 权重数组 eg:[1, 9, 30, 70] 概率的总和是100%
|
||||
* return 返回计算后的索引
|
||||
*/
|
||||
static function weightRandom($weights){
|
||||
//$weights = [1, 9, 30, 70]; // 权重数组
|
||||
$totalWeight = array_sum($weights);
|
||||
$min_num = min($weights);//取出数组中最小的值
|
||||
$random = mt_rand($min_num, $totalWeight); // 生成一个最小元素到总权重的随机数
|
||||
|
||||
$cumulativeWeight = 0; // 累积权重
|
||||
$selected = 0; // 选择的索引
|
||||
|
||||
foreach ($weights as $index => $weight) {
|
||||
$cumulativeWeight += $weight; // 累加权重
|
||||
if ($random <= $cumulativeWeight) {
|
||||
$selected = $index; // 根据权重选择索引
|
||||
break;
|
||||
}
|
||||
}
|
||||
//输出选择的索引
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:测试权重随机算法概率
|
||||
* author:wh
|
||||
* @param array $weights 权重数组 eg:[1, 9, 30, 70]
|
||||
*/
|
||||
static function testWeightRandom(array $weights){
|
||||
echo json_encode($weights)."\n";
|
||||
|
||||
$trials = 1000; // 试验次数
|
||||
$selectionCounts = array_fill(0, count($weights), 0); // 用于存储每个索引的选择次数
|
||||
|
||||
for ($i = 0; $i < $trials; $i++) {
|
||||
|
||||
$index = self::weightRandom($weights);
|
||||
$selectionCounts[$index]++; // 记录选择次数
|
||||
}
|
||||
|
||||
// 计算每个索引的选择概率
|
||||
$probabilities = [];
|
||||
foreach ($selectionCounts as $index => $count) {
|
||||
$probabilities[$index] = ($count / $trials) * 100; // 转换为百分比
|
||||
}
|
||||
|
||||
// 输出结果
|
||||
echo "After {$trials} trials, the probabilities of selecting each index are:\n";
|
||||
foreach ($probabilities as $index => $probability) {
|
||||
echo "Index {$index}: {$probability}%\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:洗牌算法
|
||||
*
|
||||
* 对数组进行随机排序,实现洗牌算法
|
||||
* author:wh
|
||||
* @param array $items eg: [1, 2, 3, 4, 5]
|
||||
* @return array 返回计算后的数组
|
||||
*/
|
||||
static function shuffle(array $items) {
|
||||
//$items = [1, 2, 3, 4, 5];
|
||||
shuffle($items);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机密码生成算法
|
||||
*
|
||||
* 作用:创建安全的随机密码,常用于用户注册或密码重置
|
||||
* 使用场景:用户账户创建、密码重置链接生成
|
||||
*/
|
||||
static function randomPassword($length = 8) {
|
||||
$password = '';
|
||||
$possibleChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$password .= substr($possibleChars, mt_rand(0, strlen($possibleChars) - 1), 1);
|
||||
}
|
||||
return $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机颜色生成算法
|
||||
*
|
||||
* 作用:生成随机RGB颜色值,可用于网页设计中动态改变元素颜色
|
||||
* 使用场景:动态网页背景、随机颜色显示的元素
|
||||
*/
|
||||
static function randomColor() {
|
||||
$red = mt_rand(0, 255);
|
||||
$green = mt_rand(0, 255);
|
||||
$blue = mt_rand(0, 255);
|
||||
return [$red, $green, $blue];
|
||||
}
|
||||
}
|
||||
52
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/AlgorithmTest.php
vendored
Normal file
52
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/AlgorithmTest.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/27} {17:36}
|
||||
*/
|
||||
|
||||
namespace wanghua\general_utility_tools_php\algorithm;
|
||||
|
||||
|
||||
/**
|
||||
* 算法测试
|
||||
* Class AlgorithmTest
|
||||
* @package wanghua\general_utility_tools_php\algorithm
|
||||
*/
|
||||
class AlgorithmTest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* desc:测试权重随机算法概率
|
||||
* author:wh
|
||||
* @param array $weights 权重数组 eg:[1, 9, 30, 70]
|
||||
*/
|
||||
static function testWeightRandom(array $weights){
|
||||
echo json_encode($weights)."\n";
|
||||
|
||||
$trials = 1000; // 试验次数
|
||||
$selectionCounts = array_fill(0, count($weights), 0); // 用于存储每个索引的选择次数
|
||||
|
||||
for ($i = 0; $i < $trials; $i++) {
|
||||
|
||||
$index = Algorithm::weightRandom($weights);
|
||||
$selectionCounts[$index]++; // 记录选择次数
|
||||
}
|
||||
|
||||
// 计算每个索引的选择概率
|
||||
$probabilities = [];
|
||||
foreach ($selectionCounts as $index => $count) {
|
||||
$probabilities[$index] = ($count / $trials) * 100; // 转换为百分比
|
||||
}
|
||||
|
||||
// 输出结果
|
||||
echo "After {$trials} trials, the probabilities of selecting each index are:\n";
|
||||
foreach ($probabilities as $index => $probability) {
|
||||
echo "Index {$index}: {$probability}%\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/README.MD
vendored
Normal file
1
digital_doctor/vendor/wanghua/general-utility-tools-php/src/algorithm/README.MD
vendored
Normal file
@@ -0,0 +1 @@
|
||||
## 常见实用算法
|
||||
@@ -25,6 +25,7 @@ class AlibabaAuth
|
||||
{
|
||||
public $base_url = '';//不同业务线,授权地址不一样
|
||||
public $config = [];
|
||||
public $request_body = [];
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
@@ -154,6 +155,7 @@ class AlibabaAuth
|
||||
|
||||
$url = $this->base_url.$urlPath.'?'.$request_params_str.'&access_token='.$accessToken.'&_aop_signature='.$_aop_signature;
|
||||
//dump($url);
|
||||
$this->request_body = $url;
|
||||
$res = Curl::curl_post($url,[]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,20 @@ class Testexample
|
||||
$order->setGoods($goods,$order_info['buy_num']);
|
||||
return $order->previewOrder();
|
||||
}
|
||||
//查询订单可以支持的支付渠道
|
||||
function queryOrderPayChannel($order_id){
|
||||
$config = config('meebo_supply_config');
|
||||
$authObj = new AlibabaAuth($config);
|
||||
$order = new StrictPay($authObj);
|
||||
return $order->queryOrderPayChannel($order_id);
|
||||
}
|
||||
//组合收银台url获取
|
||||
function getPayUrl(array $orderIds){
|
||||
$config = config('meebo_supply_config');
|
||||
$authObj = new AlibabaAuth($config);
|
||||
$order = new StrictPay($authObj);
|
||||
return $order->getPayUrl($orderIds,'PC');
|
||||
}
|
||||
|
||||
//获取唤起旺旺聊天的链接
|
||||
function getCustomerServiceLink($toOpenUid){
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/6/29} {17:31}
|
||||
*/
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
|
||||
use app\common\model\TabConf;
|
||||
use app\index\logic\alibaba\distributes\notify\BaseStrictNotify;
|
||||
use wanghua\general_utility_tools_php\alibaba\distributes\Testexample;
|
||||
use app\index\logic\alibabanotify\ProductNotify;
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
/**
|
||||
* 阿里巴巴异步通知控制器类,是消息处理入口类
|
||||
* Class Alibabanotify
|
||||
* @package app\index\controller
|
||||
*/
|
||||
class Alibaba extends BasePublicController
|
||||
{
|
||||
|
||||
/**
|
||||
* desc:通知
|
||||
* index/Alibaba/notify
|
||||
*
|
||||
* 输出message
|
||||
{
|
||||
"data":{
|
||||
"productIds":"107680826",
|
||||
"msgSendTime":"2018-05-30 20:29:37",
|
||||
"memberId":"shyxsscl",
|
||||
"status":"RELATION_VIEW_PRODUCT_REPOST"
|
||||
},
|
||||
"gmtBorn":1720459935606,
|
||||
"msgId":88837491757,
|
||||
"type":"PRODUCT_RELATION_VIEW_PRODUCT_REPOST",
|
||||
"userInfo":"b2b-1881150273"
|
||||
}
|
||||
* author:wh
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
function notify(){
|
||||
return Mmodel::catchJson(function (){
|
||||
Tools::log_to_write_txt(['执行消息处理']);
|
||||
//根据消息类型,选择对应的处理类
|
||||
$message_data = input('message');
|
||||
if(empty($message_data)){
|
||||
return Tools::set_fail('message为空');
|
||||
}
|
||||
$message_data = json_decode($message_data,true);
|
||||
Tools::log_to_write_txt(['消息解码'=>$message_data]);
|
||||
if(empty($message_data['type'])){
|
||||
return Tools::set_fail('type为空');
|
||||
}
|
||||
//$key = strtolower(explode('_',$message_data['type'])[0]);
|
||||
//获取消息类型
|
||||
$fn = strtolower($message_data['type']);//类型即为方法名
|
||||
//消息类型前缀即为类名
|
||||
$class = '\\app\\index\\logic\\alibabanotify\\'.ucfirst(explode('_',$fn)[0]).'Notify';
|
||||
//实例化类
|
||||
return (new $class())->{$fn}($message_data);//调用方法
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:ali采购获取临时授权code
|
||||
*
|
||||
* index/alibaba/webAuthCode
|
||||
*
|
||||
* author:wh
|
||||
* @return string
|
||||
*/
|
||||
function webAuthCode(){
|
||||
|
||||
$Testexample = new Testexample();
|
||||
|
||||
$res = $Testexample->testWebAuth(request()->domain().'/index/alibaba/webUserAuth');
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:网页授权,code换取token
|
||||
*
|
||||
* index/alibaba/webUserAuth
|
||||
*
|
||||
* author:wh
|
||||
*/
|
||||
function webUserAuth(){
|
||||
$code = input('code');
|
||||
if(empty($code)){
|
||||
return $this->error('授权失败');
|
||||
}
|
||||
|
||||
$redirect_uri = url('test/test2');
|
||||
$Testexample = new Testexample();
|
||||
$res = $Testexample->getTokenByCode($code,$redirect_uri);
|
||||
if($res['code'] != 200){
|
||||
return $this->error('授权失败.'.$res['msg']);
|
||||
}
|
||||
$data = json_decode($res['data']);
|
||||
$auth_data = [
|
||||
'access_token'=>$data['access_token'],
|
||||
'aliid'=>$data['aliId'],
|
||||
'expires_in'=>$data['expires_in'],
|
||||
'memberid'=>$data['memberId'],
|
||||
'refresh_token'=>$data['refresh_token'],
|
||||
'refresh_token_timeout'=>$data['refresh_token_timeout'],
|
||||
'resource_owner'=>$data['resource_owner'],
|
||||
];
|
||||
//写入数据库
|
||||
Mmodel::existsUpdateInsert(TabConf::$fa_alibaba_user_auth,['access_token'=>$data['access_token']],$auth_data);
|
||||
return '授权成功';
|
||||
}
|
||||
|
||||
//function getCode(){
|
||||
// return Mmodel::catchJson(function (){
|
||||
// //保存code
|
||||
// $code = input('code');
|
||||
//
|
||||
// });
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/25} {0:41}
|
||||
*/
|
||||
|
||||
namespace app\index\logic\alibabanotify;
|
||||
|
||||
|
||||
use app\index\logic\BaseLogic;
|
||||
|
||||
class BaseAlibabaLogic extends BaseLogic
|
||||
{
|
||||
|
||||
//接收消息成功后,只要响应http code是200,则认为消息消费成功
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/25} {1:04}
|
||||
*/
|
||||
|
||||
namespace app\index\logic\alibabanotify;
|
||||
|
||||
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
class LogisticsNotify extends BaseAlibabaLogic
|
||||
{
|
||||
/**
|
||||
* 物流单状态变更(买家视角)
|
||||
*/
|
||||
function logistics_buyer_view_trace($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 物流单号修改消息
|
||||
*/
|
||||
function logistics_mail_no_change($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/25} {0:37}
|
||||
*/
|
||||
namespace app\index\logic\alibabanotify;
|
||||
|
||||
use app\index\logic\BaseLogic;
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
class OrderNotify extends BaseAlibabaLogic
|
||||
{
|
||||
/**
|
||||
* desc:1688创建订单(买家视角)/order created (buyer view)
|
||||
* author:wh
|
||||
* @return array
|
||||
*/
|
||||
function order_buyer_view_buyer_make($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:1688交易成功(卖家视角)
|
||||
* author:wh
|
||||
*/
|
||||
function order_buyer_view_order_success($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单批量支付状态同步消息
|
||||
*/
|
||||
function order_batch_pay($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688交易付款(买家视角)/1688 transaction payment (buyer view)
|
||||
*/
|
||||
function order_buyer_view_order_pay($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688卖家关闭订单(买家视角)/seller closing order (buyer view)
|
||||
*/
|
||||
function order_buyer_view_order_seller_close($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688修改订单价格(买家视角)/order price modification (buyer view)
|
||||
*/
|
||||
function order_buyer_view_order_price_modify($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单发货(买家视角)/1688 order delivery (buyer view)
|
||||
*/
|
||||
function order_buyer_view_announce_sendgoods($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单部分发货(买家视角)/Partial delivery of 1688 order (buyer view)
|
||||
*/
|
||||
function order_buyer_view_part_part_sendgoods($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 商家修改订单地址(买家视角)
|
||||
*/
|
||||
function order_buyer_view_order_seller_modify_adress($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单售中退款(买家视角)
|
||||
*/
|
||||
function order_buyer_view_order_buyer_refund_in_sales($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单售后退款(买家视角)
|
||||
*/
|
||||
function order_buyer_view_order_refund_after_sales($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688买家关闭订单(买家视角)/buyer closing order (buyer view)
|
||||
*/
|
||||
function order_buyer_view_order_buyer_close($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688订单确认收货(买家视角)/order receipt confirmation (buyer view)
|
||||
*/
|
||||
function order_buyer_view_order_comfirm_receivegoods($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/25} {1:06}
|
||||
*/
|
||||
|
||||
namespace app\index\logic\alibabanotify;
|
||||
|
||||
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
class ProductNotify extends BaseAlibabaLogic
|
||||
{
|
||||
/**
|
||||
* 1688产品审核下架(关系用户视角)
|
||||
*/
|
||||
function product_relation_view_product_audit($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688产品删除(关系用户视角)
|
||||
*/
|
||||
function product_relation_view_product_delete($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688产品新增或修改(关系用户视角)
|
||||
*/
|
||||
function product_relation_view_product_new_or_modify($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688产品上架(关系用户视角)
|
||||
*/
|
||||
function product_relation_view_product_repost($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688商品库存变更消息(关系用户视角)
|
||||
*/
|
||||
function product_product_inventory_change($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 精选货源商品下架消息
|
||||
*/
|
||||
function product_pft_offer_quit($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 精选货源商品价格变动消息
|
||||
*/
|
||||
function product_pft_offer_price_modify($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 1688产品下架(关系用户视角)
|
||||
*/
|
||||
function product_relation_view_product_expire($message_data){
|
||||
return Mmodel::catch(function ()use($message_data){
|
||||
Tools::log_to_write_txt([__FUNCTION__.'消息入参:'=>$message_data]);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
## 阿里巴巴开放平台消息通知模板
|
||||
|
||||
|
||||
### 特别说明
|
||||
#### Alibaba.php是控制器类(复制可用),是消息通道httpCallback的回调地址类文件。
|
||||
##### eg:http://www.xxx.com/index/alibaba/notify
|
||||
##### 回调地址配置入口:https://open.1688.com/develop/app/detail?spm=a260s.develop-app-list.0.0.4d875bfaS5YzoD&appkey=7571564&appKey=7571564
|
||||
进入页面后找到“日常消息测试”按钮,点击后在弹出的界面中进行配置。
|
||||
### 文件说明
|
||||
#### 按照消息类型前缀分类(复制可用)
|
||||
1. 订单相关 OrderNotify.php
|
||||
2. 产品相关 ProductNotify.php
|
||||
3. 物流相关 LogisticsNotify.php
|
||||
4. 售后相关
|
||||
|
||||
......以此类推,消息类型的小写就是类的方法名。
|
||||
|
||||
这里只是打个样,这几个模板可以直接复制,补充上自己的业务逻辑即可。
|
||||
@@ -26,7 +26,7 @@ class StrictOrder extends BaseStrict
|
||||
//发票信息
|
||||
private $invoice = [];
|
||||
//交易类型 由于不同的商品支持的交易方式不同,没有一种交易方式是全局通用的,所以当前下单可使用的交易方式必须通过下单预览接口的tradeModeNameList获取。
|
||||
private $tradeType = '';
|
||||
public $tradeType = '';
|
||||
|
||||
/**
|
||||
* desc:收货地址说明
|
||||
@@ -68,10 +68,27 @@ class StrictOrder extends BaseStrict
|
||||
function setGoods($goods,$buy_num){
|
||||
$this->goods = [
|
||||
'offerId'=>$goods['offerid'],
|
||||
'specId'=>$goods['specid'],//商品规格id
|
||||
'quantity'=>$buy_num,//$goods['quantity'],//商品数量(计算金额用)
|
||||
|
||||
];
|
||||
if(!empty($goods['specid'])){
|
||||
$this->goods['specId'] = $goods['specid'];//商品规格id
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:设置发票信息
|
||||
* author:wh
|
||||
*/
|
||||
function setInvoice(array $invoice){
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:设置发票信息
|
||||
* author:wh
|
||||
*/
|
||||
function setInvoice(array $invoice){
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
/**
|
||||
* desc:创建分销订单
|
||||
@@ -95,6 +112,8 @@ class StrictOrder extends BaseStrict
|
||||
if(empty($this->tradeType)){
|
||||
throw new Exception('交易类型必须');
|
||||
}
|
||||
//由于不同的商品支持的交易方式不同,没有一种交易方式是全局通用的,
|
||||
//所以当前下单可使用的交易方式必须通过下单预览接口的tradeModeNameList获取。
|
||||
$request_data = ['tradeType'=>$this->tradeType];
|
||||
|
||||
//boutiquefenxiao(新分销严选)
|
||||
@@ -247,4 +266,153 @@ class StrictOrder extends BaseStrict
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表查看(买家视角)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.getBuyerOrderList-1&aopApiCategory=trade_new
|
||||
*
|
||||
*/
|
||||
function getOrderList($queryParams=[],$page=1,$pageSize=20){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.getSellerOrderList/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['page'] = $page;
|
||||
$request_data['pageSize'] = $pageSize;
|
||||
|
||||
//业务类型,支持: "cn"(普通订单类型), "ws"(大额批发订单类型), "yp"(普通拿样订单类型), "yf"(一分钱拿样订单类型),
|
||||
// "fs"(倒批(限时折扣)订单类型), "cz"(加工定制订单类型), "ag"(协议采购订单类型), "hp"(伙拼订单类型),
|
||||
// "gc"(国采订单类型), "supply"(供销订单类型), "nyg"(nyg订单类型), "factory"(淘工厂订单类型),
|
||||
// "quick"(快订下单), "xiangpin"(享拼订单), "nest"(采购商城-鸟巢), "f2f"(当面付), "cyfw"(存样服务),
|
||||
// "sp"(代销订单标记), "wg"(微供订单), "factorysamp"(淘工厂打样订单), "factorybig"(淘工厂大货订单)
|
||||
if(isset($queryParams['bizTypes'])){
|
||||
$request_data['bizTypes'] = $queryParams['bizTypes'];
|
||||
}
|
||||
//下单开始时间 20180802211113000+0800
|
||||
if(isset($queryParams['createStartTime'])){
|
||||
$request_data['createStartTime'] = $queryParams['createStartTime'];
|
||||
}
|
||||
//下单结束时间 20180802211113000+0800
|
||||
if(isset($queryParams['createEndTime'])){
|
||||
$request_data['createEndTime'] = $queryParams['createEndTime'];
|
||||
}
|
||||
//是否查询历史订单表,默认查询当前表,即默认值为false
|
||||
if(isset($queryParams['isHis'])){
|
||||
$request_data['isHis'] = $queryParams['isHis'];
|
||||
}
|
||||
//查询修改时间结束 20180802211113000+0800
|
||||
if(isset($queryParams['modifyStartTime'])){
|
||||
$request_data['modifyStartTime'] = $queryParams['modifyStartTime'];
|
||||
}
|
||||
//查询修改时间结束 20180802211113000+0800
|
||||
if(isset($queryParams['modifyEndTime'])){
|
||||
$request_data['modifyEndTime'] = $queryParams['modifyEndTime'];
|
||||
}
|
||||
//订单状态,值有 success, cancel(交易取消,违约金等交割完毕), waitbuyerpay(等待卖家付款),
|
||||
// waitsellersend(等待卖家发货),waitbuyerreceive(等待买家收货 )
|
||||
if(isset($queryParams['orderStatus'])){
|
||||
$request_data['orderStatus'] = $queryParams['orderStatus'];
|
||||
}
|
||||
//查询分页页码,从1开始
|
||||
//if(isset($queryParams['page'])){
|
||||
// $request_data['page'] = $queryParams['page'];
|
||||
//}
|
||||
////查询的每页的数量 20
|
||||
//if(isset($queryParams['pageSize'])){
|
||||
// $request_data['pageSize'] = $queryParams['pageSize'];
|
||||
//}
|
||||
//退款状态,支持: "waitselleragree"(等待卖家同意), "refundsuccess"(退款成功), "refundclose"(退款关闭),
|
||||
// "waitbuyermodify"(待买家修改), "waitbuyersend"(等待买家退货), "waitsellerreceive"(等待卖家确认收货)
|
||||
if(isset($queryParams['refundStatus'])){
|
||||
$request_data['refundStatus'] = $queryParams['refundStatus'];
|
||||
}
|
||||
//卖家memberId b2b-1624961198
|
||||
if(isset($queryParams['sellerMemberId'])){
|
||||
$request_data['sellerMemberId'] = $queryParams['sellerMemberId'];
|
||||
}
|
||||
//卖家loginId alitestforisv02
|
||||
if(isset($queryParams['sellerLoginId'])){
|
||||
$request_data['sellerLoginId'] = $queryParams['sellerLoginId'];
|
||||
}
|
||||
//卖家评价状态 (4:已评价,5:未评价,6;不需要评价)
|
||||
if(isset($queryParams['sellerRateStatus'])){
|
||||
$request_data['sellerRateStatus'] = $queryParams['sellerRateStatus'];
|
||||
}
|
||||
//交易类型: 担保交易(1), 预存款交易(2), ETC境外收单交易(3), 即时到帐交易(4), 保障金安全交易(5), 统一交易流程(6),
|
||||
// 分阶段交易(7), 货到付款交易(8), 信用凭证支付交易(9), 账期支付交易(10), 1688交易4.0,新分阶段交易(50060),
|
||||
// 当面付的交易流程(50070), 服务类的交易流程(50080)
|
||||
if(isset($queryParams['tradeType'])){
|
||||
$request_data['tradeType'] = $queryParams['tradeType'];
|
||||
}
|
||||
//商品名称
|
||||
if(isset($queryParams['productName'])){
|
||||
$request_data['productName'] = $queryParams['productName'];
|
||||
}
|
||||
//是否需要查询买家的详细地址信息和电话 false
|
||||
if(isset($queryParams['needBuyerAddressAndPhone'])){
|
||||
$request_data['needBuyerAddressAndPhone'] = $queryParams['needBuyerAddressAndPhone'];
|
||||
}
|
||||
//是否需要查询备注信息 false
|
||||
if(isset($queryParams['needMemoInfo'])){
|
||||
$request_data['needMemoInfo'] = $queryParams['needMemoInfo'];
|
||||
}
|
||||
//外部订单号,可用于控制幂等 90187872898371
|
||||
if(isset($queryParams['outOrderId'])){
|
||||
$request_data['outOrderId'] = $queryParams['outOrderId'];
|
||||
}
|
||||
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* 订单详情查看(买家视角)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.get.buyerView-1&aopApiCategory=trade_new
|
||||
*/
|
||||
function getBuyerView(int $orderId,$webSite='1688',$includeFields='',$attributeKeys='',$outOrderId=''){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.get.buyerView/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['orderId'] = $orderId;//交易的订单id 1234345
|
||||
$request_data['webSite'] = $webSite;//站点信息,指定调用的API是属于国际站(alibaba)还是1688网站(1688)
|
||||
$request_data['includeFields'] = $includeFields;//查询结果中包含的域,GuaranteesTerms:保障条款,NativeLogistics:物流信息,RateDetail:评价详情,OrderInvoice:发票信息。默认返回GuaranteesTerms、NativeLogistics、OrderInvoice。
|
||||
$request_data['attributeKeys'] = $attributeKeys;//垂直表中的attributeKeys
|
||||
$request_data['outOrderId'] = $outOrderId;//外部订单id,控制幂等
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交易订单的物流信息(买家视角)
|
||||
*
|
||||
* 该接口需要获得订单买家的授权,获取买家的订单的物流详情,在采购或者分销场景中,作为买家也有获取物流详情的需求。
|
||||
* 该接口能查能根据订单号查看物流详情,包括发件人,收件人,所发货物明细等。由于物流单录入的原因,
|
||||
* 可能跟踪信息的API查询会有延迟。该API需要向开放平台申请权限才能访问。
|
||||
*
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.logistics:alibaba.trade.getLogisticsInfos.buyerView-1&aopApiCategory=Logistics_NEW
|
||||
*/
|
||||
function getLogisticsInfosBuyerView(int $orderId,$webSite='1688',$fields=''){
|
||||
$urlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['orderId'] = $orderId;//交易的订单id 1234345
|
||||
$request_data['webSite'] = $webSite;//站点信息,指定调用的API是属于国际站是1688业务还是icbu业务 (1688或者alibaba)
|
||||
$request_data['fields'] = $fields;//需要返回的字段,目前有:company.name,sender,receiver,sendgood。返回的字段要用英文逗号分隔开
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* 获取交易订单的物流跟踪信息(买家视角)
|
||||
*
|
||||
* 该接口需要获取订单买家的授权,获取买家的订单的物流跟踪信息,在采购或者分销场景中,作为买家也有获取物流详情的需求。
|
||||
* 该接口能查能根据物流单号查看物流单跟踪信息。由于物流单录入的原因,可能跟踪信息的API查询会有延迟。
|
||||
* 该API需要向开放平台申请权限才能访问。
|
||||
*
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.logistics:alibaba.trade.getLogisticsTraceInfo.buyerView-1&aopApiCategory=Logistics_NEW
|
||||
*/
|
||||
function getLogisticsTraceInfoBuyerView(int $orderId,$webSite='1688',$logisticsId=''){
|
||||
$urlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['orderId'] = $orderId;//交易的订单id 1234345
|
||||
$request_data['webSite'] = $webSite;//站点信息,指定调用的API是属于国际站是1688业务还是ic
|
||||
$request_data['logisticsId'] = $logisticsId;//该订单下的物流编号 AL8234243
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,4 +30,34 @@ class StrictPay extends BaseStrict
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* desc:查询订单可以支持的支付渠道
|
||||
* author:wh
|
||||
* @param string $order_id
|
||||
*/
|
||||
function queryOrderPayChannel(string $order_id){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.payWay.query/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['orderId'] = $order_id;
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:组合收银台url获取
|
||||
* author:wh
|
||||
* @param string $orderIds 订单列表 格式参考 字符串格式的数组:["123456789","123456789"]
|
||||
* @param string $payPlatformType PC或WIRELESS
|
||||
* @return mixed
|
||||
*/
|
||||
function getPayUrl(string $orderIds,string $payPlatformType){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.grouppay.url.get/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['orderIds'] = $orderIds;//json_encode($orderIds);
|
||||
$request_data['payPlatformType'] = $payPlatformType;//PC或WIRELESS
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/23} {22:57}
|
||||
*/
|
||||
|
||||
namespace wanghua\general_utility_tools_php\alibaba\distributes\strict;
|
||||
|
||||
|
||||
use wanghua\general_utility_tools_php\alibaba\distributes\BaseStrict;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
class StrictRefund extends BaseStrict
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建退款退货申请
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.createRefund-1
|
||||
*/
|
||||
function createRefund($params){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.createRefund/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
|
||||
//主订单
|
||||
if(empty($params['orderId'])){
|
||||
return Tools::set_fail('orderId不能为空');
|
||||
}
|
||||
$request_data['orderId'] = $params['orderId'];
|
||||
//子订单 订单接口 productItems- subItemID 就是子订单ID,
|
||||
// 卖家拒绝退款后无法重新申请,需要到1688后台退款单页面 修改退款协议
|
||||
if(empty($params['orderEntryIds'])){
|
||||
return Tools::set_fail('orderEntryIds不能为空');
|
||||
}
|
||||
$request_data['orderEntryIds'] = $params['orderEntryIds'];
|
||||
//退款/退款退货。只有已收到货,才可以选择退款退货 退款:"refund"; 退款退货:"returnRefund"
|
||||
if(empty($params['disputeRequest'])){
|
||||
return Tools::set_fail('disputeRequest不能为空');
|
||||
}
|
||||
$request_data['disputeRequest'] = $params['disputeRequest'];
|
||||
//退款金额(单位:分)。不大于实际付款金额;等待卖家发货时,必须为商品的实际付款金额。
|
||||
if(empty($params['applyPayment'])){
|
||||
return Tools::set_fail('applyPayment不能为空');
|
||||
}
|
||||
$request_data['applyPayment'] = $params['applyPayment'];
|
||||
//退运费金额(单位:分)。
|
||||
if(empty($params['applyCarriage'])){
|
||||
return Tools::set_fail('applyCarriage不能为空');
|
||||
}
|
||||
$request_data['applyCarriage'] = $params['applyCarriage'];
|
||||
//退款原因id(从API getRefundReasonList获取)
|
||||
if(empty($params['applyReasonId'])){
|
||||
return Tools::set_fail('applyReasonId不能为空');
|
||||
}
|
||||
$request_data['applyReasonId'] = $params['applyReasonId'];
|
||||
//退款申请理由,2-150字
|
||||
if(empty($params['description'])){
|
||||
return Tools::set_fail('description不能为空');
|
||||
}
|
||||
$request_data['description'] = $params['description'];
|
||||
//货物状态 售中等待卖家发货:"refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive";
|
||||
// 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived";
|
||||
// 售后已收到货:"aftersaleBuyerReceived"
|
||||
if(empty($params['goodsStatus'])){
|
||||
return Tools::set_fail('goodsStatus不能为空');
|
||||
}
|
||||
$request_data['goodsStatus'] = $params['goodsStatus'];
|
||||
//凭证图片URLs。1-5张,必须使用API uploadRefundVoucher返回的“图片域名/相对路径”
|
||||
if(isset($params['vouchers'])){
|
||||
$request_data['vouchers'] = $params['vouchers'];
|
||||
}
|
||||
//子订单退款数量。仅在售中买家已收货(退款退货)时,可指定退货数量;默认,全部退货。[{"id":586683458996743215,"count":1}]
|
||||
if(isset($params['orderEntryCountList'])){
|
||||
$request_data['orderEntryCountList'] = $params['orderEntryCountList'];
|
||||
}
|
||||
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款退货原因(用于创建退款退货)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.getRefundReasonList-1
|
||||
*/
|
||||
function getRefundReasonList(int $orderId,$orderEntryIds,$goodsStatus){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.getRefundReasonList/".$this->authObj->config['appkey'];
|
||||
|
||||
$request_data = [];
|
||||
$request_data['orderId'] = $orderId;//主订单id 1234345
|
||||
$request_data['orderEntryIds'] = $orderEntryIds;//子订单id Long[]
|
||||
//售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive";
|
||||
// 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived";
|
||||
// 售后已收到货:"aftersaleBuyerReceived"
|
||||
$request_data['goodsStatus'] = $goodsStatus;//货物状态
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 【可在前端通过表单提交】
|
||||
*
|
||||
* 上传退款退货凭证
|
||||
*
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.uploadRefundVoucher-1
|
||||
*/
|
||||
function uploadRefundVoucher($imageData){
|
||||
//$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.uploadRefundVoucher/".$this->authObj->config['appkey'];
|
||||
//$request_data = [];
|
||||
//$request_data['imageData'] = $imageData;//凭证图片数据。小于1M,jpg格式。
|
||||
//$res = $this->authObj->request($urlPath, $request_data);
|
||||
//return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款单列表(买家视角)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.refund.buyer.queryOrderRefundList-1&aopApiCategory=trade_new
|
||||
* 买家查看退款单列表,该接口不支持子账号查询,请使用主账号授权后查询
|
||||
*/
|
||||
function queryOrderRefundList($params){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.buyer.queryOrderRefundList/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
//订单Id
|
||||
if(isset($params['orderId'])){
|
||||
$request_data['orderId'] = $params['orderId'];
|
||||
}
|
||||
//退款申请时间(起始) 20220926114526000+0800
|
||||
if(isset($params['applyStartTime'])){
|
||||
$request_data['applyStartTime'] = $params['applyStartTime'];
|
||||
}
|
||||
//退款申请时间(截止) 20220926114526000+0800
|
||||
if(isset($params['applyEndTime'])){
|
||||
$request_data['applyEndTime'] = $params['applyEndTime'];
|
||||
}
|
||||
//退款状态列表 等待卖家同意 waitselleragree;退款成功 refundsuccess;退款关闭 refundclose;
|
||||
//待买家修改 waitbuyermodify;等待买家退货 waitbuyersend;等待卖家确认收货 waitsellerreceive
|
||||
if(isset($params['refundStatusSet'])){
|
||||
$request_data['refundStatusSet'] = $params['refundStatusSet'];
|
||||
}
|
||||
//卖家memberId
|
||||
if(isset($params['sellerMemberId'])){
|
||||
$request_data['sellerMemberId'] = $params['sellerMemberId'];
|
||||
}
|
||||
//当前页码
|
||||
if(isset($params['currentPageNum'])){
|
||||
$request_data['currentPageNum'] = $params['currentPageNum'];
|
||||
}
|
||||
//每页条数
|
||||
if(isset($params['pageSize'])){
|
||||
$request_data['pageSize'] = $params['pageSize'];
|
||||
}
|
||||
//退货物流单号(传此字段查询时,需同时传入sellerMemberId)
|
||||
if(isset($params['logisticsNo'])){
|
||||
$request_data['logisticsNo'] = $params['logisticsNo'];
|
||||
if(empty($params['sellerMemberId'])){
|
||||
return Tools::set_fail('logisticsNo必须与sellerMemberId同时传入');
|
||||
}
|
||||
}
|
||||
//退款修改时间(起始) 20220926114526000+0800
|
||||
if(isset($params['modifyStartTime'])){
|
||||
$request_data['modifyStartTime'] = $params['modifyStartTime'];
|
||||
}
|
||||
//退款修改时间(截止) 20220926114526000+0800
|
||||
if(isset($params['modifyEndTime'])){
|
||||
$request_data['modifyEndTime'] = $params['modifyEndTime'];
|
||||
}
|
||||
//1:售中退款,2:售后退款;0:所有退款单
|
||||
if(isset($params['dipsuteType'])){
|
||||
$request_data['dipsuteType'] = $params['dipsuteType'];
|
||||
}
|
||||
|
||||
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款单详情-根据订单ID(买家视角)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.refund.OpQueryBatchRefundByOrderIdAndStatus-1&aopApiCategory=trade_new
|
||||
*/
|
||||
function queryBatchRefundByOrderIdAndStatus(int $orderId,string $queryType){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.OpQueryBatchRefundByOrderIdAndStatus/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
//订单Id
|
||||
$request_data['orderId'] = $orderId;
|
||||
//查询类型 1:活动;3:退款成功(只支持退款中和退款成功)
|
||||
$request_data['queryType'] = $queryType;
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款单操作记录列表(买家视角)
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.refund.OpQueryOrderRefundOperationList-1
|
||||
*/
|
||||
function queryOrderRefundOperationList(string $refundId,$pageNo=1,$pageSize=100){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefundOperationList/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['refundId'] = $refundId;
|
||||
$request_data['pageNo'] = $pageNo;
|
||||
$request_data['pageSize'] = $pageSize;
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* 买家提交退款货信息
|
||||
* https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade:alibaba.trade.refund.returnGoods-1
|
||||
*/
|
||||
function buyerSubmitRefundGoodsInfo(string $refundId,string $logisticsCompanyNo,string $freightBill,string $description='',string $vouchers=''){
|
||||
$urlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.returnGoods/".$this->authObj->config['appkey'];
|
||||
$request_data = [];
|
||||
$request_data['refundId'] = $refundId;
|
||||
$request_data['logisticsCompanyNo'] = $logisticsCompanyNo;
|
||||
$request_data['freightBill'] = $freightBill;
|
||||
if($description){
|
||||
$request_data['description'] = $description;//发货说明,内容在2-200个字之间
|
||||
}
|
||||
//凭证图片URLs,必须使用API alibaba.trade.uploadRefundVoucher返回的“图片域名/相对路径”,
|
||||
//最多可上传 10 张图片 ;单张大小不超过1M;支持jpg、gif、jpeg、png、和bmp格式。
|
||||
// 请上传凭证,以便以后续赔所需(不上传将无法理赔)
|
||||
if($vouchers){
|
||||
$request_data['vouchers'] = $vouchers;//[https://cbu01.alicdn.com/img/ibank/2019/901/930/11848039109.jpg]
|
||||
}
|
||||
$res = $this->authObj->request($urlPath, $request_data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,6 @@ class Ip
|
||||
* @return bool
|
||||
*/
|
||||
function qihuBaidu($ip){
|
||||
$url = 'https://qifu.baidu.com/ip/geo/v1/district?ip='.$ip;
|
||||
if($this->isPrivateIP($ip)){
|
||||
return true;//国内
|
||||
}
|
||||
@@ -92,21 +91,24 @@ class Ip
|
||||
if($this->getRecord($ip)){
|
||||
return false;
|
||||
}
|
||||
$res = Curl::curl_get($url);
|
||||
|
||||
|
||||
|
||||
$res = $this->curl_get($ip);
|
||||
if($res['code'] == 200){//请求成功
|
||||
if(empty($res['data'])){
|
||||
Tools::log_to_write_txt(['error'=>'IP查询,curl结果为空','$res'=>$res,'$url'=>$url]);
|
||||
Tools::log_to_write_txt(['error'=>'IP查询,curl结果为空','$res'=>$res]);
|
||||
}
|
||||
//校验ip属地
|
||||
$data = json_decode($res['data'],true);
|
||||
if($data['code'] != 'Success'){//查询失败
|
||||
Tools::log_to_write_txt(['error'=>'IP查询成功,但结果返回为失败.','$res'=>$res,'$url'=>$url]);
|
||||
Tools::log_to_write_txt(['error'=>'IP查询成功,但结果返回为失败.','$res'=>$res]);
|
||||
return true;
|
||||
}
|
||||
//查询成功
|
||||
if(empty($data['data']['country'])){
|
||||
//country为空时默认为国内
|
||||
Tools::log_to_write_txt(['error'=>'IP查询成功,但country返回为空.','$res'=>$res,'$url'=>$url]);
|
||||
Tools::log_to_write_txt(['error'=>'IP查询成功,但country返回为空.','$res'=>$res]);
|
||||
return true;
|
||||
}
|
||||
if($data['data']['country'] == '中国'){
|
||||
@@ -117,11 +119,11 @@ class Ip
|
||||
$this->insertRecord($ip,$data['data']['continent'].' '.$data['data']['prov'],$data['data']['country'],'no');
|
||||
//缓存ip地址
|
||||
cache($ip,'no');//国外
|
||||
Tools::log_to_write_txt(['ip地址不在中国内,禁止访问:'.$ip,'curl data'=>$res['data'],'$url'=>$url]);
|
||||
Tools::log_to_write_txt(['ip地址不在中国内,禁止访问:'.$ip,'curl data'=>$res['data']]);
|
||||
//return redirect($this->redirect_url);
|
||||
return false;
|
||||
}
|
||||
Tools::log_to_write_txt(['error'=>'IP查询,curl请求失败.','$res'=>$res,'$url'=>$url]);
|
||||
Tools::log_to_write_txt(['error'=>'IP查询,curl请求失败.','$res'=>$res]);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@@ -226,4 +228,47 @@ class Ip
|
||||
->field('id,is_china')
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* desc:curl
|
||||
* author:wh
|
||||
* @param $ip
|
||||
* @return array
|
||||
*/
|
||||
function curl_get($ip){
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://qifu.baidu.com/ip/geo/v1/district?ip='.$ip,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => 'CURL_HTTP_VERSION_1_1',
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'User-Agent: Apifox/1.0.0 (https://apifox.com)',
|
||||
'Accept: */*',
|
||||
'Host: qifu.baidu.com',
|
||||
'Connection: keep-alive'
|
||||
),
|
||||
));
|
||||
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
$data = curl_exec($curl);
|
||||
|
||||
// 显示错误信息
|
||||
if (curl_error($curl)) {
|
||||
//print "Error: ".curl_errno($curl).'-' . curl_error($curl);
|
||||
//返回错误码
|
||||
return ['code' => curl_errno($curl), 'msg' => curl_error($curl)];
|
||||
} else {
|
||||
//关闭句柄
|
||||
curl_close($curl);
|
||||
// 返回的内容
|
||||
return ['code' => 200, 'msg' => 'cURL ok', 'data' => $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user