|
|
@@ -35,57 +35,56 @@ class U8ServerService extends Service
|
|
|
{
|
|
|
return $this->error;
|
|
|
}
|
|
|
-
|
|
|
- public function purchaseRequisition($data, $user){
|
|
|
+ public function purchaseOrder($data, $user){
|
|
|
$qx = $user['qx'];
|
|
|
$order_date = $data['order_date'] ?? [];
|
|
|
$order_date = array_filter($order_date);
|
|
|
$order_number = $data['order_number'] ?? "";
|
|
|
|
|
|
- $model = $this->databaseService->table('PU_AppVouch as a')
|
|
|
- ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
|
|
|
+ $model = $this->databaseService->table('PO_Pomain as a')
|
|
|
+ ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
|
|
|
->when(empty($qx), function ($query) use($user){
|
|
|
return $query->where('a.cMaker',$user['username']);
|
|
|
})
|
|
|
->when(! empty($order_number), function ($query) use($order_number){
|
|
|
- return $query->where('a.cCode','LIKE', '%'.$order_number.'%');
|
|
|
+ return $query->where('a.cPOID','LIKE', '%'.$order_number.'%');
|
|
|
})
|
|
|
->when(! empty($order_date), function ($query) use($order_date){
|
|
|
$start = date('Y-m-d H:i:s.000', $order_date[0]);
|
|
|
$end = date('Y-m-d H:i:s.000', $order_date[1]);
|
|
|
- return $query->whereBetween('a.dDate', [$start, $end]);
|
|
|
+ return $query->whereBetween('a.dPODate', [$start, $end]);
|
|
|
})
|
|
|
->where(function ($query) {
|
|
|
$query->where('a.iverifystateex', 0)
|
|
|
->OrwhereNull('a.iverifystateex');
|
|
|
})
|
|
|
- ->select('a.cMaker as crt_name', DB::raw("COALESCE(c.cPersonName, '') as purchase_name"),'a.cBusType as business_type','a.cCode as order_number',DB::raw("CONVERT(varchar(10), a.dDate, 120) as order_date"))
|
|
|
- ->orderBy('a.ID','desc');
|
|
|
+ ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number',DB::raw("CONVERT(varchar(10), a.dPODate, 120) as order_date"),'c.cVenName as supplier_title')
|
|
|
+ ->orderBy('a.POID','desc');
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
- $list = $this->fillAll($list, 2);
|
|
|
+ $list = $this->fillAll($list, 1, $user['login_type']);
|
|
|
|
|
|
- return [true , $list];
|
|
|
+ return [true , $list];
|
|
|
}
|
|
|
|
|
|
- public function purchaseRequisitionDetail($data, $user){
|
|
|
- if(empty($data['order_number'])) return [false, '采购请购单号不能为空'];
|
|
|
+ public function purchaseOrderDetail($data, $user){
|
|
|
+ if(empty($data['order_number'])) return [false, '采购单号不能为空'];
|
|
|
|
|
|
- $order = $this->databaseService->table('PU_AppVouch as a')
|
|
|
- ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
|
|
|
+ $order = $this->databaseService->table('PO_Pomain as a')
|
|
|
+ ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
|
|
|
+ ->where('cPOID', $data['order_number'])
|
|
|
// ->where('a.cMaker',$user['username'])
|
|
|
// ->where('a.iverifystateex',0)
|
|
|
- ->where('cCode', $data['order_number'])
|
|
|
- ->select('a.cMaker as crt_name', DB::raw("COALESCE(c.cPersonName, '') as purchase_name"),'a.cBusType as business_type','a.cCode as order_number',DB::raw("CONVERT(varchar(10), a.dDate, 120) as order_date"),'a.ID as id')
|
|
|
+ ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number',DB::raw("CONVERT(varchar(10), a.dPODate, 120) as order_date"),'c.cVenName as supplier_title','a.POID as id')
|
|
|
->first();
|
|
|
- if(empty($order)) return [false, '采购请购单不存在'];
|
|
|
+ if(empty($order)) return [false, '采购单不存在'];
|
|
|
$order = (array) $order;
|
|
|
|
|
|
- $detail = $this->databaseService->table('PU_AppVouchs as a')
|
|
|
+ $detail = $this->databaseService->table('PO_Podetails as a')
|
|
|
->leftJoin('Inventory as b', 'b.cInvCode', 'a.cInvCode')
|
|
|
->leftJoin('ComputationUnit as c', 'c.cComunitCode', 'b.cComUnitCode')
|
|
|
- ->where('a.ID', $order['id'])
|
|
|
- ->select('b.cInvName as product_title','b.cInvCode as product_code','c.cComUnitName as unit_title',DB::raw("CONVERT(varchar(10), a.dRequirDate, 120) as need_arrived_date"),DB::raw("LTRIM(STR(a.fQuantity, 20, 2)) as quantity"))
|
|
|
+ ->where('a.POID', $order['id'])
|
|
|
+ ->select('b.cInvName as product_title','b.cInvCode as product_code','c.cComUnitName as unit_title',DB::raw("LTRIM(STR(a.iQuantity, 20, 2)) as quantity"),DB::raw("LTRIM(STR(a.iSum, 20, 2)) as amount"))
|
|
|
->get();
|
|
|
// 转为数组的数组
|
|
|
$detail = array_map(function ($item) {
|
|
|
@@ -96,56 +95,56 @@ class U8ServerService extends Service
|
|
|
return [true, $order];
|
|
|
}
|
|
|
|
|
|
- public function purchaseOrder($data, $user){
|
|
|
+ public function purchaseRequisition($data, $user){
|
|
|
$qx = $user['qx'];
|
|
|
$order_date = $data['order_date'] ?? [];
|
|
|
$order_date = array_filter($order_date);
|
|
|
$order_number = $data['order_number'] ?? "";
|
|
|
|
|
|
- $model = $this->databaseService->table('PO_Pomain as a')
|
|
|
- ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
|
|
|
+ $model = $this->databaseService->table('PU_AppVouch as a')
|
|
|
+ ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
|
|
|
->when(empty($qx), function ($query) use($user){
|
|
|
return $query->where('a.cMaker',$user['username']);
|
|
|
})
|
|
|
->when(! empty($order_number), function ($query) use($order_number){
|
|
|
- return $query->where('a.cPOID','LIKE', '%'.$order_number.'%');
|
|
|
+ return $query->where('a.cCode','LIKE', '%'.$order_number.'%');
|
|
|
})
|
|
|
->when(! empty($order_date), function ($query) use($order_date){
|
|
|
$start = date('Y-m-d H:i:s.000', $order_date[0]);
|
|
|
$end = date('Y-m-d H:i:s.000', $order_date[1]);
|
|
|
- return $query->whereBetween('a.dPODate', [$start, $end]);
|
|
|
+ return $query->whereBetween('a.dDate', [$start, $end]);
|
|
|
})
|
|
|
->where(function ($query) {
|
|
|
$query->where('a.iverifystateex', 0)
|
|
|
->OrwhereNull('a.iverifystateex');
|
|
|
})
|
|
|
- ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number',DB::raw("CONVERT(varchar(10), a.dPODate, 120) as order_date"),'c.cVenName as supplier_title')
|
|
|
- ->orderBy('a.POID','desc');
|
|
|
+ ->select('a.cMaker as crt_name', DB::raw("COALESCE(c.cPersonName, '') as purchase_name"),'a.cBusType as business_type','a.cCode as order_number',DB::raw("CONVERT(varchar(10), a.dDate, 120) as order_date"))
|
|
|
+ ->orderBy('a.ID','desc');
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
- $list = $this->fillAll($list, 1);
|
|
|
+ $list = $this->fillAll($list, 2, $user['login_type']);
|
|
|
|
|
|
- return [true , $list];
|
|
|
+ return [true , $list];
|
|
|
}
|
|
|
|
|
|
- public function purchaseOrderDetail($data, $user){
|
|
|
- if(empty($data['order_number'])) return [false, '采购单号不能为空'];
|
|
|
+ public function purchaseRequisitionDetail($data, $user){
|
|
|
+ if(empty($data['order_number'])) return [false, '采购请购单号不能为空'];
|
|
|
|
|
|
- $order = $this->databaseService->table('PO_Pomain as a')
|
|
|
- ->leftJoin('Vendor as c', 'c.cVenCode', 'a.cVenCode')
|
|
|
- ->where('cPOID', $data['order_number'])
|
|
|
+ $order = $this->databaseService->table('PU_AppVouch as a')
|
|
|
+ ->leftJoin('Person as c', 'c.cPersonCode', 'a.cPersonCode')
|
|
|
// ->where('a.cMaker',$user['username'])
|
|
|
// ->where('a.iverifystateex',0)
|
|
|
- ->select('a.cMaker as crt_name', 'a.cBusType as business_type','a.cPOID as order_number',DB::raw("CONVERT(varchar(10), a.dPODate, 120) as order_date"),'c.cVenName as supplier_title','a.POID as id')
|
|
|
+ ->where('cCode', $data['order_number'])
|
|
|
+ ->select('a.cMaker as crt_name', DB::raw("COALESCE(c.cPersonName, '') as purchase_name"),'a.cBusType as business_type','a.cCode as order_number',DB::raw("CONVERT(varchar(10), a.dDate, 120) as order_date"),'a.ID as id')
|
|
|
->first();
|
|
|
- if(empty($order)) return [false, '采购单不存在'];
|
|
|
+ if(empty($order)) return [false, '采购请购单不存在'];
|
|
|
$order = (array) $order;
|
|
|
|
|
|
- $detail = $this->databaseService->table('PO_Podetails as a')
|
|
|
+ $detail = $this->databaseService->table('PU_AppVouchs as a')
|
|
|
->leftJoin('Inventory as b', 'b.cInvCode', 'a.cInvCode')
|
|
|
->leftJoin('ComputationUnit as c', 'c.cComunitCode', 'b.cComUnitCode')
|
|
|
- ->where('a.POID', $order['id'])
|
|
|
- ->select('b.cInvName as product_title','b.cInvCode as product_code','c.cComUnitName as unit_title',DB::raw("LTRIM(STR(a.iQuantity, 20, 2)) as quantity"),DB::raw("LTRIM(STR(a.iSum, 20, 2)) as amount"))
|
|
|
+ ->where('a.ID', $order['id'])
|
|
|
+ ->select('b.cInvName as product_title','b.cInvCode as product_code','c.cComUnitName as unit_title',DB::raw("CONVERT(varchar(10), a.dRequirDate, 120) as need_arrived_date"),DB::raw("LTRIM(STR(a.fQuantity, 20, 2)) as quantity"))
|
|
|
->get();
|
|
|
// 转为数组的数组
|
|
|
$detail = array_map(function ($item) {
|
|
|
@@ -180,7 +179,7 @@ class U8ServerService extends Service
|
|
|
->orderBy('a.ID','desc');
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
- $list = $this->fillAll($list, 3);
|
|
|
+ $list = $this->fillAll($list, 3, $user['login_type']);
|
|
|
|
|
|
return [true , $list];
|
|
|
}
|
|
|
@@ -261,11 +260,12 @@ class U8ServerService extends Service
|
|
|
return [$success, $order];
|
|
|
}
|
|
|
|
|
|
- private function fillAll($list, $type){
|
|
|
+ private function fillAll($list, $type, $login_type){
|
|
|
if(empty($list['data'])) return $list;
|
|
|
|
|
|
$map = Record::where('del_time',0)
|
|
|
->where('type', $type)
|
|
|
+ ->where('login_type', $login_type)
|
|
|
->whereIn('order_number',array_column($list['data'],'order_number'))
|
|
|
->pluck('id','order_number')
|
|
|
->toArray();
|