|
|
@@ -7,6 +7,7 @@ use App\inventoryDailyLog;
|
|
|
use App\InventoryDailyLoggingOwner;
|
|
|
use App\Owner;
|
|
|
use App\Services\common\QueryService;
|
|
|
+use App\Traits\ModelSearchWay;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
|
|
|
@@ -14,6 +15,7 @@ use App\Traits\ServiceAppAop;
|
|
|
class InventoryService
|
|
|
{
|
|
|
use ServiceAppAop;
|
|
|
+ use ModelSearchWay;
|
|
|
protected $modelClass=Inventory::class;
|
|
|
public function getSql(array $params,$page=null,$paginate=null){
|
|
|
$ownerCodes=Owner::filterAuthorities()->select('code')->get();
|
|
|
@@ -40,8 +42,8 @@ class InventoryService
|
|
|
if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
|
|
|
// if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."' ";
|
|
|
// if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
|
|
|
- if ($TOLocation)$sql=$this->searchWay($sql,$TOLocation,"TOLocation");
|
|
|
- if ($SKU)$sql=$this->searchWay($sql,$SKU,"FMSKU");
|
|
|
+ if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"TOLocation");
|
|
|
+ if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
|
|
|
if ($customerid){
|
|
|
$sql .= ' and TOCustomerID in (';
|
|
|
$arr = explode(',',$customerid);
|
|
|
@@ -66,8 +68,8 @@ class InventoryService
|
|
|
if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
|
|
|
// if ($TOLocation)$sql .= " and FMLOCATION like '".$TOLocation."' ";
|
|
|
// if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
|
|
|
- if ($TOLocation)$sql=$this->searchWay($sql,$TOLocation,"FMLOCATION");
|
|
|
- if ($SKU)$sql=$this->searchWay($sql,$SKU,"FMSKU");
|
|
|
+ if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"FMLOCATION");
|
|
|
+ if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
|
|
|
if ($customerid){
|
|
|
$sql .= ' and FMCUSTOMERID in (';
|
|
|
$arr = explode(',',$customerid);
|
|
|
@@ -92,8 +94,8 @@ class InventoryService
|
|
|
if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
|
|
|
// if ($TOLocation)$sql .= " and FMLocation like '".$TOLocation."' ";
|
|
|
// if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
|
|
|
- if ($TOLocation)$sql=$this->searchWay($sql,$TOLocation,"FMLocation");
|
|
|
- if ($SKU)$sql=$this->searchWay($sql,$SKU,"FMSKU");
|
|
|
+ if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"FMLocation");
|
|
|
+ if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
|
|
|
|
|
|
if ($customerid){
|
|
|
$sql .= ' and FMCUSTOMERID in (';
|
|
|
@@ -119,8 +121,8 @@ class InventoryService
|
|
|
if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
|
|
|
// if ($TOLocation)$sql .= " and TOLocation like '".$TOLocation."' ";
|
|
|
// if ($SKU)$sql.=" and FMSKU like '".$SKU."' ";
|
|
|
- if ($TOLocation)$sql=$this->searchWay($sql,$TOLocation,"TOLocation");
|
|
|
- if ($SKU)$sql=$this->searchWay($sql,$SKU,"FMSKU");
|
|
|
+ if ($TOLocation)$sql=$this->sqlSearchWay($sql,$TOLocation,"TOLocation");
|
|
|
+ if ($SKU)$sql=$this->sqlSearchWay($sql,$SKU,"FMSKU");
|
|
|
|
|
|
if ($customerid){
|
|
|
$sql .= ' and TOCustomerID in (';
|
|
|
@@ -150,34 +152,17 @@ class InventoryService
|
|
|
$sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,stockLog.客户 ';
|
|
|
$sql.=' )result where 1=1 ';
|
|
|
// if ($LotAtt05)$sql .=" and 属性仓 like '".$LotAtt05."' ";
|
|
|
- if ($LotAtt05)$sql=$this->searchWay($sql,$LotAtt05,"属性仓");
|
|
|
+ if ($LotAtt05)$sql=$this->sqlSearchWay($sql,$LotAtt05,"属性仓");
|
|
|
if ($LotAtt02_start)$sql.=" and 失效日期 >='".$LotAtt02_start." 00:00:00' ";
|
|
|
if ($LotAtt02_end)$sql.=" and 失效日期 <='".$LotAtt02_end." 23:59:59' ";
|
|
|
// if ($ALTERNATE_SKU1)$sql.=" and 产品条码 like '".$ALTERNATE_SKU1."' ";
|
|
|
- if ($ALTERNATE_SKU1)$sql=$this->searchWay($sql,$ALTERNATE_SKU1,"产品条码");
|
|
|
+ if ($ALTERNATE_SKU1)$sql=$this->sqlSearchWay($sql,$ALTERNATE_SKU1,"产品条码");
|
|
|
if ($page&&$paginate)$sql.=" and ROWNUM<='".$page*$paginate."'";
|
|
|
$sql.=' ) ';
|
|
|
if ($page&&$paginate)$sql.=" where rn>'".($page-1)*$paginate."'";
|
|
|
return $sql;
|
|
|
}
|
|
|
- private function searchWay($sql,$condition,$column)
|
|
|
- {
|
|
|
- if ($condition){
|
|
|
- if (strpos($condition, ',') || strpos($condition, ',') || strpos($condition, ' ')) {
|
|
|
- $arr = array_filter(preg_split('/[,, ]+/is', $condition));
|
|
|
- $sql .= ' and '.$column.' in (';
|
|
|
- foreach ($arr as $index => $arr){
|
|
|
- if ($index != 0)$sql .= ',';
|
|
|
- $sql .= "'".$arr."'";
|
|
|
- }
|
|
|
- $sql .= ') ';
|
|
|
- unset($condition);
|
|
|
- } else {
|
|
|
- $sql .= " and $column like '".$condition."' ";
|
|
|
- }
|
|
|
- }
|
|
|
- return $sql;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
public function paginate(array $params)
|
|
|
{
|