提交 02da718a 编写于 作者: D devil

库存管理,部分细节优化

上级 dd0a77e8
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* 支付宝小程序管理动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
*/
class Appminialipaylist
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'name',
'is_delete' => 1,
'delete_url' => MyUrl('admin/appminialipaylist/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '包名',
'view_type' => 'field',
'view_key' => 'name',
],
[
'label' => '大小',
'view_type' => 'field',
'view_key' => 'size',
],
[
'label' => '下载地址',
'view_type' => 'field',
'view_key' => 'url',
'grid_size' => 'auto',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'time',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'appminialipaylist/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* 百度小程序管理动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
*/
class Appminibaidulist
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'name',
'is_delete' => 1,
'delete_url' => MyUrl('admin/appminibaidulist/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '包名',
'view_type' => 'field',
'view_key' => 'name',
],
[
'label' => '大小',
'view_type' => 'field',
'view_key' => 'size',
],
[
'label' => '下载地址',
'view_type' => 'field',
'view_key' => 'url',
'grid_size' => 'auto',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'time',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'appminibaidulist/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* QQ小程序管理动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
*/
class Appminiqqlist
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'name',
'is_delete' => 1,
'delete_url' => MyUrl('admin/appminiqqlist/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '包名',
'view_type' => 'field',
'view_key' => 'name',
],
[
'label' => '大小',
'view_type' => 'field',
'view_key' => 'size',
],
[
'label' => '下载地址',
'view_type' => 'field',
'view_key' => 'url',
'grid_size' => 'auto',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'time',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'appminiqqlist/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* 头条小程序管理动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
*/
class Appminitoutiaolist
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'name',
'is_delete' => 1,
'delete_url' => MyUrl('admin/appminitoutiaolist/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '包名',
'view_type' => 'field',
'view_key' => 'name',
],
[
'label' => '大小',
'view_type' => 'field',
'view_key' => 'size',
],
[
'label' => '下载地址',
'view_type' => 'field',
'view_key' => 'url',
'grid_size' => 'auto',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'time',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'appminitoutiaolist/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;
/**
* 微信小程序管理动态表格
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
*/
class Appminiweixinlist
{
// 基础条件
public $condition_base = [];
/**
* 入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-22
* @desc description
* @param [array] $params [输入参数]
*/
public function Run($params = [])
{
return [
// 基础配置
'base' => [
'key_field' => 'name',
'is_delete' => 1,
'delete_url' => MyUrl('admin/appminiweixinlist/delete'),
'delete_key' => 'ids',
],
// 表单配置
'form' => [
[
'view_type' => 'checkbox',
'is_checked' => 0,
'checked_text' => '反选',
'not_checked_text' => '全选',
'align' => 'center',
'width' => 80,
],
[
'label' => '包名',
'view_type' => 'field',
'view_key' => 'name',
],
[
'label' => '大小',
'view_type' => 'field',
'view_key' => 'size',
],
[
'label' => '下载地址',
'view_type' => 'field',
'view_key' => 'url',
'grid_size' => 'auto',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'time',
],
[
'label' => '操作',
'view_type' => 'operate',
'view_key' => 'appminiweixinlist/module/operate',
'align' => 'center',
'fixed' => 'right',
],
],
];
}
}
?>
\ No newline at end of file
......@@ -18,7 +18,7 @@ namespace app\admin\form;
* @date 2020-06-16
* @desc description
*/
class CustomView
class Customview
{
// 基础条件
public $condition_base = [];
......
......@@ -20,7 +20,7 @@ use think\Db;
* @date 2020-06-30
* @desc description
*/
class GoodsBrowse
class Goodsbrowse
{
// 基础条件
public $condition_base = [];
......
......@@ -20,7 +20,7 @@ use think\Db;
* @date 2020-06-30
* @desc description
*/
class GoodsFavor
class Goodsfavor
{
// 基础条件
public $condition_base = [];
......
......@@ -3,7 +3,7 @@
<i class="am-icon-eye"></i>
<span>详情</span>
</button>
<a class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block" href="{{:MyUrl('admin/warehouse/saveinfo', ['wid'=>$module_data['id']])}}">
<a class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block" href="{{:MyUrl('admin/warehouse/saveinfo', ['id'=>$module_data['id']])}}">
<i class="am-icon-edit"></i>
<span>编辑</span>
</a>
......
......@@ -40,7 +40,7 @@
<input type="hidden" name="lat" id="form-lat" {{if !empty($data)}} value="{{$data.lat}}"{{/if}} />
<input type="text" name="address" id="form-address" placeholder="详细地址" minlength="2" maxlength="80" data-validation-message="详细地址格式 1~80 个字符之间" class="am-radius" {{if !empty($data)}} value="{{$data.address}}"{{/if}} required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="button" id="map-location-submit"><span class="am-icon-map-marker"></span> 定位</button>
<button type="button" class="am-btn am-btn-default am-radius" type="button" id="map-location-submit"><span class="am-icon-map-marker"></span> 定位</button>
</span>
</div>
<div id="map" data-level="17" class="am-margin-top-xs"></div>
......
......@@ -5,23 +5,23 @@
<!-- form start -->
<form class="am-form form-validation" method="post" action="{{:MyUrl('index/useraddress/save')}}" request-type="ajax-fun" request-value="ViewModalBack">
<div class="am-form-group">
<label>姓名</label>
<label>姓名<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="name" placeholder="姓名" minlength="2" maxlength="16" data-validation-message="姓名格式 2~16 个字符之间" class="am-radius" {{if !empty($data)}} value="{{$data.name}}"{{/if}} required />
</div>
<div class="am-form-group">
<label>电话</label>
<label>电话<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="tel" placeholder="电话" minlength="6" maxlength="30" data-validation-message="电话格式有误" class="am-radius" {{if !empty($data)}} value="{{$data.tel}}"{{/if}} required />
</div>
{{include file="lib/region_linkage" /}}
<div class="am-form-group">
<label>详细地址</label>
<label>详细地址<span class="am-form-group-label-tips-must">必填</span></label>
<div class="am-input-group am-input-group-sm">
<input type="hidden" name="lng" id="form-lng" {{if !empty($data)}} value="{{$data.lng}}"{{/if}} />
<input type="hidden" name="lat" id="form-lat" {{if !empty($data)}} value="{{$data.lat}}"{{/if}} />
<input type="text" name="address" id="form-address" placeholder="详细地址" minlength="2" maxlength="80" data-validation-message="详细地址格式 1~80 个字符之间" class="am-radius" {{if !empty($data)}} value="{{$data.address}}"{{/if}} required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="button" id="map-location-submit"><span class="am-icon-map-marker"></span> 定位</button>
<button type="button" class="am-btn am-btn-default am-radius" type="button" id="map-location-submit"><span class="am-icon-map-marker"></span> 定位</button>
</span>
</div>
<div id="map" data-level="17" class="am-margin-top-xs"></div>
......@@ -29,7 +29,7 @@
<div class="am-form-group">
<label>别名</label>
<label>别名<span class="am-form-group-label-tips">选填</span></label>
<input type="text" name="alias" placeholder="别名" minlength="0" maxlength="16" data-validation-message="别名格式最多 16 个字符" class="am-radius" {{if !empty($data)}} value="{{$data.alias}}"{{/if}} />
</div>
<div class="am-form-group">
......
......@@ -1375,7 +1375,7 @@ class GoodsService
}
// 获取仓库规格库存
$temp_data['inventory'] = WarehouseGoodsService::GoodsSpecInventory($goods_id);
$temp_data['inventory'] = WarehouseGoodsService::WarehouseGoodsSpecInventory($goods_id);
// 规格基础添加
if(Db::name('GoodsSpecBase')->insertGetId($temp_data) <= 0)
......
......@@ -11,7 +11,6 @@
namespace app\service;
use think\Db;
use think\facade\Hook;
use app\service\ResourcesService;
use app\service\GoodsService;
use app\service\UserService;
......@@ -346,7 +345,7 @@ class WarehouseGoodsService
if(!empty($result['data']) && is_array($result['data']))
{
// 获取仓库商品
$warehouse_goods_ids = Db::name('WarehouseGoods')->where(['goods_id'=>array_column($result['data'], 'id')])->column('goods_id');
$warehouse_goods_ids = Db::name('WarehouseGoods')->where(['warehouse_id'=>intval($params['warehouse_id']), 'goods_id'=>array_column($result['data'], 'id')])->column('goods_id');
if(!empty($warehouse_goods_ids))
{
foreach($result['data'] as &$v)
......@@ -748,7 +747,7 @@ class WarehouseGoodsService
// 商品规格库存
foreach($res['value'] as $v)
{
$inventory = self::GoodsSpecInventory($goods_id, str_replace(',', '', $v['value']));
$inventory = self::WarehouseGoodsSpecInventory($goods_id, str_replace(',', '', $v['value']));
if(Db::name('GoodsSpecBase')->where(['id'=>$v['base_id'], 'goods_id'=>$goods_id])->update(['inventory'=>$inventory]) === false)
{
......@@ -780,7 +779,7 @@ class WarehouseGoodsService
* @param [int] $goods_id [商品id]
* @param [string] $spec_str [规格值,如 套餐一白色16G(无则 default)]
*/
public static function GoodsSpecInventory($goods_id, $spec_str = 'default')
public static function WarehouseGoodsSpecInventory($goods_id, $spec_str = 'default')
{
// 获取商品仓库
// 仓库商品是否有效
......@@ -790,17 +789,18 @@ class WarehouseGoodsService
return 0;
}
// 无规格则使用 default 默认
if(empty($spec_str))
// 检查仓库是否启用
$warehouse_ids = Db::name('Warehouse')->where(['id'=>$warehouse_ids, 'is_enable'=>1, 'is_delete_time'=>0])->column('id');
if(empty($warehouse_ids))
{
$spec_str = 'default';
return 0;
}
// 获取商品规格库存
$where = [
'warehouse_id' => $warehouse_ids,
'goods_id' => $goods_id,
'md5_key' => md5($spec_str),
'md5_key' => md5(empty($spec_str) ? 'default' : $spec_str),
];
return (int) Db::name('WarehouseGoodsSpec')->where($where)->sum('inventory');
}
......
......@@ -11,8 +11,8 @@
namespace app\service;
use think\Db;
use think\facade\Hook;
use app\service\RegionService;
use app\service\WarehouseGoodsService;
/**
* 仓库服务层
......@@ -203,12 +203,28 @@ class WarehouseService
$params['ids'] = explode(',', $params['ids']);
}
// 启动事务
Db::startTrans();
// 删除操作
if(Db::name('Warehouse')->where(['id'=>$params['ids']])->delete())
if(Db::name('Warehouse')->where(['id'=>$params['ids']])->update(['is_delete_time'=>time(), 'upd_time'=>time()]))
{
foreach($params['ids'] as $warehouse_id)
{
$ret = self::WarehouseGoodsInventorySync($warehouse_id);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
// 提交事务
Db::commit();
return DataReturn('删除成功');
}
Db::rollback();
return DataReturn('删除失败', -100);
}
......@@ -248,12 +264,58 @@ class WarehouseService
return DataReturn($ret, -1);
}
// 启动事务
Db::startTrans();
// 数据更新
if(Db::name('Warehouse')->where(['id'=>intval($params['id'])])->update([$params['field']=>intval($params['state']), 'upd_time'=>time()]))
{
// 状态更新
if($params['field'] == 'is_enable')
{
$ret = self::WarehouseGoodsInventorySync(intval($params['id']));
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
// 提交事务
Db::commit();
return DataReturn('编辑成功');
}
Db::rollback();
return DataReturn('编辑失败', -100);
}
/**
* 仓库商品库存同步
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-17
* @desc description
* @param [int] $warehouse_id [仓库id]
*/
public static function WarehouseGoodsInventorySync($warehouse_id)
{
// 获取仓库商品
$goods_ids = Db::name('WarehouseGoods')->where(['warehouse_id'=>$warehouse_id])->column('goods_id');
if(!empty($goods_ids))
{
// 同步商品库存
foreach($goods_ids as $goods_id)
{
$ret = WarehouseGoodsService::GoodsSpecInventorySync($goods_id);
if($ret['code'] != 0)
{
return $ret;
}
}
}
return DataReturn('处理成功', 0);
}
}
?>
\ No newline at end of file
......@@ -5,7 +5,9 @@
1. 积分支持按照订单商品总额比例发放,发生售后收回积分
2. 微信小程序好物推荐和直播组件支持配置组件版本号
3. 支持商品自定义销售类型(销售模式、展示模式、自提模式、虚拟销售模式、销售+自提模式)
4. 商品管理去除库存的配置,移动到独立库存中管理
5. 新增仓库管理,仓库商品库存管理(多仓库、多库存)
6. 新增 Ipay88 支付方式
web端
1. 所有条件、数据列表、新增、编辑、删除 新增钩子(公共 form 表单封装)
......@@ -17,11 +19,13 @@ web端
7. 支付插件管理优化适配平台,编辑不可超出插件定义的适配平台
8. 用户积分实时获取
9. 管理员新增状态
10. 后台左侧菜单优化,更简洁方便,小程序管理集合
小程序端
1. 支持商品自定义销售类型模式
插件
1. 分销插件新增返积分模块
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册