修改财务流水写入

This commit is contained in:
luofei 2024-06-05 18:07:34 +08:00
parent 43d0168db0
commit be1e3067ec
4 changed files with 82 additions and 17 deletions

View File

@ -46,22 +46,37 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
public function lists(): array
{
return StoreFinanceFlow::where($this->searchWhere)
->when(!empty($this->params['start_time']), function ($query) {
$query->whereTime('create_time', '>=', $this->params['start_time']);
})
->when(!empty($this->params['end_time']), function ($query) {
if ($this->params['end_time'] == $this->params['start_time']) {
$this->params['end_time'] = strtotime($this->params['end_time']) + 86399;
}
$query->whereTime('create_time', '<=', $this->params['end_time']);
})
->when(!empty($this->request->adminInfo['store_id']), function ($query) {
$query->where('store_id', '=', $this->request->adminInfo['store_id']);
})
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
if($item['user_id']<=0){
$item['nickname']='游客';
}else{
$item['nickname']=User::where('id',$item['user_id'])->value('nickname');
if ($item['user_id'] <= 0) {
$item['nickname'] = '游客';
} else {
$item['nickname'] = User::where('id', $item['user_id'])->value('nickname');
}
if($item['financial_pm']==0){
$item['number']='-'.$item['number'];
}else{
$item['number']='+'.$item['number'];
if (!empty($this->request->adminInfo['store_id'])) {
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
}
$item['staff_name']=SystemStoreStaff::where('id',$item['staff_id'])->value('staff_name');
$item['pay_type_name']=PayEnum::getPaySceneDesc($item['pay_type']);
$item['financial_type_name']=OrderEnum::getFinancialType($item['financial_type']);
if ($item['financial_pm'] == 0) {
$item['number'] = '-' . $item['number'];
} else {
$item['number'] = '+' . $item['number'];
}
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']);
})
->toArray();
}
@ -78,4 +93,4 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
return StoreFinanceFlow::where($this->searchWhere)->count();
}
}
}

View File

@ -151,7 +151,6 @@ class PayNotifyLogic extends BaseLogic
if (!$order->save()) {
throw new \Exception('订单保存出错');
}
self::afterPay($order);
}
/**
@ -204,9 +203,9 @@ class PayNotifyLogic extends BaseLogic
$financeLogic->user = ['uid' => $order['uid']];
if ($order->pay_type != 9 || $order->pay_type != 10) {
$financeLogic->in($transaction_id,$order['pay_price'], OrderEnum::USER_ORDER_PAY);
$financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0);
$financeLogic->save();
}
$financeLogic->out($transaction_id,$order['pay_price'], OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0);
$financeLogic->save();
}
//等级处理

View File

@ -26,7 +26,7 @@ class StoreFinanceFlowLogic extends BaseLogic
*/
public function out($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1)
{
$this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id);
$this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id);
}
/**
@ -40,7 +40,7 @@ class StoreFinanceFlowLogic extends BaseLogic
*/
public function in($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1)
{
$this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id);
$this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id);
}
public function setData($number, $financialType, $pm, $storeId, $staffId, $status,$transaction_id)

View File

@ -0,0 +1,51 @@
<?php
namespace app\store\controller\finance;
use app\admin\lists\store_finance_flow\StoreFinanceFlowLists;
use app\common\controller\Definitions;
use app\store\controller\BaseAdminController;
use hg\apidoc\annotation as ApiDoc;
#[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' => 'order_id', 'desc' => '订单编号', 'type' => 'string'],
['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'],
['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'],
['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'],
['name' => 'status_name', 'desc' => '状态', 'type' => 'int'],
['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'],
['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'],
['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'],
['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [
['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [
['name' => 'name', 'desc' => '商品名称', 'type' => 'int'],
['name' => 'image', 'desc' => '图片', 'type' => 'string'],
['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'],
['name' => 'price', 'desc' => '单价', 'type' => 'string'],
]],
]],
]),
]
public function lists()
{
return $this->dataLists(new StoreFinanceFlowLists());
}
}