DOC_ORDER_HEADER[orderno] * wms客户订单号 client_code=>DOC_ORDER_HEADER['soreference1'] * wms订单状态 wms_status=> * 仓库 warehouse_id=>DOC_ORDER_HEADER['WAREHOUSEID'] */ const STATUS = [ '00' => "创建订单", '10' => "部分预配", '20' => "预配完成", '30' => "部分分配", '40' => "分配完成", '50' => "部分拣货", '60' => "拣货完成", '61' => "播种完成", '62' => "部分装箱", '63' => "完全装箱", '65' => "部分装车", '66' => "装车完成", '70' => "部分发运", '80' => "完全发运", '90' => "订单取消", '98' => "等待释放", '99' => "订单完成", ]; public function cancel(){ $this['status'] = '取消'; $this->update(); } public function logistic() { return $this->hasOne(Logistic::class, 'id', 'logistic_id'); } public function issue() { return $this->belongsTo(OrderIssue::class, 'id', 'order_id'); } public function shop() { return $this->belongsTo(Shop::class, 'shop_id', 'id'); } public function owner() { return $this->hasOne(Owner::class, 'id', 'owner_id'); } public function packages() { return $this->hasMany(OrderPackage::class,'order_id','id'); } public function warehouse() { return $this->belongsTo(Warehouse::class); } public function orderCommodities(){ return $this->hasMany('App\OrderCommodity','order_id','id'); } public function bin(){ return $this->hasOne('App\OrderBin','order_id','id'); } public function batch(){ return $this->belongsTo('App\Batch', 'batch_id','id'); } public function detail(): HasOne { return $this->hasOne(OrderDetail::class); } public function getLogisticNumbersAttribute() { $packages = $this->packages; if (!$packages) { return []; } else { $arr = []; foreach ($packages as $package) { array_push($arr, $package->logistic_number); } return $arr; } } public function getAmountAttribute() { $packages = $this->packages; if (!$packages) { return 0; } else { $count = 0; foreach ($packages as $package) { foreach ($package->commodities as $item) { $count += $item->amount; } } return $count; } } public function getCommodityPackagesAttribute() { $packages = $this->packages; if (!$packages) { return 0; } else { $count = 0; foreach ($packages as $package) { foreach ($package->commodities as $item) { $count++; } } return $count; } } public function delete() { $this->packages()->delete(); return parent::delete(); } public function deleteSafe() { return parent::delete(); } public function isEquals($order) { return $this['wms_edittime'] == $order['wms_edittime'] && $this['batch_id'] == $order['batch_id'] && $this['warehouse_id'] == $order['warehouse_id'] && $this['frozen'] == $order['frozen']; } public function assignValueByOrder($order) { $this['code'] = $order['code'] ; $this['batch_id'] = $order['batch_id'] ; $this['warehouse_id'] = $order['warehouse_id'] ; $this['owner_id'] = $order['owner_id'] ; $this['shop_id'] = $order['shop_id'] ; $this['logistic_id'] = $order['logistic_id'] ; $this['consignee_name'] = $order['consignee_name'] ; $this['consignee_phone'] = $order['consignee_phone'] ; $this['province'] = $order['province'] ; $this['city'] = $order['city'] ; $this['district'] = $order['district'] ; $this['address'] = $order['address'] ; $this['client_code'] = $order['client_code'] ; $this['wms_status'] = $order['wms_status'] ; $this['wms_edittime'] = $order['wms_edittime']; $this['frozen'] = $order['frozen']; $this['order_type'] = $order['order_type']; $this['created_at'] =$order['created_at']; $this['pay_at'] =$order['pay_at']; } public static function getFrozen($string): string { $arr = [ 'H' => '是', 'Y' => '否', 'N' => '否' ]; return $arr[$string] ?? '否'; } public function OracleDOCOrderHeader(): BelongsTo { return $this->belongsTo(OracleDOCOrderHeader::class,'code','orderno'); } }