From 09f117e59cc7e1f10ff0704f18ebd6535088b4c1 Mon Sep 17 00:00:00 2001 From: gitfjn <2860488097@qq.com> Date: Thu, 1 Jan 2026 15:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BEapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/logic/GoodsCategoryLogic.php | 4 +- application/admin/logic/GoodsLogic.php | 3 +- application/admin/validate/Goods.php | 2 + application/admin/validate/GoodsCategory.php | 2 + application/admin/validate/GoodsOneSpec.php | 4 ++ application/admin/view/goods/add.html | 7 ++++ .../admin/view/goods_category/add.html | 7 ++++ .../admin/view/goods_category/edit.html | 7 ++++ .../admin/view/goods_category/lists.html | 8 ++++ application/api/controller/Goods.php | 2 +- application/api/controller/GoodsCategory.php | 3 +- application/api/controller/Index.php | 7 +++- application/api/controller/Payment.php | 8 ++++ application/api/logic/GoodsCategoryLogic.php | 39 ++++++++++++++++--- application/api/logic/GoodsLogic.php | 3 +- application/api/logic/UserLogic.php | 1 + application/api/server/CityService.php | 5 ++- 17 files changed, 99 insertions(+), 13 deletions(-) diff --git a/application/admin/logic/GoodsCategoryLogic.php b/application/admin/logic/GoodsCategoryLogic.php index 0dc57818..4a5deccc 100644 --- a/application/admin/logic/GoodsCategoryLogic.php +++ b/application/admin/logic/GoodsCategoryLogic.php @@ -47,6 +47,7 @@ class GoodsCategoryLogic 'level' => $level + 1, 'is_recommend' => $post['pid'] == 0 ? $is_recommend : 0, 'remark' => $post['remark'], + 'type' => $post['type'], //1:普通分类 2:推荐分类 'create_time' => time(), 'update_time' => time(), ]; @@ -77,6 +78,7 @@ class GoodsCategoryLogic 'pid' => $post['pid'], 'is_recommend' => $post['pid'] == 0 ? $is_recommend : 0, 'remark' => $post['remark'], + 'type' => $post['type'], //1:普通分类 2:推荐分类 'update_time' => time(), ]; @@ -128,7 +130,7 @@ class GoodsCategoryLogic $lists = Db::name('goods_category') ->where(['del' => 0]) ->order('id asc') - ->column('id,name,pid,is_recommend,is_show,level,image,sort'); + ->column('id,name,pid,is_recommend,is_show,level,image,sort,type'); foreach ($lists as $k => $item){ $lists[$k]['image'] = UrlServer::getFileUrl($item['image']); } diff --git a/application/admin/logic/GoodsLogic.php b/application/admin/logic/GoodsLogic.php index f96f6640..cf6c6c16 100644 --- a/application/admin/logic/GoodsLogic.php +++ b/application/admin/logic/GoodsLogic.php @@ -481,7 +481,8 @@ class GoodsLogic 'give_integral_type' => $give_integral_type, 'give_integral' => $give_integral, 'spec_type' => $post['spec_type'], - 'update_time' => $time + 'update_time' => $time, + 'type' => $post['type'], ]; Db::name('goods') diff --git a/application/admin/validate/Goods.php b/application/admin/validate/Goods.php index c190cf2c..e6ae2a2d 100644 --- a/application/admin/validate/Goods.php +++ b/application/admin/validate/Goods.php @@ -44,6 +44,7 @@ class Goods extends Validate 'region_ratio' => 'lt:100', 'shareholder_ratio' => 'lt:100', 'give_integral_ratio' => 'egt:0', + 'type' => 'require', ]; protected $message = [ @@ -69,6 +70,7 @@ class Goods extends Validate 'region_ratio.lt' => '区域分红比例不能超过100', 'shareholder_ratio.lt' => '股东分红比例不能超过100', 'give_integral_ratio.egt' => '赠送积分比例须大于或等于0', + 'type.require' => '请选择商品类型', ]; /** diff --git a/application/admin/validate/GoodsCategory.php b/application/admin/validate/GoodsCategory.php index 20061a36..9093bd71 100644 --- a/application/admin/validate/GoodsCategory.php +++ b/application/admin/validate/GoodsCategory.php @@ -30,6 +30,7 @@ class GoodsCategory extends Validate 'name' => 'require|checkName', 'pid' => 'addPid|editPid', 'image' => 'require', + 'type' => 'require', ]; protected $message = [ @@ -37,6 +38,7 @@ class GoodsCategory extends Validate 'name.require' => '分类名称不能为空!', 'name.unique' => '分类名称已存在', 'image.require' => '请上传分类图标', + 'type.require' => '请选择分类类型' ]; protected function sceneAdd() { diff --git a/application/admin/validate/GoodsOneSpec.php b/application/admin/validate/GoodsOneSpec.php index c9339fa1..3c3ba339 100644 --- a/application/admin/validate/GoodsOneSpec.php +++ b/application/admin/validate/GoodsOneSpec.php @@ -30,6 +30,8 @@ class GoodsOneSpec extends Validate 'one_stock' => 'require|integer', 'one_volume' => 'egt:0', 'one_weight' => 'egt:0', + 'type' => 'require', + 'points' => 'egt:0', ]; protected $message = [ @@ -45,6 +47,8 @@ class GoodsOneSpec extends Validate 'one_cost_price.egt' => '成本价必须大于或等于0.01', 'one_stock.require' => '请输入库存', 'one_stock.integer' => '库存必须为整型', + 'type.require' => '请选择规格类型', + 'points.egt' => '积分必须为正整数', ]; diff --git a/application/admin/view/goods/add.html b/application/admin/view/goods/add.html index 92eb0f21..69606879 100644 --- a/application/admin/view/goods/add.html +++ b/application/admin/view/goods/add.html @@ -22,6 +22,13 @@ class="layui-input"> +
+ +
+ + +
+
diff --git a/application/admin/view/goods_category/add.html b/application/admin/view/goods_category/add.html index 3bb61101..e3804a26 100644 --- a/application/admin/view/goods_category/add.html +++ b/application/admin/view/goods_category/add.html @@ -45,6 +45,13 @@
+
+ +
+ + +
+
diff --git a/application/admin/view/goods_category/edit.html b/application/admin/view/goods_category/edit.html index 5f97866d..060c1f91 100644 --- a/application/admin/view/goods_category/edit.html +++ b/application/admin/view/goods_category/edit.html @@ -46,6 +46,13 @@
+
+ +
+ + +
+
diff --git a/application/admin/view/goods_category/lists.html b/application/admin/view/goods_category/lists.html index ad9866b5..d1c5ef48 100644 --- a/application/admin/view/goods_category/lists.html +++ b/application/admin/view/goods_category/lists.html @@ -93,6 +93,14 @@ }, cols: [ {field: 'name', title: '分类名称',width: 280}, + //类型 1服务商品 2普通商品 + {field: 'type', title: '类型', width: 100, align: 'center',templet: function (d) { + if(d.type === 1){ + return '服务商品'; + }else{ + return '普通商品'; + } + }}, {field: '#image', title: '分类图标', width: 120,style:'height:100px;',toolbar: '#image', align: 'center'}, {templet: '#is_recommend', title: '首页推荐', width: 100,align: 'center'}, {templet: '#is_show', title: '显示', width: 100}, diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index e8c7a517..3757cbda 100644 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -11,7 +11,7 @@ class Goods extends ApiBase{ */ public function getGoodsList(){ $get = $this->request->get(); - $goods_list = GoodsLogic::getGoodsList($this->user_id, $get, $this->page_no, $this->page_size); + $goods_list = GoodsLogic::getGoodsList($this->user_id, $get, $this->page_no, $this->page_size,$get['type']); $this->_success('获取成功',$goods_list); } diff --git a/application/api/controller/GoodsCategory.php b/application/api/controller/GoodsCategory.php index 1722e4f6..d1631239 100644 --- a/application/api/controller/GoodsCategory.php +++ b/application/api/controller/GoodsCategory.php @@ -14,7 +14,8 @@ class GoodsCategory extends ApiBase{ */ public function lists(){ $client = $this->request->get('client',1); - $cateogry = GoodsCategoryLogic::categoryThirdTree($client); + $type = $this->request->get('type',1); + $cateogry = GoodsCategoryLogic::categoryThirdTree($client,$type); $this->_success('获取成功',$cateogry); } diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 9e7f2456..36aeea64 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -30,7 +30,12 @@ use app\common\server\Alisms; class Index extends ApiBase { public $like_not_need_login = ['test','sedx','lists','appInit', 'downLine', 'share', 'config','pcLists','goods_stay_time','send_sms','get_pege']; - + + public function visit() + { + $this->_success('',['a'=>1]); + } + //短信宝接口 public function sedx(){ $nowtime = time(); diff --git a/application/api/controller/Payment.php b/application/api/controller/Payment.php index 1e1a6055..6a5dec95 100644 --- a/application/api/controller/Payment.php +++ b/application/api/controller/Payment.php @@ -54,6 +54,9 @@ class Payment extends ApiBase switch ($post['from']) { case 'order': $order = Order::get($post['order_id']); + if ($order == null) { + $this->_error('订单不存在'); + } if ($order['order_status'] == CommonOrder::STATUS_CLOSE || $order['del'] == 1) { $this->_error('订单已关闭'); } @@ -79,6 +82,11 @@ class Payment extends ApiBase } if (PaymentLogic::getReturnCode() != 0) { + /** + * 支付成功 + * 添加对应商品积分 + */ + $this->_success('', $result, PaymentLogic::getReturnCode()); } diff --git a/application/api/logic/GoodsCategoryLogic.php b/application/api/logic/GoodsCategoryLogic.php index 011928bb..8506d887 100644 --- a/application/api/logic/GoodsCategoryLogic.php +++ b/application/api/logic/GoodsCategoryLogic.php @@ -31,16 +31,38 @@ class GoodsCategoryLogic{ * @throws \think\exception\DbException * @author: 2021/3/6 18:49 */ - public static function categoryThirdTree($client){ + public static function categoryThirdTree($client,$type){ $cache = Cache::get('goods_category_'.$client); if ($cache) { return $cache; } - $lists = Db::name('goods_category')->where(['is_show'=>1,'del'=>0,'level'=>1])->order('sort desc')->column('id,name,pid,image,level','id'); + // 构建查询条件 + $where1 = ['is_show'=>1,'del'=>0,'level'=>1]; + $where2 = ['is_show'=>1,'del'=>0,'level'=>2]; + $where3 = ['is_show'=>1,'del'=>0,'level'=>3]; + + // 如果type参数存在,尝试添加type条件(如果表中存在该字段) + // 注意:如果数据库表中没有type字段,需要移除这些条件或添加字段 + // 暂时注释掉type条件,避免报错 + if ($type) { + $where1['type'] = $type; + $where2['type'] = $type; + $where3['type'] = $type; + } + + $lists = Db::name('goods_category') + ->where($where1) + ->order('sort desc') + ->column('id,name,pid,image,level','id'); - $level2 = Db::name('goods_category')->where(['is_show'=>1,'del'=>0,'level'=>2])->order('sort desc')->column('id,name,pid,image,level','id'); - $level3 = Db::name('goods_category')->where(['is_show'=>1,'del'=>0,'level'=>3])->order('sort desc')->field('id,name,pid,image,level')->select(); + $level2 = Db::name('goods_category') + ->where($where2) + ->column('id,name,pid,image,level','id'); + + $level3 = Db::name('goods_category') + ->where($where3) + ->field('id,name,pid,image,level')->select(); //挂载第二级 foreach ($level3 as $list3){ @@ -78,8 +100,15 @@ class GoodsCategoryLogic{ //pc端不显示品牌 if(1 == $client){ + $brandWhere = ['del'=>0,'is_show'=>1]; + // 如果type参数存在,尝试添加type条件(如果表中存在该字段) + // 暂时注释掉type条件,避免报错 + // if ($type) { + // $brandWhere['type'] = $type; + // } + $goods_brand = Db::name('goods_brand') - ->where(['del'=>0,'is_show'=>1]) + ->where($brandWhere) ->field('id,name,image') ->order('sort desc,id desc') ->select(); diff --git a/application/api/logic/GoodsLogic.php b/application/api/logic/GoodsLogic.php index ad4cec15..99ea4b5f 100644 --- a/application/api/logic/GoodsLogic.php +++ b/application/api/logic/GoodsLogic.php @@ -28,11 +28,12 @@ use think\facade\Hook; class GoodsLogic{ //商品列表 - public static function getGoodsList($user_id,$get,$page,$size){ + public static function getGoodsList($user_id,$get,$page,$size,$type){ $where = []; $order = []; $where[] = ['status','=',1]; $where[] = ['del','=',0]; + $where[] = ['type','=',$type]; $goods = new Goods(); //品牌筛选 diff --git a/application/api/logic/UserLogic.php b/application/api/logic/UserLogic.php index 5645585f..5adeb325 100644 --- a/application/api/logic/UserLogic.php +++ b/application/api/logic/UserLogic.php @@ -53,6 +53,7 @@ class UserLogic extends LogicBase { ->where(['del'=>0,'user_id'=>$user_id]) ->where('status','<>',AfterSale::STATUS_SUCCESS_REFUND) ->count(); + //查询名下优惠券 $user->coupon = Db::name('coupon_list')->where(['user_id'=>$user_id,'del'=>0,'status'=>0])->count(); //分销开关 $user->distribution_setting = ConfigServer::get('distribution', 'is_open',1); diff --git a/application/api/server/CityService.php b/application/api/server/CityService.php index 94700aab..8d336ba2 100644 --- a/application/api/server/CityService.php +++ b/application/api/server/CityService.php @@ -9,8 +9,9 @@ use think\facade\Config; class CityService { // 腾讯地图API Key - private $tencentMapKey = 'EVOBZ-VX7YU-QKJVR-BVESA-AVFT3-7JBWG'; - +// private $tencentMapKey = 'EVOBZ-VX7YU-QKJVR-BVESA-AVFT3-7JBWG'; + private $tencentMapKey = '66NBZ-KH3W4-7QSUS-K5OBA-7P552-F7F6T'; + public function list() { $cacheKey = 'city_cache_keys';