Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 954de121b8 | |||
| 9c5a962c70 | |||
| c221f8f9ae |
@ -7,7 +7,6 @@ use App\Http\Resources\ShopsResource;
|
||||
use App\Models\Shop;
|
||||
use App\Models\ShopSender;
|
||||
use App\Models\ShopShip;
|
||||
use App\Services\Business\KuaiTuanTuan\FaceSheet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ use App\Models\GoodsSku;
|
||||
use App\Models\Shop;
|
||||
use App\Http\Resources\ShopsResource;
|
||||
use App\Models\ShopSender;
|
||||
use App\Models\ShopShip;
|
||||
use App\Services\Business\KuaiTuanTuan\FaceSheet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -228,18 +227,11 @@ class ShopsController extends Controller
|
||||
|
||||
public function pddPrintAuth(Request $request)
|
||||
{
|
||||
[$shopId, $platId] = explode('_', $request->get('state'));
|
||||
[$shopId, $type] = explode('_', $request->get('state'));
|
||||
$faceSheet = new FaceSheet();
|
||||
$faceSheet->setCode($request->get('code'));
|
||||
$faceSheet->setShopWithId($shopId);
|
||||
$faceSheet->auth('ship');
|
||||
$shopShip = ShopShip::query()
|
||||
->where('shop_id', $shopId)
|
||||
->first();
|
||||
if (empty($shopShip)) {
|
||||
exit();
|
||||
}
|
||||
$faceSheet->setShop($shopShip);
|
||||
$shopShip = $faceSheet->auth('ship', $type);
|
||||
$resp = $faceSheet->searchWayBill();
|
||||
if (!isset($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'])) {
|
||||
exit();
|
||||
|
||||
@ -8,7 +8,7 @@ class ShopShip extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function shop()
|
||||
public function shop()
|
||||
{
|
||||
return $this->belongsTo(Shop::class, 'shop_id', 'id');
|
||||
}
|
||||
@ -32,6 +32,16 @@ class ShopShip extends Model
|
||||
return $value ? date('Y-m-d H:i:s', $value) : '';
|
||||
}
|
||||
|
||||
public function getTypeAttribute($value)
|
||||
{
|
||||
$map = [
|
||||
'normal' => '电商标快',
|
||||
'air' => '空运',
|
||||
];
|
||||
|
||||
return $map[$value];
|
||||
}
|
||||
|
||||
public function senders()
|
||||
{
|
||||
return $this->hasMany(ShopSender::class, 'shop_ship_id');
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@ -12,7 +11,6 @@ class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
use HasRoles;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@ -31,7 +31,7 @@ class KuaiTuanTuan extends BusinessClient
|
||||
'sign' => ''
|
||||
];
|
||||
|
||||
public function auth($type = 'ktt')
|
||||
public function auth($type = 'ktt', $shipType = 'normal')
|
||||
{
|
||||
$accessToken = $this->getAccessTokenWithCode();
|
||||
$accessToken['scope'] = json_encode($accessToken['scope'], 256);
|
||||
@ -42,8 +42,8 @@ class KuaiTuanTuan extends BusinessClient
|
||||
}
|
||||
if ('ship' === $type) {
|
||||
unset($accessToken['r1_expires_at'], $accessToken['r1_expires_in'], $accessToken['r2_expires_at'], $accessToken['r2_expires_in'], $accessToken['w1_expires_at'], $accessToken['w1_expires_in'], $accessToken['w2_expires_at'], $accessToken['w2_expires_in'], $accessToken['request_id']);
|
||||
ShopShip::query()->updateOrCreate(
|
||||
['shop_id' => $this->shop->id],
|
||||
$this->shop = ShopShip::query()->updateOrCreate(
|
||||
['shop_id' => $this->shop->id, 'type' => $shipType],
|
||||
$accessToken
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTypeToShopShipsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumns('shop_ships', ['type'])) {
|
||||
return;
|
||||
}
|
||||
Schema::table('shop_ships', function (Blueprint $table) {
|
||||
$table->string('type')->default('normal')->comment('账户类型normal-普通,air-空运');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('shop_ships', function (Blueprint $table) {
|
||||
$table->dropColumn(['type']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddCodeToWaybillsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumns('waybills', ['code'])) {
|
||||
return;
|
||||
}
|
||||
Schema::table('waybills', function (Blueprint $table) {
|
||||
$table->integer('code')->default(247)->comment('247-电商标快,266-空运');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('waybills', function (Blueprint $table) {
|
||||
$table->dropColumn(['code']);
|
||||
});
|
||||
}
|
||||
}
|
||||
4
public/dist/js/107.4ae2ec64.js
vendored
Normal file
4
public/dist/js/107.4ae2ec64.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/dist/js/107.4ae2ec64.js.map
vendored
Normal file
1
public/dist/js/107.4ae2ec64.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/dist/js/app.65f96f26.js
vendored
Normal file
2
public/dist/js/app.65f96f26.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/dist/js/app.65f96f26.js.map
vendored
Normal file
1
public/dist/js/app.65f96f26.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,33 +1,44 @@
|
||||
<template>
|
||||
<div class="conent">
|
||||
<div>
|
||||
<el-button type="primary" @click="addAuthVisible = true">新增授权</el-button>
|
||||
</div>
|
||||
|
||||
<div class="table" style="margin-top: 10px">
|
||||
<el-table v-loading="loading" :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="name" label="店铺名称"></el-table-column>
|
||||
<el-table-column prop="ship.expires_at" label="授权过期时间点"></el-table-column>
|
||||
<el-table-column prop="ship.owner_id" label="商家店铺id"></el-table-column>
|
||||
<el-table-column prop="ship.owner_name" label="商家账号名称"></el-table-column>
|
||||
<el-table-column prop="shop.name" label="店铺名称"></el-table-column>
|
||||
<el-table-column prop="type" label="账户类型"></el-table-column>
|
||||
<el-table-column prop="expires_at" label="授权过期时间点"></el-table-column>
|
||||
<el-table-column prop="owner_id" label="商家店铺id"></el-table-column>
|
||||
<el-table-column prop="owner_name" label="商家账号名称"></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="danger" v-if="scope.row.status === '未授权'" size="small">
|
||||
<a :href="scope.row.authUrl" target="_blank" rel="noopener noreferrer">授权</a>
|
||||
</el-button>
|
||||
|
||||
<template v-if="scope.row.status === '已授权'">
|
||||
<el-button type="success" :disabled="true" size="small">{{ scope.row.status }}</el-button>
|
||||
</template>
|
||||
<template v-if="scope.row.status === '重新授权'">
|
||||
<el-button type="danger" target="_blank" size="small">
|
||||
<a :href="scope.row.authUrl" rel="noopener noreferrer">重新授权</a>
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<el-button v-if="scope.row.ship" type="info" @click="getSenders(scope.row)"
|
||||
size="small">发货信息</el-button>
|
||||
<el-button type="info" @click="getSenders(scope.row)" size="small">发货信息</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 新增授权 -->
|
||||
<el-dialog title="新增授权" :visible.sync="addAuthVisible" :close-on-click-modal="false" width="20%">
|
||||
<el-form :model="authForm" label-width="80px">
|
||||
<el-form-item label="店铺">
|
||||
<el-select v-model="authForm.shop_id" placeholder="请选择店铺">
|
||||
<el-option v-for="item in shops" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="账户类型">
|
||||
<el-radio-group v-model="authForm.type">
|
||||
<el-radio label="normal">电商标快</el-radio>
|
||||
<el-radio label="air">空运</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="authBtn()">授权</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 发货信息 -->
|
||||
<el-dialog title="发货信息" :visible.sync="dialogVisible" :close-on-click-modal="false">
|
||||
@ -78,7 +89,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { shipList, ShopSenderList, saveSenders } from "../../api/shop";
|
||||
import { shipList, ShopSenderList, saveSenders, storeList } from "../../api/shop";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -86,13 +97,20 @@ export default {
|
||||
loading: true,
|
||||
tableData: [],
|
||||
dialogVisible: false,
|
||||
addAuthVisible: false,
|
||||
sendersForm: {
|
||||
senderList: []
|
||||
},
|
||||
shops: [],
|
||||
authForm: {
|
||||
shop_id: '',
|
||||
type: 'normal'
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getShipList();
|
||||
this.getShopsList();
|
||||
},
|
||||
methods: {
|
||||
getShipList() {
|
||||
@ -102,7 +120,7 @@ export default {
|
||||
this.loading = false
|
||||
},
|
||||
getSenders(row) {
|
||||
ShopSenderList(row.id, row.ship.id).then((res) => {
|
||||
ShopSenderList(row.shop_id, row.id).then((res) => {
|
||||
this.sendersForm.senderList = res.data.data;
|
||||
this.dialogVisible = true;
|
||||
})
|
||||
@ -115,6 +133,19 @@ export default {
|
||||
this.$message.error(res.data.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
getShopsList() {
|
||||
let page = {
|
||||
page: 0,
|
||||
per_page: 999,
|
||||
plat_id: 1,
|
||||
};
|
||||
storeList(page).then((res) => {
|
||||
this.shops = res.data.data;
|
||||
});
|
||||
},
|
||||
authBtn() {
|
||||
location.href = "https://wb.pinduoduo.com/logistics/auth?client_id=24f25877aca447c5830a6aa896301d5e&redirect_uri=http://erp.chutang66.com/pdd/ship&state=" + this.authForm.shop_id + '_' + this.authForm.type;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user