|
|
@@ -359,6 +359,30 @@ class ItemController extends BaseController
|
|
|
$v['shopId'] = $shopId;
|
|
|
$v['mainId'] = $mainId;
|
|
|
$v['staffName'] = $shopAdmin->name ?? '';
|
|
|
+
|
|
|
+ $name = $v['name'] ?? '';
|
|
|
+ $price = is_numeric($v['price']) ? $v['price'] : 0;
|
|
|
+ $skPrice = is_numeric($v['skPrice']) ? $v['skPrice'] : 0;
|
|
|
+ $cost = is_numeric($v['cost']) ? $v['cost'] : 0;
|
|
|
+ if ($price <= 0) {
|
|
|
+ util::fail("请填写{$name}的花店价");
|
|
|
+ }
|
|
|
+ if ($skPrice <= 0) {
|
|
|
+ util::fail("请填写{$name}的个人价");
|
|
|
+ }
|
|
|
+ if ($cost <= 0) {
|
|
|
+ util::fail("请填写{$name}的成本价");
|
|
|
+ }
|
|
|
+ if ($price > $skPrice) {
|
|
|
+ util::fail("{$name}的花店价比个人价还高");
|
|
|
+ }
|
|
|
+ if ($cost > $price) {
|
|
|
+ util::fail("{$name}的成本价比花店价还高");
|
|
|
+ }
|
|
|
+ $skMore = bcsub($skPrice, $price, 2);
|
|
|
+ $addPrice = bcsub($price, $cost, 2);
|
|
|
+ $v['skMore'] = $skMore;
|
|
|
+ $v['addPrice'] = $addPrice;
|
|
|
ProductClass::addProduct($v, $shop);
|
|
|
}
|
|
|
$transaction->commit();
|