|
|
@@ -6,23 +6,26 @@ use App\OracleDocOrderDeliveryInfo;
|
|
|
use App\OracleDOCOrderHeader;
|
|
|
use App\OwnerLogisticPrintTemplate;
|
|
|
use App\Services\Interfaces\DeliveryInterface;
|
|
|
+use App\Traits\DeliveryProcess;
|
|
|
use App\Traits\DrawImage;
|
|
|
use Illuminate\Database\Query\Builder;
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
class JDDeliveryService implements DeliveryInterface
|
|
|
{
|
|
|
- use DrawImage;
|
|
|
+ use DeliveryProcess;
|
|
|
|
|
|
- function getDeliveryInfo($logistic_number)
|
|
|
+ function getDeliveryInfo($logistic_number): array
|
|
|
{
|
|
|
- return OracleDOCOrderHeader::query()->whereIn('deliveryno',$logistic_number)
|
|
|
+ $oracleDocOrderHeaders = OracleDOCOrderHeader::query()
|
|
|
+ ->with('oracleBASCustomer','oracleDOCWaveDetail')
|
|
|
+ ->whereIn('deliveryno',$logistic_number)
|
|
|
->whereIn('consigneeId',['JD','BSZX','BSZFC','BSZXDF','BSZFCDF'])
|
|
|
- ->get()->map(function($item){
|
|
|
+ ->get();
|
|
|
+ return $oracleDocOrderHeaders->map(function ($item){
|
|
|
return [
|
|
|
- // TODO 需要动态获取面单获取的组件 TYPE
|
|
|
'type' => 'JD',
|
|
|
- 'is_process' => false,
|
|
|
+ 'is_process' => true,
|
|
|
'task_id' => Str::uuid(),
|
|
|
'data' => '',
|
|
|
'component_type' => 'JD',
|
|
|
@@ -37,14 +40,22 @@ class JDDeliveryService implements DeliveryInterface
|
|
|
|
|
|
public function getBase64($item): string
|
|
|
{
|
|
|
- $item = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
|
|
|
- $query->from("owners")->where("code",$item['owner_code']);
|
|
|
+ $printTemplate = OwnerLogisticPrintTemplate::query()->with('printTemplate')->where('owner_id', function(Builder $query)use($item){
|
|
|
+ $query->from("owners")->selectRaw('id')->where("code",$item['customerid']);
|
|
|
})->where('logistic_id', function(Builder $query)use($item){
|
|
|
- $query->from("logistic")->where("code",$item['logistic_code']);
|
|
|
+ $query->from("logistics")->selectRaw('id')->where("code",$item['userdefine1']);
|
|
|
})->first();
|
|
|
- $image = $this->draw($item['delivery'],$item,null);
|
|
|
+
|
|
|
+ $delivery = $this->getDelivery($item);
|
|
|
+
|
|
|
+ $image = $this->draw($delivery,$printTemplate->printTemplate ?? null,null);
|
|
|
+
|
|
|
+ if (!$image) return '';
|
|
|
+
|
|
|
$path = '';
|
|
|
+
|
|
|
$this->saveImage($image,$path);
|
|
|
+
|
|
|
return $this->readImageBase64($path);
|
|
|
}
|
|
|
|
|
|
@@ -68,30 +79,16 @@ class JDDeliveryService implements DeliveryInterface
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
- function getDelivery($item)
|
|
|
+ function getDelivery($item): array
|
|
|
{
|
|
|
-
|
|
|
- $delivery = [
|
|
|
- 'oerderno' => $item['orderno'],
|
|
|
- 'waveno' => $item['waveno'],
|
|
|
- 'logistic_number' => $item['deliveryno'],
|
|
|
- 'shop' => $item[''],
|
|
|
- 'c_address1' => $item['c_address1'],
|
|
|
- 'c_city' => $item['c_city'],
|
|
|
- 'c_province' => $item['c_province'],
|
|
|
- 'c_district' => $item['c_district'],
|
|
|
- 'c_tel' => $item['c_tel1'] ?? $item['c_tel2'],
|
|
|
- 'i_contact' => $item['i_contact'],
|
|
|
- 'i_tel1' => $item['i_tel1'],
|
|
|
- 'i_tel2' => $item['i_tel2'],
|
|
|
- 'soreference1' => $item['soreference1'],
|
|
|
- 'b_addresss1' => $item['MJ-ZP'], // 目的地分拣中心
|
|
|
- 'd_addresss1' => 'BB-Y3-21',
|
|
|
- ];
|
|
|
+ $delivery = $this->getDocOrderInfo($item);
|
|
|
+ $delivery['b_addresss1'] = $item['MJ-ZP'];
|
|
|
+ $delivery['d_addresss1'] = $item['BB-Y3-21'];
|
|
|
+ return $delivery;
|
|
|
}
|
|
|
|
|
|
function processing(&$params)
|
|
|
{
|
|
|
-
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|