feat: #10000 发货地址
This commit is contained in:
parent
880b8717d7
commit
0cd5af981d
@ -10,6 +10,8 @@ use App\Models\GoodsSku;
|
||||
use App\Models\GoodsType;
|
||||
use App\Models\Log;
|
||||
use App\Models\Shop;
|
||||
use App\Models\ShopSender;
|
||||
use App\Models\ShopShip;
|
||||
use App\Models\TodayPrice;
|
||||
use App\Services\Business\BusinessFactory;
|
||||
use App\Services\Business\KuaiTuanTuan\FaceSheet;
|
||||
@ -46,13 +48,74 @@ class Test extends Command
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function handle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
public function old()
|
||||
{
|
||||
$resp = [
|
||||
'pdd_waybill_search_response' => [
|
||||
'waybill_apply_subscription_cols' => [
|
||||
[
|
||||
'wp_type' => 3,
|
||||
'branch_account_cols' => [
|
||||
[
|
||||
'quantity' => 0,
|
||||
'shipp_address_cols' => [
|
||||
[
|
||||
'country' => '中国',
|
||||
'province' => '云南省',
|
||||
'city' => '昆明市',
|
||||
'district' => '官渡区',
|
||||
'detail' => '肖家营花卉市场1期-2',
|
||||
],
|
||||
[
|
||||
'country' => '中国',
|
||||
'province' => '云南省',
|
||||
'city' => '昆明市',
|
||||
'district' => '官渡区',
|
||||
'detail' => '肖家营花卉市场1期-3',
|
||||
],
|
||||
[
|
||||
'country' => '中国',
|
||||
'province' => '云南省',
|
||||
'city' => '昆明市',
|
||||
'district' => '官渡区',
|
||||
'detail' => '肖家营花卉市场1期',
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$shopId = 6;
|
||||
$shopShip = ShopShip::query()
|
||||
->where('shop_id', $shopId)
|
||||
->first();
|
||||
if (empty($shopShip)) {
|
||||
exit(1);
|
||||
}
|
||||
if (!isset($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'])) {
|
||||
exit(2);
|
||||
}
|
||||
foreach ($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'] as $subCols) {
|
||||
foreach ($subCols['branch_account_cols'] as $accountCols) {
|
||||
foreach ($accountCols['shipp_address_cols'] as $item) {
|
||||
ShopSender::query()->updateOrCreate(
|
||||
['shop_id' => $shopId, 'shop_ship_id' => $shopShip->id, 'detail' => $item['detail']],
|
||||
$item
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,11 +19,15 @@ class BusinessOrderController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$shopIds = Shop::query()
|
||||
->where('plat_id', Shop::$PLAT_KTT)
|
||||
->pluck('id');
|
||||
$builder = BusinessOrder::query()
|
||||
->with([
|
||||
'shop:id,name',
|
||||
'items:id,business_order_id,goods_name,goods_number,external_sku_id'
|
||||
])
|
||||
->whereIn('shop_id', $shopIds)
|
||||
->filter();
|
||||
$externalSkuIds = $request->get('external_sku_ids');
|
||||
if ($externalSkuIds) {
|
||||
|
||||
@ -5,9 +5,11 @@ namespace App\Http\Controllers\Shop;
|
||||
use App\Http\Controllers\Controller;
|
||||
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;
|
||||
|
||||
class ShipController extends Controller
|
||||
{
|
||||
@ -18,7 +20,7 @@ class ShipController extends Controller
|
||||
->with('ship')
|
||||
->where('plat_id', 1)
|
||||
->get();
|
||||
$time = time();
|
||||
$time = date('Y-m-d H:i:s');
|
||||
foreach ($shops as $shop) {
|
||||
$faceSheet = new FaceSheet();
|
||||
$shop->authUrl = $faceSheet->getAuthUrl($shop->id, $shop->plat_id);
|
||||
@ -33,4 +35,31 @@ class ShipController extends Controller
|
||||
|
||||
return ShopsResource::collection($shops);
|
||||
}
|
||||
|
||||
public function getSenders(Request $request)
|
||||
{
|
||||
$senders = ShopSender::query()
|
||||
->where('shop_id', $request->get('shop_id'))
|
||||
->where('shop_ship_id', $request->get('shop_ship_id'))
|
||||
->orderBy('sort')
|
||||
->get();
|
||||
|
||||
return JsonResource::collection($senders);
|
||||
}
|
||||
|
||||
public function saveSenders(Request $request)
|
||||
{
|
||||
$senderList = $request->input('senderList');
|
||||
foreach ($senderList as $item) {
|
||||
$item = json_decode($item, true);
|
||||
$sender = ShopSender::query()->findOrFail($item['id']);
|
||||
$sender->name = $item['name'];
|
||||
$sender->mobile = $item['mobile'];
|
||||
$sender->sort = $item['sort'];
|
||||
$sender->status = $item['status'];
|
||||
$sender->save();
|
||||
}
|
||||
|
||||
return response(['message' =>'保存成功']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ use App\Models\BusinessGoodsSku;
|
||||
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;
|
||||
@ -230,5 +232,26 @@ class ShopsController extends Controller
|
||||
$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);
|
||||
$resp = $faceSheet->searchWayBill();
|
||||
if (!isset($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'])) {
|
||||
exit();
|
||||
}
|
||||
foreach ($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'] as $subCols) {
|
||||
foreach ($subCols['branch_account_cols'] as $accountCols) {
|
||||
foreach ($accountCols['shipp_address_cols'] as $item) {
|
||||
ShopSender::query()->updateOrCreate(
|
||||
['shop_id' => $shopId, 'shop_ship_id' => $shopShip->id, 'detail' => $item['detail']],
|
||||
$item
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
app/Models/ShopSender.php
Normal file
10
app/Models/ShopSender.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShopSender extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
@ -110,7 +110,7 @@ abstract class BusinessClient
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setShop(Shop $shop)
|
||||
public function setShop($shop)
|
||||
{
|
||||
$this->shop = $shop;
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateShopSendersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('shop_senders')) {
|
||||
return;
|
||||
}
|
||||
Schema::create('shop_senders', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->integer('shop_id');
|
||||
$table->integer('shop_ship_id');
|
||||
$table->string('country');
|
||||
$table->string('province');
|
||||
$table->string('city');
|
||||
$table->string('district');
|
||||
$table->string('detail');
|
||||
$table->string('name')->nullable()->default('');
|
||||
$table->integer('mobile')->nullable();
|
||||
$table->integer('sort')->default(1);
|
||||
$table->integer('status')->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('shop_senders');
|
||||
}
|
||||
}
|
||||
19
resources/frontend/src/api/shop.js
vendored
19
resources/frontend/src/api/shop.js
vendored
@ -56,3 +56,22 @@ export function shipList() {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function ShopSenderList(shopId, shopShipId) {
|
||||
return http({
|
||||
url: '/api/shop/ship/senders',
|
||||
method: 'get',
|
||||
params: {
|
||||
'shop_id': shopId,
|
||||
'shop_ship_id': shopShipId,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function saveSenders(params) {
|
||||
return http({
|
||||
url: '/api/shop/ship/senders',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
@ -12,29 +12,76 @@
|
||||
<a :href="scope.row.authUrl" target="_blank" rel="noopener noreferrer">授权</a>
|
||||
</el-button>
|
||||
|
||||
<div v-if="scope.row.status === '已授权'">
|
||||
<template v-if="scope.row.status === '已授权'">
|
||||
<el-button type="success" :disabled="true" size="small">{{ scope.row.status }}</el-button>
|
||||
</div>
|
||||
<div v-if="scope.row.status === '重新授权'">
|
||||
</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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-button v-if="scope.row.ship" type="info" @click="getSenders(scope.row)"
|
||||
size="small">发货信息</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 发货信息 -->
|
||||
<el-dialog title="发货信息" :visible.sync="dialogVisible" :close-on-click-modal="false">
|
||||
<el-form ref="sendersForm" :model="sendersForm" label-width="100px">
|
||||
|
||||
<template v-for="(item, index) in sendersForm.senderList" :prop="`senderList.$(index)`">
|
||||
<div>
|
||||
<p>发货地址 {{ index + 1 }}</p>
|
||||
<el-form-item label="详细地址">
|
||||
{{ item.province }} {{ item.city }} {{ item.district }} {{ item.detail }}
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="发货人" prop="name">
|
||||
<el-input v-model="item.name"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="手机号" prop="mobile">
|
||||
<el-input v-model="item.mobile"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="item.sort"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="item.status">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
<el-radio :label="0">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="saveSenders">保存</el-button>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { shipList } from "../../api/shop";
|
||||
import { shipList, ShopSenderList, saveSenders } from "../../api/shop";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
storeId: [],
|
||||
loading: true,
|
||||
tableData: [],
|
||||
dialogVisible: false,
|
||||
sendersForm: {
|
||||
senderList: []
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@ -47,6 +94,21 @@ export default {
|
||||
});
|
||||
this.loading = false
|
||||
},
|
||||
getSenders(row) {
|
||||
ShopSenderList(row.id, row.ship.id).then((res) => {
|
||||
this.sendersForm.senderList = res.data.data;
|
||||
this.dialogVisible = true;
|
||||
})
|
||||
},
|
||||
saveSenders() {
|
||||
saveSenders(this.sendersForm).then((res) => {
|
||||
if (200 === res.status) {
|
||||
this.$message.success(res.data.message);
|
||||
} else {
|
||||
this.$message.error(res.data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Controllers\Role\RolesController;
|
||||
use App\Http\Controllers\Shop\ShipController;
|
||||
use App\Http\Controllers\UploadController;
|
||||
use App\Http\Controllers\Shop\ShopsController;
|
||||
use App\Http\Controllers\Goods\GoodsSkusController;
|
||||
@ -62,7 +63,10 @@ Route::middleware(['auth:api', 'check.permissions'])->group(function () {
|
||||
Route::put('goods_sku_location', [GoodsSkuLocationController::class, 'update'])->name('goods_sku_location.update');
|
||||
Route::delete('goods_sku_location', [GoodsSkuLocationController::class, 'delete'])->name('goods_sku_location.delete');
|
||||
// 电子面单
|
||||
Route::resource('shop/ship', 'Shop\ShipController', ['only' => ['index']]);
|
||||
Route::get('shop/ship', [ShipController::class, 'index']);
|
||||
// 发货信息
|
||||
Route::get('shop/ship/senders', [ShipController::class, 'getSenders']);
|
||||
Route::post('shop/ship/senders', [ShipController::class, 'saveSenders']);
|
||||
});
|
||||
Route::get('stock/goods_skus', [GoodsSkusController::class, 'stockNum'])->middleware('auth:api');
|
||||
Route::get('goods/filter/{title}', [GoodsCombinationController::class, 'goodsSkus'])->middleware('auth:api');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user