切换导航条
此项目
正在载入...
登录
何书鹏
/
anttest
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
a1648b061c40fa80eca3ab5dc9038421fc595739
1 个父辈
b5e419f6
供货商库存优化
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
53 行增加
和
5 行删除
addons/shopro/listener/order/Payed.php
application/admin/controller/dealer/Dealer.php
application/admin/controller/dealer/DealerStock.php
public/assets/js/backend/dealer/dealer.js
addons/shopro/listener/order/Payed.php
查看文件 @
a1648b0
...
...
@@ -36,6 +36,7 @@ class Payed
->
where
(
'a.goods_id'
,
$item
[
'goods_id'
])
->
where
(
'a.sku_price_id'
,
$item
[
'goods_sku_price_id'
])
->
where
(
'a.stock'
,
'>'
,
0
)
->
where
(
'a.deletetime'
,
null
)
->
orderRaw
(
'rand()'
)
->
field
(
'a.id,a.dealer_id'
)
->
limit
(
1
)
...
...
application/admin/controller/dealer/Dealer.php
查看文件 @
a1648b0
...
...
@@ -304,10 +304,57 @@ class Dealer extends Backend
*/
public
function
goods
()
{
$dealer_id
=
$this
->
request
->
param
(
'dealer_id'
);
//当前是否为关联查询
$this
->
relationSearch
=
false
;
//设置过滤方法
$this
->
request
->
filter
([
'strip_tags'
,
'trim'
]);
if
(
$this
->
request
->
isAjax
()){
(
new
\app\admin\controller\shopro\goods\Goods
)
->
index
();
list
(
$where
,
$sort
,
$order
,
$offset
,
$limit
)
=
$this
->
buildparams
();
$goods_model
=
new
\app\admin\model\shopro\goods\Goods
;
$where
=
[];
// 经销商
$goods_ids
=
[];
if
(
isset
(
$dealer_id
)
&&
$dealer_id
!=
0
)
{
$goods_ids
=
\app\admin\model\dealer\DealerStock
::
alias
(
'a'
)
->
join
(
'shopro_goods_sku_price b'
,
'a.sku_price_id = b.id'
)
->
where
(
'dealer_id'
,
$dealer_id
)
->
column
(
'a.goods_id'
);
}
if
(
$goods_ids
)
{
$where
[
'id'
]
=
[
'in'
,
$goods_ids
];
// 删除无用的供货商库存
\app\admin\model\dealer\DealerStock
::
where
(
'goods_id'
,
'not in'
,
$goods_ids
)
->
where
(
'dealer_id'
,
$dealer_id
)
->
delete
();
}
$total
=
$goods_model
->
where
(
$where
)
->
count
();
$subsql
=
\app\admin\model\shopro\goods\SkuPrice
::
where
(
'status'
,
'up'
)
->
field
(
'sum(stock) as stock, goods_id'
)
->
group
(
'goods_id'
)
->
buildSql
();
$goodsTableName
=
$goods_model
->
getQuery
()
->
getTable
();
// 关联规格表,获取总库存
$list
=
$goods_model
->
join
([
$subsql
=>
'w'
],
$goodsTableName
.
'.id = w.goods_id'
,
'left'
);
// 关联查询当前商品的活动,一个商品可能存在多条活动记录,关联条件 只有 find_in_set 会存在一个商品出现多次,所以使用 group
$actSubSql
=
\app\admin\model\shopro\activity\Activity
::
field
(
'type as activity_type, id as activity_id, goods_ids'
)
->
buildSql
();
$list
=
$list
->
join
([
$actSubSql
=>
'act'
],
"find_in_set("
.
$goodsTableName
.
".id, goods_ids)"
,
'left'
)
->
group
(
'id'
);
$list
=
$list
->
orderRaw
(
$sort
.
' '
.
$order
)
->
where
(
$where
)
->
limit
(
$offset
,
$limit
)
->
select
();
foreach
(
$list
as
$row
)
{
$row
->
visible
([
'id'
,
'type'
,
'activity_id'
,
'activity_type'
,
'app_type'
,
'title'
,
'status'
,
'weigh'
,
'category_ids'
,
'image'
,
'price'
,
'likes'
,
'views'
,
'sales'
,
'stock'
,
'show_sales'
,
'dispatch_type'
,
'updatetime'
]);
}
$list
=
collection
(
$list
)
->
toArray
();
return
json
([
"total"
=>
$total
,
"rows"
=>
$list
]);
}
$this
->
assignconfig
(
'dealer_id'
,
$
this
->
request
->
param
(
'dealer_id'
)
);
$this
->
assignconfig
(
'dealer_id'
,
$
dealer_id
);
return
$this
->
view
->
fetch
();
}
...
...
@@ -379,7 +426,7 @@ class Dealer extends Backend
// 更新规格库存
foreach
(
$list
as
$v
)
{
$sum_stock
=
$act
->
where
(
'sku_price_id'
,
$v
[
'sku_price_id'
])
->
sum
(
'stock'
);
$sum_stock
=
$act
->
where
(
'sku_price_id'
,
$v
[
'sku_price_id'
])
->
where
(
'deletetime'
,
null
)
->
sum
(
'stock'
);
\app\admin\model\shopro\goods\SkuPrice
::
where
(
'id'
,
$v
[
'sku_price_id'
])
->
update
([
'stock'
=>
$sum_stock
]);
}
Db
::
commit
();
...
...
application/admin/controller/dealer/DealerStock.php
查看文件 @
a1648b0
...
...
@@ -114,7 +114,7 @@ class DealerStock extends Backend
}
$result
=
$this
->
model
->
allowField
(
true
)
->
save
(
$params
);
// 更新规格库存
$skuPrice
->
stock
=
$this
->
model
->
where
(
'sku_price_id'
,
$skuPrice
[
'id'
])
->
sum
(
'stock'
);
$skuPrice
->
stock
=
$this
->
model
->
where
(
'sku_price_id'
,
$skuPrice
[
'id'
])
->
where
(
'deletetime'
,
null
)
->
sum
(
'stock'
);
$skuPrice
->
save
();
Db
::
commit
();
}
catch
(
ValidateException
$e
)
{
...
...
public/assets/js/backend/dealer/dealer.js
查看文件 @
a1648b0
...
...
@@ -167,7 +167,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 初始化表格参数配置
Table
.
api
.
init
({
extend
:
{
index_url
:
'
shopro/goods/goods/index
'
+
location
.
search
,
index_url
:
'
dealer/dealer/goods
'
+
location
.
search
,
dragsort_url
:
''
,
table
:
'shopro_goods'
,
}
...
...
请
注册
或
登录
后发表评论