From b359cdfeec266f4df5ca5649bf21d43e6a7821d6 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 5 Jul 2023 02:27:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=B7=E6=A0=BC=E6=AF=94?= =?UTF-8?q?=E8=BE=83app=20Signed-off-by:=20kevin=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pricetrend/action/do.php | 145 ++++++++++++++++++++++++++++++++ app/pricetrend/action/get.php | 76 +++++++++++++++++ app/pricetrend/action/index.php | 5 +- app/pricetrend/html/index.html | 3 - app/workorder/html/index.html | 3 - 5 files changed, 224 insertions(+), 8 deletions(-) create mode 100644 app/pricetrend/action/do.php create mode 100644 app/pricetrend/action/get.php diff --git a/app/pricetrend/action/do.php b/app/pricetrend/action/do.php new file mode 100644 index 0000000..274453f --- /dev/null +++ b/app/pricetrend/action/do.php @@ -0,0 +1,145 @@ +find ( 'pricetrend_item', array ( + 'SUK'=>$item_suk, + 'platform'=>$platform, + 'salestart'=>$salestart, + ) ); + + if(!$item) + { + $itemid = $new['pricetrend']->create('pricetrend_item',array( + 'SUK'=>$item_suk, + 'platform'=>$platform, + 'salestart'=>$salestart, + 'uploaddate'=> date("Y-m-d H:i:s"), + )); + $arrUpload = tsUpload($_FILES['mainphoto'],$itemid,'pricetrend',array('jpg','png','jpeg','gif')); + $new['pricetrend'] -> update('pricetrend_item', array('SUK' => $item_suk), + array( + 'mainphoto' => $arrUpload['url'], + )); + + }else + { + $itemid=$item['id']; + } + + //将名字写进数据库,并对应itemid + foreach($names as $name) + { + $tempname =json_decode(json_encode($name), true); + $tempname['name']=tsTitle($tempname['name']); + $tempname['region']=tsTitle($tempname['region']); + + $sqlname = $new ['pricetrend']->find ( 'pricetrend_item_name', array ( + 'item_id'=>$itemid, + 'name'=>$tempname['name'], + 'region'=>$tempname['region'], + ) ); + if(!$sqlname) + { + $new ['pricetrend']->create ( 'pricetrend_item_name', array ( + 'item_id'=>$itemid, + 'name'=>$tempname['name'], + 'region'=>$tempname['region'], + ) ); + } + } + + // 处理标签 + foreach($tags as $tag) + { + aac ( 'tag' )->addTag ( 'pricetrend', 'id', $itemid, $tag ); + } + + + //print_r($itemid); + + break; + + case "add_more": + echo "add more\n"; + $item_suk=tsTitle($_POST['SUK']); + $price=tsTitle($_POST['price']); + $const=tsIntval($_POST['const']); + $price_type=tsTitle($_POST['price_type']); + $sources=tsTitle($_POST['sources']); + $shop=tsTitle($_POST['shop']); + $platform=tsTitle($_POST['platform']); + $salestart=tsTitle($_POST['salestart']); + //先获取item id + $item = $new ['pricetrend']->find ( 'pricetrend_item', array ( + 'SUK'=>$item_suk, + 'platform'=>$platform, + 'salestart'=>$salestart, + ) ); + + if(!$item) + { + $itemid = $new['pricetrend']->create('pricetrend_item',array( + 'SUK'=>$item_suk, + 'platform'=>$platform, + 'salestart'=>$salestart, + 'uploaddate'=> date("Y-m-d H:i:s"), + )); + + }else + { + $itemid=$item['id']; + } + //再获取shop id + $shopit = $new ['pricetrend']->find ( 'pricetrend_shop', array ( + 'name'=>$shop, + + ) ); + + if(!$shopit) + { + $shopid = $new['pricetrend']->create('pricetrend_shop',array( + 'name'=>$shop, + + 'uploaddate'=> date("Y-m-d H:i:s"), + )); + + }else + { + $shopid=$shopit['id']; + } + + $new['pricetrend']->create('pricetrend_item_price',array( + 'item_id'=>$itemid, + 'shop_id'=>$shopid, + 'price_type'=>$price_type, + 'price'=> $price, + 'sources'=>$sources, + 'uploaddate'=>date("Y-m-d H:i:s"), + )); + $new['pricetrend']->create('pricetrend_item_const',array( + 'item_id'=>$itemid, + 'shop_id'=>$shopid, + 'const'=>$const, + 'uploaddate'=>date("Y-m-d H:i:s"), + )); + echo "ok"; + break; +} \ No newline at end of file diff --git a/app/pricetrend/action/get.php b/app/pricetrend/action/get.php new file mode 100644 index 0000000..2f85cc1 --- /dev/null +++ b/app/pricetrend/action/get.php @@ -0,0 +1,76 @@ +find ( 'pricetrend_item', array ( + 'SUK'=>$suk, + ) ); + + +$item_id=$item['id']; + +function getitem($item_id){ + + +} + +$names = $new ['pricetrend']->findall ( 'pricetrend_item_name', array ( + 'item_id'=>$item_id, + ) ); + +$price = $new ['pricetrend']->findall ( 'pricetrend_item_price', array ( + 'item_id'=>$item_id, + ) ); + +$const = $new ['pricetrend']->findall ( 'pricetrend_item_const', array ( + 'item_id'=>$item_id + ) ); + + + + + + +echo "{"; + +echo "\"id\":"; +echo "\""; +echo $item_id; +echo "\","; + +echo "\"suk\":"; +echo "\""; +echo $item['SUK']; +echo "\","; + +echo "\"platform\":"; +echo "\""; +echo $item['platform']; +echo "\","; + +echo "\"salestart\":"; +echo "\""; +echo $item['salestart']; +echo "\","; + +echo "\"mainphoto\":"; +echo "\""; +echo SITE_URL.'uploadfile/pricetrend/'.$item['mainphoto']; +echo "\","; + +echo "\"names\":"; +echo json_encode($names,JSON_UNESCAPED_UNICODE); +echo ","; + +echo "\"price\":"; +echo json_encode($price,JSON_UNESCAPED_UNICODE); +echo ","; + +echo "\"const\":"; +echo json_encode($const,JSON_UNESCAPED_UNICODE); +echo ","; + +echo "}"; \ No newline at end of file diff --git a/app/pricetrend/action/index.php b/app/pricetrend/action/index.php index f7476c5..d21a0d7 100644 --- a/app/pricetrend/action/index.php +++ b/app/pricetrend/action/index.php @@ -1,4 +1,5 @@