feat(OrderLogic, PayNotifyLogic, Task): 修改订单逻辑,优化核销流程,增加资金流动逻辑及订单购物详情处理
This commit is contained in:
parent
9b1f3cb967
commit
795d19dda3
@ -594,6 +594,7 @@ class OrderLogic extends BaseLogic
|
||||
'writeoff_time' => time(),
|
||||
'is_writeoff' => YesNoEnum::YES,
|
||||
'store_id' => $params['store_id'],
|
||||
'status' => 1,
|
||||
'staff_id' => $params['staff_id'] ?? 0,
|
||||
'update_time' => time(),
|
||||
], ['oid' => $order['id']]);
|
||||
@ -627,51 +628,6 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
//不走二次分钱的核销
|
||||
public static function lessWriteOff($params): bool
|
||||
{
|
||||
$data = StoreOrder::with('store')->where([
|
||||
'verify_code' => $params['verify_code']
|
||||
])->find();
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
StoreOrder::update([
|
||||
'verify_code' => $params['verify_code'] . '-1',
|
||||
'status' => OrderEnum::RECEIVED_GOODS,
|
||||
'is_writeoff' => OrderEnum::IS_OK,
|
||||
'update_time' => time(),
|
||||
'store_id' => $params['store_id'],
|
||||
'staff_id' => $params['staff_id'] ?? 0,
|
||||
], ['id' => $data['id']]);
|
||||
(new StoreOrderCartInfo())->update([
|
||||
'verify_code' => $params['verify_code'] . '-1',
|
||||
'writeoff_time' => time(),
|
||||
'is_writeoff' => YesNoEnum::YES,
|
||||
'store_id' => $params['store_id'],
|
||||
'staff_id' => $params['staff_id'] ?? 0,
|
||||
'update_time' => time(),
|
||||
], ['oid' => $data['id']]);
|
||||
// $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']);
|
||||
// if (!empty($financeFlow)) {
|
||||
// $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store');
|
||||
// $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']);
|
||||
// }
|
||||
$order = StoreOrder::where('id', $data['id'])->find();
|
||||
PayNotifyLogic::descSwap($order['id']);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function write_count($info, $params)
|
||||
{
|
||||
|
@ -160,14 +160,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
];
|
||||
UserSign::create($sing);
|
||||
|
||||
if ($order && $order['store_id']) {
|
||||
$params = [
|
||||
'verify_code' => $order['verify_code'],
|
||||
'store_id' => $order['store_id'],
|
||||
'staff_id' => $order['staff_id']
|
||||
];
|
||||
OrderLogic::lessWriteOff($params);
|
||||
}
|
||||
self::dealProductLog($order);
|
||||
}
|
||||
|
||||
@ -329,8 +321,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
||||
//对应比例得退礼品券逻辑
|
||||
$discount = self::getDiscount($user->user_ship);
|
||||
$total_price = bcmul($order->refund_price, $discount, 2);
|
||||
// $discount = self::getDiscount($user->user_ship);
|
||||
// $total_price = bcmul($order->refund_price, $discount, 2);
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付
|
||||
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
||||
@ -352,6 +344,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
|
||||
return true;
|
||||
}
|
||||
//订单购物详情
|
||||
StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]);
|
||||
//积分
|
||||
UserSignLogic::RefundOrder($order);
|
||||
//微信日志 user_order_refund
|
||||
@ -394,6 +388,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
$model->save();
|
||||
//增加数量
|
||||
self::addStock($order['id']);
|
||||
StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace process;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
@ -26,6 +27,8 @@ class Task
|
||||
$oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除
|
||||
if ($oid) {
|
||||
StoreOrder::where('id', 'in', $oid)->update(['delete_time' => time()]);
|
||||
StoreOrderCartInfo::where('oid','in',$oid)->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]);
|
||||
|
||||
$arr = StoreOrderCartInfo::where('oid', 'in', $oid)->field('store_id,product_id,cart_num')->select();
|
||||
$updateData = [];
|
||||
$updateDataTwo = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user