1
This commit is contained in:
parent
527ddb7063
commit
051a52cc86
@ -3,6 +3,7 @@
|
|||||||
namespace app\modules\api\models;
|
namespace app\modules\api\models;
|
||||||
|
|
||||||
use app\models\Goods;
|
use app\models\Goods;
|
||||||
|
use app\models\GoodsAttr;
|
||||||
use app\models\GoodsHub;
|
use app\models\GoodsHub;
|
||||||
use app\models\Model;
|
use app\models\Model;
|
||||||
use app\models\Signing;
|
use app\models\Signing;
|
||||||
@ -23,10 +24,12 @@ class SigningForm extends ApiModel
|
|||||||
public $remark;
|
public $remark;
|
||||||
public $user_id;
|
public $user_id;
|
||||||
|
|
||||||
|
public $attr_id;
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['goods_hub_id', 'company_name', 'brand_name', 'product', 'type', 'number'], 'required'],
|
[['goods_hub_id', 'company_name', 'attr_id', 'brand_name', 'product', 'type', 'number'], 'required'],
|
||||||
[['goods_hub_id', 'number', 'user_id'], 'integer'],
|
[['goods_hub_id', 'number', 'user_id'], 'integer'],
|
||||||
[['remark'], 'string']
|
[['remark'], 'string']
|
||||||
];
|
];
|
||||||
@ -42,6 +45,13 @@ class SigningForm extends ApiModel
|
|||||||
|
|
||||||
$goods = Goods::findOne($this->goods_hub_id);
|
$goods = Goods::findOne($this->goods_hub_id);
|
||||||
|
|
||||||
|
|
||||||
|
$goodsAttr = GoodsAttr::findOne(['goods_id' => $goods->id, 'sign_id' => $this->attr_id, 'is_delete' => 0]);
|
||||||
|
|
||||||
|
if (empty($goodsAttr->price)) {
|
||||||
|
return $this->apiReturnError('价格错误');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$goods) {
|
if (!$goods) {
|
||||||
return $this->apiReturnError('商品id异常');
|
return $this->apiReturnError('商品id异常');
|
||||||
}
|
}
|
||||||
@ -51,7 +61,7 @@ class SigningForm extends ApiModel
|
|||||||
$signing->order_no = $this->orderNo();
|
$signing->order_no = $this->orderNo();
|
||||||
$signing->user_id = $this->user_id;
|
$signing->user_id = $this->user_id;
|
||||||
$signing->goods_id = $goods->id;
|
$signing->goods_id = $goods->id;
|
||||||
$signing->moy = $goods->price * $this->number;
|
$signing->moy = $goodsAttr->price;
|
||||||
$signing->company_name = $this->company_name;
|
$signing->company_name = $this->company_name;
|
||||||
$signing->brand_name = $this->brand_name;
|
$signing->brand_name = $this->brand_name;
|
||||||
$signing->product = $this->product;
|
$signing->product = $this->product;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user