Selaa lähdekoodia

Merge branch 'dev_wf' of wugg/phpstock into version1.5

wufeng 2 vuotta sitten
vanhempi
commit
25ee6b2ff7
1 muutettua tiedostoa jossa 194 lisäystä ja 6 poistoa
  1. 194 6
      app/admin/controller/Report.php

+ 194 - 6
app/admin/controller/Report.php

@@ -8,6 +8,70 @@ use think\facade\Validate;
 //报表处理类
 class Report extends Base
 {
+    //商品表部分字段的中英文对照
+    private $good_field_title = [
+        'spuCode' => '商品成本编号',
+        'good_code' => '商品编码',
+        'good_name' => '商品名称',
+        'cat_id' => '分类',
+        'brand_id' => '品牌',
+        'good_unit' => '商品单位',
+        'good_type' => '',
+        'companyNo' => '业务企业',
+        'moq' => '起订量',
+        'customized' => '定制工期',
+        'tax' => '税点',
+        'supplierNo' => '供应商',
+        'is_auth' => '是否有销售权限',
+        'is_stock' => '是否库存品',
+        'auth_img' => '销售授权图片',
+        'after_sales' => '售后说明',
+        'craft_desc' => '工艺说明',
+        'good_remark' => '商品备注',
+        'good_size' => '商品尺寸',
+        'weight' => '商品重量',
+        'packing_way' => '包装方式',
+        'packing_size' => '装箱尺寸',
+        'packing_spec' => '装箱规格',
+        'packing_list' => '包装清单',
+        'packing_weight' => '装箱重量',
+        'good_bar' => '商品条形码',
+        'supply_area' => '供货区域',
+        'delivery_place' => '发货地',
+        'origin_place' => '产地',
+        'delivery_day' => '物流时间',
+        'lead_time' => '供货周期',
+        'sample_day' => '调样周期',
+        'sample_fee' => '调样费有',
+        'good_img' => '商品详情主图 ',
+        'good_thumb_img' => '商品缩略图',
+        'good_info_img' => '商品详情图',
+        'cert_fee' => '证书费',
+        'packing_fee' => '包装费',
+        'cost_fee' => '工艺费',
+        'mark_fee' => '加标费',
+        'demo_fee' => '打样费',
+        'open_fee' => '开模费',
+        'noble_metal' => '贵金属种类',
+        'noble_weight' => '贵金属重量',
+        'is_gold_price' => '是否使用实时金价',
+        'cgd_gold_price' => '供应商采购金价',
+        'market_price' => '市场价',
+        'nake_price' => '含税成本价',
+        'is_step' => '阶梯价是否启用',
+        'is_online' => '是否上线',
+        'status' => '状态',
+        'createrid' => '创建人id',
+        'creater' => '创建人',
+        'is_del' => '是否删除',
+        'addtime' => '创建时间',
+        'updatetime' => '修改时间',
+        'is_exclusive' => '是否专属类型',
+        'is_diff' => '是否有工差',
+        'config' => '配置',
+        'other_config' => '其他配置',
+
+    ];
 
     //产品价格和产品导出
     public function exportGood()
@@ -1414,20 +1478,144 @@ class Report extends Base
             if (isset($after_info['field_change'])) {
                 $field_change = json_decode($after_info['field_change'], true);
 
-                $value['修改前的内容'] = [];
+                $before_new = $after_new = [];
                 foreach ($field_change as $v) {
-                    $value['修改前的内容'][$v] = $before_info[$v];
+
+                    //特殊字段处理
+                    switch ($v) {
+
+                        //品牌
+                        case 'brand_id':
+                            $all_brand = Db::name('brand')
+                                ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0])
+                                ->where('is_del', 0)
+                                ->column('brand_name', 'id');
+
+                            if (isset($before_info[$v])) $before_info[$v] = isset($all_brand[$before_info[$v]]) ? $all_brand[$before_info[$v]] : '';
+                            if (isset($after_info[$v])) $after_info[$v] = isset($all_brand[$after_info[$v]]) ? $all_brand[$after_info[$v]] : '';
+                            break;
+
+                        //分类
+                        case 'cat_id':
+                            if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(made($before_info[$v]), 'name'));
+                            if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(made($after_info[$v]), 'name'));
+                            break;
+
+                        //发货地
+                        case 'delivery_place':
+                            $delivery_place = explode(',', $before_info[$v]);
+                            $before_info[$v] = empty($delivery_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place[0] ?? '', 'city_code' => $delivery_place[1] ?? '', 'area_code' => $delivery_place[2] ?? '']));
+
+                            $delivery_place_2 = explode(',', $after_info[$v]);
+                            $after_info[$v] = empty($delivery_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place_2[0] ?? '', 'city_code' => $delivery_place_2[1] ?? '', 'area_code' => $delivery_place_2[2] ?? '']));
+                            break;
+
+                        //产地
+                        case 'origin_place':
+                            $origin_place = explode(',', $before_info[$v]);
+                            $before_info[$v] = empty($origin_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place[0] ?? '', 'city_code' => $origin_place[1] ?? '', 'area_code' => $origin_place[2] ?? '']));
+
+                            $origin_place_2 = explode(',', $after_info[$v]);
+                            $after_info[$v] = empty($origin_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place_2[0] ?? '', 'city_code' => $origin_place_2[1] ?? '', 'area_code' => $origin_place_2[2] ?? '']));
+                            break;
+
+                        //商品单位
+                        case 'good_unit':
+                            $all_unit = Db::name('unit')
+                                ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0])
+                                ->where(['is_del' => 0])
+                                ->column('unit', 'id');
+
+                            if (isset($before_info[$v])) $before_info[$v] = isset($all_unit[$before_info[$v]]) ? $all_unit[$before_info[$v]] : '';
+                            if (isset($after_info[$v])) $after_info[$v] = isset($all_unit[$after_info[$v]]) ? $all_unit[$after_info[$v]] : '';
+
+                            break;
+
+                        //业务企业
+                        case 'companyNo':
+                            $all_business = Db::name('business')
+                                ->whereIn('companyNo', [$before_info[$v] ?? '', $after_info[$v] ?? ''])
+                                ->where(['is_del' => 0])
+                                ->column('company', 'companyNo');
+
+                            if (isset($before_info[$v])) $before_info[$v] = isset($all_business[$before_info[$v]]) ? $all_business[$before_info[$v]] : '';
+                            if (isset($after_info[$v])) $after_info[$v] = isset($all_business[$after_info[$v]]) ? $all_business[$after_info[$v]] : '';
+                            break;
+
+                        //供应商
+                        case 'supplierNo':
+                            $all_supplier = Db::name('supplier')
+                                ->whereIn('code', [$before_info[$v], $after_info[$v]])
+                                ->where(['is_del' => 0])
+                                ->column('name', 'code');
+
+                            $before_info[$v] = isset($all_supplier[$before_info[$v]]) ? $all_supplier[$before_info[$v]] : '';
+                            $after_info[$v] = isset($all_supplier[$after_info[$v]]) ? $all_supplier[$after_info[$v]] : '';
+                            break;
+
+                        //供货区域
+                        case 'supply_area':
+                            if (isset($before_info[$v])) {
+                                if ($before_info[$v] == 1) $before_info[$v] = '全国';
+                                elseif ($before_info[$v] == 2) $before_info[$v] = '全国除偏远';
+                                else $before_info[$v] = '';
+                            }
+
+                            if (isset($after_info[$v])) {
+                                if ($after_info[$v] == 1) $after_info[$v] = '全国';
+                                elseif ($after_info[$v] == 2) $after_info[$v] = '全国除偏远';
+                                else $after_info[$v] = '';
+                            }
+                            break;
+
+                        //贵金属种类
+                        case 'noble_metal':
+
+                            if (isset($before_info[$v])) {
+                                if ($before_info[$v] == 1) $before_info[$v] = '18K';
+                                elseif ($before_info[$v] == 2) $before_info[$v] = '24K';
+                                elseif ($before_info[$v] == 3) $before_info[$v] = '白银';
+                                else $before_info[$v] = '';
+                            }
+
+                            if (isset($after_info[$v])) {
+                                if ($after_info[$v] == 1) $after_info[$v] = '18K';
+                                elseif ($after_info[$v] == 2) $after_info[$v] = '24K';
+                                elseif ($after_info[$v] == 3) $after_info[$v] = '白银';
+                                else $after_info[$v] = '';
+                            }
+                            break;
+
+                        //专属类型
+                        case 'is_exclusive':
+                            if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(mai($before_info[$v]), 'rname'));
+                            if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(mai($after_info[$v]), 'rname'));
+                            break;
+
+                        //状态
+                        case 'status':
+                            $all_status = [1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线'];
+                            if (isset($before_info[$v])) $before_info[$v] = isset($all_status[$before_info[$v]])?$all_status[$before_info[$v]]:'';
+                            if (isset($after_info[$v])) $after_info[$v] = isset($all_status[$after_info[$v]])?$all_status[$after_info[$v]]:'';
+
+                    }
+
+
+                    $key = isset($this->good_field_title[$v]) ? $this->good_field_title[$v] : $v;
+
+                    if (isset($before_info[$v])) $before_new[$key] = $before_info[$v];
+                    if (isset($after_info[$v])) $after_new[$key] = $after_info[$v];
                 }
-                unset($after_info['field_change']);
-                $value['修改前的内容'] = json_encode($value['修改前的内容'], JSON_UNESCAPED_UNICODE);
-                $value['修改后的内容'] = json_encode($after_info, JSON_UNESCAPED_UNICODE);
+
+                $value['修改前的内容'] = json_encode($before_new, JSON_UNESCAPED_UNICODE);
+                $value['修改后的内容'] = json_encode($after_new, JSON_UNESCAPED_UNICODE);
 
             }
 
             $list[] = $value;
 
         }
-
+        
         if (empty($list)) $list[] = '没有可供导出的数据';
 
         $headerArr = array_keys($list[0]);