feat(OrderEnum): 修改订单枚举类型中的支付方式描述

This commit is contained in:
mkm 2024-06-20 17:27:50 +08:00
parent 0dc94531a5
commit 8fadc9fdd7
4 changed files with 173 additions and 38 deletions

View File

@ -32,8 +32,8 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
{
return [
'=' => ['store_id', 'user_id', 'create_time', 'staff_id'],
'between_time'=>'create_time',
'%pipe_like%' => ['keyword'=>'order_sn'],
'between_time' => 'create_time',
'%pipe_like%' => ['keyword' => 'order_sn'],
];
}
@ -49,7 +49,13 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
*/
public function lists(): array
{
return StoreFinanceFlow::where($this->searchWhere)
$field = [
'id','order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status'
];
$this->searchWhere[] = ['financial_type', '=', 1];
$this->searchWhere[] = ['financial_pm', '=', 1];
$data = StoreFinanceFlow::where($this->searchWhere)
->field($field)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
@ -64,16 +70,40 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
}
if ($item['financial_pm'] == 0) {
$item['number'] = '-' . $item['number'];
$item['financial_type_name'] = '订单支出:'.OrderEnum::getFinancialType($item['financial_type']);
$item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']);
} else {
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']).'获得';
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得';
$item['number'] = '+' . $item['number'];
}
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
})
->toArray();
})->toArray();
foreach ($data as $key => $item) {
$data[$key]['list'] = StoreFinanceFlow::where('order_id' ,$item['order_id'])->where('financial_type','>', 1)->field($field)->order('financial_pm','desc')->select()->each(function ($item) {
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
$id = $item['user_id'];
$item['nickname'] = User::where('id', $item['user_id'])->value('nickname') . "|$id";
}
if (!empty($this->request->adminInfo['store_id'])) {
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
}
if ($item['financial_pm'] == 0) {
$item['number'] = '-' . $item['number'];
$item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']);
} else {
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得';
$item['number'] = '+' . $item['number'];
}
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
});
}
return $data;
}
@ -87,5 +117,4 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
{
return StoreFinanceFlow::where($this->searchWhere)->count();
}
}

View File

