From 9100c673617f899d0973105e6e5007feba9c95b5 Mon Sep 17 00:00:00 2001 From: zengyyh Date: Sun, 20 Oct 2024 14:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E6=8A=A5=E6=8F=90=E4=BA=A4=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 10 +++++ app/api/controller/Store.php | 18 ++++++++ app/common/model/OpenShop.php | 78 ++++++++++++++++++++++++++++++++++ app/common/model/Tipoff.php | 70 ++++++++++++++++++++---------- app/store/controller/Goods.php | 19 +++++---- app/store/controller/Store.php | 8 ++++ 6 files changed, 173 insertions(+), 30 deletions(-) create mode 100644 app/common/model/OpenShop.php diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 108dd6ff..49d12b97 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -20,6 +20,7 @@ use EasyWeChat\Factory; use app\api\service\Setting as SettingService; use app\common\service\GoodsCateEs; use app\common\service\Jd; +use app\common\model\Tipoff as ModelTipoff; /** * 商品控制器 @@ -531,4 +532,13 @@ class Goods extends Controller return $this->renderSuccess(['detail' => $goodsInfo]); } + public function tipOffList() + { + $params = $this->request->param(); + $model = new ModelTipoff; + $list = $model->getList($params); + return $this->renderSuccess(compact('list')); + + } + } diff --git a/app/api/controller/Store.php b/app/api/controller/Store.php index 59335b64..aaa8121b 100644 --- a/app/api/controller/Store.php +++ b/app/api/controller/Store.php @@ -23,6 +23,7 @@ use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\response\Json; +use app\common\model\OpenShop; /** * 商城基础信息 @@ -215,5 +216,22 @@ class Store extends Controller return $this->renderSuccess($list); } + /** + * 开通商城提交的信息 + */ + public function openShop() + { + $userId = UserService::getCurrentLoginUserId(); + $params = $this->postForm(); + $params['user_id'] = $userId; + $params['store_id'] = $this->storeId; + $model =new OpenShop(); + if(!$model->add($params)){ + return $this->renderError($model->getError() ?: '提交失败'); + } + return $this->renderSuccess('提交成功,请耐心等待'); + + } + } \ No newline at end of file diff --git a/app/common/model/OpenShop.php b/app/common/model/OpenShop.php new file mode 100644 index 00000000..abc2d556 --- /dev/null +++ b/app/common/model/OpenShop.php @@ -0,0 +1,78 @@ +save($data); + } + + public function select888() + { + return self::select(); + } + + public function getList(array $param = []) + { + $filter = $this->getQueryFilter($param); + // 商品信息查询 + $list = $this->where($filter)->order('create_time', 'desc')->paginate($param['pageSize'] ?? 15)->toArray(); + + foreach ($list['data'] as &$value) { + $value['card_front_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['id_card_front_id'])->select(); + $value['card_back_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['id_card_back_id'])->select(); + $value['business_license_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['business_license_id'])->select(); + $value['photo_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['photo_id'])->select(); + $value['qr_code_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['qr_code_id'])->select(); + $value['merchant_name_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['merchant_name_id'])->select(); + } + + return $list; + } + + public function getQueryFilter(array $param) + { + // 设置默认的检索数据 + $params = $this->setQueryDefaultValue($param, [ + 'name' =>"", // 查询内容 + 'mobile' => "", // 手机号 + 'betweenTime' => [] // 起止时间 + ]); + // 检索查询条件 + $filter = []; + + // 起止时间 + if (!empty($params['betweenTime'])) { + $times = between_time($params['betweenTime']); + if (isset($times['start_time']) && isset($times['end_time'])) { + $filter[] = ['create_time', '>=', $times['start_time']]; + $filter[] = ['create_time', '<', $times['end_time'] + 86400]; + } + } + + // 渠道名称 + if (!empty($params['name'])) { + $filter[] = ['name', 'like', "%{$params['name']}%"]; + } + + // 查询内容 + if (!empty($params['mobile'])) { + $filter[] = ['mobile', 'like', "%{$params['mobile']}%"]; + } + + return $filter; + } + } diff --git a/app/common/model/Tipoff.php b/app/common/model/Tipoff.php index 6967509a..38cbdb4b 100644 --- a/app/common/model/Tipoff.php +++ b/app/common/model/Tipoff.php @@ -6,6 +6,7 @@ namespace app\common\model; use cores\BaseModel; use app\common\service\Jd; +use app\store\model\Goods as GoodsModel; class Tipoff extends BaseModel { @@ -22,19 +23,23 @@ class Tipoff extends BaseModel public function getList(array $param = []) { $filter = $this->getQueryFilter($param); - $list = $this->alias('tipoff') - ->where($filter) - ->join('goods', 'goods.goods_id = tipoff.goods_id') - ->field('tipoff.*,goods.*') - ->order(['tipoff.create_time' => 'desc']) - ->paginate($param['pageSize'] ?? 15); $jd = new Jd(); - foreach ($list as $key => $value) { - //京东短链 - $jd_short_url = $jd->getJdShortLink($value->goods_no); - $value['jd_short_url'] = $jd_short_url; + $list = $this->where($filter)->order('create_time', 'desc')->paginate($param['pageSize'] ?? 15)->toArray(); + + foreach ($list['data'] as &$value) { + if (isset($value['goods_id'])) { + // 确保 $value['goods_id'] 是一个数组 + $value['goods'] = Goods::where('goods_id','in', $value['goods_id'])->select(); + } + + // foreach ( $value['goods'] as $key => $val) { + // //京东短链 + // $jd_short_url = $jd->getJdShortLink($val->goods_no); + // $val['jd_short_url'] = $jd_short_url; + // } + } - + return $list; } @@ -42,24 +47,45 @@ class Tipoff extends BaseModel { // 设置默认的检索数据 $params = $this->setQueryDefaultValue($param, [ - 'header_content' =>"", // 查询内容 - 'channel' => "", // 渠道 - 'betweenTime' => [] // 起止时间 + 'header_content' => "", // 查询内容 + 'channel_name' => "", // 渠道 + 'betweenTime' => [] // 起止时间 ]); + // 检索查询条件 $filter = []; - + // 起止时间 - if (!empty($params['create_time'])) { - $times = between_time($params['create_time']); - $filter[] = ['tipoff.create_time', '>=', $times['create_time']]; - $filter[] = ['tipoff.create_time', '<', $times['create_time'] + 86400]; + if (!empty($params['betweenTime'])) { + $times = between_time($params['betweenTime']); + if (isset($times['start_time']) && isset($times['end_time'])) { + $filter[] = ['create_time', '>=', $times['start_time']]; + $filter[] = ['create_time', '<', $times['end_time'] + 86400]; + } + } + + // 渠道名称 + if (!empty($params['channel_name'])) { + $filter[] = ['channel_name', 'like', "%{$params['channel_name']}%"]; + } + + // 查询内容 + if (!empty($params['header_content'])) { + $filter[] = ['header_content', 'like', "%{$params['header_content']}%"]; } + + return $filter; + } - !empty($params['channel_name']) && $filter[] = ['tipoff.channel_name', 'like', "%{$params['channel_name']}%"]; - !empty($params['header_content']) && $filter[] = ['tipoff.header_content', 'like', "%{$params['header_content']}%"]; + public function deleteTipoff($ids) + { + // 检查 $ids 是否为空或 null + if (empty($ids)) { + return false; // 或者抛出一个异常,具体取决于业务需求 + } - return $filter; + return $this->where('id', 'in', $ids)->delete(); + } diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index f4b6c0e8..d08515aa 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -602,14 +602,6 @@ class Goods extends Controller { $params = $this->postForm(); $model = new GoodsModel; - $goods = $model->where("goods_id", "in", $params['goods_id'])->select(); - // $jd = new Jd(); - // foreach ($goods as $key => $value) { - // //京东短链 - // $jd_short_url = $jd->getJdShortLink($value->goods_no); - // $value['jd_short_url'] = $jd_short_url; - // } - // $params['goods'] = $goods; $params['store_id'] = $this->storeId; $Tipoff = new ModelTipoff(); @@ -627,4 +619,15 @@ class Goods extends Controller return $this->renderSuccess(compact('result')); } + + public function deleteTipOff() + { + $ids = $this->postForm('ids'); + $model = new ModelTipoff; + if(!$model->deleteTipOff($ids)){ + return $this->renderError($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('操作成功'); + + } } diff --git a/app/store/controller/Store.php b/app/store/controller/Store.php index 160d9541..e2eec05d 100644 --- a/app/store/controller/Store.php +++ b/app/store/controller/Store.php @@ -18,6 +18,7 @@ use app\store\model\Store as StoreModel; use app\admin\model\Store as AdminStoreModel; use app\common\model\Channel; use app\common\model\PriceSet; +use app\common\model\OpenShop; /** * 商家中心控制器 @@ -206,5 +207,12 @@ class Store extends Controller $data['type'] = $type; return $this->renderSuccess($data); } + + public function getOpenShopList() + { + $model = new OpenShop(); + $list = $model->getList(); + return $this->renderSuccess(compact('list')); + } }