bulk_edit
This commit is contained in:
@@ -650,6 +650,71 @@ class Base extends Model
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 批量修改购物车
|
||||
public static function bulk_edit_data($message)
|
||||
{
|
||||
// 需要过滤的字段
|
||||
$arr = [
|
||||
'type',
|
||||
'operate_type',
|
||||
'account',
|
||||
'active',
|
||||
'create_time',
|
||||
'goods_type',
|
||||
'group_type',
|
||||
'selectSpecInfo',
|
||||
'limitDiscountPrice',
|
||||
'isStock',
|
||||
'stockNumber',
|
||||
'group_text',
|
||||
'skuList',
|
||||
'update_time',
|
||||
'lowPrice',
|
||||
'salePrice',
|
||||
'coverImg',
|
||||
'name',
|
||||
'packFee',
|
||||
'unitName',
|
||||
'suitNum',
|
||||
'memberPrice',
|
||||
'tableCode',
|
||||
];
|
||||
$res = 0;
|
||||
if(!empty($message['history'])) {
|
||||
$list = $message['history'];
|
||||
$table_name = 'tb_order_detail';
|
||||
$edit_type = 'history';
|
||||
$num = 'num';
|
||||
}elseif (!empty($message['cart'])) {
|
||||
$list = $message['cart'];
|
||||
$table_name = 'tb_cashier_cart';
|
||||
$edit_type = 'cart';
|
||||
$num = 'number';
|
||||
}
|
||||
// 过滤字段
|
||||
foreach ($list as $k => $v) {
|
||||
foreach ($arr as $av) {
|
||||
if(!empty($v[$av])) {
|
||||
unset($list[$k][$v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($list as $k => $data) {
|
||||
$data['update_time'] = date('Y-m-d H:i:s');
|
||||
if($edit_type == 'cart' && !empty($data['pro_group_info']) && is_array($data['pro_group_info'])) {
|
||||
$data['pro_group_info'] = json_encode($data['pro_group_info']);
|
||||
}
|
||||
if(isset($data[$num]) && $data[$num] <= 0) {
|
||||
$res += Db::table($table_name)->where('id' , $data['id'])->delete();
|
||||
}else {
|
||||
$res += Db::table($table_name)->update($data);
|
||||
}
|
||||
}
|
||||
return ['status' => $res>1?1:0, 'data_type' => $edit_type];
|
||||
}
|
||||
|
||||
|
||||
// 转桌
|
||||
public static function rottable($message)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user