@ -146,13 +146,13 @@ class OrderEnum
public static function getFinancialType($value = true)
{
$data = [
self::USER_ORDER_PAY => '用户订单支付',
self::USER_ORDER_PAY => '订单支付',
self::MERCHANT_ORDER_PAY => '商户订单支付',
self::PLATFORM_ORDER_PAY => '平台订单支付',
self::MERCHANT_ORDER_OBTAINS => '商户',
self::ORDER_HANDLING_FEES => '手续费',
self::PLATFORM_ORDER_OBTAINS => '平台',
self::SUPPLIER_ORDER_OBTAINS => '供应商',
self::SUPPLIER_ORDER_OBTAINS => '成本',
self::SYSTEM_SET => '平台设置',
self::VILLAGE_ORDER_OBTAINS => '村长',
self::BRIGADE_ORDER_OBTAINS=>'队长',

View File

@ -2,41 +2,18 @@
namespace app\store\controller\finance;
use app\admin\lists\store_finance_flow\StoreFinanceFlowLists;
use app\common\controller\Definitions;
use app\common\logic\StoreFinanceFlowLogic;
use app\store\controller\BaseAdminController;
use app\store\lists\store_finance_flow\StoreFinanceFlowLists;
// #[ApiDoc\title('财务')]
class FinanceController extends BaseAdminController
{
// #[
// ApiDoc\Title('财务流水'),
// ApiDoc\url('/store/finance/finance/lists'),
// ApiDoc\Method('GET'),
// ApiDoc\NotHeaders(),
// ApiDoc\Author('中国队长'),
// ApiDoc\Query(name: 'keyword', type: 'string', require: false, desc: '订单编号'),
// ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'),
// ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'),
// ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'),
// ApiDoc\Header(ref: [Definitions::class, "token"]),
// ApiDoc\Query(ref: [Definitions::class, "page"]),
// ApiDoc\ResponseSuccess("data", type: "array", children: [
// ['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
// ['name' => 'financial_record_sn', 'desc' => '流水号', 'type' => 'string'],
// ['name' => 'order_sn', 'desc' => '订单号', 'type' => 'string'],
// ['name' => 'number', 'desc' => '金额', 'type' => 'float'],
// ['name' => 'create_time', 'desc' => '创建时间', 'type' => 'string'],
// ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'],
// ['name' => 'staff_name', 'desc' => '店员', 'type' => 'string'],
// ['name' => 'store_name', 'desc' => '店铺名称', 'type' => 'string'],
// ['name' => 'pay_type_name', 'desc' => '支付方式', 'type' => 'string'],
// ['name' => 'financial_type_name', 'desc' => '流水类型', 'type' => 'string'],
// ['name' => 'remark', 'desc' => '备注', 'type' => 'string'],
// ]),
// ]
/**
* 门店流水
*/
public function lists()
{
return $this->dataLists(new StoreFinanceFlowLists());

View File

@ -0,0 +1,129 @@
<?php
namespace app\store\lists\store_finance_flow;
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\lists\ListsSearchInterface;
use app\common\model\system_store\SystemStore;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user\User;
/**
* 门店流水列表
* Class StoreFinanceFlowLists
* @package app\admin\listsstore_finance_flow
*/
class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/05/31 16:56
*/
public function setSearch(): array
{
return [
'=' => ['store_id', 'user_id', 'create_time', 'staff_id'],
'between_time' => 'create_time',
'%pipe_like%' => ['keyword' => 'order_sn'],
];
}
/**
* @notes 获取门店流水列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/05/31 16:56
*/
public function lists(): array
{
$field = [
'id', 'order_id', 'order_sn', 'create_time', 'other_uid', 'user_id', 'store_id', 'staff_id', 'financial_type', 'financial_pm', 'pay_type', 'type', 'number', 'status'
];
$this->searchWhere[] = ['financial_type', '=', 1];
$this->searchWhere[] = ['financial_pm', '=', 1];
$data = StoreFinanceFlow::where($this->searchWhere)
->field($field)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
$id = $item['user_id'];
$item['nickname'] = User::where('id', $item['user_id'])->value('nickname') . "|$id";
}
if (!empty($this->request->adminInfo['store_id'])) {
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
}
if ($item['financial_pm'] == 0) {
$item['number'] = '-' . $item['number'];
$item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']);
} else {
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得';
$item['number'] = '+' . $item['number'];
}
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
})->toArray();
foreach ($data as $key => $item) {
$list1= StoreFinanceFlow::where('order_id', $item['order_id'])->where('financial_type', '>', 1)
->where('financial_pm', 0)
->field($field)->order('financial_pm', 'desc')->select()->each(function ($item) {
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
$id = $item['user_id'];
$item['nickname'] = User::where('id', $item['user_id'])->value('nickname') . "|$id";
}
$item['number'] = '-' . $item['number'];
$item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']);
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
});
$list2= StoreFinanceFlow::where('order_id', $item['order_id'])->where('financial_type' ,2)
->where('financial_pm', 1)
->field($field)->order('financial_pm', 'desc')->select()->each(function ($item) {
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
$id = $item['user_id'];
$item['nickname'] = User::where('id', $item['user_id'])->value('nickname') . "|$id";
}
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得';
$item['number'] = '+' . $item['number'];
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
});
$data[$key]['list'] = array_merge($list1->toArray(), $list2->toArray());
}
return $data;
}
/**
* @notes 获取门店流水数量
* @return int
* @author admin
* @date 2024/05/31 16:56
*/
public function count(): int
{
return StoreFinanceFlow::where($this->searchWhere)->count();
}
}