|
@@ -22,6 +22,7 @@ class U8XkyServerService extends Service
|
|
|
$inventoryData = [
|
|
$inventoryData = [
|
|
|
'order_number' => $this->generateBillNo([
|
|
'order_number' => $this->generateBillNo([
|
|
|
'type' => Inventory::Order_type,
|
|
'type' => Inventory::Order_type,
|
|
|
|
|
+ 'login_type' => $user['login_type'],
|
|
|
'period' => date("Ym")
|
|
'period' => date("Ym")
|
|
|
]),
|
|
]),
|
|
|
'code' => $data['code'] ?? "",
|
|
'code' => $data['code'] ?? "",
|
|
@@ -44,6 +45,7 @@ class U8XkyServerService extends Service
|
|
|
'iImpTaxRate' => $data['iImpTaxRate'] ?? 0, // 进项税率
|
|
'iImpTaxRate' => $data['iImpTaxRate'] ?? 0, // 进项税率
|
|
|
'iTaxRate' => $data['iTaxRate'] ?? 0, // 销项税率
|
|
'iTaxRate' => $data['iTaxRate'] ?? 0, // 销项税率
|
|
|
'customs_change_rate' => $data['customs_change_rate'] ?? 0,
|
|
'customs_change_rate' => $data['customs_change_rate'] ?? 0,
|
|
|
|
|
+ 'login_type' => $user['login_type'],
|
|
|
'crt_id' => $user['userid'],
|
|
'crt_id' => $user['userid'],
|
|
|
'crt_time' => time(),
|
|
'crt_time' => time(),
|
|
|
];
|
|
];
|
|
@@ -95,7 +97,7 @@ class U8XkyServerService extends Service
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
} catch (\Throwable $exception) {
|
|
} catch (\Throwable $exception) {
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
- return [false, "创建存货失败: " . $exception->getMessage()];
|
|
|
|
|
|
|
+ return [false, "编辑存货失败: " . $exception->getMessage()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
@@ -141,6 +143,7 @@ class U8XkyServerService extends Service
|
|
|
|
|
|
|
|
if(! empty($code)){
|
|
if(! empty($code)){
|
|
|
$bool = Inventory::where('del_time', 0)
|
|
$bool = Inventory::where('del_time', 0)
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->when(! empty($id), function ($query) use($id){
|
|
->when(! empty($id), function ($query) use($id){
|
|
|
return $query->where('id', '<>', $id);
|
|
return $query->where('id', '<>', $id);
|
|
|
})
|
|
})
|
|
@@ -151,6 +154,7 @@ class U8XkyServerService extends Service
|
|
|
|
|
|
|
|
if(! $is_add){
|
|
if(! $is_add){
|
|
|
$bool = Inventory::where('del_time', 0)
|
|
$bool = Inventory::where('del_time', 0)
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->where('id', $id)
|
|
->where('id', $id)
|
|
|
->where('status', '>', Inventory::STATE_ZERO)
|
|
->where('status', '>', Inventory::STATE_ZERO)
|
|
|
->exists();
|
|
->exists();
|
|
@@ -162,7 +166,8 @@ class U8XkyServerService extends Service
|
|
|
|
|
|
|
|
public function inventoryCommon($data,$user, $field = []){
|
|
public function inventoryCommon($data,$user, $field = []){
|
|
|
$model = Inventory::where('del_time',0)
|
|
$model = Inventory::where('del_time',0)
|
|
|
- ->where('crt_id', $user['userid'])
|
|
|
|
|
|
|
+// ->where('crt_id', $user['userid'])
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->orderby('id', 'desc');
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
@@ -187,7 +192,11 @@ class U8XkyServerService extends Service
|
|
|
public function fillInventoryData($data, $user){
|
|
public function fillInventoryData($data, $user){
|
|
|
if(empty($data['data'])) return $data;
|
|
if(empty($data['data'])) return $data;
|
|
|
|
|
|
|
|
|
|
+ $map = DDEmployee::whereIn('userid', array_unique(array_column($data['data'],'crt_id')))
|
|
|
|
|
+ ->pluck('name','id')
|
|
|
|
|
+ ->toArray();
|
|
|
foreach ($data['data'] as $key => $value){
|
|
foreach ($data['data'] as $key => $value){
|
|
|
|
|
+ $data['data'][$key]['crt_name'] = $map[$value['crt_id']] ?? "";
|
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
$data['data'][$key]['status_title'] = Inventory::$name[$value['status']] ?? '';
|
|
$data['data'][$key]['status_title'] = Inventory::$name[$value['status']] ?? '';
|
|
|
$data['data'][$key]['bSale'] = $value['bSale'] ? '是' : '否';
|
|
$data['data'][$key]['bSale'] = $value['bSale'] ? '是' : '否';
|
|
@@ -240,6 +249,7 @@ class U8XkyServerService extends Service
|
|
|
$vendorData = [
|
|
$vendorData = [
|
|
|
'order_number' => $this->generateBillNo([
|
|
'order_number' => $this->generateBillNo([
|
|
|
'type' => Vendor::Order_type,
|
|
'type' => Vendor::Order_type,
|
|
|
|
|
+ 'login_type' => $user['login_type'],
|
|
|
'period' => date("Ym")
|
|
'period' => date("Ym")
|
|
|
]),
|
|
]),
|
|
|
'code' => $data['code'] ?? "",
|
|
'code' => $data['code'] ?? "",
|
|
@@ -247,6 +257,7 @@ class U8XkyServerService extends Service
|
|
|
'easy_title' => $data['easy_title'] ?? "",
|
|
'easy_title' => $data['easy_title'] ?? "",
|
|
|
'category_code' => $data['category_code'] ?? "",
|
|
'category_code' => $data['category_code'] ?? "",
|
|
|
'category_code_title' => $data['category_code_title'] ?? "",
|
|
'category_code_title' => $data['category_code_title'] ?? "",
|
|
|
|
|
+ 'login_type' => $user['login_type'] ?? "",
|
|
|
'crt_id' => $user['userid'],
|
|
'crt_id' => $user['userid'],
|
|
|
'crt_time' => time(),
|
|
'crt_time' => time(),
|
|
|
];
|
|
];
|
|
@@ -283,7 +294,7 @@ class U8XkyServerService extends Service
|
|
|
DB::commit();
|
|
DB::commit();
|
|
|
} catch (\Throwable $exception) {
|
|
} catch (\Throwable $exception) {
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
- return [false, "创建供应商失败: " . $exception->getMessage()];
|
|
|
|
|
|
|
+ return [false, "编辑供应商失败: " . $exception->getMessage()];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
@@ -391,6 +402,7 @@ class U8XkyServerService extends Service
|
|
|
// 使用 GROUP_CONCAT 将 title 合并,并起别名为 titles
|
|
// 使用 GROUP_CONCAT 将 title 合并,并起别名为 titles
|
|
|
DB::raw('GROUP_CONCAT(title SEPARATOR ",") as titles')
|
|
DB::raw('GROUP_CONCAT(title SEPARATOR ",") as titles')
|
|
|
])
|
|
])
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->groupBy('userid', 'type')
|
|
->groupBy('userid', 'type')
|
|
|
->orderBy('type', 'desc'); // 或者根据你的需求排序
|
|
->orderBy('type', 'desc'); // 或者根据你的需求排序
|
|
|
|
|
|
|
@@ -425,6 +437,7 @@ class U8XkyServerService extends Service
|
|
|
if(! isset($data['userid'])) return [false, '人员id不能为空'];
|
|
if(! isset($data['userid'])) return [false, '人员id不能为空'];
|
|
|
|
|
|
|
|
return [true, FieldData::where('type', $data['type'])
|
|
return [true, FieldData::where('type', $data['type'])
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->where('userid', $data['userid'])
|
|
->where('userid', $data['userid'])
|
|
|
->get()->toArray()];
|
|
->get()->toArray()];
|
|
|
}
|
|
}
|
|
@@ -440,12 +453,13 @@ class U8XkyServerService extends Service
|
|
|
'userid' => $data['userid'],
|
|
'userid' => $data['userid'],
|
|
|
'key' => $value['key'],
|
|
'key' => $value['key'],
|
|
|
'title' => $value['title'],
|
|
'title' => $value['title'],
|
|
|
|
|
+ 'login_type' => $user['login_type']
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
- FieldData::where('userid', $data['userid'])->delete();
|
|
|
|
|
|
|
+ FieldData::where('userid', $data['userid'])->where('login_type', $user['login_type'])->delete();
|
|
|
|
|
|
|
|
if(! empty($insert)) FieldData::insert($insert);
|
|
if(! empty($insert)) FieldData::insert($insert);
|
|
|
} catch (\Throwable $exception) {
|
|
} catch (\Throwable $exception) {
|
|
@@ -465,6 +479,7 @@ class U8XkyServerService extends Service
|
|
|
|
|
|
|
|
public function ddEmployeeCommon($data,$user, $field = []){
|
|
public function ddEmployeeCommon($data,$user, $field = []){
|
|
|
$model = DDEmployee::where('del_time',0)
|
|
$model = DDEmployee::where('del_time',0)
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->orderby('id', 'desc');
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
if(! empty($data['id'])) $model->where('id', $data['id']);
|
|
@@ -494,10 +509,11 @@ class U8XkyServerService extends Service
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
$field_list = [];
|
|
$field_list = [];
|
|
|
- $employee = DDEmployee::where('userid', $user['userid'])->first();
|
|
|
|
|
|
|
+ $employee = DDEmployee::where('userid', $user['userid'])->where('login_type', $user['login_type'])->first();
|
|
|
$qx = $employee['qx'] ?? 0;
|
|
$qx = $employee['qx'] ?? 0;
|
|
|
if(empty($qx)) {
|
|
if(empty($qx)) {
|
|
|
$field_list = FieldData::where('userid', $user['userid'])
|
|
$field_list = FieldData::where('userid', $user['userid'])
|
|
|
|
|
+ ->where('login_type', $user['login_type'])
|
|
|
->where('type', FieldData::STATE_ZERO)
|
|
->where('type', FieldData::STATE_ZERO)
|
|
|
->pluck('key')
|
|
->pluck('key')
|
|
|
->all();
|
|
->all();
|
|
@@ -784,373 +800,4 @@ class U8XkyServerService extends Service
|
|
|
|
|
|
|
|
return [true, $list];
|
|
return [true, $list];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //U8 存货新增到用友
|
|
|
|
|
- public function inventoryAdd1($data, $user){
|
|
|
|
|
- $inventory = Inventory::where('del_time', 0)
|
|
|
|
|
- ->where('id', $data['id'])
|
|
|
|
|
- ->first();
|
|
|
|
|
- if(empty($inventory)) return [false, '存货记录不存在或已被删除'];
|
|
|
|
|
- $inventory = $inventory->toArray();
|
|
|
|
|
- if($inventory['status'] != Inventory::STATE_TWO) return [false, '存货记录未审核通过'];
|
|
|
|
|
-
|
|
|
|
|
- $title = $inventory['title'];
|
|
|
|
|
- $category_code = $inventory['category_code'];
|
|
|
|
|
- if(! empty($data['code'])){
|
|
|
|
|
- //用户传入
|
|
|
|
|
- $no = $inventory['code'];
|
|
|
|
|
- $flag_title = "重填";
|
|
|
|
|
- }else{
|
|
|
|
|
- //生成编码
|
|
|
|
|
- list($status, $msg) = $this->generate('inventory','1005');
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
- $no = $msg;
|
|
|
|
|
- $flag_title = "重试";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $inventoryData = [
|
|
|
|
|
- 'cInvCode' => $no,
|
|
|
|
|
- 'cInvName' => $title,
|
|
|
|
|
- 'cInvCCode' => $category_code,
|
|
|
|
|
- 'cInvStd' => $inventory['size'] ?? null, // 规格型号
|
|
|
|
|
- 'bSale' => $inventory['bSale'], //内销
|
|
|
|
|
- 'bExpSale' => $inventory['bExpSale'], //外销
|
|
|
|
|
- 'bPurchase' => $inventory['bPurchase'], // 采购
|
|
|
|
|
- 'bSelf' => $inventory['bSelf'], // 自制
|
|
|
|
|
- 'bComsume' => $inventory['bComsume'], // 生产耗材
|
|
|
|
|
- 'iGroupType' => $inventory['unit_group_type'], // 计量单位组类别
|
|
|
|
|
- 'cGroupCode' => $inventory['unit_group_code'], //计量单位组
|
|
|
|
|
- 'cComUnitCode' => $inventory['unit_code'], // 主计量单位
|
|
|
|
|
- 'cShopUnit' => $inventory['unit_code'], // 零售计量单位
|
|
|
|
|
- 'iImpTaxRate' => $inventory['iImpTaxRate'], // 进项税率
|
|
|
|
|
- 'iTaxRate' => $inventory['iTaxRate'], // 销项税率
|
|
|
|
|
- 'dSDate' => date("Y-m-d 00:00:00.000"), // 启用日期
|
|
|
|
|
- 'cEnterprise' => $inventory['vendor_code_title'] ?? null,
|
|
|
|
|
- 'iSupplyType' => '0', // 供应类型
|
|
|
|
|
- 'fConvertRate' => '1.0', // 转换因子
|
|
|
|
|
- 'bInTotalCost' => '1', // 成本累计否
|
|
|
|
|
- 'cPlanMethod' => 'R',
|
|
|
|
|
- 'cSRPolicy' => 'PE',
|
|
|
|
|
- 'bBomMain' => '0', // 允许BOM母件
|
|
|
|
|
- 'bBomSub' => '0', // 允许BOM子件
|
|
|
|
|
- 'bProductBill' => '0', // 允许生产订单
|
|
|
|
|
- 'iPlanDefault' => '1',
|
|
|
|
|
- 'iAllocatePrintDgt' => '4',
|
|
|
|
|
- 'bService' => '0',
|
|
|
|
|
- 'bAccessary' => '0',
|
|
|
|
|
- 'iInvAdvance' => '0.0',
|
|
|
|
|
- 'bInvQuality' => '0',
|
|
|
|
|
- 'bInvBatch' => '0',
|
|
|
|
|
- 'bInvEntrust' => '0',
|
|
|
|
|
- 'bInvOverStock' => '0',
|
|
|
|
|
- 'bFree1' => '0',
|
|
|
|
|
- 'bFree2' => '0',
|
|
|
|
|
- 'bInvType' => '0',
|
|
|
|
|
- 'bFree3' => '0',
|
|
|
|
|
- 'bFree4' => '0',
|
|
|
|
|
- 'bFree5' => '0',
|
|
|
|
|
- 'bFree6' => '0',
|
|
|
|
|
- 'bFree7' => '0',
|
|
|
|
|
- 'bFree8' => '0',
|
|
|
|
|
- 'bFree9' => '0',
|
|
|
|
|
- 'bFree10' => '0',
|
|
|
|
|
- 'cCreatePerson' => 'demo',
|
|
|
|
|
- 'cModifyPerson' => 'demo', // 变更
|
|
|
|
|
- 'dModifyDate' => date("Y-m-d H:i:s.000"),
|
|
|
|
|
- 'bFixExch' => '0',
|
|
|
|
|
- 'bTrack' => '0',
|
|
|
|
|
- 'bSerial' => '0',
|
|
|
|
|
- 'bBarCode' => '0',
|
|
|
|
|
- 'bSolitude' => '0',
|
|
|
|
|
- 'bSpecialties' => '0',
|
|
|
|
|
- 'bPropertyCheck' => '0',
|
|
|
|
|
- 'iRecipeBatch' => '0',
|
|
|
|
|
- 'bPromotSales' => '0',
|
|
|
|
|
- 'bPlanInv' => '0',
|
|
|
|
|
- 'bProxyForeign' => '0',
|
|
|
|
|
- 'bATOModel' => '0',
|
|
|
|
|
- 'bCheckItem' => '0',
|
|
|
|
|
- 'bPTOModel' => '0',
|
|
|
|
|
- 'bEquipment' => '0',
|
|
|
|
|
- 'bMPS' => '0',
|
|
|
|
|
- 'bROP' => '0',
|
|
|
|
|
- 'bRePlan' => '0',
|
|
|
|
|
- 'bBillUnite' => '0',
|
|
|
|
|
- 'bCutMantissa' => '0',
|
|
|
|
|
- 'bConfigFree1' => '0',
|
|
|
|
|
- 'bConfigFree2' => '0',
|
|
|
|
|
- 'bConfigFree3' => '0',
|
|
|
|
|
- 'bConfigFree4' => '0',
|
|
|
|
|
- 'bConfigFree5' => '0',
|
|
|
|
|
- 'bConfigFree6' => '0',
|
|
|
|
|
- 'bConfigFree7' => '0',
|
|
|
|
|
- 'bConfigFree8' => '0',
|
|
|
|
|
- 'bConfigFree9' => '0',
|
|
|
|
|
- 'bConfigFree10' => '0',
|
|
|
|
|
- 'bPeriodDT' => '0',
|
|
|
|
|
- 'bOutInvDT' => '0',
|
|
|
|
|
- 'bBackInvDT' => '0',
|
|
|
|
|
- 'bDTWarnInv' => '0',
|
|
|
|
|
- 'bImportMedicine' => '0',
|
|
|
|
|
- 'bFirstBusiMedicine' => '0',
|
|
|
|
|
- 'bForeExpland' => '0',
|
|
|
|
|
- 'bInvModel' => '0',
|
|
|
|
|
- 'bKCCutMantissa' => '0',
|
|
|
|
|
- 'bReceiptByDT' => '0',
|
|
|
|
|
- 'bCheckBSATP' => '0',
|
|
|
|
|
- 'bCheckFree1' => '0',
|
|
|
|
|
- 'bCheckFree2' => '0',
|
|
|
|
|
- 'bCheckFree3' => '0',
|
|
|
|
|
- 'bCheckFree4' => '0',
|
|
|
|
|
- 'bCheckFree5' => '0',
|
|
|
|
|
- 'bCheckFree6' => '0',
|
|
|
|
|
- 'bCheckFree7' => '0',
|
|
|
|
|
- 'bCheckFree8' => '0',
|
|
|
|
|
- 'bCheckFree9' => '0',
|
|
|
|
|
- 'bCheckFree10' => '0',
|
|
|
|
|
- 'iCheckATP' => '0',
|
|
|
|
|
- 'bPiece' => '0',
|
|
|
|
|
- 'bSrvItem' => '0',
|
|
|
|
|
- 'bSrvFittings' => '0',
|
|
|
|
|
- 'bSpecialOrder' => '0',
|
|
|
|
|
- 'bTrackSaleBill' => '0',
|
|
|
|
|
- 'bCheckBatch' => '0',
|
|
|
|
|
- 'bMngOldpart' => '0',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- $inventorySubData = [
|
|
|
|
|
- 'cInvSubCode' => $no,
|
|
|
|
|
- 'iSurenessType' => '1',
|
|
|
|
|
- 'bIsAttachFile' => '0',
|
|
|
|
|
- 'bInByProCheck' => '1',
|
|
|
|
|
- 'iRequireTrackStyle' => '0',
|
|
|
|
|
- 'iExpiratDateCalcu' => '0',
|
|
|
|
|
- 'iBOMExpandUnitType' => '1',
|
|
|
|
|
- 'iDrawType' => $inventory['iDrawType'] ?? 0, // 领用方式
|
|
|
|
|
- 'fInvCIQExch' => $inventory['customs_change_rate'] ?? 1, // 海关换算率
|
|
|
|
|
- 'bInvKeyPart' => '1',
|
|
|
|
|
- 'iAcceptEarlyDays' => '999',
|
|
|
|
|
- 'dInvCreateDatetime' => date("Y-m-d H:i:s.000"),
|
|
|
|
|
- 'bPUQuota' => '0',
|
|
|
|
|
- 'bInvROHS' => '0',
|
|
|
|
|
- 'bPrjMat' => '0',
|
|
|
|
|
- 'bInvAsset' => '0',
|
|
|
|
|
- 'bSrvProduct' => '0',
|
|
|
|
|
- 'iAcceptDelayDays' => '0',
|
|
|
|
|
- 'bSCkeyProjections' => '0',
|
|
|
|
|
- 'iSupplyPeriodType' => '1',
|
|
|
|
|
- 'iAvailabilityDate' => '1',
|
|
|
|
|
- 'bImport' => '0',
|
|
|
|
|
- 'bCheckSubitemCost' => '1',
|
|
|
|
|
- 'fRoundFactor' => '0.0',
|
|
|
|
|
- 'bConsiderFreeStock' => '1',
|
|
|
|
|
- 'bSuitRetail' => '0',
|
|
|
|
|
- 'bFeatureMatch' => '0',
|
|
|
|
|
- 'bProduceByFeatureAllocate' => '0',
|
|
|
|
|
- 'bMaintenance' => '0',
|
|
|
|
|
- 'iMaintenanceCycleUnit' => '0',
|
|
|
|
|
- 'bCoupon' => '0',
|
|
|
|
|
- 'bStoreCard' => '0',
|
|
|
|
|
- 'bProcessProduct' => '0',
|
|
|
|
|
- 'bProcessMaterial' => '0',
|
|
|
|
|
- // 所有的价格自由项默认设为 '0'
|
|
|
|
|
- 'bPurPriceFree1' => '0', 'bPurPriceFree2' => '0', 'bPurPriceFree3' => '0', 'bPurPriceFree4' => '0', 'bPurPriceFree5' => '0',
|
|
|
|
|
- 'bPurPriceFree6' => '0', 'bPurPriceFree7' => '0', 'bPurPriceFree8' => '0', 'bPurPriceFree9' => '0', 'bPurPriceFree10' => '0',
|
|
|
|
|
- 'bOMPriceFree1' => '0', 'bOMPriceFree2' => '0', 'bOMPriceFree3' => '0', 'bOMPriceFree4' => '0', 'bOMPriceFree5' => '0',
|
|
|
|
|
- 'bOMPriceFree6' => '0', 'bOMPriceFree7' => '0', 'bOMPriceFree8' => '0', 'bOMPriceFree9' => '0', 'bOMPriceFree10' => '0',
|
|
|
|
|
- 'bSalePriceFree1' => '0', 'bSalePriceFree2' => '0', 'bSalePriceFree3' => '0', 'bSalePriceFree4' => '0', 'bSalePriceFree5' => '0',
|
|
|
|
|
- 'bSalePriceFree6' => '0', 'bSalePriceFree7' => '0', 'bSalePriceFree8' => '0', 'bSalePriceFree9' => '0', 'bSalePriceFree10' => '0',
|
|
|
|
|
- // 所有的控制自由项默认设为 '0'
|
|
|
|
|
- 'bControlFreeRange1' => '0', 'bControlFreeRange2' => '0', 'bControlFreeRange3' => '0', 'bControlFreeRange4' => '0', 'bControlFreeRange5' => '0',
|
|
|
|
|
- 'bControlFreeRange6' => '0', 'bControlFreeRange7' => '0', 'bControlFreeRange8' => '0', 'bControlFreeRange9' => '0', 'bControlFreeRange10' => '0',
|
|
|
|
|
- // 所有的批次属性默认设为 '0'
|
|
|
|
|
- 'bBatchProperty1' => '0', 'bBatchProperty2' => '0', 'bBatchProperty3' => '0', 'bBatchProperty4' => '0', 'bBatchProperty5' => '0',
|
|
|
|
|
- 'bBatchProperty6' => '0', 'bBatchProperty7' => '0', 'bBatchProperty8' => '0', 'bBatchProperty9' => '0', 'bBatchProperty10' => '0',
|
|
|
|
|
- 'bBondedInv' => '0',
|
|
|
|
|
- 'bBatchCreate' => '0',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- DB::connection('sqlsrv')->beginTransaction();
|
|
|
|
|
-
|
|
|
|
|
- $exists = DB::connection('sqlsrv')
|
|
|
|
|
- ->table('Inventory')
|
|
|
|
|
- ->where('cInvCode', $inventoryData['cInvCode'])
|
|
|
|
|
- ->lockForUpdate() // 锁定该行,防止并发冲突
|
|
|
|
|
- ->exists();
|
|
|
|
|
-
|
|
|
|
|
- if ($exists) return [false, '存货编码已存在,请' . $flag_title];
|
|
|
|
|
-
|
|
|
|
|
- DB::connection('sqlsrv')->table('Inventory')->insert($inventoryData);
|
|
|
|
|
- DB::connection('sqlsrv')->table('Inventory_sub')->insert($inventorySubData);
|
|
|
|
|
-
|
|
|
|
|
- DB::connection('sqlsrv')->commit();
|
|
|
|
|
- } catch (\Throwable $exception) {
|
|
|
|
|
- DB::connection('sqlsrv')->rollBack();
|
|
|
|
|
-
|
|
|
|
|
- return [false, "创建用友失败: " . $exception->getMessage()];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [true, ''];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //U8 供应商新增
|
|
|
|
|
- public function vendorAdd1($data, $user){
|
|
|
|
|
- $vendor = Vendor::where('del_time', 0)
|
|
|
|
|
- ->where('id', $data['id'])
|
|
|
|
|
- ->first();
|
|
|
|
|
- if(empty($vendor)) return [false, '供应商记录不存在或已被删除'];
|
|
|
|
|
- $vendor = $vendor->toArray();
|
|
|
|
|
- if($vendor['status'] != Vendor::STATE_TWO) return [false, '供应商记录未审核通过'];
|
|
|
|
|
-
|
|
|
|
|
- if(! empty($vendor['code'])){
|
|
|
|
|
- //用户传入
|
|
|
|
|
- $no = $vendor['code'];
|
|
|
|
|
- $flag_title = "重填";
|
|
|
|
|
- }else{
|
|
|
|
|
- //生成编码
|
|
|
|
|
- list($status, $msg) = $this->generate('vendor');
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
- $no = $msg;
|
|
|
|
|
- $flag_title = "重试";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $vendorData = [
|
|
|
|
|
- 'cVenCode' => $no,
|
|
|
|
|
- 'cVenName' => $vendor['title'],
|
|
|
|
|
- 'cVenAbbName' => $vendor['easy_title'],
|
|
|
|
|
- 'cVCCode' => $vendor['category_code'],
|
|
|
|
|
- 'dVenDevDate' => date("Y-m-d 00:00:00.000"),
|
|
|
|
|
- 'iVenDisRate' => '0.0',
|
|
|
|
|
- 'iVenCreLine' => '0.0',
|
|
|
|
|
- 'iVenCreDate' => '0',
|
|
|
|
|
- 'cVenHeadCode' => $no,
|
|
|
|
|
- 'iAPMoney' => '0.0',
|
|
|
|
|
- 'iLastMoney' => '0.0',
|
|
|
|
|
- 'iLRMoney' => '0.0',
|
|
|
|
|
- 'iFrequency' => '0',
|
|
|
|
|
- 'bVenTax' => '1',
|
|
|
|
|
- 'cCreatePerson' => 'demo',
|
|
|
|
|
- 'cModifyPerson' => 'demo',
|
|
|
|
|
- 'dModifyDate' => date("Y-m-d H:i:s.000"),
|
|
|
|
|
- 'iGradeABC' => '-1',
|
|
|
|
|
- 'bLicenceDate' => '0',
|
|
|
|
|
- 'bBusinessDate' => '0',
|
|
|
|
|
- 'bProxyDate' => '0',
|
|
|
|
|
- 'bPassGMP' => '0',
|
|
|
|
|
- 'bVenCargo' => '1', // 采购
|
|
|
|
|
- 'bProxyForeign' => '0', // 委外
|
|
|
|
|
- 'bVenService' => '0', // 服务
|
|
|
|
|
- 'bVenOverseas' => '0', // 国外
|
|
|
|
|
- 'cVenExch_name' => '人民币',
|
|
|
|
|
- 'iVenGSPType' => '0',
|
|
|
|
|
- 'iVenGSPAuth' => '-1',
|
|
|
|
|
- 'bVenAccPeriodMng' => '0',
|
|
|
|
|
- 'bVenHomeBranch' => '0',
|
|
|
|
|
- 'dVenCreateDatetime' => date("Y-m-d H:i:s.000"),
|
|
|
|
|
- 'bIsVenAttachFile' => '0',
|
|
|
|
|
- 'bRetail' => '0',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- DB::connection('sqlsrv')->beginTransaction();
|
|
|
|
|
-
|
|
|
|
|
- $exists = DB::connection('sqlsrv')
|
|
|
|
|
- ->table('Vendor')
|
|
|
|
|
- ->where('cVenCode', $vendorData['cVenCode'])
|
|
|
|
|
- ->lockForUpdate() // 锁定该行,防止并发冲突
|
|
|
|
|
- ->exists();
|
|
|
|
|
-
|
|
|
|
|
- if ($exists) return [false, '供应商编码已存在,请' . $flag_title];
|
|
|
|
|
-
|
|
|
|
|
- DB::connection('sqlsrv')->table('Vendor')->insert($vendorData);
|
|
|
|
|
-
|
|
|
|
|
- DB::connection('sqlsrv')->commit();
|
|
|
|
|
-
|
|
|
|
|
- } catch (\Throwable $exception) {
|
|
|
|
|
- DB::connection('sqlsrv')->rollBack();
|
|
|
|
|
-
|
|
|
|
|
- return [false, "创建供应商失败: " . $exception->getMessage()];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [true, ''];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 生成编码
|
|
|
|
|
- public function generate($type, $classCode = "")
|
|
|
|
|
- {
|
|
|
|
|
- try {
|
|
|
|
|
- // 1. 确定对象映射
|
|
|
|
|
- $cardNumber = ($type === 'inventory') ? 'inventory' : 'Vendor';
|
|
|
|
|
- $cardNumber_name = ($type === 'inventory') ? '存货' : '供应商';
|
|
|
|
|
- $table = ($type === 'inventory') ? 'Inventory' : 'Vendor';
|
|
|
|
|
- $codeField = ($type === 'inventory') ? 'cInvCode' : 'cVenCode';
|
|
|
|
|
-
|
|
|
|
|
- // 2. 获取 U8 规则定义
|
|
|
|
|
- $rule = DB::connection('sqlsrv')->table('VoucherNumber')
|
|
|
|
|
- ->where('CardNumber', $cardNumber)
|
|
|
|
|
- ->first();
|
|
|
|
|
-
|
|
|
|
|
- if (!$rule) return [false, "未找到 {$cardNumber_name} 的规则定义"];
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 3. 动态解析前缀 (Prefix1, Prefix2, Prefix3)
|
|
|
|
|
- * U8 的规则通常存放在 PrefixRule 或 Prefix 字段中
|
|
|
|
|
- */
|
|
|
|
|
- $prefix = "";
|
|
|
|
|
- for ($i = 1; $i <= 3; $i++) {
|
|
|
|
|
- $ruleField = "Prefix{$i}Rule";
|
|
|
|
|
- $valField = "Prefix{$i}";
|
|
|
|
|
-
|
|
|
|
|
- // 检查规则描述
|
|
|
|
|
- $ruleDesc = $rule->$ruleField ?? ''; // 例如 "存货分类编码" 或 "GYS"
|
|
|
|
|
- $staticVal = $rule->$valField ?? '';
|
|
|
|
|
-
|
|
|
|
|
- if (str_contains($ruleDesc, '分类') || str_contains($staticVal, '分类')) {
|
|
|
|
|
- // 如果规则提到“分类”,则填入传入的分类编码
|
|
|
|
|
- $prefix .= $classCode;
|
|
|
|
|
- } elseif (!empty($ruleDesc)) {
|
|
|
|
|
- // 如果规则是具体的字符(如 "GYS"),直接拼接
|
|
|
|
|
- $prefix .= $ruleDesc;
|
|
|
|
|
- } elseif (!empty($staticVal) && $staticVal !== '手工输入' && $staticVal !== '存货分类编码') {
|
|
|
|
|
- // 如果静态值不是提示语,则作为前缀
|
|
|
|
|
- $prefix .= $staticVal;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 4. 获取流水号配置 (Glide)
|
|
|
|
|
- $glideLen = $rule->GlideLen > 0 ? $rule->GlideLen : 4;
|
|
|
|
|
- $startNum = $rule->iStartNumber ?? 1;
|
|
|
|
|
-
|
|
|
|
|
- // 5. 查找当前最大编码
|
|
|
|
|
- $expectedLen = strlen($prefix) + $glideLen;
|
|
|
|
|
-
|
|
|
|
|
- $lastCode = DB::connection('sqlsrv')->table($table)
|
|
|
|
|
- ->where($codeField, 'like', $prefix . '%')
|
|
|
|
|
- ->whereRaw("LEN($codeField) = $expectedLen")
|
|
|
|
|
- ->orderBy($codeField, 'desc')
|
|
|
|
|
- ->value($codeField);
|
|
|
|
|
-
|
|
|
|
|
- // 6. 生成编码
|
|
|
|
|
- if (!$lastCode) {
|
|
|
|
|
- // 初始:前缀 + 起始值补零
|
|
|
|
|
- $finalCode = $prefix . str_pad($startNum, $glideLen, '0', STR_PAD_LEFT);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 截取流水号自增
|
|
|
|
|
- $lastSerial = substr($lastCode, -$glideLen);
|
|
|
|
|
- $nextSerial = ++$lastSerial;
|
|
|
|
|
-
|
|
|
|
|
- // 溢出检查
|
|
|
|
|
- if (strlen($nextSerial) > $glideLen) {
|
|
|
|
|
- return [false, "流水号已溢出"];
|
|
|
|
|
- }
|
|
|
|
|
- $finalCode = $prefix . str_pad($nextSerial, $glideLen, '0', STR_PAD_LEFT);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [true, $finalCode];
|
|
|
|
|
-
|
|
|
|
|
- } catch (\Throwable $e) {
|
|
|
|
|
- return [false, "生成失败: " . $e->getMessage()];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|