merge merchantId

feature/main20240421
guojia 12 months ago
parent 7e81dc2af0
commit 175769f614
  1. 6
      app/common/model/Goods.php
  2. 16
      app/common/model/Payment.php
  3. 3
      app/store/controller/Controller.php
  4. 3
      app/store/controller/setting/Payment.php
  5. 3
      app/store/controller/setting/payment/Template.php
  6. 6
      app/store/model/Order.php
  7. 8
      app/store/model/PaymentTemplate.php
  8. 4
      public/install/data/install_struct.sql

@ -434,6 +434,12 @@ class Goods extends BaseModel
if (isset($param['is_new']) && $param['is_new'] !== '') { if (isset($param['is_new']) && $param['is_new'] !== '') {
$filter[] = ['is_new', '=', $param['is_new']]; $filter[] = ['is_new', '=', $param['is_new']];
} }
//gj
if (isset($param['merchantId']) && $param['merchantId']) {
$filter[] = ['merchant_id', '=', $param['merchantId']];
}
if (!empty($param['paihang'])) { if (!empty($param['paihang'])) {
$filter[] = ['paihang', '>', 0]; $filter[] = ['paihang', '>', 0];
$query->order('paihang asc'); $query->order('paihang asc');

@ -79,17 +79,17 @@ class Payment extends BaseModel
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
*/ */
public static function getAll(int $storeId): array public static function getAll(int $storeId, int $merchantId = 0): array
{ {
// 实例化当前模型 // 实例化当前模型
$model = new static; $model = new static;
// 默认的支付方式数据 // 默认的支付方式数据
$defaultData = $model->defaultData(); $defaultData = $model->defaultData();
if (!$data = Cache::get("payment_{$storeId}")) { if (!$data = Cache::get("payment_{$storeId}_{$merchantId}")) {
// 获取所有支付方式 // 获取所有支付方式
$data = $model->dataByStorage($storeId, $defaultData); $data = $model->dataByStorage($storeId, $defaultData, $merchantId);
// 写入缓存中 // 写入缓存中
Cache::tag('cache')->set("payment_{$storeId}", $data); Cache::tag('cache')->set("payment_{$storeId}_{$merchantId}", $data);
} }
// 重组缓存数据 (多维) // 重组缓存数据 (多维)
return static::reorganize2($defaultData, $data); return static::reorganize2($defaultData, $data);
@ -133,10 +133,14 @@ class Payment extends BaseModel
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
private function dataByStorage(int $storeId, array $defaultData): array private function dataByStorage(int $storeId, array $defaultData, int $merchantId = 0): array
{ {
// 获取数据库中所有的支付方式 // 获取数据库中所有的支付方式
$list = $this->where('store_id', '=', $storeId)->select(); $where = [];
if (isset($merchantId) && $merchantId) {
$where = ['merchant_id', '=', $merchantId];
}
$list = $this->where($where)->where('store_id', '=', $storeId)->select();
if ($list->isEmpty()) { if ($list->isEmpty()) {
return []; return [];
} }

@ -31,6 +31,9 @@ class Controller extends BaseController
// 当前商城ID // 当前商城ID
protected int $storeId; protected int $storeId;
// 当前商户ID
protected int $merchantId;
// 当前控制器名称 // 当前控制器名称
protected string $controller = ''; protected string $controller = '';

@ -22,7 +22,8 @@ class Payment extends Controller
*/ */
public function options(): Json public function options(): Json
{ {
$options = PaymentModel::getAll($this->storeId); $this->merchantId = $this->request->param("merchantId");
$options = PaymentModel::getAll($this->storeId, $this->merchantId);
return $this->renderSuccess(compact('options')); return $this->renderSuccess(compact('options'));
} }

@ -31,8 +31,9 @@ class Template extends Controller
*/ */
public function list(): Json public function list(): Json
{ {
$merchantId = $this->request->param("merchantId");
$model = new PaymentTemplateModel; $model = new PaymentTemplateModel;
$list = $model->getList(); $list = $model->getList($merchantId);
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }

@ -221,6 +221,12 @@ class Order extends OrderModel
$params['extractShopId'] > 0 && $filter[] = ['extract_shop_id', '=', (int)$params['extractShopId']]; $params['extractShopId'] > 0 && $filter[] = ['extract_shop_id', '=', (int)$params['extractShopId']];
// 会员ID // 会员ID
$params['userId'] > 0 && $filter[] = ['order.user_id', '=', (int)$params['userId']]; $params['userId'] > 0 && $filter[] = ['order.user_id', '=', (int)$params['userId']];
//gj
if (isset($param['merchantId']) && $param['merchantId']) {
$filter[] = ['merchant_id', '=', $param['merchantId']];
}
//非售后订单 //非售后订单
$filter[] = ['is_refund', '=', 10]; $filter[] = ['is_refund', '=', 10];
return $filter; return $filter;

@ -32,9 +32,13 @@ class PaymentTemplate extends PaymentTemplateModel
* @return \think\Paginator * @return \think\Paginator
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
*/ */
public function getList(): \think\Paginator public function getList($merchantId = 0): \think\Paginator
{ {
return $this->where('is_delete', '=', 0) $where = [];
if (isset($merchantId) && $merchantId) {
$where = ['merchant_id', '=', $merchantId];
}
return $this->where($where)->where('is_delete', '=', 0)
->order(['sort' => 'asc', $this->getPk()]) ->order(['sort' => 'asc', $this->getPk()])
->paginate(15); ->paginate(15);
} }

@ -429,6 +429,7 @@ CREATE TABLE `yoshop_goods` (
`goods_no` varchar(50) NOT NULL DEFAULT '' COMMENT '商品编码', `goods_no` varchar(50) NOT NULL DEFAULT '' COMMENT '商品编码',
`video_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主图视频ID', `video_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主图视频ID',
`video_cover_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主图视频ID', `video_cover_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '主图视频ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户',
`selling_point` varchar(500) NOT NULL DEFAULT '' COMMENT '商品卖点', `selling_point` varchar(500) NOT NULL DEFAULT '' COMMENT '商品卖点',
`spec_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '商品规格(10单规格 20多规格)', `spec_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '商品规格(10单规格 20多规格)',
`goods_price_min` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品价格(最低)', `goods_price_min` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品价格(最低)',
@ -755,6 +756,7 @@ CREATE TABLE `yoshop_order` (
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID', `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除', `is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID', `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户'
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`order_id`), PRIMARY KEY (`order_id`),
@ -974,6 +976,7 @@ CREATE TABLE `yoshop_payment` (
`is_default` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '是否为默认支付方式', `is_default` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '是否为默认支付方式',
`others` text NOT NULL COMMENT '其他选项(json格式)', `others` text NOT NULL COMMENT '其他选项(json格式)',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID', `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`payment_id`), PRIMARY KEY (`payment_id`),
@ -992,6 +995,7 @@ CREATE TABLE `yoshop_payment_template` (
`sort` int(3) unsigned NOT NULL DEFAULT '100' COMMENT '排序(数字越小越靠前)', `sort` int(3) unsigned NOT NULL DEFAULT '100' COMMENT '排序(数字越小越靠前)',
`is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除', `is_delete` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID', `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
`merchant_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商户ID、商店ID 隔离商城里面的商户',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`template_id`), PRIMARY KEY (`template_id`),

Loading…
Cancel
Save