| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller\shop;
- use app\common\controller\Backend;
- use think\annotation\route\Group;
- use think\annotation\route\Route;
- 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\ShopList as ShopListModel;
- #[Group("shop/shop_list")]
- class ShopList extends Backend
- {
- use Actions{
- add as protected _add;
- edit as protected _edit;
- }
- protected function _initialize()
- {
- parent::_initialize();
- $this->model = new ShopListModel();
- $this->assign('customerList', Customer::where('status', 1)->column('name','id'));
- $this->assign('platformList', site_config('addonsd.platform_list'));
- $this->assign('userList', User::where('status',Customer::STATUS_NORMAL)->column('nickname','id'));
- $this->assign('fieldList', StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
- $this->relationField=['customer','staff'];
- }
-
- #[Route('GET,POST','specs')]
- public function specs()
- {
- 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();
- return resp_json(200,'操作成功');
- }else{
-
- $ids = $this->request->get('ids/d', 0);
- $rows = $this->model::find($ids);
- $this->assign('row', $rows);
- return $this->fetch();
- }
- }
-
- #[Route('GET','get_box')]
- public function get_box()
- {
- if($this->request->isAjax()){
-
- $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();
- if($rows->specs){
- $specs = json_decode($rows->specs, true);
- dump($specs);die;
- foreach ($specs['specs'] as $item) {
- }
- }
- return json($rows, 200);
- }
- }
-
- }
|