refactor(PayNotifyLogic, StoreOrderController): 移除无用核销逻辑,优化库存更新流程
This commit is contained in:
parent
a5d93516b2
commit
3c305cfaf0
@ -107,14 +107,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
];
|
];
|
||||||
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
|
self::dealGoodsLeft($checkArr, $order['uid'], $order['id']);
|
||||||
}
|
}
|
||||||
if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
|
// if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
|
||||||
$params = [
|
// $params = [
|
||||||
'verify_code' => $order['verify_code'],
|
// 'verify_code' => $order['verify_code'],
|
||||||
'store_id' => $order['store_id'],
|
// 'store_id' => $order['store_id'],
|
||||||
'staff_id' => $order['staff_id']
|
// 'staff_id' => $order['staff_id']
|
||||||
];
|
// ];
|
||||||
OrderLogic::writeOff($params);
|
// OrderLogic::writeOff($params);
|
||||||
}
|
// }
|
||||||
if (in_array($order['shipping_type'], [1, 2])) {
|
if (in_array($order['shipping_type'], [1, 2])) {
|
||||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||||
}
|
}
|
||||||
@ -203,14 +203,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// }
|
// }
|
||||||
// self::addUserSing($order);
|
// self::addUserSing($order);
|
||||||
self::afterPay($order);
|
self::afterPay($order);
|
||||||
if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
|
// if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) {
|
||||||
$params = [
|
// $params = [
|
||||||
'verify_code' => $order['verify_code'],
|
// 'verify_code' => $order['verify_code'],
|
||||||
'store_id' => $order['store_id'],
|
// 'store_id' => $order['store_id'],
|
||||||
'staff_id' => $order['staff_id']
|
// 'staff_id' => $order['staff_id']
|
||||||
];
|
// ];
|
||||||
OrderLogic::writeOff($params);
|
// OrderLogic::writeOff($params);
|
||||||
}
|
// }
|
||||||
// self::dealProductLog($order);
|
// self::dealProductLog($order);
|
||||||
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
|
if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) {
|
||||||
$checkArr = [
|
$checkArr = [
|
||||||
@ -504,7 +504,8 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$order->paid = 1;
|
$order->paid = 1;
|
||||||
$order->pay_time = time();
|
$order->pay_time = time();
|
||||||
$order->status = 2;
|
$order->status = 1;
|
||||||
|
// $order->status = 2;
|
||||||
if ($order['reservation'] == 1) {
|
if ($order['reservation'] == 1) {
|
||||||
$order->status = 1;
|
$order->status = 1;
|
||||||
}
|
}
|
||||||
@ -519,14 +520,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
||||||
// self::dealProductLog($order);
|
// self::dealProductLog($order);
|
||||||
|
|
||||||
if ($order && $order['store_id'] && $order['reservation'] != 1) {
|
// if ($order && $order['store_id'] && $order['reservation'] != 1) {
|
||||||
$params = [
|
// $params = [
|
||||||
'verify_code' => $order['verify_code'],
|
// 'verify_code' => $order['verify_code'],
|
||||||
'store_id' => $order['store_id'],
|
// 'store_id' => $order['store_id'],
|
||||||
'staff_id' => $order['staff_id']
|
// 'staff_id' => $order['staff_id']
|
||||||
];
|
// ];
|
||||||
OrderLogic::writeOff($params);
|
// OrderLogic::writeOff($params);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||||
@ -571,14 +572,14 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
// else {
|
// else {
|
||||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||||
// }
|
// }
|
||||||
if ($order->pay_type == 13) {
|
// if ($order->pay_type == 13) {
|
||||||
$params = [
|
// $params = [
|
||||||
'verify_code' => $order['verify_code'],
|
// 'verify_code' => $order['verify_code'],
|
||||||
'store_id' => $order['store_id'],
|
// 'store_id' => $order['store_id'],
|
||||||
'staff_id' => $order['staff_id']
|
// 'staff_id' => $order['staff_id']
|
||||||
];
|
// ];
|
||||||
OrderLogic::writeOff($params);
|
// OrderLogic::writeOff($params);
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,36 +597,20 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$branchProduct = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $v['store_id'])->find();
|
$branchProduct = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $v['store_id'])->find();
|
||||||
if ($branchProduct) {
|
if ($branchProduct) {
|
||||||
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
$stock = bcsub($branchProduct['stock'], $v['cart_num'], 2);
|
||||||
onBeforeUpdate($branchProduct->toArray(), 'branch_product');
|
StoreBranchProduct::update([
|
||||||
|
|
||||||
StoreBranchProduct::where('id', $branchProduct['id'])->update([
|
|
||||||
'stock' => $stock,
|
'stock' => $stock,
|
||||||
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
|
'total_price' => bcmul($stock, $branchProduct['purchase'], 2),
|
||||||
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
|
'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2)
|
||||||
]);
|
],['id'=>$branchProduct['id']]);
|
||||||
|
|
||||||
$branchProduct = $branchProduct->toArray();
|
|
||||||
$branchProduct['stock'] = $stock;
|
|
||||||
$branchProduct['total_price'] = bcmul($stock, $branchProduct['purchase'], 2);
|
|
||||||
$branchProduct['sales'] = bcadd($branchProduct['sales'], $v['cart_num'], 2);
|
|
||||||
onAfterUpdate($branchProduct, 'branch_product');
|
|
||||||
}
|
}
|
||||||
$storeProduct = StoreProduct::where('id', $v['product_id'])->find();
|
$storeProduct = StoreProduct::where('id', $v['product_id'])->find();
|
||||||
if ($storeProduct) {
|
if ($storeProduct) {
|
||||||
$stock = bcsub($storeProduct['stock'], $v['cart_num'], 2);
|
$stock = bcsub($storeProduct['stock'], $v['cart_num'], 2);
|
||||||
onBeforeUpdate($storeProduct->toArray(), 'product');
|
StoreProduct::update([
|
||||||
|
|
||||||
StoreProduct::where('id', $v['product_id'])->update([
|
|
||||||
'stock' => $stock,
|
'stock' => $stock,
|
||||||
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
'total_price' => bcmul($stock, $storeProduct['purchase'], 2),
|
||||||
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2)
|
||||||
]);
|
],['id'=>$v['product_id']]);
|
||||||
|
|
||||||
$storeProduct = $storeProduct->toArray();
|
|
||||||
$storeProduct['stock'] = $stock;
|
|
||||||
$storeProduct['total_price'] = bcmul($stock, $storeProduct['purchase'], 2);
|
|
||||||
$storeProduct['sales'] = bcadd($storeProduct['sales'], $v['cart_num'], 2);
|
|
||||||
onAfterUpdate($storeProduct, 'product');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -668,11 +653,6 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果是会员需要返回会员金额
|
|
||||||
// if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) {
|
|
||||||
// $order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if($order['uid']>0){
|
if($order['uid']>0){
|
||||||
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
|
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
|
||||||
if ($address) {
|
if ($address) {
|
||||||
|
@ -542,4 +542,24 @@ class StoreOrderController extends BaseAdminController
|
|||||||
return $this->fail('订单支付中');
|
return $this->fail('订单支付中');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不配送核销
|
||||||
|
*/
|
||||||
|
public function noDelivery(){
|
||||||
|
$id=$this->request->post('id');
|
||||||
|
if($id){
|
||||||
|
$params = StoreOrder::where('id', $id)->find();
|
||||||
|
if (!$params) {
|
||||||
|
return $this->fail('无该核销码请检查');
|
||||||
|
}
|
||||||
|
$params['store_id'] = $this->adminInfo['store_id'];
|
||||||
|
$params['staff_id'] = $this->adminId;
|
||||||
|
$res = OrderLogic::writeOff($params);
|
||||||
|
if ($res) {
|
||||||
|
return $this->success('核销成功');
|
||||||
|
}
|
||||||
|
return $this->fail('核销失败' . OrderLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user