|
@@ -3450,4 +3450,75 @@ class Sale extends Base
|
|
|
$order["noble_weight"] = isset($order['weight'])?$order['weight']:0;
|
|
|
return app_show(0,"获取成功",$order);
|
|
|
}
|
|
|
+
|
|
|
+ //发货申请单导出
|
|
|
+ public function exportSaleOut()
|
|
|
+ {
|
|
|
+ $outCodes = $this->request->post('outCodes', [], 'trim');
|
|
|
+
|
|
|
+ if (empty($outCodes)) return error_show(1004, '要导出的发货申请单编号不能为空');
|
|
|
+
|
|
|
+ $i = 1;
|
|
|
+ $send_type = [1 => '直接发货', 2 => '延时发货'];
|
|
|
+ $status = [0 => '待发货', 1 => '待库管发货', 2 => '已发货待收货', 3 => '已收货', 4 => '已全部退货'];
|
|
|
+ $list = Db::name("order_out")
|
|
|
+ ->alias('a')
|
|
|
+ ->field('"" as 序号,a.addtime as 创建时间,po.cgdNo as 采购单编号,po.status as 采购单状态,po.cgder as 采购员,b.orderCode as 确认单号,b.addtime as 确认单时间,b.good_code as 产品编号,b.good_name as 产品名称,"" as 规格,"" as 单位,wi.name as 供应商名称,s.code as 供应商编号,po.nake_fee as 裸价,a.post_fee as 物流费,b.send_type as 发货方式,po.good_price as 采购单价,b.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,oa.contactor as 收货人,oa.mobile as 联系方式,oa.addr as 收货地址,oa.arrive_time as 到货时间,po.order_type')
|
|
|
+ ->whereIn('a.outCode', $outCodes)
|
|
|
+ ->order("a.addtime desc")
|
|
|
+ ->withAttr('序号', function () use (&$i) {
|
|
|
+ return $i++;
|
|
|
+ })->withAttr('采购单状态', function ($val) use ($status) {
|
|
|
+ return isset($status[$val]) ? $status[$val] : '';
|
|
|
+ })->withAttr('发货方式', function ($val) use ($send_type) {
|
|
|
+ return isset($send_type[$val]) ? $send_type[$val] : '';
|
|
|
+ })
|
|
|
+ ->leftJoin("sale b", "b.orderCode=a.orderCode")
|
|
|
+ ->leftJoin("order_addr oa", "oa.id=a.addrid AND oa.is_del=0")
|
|
|
+ ->leftJoin("warehouse_info wi", "wi.wsm_code=a.wsm_code AND wi.is_del=0")
|
|
|
+ ->leftJoin("supplier s", "s.code=wi.supplierNo AND s.is_del=0")
|
|
|
+ ->leftJoin('order_send os', 'os.outCode=a.outCode ')
|
|
|
+ ->leftJoin("purchease_order po", "po.cgdNo=os.cgdNo AND po.is_del=0")
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ foreach ($list as &$value) {
|
|
|
+
|
|
|
+ if ($value['order_type'] == 3 || $value['order_type'] == 4) {
|
|
|
+ $temp = Db::name("good_zixun")
|
|
|
+ ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
|
|
|
+ ->field('id,specinfo,good_unit')
|
|
|
+ ->find();
|
|
|
+ $good_unit = isset($temp['good_unit']) ? $temp['good_unit'] : 0;
|
|
|
+ $specinfo = isset($temp['specinfo']) ? json_decode($temp['specinfo'], true) : [];
|
|
|
+
|
|
|
+ $speclist = [];
|
|
|
+ foreach ($specinfo as $val) {
|
|
|
+ $speclist[] = $val['spec_name'] . ':' . $val['spec_value_name'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $good_unit = Db::name('good_basic')
|
|
|
+ ->where(['spuCode' => $value['产品编号']])
|
|
|
+ ->value('good_unit', 0);
|
|
|
+ $spec = Db::name("good_spec")
|
|
|
+ ->field('id,spec_id,spec_value_id')
|
|
|
+ ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ $speclist = [];
|
|
|
+ if (!empty($spec)) {
|
|
|
+ foreach ($spec as $val) {
|
|
|
+ $speclist[] = Db::name("specs")->where(["id" => $val['spec_id']])->value('spec_name', '') . ':' . Db::name("spec_value")->where(["id" => $val['spec_value_id']])->value('spec_value', '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $value['规格'] = empty($speclist) ? '' : implode(',', $speclist);;
|
|
|
+ $value['单位'] = $good_unit ? Db::name('unit')->where(['id' => $good_unit, 'is_del' => 0])->value('unit', '') : '';
|
|
|
+ unset($value['order_type']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $headerArr = array_keys($list[0]);
|
|
|
+ excelSave('发货申请单导出' . date('YmdHis') . '.xls', $headerArr, $list);
|
|
|
+ }
|
|
|
}
|