调整账单导出
This commit is contained in:
parent
d0bbd71dde
commit
a4ae19a64a
@ -3,10 +3,12 @@
|
|||||||
namespace app\common\lists;
|
namespace app\common\lists;
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\enum\OrderEnum;
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||||
use think\db\Query;
|
use think\db\Query;
|
||||||
|
|
||||||
class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface
|
class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
@ -18,7 +20,7 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1;
|
$this->params['type'] = !empty($this->params['type']) ? $this->params['type'] : 1;
|
||||||
return StoreFinanceFlow::where('1=1')
|
return StoreFinanceFlow::with(['user', 'staff'])
|
||||||
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->request->adminInfo['store_id']);
|
$query->where('store_id', $this->request->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
@ -54,6 +56,13 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item->month = date('m', strtotime($item->create_time));
|
$item->month = date('m', strtotime($item->create_time));
|
||||||
|
if (!empty($this->request->adminInfo['store_id'])) {
|
||||||
|
$item->pm_type = $item->financial_pm == 0 ? '收入' : '支出';
|
||||||
|
} else {
|
||||||
|
$item->pm_type = $item->financial_pm == 0 ? '支出' : '收入';
|
||||||
|
}
|
||||||
|
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
|
||||||
|
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']);
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
@ -95,4 +104,24 @@ class StoreBillLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setExcelFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'financial_record_sn' => '交易单号',
|
||||||
|
'order_sn' => '关联订单',
|
||||||
|
'create_time' => '交易时间',
|
||||||
|
'number' => '交易金额',
|
||||||
|
'pm_type' => '支出收入',
|
||||||
|
'nickname' => '交易人',
|
||||||
|
'staff_name' => '关联店员',
|
||||||
|
'financial_type_name' => '交易类型',
|
||||||
|
'pay_type_name' => '支付方式',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFileName(): string
|
||||||
|
{
|
||||||
|
return '账单导出';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ namespace app\common\model\store_finance_flow;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
|
use app\common\model\user\User;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -18,5 +20,14 @@ class StoreFinanceFlow extends BaseModel
|
|||||||
protected $name = 'store_finance_flow';
|
protected $name = 'store_finance_flow';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->hasOne(User::class, 'id', 'user_id')->bind(['nickname']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function staff()
|
||||||
|
{
|
||||||
|
return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ namespace app\store\controller\finance;
|
|||||||
use app\admin\lists\store_finance_flow\StoreFinanceFlowLists;
|
use app\admin\lists\store_finance_flow\StoreFinanceFlowLists;
|
||||||
use app\common\controller\Definitions;
|
use app\common\controller\Definitions;
|
||||||
use app\common\lists\StoreBillLists;
|
use app\common\lists\StoreBillLists;
|
||||||
use app\common\logic\StoreFinanceFlowLogic;
|
|
||||||
use app\store\controller\BaseAdminController;
|
use app\store\controller\BaseAdminController;
|
||||||
use hg\apidoc\annotation as ApiDoc;
|
use hg\apidoc\annotation as ApiDoc;
|
||||||
|
|
||||||
@ -22,6 +21,7 @@ class StoreBillController extends BaseAdminController
|
|||||||
ApiDoc\Query(name: 'type', type: 'int', require: false, desc: '类型:1日账单,2周账单,3月账单'),
|
ApiDoc\Query(name: 'type', type: 'int', require: false, desc: '类型:1日账单,2周账单,3月账单'),
|
||||||
ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'),
|
ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'),
|
||||||
ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'),
|
ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'),
|
||||||
|
ApiDoc\Query(name: 'export', type: 'int', require: false, desc: '是否导出:2是'),
|
||||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||||
ApiDoc\Query(ref: [Definitions::class, "page"]),
|
ApiDoc\Query(ref: [Definitions::class, "page"]),
|
||||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
@ -51,23 +51,4 @@ class StoreBillController extends BaseAdminController
|
|||||||
return $this->dataLists(new StoreFinanceFlowLists());
|
return $this->dataLists(new StoreFinanceFlowLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[
|
|
||||||
ApiDoc\Title('下载'),
|
|
||||||
ApiDoc\url('/store/finance/storeBill/download'),
|
|
||||||
ApiDoc\Method('GET'),
|
|
||||||
ApiDoc\NotHeaders(),
|
|
||||||
ApiDoc\Author('中国队长'),
|
|
||||||
ApiDoc\Param(name: 'id', type: 'int', require: true, desc: 'id'),
|
|
||||||
ApiDoc\Param(name: 'remark', type: 'string', require: true, desc: '备注'),
|
|
||||||
ApiDoc\Header(ref: [Definitions::class, "token"]),
|
|
||||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
|
||||||
]
|
|
||||||
public function download(StoreFinanceFlowLogic $logic)
|
|
||||||
{
|
|
||||||
$id = $this->request->post('id');
|
|
||||||
$remark = $this->request->post('remark');
|
|
||||||
$logic->remark($id, $remark);
|
|
||||||
return $this->success('操作成功', [], 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user