全部
常见问题
产品动态
精选推荐

修复多店后台导出订单功能

管理 管理 编辑 删除

问题描述:

后台订单列表导出数量不对。

解决方法:

src/pages/order/orderList/components/tableList.vue,找到这个文件,修改exports()方法。

    async exports(value) {
      this.exportListOn = this.exportList.findIndex(
          (item) => item.name === value
      )
      let [th, filekey, data, fileName] = [[], [], [], '']
      let excelData = {
        ...this.where,
        page: 1,
        export_type: value,
        ids: this.checkUidList.join(),
        plat_type: this.currentTab,
      }
      for (let i = 0; i < excelData.page; i++) {
        let lebData = await this.downOrderData(excelData)
        if (!lebData.export.length) {
          break;
        }
        if (!fileName) {
          fileName = lebData.filename
        }
        if (!filekey.length) {
          filekey = lebData.filekey
        }
        if (!th.length) {
          th = lebData.header
        }
        data = data.concat(lebData.export)
        excelData.page++
      }
      let sheetData = []
      for (let j = 0; j < data.length; j++) {
        let goodsList = data[j].goods_name.split('\n')
        for (let k = 0; k < goodsList.length; k++) {
          let row = {...data[j]}
          row.goods_name = goodsList[k]
          if (k) {
            for (const key in row) {
              if (Object.hasOwnProperty.call(row, key)) {
                if (key !== 'goods_name') {
                  row[key] = null
                }
              }
            }
          }
          sheetData.push(row)
        }
      }
      exportExcel(th, filekey, fileName, sheetData)
    },

修改完成后需要重新打包。

打包文档: https://doc.crmeb.com/pro/crmebprov2/2354


后台文件修改:app\controller\admin\v1\other\export\ExportExcel

修改方法:storeOrder()

public function storeOrder(StoreOrderServices $services)
    {
        $where_tmp = $this->request->getMore([
            ['status', ''],
            ['real_name', ''],
            ['is_del', ''],
            ['data', '', '', 'time'],
			['type', ''],
            ['export_type', ''],
            ['pay_type', ''],
			['plat_type', -1],
            ['order', ''],
            ['field_key', ''],
            ['store_id', ''],
            ['supplier_id', ''],
            ['ids', '']
        ]);
        $type = $where_tmp['export_type'];
		unset($where_tmp['export_type']);
        $with = [];
        if ($where_tmp['ids']) {
            $where['id'] = explode(',', $where_tmp['ids']);
        }
        if ($type) {
            $where['status'] = 1;
            $where['paid'] = 1;
            $where['is_del'] = 0;
            $where['shipping_type'] = 1;
            $where['pid'] = 0;
            $with = ['pink', 'refund' => function ($query) {
						$query->whereIn('refund_type', [0, 1, 2, 4, 5])->where('is_cancel', 0)->where('is_del', 0)->field('id,store_order_id');
					}];
        }
        if (!$where_tmp['ids'] && !$type) {
            unset($where_tmp['ids']);
            $where = $where_tmp;
        }
        $where['is_system_del'] = 0;
		$where['plat_type'] = $where_tmp['plat_type'];
		$where['store_id'] = $where_tmp['store_id'];
		$where['supplier_id'] = $where_tmp['supplier_id'];
        if ($where['store_id'] || $where['supplier_id'] || $where['plat_type'] != '' && in_array($where['plat_type'], [0, 1, 2])) {
            $where['pid'] = 0;
        } elseif (!in_array($where['status'], [-1, -2, -3])) {
            $where['pid'] = [0, -1];
        }
        $data = $services->getExportList($where, $with, $this->service->limit);
        return $this->success($this->service->storeOrder($data, $type));
    }


后台文件修改:app\services\order\StoreOrderServices

修改方法:getExportList()

public function getExportList(array $where, array $with = [], int $limit = 0)
    {
        if ($limit) {
            [$page] = $this->getPageValue();
        } else {
            [$page, $limit] = $this->getPageValue();
        }
        $list = $this->dao->search($where)->with($with)->page($page, $limit)->order('add_time DESC,id DESC')->select()->toArray();
        if ($list) {
			/** @var  $userServices */
			$userServices = app()->make(UserServices::class);
			$userSex = $userServices->getColumn([['uid', 'IN', array_unique(array_column($list, 'uid'))]], 'uid,sex', 'uid');
            foreach ($list as &$item) {
                /** @var StoreOrderCartInfoServices $orderCart */
                $orderCart = app()->make(StoreOrderCartInfoServices::class);
                $_info = $orderCart->getCartColunm(['oid' => $item['id']], 'cart_info', 'unique');
                foreach ($_info as $k => $v) {
                    $cart_info = is_string($v) ? json_decode($v, true) : $v;
                    if (!isset($cart_info['productInfo'])) $cart_info['productInfo'] = [];
                    $_info[$k] = $cart_info;
                    unset($cart_info);
                }
                $item['_info'] = $_info;
                $item['sex'] = $userSex[$item['uid']]['sex'] ?? '';
				[$pink_name, $color] = $this->tidyOrderType($item);
            	$item['pink_name'] = $pink_name;
            	$item['color'] = $color;
            }
        }
        return $list;
    }



请登录后查看

全 最后编辑于2024-10-31 16:48:59

快捷回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest==1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

作者 管理员 企业

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}   {{itemc.ip_address}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
回复
回复
216
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} {{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
加精
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服