|
|
@@ -587,6 +587,291 @@ class TestService extends Service
|
|
|
return [$status, $msg];
|
|
|
}
|
|
|
|
|
|
+ //检验单(不是用友的检验单 所以不是参照)生成产成品入库单
|
|
|
+ public function productInByZj($data, $common_array){
|
|
|
+ // u8 token 获取
|
|
|
+ list($status, $msg) = $this->getToken($common_array);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+ $title = $common_array['title'];
|
|
|
+
|
|
|
+ // 组织 ProductIn 结构
|
|
|
+ $tmp = [
|
|
|
+ "Inum" => "ProductIn",
|
|
|
+ "Data" => [
|
|
|
+ "iHead" => [
|
|
|
+ "cWhCode" => $data['warehouseCode'] ?? "01", // 默认产成品库
|
|
|
+ "cRdCode" => "105", // 入库类别
|
|
|
+ "cDepCode" => null,
|
|
|
+ "cMemo" => "接口生成",
|
|
|
+ "cSource" => "库存",
|
|
|
+ "cBusType" => "成品入库",
|
|
|
+ "dDate" => date("Y-m-d"),
|
|
|
+ "IsVerify" => true,
|
|
|
+ ],
|
|
|
+ "iBody" => []
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ //合格数量加让步接收数量
|
|
|
+ $num = $data['quality_receive_num'] ?? 0;
|
|
|
+ $num2 = $data['compromise_receive_num'] ?? 0;
|
|
|
+ $num = bcadd($num, $num2,2);
|
|
|
+
|
|
|
+ //产品编码
|
|
|
+ $product_code = $data['material_code'] ?? "";
|
|
|
+
|
|
|
+ $baseData = [
|
|
|
+ "iRowNo" => 1,
|
|
|
+ "cInvCode" => $product_code,
|
|
|
+ "iQuantity" => $num,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($common_array['site'] == "LFMY") {
|
|
|
+ // 朗峰结构 (cdefine28 - cdefine33)
|
|
|
+ $extData = [
|
|
|
+ 'cdefine28' => $data['brand_name'] ?? null,
|
|
|
+ 'cdefine29' => $data['safe'] ?? null,
|
|
|
+ 'cdefine30' => $data['decor'] ?? null,
|
|
|
+ 'cdefine31' => $data['craft_type_code'] ?? null,
|
|
|
+ 'cdefine32' => $data['decor_b'] ?? null,
|
|
|
+ 'cdefine33' => $data['craft_type_code_b'] ?? null,
|
|
|
+ ];
|
|
|
+ } elseif ($common_array['site'] == "HCLT") {
|
|
|
+ // 恒昌结构 (cfree + cdefine22/23 + cdefine28-31)
|
|
|
+ $extData = [
|
|
|
+ 'cfree1' => $data['customer_brand'] ?? null,
|
|
|
+ 'cfree2' => $data['color'] ?? null,
|
|
|
+ 'cdefine22' => $data['plan_no'] ?? null,
|
|
|
+ 'cdefine23' => $data['contract_no'] ?? null,
|
|
|
+ 'cdefine28' => $data['technical_require'] ?? null,
|
|
|
+ 'cdefine29' => $data['quality_require'] ?? null,
|
|
|
+ 'cdefine30' => $data['package_require'] ?? null,
|
|
|
+ 'cdefine31' => $data['shipping_mark'] ?? null,
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $extData = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $inventoryEntry = array_merge($baseData, $extData);
|
|
|
+
|
|
|
+ // 组织表体
|
|
|
+ $tmp["Data"]["iBody"][] = $inventoryEntry;
|
|
|
+
|
|
|
+ $final_data = [$tmp];
|
|
|
+
|
|
|
+ // 调用参数
|
|
|
+ $host = $msg['host'] ?? "";
|
|
|
+ $token = $msg['token'] ?? "";
|
|
|
+ $url = $host . "/api/ProductIn/Add";
|
|
|
+ $header = ["Authorization: {$token}", 'Content-Type:application/json'];
|
|
|
+
|
|
|
+ $json = json_encode($final_data);
|
|
|
+
|
|
|
+ list($status, $result) = $this->post_helper($url, json_encode($json), $header, 60, $title . '生成产成品入库单');
|
|
|
+ if(! $status) return [false, $result];
|
|
|
+
|
|
|
+ if(! isset($result['code'])) return [false, '产成品入库单生成失败,请重试'];
|
|
|
+ if($result['code'] != 0) return [false, $result['msg']];
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ //检验单(不是用友的检验单 所以不是参照)生成采购入库单
|
|
|
+ public function purchaseInByZj($data, $common_array)
|
|
|
+ {
|
|
|
+ // u8 token 获取
|
|
|
+ list($status, $msg) = $this->getToken($common_array);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+ $title = $common_array['title'];
|
|
|
+
|
|
|
+ //合格数量加让步接收数量
|
|
|
+ $num = $data['quality_receive_num'] ?? 0;
|
|
|
+ $num2 = $data['compromise_receive_num'] ?? 0;
|
|
|
+ $num = bcadd($num, $num2,2);
|
|
|
+ $qty = $num;
|
|
|
+ $taxRate = $data['tax_rate'] ?? 0; // 税率
|
|
|
+ $taxUnitPrice = $data['tax_price'] ?? 0; // 原币含税单价
|
|
|
+
|
|
|
+ // 1. 价税合计 (iSum)
|
|
|
+ $iSum = round($qty * $taxUnitPrice, 2);
|
|
|
+ // 2. 原币无税金额 (imoney) = 价税合计 / (1 + 税率/100)
|
|
|
+ $iMoney = round($iSum / (1 + ($taxRate / 100)), 2);
|
|
|
+ // 3. 税额 (itax)
|
|
|
+ $iTax = round($iSum - $iMoney, 2);
|
|
|
+ // 4. 原币无税单价 (iunitprice)
|
|
|
+ $iUnitPrice = round($taxUnitPrice / (1 + ($taxRate / 100)), 6);
|
|
|
+
|
|
|
+ $baseData = [
|
|
|
+ "iRowNo" => 1,
|
|
|
+ "cInvCode" => $data['material_code'],
|
|
|
+ "iQuantity" => $qty,
|
|
|
+ "iPOsID" => $data['detail_id'] ?? 0,
|
|
|
+ "iOriTaxCost" => (float)$taxUnitPrice, // 原币含税单价
|
|
|
+ "iOriCost" => (float)$iUnitPrice, // 原币无税单价
|
|
|
+ "iOriMoney" => (float)$iMoney, // 原币无税金额
|
|
|
+ "iOriTaxPrice" => (float)$iTax, // 原币税额
|
|
|
+ "iOriSum" => (float)$iSum, // 原币价税合计
|
|
|
+ "iTaxRate" => (float)$taxRate, // 税率
|
|
|
+ "cBatch" => $data['batch'] ?? null,
|
|
|
+ "dMadeDate" => $data['made_date'] ?? null,
|
|
|
+ "dVDate" => $data['valid_date'] ?? null,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($common_array['site'] == "LFMY") {
|
|
|
+ // 朗峰结构 (cdefine28 - cdefine33)
|
|
|
+ $extData = [
|
|
|
+ 'cDefine28' => $data['brand_name'] ?? null,
|
|
|
+ 'cDefine29' => $data['safe'] ?? null,
|
|
|
+ 'cDefine30' => $data['decor'] ?? null,
|
|
|
+ 'cDefine31' => $data['craft_type_code'] ?? null,
|
|
|
+ 'cDefine32' => $data['decor_b'] ?? null,
|
|
|
+ 'cDefine33' => $data['craft_type_code_b'] ?? null,
|
|
|
+ ];
|
|
|
+ } elseif ($common_array['site'] == "HCLT") {
|
|
|
+ // 恒昌结构 (cfree + cdefine22/23 + cdefine28-31)
|
|
|
+ $extData = [
|
|
|
+ 'cFree1' => $data['customer_brand'] ?? null,
|
|
|
+ 'cFree2' => $data['color'] ?? null,
|
|
|
+ 'cFree3' => $data['bar_code'] ?? '无',
|
|
|
+ 'cDefine22' => $data['plan_no'] ?? null,
|
|
|
+ 'cDefine23' => $data['contract_no'] ?? null,
|
|
|
+ 'cDefine28' => $data['technical_require'] ?? null,
|
|
|
+ 'cDefine29' => $data['quality_require'] ?? null,
|
|
|
+ 'cDefine30' => $data['package_require'] ?? null,
|
|
|
+ 'cDefine31' => $data['shipping_mark'] ?? null,
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $extData = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $inventoryEntry = array_merge($baseData, $extData);
|
|
|
+
|
|
|
+ // 3. 组织采购入库单
|
|
|
+ $tmp = [
|
|
|
+ "Inum" => "PurchaseIn",
|
|
|
+ "Data" => [
|
|
|
+ "iHead" => [
|
|
|
+ "IsVerify" => true,
|
|
|
+ "bCalPrice" => true, // 开启自动计算
|
|
|
+ "PriceCalKey" => "iOriTaxCost", // 以含税单价为准
|
|
|
+ "cWhCode" => $data['warehouse_code'] ?? "",
|
|
|
+ "cVenCode" => $data['supplier_code'] ?? "",
|
|
|
+ "cRdCode" => $data['cRdCode'] ?? "101", //收发类别
|
|
|
+ "iExchRate" => $data['iExchRate'] ?? 1.0,
|
|
|
+ "iTaxRate" => (float)$taxRate,
|
|
|
+ "cExch_Name" => "人民币",
|
|
|
+ "cSource" => "库存",
|
|
|
+ "cBusType" => "普通采购",
|
|
|
+ "cMemo" => $data['cMemo'] ?? "接口生成",
|
|
|
+ "dDate" => date("Y-m-d"),
|
|
|
+ ],
|
|
|
+ "iBody" => [
|
|
|
+ $inventoryEntry
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $final_data = [$tmp];
|
|
|
+
|
|
|
+ // 4. 调用 API
|
|
|
+ list($host, $token) = $msg;
|
|
|
+ $header = ["Authorization: {$token}", 'Content-Type:application/json'];
|
|
|
+ $url = $host . "/api/PurchaseIn/Add";
|
|
|
+
|
|
|
+ $json = json_encode($final_data);
|
|
|
+
|
|
|
+ list($status, $result) = $this->post_helper($url,$json, $header, 60, $title . '生成采购入库单');
|
|
|
+
|
|
|
+ if(! $status) return [false, $result];
|
|
|
+ if(! isset($result['code'])) return [false, '采购入库单生成失败'];
|
|
|
+ if($result['code'] != 0) return [false, $result['msg']];
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ //检验单(不是用友的检验单 所以不是参照)生成其他入库单
|
|
|
+ public function otherInByZj($data, $common_array){
|
|
|
+ // u8 token 获取
|
|
|
+ list($status, $msg) = $this->getToken($common_array);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+ $title = $common_array['title'];
|
|
|
+
|
|
|
+ $baseData = [
|
|
|
+ "iRowNo" => 1,
|
|
|
+ "cInvCode" => $data['material_code'] ?? '',
|
|
|
+ "cBatch" => $data['batch'] ?? null,
|
|
|
+ "iinvexchrate" => null,
|
|
|
+ "iQuantity" => $data['quantity'], // 数量
|
|
|
+ "dMadeDate" => $data['made_date'] ?? null, // 生产日期
|
|
|
+ "dVDate" => $data['valid_date'] ?? null,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($common_array['site'] == "LFMY") {
|
|
|
+ // 朗峰结构 (cdefine28 - cDefine33)
|
|
|
+ $extData = [
|
|
|
+ 'cDefine28' => $data['brand_name'] ?? null,
|
|
|
+ 'cDefine29' => $data['safe'] ?? null,
|
|
|
+ 'cDefine30' => $data['decor'] ?? null,
|
|
|
+ 'cDefine31' => $data['craft_type_code'] ?? null,
|
|
|
+ 'cDefine32' => $data['decor_b'] ?? null,
|
|
|
+ 'cDefine33' => $data['craft_type_code_b'] ?? null,
|
|
|
+ ];
|
|
|
+ } elseif ($common_array['site'] == "HCLT") {
|
|
|
+ // 恒昌结构 (cfree + cdefine22/23 + cdefine28-31)
|
|
|
+ $extData = [
|
|
|
+ 'cFree1' => $data['customer_brand'] ?? null,
|
|
|
+ 'cFree2' => $data['color'] ?? null,
|
|
|
+ 'cFree3' => $data['bar_code'] ?? '无',
|
|
|
+ 'cDefine22' => $data['plan_no'] ?? null,
|
|
|
+ 'cDefine23' => $data['contract_no'] ?? null,
|
|
|
+ 'cDefine28' => $data['technical_require'] ?? null,
|
|
|
+ 'cDefine29' => $data['quality_require'] ?? null,
|
|
|
+ 'cDefine30' => $data['package_require'] ?? null,
|
|
|
+ 'cDefine31' => $data['shipping_mark'] ?? null,
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $extData = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $inventoryEntry = array_merge($baseData, $extData);
|
|
|
+
|
|
|
+ $tmp = [
|
|
|
+ "Inum" => "OtherIn",
|
|
|
+ "Data" => [
|
|
|
+ "iHead" => [
|
|
|
+ "IsVerify" => true,
|
|
|
+ "cWhCode" => $data['warehouse_code'] ?? "",
|
|
|
+ "cRdCode" => $data['cRdCode'] ?? null, // 入库类别
|
|
|
+ "cDepCode" => null, // 部门
|
|
|
+ "cSource" => "库存",
|
|
|
+ "cBusType" => "其他入库",
|
|
|
+ "cMemo" => $data['cMemo'] ?? "接口生成",
|
|
|
+ "dDate" => date("Y-m-d"),
|
|
|
+ ],
|
|
|
+ "iBody" => [$inventoryEntry]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $final_data = [$tmp];
|
|
|
+
|
|
|
+ //调用所需
|
|
|
+ list($host, $token) = $msg;
|
|
|
+
|
|
|
+ //产成品入库单生成
|
|
|
+ $header = ["Authorization: {$token}",'Content-Type:application/json'];
|
|
|
+ $url = $host . "/api/OtherIn/Add";
|
|
|
+
|
|
|
+ $json = json_encode($final_data);
|
|
|
+ list($status, $result) = $this->post_helper($url, $json, $header, 60, $title . '生成其他入库单');
|
|
|
+
|
|
|
+ if(! $status) return [false, $result];
|
|
|
+
|
|
|
+ if(! isset($result['code'])) return [false, '其他入库单生成失败,请重试'];
|
|
|
+ if($result['code'] != 0) return [false, $result['msg']];
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
//-----------------------------------朗峰u8-----
|
|
|
public function post_helper($url, $data, $header = [], $timeout = 20, $title = ""){
|
|
|
Log::channel('apiLog')->info($title . 'POST', ["api" => $url , "param" => json_decode($data,true) ,"header" => $header]);
|