|
|
@@ -10,8 +10,8 @@ use app\admin\traits\Actions;
|
|
|
use app\common\model\Customer;
|
|
|
use app\common\model\User;
|
|
|
use app\common\model\StockConfig;
|
|
|
-use app\common\model\ProductConfig;
|
|
|
-use think\Response;
|
|
|
+use app\common\model\CustomerSpec;
|
|
|
+use app\common\service\SpecService;
|
|
|
use app\common\model\ShopList as ShopListModel;
|
|
|
|
|
|
#[Group("shop/shop_list")]
|
|
|
@@ -40,25 +40,20 @@ class ShopList extends Backend
|
|
|
{
|
|
|
if($this->request->isAjax()){
|
|
|
$ids = $this->request->post('ids/d', 0);
|
|
|
- $field_name= $this->request->post('field_name');
|
|
|
- $type_id = $this->request->post('type_id');
|
|
|
- $specs = $this->request->post('type_box');
|
|
|
- $specsList = [];
|
|
|
-
|
|
|
- foreach ($specs as $item) {
|
|
|
- if(empty($item['price'])) return resp_json(0, '请填写发货价格');
|
|
|
- $specsList[] = ['name'=>$item['name'], 'price'=> $item['price']];
|
|
|
- }
|
|
|
- $row = $this->model::find($ids);
|
|
|
- $row->type_spec = json_encode(['field_name'=>['type_id'=>$type_id, 'field_name'=>$field_name], 'specs'=> $specsList], JSON_UNESCAPED_UNICODE);
|
|
|
-
|
|
|
- $row->save();
|
|
|
+ $params = $this->request->post('');
|
|
|
+ if(empty($params['variety']) || empty($ids) || empty($params['type_box'])) return resp_json(0, '参数错误');
|
|
|
+
|
|
|
+ $this->model->where('id', $ids)->save([
|
|
|
+ 'variety' => json_encode($params['variety'], JSON_UNESCAPED_UNICODE),
|
|
|
+ 'type_spec' => json_encode($params['type_box'], JSON_UNESCAPED_UNICODE),
|
|
|
+ ]);
|
|
|
return resp_json(200,'操作成功');
|
|
|
-
|
|
|
}else{
|
|
|
|
|
|
$ids = $this->request->get('ids/d', 0);
|
|
|
$rows = $this->model::find($ids);
|
|
|
+ $rows->variety = $rows->variety? json_decode($rows->variety, true) : [];
|
|
|
+ $rows->type_spec = $rows->type_spec? json_decode($rows->type_spec, true) : [];
|
|
|
$this->assign('row', $rows);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
@@ -69,22 +64,16 @@ class ShopList extends Backend
|
|
|
public function get_box()
|
|
|
{
|
|
|
if($this->request->isAjax()){
|
|
|
-
|
|
|
+ $result = [];
|
|
|
$customer_id = $this->request->get('customer_id/d', 0);
|
|
|
$type_id = $this->request->get('type_id/d', 0);
|
|
|
if(empty($type_id) || empty($customer_id)) return resp_json(0, '参数错误');
|
|
|
- $rows = $this->model::where('customer_id', $customer_id)->order('sort desc')->find();
|
|
|
+ $rows = CustomerSpec::where('customer_id', $customer_id)->order('sort desc')->find();
|
|
|
if($rows->specs){
|
|
|
-
|
|
|
$specs = json_decode($rows->specs, true);
|
|
|
-
|
|
|
- dump($specs);die;
|
|
|
- foreach ($specs['specs'] as $item) {
|
|
|
-
|
|
|
- }
|
|
|
+ $result = SpecService::getSpecsList($type_id, $specs);
|
|
|
}
|
|
|
-
|
|
|
- return json($rows, 200);
|
|
|
+ return json($result, 200);
|
|
|
}
|
|
|
}
|
|
|
|