|
|
@@ -6,8 +6,10 @@ use app\extra\basic\Base;
|
|
|
use app\extra\dyLife\data\BaseData;
|
|
|
use app\extra\tools\CodeExtend;
|
|
|
use app\middleware\AuthMiddleware;
|
|
|
+use app\middleware\DepositMiddleware;
|
|
|
use app\model\saas\SaasGoods;
|
|
|
use app\model\saas\SaasGoodsSku;
|
|
|
+use app\model\saas\SaasOrder;
|
|
|
use app\model\saas\SaasStore;
|
|
|
use app\service\saas\GoodsService;
|
|
|
use DI\Attribute\Inject;
|
|
|
@@ -132,12 +134,14 @@ class Goods extends Base
|
|
|
public function saveGoods(Request $request): Response
|
|
|
{
|
|
|
try {
|
|
|
+ [$state,$msg] = $this->checkDeposit($request->user['store_id']);
|
|
|
+ if (!$state) return error($msg);
|
|
|
$param = $request->post();
|
|
|
if (empty($param['auto_renew'])) $param['auto_renew'] = 0;
|
|
|
$param['image_list'] = empty($param['image_list']) ? [] : json_encode($param['image_list']);
|
|
|
$param['detail_image_list'] = empty($param['detail_image_list']) ? [] : json_encode($param['detail_image_list']);
|
|
|
$param['environment_image_list'] = empty($param['environment_image_list']) ? [] : json_encode($param['environment_image_list']);
|
|
|
- $param['notification'] = empty($param['notification']) ? [] : json_encode($param['notification']);
|
|
|
+// $param['notification'] = empty($param['notification']) ? [] : json_encode($param['notification']);
|
|
|
if (empty($param['specs'])) return error("至少添加一组搭配信息");
|
|
|
if (is_array($param['specs'])) $param['specs'] = json_encode($param['specs']);
|
|
|
if (is_array($param['category'])) {
|
|
|
@@ -165,11 +169,11 @@ class Goods extends Base
|
|
|
}
|
|
|
unset($param['skuSpecs']);
|
|
|
$param['line_price'] = $param['line_price'] * 100;
|
|
|
- if (empty($param['notification'])) return error("请最少添加一组添加使用规则");
|
|
|
- foreach (json_decode($param['notification'],true) as $key => $value) {
|
|
|
- if (empty($value['title'])) return error("规则标题不能为空");
|
|
|
- if (empty($value['content'])) return error("规则内容不能为空");
|
|
|
- }
|
|
|
+// if (empty($param['notification'])) return error("请最少添加一组添加使用规则");
|
|
|
+// foreach (json_decode($param['notification'],true) as $key => $value) {
|
|
|
+// if (empty($value['title'])) return error("规则标题不能为空");
|
|
|
+// if (empty($value['content'])) return error("规则内容不能为空");
|
|
|
+// }
|
|
|
$store = (new SaasStore)->where("poi_id",$request->user['store_id'])->findOrEmpty();
|
|
|
if ($store->isEmpty()) return errorTrans("error.data");
|
|
|
// 获取attr_key_value_map参数
|
|
|
@@ -258,5 +262,25 @@ class Goods extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #[PostMapping("del")]
|
|
|
+ public function delGoods(Request $request)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $this->_valid([
|
|
|
+ "id.require" => trans("empty.require"),
|
|
|
+ ],$request->method());
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
+ $detail = $this->model->where("id",$param["id"])->findOrEmpty();
|
|
|
+ if ($detail->isEmpty()) return errorTrans("empty.data");
|
|
|
+ if ($detail['poi_id'] <> $request->user['store_id']) return error("非法操作");
|
|
|
+ $state = $detail->delete();
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
+ (new SaasOrder)->where("product_id",$detail["product_id"])->delete();
|
|
|
+ return successTrans("success.data");
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|