|
@@ -1570,13 +1570,16 @@ class ProductService extends Service
|
|
$head = $user['head']['id'] ?? 0;
|
|
$head = $user['head']['id'] ?? 0;
|
|
$storehouse_id = Storehouse::where('top_depart_id', $head)->where('del_time',0)->value('id') ?? 0;
|
|
$storehouse_id = Storehouse::where('top_depart_id', $head)->where('del_time',0)->value('id') ?? 0;
|
|
|
|
|
|
|
|
+ $service = new U8ServerService(true);
|
|
|
|
+ if(! empty($service->error)) return [false, $service->error];
|
|
|
|
+
|
|
$time = time();
|
|
$time = time();
|
|
DB::table('product')
|
|
DB::table('product')
|
|
->where('del_time', 0)
|
|
->where('del_time', 0)
|
|
->where('top_depart_id', $head)
|
|
->where('top_depart_id', $head)
|
|
->select('id','code')
|
|
->select('id','code')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
- ->chunk(200, function ($data) use($head,$storehouse_id,$time){
|
|
|
|
|
|
+ ->chunk(200, function ($data) use($head,$storehouse_id,$time,$service){
|
|
$data = Collect($data)->map(function ($object) {
|
|
$data = Collect($data)->map(function ($object) {
|
|
return (array)$object;
|
|
return (array)$object;
|
|
})->toArray();
|
|
})->toArray();
|
|
@@ -1584,16 +1587,18 @@ class ProductService extends Service
|
|
$map = array_column($data,'id','code');
|
|
$map = array_column($data,'id','code');
|
|
$id = array_unique(array_column($data,'id'));
|
|
$id = array_unique(array_column($data,'id'));
|
|
$code = array_unique(array_column($data,'code'));
|
|
$code = array_unique(array_column($data,'code'));
|
|
- $post = [
|
|
|
|
- 'urlFromT9' => 'getStock',
|
|
|
|
- 'code' => $code,
|
|
|
|
- 'warehouse' => '001',
|
|
|
|
- ];
|
|
|
|
- $post = json_encode($post);
|
|
|
|
- $header = ['Content-Type:application/json'];
|
|
|
|
- list($status, $msg) = $this->post_helper("https://workapi.qingyaokeji.com/api/updateTopStock",$post, $header);
|
|
|
|
- if($msg['code'] != 200) return [false, $msg['msg']];
|
|
|
|
- $msg = $msg['data'] ?? [];
|
|
|
|
|
|
+ list($status, $msg) = $service->getStock($code, "001");
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+// $post = [
|
|
|
|
+// 'urlFromT9' => 'getStock',
|
|
|
|
+// 'code' => $code,
|
|
|
|
+// 'warehouse' => '001',
|
|
|
|
+// ];
|
|
|
|
+// $post = json_encode($post);
|
|
|
|
+// $header = ['Content-Type:application/json'];
|
|
|
|
+// list($status, $msg) = $this->post_helper("https://workapi.qingyaokeji.com/api/updateTopStock",$post, $header);
|
|
|
|
+// if($msg['code'] != 200) return [false, $msg['msg']];
|
|
|
|
+// $msg = $msg['data'] ?? [];
|
|
|
|
|
|
$insert = [];
|
|
$insert = [];
|
|
foreach ($msg as $value){
|
|
foreach ($msg as $value){
|
|
@@ -1663,7 +1668,7 @@ class ProductService extends Service
|
|
->where('top_depart_id', $head)
|
|
->where('top_depart_id', $head)
|
|
->select('id','code')
|
|
->select('id','code')
|
|
->orderBy('id')
|
|
->orderBy('id')
|
|
- ->chunk(200, function ($data) use($head,$storehouse_id,$time){
|
|
|
|
|
|
+ ->chunk(200, function ($data) use($head,$storehouse_id,$time,$service){
|
|
$data = Collect($data)->map(function ($object) {
|
|
$data = Collect($data)->map(function ($object) {
|
|
return (array)$object;
|
|
return (array)$object;
|
|
})->toArray();
|
|
})->toArray();
|
|
@@ -1671,16 +1676,18 @@ class ProductService extends Service
|
|
$map = array_column($data,'id','code');
|
|
$map = array_column($data,'id','code');
|
|
$id = array_unique(array_column($data,'id'));
|
|
$id = array_unique(array_column($data,'id'));
|
|
$code = array_unique(array_column($data,'code'));
|
|
$code = array_unique(array_column($data,'code'));
|
|
- $post = [
|
|
|
|
- 'urlFromT9' => 'getStock',
|
|
|
|
- 'code' => $code,
|
|
|
|
- 'warehouse' => '001',
|
|
|
|
- ];
|
|
|
|
- $post = json_encode($post);
|
|
|
|
- $header = ['Content-Type:application/json'];
|
|
|
|
- list($status, $msg) = $this->post_helper("https://workapi.qingyaokeji.com/api/updateTopStock",$post, $header);
|
|
|
|
- if($msg['code'] != 200) return [false, $msg['msg']];
|
|
|
|
- $msg = $msg['data'] ?? [];
|
|
|
|
|
|
+ list($status, $msg) = $service->getStock($code, "001");
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+// $post = [
|
|
|
|
+// 'urlFromT9' => 'getStock',
|
|
|
|
+// 'code' => $code,
|
|
|
|
+// 'warehouse' => '001',
|
|
|
|
+// ];
|
|
|
|
+// $post = json_encode($post);
|
|
|
|
+// $header = ['Content-Type:application/json'];
|
|
|
|
+// list($status, $msg) = $this->post_helper("https://workapi.qingyaokeji.com/api/updateTopStock",$post, $header);
|
|
|
|
+// if($msg['code'] != 200) return [false, $msg['msg']];
|
|
|
|
+// $msg = $msg['data'] ?? [];
|
|
|
|
|
|
$insert = [];
|
|
$insert = [];
|
|
foreach ($msg as $value){
|
|
foreach ($msg as $value){
|