|
@@ -447,6 +447,189 @@ class U8ServerService extends Service
|
|
|
return [true, $return];
|
|
|
}
|
|
|
|
|
|
+ public function getSnList($data, $user){
|
|
|
+ //映射ip是否通畅
|
|
|
+ $bool = $this->isDomainAvailable($this->u8['domain']);
|
|
|
+ if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
+
|
|
|
+ if($data['sn_type'] == 1){
|
|
|
+ list($status, $msg) = $this->getSnListFormU8One($this->db,$data);
|
|
|
+ }else{
|
|
|
+ //发货出库单 sn码
|
|
|
+ list($status, $msg) = $this->getSnListFormU8Two($this->db,$data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [$status, $msg];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnListFormU8One($db, $data){
|
|
|
+ if(empty($data['code'])) return [false, '存货不能为空'];
|
|
|
+ $sn = $data['sn'] ?? "";
|
|
|
+ $construction_id = $data['construction_id'] ?? 0;
|
|
|
+ $warehouse = [
|
|
|
+ '001',
|
|
|
+ '003',
|
|
|
+ '010',
|
|
|
+ ];
|
|
|
+// $db->enableQueryLog();
|
|
|
+
|
|
|
+ //检索条件 在库的
|
|
|
+ $model = $db->table('ST_SNState')
|
|
|
+ ->select('cinvCode as code','cInvSN as sn','AutoID as auto_id')
|
|
|
+ ->whereIn("cWhCode", $warehouse)
|
|
|
+ ->where("cInvCode", $data['code'])
|
|
|
+ ->where("iSNState", 2)
|
|
|
+ ->when(! empty($sn), function ($query) use ($sn) {
|
|
|
+ return $query->where('cInvSN', 'LIKE', '%'.$sn.'%');
|
|
|
+ })
|
|
|
+// ->when(! empty($construction_id), function ($query) use ($construction_id) {
|
|
|
+// return $query->whereNull('cSNDefine1')->orWhere('cSNDefine1', '')->orWhere('cSNDefine1', $construction_id);
|
|
|
+// })
|
|
|
+ ->when(empty($construction_id), function ($query) {
|
|
|
+ return $query->where(function ($q) {
|
|
|
+ $q->whereNull('cSNDefine1')
|
|
|
+ ->orWhere('cSNDefine1', '');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->orderBy('cSNDefine1','desc')
|
|
|
+ ->orderBy('AutoID','asc');
|
|
|
+
|
|
|
+ $list = $this->limit($model, '', $data);
|
|
|
+// dd($db->getQueryLog());
|
|
|
+
|
|
|
+ return [true, $list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnListFormU8Two($db, $data){
|
|
|
+ if(empty($data['code']) || empty($data['depart_title'])) return [false, '存货以及门店信息不能为空'];
|
|
|
+ $sn = $data['sn'] ?? "";
|
|
|
+ $construction_id = $data['construction_id'] ?? 0;
|
|
|
+// $db->enableQueryLog();
|
|
|
+
|
|
|
+ $model = $db->table('rdrecord32 as a')
|
|
|
+ ->leftJoin('rdrecords32 as b','b.ID','a.ID')
|
|
|
+ ->leftJoin('ST_SNDetail_SaleOut as c','c.iVouchsID','b.AutoID')
|
|
|
+ ->select("c.cInvCode as code",'c.cinvSN as sn','c.AutoID as auto_id') //,'c.cSNDefine1','a.ID'
|
|
|
+ ->whereNotNull('a.cHandler')
|
|
|
+ ->where("b.cInvCode", $data['code'])
|
|
|
+ ->where("b.iQuantity", '>', 0)
|
|
|
+ ->where("b.cDefine31", $data['depart_title'])
|
|
|
+ ->whereNotNull("c.cinvSN")
|
|
|
+ ->when(! empty($sn), function ($query) use ($sn) {
|
|
|
+ return $query->where('c.cInvSN', 'LIKE', '%'.$sn.'%');
|
|
|
+ })
|
|
|
+// ->when(! empty($construction_id), function ($query) use ($construction_id) {
|
|
|
+// return $query->whereNull('c.cSNDefine1')->orWhere('c.cSNDefine1', '')->orWhere('c.cSNDefine1', $construction_id);
|
|
|
+// })
|
|
|
+ ->when(empty($construction_id), function ($query) {
|
|
|
+ return $query->where(function ($q) {
|
|
|
+ $q->whereNull('c.cSNDefine1')
|
|
|
+ ->orWhere('c.cSNDefine1', '');
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->orderBy('c.cSNDefine1','desc')
|
|
|
+ ->orderBy('a.ID','desc')
|
|
|
+ ->orderBy('c.AutoID','asc');
|
|
|
+
|
|
|
+ $list = $this->limit($model, '', $data);
|
|
|
+// $logs = $db->getQueryLog();dd($logs);
|
|
|
+
|
|
|
+ return [true, $list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnListFormU8ForMap($data){
|
|
|
+ //映射ip是否通畅
|
|
|
+ $bool = $this->isDomainAvailable($this->u8['domain']);
|
|
|
+ if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
+
|
|
|
+ $warehouse = [
|
|
|
+ '001',
|
|
|
+ '003',
|
|
|
+ '010',
|
|
|
+ ];
|
|
|
+
|
|
|
+ $list = $this->db->table('ST_SNState')
|
|
|
+ ->select("cInvCode as code",'cinvSN as sn')
|
|
|
+ ->whereIn("cWhCode", $warehouse)
|
|
|
+ ->whereIn("cInvCode", $data['code'])
|
|
|
+ ->whereIn('cInvSN', $data['sn'])
|
|
|
+// ->where("iSNState", 2)
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ $return = [];
|
|
|
+
|
|
|
+ foreach ($list as $value){
|
|
|
+ $return[] = [
|
|
|
+ 'code' => $value->code,
|
|
|
+ 'sn' => $value->sn
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $return];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function saveSnUseDataDetail($sn_type, $sn_for_u8, $data_id){
|
|
|
+ $bool = $this->isDomainAvailable($this->u8['domain']);
|
|
|
+ if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
+ $db = $this->db;
|
|
|
+
|
|
|
+ try {
|
|
|
+ DB::beginTransaction();
|
|
|
+ if(empty($sn_for_u8)){//删除
|
|
|
+ if($sn_type == 1){
|
|
|
+ $db->table('ST_SNState')
|
|
|
+ ->where('cSNDefine1', $data_id)
|
|
|
+ ->update(['cSNDefine1' => ""]);
|
|
|
+ }else{
|
|
|
+ $db->table('ST_SNDetail_SaleOut')
|
|
|
+ ->where('cSNDefine1', $data_id)
|
|
|
+ ->update(['cSNDefine1' => ""]);
|
|
|
+ }
|
|
|
+ }else{//增加或更新
|
|
|
+ if($sn_type == 1){
|
|
|
+ $db->table('ST_SNState')
|
|
|
+ ->whereIn('AutoID', $sn_for_u8)
|
|
|
+ ->update(['cSNDefine1' => $data_id]);
|
|
|
+ }else{
|
|
|
+ $db->table('ST_SNDetail_SaleOut')
|
|
|
+ ->whereIn('AutoID', $sn_for_u8)
|
|
|
+ ->update(['cSNDefine1' => $data_id]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+ }catch (\Exception $exception){
|
|
|
+ DB::rollBack();
|
|
|
+ return [false, $exception->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnForWarrantyData($data){
|
|
|
+ //映射ip是否通畅
|
|
|
+ $bool = $this->isDomainAvailable($this->u8['domain']);
|
|
|
+ if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
+
|
|
|
+ $warehouse = [
|
|
|
+ '001',
|
|
|
+ '003',
|
|
|
+ '010',
|
|
|
+ ];
|
|
|
+
|
|
|
+ $list = $this->db->table('ST_SNState')
|
|
|
+ ->select("cInvCode as code",'cinvSN as sn','AutoID as auto_id')
|
|
|
+ ->whereIn("cWhCode", $warehouse)
|
|
|
+ ->where('cInvSN', $data['sn'])
|
|
|
+// ->where("iSNState", 2)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ $listArray = [];
|
|
|
+ if (! empty($list)) $listArray = get_object_vars($list);
|
|
|
+
|
|
|
+ return [true, $listArray];
|
|
|
+ }
|
|
|
+
|
|
|
public function getPurchaseData($id){
|
|
|
$main = PurchaseOrder::whereIn('id',$id)
|
|
|
->where('del_time',0)
|