测试版2.3.2发布

This commit is contained in:
2021-05-08 20:14:31 +08:00
parent dafdbc1746
commit c8aa6ac4bc
17 changed files with 335 additions and 271 deletions
+8 -24
View File
@@ -22,32 +22,16 @@ class TaxHook
public function onAfterStore($params) {
$master = $params['master'];
if (empty($master['code'])) {
// 自动设置开票编码
$customer = Customer::find($master['customer_id']);
$code = $customer['code'];
$max_id = (int)$customer['tax_max_id'] + 1;
// 更新开票单位code
$tax = CustomerTax::find($master['id']);
$tax->code = $code.$max_id;
$tax->save();
$customer->tax_max_id = $max_id;
$customer->save();
// 客户档案写入外部接口
$department = DB::table('department')->where('id', $tax['department_id'])->first();
$class = DB::table('customer_class')->where('id', $tax['class_id'])->first();
$tax['class_code'] = $class['code'];
$tax['department_code'] = $department['code'];
$tax['headCode'] = $customer->code;
$ret = plugin_sync_api('CustomerSync', $tax);
if ($ret['success'] == true) {
return $params;
}
// 开票单位同步外部接口
$department = DB::table('department')->where('id', $master['department_id'])->first();
$class = DB::table('customer_class')->where('id', $master['class_id'])->first();
$master['class_code'] = $class['code'];
$master['department_code'] = $department['code'];
$ret = plugin_sync_api('postTax', $master);
if ($ret['error_code'] > 0) {
abort_error($ret['msg']);
}
}
return $params;
}