lqmac 1 month ago
commit a96c80364f
  1. 10
      app/api/controller/Goods.php
  2. 18
      app/api/controller/Store.php
  3. 110
      app/common/model/OpenShop.php
  4. 92
      app/common/model/Tipoff.php
  5. 33
      app/store/controller/Goods.php
  6. 8
      app/store/controller/Store.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;
/**
* 商品控制器
@ -534,4 +535,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'));
}
}

@ -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('提交成功,请耐心等待');
}
}

@ -0,0 +1,110 @@
<?php
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\facade\Db;
use app\common\model\UploadFile;
use function Qcloud\Cos\encodeKey;
class OpenShop extends BaseModel
{
protected $name = 'open_shop';
protected $pk = 'id';
public function add(array $data)
{
return $this->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) {
if (isset($value['id_card_front_id']) && $value['id_card_front_id'] !== null) {
$value['card_front_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['id_card_front_id'])->select();
} else {
$value['card_front_url'] = null;
}
if (isset($value['id_card_back_id']) && $value['id_card_back_id'] !== null) {
$value['card_back_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['id_card_back_id'])->select();
} else {
$value['card_back_url'] = null;
}
if (isset($value['business_license_id']) && $value['business_license_id'] !== null) {
$value['business_license_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['business_license_id'])->select();
} else {
$value['business_license_url'] = null;
}
if (isset($value['photo_id']) && $value['photo_id'] !== null) {
$value['photo_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['photo_id'])->select();
} else {
$value['photo_url'] = null;
}
if (isset($value['qr_code_id']) && $value['qr_code_id'] !== null) {
$value['qr_code_url'] = UploadFile::withoutGlobalScope()->where("file_id", $value['qr_code_id'])->select();
} else {
$value['qr_code_url'] = null;
}
}
return $list;
}
public function getQueryFilter(array $param)
{
// 设置默认的检索数据
$params = $this->setQueryDefaultValue($param, [
'name' =>"", // 查询内容
'mobile' => "", // 手机号
"type"=> "",
'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']}%"];
}
// 类型
if (!empty($params['type'])) {
$filter[] = ['type', '=', $params['type']];
}
return $filter;
}
}

@ -0,0 +1,92 @@
<?php
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use app\common\service\Jd;
use app\store\model\Goods as GoodsModel;
class Tipoff extends BaseModel
{
protected $name = 'tipoff';
protected $pk = 'id';
public function add(array $data)
{
return $this->save($data);
}
public function getList(array $param = [])
{
$filter = $this->getQueryFilter($param);
$jd = new Jd();
$list = $this->where($filter)->order('create_time', 'desc')->paginate($param['pageSize'] ?? 150)->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;
}
public function getQueryFilter(array $param)
{
// 设置默认的检索数据
$params = $this->setQueryDefaultValue($param, [
'header_content' => "", // 查询内容
'channel_name' => "", // 渠道
'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['channel_name'])) {
$filter[] = ['channel_name', 'like', "%{$params['channel_name']}%"];
}
// 查询内容
if (!empty($params['header_content'])) {
$filter[] = ['header_content', 'like', "%{$params['header_content']}%"];
}
return $filter;
}
public function deleteTipoff($ids)
{
// 检查 $ids 是否为空或 null
if (empty($ids)) {
return false; // 或者抛出一个异常,具体取决于业务需求
}
return $this->where('id', 'in', $ids)->delete();
}
}

@ -19,6 +19,7 @@ use app\store\model\Goods as GoodsModel;
use app\store\model\goods\Import as ImportModel;
use app\common\model\GoodsCategoryRel;
use app\common\model\Category;
use app\common\model\Tipoff as ModelTipoff;
use app\job\controller\goods\StoreGoodsOffline as StoreGoodsOfflineJob;
use app\job\controller\goods\StoreGoodsOnline as StoreGoodsOnlineJob;
use app\job\controller\goods\StoreGoodsDelete as StoreGoodsDeleteJob;
@ -598,4 +599,36 @@ class Goods extends Controller
}
public function addTipff()
{
$params = $this->postForm();
$model = new GoodsModel;
$params['store_id'] = $this->storeId;
$Tipoff = new ModelTipoff();
if (!$Tipoff->add($params)) {
return $this->renderError($Tipoff->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
public function tipOffList()
{
$params = $this->request->param();
$model = new ModelTipoff;
$result = $model->getList($params);
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('操作成功');
}
}

@ -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;
/**
* 商家中心控制器
@ -207,5 +208,12 @@ class Store extends Controller
$data['type'] = $type;
return $this->renderSuccess($data);
}
public function getOpenShopList()
{
$model = new OpenShop();
$list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list'));
}
}

Loading…
Cancel
Save