库存处理
This commit is contained in:
@@ -246,9 +246,31 @@ class Events
|
|||||||
if (
|
if (
|
||||||
(!empty($message['operate_type']) && ($message['operate_type'] == 'add' || $message['operate_type'] == 'edit')) &&
|
(!empty($message['operate_type']) && ($message['operate_type'] == 'add' || $message['operate_type'] == 'edit')) &&
|
||||||
(!empty($message['product_id']) && !empty($message['shop_id']) && !empty($message['number'])) &&
|
(!empty($message['product_id']) && !empty($message['shop_id']) && !empty($message['number'])) &&
|
||||||
(!empty($product) && $product[0]['is_stock'] == 1)
|
(!empty($product) && $product[0]['is_auto_sold_stock'] == 1)
|
||||||
) {
|
) {
|
||||||
$gate_way = GateWay::class;
|
$gate_way = GateWay::class;
|
||||||
|
$tb_prod_cons = Db::name('prod_cons_relation')
|
||||||
|
->alias('r')
|
||||||
|
->join('tb_cons_info cons', 'r.cons_info_id = cons.id AND cons.is_stock = 1', 'inner')
|
||||||
|
->where('r.product_id', $message['product_id'])
|
||||||
|
->fieldRaw('r.cons_info_id AS consId, SUM(r.surplus_stock * ' . $message['number'] . ') AS quantity, cons.stock_number AS current_quantity')
|
||||||
|
->group('r.cons_info_id')
|
||||||
|
->select()->toArray();
|
||||||
|
p($tb_prod_cons);
|
||||||
|
if($tb_prod_cons['quantity'] > $tb_prod_cons['current_quantity']) {
|
||||||
|
$snd_data = [
|
||||||
|
'msg' => '此商品库存不足',
|
||||||
|
'operate_type' => $message['operate_type'],
|
||||||
|
'msg_id' => 'out_of_stock' . Random::build(),
|
||||||
|
'type' => 'out_of_stock',
|
||||||
|
'id' => !empty($message['id'])?$message['id']:'',
|
||||||
|
'data_type' => 'cart',
|
||||||
|
'status' => 0,
|
||||||
|
'data' => []
|
||||||
|
];
|
||||||
|
$gate_way::sendToClient($client_id, json_encode($snd_data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
$number = $message['number'];
|
$number = $message['number'];
|
||||||
try {
|
try {
|
||||||
// Redis::select(3);
|
// Redis::select(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user