This commit is contained in:
mkm 2024-05-22 16:37:07 +08:00
parent d06160776f
commit 0fa8522d01
3 changed files with 46 additions and 31 deletions

View File

@ -56,7 +56,9 @@ class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInte
->field("FROM_UNIXTIME(create_time, '%Y-%m-%d') as record_date, SUM(number) as total_amount")
->group('record_date')
->order('record_date')
->select();
->select()->each(function ($item) {
$item['total_amount'] = $item['total_amount'] ?? 0;
});
return $list?->toArray();
}

View File

@ -9,6 +9,8 @@ class OrderEnum
/**
* 流水类型
* @USER_ORDER_PAY 用户订单支付
* @CASHIER_ORDER_PAY 收银台支付
* @CASHIER_CASH_ORDER_PAY 收银台现金支付
* @MERCHANT_ORDER_OBTAINS 商户订单获得
* @ORDER_HANDLING_FEES 订单手续费
* @MERCHANT_ORDER_PAY 商户订单支付
@ -25,6 +27,8 @@ class OrderEnum
const SUPPLIER_ORDER_OBTAINS = 6;
const PLATFORM_ORDER_PAY = 7;
const SYSTEM_SET = 8;
const CASHIER_ORDER_PAY = 9;
const CASHIER_CASH_ORDER_PAY = 10;
/**

View File

@ -61,13 +61,21 @@ class PayNotifyLogic extends BaseLogic
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
return true;
}
$order->money = bcdiv($extra['amount']['payer_total'], 100, 2);
$order->paid = 1;
$order->status = 1;
$financial_type = OrderEnum::USER_ORDER_PAY;
$financial_type2 = OrderEnum::MERCHANT_ORDER_OBTAINS;
if($order->pay_type !=10){
$order->money = bcdiv($extra['amount']['payer_total'], 100, 2);
$order->paid = 1;
$order->status = 1;
$order->save();
}else{
$financial_type2 = OrderEnum::CASHIER_CASH_ORDER_PAY;
$extra['transaction_id']=time();
}
if ($order->pay_type == 9) {
$order->status = 2;
$financial_type2 = OrderEnum::CASHIER_ORDER_PAY;
}
$order->save();
if ($order['cart_id']) {
if (!is_array($order['cart_id'])) {
$cart_arr = explode(',', $order['cart_id']);
@ -76,41 +84,42 @@ class PayNotifyLogic extends BaseLogic
Cart::whereIn('cart_id', $order['cart_id'])->update(['is_pay' => 1]);
}
}
if ($order->pay_type != 9) {
if ($order->pay_type != 9 || $order->pay_type != 10) {
//用户支出流水
$record[] = [
'financial_record_sn' => $extra['transaction_id'],
'order_id' => $order['id'],
'number_sn' => $order['number'],
'user_id' => $order['uid'],
'financial_type' => OrderEnum::USER_ORDER_PAY,
'financial_type' => $financial_type,
'financial_pm' => OrderEnum::EXPENDITURE,
'number' => $order['actual'],
'status' => 1,
'type' => OrderEnum::USER,
'mer_id' => $order['merchant'],
];
//商户获得流水
$record[] = [
'financial_record_sn' => $extra['transaction_id'],
'order_id' => $order['id'],
'number_sn' => $order['number'],
'user_id' => $order['uid'],
'financial_type' => OrderEnum::MERCHANT_ORDER_OBTAINS,
'financial_pm' => OrderEnum::INCOME,
'number' => $order['actual'],
'status' => 0,
'type' => OrderEnum::MERCHANT,
'mer_id' => $order['merchant'],
];
(new FinancialRecord())->saveAll($record);
}
//商户获得流水
$record[] = [
'financial_record_sn' => $extra['transaction_id'],
'order_id' => $order['id'],
'number_sn' => $order['number'],
'user_id' => $order['uid'],
'financial_type' => $financial_type2,
'financial_pm' => OrderEnum::INCOME,
'number' => $order['actual'],
'status' => 0,
'type' => OrderEnum::MERCHANT,
'mer_id' => $order['merchant'],
];
(new FinancialRecord())->saveAll($record);
if ($order->pay_type == 9) {
$extra['create_time']=$order['create_time'];
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type'=>'cash_register','msg'=>'您有一笔订单已支付','data'=>$extra]);
$extra['create_time'] = $order['create_time'];
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
} else {
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type'=>'store_merchant','msg'=>'您有一笔新的订单']);
PushService::push('store_merchant_' . $order['merchant'], $order['merchant'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
Redis::send('push-platform-print', ['order_id' => $order['id']], 60);
}
if (!empty($extra['payer']['openid']) && $order->pay_type != 9) {
@ -124,9 +133,9 @@ class PayNotifyLogic extends BaseLogic
public static function opurchaseclass($orderSn, $extra = [])
{
$order = Opurchaseclass::where('number', $orderSn)->findOrEmpty();
$order_arr=explode(',',$order['order_arr']);
(new FinancialRecord())->where('order_id','in',$order_arr)->update(['status' => 1]);
$time=time();
$order_arr = explode(',', $order['order_arr']);
(new FinancialRecord())->where('order_id', 'in', $order_arr)->update(['status' => 1]);
$time = time();
//商户支出流水
$record[] = [
'financial_record_sn' => $time,
@ -156,15 +165,15 @@ class PayNotifyLogic extends BaseLogic
(new FinancialRecord())->saveAll($record);
}
/**
/**
* 平台采购订单支付成功
*/
public static function operated($orderSn, $extra = [])
{
$order = Opurchaseclass::where('number', $orderSn)->findOrEmpty();
$order_arr=explode(',',$order['order_arr']);
(new FinancialRecord())->where('order_id','in',$order_arr)->update(['status' => 1]);
$time=time();
$order_arr = explode(',', $order['order_arr']);
(new FinancialRecord())->where('order_id', 'in', $order_arr)->update(['status' => 1]);
$time = time();
//平台支出流水
$record[] = [
'financial_record_sn' => $time,