ThinkAdmin/plugin/think-plugs-wuma/src/model/PluginWumaWarehouseOrder.php

141 lines
4.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | Wuma Plugin for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2022~2024 ThinkAdmin [ thinkadmin.top ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 免责声明 ( https://thinkadmin.top/disclaimer )
// | 收费插件 ( https://thinkadmin.top/fee-introduce.html )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/think-plugs-wuma
// | github 代码仓库https://github.com/zoujingli/think-plugs-wuma
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace plugin\wuma\model;
use plugin\wemall\model\PluginWemallGoodsItem;
use think\model\relation\HasOne;
/**
* 仓库订单模型
*
* @property int $auid 出库代理
* @property int $deleted 删除状态(0未删,1已删)
* @property int $id
* @property int $mode 操作方式(1扫码操作,2虚拟操作)
* @property int $num_need 扫码总数
* @property int $num_used 扫码完成
* @property int $status 记录状态(0无效,1有效,2完成)
* @property int $type 操作类型(1订单入库,2直接入库,3调货入库,4订单出库,5直接出库,6调货出库,7关联出库,8直接退货)
* @property int $vir_need 虚拟总数
* @property int $vir_used 虚拟完成
* @property string $code 操作单号
* @property string $create_time 创建时间
* @property string $deleted_time 删除时间
* @property string $ghash 绑定产品
* @property string $update_time 更新时间
* @property string $wcode 仓库编号
* @property-read \plugin\wemall\model\PluginWemallGoodsItem $bind_goods
* @property-read \plugin\wemall\model\PluginWemallGoodsItem $goods
* @property-read \plugin\wuma\model\PluginWumaWarehouse $bind_warehouse
* @property-read \plugin\wuma\model\PluginWumaWarehouse $warehouse
* @class PluginWumaWarehouseOrder
* @package plugin\wuma\model
*/
class PluginWumaWarehouseOrder extends AbstractPrivate
{
// 入库订单类型
public const interTypes = [1, 2, 3];
// 出库订单类型
public const outerTypes = [4, 5, 6, 7];
// 退货订单状态
public const returnTypes = [8];
/**
* 关联商品数据
* @return \think\model\relation\HasOne
*/
public function goods(): HasOne
{
return $this->hasOne(PluginWemallGoodsItem::class, 'ghash', 'ghash')->with('bindGoods');
}
/**
* 出库搜索器
* @param mixed $query
* @return void
*/
public function searchOuterAttr($query)
{
$query->whereIn('type', PluginWumaWarehouseOrder::outerTypes);
}
/**
* 入库搜索器
* @param mixed $query
* @return void
*/
public function searchInterAttr($query)
{
$query->whereIn('type', PluginWumaWarehouseOrder::interTypes);
}
/**
* 退货搜索器
* @param mixed $query
* @return void
*/
public function searchReturnAttr($query)
{
$query->whereIn('type', PluginWumaWarehouseOrder::returnTypes);
}
/**
* 绑定产品数据
* @return HasOne
*/
public function bindGoods(): HasOne
{
return $this->goods()->bind([
'gcode' => 'gcode',
'gname' => 'gname',
'gunit' => 'gunit',
'gspec' => 'gspec',
'gcover' => 'gcover',
]);
}
/**
* 关联仓库数据
* @return \think\model\relation\HasOne
*/
public function warehouse(): HasOne
{
return $this->hasOne(PluginWumaWarehouse::class, 'code', 'wcode');
}
/**
* 绑定仓库数据
* @return \think\model\relation\HasOne
*/
public function bindWarehouse(): HasOne
{
return $this->warehouse()->bind([
'wname' => 'name',
'wperson' => 'person',
'wprov' => 'addr_prov',
'wcity' => 'addr_city',
'warea' => 'addr_area',
'wstatus' => 'status',
'wdeleted' => 'deleted'
]);
}
}