| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\api\controller\v1\admin;
- use app\Request;
- use app\services\admin\StoreManageServices;
- use app\services\shipping\ShippingTemplatesServices;
- class StoreManageController
- {
- protected StoreManageServices $services;
- public function __construct(StoreManageServices $services)
- {
- $this->services = $services;
- }
- /**
- * 商家统计
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function statistics()
- {
- return app('json')->success($this->services->statistics());
- }
- /**
- * 商家商品
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function product(Request $request)
- {
- $where = $request->getMore([
- [['page', 'd'], 1],
- [['limit', 'd'], 10],
- ['type', ''],
- ['store_name', ''],
- ]);
- return app('json')->success($this->services->product($where));
- }
- /**
- * 商家商品上下架
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function productShow(Request $request)
- {
- [$id, $isShow] = $request->postMore([
- [['id', 'd'], 0],
- [['is_show', 'd'], 0],
- ], true);
- $this->services->productShow($id, $isShow);
- return app('json')->success('操作成功');
- }
- /**
- * 商家商品标签
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function productLabel()
- {
- return app('json')->success($this->services->productLabel());
- }
- /**
- * 商家商品标签保存
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function saveProductLabel(Request $request)
- {
- [$ids, $label_list] = $request->postMore([
- ['ids', []],
- ['label_list', []],
- ], true);
- if (is_int($ids)) $ids = [$ids];
- $this->services->saveProductLabel($ids, $label_list);
- return app('json')->success('操作成功');
- }
- /**
- * 商家商品分类
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function productCate()
- {
- return app('json')->success($this->services->productCate());
- }
- /**
- * 商家商品分类保存
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function saveProductCate(Request $request)
- {
- [$ids, $cate_id] = $request->postMore([
- ['ids', []],
- ['cate_id', []],
- ], true);
- if (is_int($ids)) $ids = [$ids];
- $this->services->saveProductCate($ids, $cate_id);
- return app('json')->success('操作成功');
- }
- /**
- * 商家商品属性
- * @param $id
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function productAttr($id)
- {
- return app('json')->success($this->services->productAttr($id));
- }
- /**
- * 商家商品属性保存
- * @param Request $request
- * @param $id
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/13
- */
- public function saveProductAttr(Request $request, $id)
- {
- [$attr_value] = $request->postMore([
- ['attr_value', []],
- ], true);
- $this->services->saveProductAttr($id, $attr_value);
- return app('json')->success('修改成功');
- }
- /**
- * 商家商品运费模版
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/12/8
- */
- public function shippingTemp()
- {
- /** @var ShippingTemplatesServices $shippingTemplatesServices */
- $shippingTemplatesServices = app()->make(ShippingTemplatesServices::class);
- $data = $shippingTemplatesServices->getSelectList();
- $data = array_merge([['id' => 0, 'name' => '未选择']], $data);
- return app('json')->success($data);
- }
- /**
- * 创建商品
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/12/9
- */
- public function createProduct(Request $request)
- {
- $data = $request->postMore([
- ['store_name', ''],
- ['slider_image', []],
- ['cate_id', []],
- ['unit_name', ''],
- ['attr', []],
- ['content', ''],
- ['logistics', []],
- ['freight', 2],
- ['postage', 0],
- ['temp_id', 0],
- ['spec_type', 0],
- ]);
- $this->services->createProduct($data);
- return app('json')->success('创建成功');
- }
- /**
- * 商家用户列表
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function user(Request $request)
- {
- $where = $request->getMore([
- ['page', 1],
- ['limit', 10],
- ['nickname', ''],
- ['group_id', 0],
- ['level', 0],
- ['label_id', ''],
- ]);
- return app('json')->success($this->services->user($where));
- }
- /**
- * 用户信息
- * @param $uid
- * @return \think\Response
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userInfo($uid)
- {
- return app('json')->success($this->services->userInfo($uid));
- }
- /**
- * 用户分组
- * @return \think\Response
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userGroup()
- {
- return app('json')->success($this->services->userGroup());
- }
- /**
- * 用户等级
- * @return \think\Response
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userLevel()
- {
- return app('json')->success($this->services->userLevel());
- }
- /**
- * 用户标签
- * @param int $uid
- * @return \think\Response
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userLabel($uid = 0)
- {
- return app('json')->success($this->services->userLabel($uid));
- }
- /**
- * 用户优惠券列表
- * @param Request $request
- * @return \think\Response
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userCoupon(Request $request)
- {
- $where = $request->getMore([
- ['page', 1],
- ['limit', 10],
- ['coupon_title', ''],
- ['uid', 0],
- ]);
- return app('json')->success($this->services->userCoupon($where));
- }
- /**
- * 修改用户信息
- * @param Request $request
- * @param $uid
- * @return \think\Response
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author wuhaotian
- * @email 442384644@qq.com
- * @date 2025/11/17
- */
- public function userUpdate(Request $request, $uid)
- {
- $data = $request->postMore([
- ['type', 0],
- ['number', 0],
- ['status', 0],
- ['level', 0],
- ['group_id', 0],
- ['days', 0],
- ['coupon_id', 0],
- ['label_id', []],
- ]);
- $this->services->userUpdate($uid, $data);
- return app('json')->success('修改成功');
- }
- }
|