|
|
@@ -23,6 +23,8 @@ class DouYinService
|
|
|
{
|
|
|
protected static int $terminal = \app\common\enum\user\UserTerminalEnum::DOUYIN;
|
|
|
protected static int $external_platform_id = 6;
|
|
|
+
|
|
|
+ // ********************************* 注册登录
|
|
|
public static function register(array $params)
|
|
|
{
|
|
|
$userSn = User::createUserSn();
|
|
|
@@ -77,6 +79,33 @@ class DouYinService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // **************************** 商品管理
|
|
|
+/*/product/save/ 先调
|
|
|
+goods/sku/batch_save/ 再调
|
|
|
+
|
|
|
+生成 产品组装
|
|
|
+生成 sku 组装
|
|
|
+生成对应的 attr_key_value_map 组装*/
|
|
|
+
|
|
|
+ public static function getProductParams($type,$params)
|
|
|
+ {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ public static function getSkuParams($type,$params)
|
|
|
+ {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static function getAttrKeyValueMapParams($type,$params)
|
|
|
+ {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 提交订单
|
|
|
* @param array $params
|
|
|
@@ -505,24 +534,7 @@ class DouYinService
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- $douyinRefundOrder = DouyinRefundOrder::where('refund_number', $params['out_refund_no'])->findOrEmpty();
|
|
|
- if($douyinRefundOrder->isEmpty()){
|
|
|
- throw new \Exception('退款订单不存在');
|
|
|
- }
|
|
|
- if($douyinRefundOrder->refund_status == 0){
|
|
|
- if($params['status'] === 'SUCCESS'){
|
|
|
- $douyinRefundOrder->refund_status = 3;
|
|
|
- DouyinOrder::where('order_number', $douyinRefundOrder->order_number)->update([
|
|
|
- 'order_status' => 4,
|
|
|
- 'pay_status' => 3,
|
|
|
- ]);
|
|
|
- }elseif($params['status'] === 'FAIL'){
|
|
|
- $douyinRefundOrder->refund_status = 4;
|
|
|
- }else{
|
|
|
- throw new \Exception('退款状态未知');
|
|
|
- }
|
|
|
- $douyinRefundOrder->save();
|
|
|
- }
|
|
|
+
|
|
|
Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -566,23 +578,24 @@ class DouYinService
|
|
|
}
|
|
|
return $str;
|
|
|
}
|
|
|
- public static function getClientToken() {
|
|
|
+ public static function getClientToken($isRefresh = false) {
|
|
|
$url = config('douyin.host').'oauth/client_token/';
|
|
|
$cache_name = 'dy_client_token';
|
|
|
$cache_data = cache($cache_name);
|
|
|
- if(empty($cache_data) || $cache_data == null){
|
|
|
+ if(empty($cache_data) || $cache_data == null || $isRefresh){
|
|
|
$data = [
|
|
|
'client_key'=> config('douyin.appId'),
|
|
|
'client_secret'=> config('douyin.appSecret'),
|
|
|
'grant_type'=> "client_credential"
|
|
|
];
|
|
|
$res = http_request($url,$data,['Content-Type' => 'application/json;charset=utf-8']);
|
|
|
+ Log::info(json_encode($res));
|
|
|
if($res['message'] === 'success'){
|
|
|
cache($cache_name, json_encode($res['data']), (time()+$res['data']['expires_in']-1));
|
|
|
$cache_data = $res['data'];
|
|
|
}
|
|
|
}
|
|
|
- return json_decode($cache_data, true)['access_token'];
|
|
|
+ return $cache_data['access_token'];
|
|
|
}
|
|
|
|
|
|
|