diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 548d0fd..e1c3d4a 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -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 + ); + } + } + } } } diff --git a/app/Http/Controllers/Business/BusinessOrderController.php b/app/Http/Controllers/Business/BusinessOrderController.php index 34fab18..5979ccc 100644 --- a/app/Http/Controllers/Business/BusinessOrderController.php +++ b/app/Http/Controllers/Business/BusinessOrderController.php @@ -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) { diff --git a/app/Http/Controllers/Shop/ShipController.php b/app/Http/Controllers/Shop/ShipController.php index 3ebb779..db69a30 100644 --- a/app/Http/Controllers/Shop/ShipController.php +++ b/app/Http/Controllers/Shop/ShipController.php @@ -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' =>'保存成功']); + } } diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 95b776e..1793cc7 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -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 + ); + } + } + } } } diff --git a/app/Models/ShopSender.php b/app/Models/ShopSender.php new file mode 100644 index 0000000..1eec811 --- /dev/null +++ b/app/Models/ShopSender.php @@ -0,0 +1,10 @@ +shop = $shop; diff --git a/database/migrations/2023_07_26_184009_create_shop_senders_table.php b/database/migrations/2023_07_26_184009_create_shop_senders_table.php new file mode 100644 index 0000000..51f97c7 --- /dev/null +++ b/database/migrations/2023_07_26_184009_create_shop_senders_table.php @@ -0,0 +1,45 @@ +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'); + } +} diff --git a/resources/frontend/src/api/shop.js b/resources/frontend/src/api/shop.js index 3b8fe53..d757d6d 100644 --- a/resources/frontend/src/api/shop.js +++ b/resources/frontend/src/api/shop.js @@ -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 + }) +} diff --git a/resources/frontend/src/views/plat/faceSheet.vue b/resources/frontend/src/views/plat/faceSheet.vue index 2c5a556..5c34eac 100644 --- a/resources/frontend/src/views/plat/faceSheet.vue +++ b/resources/frontend/src/views/plat/faceSheet.vue @@ -12,29 +12,76 @@ 授权 -
发货地址 {{ index + 1 }}
+