作者 wangzhi

修改

... ... @@ -40,8 +40,12 @@ class Add extends Api
$this->error('您不是门店拥有者');
}
$params = $this->request->param();
$battery_type_id=Db::name('battery_code')->where('BatteryCode', $params['battery_code'])->value('battery_type_id');
if(empty($battery_type_id))$this->error('未在产品库找到该电池类型');
$battery_type_id = Db::name('battery_code')->where('BatteryCode', $params['battery_code'])->value('battery_type_id');
if (empty($battery_type_id)) $this->error('未在产品库找到该电池类型');
$IsOnly = Db::name('cp')->where(['battery_code' => $params['battery_code'],
'battery_type_id' => $battery_type_id,
'stor_id' => $StorID])->find();
if (!empty($IsOnly)) $this->error('禁止重复添加');
$data = [
'battery_code' => $params['battery_code'],
'battery_type_id' => $battery_type_id,
... ... @@ -352,7 +356,7 @@ class Add extends Api
public function BatteryCenter()
{
$UserId = $this->IsToken($this->request->header());
$Params=$this->request->param();
$Params = $this->request->param();
$mobile = Db::name('user')->where('id', $UserId)->value('mobile');
$StorID = Db::name('stor')->where('mobile', $mobile)->value('id');
if (empty($StorID)) {
... ... @@ -364,7 +368,7 @@ class Add extends Api
->where('c.stor_id', $StorID)
->where('c.status', 1)
->join('battery_code b', 'b.BatteryCode=c.battery_code')
->where('b.battery_type_id',$Params['battery_type_id'])
->where('b.battery_type_id', $Params['battery_type_id'])
->field('c.id,c.battery_code,b.Mac,c.battery')
->select();
$this->success('成功', $BatteryCenter);
... ...