48 lines
1.1 KiB
PHP
Executable File
48 lines
1.1 KiB
PHP
Executable File
<?php
|
|
namespace app\farm\model;
|
|
|
|
use app\BaseModel;
|
|
use think\facade\Db;
|
|
use think\facade\Log;
|
|
|
|
class ClaimSpec extends BaseModel
|
|
{
|
|
//定义表名
|
|
protected $name = 'lbfarm_claim_spec';
|
|
|
|
public function getList($claim_id){
|
|
|
|
return $this->where(['claim_id'=>$claim_id])->select();
|
|
}
|
|
|
|
public function claimSpecUpdate($claimSpecList,$claim_id){
|
|
|
|
$ids = [];
|
|
|
|
$claimSpecList = json_decode($claimSpecList,true);
|
|
|
|
Log::write($claimSpecList);
|
|
Log::write('11--');
|
|
foreach ($claimSpecList as $item) {
|
|
$info = $this->where(['id'=>$item['id']])->find();
|
|
if (!$info){
|
|
$info = new ClaimSpec();
|
|
$info['claim_id'] = $claim_id;
|
|
}
|
|
$info['spec_name'] = $item['spec_name'];
|
|
$info['price'] = $item['price'];
|
|
$info['stock'] = $item['stock'];
|
|
$info->save();
|
|
array_push($ids,$info['id']);
|
|
}
|
|
|
|
$this->whereNotIn('id',$ids)->where('claim_id',$claim_id)->delete();
|
|
|
|
}
|
|
|
|
public function getSpecInfo($spec_id){
|
|
return $this->find($spec_id);
|
|
}
|
|
|
|
}
|