refactor(api): 优化 wps_product 接口并移除未使用的方法

- 移除了 notNeedLogin 数组中的 'wps_product' 方法
- 优化了 wps_product 方法的逻辑,移除了不必要的解码和重新编码过程
- 删除了未使用的返回语句
This commit is contained in:
mkm 2024-11-29 20:58:15 +08:00
parent cb2187c0ff
commit 91877cd4a3

View File

@ -53,7 +53,7 @@ use PhpOffice\PhpWord\Style\Font;
class IndexController extends BaseApiController class IndexController extends BaseApiController
{ {
public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer','wps_product']; public $notNeedLogin = ['index', 'app_update', 'express_list', 'province', 'city', 'area', 'street', 'village', 'brigade', 'config', 'push', 'purchase_product_offer'];
public function index() public function index()
{ {
@ -285,11 +285,7 @@ class IndexController extends BaseApiController
public function wps_product() public function wps_product()
{ {
$data = $this->request->post(); $data = $this->request->post();
if ($data) { if ($data) {
$keys = array_keys($data); // 获取所有键
$firstKey = $keys[0]; // 获取第一个键
$data=json_decode($firstKey,true);
if ($data['product_id'] > 0) { if ($data['product_id'] > 0) {
$find = Db::name('wps_product')->where('product_id', $data['product_id'])->find(); $find = Db::name('wps_product')->where('product_id', $data['product_id'])->find();
$arr = []; $arr = [];
@ -310,7 +306,6 @@ class IndexController extends BaseApiController
Db::name('wps_product')->insert($arr); Db::name('wps_product')->insert($arr);
} }
} }
return $this->success('ok');
} else { } else {
return $this->fail('时间不能为空'); return $this->fail('时间不能为空');
} }