刷新一次加1,游览次数增加
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Sym\Sym;
class ProductController
{
public function index(Request $request){
Storage::put('test28.txt', $request);
//查询绿码的这条信息
$lm = DB::table('lmai_sym')->where('code', $request->code)->first();
$changjia = DB::table('lmai_changjia')->where('id', $lm->changjia_id)->first();
//产品名称= 绿码->piciId(批次表)->cp_id
$pc = DB::table('lmai_sym_pici')->where('id', $lm->pc_id)->first();
$cp = DB::table('lmai_chanpin')->where('id', $pc->cp_id)->first();
//Sym::where('code', $request->code)->increment('ci');
//DB::table('lmai_sym')->where('code', $lm->code)->increment('ci', 1);
DB::table('lmai_sym')
->where('code', $lm->code)
->update([
'ci' => DB::raw('COALESCE(ci, 0) + 1')
]);
//重新重新最新数据
$lm2 = DB::table('lmai_sym')->where('code', $request->code)->first();
$data = [
'name' => $cp->name ?? '',
'batchNo' => $pc->pc_bh,
'manufacturer' => $changjia->name,
'price' => $cp->danjia,
'count' => $lm2->ci,
'sccx' =>$lm2->sccx??''
];
return response()->json(['code' => 0,'message'=>'success','data'=>$data]);
}
}
最近访问时间:2025-12-03 10:20:56