mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-17 11:05:30 +08:00
1. 【新增】售后单售后原因类型支持搜索
2. 【新增】手工创建订单折扣可输入正数 3. 【优化】盘点申请单确认 4. 【修复】采购退货单模拟出库失败问题 5. 【新增】订单金额客户实付与结算金额 6. 【优化】仓库发货统计报表物料名称显示 7. 【优化】自有仓储虚拟发货逻辑 8. 【修复】基础物料分类管理问题
This commit is contained in:
@@ -22,9 +22,28 @@
|
||||
*/
|
||||
class omeauto_ctl_order_labels extends omeauto_controller
|
||||
{
|
||||
var $title = '订单标签管理';
|
||||
var $workground = 'setting_tools';
|
||||
|
||||
function index()
|
||||
private $_appName = 'omeauto';
|
||||
private $_mdl = null; //model类
|
||||
private $_primary_id = null; //主键ID字段名
|
||||
private $_primary_bn = null; //单据编号字段名
|
||||
|
||||
public function __construct($app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
|
||||
$this->_mdl = app::get($this->_appName)->model('order_labels');
|
||||
|
||||
//primary_id
|
||||
$this->_primary_id = 'label_id';
|
||||
|
||||
//primary_bn
|
||||
$this->_primary_bn = 'label_code';
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$base_filter = array();
|
||||
$actions = array();
|
||||
@@ -43,7 +62,7 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
);
|
||||
|
||||
$params = array(
|
||||
'title' => '订单标签管理',
|
||||
'title' => $this->title,
|
||||
'actions' => $actions,
|
||||
'use_buildin_new_dialog' => false,
|
||||
'use_buildin_set_tag' => false,
|
||||
@@ -57,19 +76,17 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
$this->finder('omeauto_mdl_order_labels', $params);
|
||||
}
|
||||
|
||||
function add()
|
||||
public function add()
|
||||
{
|
||||
$this->pagedata['data'] = array();
|
||||
|
||||
$this->page('order/label/label_add.html');
|
||||
}
|
||||
|
||||
function edit($label_id)
|
||||
public function edit($label_id)
|
||||
{
|
||||
$labelObj = app::get('omeauto')->model('order_labels');
|
||||
|
||||
//标记信息
|
||||
$labelInfo = $labelObj->dump(array('label_id'=>$label_id), '*');
|
||||
$labelInfo = $this->_mdl->dump(array('label_id'=>$label_id), '*');
|
||||
|
||||
$this->pagedata['data'] = $labelInfo;
|
||||
|
||||
@@ -83,8 +100,6 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
|
||||
public function save()
|
||||
{
|
||||
$labelObj = app::get('omeauto')->model('order_labels');
|
||||
|
||||
$labelLib = kernel::single('omeauto_order_label');
|
||||
|
||||
$url = "index.php?app=omeauto&ctl=order_labels&act=index";
|
||||
@@ -108,7 +123,7 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
}
|
||||
|
||||
//save
|
||||
$return = $labelObj->save($data);
|
||||
$return = $this->_mdl->save($data);
|
||||
if(!$return){
|
||||
$this->splash("error", $url, '保存失败');
|
||||
}
|
||||
@@ -123,7 +138,6 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
{
|
||||
$this->begin('index.php?app=omeauto&ctl=order_labels&act=index');
|
||||
|
||||
$labelObj = app::get('omeauto')->model('order_labels');
|
||||
$orderLabelObj = app::get('ome')->model('bill_label');
|
||||
|
||||
if($_POST['isSelectedAll'] == '_ALL_'){
|
||||
@@ -134,6 +148,11 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
$this->end(false, '没有可删除的记录');
|
||||
}
|
||||
|
||||
// list
|
||||
$labelList = $this->_mdl->getList('*', array('label_id'=>$_POST['label_id']));
|
||||
$labelList = array_column($labelList, null, 'label_id');
|
||||
|
||||
// delete label
|
||||
foreach($_POST['label_id'] as $label_id)
|
||||
{
|
||||
//判断是否已经有订单使用
|
||||
@@ -142,8 +161,13 @@ class omeauto_ctl_order_labels extends omeauto_controller
|
||||
$this->end(false, $labelInfo['label_name'] .'已经被订单使用,不能删除');
|
||||
}
|
||||
|
||||
// 系统标签不能删除
|
||||
if(isset($labelList[$label_id]) && $labelList[$label_id]['source'] == 'system'){
|
||||
$this->end(false, $labelList[$label_id]['label_name'] .':是系统标签,不能删除');
|
||||
}
|
||||
|
||||
//del
|
||||
$labelObj->db->exec("DELETE FROM sdb_omeauto_order_labels WHERE label_id=".$label_id);
|
||||
$this->_mdl->db->exec("DELETE FROM sdb_omeauto_order_labels WHERE label_id=".$label_id);
|
||||
}
|
||||
|
||||
$this->end(true, '已经删除完成!');
|
||||
|
||||
@@ -38,7 +38,7 @@ class omeauto_ctl_order_split extends omeauto_controller
|
||||
);
|
||||
|
||||
$params['actions'] = array(
|
||||
array('label' => '新建', 'icon' => '', 'href' => 'index.php?app=omeauto&ctl=order_split&act=add', 'target' => 'dialog::{width:760,height:480,title:\'新建拆单规则\'}'),
|
||||
array('label' => '新建', 'icon' => '', 'href' => 'index.php?app=omeauto&ctl=order_split&act=add', 'target' => 'dialog::{width:760,height:530,title:\'新建拆单规则\'}'),
|
||||
);
|
||||
|
||||
$this->finder('omeauto_mdl_order_split', $params);
|
||||
|
||||
@@ -34,7 +34,7 @@ $db['order_labels'] = array(
|
||||
'filterdefault' => true,
|
||||
'in_list' => true,
|
||||
'default_in_list' => true,
|
||||
'width' => 130,
|
||||
'width' => 260,
|
||||
'label' => '标签名称',
|
||||
'order' => 12,
|
||||
),
|
||||
@@ -47,7 +47,7 @@ $db['order_labels'] = array(
|
||||
'filterdefault' => true,
|
||||
'in_list' => true,
|
||||
'default_in_list' => true,
|
||||
'width' => 120,
|
||||
'width' => 260,
|
||||
'label' => '标签代码',
|
||||
'order' => 10,
|
||||
),
|
||||
|
||||
@@ -54,7 +54,7 @@ $db['order_split'] = array(
|
||||
),
|
||||
'split_type' =>
|
||||
array(
|
||||
'type' => 'varchar(12)',
|
||||
'type' => 'varchar(20)',
|
||||
'default' => 0,
|
||||
'editable' => false,
|
||||
'in_list' => true,
|
||||
|
||||
@@ -101,9 +101,9 @@ class omeauto_auto_combine
|
||||
public function process($group)
|
||||
{
|
||||
if (!is_array($group) || empty($group)) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->_instanceItemObjectFrom = 'process';
|
||||
|
||||
//初始化订单组结构
|
||||
@@ -127,7 +127,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//按发组类型开始审单
|
||||
$result = array('total' => 0, 'succ' => 0, 'fail' => 0);
|
||||
foreach ($orderFilters as $orderGroup) {
|
||||
@@ -233,11 +233,12 @@ class omeauto_auto_combine
|
||||
$filter->setConfig($type);
|
||||
$filters[] = $filter;
|
||||
}
|
||||
|
||||
//增加缺省订单分组
|
||||
|
||||
$filter = new omeauto_auto_group();
|
||||
$filter->setDefault();
|
||||
$filters[] = $filter;
|
||||
|
||||
//返回订单组
|
||||
return $filters;
|
||||
}
|
||||
@@ -252,10 +253,16 @@ class omeauto_auto_combine
|
||||
{
|
||||
//准备数据
|
||||
$ids = $this->_mergeGroup($group);
|
||||
$rows = app::get(self::__ORDER_APP)->model('orders')->getList('*', array('order_id' => $ids, 'process_status' => array('unconfirmed', 'confirmed', 'splitting', 'remain_cancel')));
|
||||
$filter = array(
|
||||
'order_id' => $ids,
|
||||
'process_status' => array('unconfirmed', 'confirmed', 'splitting', 'remain_cancel'),
|
||||
'is_not_combine' => 0,
|
||||
);
|
||||
$rows = app::get(self::__ORDER_APP)->model('orders')->getList('*', $filter);
|
||||
if (!$rows) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orders = [];
|
||||
foreach ($rows as $order) {
|
||||
//[标识]是否系统自动审单
|
||||
@@ -312,6 +319,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
$orders[$object['order_id']]['objects'][$object['obj_id']] = $object;
|
||||
}
|
||||
|
||||
//增加物流升级服务
|
||||
$orderExt = app::get(self::__ORDER_APP)->model('order_extend')->getList('order_id,cpup_service,extend_field',array('order_id'=>$ids));
|
||||
if ($orderExt) {
|
||||
@@ -478,17 +486,13 @@ class omeauto_auto_combine
|
||||
*/
|
||||
public static function getCnf($name)
|
||||
{
|
||||
|
||||
if (empty(self::$cnf)) {
|
||||
|
||||
self::$cnf = kernel::single('omeauto_config_setting')->getAutoCnf();
|
||||
}
|
||||
|
||||
if (isset(self::$cnf[$name])) {
|
||||
|
||||
return self::$cnf[$name];
|
||||
} else {
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -501,7 +505,6 @@ class omeauto_auto_combine
|
||||
*/
|
||||
private function _getBufferTime()
|
||||
{
|
||||
|
||||
return time() - self::getCnf('bufferTime') * 60;
|
||||
}
|
||||
|
||||
@@ -514,37 +517,19 @@ class omeauto_auto_combine
|
||||
public function getBufferGroup($filter = array())
|
||||
{
|
||||
$bufferTime = $this->_getBufferTime();
|
||||
|
||||
/*
|
||||
//区分分销类型,生成不同的HASH。生成一下直销订单 hash
|
||||
kernel::database()->exec("UPDATE sdb_ome_orders SET order_combine_hash=MD5(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod)), order_combine_idx= CRC32(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod)) WHERE op_id IS NULL AND group_id IS NULL AND ((shop_type<>'shopex_b2b' AND shop_type<>'dangdang' AND shop_type<>'taobao' AND shop_type<>'amazon') or shop_type is null)");
|
||||
|
||||
//当当订单如果是货到付款不合并
|
||||
kernel::database()->exec("UPDATE sdb_ome_orders SET order_combine_hash=MD5(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',IF(is_cod='true',order_id,is_cod),'-',ship_tel,'-',shop_type)), order_combine_idx= CRC32(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod,'-',ship_tel,'-',shop_type)) WHERE op_id IS NULL AND group_id IS NULL AND shop_type='dangdang'");
|
||||
//亚马逊如果是非自发货订单不合并
|
||||
kernel::database()->exec("UPDATE sdb_ome_orders SET order_combine_hash=MD5(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',IF(self_delivery='false',order_id,self_delivery),'-',ship_tel,'-',shop_type)), order_combine_idx= CRC32(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod,'-',ship_tel,'-',shop_type)) WHERE op_id IS NULL AND group_id IS NULL AND shop_type='amazon'");
|
||||
//淘宝代销订单不合并
|
||||
kernel::database()->exec("UPDATE sdb_ome_orders SET order_combine_hash=MD5(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',IF(order_source='tbdx',order_id,order_source),'-',ship_tel,'-',shop_type)), order_combine_idx= CRC32(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod,'-',ship_tel,'-',shop_type)) WHERE op_id IS NULL AND group_id IS NULL AND shop_type='taobao'");
|
||||
|
||||
//生成一下分销订单 hash
|
||||
kernel::database()->exec("UPDATE sdb_ome_orders SET order_combine_hash=MD5(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod,'-',ship_tel,'-',shop_type)), order_combine_idx= CRC32(CONCAT(IFNULL(member_id,order_id),'-',shop_id,'-',ship_name,'-',ship_mobile,'-',ship_area,'-',ship_addr,'-',is_cod,'-',ship_tel,'-',shop_type)) WHERE op_id IS NULL AND group_id IS NULL AND shop_type='shopex_b2b'");
|
||||
*/
|
||||
|
||||
|
||||
$bufferFilter = $this->_getBufferFilter();
|
||||
$bufferFilter['timing_confirm|sthan'] = time();
|
||||
|
||||
if ($filter['shop_id'] && $filter['shop_id'] != 'all') {
|
||||
$bufferFilter['shop_id'] = $filter['shop_id'];
|
||||
}
|
||||
|
||||
|
||||
//订单类型
|
||||
if ($filter['order_type'] && $filter['order_type'] != 'all') {
|
||||
$bufferFilter['order_type'] = $filter['order_type'];
|
||||
}
|
||||
|
||||
// //获取所有可处理订单
|
||||
// $this->bufferOrder = app::get(self::__ORDER_APP)->model('orders')->getList('order_id, order_combine_hash, order_combine_idx, pay_status, is_cod, createtime, paytime', $bufferFilter, 0, 1500, 'createtime ASC');
|
||||
|
||||
|
||||
//获取所有可处理订单
|
||||
$cols = 'order_id, order_combine_hash, order_combine_idx, pay_status, is_cod, createtime, paytime,step_trade_status';
|
||||
$subquery = "SELECT `order_id`
|
||||
@@ -567,12 +552,10 @@ class omeauto_auto_combine
|
||||
$orderGroup[$idx]['orders'][$key] = $row['order_id'];
|
||||
$orderGroup[$idx]['cnt'] += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//合并订单条数限制
|
||||
$orderGroup = $this->_restrictCombineLimit($orderGroup);
|
||||
|
||||
|
||||
|
||||
//去除无效数据
|
||||
foreach ($orderGroup as $key => $group) {
|
||||
if ($this->vaildBufferGroup($group['orders'], $bufferTime)) {
|
||||
@@ -582,6 +565,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $orderGroup;
|
||||
}
|
||||
|
||||
@@ -608,6 +592,7 @@ class omeauto_auto_combine
|
||||
$orderGroup[$key]['orders'] = join(',', $group['orders']);
|
||||
}
|
||||
}
|
||||
|
||||
return $orderGroup;
|
||||
}
|
||||
|
||||
@@ -620,7 +605,6 @@ class omeauto_auto_combine
|
||||
*/
|
||||
private function vaildBufferGroup($orders, $bufferTime)
|
||||
{
|
||||
|
||||
$gOrder = array();
|
||||
foreach ($orders as $idx => $ordersId) {
|
||||
$gOrder[$ordersId] = $this->bufferOrder[$idx];
|
||||
@@ -640,15 +624,11 @@ class omeauto_auto_combine
|
||||
*/
|
||||
private function _getBufferFilter()
|
||||
{
|
||||
|
||||
if(kernel::single('ome_order_func')->checkPresaleOrder()){
|
||||
|
||||
return array('order_confirm_filter' => '(op_id IS NULL AND group_id IS NULL AND ((is_cod=\'true\' and pay_status=\'0\') or (pay_status in(\'3\') AND step_trade_status in(\'FRONT_PAID_FINAL_NOPAID\')) or pay_status in (\'1\',\'4\')))', 'status' => 'active', 'ship_status' => '0', 'f_ship_status' => '0', 'confirm' => 'N', 'abnormal' => 'false', 'is_auto' => 'false', 'is_fail' => 'false', 'pause' => 'false', 'order_type|in' => kernel::single('ome_order_func')->get_normal_order_type());
|
||||
|
||||
return array('order_confirm_filter' => '(op_id IS NULL AND group_id IS NULL AND ((is_cod=\'true\' and pay_status=\'0\') or (pay_status in(\'3\') AND step_trade_status in(\'FRONT_PAID_FINAL_NOPAID\')) or pay_status in (\'1\',\'4\')))', 'status' => 'active', 'ship_status' => '0', 'f_ship_status' => '0', 'confirm' => 'N', 'abnormal' => 'false', 'is_auto' => 'false', 'is_fail' => 'false', 'pause' => 'false', 'is_not_combine'=>0, 'order_type|in' => kernel::single('ome_order_func')->get_normal_order_type());
|
||||
}else{
|
||||
return array('order_confirm_filter' => '(op_id IS NULL AND group_id IS NULL AND ((is_cod=\'true\' and pay_status=\'0\') or pay_status in (\'1\')))', 'status' => 'active', 'ship_status' => '0', 'f_ship_status' => '0', 'confirm' => 'N', 'abnormal' => 'false', 'is_auto' => 'false', 'is_fail' => 'false', 'pause' => 'false', 'order_type|in' => kernel::single('ome_order_func')->get_normal_order_type());
|
||||
return array('order_confirm_filter' => '(op_id IS NULL AND group_id IS NULL AND ((is_cod=\'true\' and pay_status=\'0\') or pay_status in (\'1\')))', 'status' => 'active', 'ship_status' => '0', 'f_ship_status' => '0', 'confirm' => 'N', 'abnormal' => 'false', 'is_auto' => 'false', 'is_fail' => 'false', 'pause' => 'false', 'is_not_combine'=>0, 'order_type|in' => kernel::single('ome_order_func')->get_normal_order_type());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -660,26 +640,21 @@ class omeauto_auto_combine
|
||||
*/
|
||||
public function fetchAlertMsg($staus, $order)
|
||||
{
|
||||
|
||||
if ($staus == 0) {
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($this->_plugins as $plug) {
|
||||
|
||||
$obj = $this->_instancePlugin($plug);
|
||||
|
||||
if (is_object($obj)) {
|
||||
|
||||
$_msg = $obj->getMsgFlag();
|
||||
if (($staus & $_msg) > 0) {
|
||||
$result[] = $obj->getAlertMsg($order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mResult = array();
|
||||
|
||||
$mark = kernel::single('omeauto_auto_group_mark');
|
||||
$mResult = $mark->fetchAlertMsg($staus, $order);
|
||||
$result = array_merge($result, $mResult);
|
||||
@@ -695,13 +670,10 @@ class omeauto_auto_combine
|
||||
*/
|
||||
public function getErrorFlags()
|
||||
{
|
||||
|
||||
$result = array();
|
||||
foreach ($this->_plugins as $plug) {
|
||||
|
||||
$obj = $this->_instancePlugin($plug);
|
||||
if (is_object($obj)) {
|
||||
|
||||
$_msg = $obj->getMsgFlag();
|
||||
$result[$_msg] = $obj->getTitle();
|
||||
}
|
||||
@@ -782,7 +754,9 @@ class omeauto_auto_combine
|
||||
$consignee['r_time'] = $o['r_time'];
|
||||
$consignee['email'] = $o['ship_email'];
|
||||
$consignee['zip'] = $o['ship_zip'];
|
||||
|
||||
$o['consignee'] = $consignee;
|
||||
|
||||
//读取店铺名称
|
||||
$shop = app::get(self::__ORDER_APP)->model('shop')->getList('name', array('shop_id' => $o['shop_id']), 0, 1);
|
||||
$o['shop_name'] = $shop[0]['name'];
|
||||
@@ -800,11 +774,8 @@ class omeauto_auto_combine
|
||||
|
||||
//转换数据 addon
|
||||
foreach ($o['items'] as $type => $item) {
|
||||
|
||||
foreach ($item as $objId => $object) {
|
||||
|
||||
foreach ($object['order_items'] as $pid => $product) {
|
||||
|
||||
$o['items'][$type][$objId]['order_items'][$pid]['bn'] = preg_replace('/^:::/is', '', $o['items'][$type][$objId]['order_items'][$pid]['bn']);
|
||||
$o['items'][$type][$objId]['order_items'][$pid]['max_left_nums'] = $product['left_nums'];
|
||||
|
||||
@@ -891,14 +862,16 @@ class omeauto_auto_combine
|
||||
|
||||
if ($ship_address == '0') {
|
||||
$filter['ship_name'] = $order['ship_name'];
|
||||
|
||||
$filter['ship_area'] = $order['ship_area'];
|
||||
$filter['ship_addr'] = $order['ship_addr'];
|
||||
|
||||
if($order['shop_type'] == 'taobao' && strpos($order['ship_name'], '>>') !== false) {
|
||||
unset($filter['ship_addr']);
|
||||
}
|
||||
|
||||
$filter['no_encrypt'] = true;
|
||||
}
|
||||
|
||||
if ($mobile == '0') {
|
||||
$filter['ship_mobile'] = $order['ship_mobile'];
|
||||
$filter['no_encrypt'] = true;
|
||||
@@ -909,13 +882,11 @@ class omeauto_auto_combine
|
||||
|
||||
private function _getCombineConf(&$combine_member_id, &$combine_shop_id)
|
||||
{
|
||||
|
||||
if (strval(app::get('ome')->getConf('ome.combine.member_id')) == '0') {
|
||||
|
||||
$combine_member_id = false;
|
||||
}
|
||||
|
||||
if (strval(app::get('ome')->getConf('ome.combine.shop_id')) == '0') {
|
||||
|
||||
$combine_shop_id = false;
|
||||
}
|
||||
}
|
||||
@@ -928,13 +899,16 @@ class omeauto_auto_combine
|
||||
*/
|
||||
public function fetchCombineOrder($order)
|
||||
{
|
||||
|
||||
//初始化变量
|
||||
$ids = array();
|
||||
$orders = array();
|
||||
$combine_member_id = true;
|
||||
$combine_shop_id = true;
|
||||
|
||||
|
||||
// 是否支持手工合单(On:开启,Off:关闭)
|
||||
//@todo:手工审单界面才会有此字段;
|
||||
$is_manual_merge = isset($order['is_manual_merge']) ? $order['is_manual_merge'] : null;
|
||||
|
||||
//统一查询收获相关信息,以免抛进来的不一致
|
||||
$order = app::get(self::__ORDER_APP)->model('orders')->getList('*', array('order_id' => $order['order_id']));
|
||||
$order = $order[0];
|
||||
@@ -943,10 +917,13 @@ class omeauto_auto_combine
|
||||
|
||||
//新增合单逻辑
|
||||
$this->_getCombineConf($combine_member_id, $combine_shop_id);
|
||||
|
||||
|
||||
//基础过滤条件[增加部分发货、部分退货 可继续审单
|
||||
$filter = array('ship_status' => array(0, 2, 3), 'process_status' => array('unconfirmed', 'confirmed', 'splitting'), 'status' => 'active', 'order_bn|noequal' => '0', 'is_cod' => $order['is_cod']);
|
||||
|
||||
|
||||
// 过滤不允许审核的订单
|
||||
$filter['is_not_combine'] = 0;
|
||||
|
||||
if ($order['shop_type'] == 'shopex_b2b') {
|
||||
//分销单,对支持跨店合的参数无视,直接内置规则处理
|
||||
if ($combine_member_id) {
|
||||
@@ -972,7 +949,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
} else if ($order['shop_type'] == 'dangdang' && $order['is_cod'] == 'true') {
|
||||
//当当,且是货到付款不合并
|
||||
//当当,且是货到付款不合并
|
||||
$filter['order_id'] = $order['order_id'];
|
||||
} else if (($order['shop_type'] == 'amazon') && $order['self_delivery'] == 'false') {
|
||||
//如果店铺类型是亚马逊,且不是自发货的不合并
|
||||
@@ -982,7 +959,6 @@ class omeauto_auto_combine
|
||||
$filter['order_id'] = $order['order_id'];
|
||||
} else if ($order['shop_type'] == 'taobao' && $order['order_source'] == 'tbdx') {
|
||||
//淘宝代销订单不合并 823修改淘代销走B2B逻辑
|
||||
//$filter['order_id'] = $order['order_id'];
|
||||
if ($combine_member_id) {
|
||||
//需判断同一用户,因分销没有实际客户信息,以无用户信息方式处理
|
||||
if (empty($order['member_id'])) {
|
||||
@@ -1027,7 +1003,7 @@ class omeauto_auto_combine
|
||||
//判定地址
|
||||
$filter = array_merge($filter, $this->_getAddrFilter($order));
|
||||
}
|
||||
|
||||
|
||||
if ($combine_shop_id) {
|
||||
$filter['shop_id'] = $order['shop_id'];
|
||||
}
|
||||
@@ -1059,11 +1035,14 @@ class omeauto_auto_combine
|
||||
}elseif($order['betc_id'] && $order['cos_id']){
|
||||
//分销一件代发订单,不允许合单
|
||||
$filter['order_id'] = $order['order_id'];
|
||||
}elseif($is_manual_merge == 'Off'){
|
||||
// 不允许手工合单(配置项:系统设置--》订单规则--》支持手工合单)
|
||||
$filter['order_id'] = $order['order_id'];
|
||||
}
|
||||
|
||||
//获取相关订单
|
||||
$row = app::get(self::__ORDER_APP)->model('orders')->getList('*', $filter);
|
||||
|
||||
|
||||
if (!empty($order['member_id'])) {
|
||||
if ($order['shop_type'] == 'shopex_b2b') {
|
||||
$tmp = array();
|
||||
@@ -1083,10 +1062,16 @@ class omeauto_auto_combine
|
||||
} elseif ($order['shop_type'] == 'jd' && kernel::single('ome_bill_label')->getBillLabelInfo($order['order_id'], 'order', kernel::single('ome_bill_label')->isSomsGxd())) {
|
||||
// 京东厂直 工小达 未接合单
|
||||
$tmp = array();
|
||||
} elseif($is_manual_merge == 'Off'){
|
||||
// 人工审单界面:不允许手工合单
|
||||
$tmp = array();
|
||||
} else {
|
||||
#拆单_增加确认状态('splitting')与发货状态(ship_status=2)部分发货条件
|
||||
// 拆单_增加确认状态('splitting')与发货状态(ship_status=2)部分发货条件
|
||||
$tmp_filter = array('member_id' => $order['member_id'], 'shop_id' => $order['shop_id'], 'status' => 'active', 'process_status' => array('unconfirmed', 'confirmed', 'splitting'), 'ship_status' => array(0, 2), 'f_ship_status' => '0', 'order_bn|noequal' => '0', 'is_cod' => $order['is_cod']);
|
||||
|
||||
|
||||
// 过滤不允许审核的订单
|
||||
$tmp_filter['is_not_combine'] = 0;
|
||||
|
||||
$tmp = app::get(self::__ORDER_APP)->model('orders')->getList('*', $tmp_filter);
|
||||
|
||||
$row = array_merge($row, $tmp);
|
||||
@@ -1148,15 +1133,20 @@ class omeauto_auto_combine
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成发货单
|
||||
*
|
||||
* @param Array $orders 订单数组
|
||||
* @return Boolean
|
||||
* @param $splitting_product 拆分的商品列表
|
||||
* @param $orderIds
|
||||
* @param $consignee
|
||||
* @param $corpId
|
||||
* @param $splitting_product
|
||||
* @param $errmsg
|
||||
* @param $split_auto
|
||||
* @param $extendInfo 扩展信息:例如指定发货单号['delivery_bn'=>'****']
|
||||
* @return bool|void
|
||||
*/
|
||||
public function mkDelivery($orderIds, $consignee, $corpId, $splitting_product = array(), &$errmsg, $split_auto = array())
|
||||
public function mkDelivery($orderIds, $consignee, $corpId, $splitting_product = array(), &$errmsg=null, $split_auto = array(), $extendInfo=array())
|
||||
{
|
||||
$orderIds = is_array($orderIds) ? $orderIds : [$orderIds];
|
||||
if($corpId == 'auto') {
|
||||
@@ -1164,8 +1154,14 @@ class omeauto_auto_combine
|
||||
} else {
|
||||
$corp = app::get('ome')->model('dly_corp')->dump($corpId, 'corp_id, name, type, is_cod, weight');
|
||||
}
|
||||
$rows = app::get(self::__ORDER_APP)->model('orders')->getList('*', array('order_id' => $orderIds));
|
||||
|
||||
|
||||
// orders
|
||||
$rows = app::get(self::__ORDER_APP)->model('orders')->getList('*', array('order_id'=>$orderIds, 'is_not_combine'=>0));
|
||||
if(empty($rows)){
|
||||
$errmsg = '没有可生成发货单的订单!';
|
||||
return false;
|
||||
}
|
||||
|
||||
$shop_group = array();
|
||||
$createway_group = array();
|
||||
foreach ($rows as $order) {
|
||||
@@ -1183,6 +1179,7 @@ class omeauto_auto_combine
|
||||
$extends[$ev['order_id']] = $ev;
|
||||
}
|
||||
}
|
||||
|
||||
$is_check_channel = false;
|
||||
foreach ($rows as $order) {
|
||||
// 验证发货数据
|
||||
@@ -1217,6 +1214,7 @@ class omeauto_auto_combine
|
||||
$errmsg = '部分支付不可以审单';
|
||||
return false;
|
||||
}
|
||||
|
||||
$is_part_split = false;
|
||||
if($order['process_status'] == 'splitting') $is_part_split = true;
|
||||
|
||||
@@ -1265,17 +1263,15 @@ class omeauto_auto_combine
|
||||
|
||||
// 判读是否是指定仓
|
||||
if (kernel::single('ome_order_bool_type')->isJDLVMI($order['order_bool_type']) ) {
|
||||
|
||||
|
||||
if(empty($consignee['waybillCode']) || !isset($consignee['waybillCode'])){
|
||||
$consignee['waybillCode'] = $extends[$order['order_id']]['platform_logi_no'];
|
||||
}
|
||||
// // 不允许合单
|
||||
|
||||
// 不允许合单
|
||||
if (count($rows) >= 2) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$store_code = app::get('ome')->model('order_objects')->db_dump(array ('order_id' => $order['order_id']), 'store_code');
|
||||
|
||||
if ($store_code['store_code']) {
|
||||
@@ -1291,7 +1287,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// order_objects
|
||||
$objects = app::get(self::__ORDER_APP)->model('order_objects')->getList('*', array('order_id' => $orderIds, 'is_sh_ship' => 'false'));
|
||||
foreach ($objects as $object) {
|
||||
$object['addon'] = @json_decode($object['addon'], 1);
|
||||
@@ -1316,8 +1312,9 @@ class omeauto_auto_combine
|
||||
if ($type_filter) {
|
||||
$filter_sql[] = '(' . implode(' OR ', $type_filter) . ')'; //过滤删除的商品
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// filter
|
||||
$filter = array(
|
||||
'order_id' => $orderIds,
|
||||
'obj_id' => array_column($objects, 'obj_id'),
|
||||
@@ -1342,17 +1339,17 @@ class omeauto_auto_combine
|
||||
//重组数据
|
||||
$orderSplitLib = kernel::single('ome_order_split');
|
||||
$orders = $orderSplitLib->format_mkDelivery($orders, $tmp_objects, $items, $splitting_product);
|
||||
|
||||
|
||||
// 过滤掉没有明细的订单
|
||||
foreach ($orders as $order_id => $order) {
|
||||
foreach ($order['objects'] as $ok => $object) {
|
||||
if (empty($object['items'])) {
|
||||
unset($orders[$order_id]['objects'][$ok]);
|
||||
} else {
|
||||
#nums变成可拆分数量 split_num需要重置为0
|
||||
// nums变成可拆分数量 split_num需要重置为0
|
||||
foreach ($object['items'] as $ik => $iv) {
|
||||
$orders[$order_id]['objects'][$ok]['items'][$ik]['split_num'] = 0;
|
||||
//震坤行不支持按行拆分
|
||||
// 震坤行不支持按行拆分
|
||||
if ($rows[0]['shop_type'] == 'zkh') {
|
||||
if ($iv['nums'] > 0 && $iv['original_num'] != $iv['nums']) {
|
||||
$errmsg = '震坤行订单不支持按数量拆分订单!';
|
||||
@@ -1368,11 +1365,12 @@ class omeauto_auto_combine
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($orders[$order_id]['objects'])) {
|
||||
unset($orders[$order_id]);
|
||||
}
|
||||
|
||||
if($orders[$order_id]) {
|
||||
list($rs, $rsData) = kernel::single('ome_order_refund')->checkRefundStatus($orders[$order_id]);
|
||||
if($rs) {
|
||||
@@ -1381,6 +1379,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($rows);
|
||||
|
||||
//没有可操作的有效订单(例如:订单没有商品明细)
|
||||
@@ -1403,23 +1402,28 @@ class omeauto_auto_combine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list($rs, $rsData) = kernel::single('material_basic_material_stock_freeze')->deleteOrderBranchFreeze(array_column($orders, 'order_id'));
|
||||
if(!$rs) {
|
||||
$errmsg = '错误:'.$rsData['msg'];
|
||||
return false;
|
||||
}
|
||||
|
||||
// canMkDelivery
|
||||
$group = new omeauto_auto_group_item($orders);
|
||||
|
||||
if ($group->canMkDelivery()) {
|
||||
if (!empty($corp)) {
|
||||
$branchId = $consignee['branch_id'];
|
||||
#菜鸟的智选物流,会返回物流单号
|
||||
|
||||
// 菜鸟的智选物流,会返回物流单号
|
||||
$waybill_arr = explode(',', $consignee['waybillCode']);
|
||||
$group->setWaybillCode($waybill_arr[0]);
|
||||
$group->setSubWaybillCode(array_slice($waybill_arr, 1));
|
||||
|
||||
unset($consignee['branch_id'], $consignee['waybillCode']);
|
||||
|
||||
$errmsg = '库存不足,生成发货单失败';
|
||||
|
||||
|
||||
foreach ($orders as $o_k => $o_v) {
|
||||
if ($o_v['shop_type'] == 'kuaishou') {
|
||||
kernel::single('omeauto_auto_plugin_checksplitgift')->process($group);
|
||||
@@ -1451,9 +1455,18 @@ class omeauto_auto_combine
|
||||
} else {
|
||||
$group->setBranchId($branchId);
|
||||
$group->setDlyCorp($corp);
|
||||
|
||||
// 指定的发货单号
|
||||
$group->setAssignDeliveryBn($extendInfo);
|
||||
|
||||
// 设置发货单扩展信息
|
||||
$group->setDeliveryExtendInfo($extendInfo);
|
||||
|
||||
// 生成发货单位
|
||||
$rs = $group->mkDelivery($consignee);
|
||||
}
|
||||
}
|
||||
|
||||
if ($rs['rsp'] == 'fail') {
|
||||
$errmsg = $rs['msg'] ? $rs['msg'] : '审单操作失败:'.$errmsg;
|
||||
return false;
|
||||
@@ -1574,9 +1587,6 @@ class omeauto_auto_combine
|
||||
*/
|
||||
public function getCombineShopMemberCount($orders)
|
||||
{
|
||||
/*
|
||||
*新增合单逻辑
|
||||
*/
|
||||
$combine_member_id = true;
|
||||
$combine_shop_id = true;
|
||||
$this->_getCombineConf($combine_member_id, $combine_shop_id);
|
||||
@@ -1614,7 +1624,6 @@ class omeauto_auto_combine
|
||||
$filter['order_id'] = $orders['order_id'];
|
||||
} else if ($orders['shop_type'] == 'taobao' && $orders['order_source'] == 'tbdx') {
|
||||
//823修改淘分销走b2b流程
|
||||
//$filter['order_id'] = $orders['order_id'];
|
||||
if ($combine_member_id) {
|
||||
//需判断同一用户,因分销没有实际客户信息,以无用户信息方式处理
|
||||
if (empty($orders['member_id'])) {
|
||||
@@ -1657,6 +1666,7 @@ class omeauto_auto_combine
|
||||
}
|
||||
$filter['filter_sql'] = "(shop_type IS NOT NULL AND order_source<>'tbdx' and shop_type<>'shopex_b2b' and (is_cod='false' or (shop_type<>'dangdang' AND is_cod='true')) and (self_delivery='true' or (shop_type<>'amazon' and self_delivery='false')) OR shop_type IS NULL)";
|
||||
}
|
||||
|
||||
if (!isset($orders['shipping_name']) && !isset($orders['store_code']) && !isset($orders['cpup_service'])) {
|
||||
$row = app::get(self::__ORDER_APP)->model('orders')->count($filter);
|
||||
}else{
|
||||
@@ -1695,7 +1705,6 @@ class omeauto_auto_combine
|
||||
}
|
||||
|
||||
//group
|
||||
$retOrderGroup = array();
|
||||
foreach ($orderGroup as $key => $group)
|
||||
{
|
||||
if(count($group['orders']) <= $combine_merge_limit) {
|
||||
@@ -1724,7 +1733,6 @@ class omeauto_auto_combine
|
||||
|
||||
$groupNum++;
|
||||
|
||||
//$newGroupKey = $key . $groupPage;
|
||||
$newGroupKey = sprintf('%s||%s', $combine_hash.'-'.$groupPage, $combine_idx . $groupPage);
|
||||
|
||||
$orderGroup[$newGroupKey]['orders'][$order_key] = $order_id;
|
||||
@@ -1734,6 +1742,4 @@ class omeauto_auto_combine
|
||||
|
||||
return $orderGroup;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -161,30 +161,87 @@ class omeauto_auto_group {
|
||||
*/
|
||||
public function process($inletClass) {
|
||||
|
||||
// 如果没有订单项,直接返回空结果
|
||||
if (empty($this->items)) {
|
||||
return array('total' => 0, 'succ' => 0, 'fail' => 0);
|
||||
}
|
||||
|
||||
$confirmRoles = $this->getRoles();
|
||||
$confirmRoles['inlet_class'] = $inletClass;
|
||||
$plugins = $this->getPluginNames($inletClass);
|
||||
|
||||
// 获取第一个订单号用于记录
|
||||
$originalBn = '';
|
||||
if (!empty($this->items)) {
|
||||
$orders = $this->items[0]->getOrders();
|
||||
$firstOrder = current($orders);
|
||||
$originalBn = $firstOrder['order_bn'] ?? '';
|
||||
}
|
||||
|
||||
// 开始性能监控
|
||||
ome_api_log::record_start('订单审核', $originalBn, 'omeauto_auto_group');
|
||||
|
||||
$pluginTimings = array();
|
||||
|
||||
foreach ($plugins as $plugName) {
|
||||
|
||||
$plugObj = $this->initPlugin($plugName);
|
||||
if (is_object($plugObj)) {
|
||||
foreach ((array) $this->items as $key => $item) {
|
||||
|
||||
$plugObj->process($this->items[$key], $confirmRoles);
|
||||
// 记录单个插件执行开始时间
|
||||
$pluginStartTime = microtime(true);
|
||||
|
||||
$pluginResult = $plugObj->process($this->items[$key], $confirmRoles);
|
||||
|
||||
// 如果插件返回了性能数据,记录到性能日志
|
||||
if (is_array($pluginResult) && isset($pluginResult['execution_time'])) {
|
||||
ome_api_log::add_message('plugin', $plugName, $pluginResult['execution_time'], $pluginResult);
|
||||
$pluginExecutionTime = $pluginResult['execution_time'];
|
||||
} else {
|
||||
// 否则使用外层计算的时间
|
||||
$pluginExecutionTime = microtime(true) - $pluginStartTime;
|
||||
ome_api_log::add_message('plugin', $plugName, $pluginExecutionTime, array('total_orders' => count($this->items)));
|
||||
}
|
||||
|
||||
// 累加插件执行时间
|
||||
if (!isset($pluginTimings[$plugName])) {
|
||||
$pluginTimings[$plugName] = 0;
|
||||
}
|
||||
$pluginTimings[$plugName] += $pluginExecutionTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array('total' => 0, 'succ' => 0, 'fail' => 0);
|
||||
|
||||
// 记录订单组处理开始时间
|
||||
$groupProcessStart = microtime(true);
|
||||
|
||||
foreach ((array) $this->items as $key => $group) {
|
||||
$result['total'] += $group->orderNums;
|
||||
if ($group->process($confirmRoles)) {
|
||||
|
||||
$groupResult = $group->process($confirmRoles);
|
||||
|
||||
if ($groupResult) {
|
||||
$result['succ'] += $group->orderNums;
|
||||
} else {
|
||||
$result['fail'] += $group->orderNums;
|
||||
}
|
||||
}
|
||||
|
||||
// 计算订单组处理时间
|
||||
$groupProcessTime = microtime(true) - $groupProcessStart;
|
||||
|
||||
// 记录订单组性能数据
|
||||
ome_api_log::add_message('group', 'order_group', $groupProcessTime, array(
|
||||
'total_orders' => $result['total'],
|
||||
'success_orders' => $result['succ'],
|
||||
'failed_orders' => $result['fail']
|
||||
));
|
||||
|
||||
// 结束性能监控
|
||||
ome_api_log::record_end();
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -211,6 +268,7 @@ class omeauto_auto_group {
|
||||
return self::$_plugObjects[$fix];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $inletClass 入口类区分
|
||||
* @return Array
|
||||
@@ -377,4 +435,5 @@ class omeauto_auto_group {
|
||||
$this->filter = array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -66,7 +66,14 @@ class omeauto_auto_group_item
|
||||
private $status = array('opt' => 0, 'log' => array());
|
||||
|
||||
private $orderWeight;
|
||||
|
||||
|
||||
/**
|
||||
* 发货单扩展信息
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_deliveryExtendInfo = array();
|
||||
|
||||
/**
|
||||
* 符合自动仓库规则
|
||||
*
|
||||
@@ -490,7 +497,13 @@ class omeauto_auto_group_item
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if($status == omeauto_auto_const::__STORE_CODE) {
|
||||
$branch_id = 0;
|
||||
if(is_array($this->getBranchId())) {
|
||||
$branch_id = current($this->getBranchId());
|
||||
}
|
||||
kernel::single('ome_order_store')->lackNotify($this->orders[$oId], $branch_id);
|
||||
}
|
||||
if (isset($this->orderStatus[$oId])) {
|
||||
|
||||
$this->orderStatus[$oId] = $this->orderStatus[$oId] | $status;
|
||||
@@ -536,7 +549,57 @@ class omeauto_auto_group_item
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置指定的发货单号
|
||||
*
|
||||
* @param Integer $branchId
|
||||
* @return void
|
||||
*/
|
||||
public function setAssignDeliveryBn($extendInfo)
|
||||
{
|
||||
if(isset($extendInfo['delivery_bn']) && $extendInfo['delivery_bn']){
|
||||
$this->status['extendInfo']['delivery_bn'] = $extendInfo['delivery_bn'];
|
||||
}else{
|
||||
$this->status['extendInfo']['delivery_bn'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定的发货单号
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public function getAssignDeliveryBn()
|
||||
{
|
||||
return $this->status['extendInfo']['delivery_bn'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置发货单扩展信息
|
||||
*
|
||||
* @param $extendInfo
|
||||
* @return void
|
||||
*/
|
||||
public function setDeliveryExtendInfo($extendInfo)
|
||||
{
|
||||
if($extendInfo){
|
||||
$this->_deliveryExtendInfo = $extendInfo;
|
||||
}else{
|
||||
$this->_deliveryExtendInfo = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发货单扩展信息
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDeliveryExtendInfo()
|
||||
{
|
||||
return $this->_deliveryExtendInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查订单组内容是否有效
|
||||
*
|
||||
@@ -655,22 +718,46 @@ class omeauto_auto_group_item
|
||||
*/
|
||||
public function process($config)
|
||||
{
|
||||
|
||||
if ($this->vaild($config)) {
|
||||
$bgData = $this->getBranchGroup();
|
||||
if($this->splitNotDly) {
|
||||
$nodeStart = microtime(true);
|
||||
foreach ($this->orders as $order) {
|
||||
$return = $this->_processSplitNotDly($config, $order);
|
||||
}
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
$orderIds = array_column($this->orders, 'order_id');
|
||||
$orderBns = array_column($this->orders, 'order_bn');
|
||||
ome_api_log::add_message('node', 'split_not_dly', $nodeTime, array(
|
||||
'order_ids' => $orderIds,
|
||||
'order_bns' => $orderBns
|
||||
));
|
||||
} elseif ($bgData) {
|
||||
$nodeStart = microtime(true);
|
||||
$return = $this->_processBranchGroupConfirm($config);
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
$orderIds = array_column($this->orders, 'order_id');
|
||||
$orderBns = array_column($this->orders, 'order_bn');
|
||||
ome_api_log::add_message('node', 'branch_group_confirm', $nodeTime, array(
|
||||
'order_ids' => $orderIds,
|
||||
'order_bns' => $orderBns
|
||||
));
|
||||
} else {
|
||||
$nodeStart = microtime(true);
|
||||
$return = $this->_processConfirm($config);
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
$orderIds = array_column($this->orders, 'order_id');
|
||||
$orderBns = array_column($this->orders, 'order_bn');
|
||||
ome_api_log::add_message('node', 'process_confirm', $nodeTime, array(
|
||||
'order_ids' => $orderIds,
|
||||
'order_bns' => $orderBns
|
||||
));
|
||||
}
|
||||
|
||||
//虚拟商品拆单后自动完成发货
|
||||
$auto_dly = $this->isAutoDelivery();
|
||||
if($return && $auto_dly){
|
||||
$nodeStart = microtime(true);
|
||||
$queueObj = app::get('base')->model('queue');
|
||||
|
||||
foreach ($this->orders as $order)
|
||||
@@ -691,21 +778,53 @@ class omeauto_auto_group_item
|
||||
);
|
||||
$queueObj->save($queueData);
|
||||
}
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
$orderIds = array_column($this->orders, 'order_id');
|
||||
$orderBns = array_column($this->orders, 'order_bn');
|
||||
ome_api_log::add_message('node', 'auto_delivery_queue', $nodeTime, array(
|
||||
'order_ids' => $orderIds,
|
||||
'order_bns' => $orderBns
|
||||
));
|
||||
}
|
||||
|
||||
} else {
|
||||
$nodeStart = microtime(true);
|
||||
$return = $this->_processDispatch($config);
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
$orderIds = array_column($this->orders, 'order_id');
|
||||
$orderBns = array_column($this->orders, 'order_bn');
|
||||
ome_api_log::add_message('node', 'process_dispatch', $nodeTime, array(
|
||||
'order_ids' => $orderIds,
|
||||
'order_bns' => $orderBns
|
||||
));
|
||||
}
|
||||
|
||||
// 合单处理
|
||||
if ($this->combineOrderId) {
|
||||
$nodeStart = microtime(true);
|
||||
kernel::single('ome_batch_log')->combineAgain($this->combineOrderId);
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
ome_api_log::add_message('node', 'combine_again', $nodeTime, array(
|
||||
'order_ids' => $this->combineOrderId
|
||||
));
|
||||
}
|
||||
|
||||
// 拆单处理
|
||||
if ($this->splitOrderId) {
|
||||
$nodeStart = microtime(true);
|
||||
kernel::single('ome_batch_log')->split($this->splitOrderId);
|
||||
$nodeTime = microtime(true) - $nodeStart;
|
||||
ome_api_log::add_message('node', 'split_log', $nodeTime, array(
|
||||
'order_ids' => $this->splitOrderId
|
||||
));
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
private function _processSplitNotDly($config, $order) {
|
||||
$split_status = '';
|
||||
list($rs, $msg) = kernel::single('ome_order_platform_split')->dealOrderObjects($order, $split_status);
|
||||
if(!$rs) {
|
||||
$logMsg = sprintf('订单拆分失败:%s,审单规则:%s(%s),仓库规则:%s(%s)', $msg, $config['confirmName'], $config['confirmId'], (string) $this->_autobranch['name'], $this->_autobranch['tid'] ? $this->_autobranch['tid'] : '-');
|
||||
@@ -827,7 +946,15 @@ class omeauto_auto_group_item
|
||||
$deliveryInfo['delivery_sub_waybillCode'] = $subWaybillCode;
|
||||
unset($deliveryInfo['order_items']);
|
||||
$split_status = '';
|
||||
$addDeliveryStart = microtime(true);
|
||||
$result = $deliveryObj->addDelivery($orderId, $deliveryInfo, array(), $order_items, $split_status);
|
||||
$addDeliveryTime = microtime(true) - $addDeliveryStart;
|
||||
|
||||
// 记录addDelivery性能数据
|
||||
ome_api_log::add_message('node', 'addDelivery', $addDeliveryTime, array(
|
||||
'order_id' => $orderId,
|
||||
'delivery_id' => $result['data'] ?? null
|
||||
));
|
||||
if ($result['rsp'] == 'succ') {
|
||||
|
||||
$orderBranch[$orderId] = $deliveryInfo['branch_id'];
|
||||
@@ -878,7 +1005,15 @@ class omeauto_auto_group_item
|
||||
kernel::single('ome_o2o_performance_orders')->updateProcessStatus($orderId, 'confirm');
|
||||
}
|
||||
// 全链路审单/通知配货回流
|
||||
$messageStartTime = microtime(true);
|
||||
kernel::single('ome_event_trigger_shop_order')->order_message_produce(array($orderId),['check','to_wms']);
|
||||
$messageTime = microtime(true) - $messageStartTime;
|
||||
|
||||
// 记录全链路消息生产性能数据
|
||||
ome_api_log::add_message('message', 'order_message_produce', $messageTime, array(
|
||||
'order_id' => $orderId,
|
||||
'message_types' => 'check,to_wms'
|
||||
));
|
||||
} elseif ($result['rsp'] == 'fail') {
|
||||
if (!in_array($result['msg'], array('明细已经生成发货单'))) {
|
||||
if ($this->isProcessSplit) {
|
||||
@@ -917,6 +1052,7 @@ class omeauto_auto_group_item
|
||||
$waybillCode = $this->getWaybillCode();
|
||||
|
||||
//合并发货单
|
||||
$err = '';
|
||||
if (!empty($ids) && count($ids) > 1 && $_isCombine) {
|
||||
//多个订单合并审核,合并发货单
|
||||
$newdly_id = $deliveryObj->merge($ids, array('logi_no' => $this->getWaybillCode(), 'logi_id' => $this->status['change']['dlyCorp']['corp_id'], 'logi_name' => $this->status['change']['dlyCorp']['name']));
|
||||
@@ -925,15 +1061,56 @@ class omeauto_auto_group_item
|
||||
foreach ($orderIds as $order_id) {
|
||||
kernel::single('ome_bill_label')->markBillLabel($order_id, '', 'SOMS_COMBINE_ORDER', 'order', $err, 0);
|
||||
}
|
||||
// 发货单创建完成后的service扩展点
|
||||
$serviceStart = microtime(true);
|
||||
foreach(kernel::servicelist('omeauto.service.group.item.confirm.after') as $serviceName => $object) {
|
||||
$individualServiceStart = microtime(true);
|
||||
if(method_exists($object, 'afterCreateDelivery')) {
|
||||
$object->afterCreateDelivery($newdly_id);
|
||||
}
|
||||
$serviceTime = microtime(true) - $individualServiceStart;
|
||||
|
||||
// 记录每个service的性能数据
|
||||
ome_api_log::add_message('service', $serviceName, $serviceTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
}
|
||||
//发货单通知单推送仓库
|
||||
$wmsStart = microtime(true);
|
||||
ome_delivery_notice::create($newdly_id);
|
||||
$wmsTime = microtime(true) - $wmsStart;
|
||||
|
||||
// 记录WMS通知性能数据
|
||||
ome_api_log::add_message('node', 'wms_notification', $wmsTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
if ($waybillCode) {
|
||||
$deliveryObj->db->exec("UPDATE sdb_ome_delivery SET logi_no='" . $waybillCode . "' WHERE delivery_id=" . $newdly_id);
|
||||
}
|
||||
} else {
|
||||
//发货单通知单推送仓库
|
||||
foreach ($ids as $newdly_id) {
|
||||
// 发货单创建完成后的service扩展点
|
||||
foreach(kernel::servicelist('omeauto.service.group.item.confirm.after') as $serviceName => $object) {
|
||||
$individualServiceStart = microtime(true);
|
||||
if(method_exists($object, 'afterCreateDelivery')) {
|
||||
$object->afterCreateDelivery($newdly_id);
|
||||
}
|
||||
$serviceTime = microtime(true) - $individualServiceStart;
|
||||
|
||||
// 记录每个service的性能数据
|
||||
ome_api_log::add_message('service', $serviceName, $serviceTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
}
|
||||
$wmsStart = microtime(true);
|
||||
ome_delivery_notice::create($newdly_id);
|
||||
$wmsTime = microtime(true) - $wmsStart;
|
||||
|
||||
// 记录WMS通知性能数据
|
||||
ome_api_log::add_message('node', 'wms_notification', $wmsTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
if ($waybillCode) {
|
||||
$deliveryObj->db->exec("UPDATE sdb_ome_delivery SET logi_no='" . $waybillCode . "' WHERE delivery_id=" . $newdly_id);
|
||||
}
|
||||
@@ -1262,6 +1439,7 @@ class omeauto_auto_group_item
|
||||
$orderObj = app::get('ome')->model("orders");
|
||||
$opInfo = kernel::single('ome_func')->getDesktopUser();
|
||||
$user_id = $opInfo['op_id'];
|
||||
|
||||
|
||||
if($this->splitNotDly) {
|
||||
foreach ($this->orders as $order) {
|
||||
@@ -1286,18 +1464,20 @@ class omeauto_auto_group_item
|
||||
}
|
||||
return $returnTxt;
|
||||
}
|
||||
|
||||
if (isset($consignee['memo'])) {
|
||||
$remark = $consignee['memo'];
|
||||
unset($consignee['memo']);
|
||||
} else {
|
||||
|
||||
$remark = '';
|
||||
}
|
||||
|
||||
$oper_source = '';
|
||||
if (isset($consignee['oper_source'])) {
|
||||
$oper_source = $consignee['oper_source'];
|
||||
unset($consignee['oper_source']);
|
||||
}
|
||||
|
||||
$deliveryInfos = $this->fetchDeliveryFormat($consignee);
|
||||
|
||||
$ids = array();
|
||||
@@ -1305,9 +1485,9 @@ class omeauto_auto_group_item
|
||||
$branchLib = kernel::single('ome_branch');
|
||||
|
||||
//此处要增加判断
|
||||
|
||||
$deliveryid_nums = count($deliveryInfos);
|
||||
#本次发货单数量,如果大于1,就是属于合单的,合单的发货单,不能传物流单号,因为物流单号表字段唯一,会导致生成单据只能保存进一个子发货单
|
||||
|
||||
// 本次发货单数量,如果大于1,就是属于合单的,合单的发货单,不能传物流单号,因为物流单号表字段唯一,会导致生成单据只能保存进一个子发货单
|
||||
if ($deliveryid_nums > 1) {
|
||||
$delivery_waybillCode = null;
|
||||
$deliverySubWaybillCode = null;
|
||||
@@ -1315,6 +1495,23 @@ class omeauto_auto_group_item
|
||||
$delivery_waybillCode = $this->getWaybillCode();
|
||||
$deliverySubWaybillCode = $this->getSubWaybillCode();
|
||||
}
|
||||
|
||||
// 是否指定发货单号
|
||||
$assign_delivery_bn = $this->getAssignDeliveryBn();
|
||||
if($assign_delivery_bn){
|
||||
if(count($deliveryInfos) > 1){
|
||||
$error_msg = '本次会生成多个发货单,不允许使用指定发货单号';
|
||||
return ['rsp'=>'fail', 'msg'=>$error_msg];
|
||||
}
|
||||
|
||||
// 检查指定发货单号是否已经存在
|
||||
$deliveryRow = $deliveryObj->db_dump(array('delivery_bn'=>$assign_delivery_bn), 'delivery_id, delivery_bn');
|
||||
if($deliveryRow){
|
||||
$error_msg = '指定发货单号:'. $assign_delivery_bn .'已经存在,请检查';
|
||||
return ['rsp'=>'fail', 'msg'=>$error_msg];
|
||||
}
|
||||
}
|
||||
|
||||
$orderBranch = [];
|
||||
$orderIds = [];
|
||||
foreach ($deliveryInfos as $orderId => $deliveryInfo) {
|
||||
@@ -1324,8 +1521,28 @@ class omeauto_auto_group_item
|
||||
$deliveryInfo['delivery_sub_waybillCode'] = $deliverySubWaybillCode;
|
||||
$order_items = $deliveryInfo['order_items'];
|
||||
unset($deliveryInfo['order_items']);
|
||||
|
||||
$result = $deliveryObj->addDelivery($orderId, $deliveryInfo, array(), $order_items, $split_status);
|
||||
|
||||
// 指定发货单号
|
||||
if($assign_delivery_bn && empty($deliveryInfo['delivery_bn'])){
|
||||
$deliveryInfo['delivery_bn'] = $assign_delivery_bn;
|
||||
}
|
||||
|
||||
// 是否补差价订单
|
||||
$is_diff_order = false;
|
||||
|
||||
// 发货单扩展信息
|
||||
$deliveryExtendInfo = $this->getDeliveryExtendInfo();
|
||||
|
||||
// 生成发货单
|
||||
$addDeliveryStart = microtime(true);
|
||||
$result = $deliveryObj->addDelivery($orderId, $deliveryInfo, array(), $order_items, $split_status, $is_diff_order, $deliveryExtendInfo);
|
||||
$addDeliveryTime = microtime(true) - $addDeliveryStart;
|
||||
|
||||
// 记录addDelivery性能数据
|
||||
ome_api_log::add_message('node', 'addDelivery', $addDeliveryTime, array(
|
||||
'order_id' => $orderId,
|
||||
'delivery_id' => $result['data'] ?? null
|
||||
));
|
||||
|
||||
if ($result['rsp'] == 'succ') {
|
||||
$delivery_id = $result['data'];
|
||||
@@ -1364,7 +1581,20 @@ class omeauto_auto_group_item
|
||||
kernel::single('ome_o2o_performance_orders')->updateProcessStatus($orderId, 'confirm');
|
||||
}
|
||||
// 全链路审单/通知配货回流
|
||||
$messageStartTime = microtime(true);
|
||||
kernel::single('ome_event_trigger_shop_order')->order_message_produce(array($orderId),['check','to_wms']);
|
||||
$messageTime = microtime(true) - $messageStartTime;
|
||||
|
||||
// 记录全链路消息生产性能数据
|
||||
ome_api_log::add_message('message', 'order_message_produce', $messageTime, array(
|
||||
'order_id' => $orderId,
|
||||
'message_types' => 'check,to_wms'
|
||||
));
|
||||
|
||||
// [更新]预约订单的确认状态
|
||||
$error_msg = '';
|
||||
kernel::single('ome_order_reservation')->operateReservationOrder($sdf, $error_msg);
|
||||
|
||||
} elseif ($result['rsp'] == 'fail') {
|
||||
$returnTxt = array('rsp' => 'fail', 'msg' => $result['msg']);
|
||||
}
|
||||
@@ -1378,8 +1608,11 @@ class omeauto_auto_group_item
|
||||
if ($dly_corp['type'] == 'DANGDANG' || $dly_corp['type'] == 'AMAZON' || $combine_select == '1') {
|
||||
$_isCombine = false;
|
||||
}
|
||||
|
||||
$waybillCode = $this->getWaybillCode();
|
||||
|
||||
//合并发货单
|
||||
$err = '';
|
||||
if (!empty($ids) && count($ids) > 1 && $_isCombine) {
|
||||
//多个订单合并审核,合并发货单
|
||||
$newdly_id = $deliveryObj->merge($ids, array('logi_no' => $this->getWaybillCode(), 'logi_id' => $this->status['change']['dlyCorp']['corp_id'], 'logi_name' => $this->status['change']['dlyCorp']['name'], 'memo' => $remark));
|
||||
@@ -1393,9 +1626,29 @@ class omeauto_auto_group_item
|
||||
foreach ($orderIds as $order_id) {
|
||||
kernel::single('ome_bill_label')->markBillLabel($order_id, '', 'SOMS_COMBINE_ORDER', 'order', $err, 0);
|
||||
}
|
||||
// 发货单创建完成后的service扩展点
|
||||
$serviceStart = microtime(true);
|
||||
foreach(kernel::servicelist('omeauto.service.group.item.confirm.after') as $serviceName => $object) {
|
||||
$individualServiceStart = microtime(true);
|
||||
if(method_exists($object, 'afterCreateDelivery')) {
|
||||
$object->afterCreateDelivery($newdly_id);
|
||||
}
|
||||
$serviceTime = microtime(true) - $individualServiceStart;
|
||||
|
||||
// 记录每个service的性能数据
|
||||
ome_api_log::add_message('service', $serviceName, $serviceTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
}
|
||||
//发货单通知单推送仓库
|
||||
$wmsStart = microtime(true);
|
||||
ome_delivery_notice::create($newdly_id);
|
||||
|
||||
$wmsTime = microtime(true) - $wmsStart;
|
||||
|
||||
// 记录WMS通知性能数据
|
||||
ome_api_log::add_message('node', 'wms_notification', $wmsTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
} else {
|
||||
//发货单通知单推送仓库
|
||||
foreach ($ids as $newdly_id) {
|
||||
@@ -1404,9 +1657,31 @@ class omeauto_auto_group_item
|
||||
$deliveryObj->db->exec("UPDATE sdb_ome_delivery SET logi_no='" . $waybillCode . "' WHERE delivery_id=" . $newdly_id);
|
||||
|
||||
}
|
||||
|
||||
// 发货单创建完成后的service扩展点
|
||||
foreach(kernel::servicelist('omeauto.service.group.item.confirm.after') as $serviceName => $object) {
|
||||
$individualServiceStart = microtime(true);
|
||||
if(method_exists($object, 'afterCreateDelivery')) {
|
||||
$object->afterCreateDelivery($newdly_id);
|
||||
}
|
||||
$serviceTime = microtime(true) - $individualServiceStart;
|
||||
|
||||
// 记录每个service的性能数据
|
||||
ome_api_log::add_message('service', $serviceName, $serviceTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
}
|
||||
$wmsStart = microtime(true);
|
||||
ome_delivery_notice::create($newdly_id);
|
||||
$wmsTime = microtime(true) - $wmsStart;
|
||||
|
||||
// 记录WMS通知性能数据
|
||||
ome_api_log::add_message('node', 'wms_notification', $wmsTime, array(
|
||||
'delivery_id' => $newdly_id
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// todo maxiaochen 得物品牌直发 请求接单接口,如果检测到有取消的发货单,则先调用发货仓修改接口
|
||||
$this->_dewu_afterAddDelivery($orderBranch);
|
||||
|
||||
|
||||
@@ -36,26 +36,55 @@ class omeauto_auto_plugin_split extends omeauto_auto_plugin_abstract implements
|
||||
*
|
||||
* @param omeauto_auto_group_item $group 要处理的订单组
|
||||
* @param array $confirmRoles autoconfirm中的config
|
||||
* @return void
|
||||
* @return array 性能数据
|
||||
*/
|
||||
public function process(&$group, &$confirmRoles=null)
|
||||
{
|
||||
$performanceData = array(
|
||||
'plugin_name' => $this->_getPlugName(),
|
||||
'start_time' => microtime(true),
|
||||
'end_time' => 0,
|
||||
'execution_time' => 0,
|
||||
'success' => true,
|
||||
'message' => '',
|
||||
'order_bns' => array(),
|
||||
'split_type' => '',
|
||||
'split_result' => array()
|
||||
);
|
||||
|
||||
// 获取第一个订单号
|
||||
$orders = $group->getOrders();
|
||||
$firstOrder = current($orders);
|
||||
$performanceData['order_bns'] = $firstOrder['order_bn'] ?? '';
|
||||
|
||||
$branchId = $group->getBranchId();
|
||||
|
||||
// 指定仓发货
|
||||
if ($branchId[0] == 'sys_appoint') {
|
||||
$group->setProcessSplit();
|
||||
$performanceData['split_type'] = 'branchappoint';
|
||||
$startTime = microtime(true);
|
||||
list($rs, $msg, $code) = kernel::single('omeauto_split_router', 'branchappoint')->splitOrder($group, '');
|
||||
|
||||
// 记录拆单结果
|
||||
$performanceData['split_result'] = array(
|
||||
'success' => $rs,
|
||||
'message' => $msg,
|
||||
'code' => $code ?? ''
|
||||
);
|
||||
|
||||
if ($code == 'no branch') {
|
||||
foreach ($group->getOrders() as $order) {
|
||||
$group->setOrderStatus($order['order_id'], $this->getMsgFlag());
|
||||
}
|
||||
|
||||
$this->writeFailLog($group->getOrders(), $msg, $startTime);
|
||||
$performanceData['success'] = false;
|
||||
$performanceData['message'] = $msg;
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
|
||||
$group->setStatus(omeauto_auto_group_item::__OPT_HOLD, $this->_getPlugName());
|
||||
return;
|
||||
$group->setStatus(omeauto_auto_group_item::__OPT_HOLD, $this->_getPlugName(), $msg);
|
||||
return $performanceData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +95,19 @@ class omeauto_auto_plugin_split extends omeauto_auto_plugin_abstract implements
|
||||
$isCtrlStore = kernel::single('ome_branch')->getBranchCtrlStore(reset($branchId));
|
||||
if ($isCtrlStore === false) {
|
||||
$group->setConfirmBranch(true);
|
||||
return;
|
||||
$performanceData['message'] = '仓库不管控库存,跳过拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
}
|
||||
|
||||
// 门店仓不跑拆单
|
||||
if ($group->isStoreBranch()) {
|
||||
return;
|
||||
$performanceData['message'] = '门店仓不跑拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
|
||||
//是否启动拆单
|
||||
@@ -80,22 +115,37 @@ class omeauto_auto_plugin_split extends omeauto_auto_plugin_abstract implements
|
||||
$split_seting = $orderSplitLib->get_delivery_seting();
|
||||
$split_model = $split_seting ? 2 : 0; //自由拆单方式split_model=2
|
||||
if (!$split_model) {
|
||||
return;
|
||||
$performanceData['message'] = '未启动拆单功能';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
|
||||
// 货到付款和门店自提/猫超的不拆单
|
||||
foreach ($group->getOrders() as $order) {
|
||||
if ($order['is_cod'] == 'true') {
|
||||
return;
|
||||
$performanceData['message'] = '货到付款订单不拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
if ($order['shipping'] == 'STORE_SELF_FETCH') {
|
||||
return;
|
||||
$performanceData['message'] = '门店自提订单不拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
if ($order['shop_type'] == "taobao" && $order['order_source'] == 'maochao') {
|
||||
return;
|
||||
$performanceData['message'] = '猫超订单不拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
if ($order['shop_type'] == "zkh") {
|
||||
return;
|
||||
$performanceData['message'] = 'ZKH订单不拆单';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +153,7 @@ class omeauto_auto_plugin_split extends omeauto_auto_plugin_abstract implements
|
||||
if ($split && $split['split_type']) {
|
||||
$splitType = $split['split_type'];
|
||||
$splitConfig = $split['split_config'];
|
||||
$performanceData['split_type'] = $splitType;
|
||||
|
||||
// 手工审单/自动审单标识
|
||||
$splitConfig['confirm_source'] = $confirmRoles['source'];
|
||||
@@ -111,53 +162,32 @@ class omeauto_auto_plugin_split extends omeauto_auto_plugin_abstract implements
|
||||
|
||||
//开始拆单
|
||||
$startTime = microtime(true);
|
||||
list($rs, $msg) = kernel::single('omeauto_split_router', $splitType)->splitOrder($group, $splitConfig);
|
||||
list($rs, $msg, $logResult) = kernel::single('omeauto_split_router', $splitType)->splitOrder($group, $splitConfig);
|
||||
|
||||
// 记录拆单结果
|
||||
$performanceData['split_result'] = array(
|
||||
'success' => $rs,
|
||||
'message' => $msg,
|
||||
'split_type' => $splitType,
|
||||
'log_result' => $logResult ?? null
|
||||
);
|
||||
|
||||
if (!$rs) {
|
||||
foreach ($group->getOrders() as $order) {
|
||||
$group->setOrderStatus($order['order_id'], $this->getMsgFlag());
|
||||
}
|
||||
$this->writeFailLog($group->getOrders(), $msg, $startTime);
|
||||
$group->setStatus(omeauto_auto_group_item::__OPT_HOLD, $this->_getPlugName());
|
||||
$performanceData['success'] = false;
|
||||
$performanceData['message'] = $msg;
|
||||
$group->setStatus(omeauto_auto_group_item::__OPT_HOLD, $this->_getPlugName(), $msg);
|
||||
}
|
||||
}
|
||||
|
||||
$performanceData['message'] = '拆单处理完成';
|
||||
$performanceData['end_time'] = microtime(true);
|
||||
$performanceData['execution_time'] = $performanceData['end_time'] - $performanceData['start_time'];
|
||||
return $performanceData;
|
||||
}
|
||||
|
||||
protected function writeFailLog($arrOrder, $msg, $startTime = null)
|
||||
{
|
||||
$orderBn = array();
|
||||
foreach ($arrOrder as $v) {
|
||||
$orderBn[] = $v['order_bn'];
|
||||
}
|
||||
$apilogModel = app::get('ome')->model('api_log');
|
||||
$log_id = $apilogModel->gen_id();
|
||||
$result = array();
|
||||
$result['msg'] = $msg;
|
||||
$result['order_bn'] = $orderBn;
|
||||
|
||||
$currentTime = microtime(true);
|
||||
$spendTime = $startTime ? ($currentTime - $startTime) : 0;
|
||||
|
||||
$logsdf = array(
|
||||
'log_id' => $log_id,
|
||||
'task_name' => '拆单结果',
|
||||
'status' => 'fail',
|
||||
'worker' => 'order.split',
|
||||
'params' => json_encode(array('order.split', array('arrorder' => $arrOrder))),
|
||||
'transfer' => '',
|
||||
'response' => json_encode($result),
|
||||
'msg' => $msg,
|
||||
'log_type' => '',
|
||||
'api_type' => 'response',
|
||||
'memo' => '',
|
||||
'original_bn' => $orderBn[0],
|
||||
'createtime' => $currentTime,
|
||||
'last_modified' => $currentTime,
|
||||
'msg_id' => '',
|
||||
'spendtime' => $spendTime,
|
||||
'url' => '',
|
||||
);
|
||||
$apilogModel->insert($logsdf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该插件名称
|
||||
|
||||
@@ -179,6 +179,10 @@ class omeauto_auto_plugin_store extends omeauto_auto_plugin_abstract implements
|
||||
$branchObj = app::get('ome')->model("branch");
|
||||
$basicMStockFreezeLib = kernel::single('material_basic_material_stock_freeze');
|
||||
$theSelectBranchId = array();
|
||||
|
||||
// 获取指定不需要管控库存的基础物料
|
||||
$notCtrlStoreBmList = kernel::single('material_basic_material')->getNotCtrlStoreProducts($groupStore['pids']);
|
||||
|
||||
//根据获取到的仓库来判断库存
|
||||
foreach ((array) $bids as $bkey => $bid ) {
|
||||
if(isset($tid)) {
|
||||
@@ -224,7 +228,14 @@ class omeauto_auto_plugin_store extends omeauto_auto_plugin_abstract implements
|
||||
|
||||
//检查订单组内的货品数量是否足够
|
||||
$allow = true;
|
||||
foreach ($groupStore['store'] as $pid => $nums) {
|
||||
foreach ($groupStore['store'] as $pid => $nums)
|
||||
{
|
||||
// 检查不需要管控库存的基础物料
|
||||
if(isset($notCtrlStoreBmList[$pid]) && $notCtrlStoreBmList[$pid]){
|
||||
continue;
|
||||
}
|
||||
|
||||
// check store
|
||||
if (($store[$pid]['store'] - $nums) < 0) {
|
||||
$allow = false;
|
||||
}
|
||||
@@ -305,5 +316,5 @@ class omeauto_auto_plugin_store extends omeauto_auto_plugin_abstract implements
|
||||
public function getInputUI() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ class omeauto_auto_type
|
||||
/**
|
||||
* 所有支持的类型
|
||||
*/
|
||||
static $TYPE_LIST = array('address', 'shop', 'money', 'platform', 'sku', 'cod', 'skunum', 'itemnum', 'weight', 'memo', 'ordertype', 'materialtype', 'orderhost', 'shopmode', 'customer', 'orderlabel');
|
||||
static $TYPE_LIST = array('address', 'shop', 'money', 'platform', 'sku', 'cod', 'skunum', 'itemnum', 'weight', 'memo', 'ordertype', 'materialtype', 'orderhost', 'shopmode', 'customer', 'orderlabel', 'materialcat');
|
||||
|
||||
/**
|
||||
* 执行插件的指定方法
|
||||
|
||||
@@ -103,12 +103,14 @@ class omeauto_auto_type_customer extends omeauto_auto_type_abstract implements o
|
||||
foreach ($order['objects'] as $objKey => $objVal)
|
||||
{
|
||||
$goods_id = $objVal['goods_id'];
|
||||
|
||||
// goods ids
|
||||
$goodsIds[$goods_id] = $goods_id;
|
||||
}
|
||||
}
|
||||
|
||||
//获取销售物料
|
||||
$tempList = $salesMaterialObj->getList('sm_id,sales_material_bn,sales_material_type,class_id', array('sm_id'=>$goods_id));
|
||||
$tempList = $salesMaterialObj->getList('sm_id,sales_material_bn,sales_material_type,class_id', array('sm_id'=>$goodsIds));
|
||||
if(empty($tempList)){
|
||||
return false;
|
||||
}
|
||||
|
||||
133
app/omeauto/lib/auto/type/materialcat.php
Normal file
133
app/omeauto/lib/auto/type/materialcat.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* 按基础物料分类
|
||||
*/
|
||||
class omeauto_auto_type_materialcat extends omeauto_auto_type_abstract implements omeauto_auto_type_interface
|
||||
{
|
||||
/**
|
||||
* 商品类型
|
||||
*
|
||||
* @param object $tpl
|
||||
* @return void
|
||||
*/
|
||||
public function _prepareUI(&$tpl)
|
||||
{
|
||||
$catMdl = app::get('material')->model('basic_material_cat');
|
||||
|
||||
//客户分类
|
||||
$catList = $catMdl->getList('cat_id,parent_id,is_leaf,type_id,cat_name,cat_code', array('disabled'=>'false'), 0, -1);
|
||||
if($catList){
|
||||
$catList = array_column($catList, null, 'cat_id');
|
||||
}
|
||||
|
||||
$tpl->pagedata['cat_list'] = $catList;
|
||||
}
|
||||
|
||||
//检查输入的参数
|
||||
public function checkParams($params)
|
||||
{
|
||||
if (empty($params['cat_id'])) {
|
||||
return "你还没有选择相应的基础物料分类\n\n请勾选以后再试!!";
|
||||
}
|
||||
|
||||
if (empty($params['find_type'])) {
|
||||
return "请先选择筛选范围!";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成规则字串
|
||||
*
|
||||
* @param Array $params
|
||||
* @return String
|
||||
*/
|
||||
public function roleToString($params)
|
||||
{
|
||||
$catMdl = app::get('material')->model('basic_material_cat');
|
||||
|
||||
//客户分类
|
||||
$caption = '';
|
||||
$catList = $catMdl->getList('cat_id,parent_id,is_leaf,type_id,cat_name,cat_code', array('disabled'=>'false'), 0, -1);
|
||||
if($catList){
|
||||
$catList = array_column($catList, null, 'cat_id');
|
||||
|
||||
foreach ($catList as $key => $val)
|
||||
{
|
||||
if($key == $params['cat_id']){
|
||||
if($params['find_type'] == 'not_include'){
|
||||
$caption = sprintf('订单明细中 [不包含] [%s] 基础物料分类', $val['cat_name']);
|
||||
}else{
|
||||
$caption = sprintf('订单明细中 [包含] [%s] 基础物料分类', $val['cat_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//role
|
||||
$role = array('role'=>'materialcat', 'caption'=>$caption, 'content'=>array('cat_id'=>$params['cat_id'], 'find_type'=>$params['find_type']));
|
||||
|
||||
return json_encode($role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查订单数据是否符合要求
|
||||
*
|
||||
* @param omeauto_auto_group_item $item
|
||||
* @return boolean
|
||||
*/
|
||||
public function vaild($item)
|
||||
{
|
||||
if(empty($this->content)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//基础物料分类
|
||||
$cat_id = intval($this->content['cat_id']);
|
||||
$find_type = $this->content['find_type'];
|
||||
|
||||
//获取订单明细中的基础物料
|
||||
$arrProductId = array();
|
||||
foreach ($item->getOrders() as $order)
|
||||
{
|
||||
foreach ($order['objects'] as $objKey => $objVal)
|
||||
{
|
||||
foreach ($objVal['items'] as $itemKey => $itemVal)
|
||||
{
|
||||
$product_id = $itemVal['product_id'];
|
||||
$arrProductId[$product_id] = $product_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取基础物料
|
||||
$basicMaterialObj = app::get('material')->model('basic_material');
|
||||
$tempList = $basicMaterialObj->getList('bm_id,material_bn,material_name,cat_id', array('bm_id'=>$arrProductId));
|
||||
|
||||
//获取规则中的基础物料
|
||||
$virtualBns = array();
|
||||
foreach ($tempList as $key => $val)
|
||||
{
|
||||
$bm_id = $val['bm_id'];
|
||||
|
||||
if($val['cat_id'] == $cat_id){
|
||||
$virtualBns[$bm_id] = $val['material_bn'];
|
||||
}
|
||||
}
|
||||
|
||||
//场景一:[不包含]指定基础物料分类
|
||||
if($find_type == 'not_include'){
|
||||
if($virtualBns){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
//场景二:[包含]指定基础物料分类
|
||||
if(empty($virtualBns)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,11 @@ class omeauto_finder_order_labels
|
||||
{
|
||||
$url = "index.php?app=omeauto&ctl=order_labels&act=edit&p[0]={$row['label_id']}&finder_id={$_GET['_finder']['finder_id']}";
|
||||
|
||||
$str = "<a href='javascript:void(0);' target='download' onclick=\"new Dialog('%s', {width:500,height:300,title:'修改标签'}); \">修改</a>";
|
||||
// 是否显示:修改按钮
|
||||
$str = '';
|
||||
if($row['source'] != 'system'){
|
||||
$str = "<a href='javascript:void(0);' target='download' onclick=\"new Dialog('%s', {width:500,height:300,title:'修改标签'}); \">修改</a>";
|
||||
}
|
||||
|
||||
return sprintf($str, $url);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class omeauto_finder_order_split {
|
||||
var $column_edit_width = "80";
|
||||
var $column_edit_order = "5";
|
||||
function column_edit($row) {
|
||||
$btn = "<a href='javascript:void(0);' onclick=\"new Dialog('index.php?app=omeauto&ctl=order_split&act=edit&p[0]={$row['sid']}&finder_id={$_GET['_finder']['finder_id']}',{width:760,height:480,title:'修改拆单规则'}); \">修改</a>";
|
||||
$btn = "<a href='javascript:void(0);' onclick=\"new Dialog('index.php?app=omeauto&ctl=order_split&act=edit&p[0]={$row['sid']}&finder_id={$_GET['_finder']['finder_id']}',{width:760,height:530,title:'修改拆单规则'}); \">修改</a>";
|
||||
return $btn;
|
||||
}
|
||||
}
|
||||
@@ -119,22 +119,16 @@ class omeauto_order_label
|
||||
$ruleObj = app::get('omeauto')->model('order_labelrule');
|
||||
$ordLabelObj = app::get('ome')->model('bill_label');
|
||||
$operLogObj = app::get('ome')->model('operation_log');
|
||||
$labelObj = app::get('omeauto')->model('order_labels');
|
||||
|
||||
//订单标记规则(最多读取50条有效规则)
|
||||
$ruleList = $ruleObj->getList('*', array('disabled' => 'false'), 0, 50);
|
||||
//订单标记规则(最多读取500条有效规则)
|
||||
$ruleList = $ruleObj->getList('*', array('disabled'=>'false'), 0, 500, 'weight DESC,id DESC');
|
||||
if (empty($ruleList)) {
|
||||
//没有配置标记规则,直接返回true,不用记录log日志
|
||||
$error_msg = '没有配置订单标记规则';
|
||||
return true;
|
||||
}
|
||||
|
||||
//检查已经打标,则跳过
|
||||
/* $isCheck = $ordLabelObj->dump(array('bill_type' => 'order', 'bill_id' => $order_id), 'bill_id');
|
||||
if ($isCheck) {
|
||||
$error_msg = '订单已经打过标签';
|
||||
return true;
|
||||
} */
|
||||
|
||||
//订单信息
|
||||
$orderInfo = $orderObj->dump(array('order_id'=>$order_id), '*', array('order_objects'=>array('*', array('order_items'=>array('*')))));
|
||||
if (empty($orderInfo)) {
|
||||
@@ -226,10 +220,15 @@ class omeauto_order_label
|
||||
continue; //标记已存在,则跳过
|
||||
}
|
||||
|
||||
// 标记信息
|
||||
$labelInfo = $labelObj->dump(array('label_id'=>$label_id), '*');
|
||||
|
||||
// sdf
|
||||
$saveData = array(
|
||||
'bill_type' => 'order',
|
||||
'bill_id' => $order_id,
|
||||
'label_id' => $label_id,
|
||||
'label_code' => $labelInfo['label_code'],
|
||||
'label_name' => $laVal['label_name'],
|
||||
'create_time' => time(),
|
||||
);
|
||||
|
||||
68
app/omeauto/lib/order/label/customer.php
Normal file
68
app/omeauto/lib/order/label/customer.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* 按客户分类给订单打标签
|
||||
*/
|
||||
class omeauto_order_label_customer extends omeauto_order_label_abstract implements omeauto_order_label_interface
|
||||
{
|
||||
/**
|
||||
* 检查订单数据是否符合要求
|
||||
*
|
||||
* @param array $orderInfo
|
||||
* @param string $error_msg
|
||||
* @return bool
|
||||
*/
|
||||
public function vaild($orderInfo, &$error_msg=null)
|
||||
{
|
||||
if(empty($this->content)){
|
||||
$error_msg = '没有设置客户分类规则';
|
||||
return false;
|
||||
}
|
||||
|
||||
$salesMaterialObj = app::get('material')->model('sales_material');
|
||||
|
||||
// 客户分类ID
|
||||
$class_id = intval($this->content['class_id']);
|
||||
|
||||
//获取订单明细中的基础物料
|
||||
$goodsIds = [];
|
||||
foreach ($orderInfo['order_objects'] as $objKey => $objVal)
|
||||
{
|
||||
$goods_id = $objVal['goods_id'];
|
||||
if($goods_id){
|
||||
$goodsIds[$goods_id] = $goods_id;
|
||||
}
|
||||
}
|
||||
|
||||
// 没有销售物料
|
||||
if(empty($goodsIds)){
|
||||
$error_msg = '订单商品明细';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 销售物料列表
|
||||
$saleMaterialList = $salesMaterialObj->getList('sm_id,sales_material_bn,class_id', array('sm_id'=>$goodsIds));
|
||||
if(empty($saleMaterialList)){
|
||||
$error_msg = '订单明细商品未创建销售物料';
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取指定的客户分类
|
||||
$findGoods = [];
|
||||
foreach ($saleMaterialList as $key => $val)
|
||||
{
|
||||
$sm_id = $val['sm_id'];
|
||||
|
||||
//check
|
||||
if($val['class_id'] == $class_id){
|
||||
$findGoods[$sm_id] = $val['sales_material_bn'];
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($findGoods)){
|
||||
$error_msg = '订单商品没有符合的客户分类';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -36,15 +36,15 @@ class omeauto_order_label_materialcat extends omeauto_order_label_abstract imple
|
||||
|
||||
$basicMaterialObj = app::get('material')->model('basic_material');
|
||||
|
||||
//基础物料分类
|
||||
$cat_id = intval($this->content['cat_id']);
|
||||
$find_type = $this->content['find_type'];
|
||||
|
||||
//包含或不包含基础物料分类:大家电、小家电
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//基础物料类型
|
||||
$material_type = intval($this->content['material_type']);
|
||||
//check
|
||||
if(empty($cat_id) || empty($find_type)){
|
||||
$error_msg = '基础物料分类或者筛选范围条件,不能为空!';
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取订单明细中的基础物料
|
||||
$arrProductId = array();
|
||||
@@ -76,20 +76,29 @@ class omeauto_order_label_materialcat extends omeauto_order_label_abstract imple
|
||||
|
||||
//获取虚拟商品
|
||||
$virtualBns = array();
|
||||
$tempList = $basicMaterialObj->getList('bm_id,material_bn,type', array('bm_id'=>$arrProductId));
|
||||
$tempList = $basicMaterialObj->getList('bm_id,material_bn,type,cat_id', array('bm_id'=>$arrProductId));
|
||||
foreach ($tempList as $key => $val)
|
||||
{
|
||||
$bm_id = $val['bm_id'];
|
||||
|
||||
//check
|
||||
if($val['type'] == $material_type){
|
||||
if($val['cat_id'] == $cat_id){
|
||||
$virtualBns[$bm_id] = $val['material_bn'];
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($virtualBns)){
|
||||
$error_msg = '没有符合条件的基础物料';
|
||||
return false;
|
||||
//场景一:[不包含]指定基础物料分类
|
||||
if($find_type == 'not_include'){
|
||||
if($virtualBns){
|
||||
$error_msg = '基础物料编码:'. implode('、', $virtualBns).'包含了指定基础物料分类';
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
//场景二:[包含]指定基础物料分类
|
||||
if(empty($virtualBns)){
|
||||
$error_msg = '订单明细没有包含指定基础物料分类';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
136
app/omeauto/lib/split/customerclassify.php
Normal file
136
app/omeauto/lib/split/customerclassify.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* 按客户分类拆Lib方法类
|
||||
*
|
||||
* @author wangbiao@shopex.cn
|
||||
* @version 2025.09.23
|
||||
*/
|
||||
class omeauto_split_customerclassify extends omeauto_split_abstract
|
||||
{
|
||||
/**
|
||||
* 拆单规则配置获取数据
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecial() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆单规则配置保存
|
||||
*
|
||||
* @param $sdf
|
||||
* @return array
|
||||
*/
|
||||
public function preSaveSdf(&$sdf)
|
||||
{
|
||||
if(empty($sdf['split_config']['class_id'])) {
|
||||
return array(false, '[客户分类]未选择,请检查!');
|
||||
}
|
||||
|
||||
return array(true, '保存成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始拆单处理
|
||||
*
|
||||
* @param $group 订单组
|
||||
* @param $splitConfig 拆单规则配置信息
|
||||
* @return array|true[]
|
||||
*/
|
||||
public function splitOrder(&$group, $splitConfig)
|
||||
{
|
||||
$salesMaterialObj = app::get('material')->model('sales_material');
|
||||
|
||||
// orders
|
||||
$arrOrder = $group->getOrders();
|
||||
|
||||
// 指定拆单的客户分类
|
||||
$class_id = isset($splitConfig['class_id']) ? $splitConfig['class_id'] : 0;
|
||||
if(empty($class_id)){
|
||||
return array(false, '按客户分类拆单失败:没有指定客户分类');
|
||||
}
|
||||
|
||||
// format
|
||||
$goodsIds = [];
|
||||
foreach ($arrOrder as $orderKey => $orderVal)
|
||||
{
|
||||
// order_objects
|
||||
foreach ($orderVal['objects'] as $objectKey => $objectVal)
|
||||
{
|
||||
$goods_id = $objectVal['goods_id'];
|
||||
|
||||
// order items
|
||||
foreach ($objectVal['items'] as $itemKey => $itemVal)
|
||||
{
|
||||
// 过滤没有可拆分的子商品
|
||||
$itemVal['nums'] = $itemVal['nums'] - $itemVal['split_num'];
|
||||
if($itemVal['nums'] < 1) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$goodsIds[$goods_id] = $goods_id;
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
if(empty($goodsIds)){
|
||||
return array(false, '按客户分类拆单失败:没有可审核的SKU货品');
|
||||
}
|
||||
|
||||
// 销售物料列表
|
||||
$saleMaterialList = $salesMaterialObj->getList('sm_id,sales_material_bn,class_id', array('sm_id'=>$goodsIds));
|
||||
if(empty($saleMaterialList)){
|
||||
return array(false, '按客户分类拆单失败:没有销售物料');
|
||||
}
|
||||
$saleMaterialList = array_column($saleMaterialList, null, 'sm_id');
|
||||
|
||||
// split
|
||||
$arrOrderId = array();
|
||||
$splitOrder = array();
|
||||
foreach ($arrOrder as $orderKey => $orderVal)
|
||||
{
|
||||
$order_id = $orderVal['order_id'];
|
||||
|
||||
// order_objects
|
||||
foreach ($orderVal['objects'] as $objectKey => $objectVal)
|
||||
{
|
||||
$goods_id = $objectVal['goods_id'];
|
||||
|
||||
// 订单商品是:指定客户分类,则进行拆分
|
||||
if(isset($saleMaterialList[$goods_id]) && $saleMaterialList[$goods_id]['class_id'] == $class_id){
|
||||
// 初始化订单信息
|
||||
if(empty($splitOrder[$orderKey])) {
|
||||
$tempOrderInfo = $orderVal;
|
||||
|
||||
// unset objects
|
||||
unset($tempOrderInfo['objects']);
|
||||
|
||||
$splitOrder[$orderKey] = $tempOrderInfo;
|
||||
}
|
||||
|
||||
$splitOrder[$orderKey]['objects'][$objectKey] = $objectVal;
|
||||
|
||||
// unset
|
||||
unset($arrOrder[$orderKey]['objects'][$objectKey]);
|
||||
}else{
|
||||
$arrOrderId[$order_id] = $order_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 剩余需要审单的order_id
|
||||
if ($arrOrderId) {
|
||||
$group->setSplitOrderId($arrOrderId);
|
||||
}
|
||||
|
||||
// 本次需要拆单的货品明细
|
||||
$group->updateOrderInfo($splitOrder);
|
||||
if (empty($splitOrder)) {
|
||||
return array(false, '按客户分类拆单失败:无法拆单');
|
||||
}
|
||||
|
||||
return array(true);
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
*/
|
||||
public function splitOrder(&$group, $splitConfig)
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
$arrOrder = $group->getOrders();
|
||||
$arrOrderId = array();
|
||||
$splitOrder = array();
|
||||
@@ -111,7 +112,7 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
if (empty($splitOrder)) {
|
||||
return array(false, '无法拆单');
|
||||
}
|
||||
return array(true);
|
||||
return array(true, '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +128,7 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
|
||||
protected function _splitOrderByStore(&$arrOrder, &$group, $splitConfig)
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
$group->setConfirmBranch(true);
|
||||
$bmIdNum = array();
|
||||
foreach ($arrOrder as $k => $order) {
|
||||
@@ -243,18 +245,36 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
$group->setStoreBranch();
|
||||
$group->setStoreDlyType('o2o_ship');
|
||||
}
|
||||
$logResult = [
|
||||
'初始值' => $branchInfo,
|
||||
'拆分情况' => $rs,
|
||||
'初选仓' => $canBranchId,
|
||||
'终选仓' => $branchId
|
||||
];
|
||||
$this->writeSuccessLog($logResult, $arrOrder);
|
||||
$endTime = microtime(true);
|
||||
$executionTime = $endTime - $startTime;
|
||||
|
||||
if(isset($tid)) {#有仓库规则需要重置仓库
|
||||
$group->setBranchId(array($branchId));
|
||||
}
|
||||
$arrOrder = $rs['order'][$branchId];
|
||||
return [true];
|
||||
|
||||
// 记录插件性能数据
|
||||
$optimizedRs = $this->optimizeSplitDetailsForLog($rs);
|
||||
|
||||
$details = array(
|
||||
'success' => true,
|
||||
'message' => '拆单处理完成',
|
||||
'order_bns' => implode(',', array_column($arrOrder, 'order_bn')),
|
||||
'split_type' => 'storemax',
|
||||
'split_result' => array(
|
||||
'success' => true,
|
||||
'message' => '拆单成功',
|
||||
'split_type' => 'storemax',
|
||||
'initial_branch_info' => $branchInfo,
|
||||
'split_details' => $optimizedRs,
|
||||
'candidate_branches' => $canBranchId,
|
||||
'final_branch' => $branchId
|
||||
)
|
||||
);
|
||||
|
||||
ome_api_log::add_message('plugin', 'split', $executionTime, $details);
|
||||
|
||||
return [true, ''];
|
||||
}
|
||||
|
||||
#根据库存订单处理拆分
|
||||
@@ -518,51 +538,7 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
return $this->sortBranchById($storeRows, $arrO2oBranchId);
|
||||
}
|
||||
|
||||
protected function writeSuccessLog($logResult, $arrOrder)
|
||||
{
|
||||
$bmIdBn = array();
|
||||
$arrOrderBn = array();
|
||||
foreach ($arrOrder as $order) {
|
||||
foreach ($order['objects'] as $ok => $object) {
|
||||
foreach ($object['items'] as $ik => $item) {
|
||||
$bmIdBn[$item['product_id']] = $item['bn'];
|
||||
}
|
||||
}
|
||||
$arrOrderBn[] = $order['order_bn'];
|
||||
}
|
||||
$branchId = array();
|
||||
foreach ($logResult['初始值'] as $v) {
|
||||
$branchId[] = $v['branch_id'];
|
||||
}
|
||||
$branchLib = kernel::single('ome_interface_branch');
|
||||
$branchRows = $branchLib->getList('branch_id, branch_bn', array('branch_id' => $branchId));
|
||||
$branchIdBn = array();
|
||||
foreach ($branchRows as $v) {
|
||||
$branchIdBn[$v['branch_id']] = $v['branch_bn'];
|
||||
}
|
||||
$logResult['id对应编码'] = [
|
||||
'基础物料'=>$bmIdBn,
|
||||
'仓库'=>$branchIdBn,
|
||||
];
|
||||
$apilogModel = app::get('ome')->model('api_log');
|
||||
$log_id = $apilogModel->gen_id();
|
||||
$logsdf = array(
|
||||
'log_id' => $log_id,
|
||||
'task_name' => '按库存就全拆结果',
|
||||
'status' => 'success',
|
||||
'worker' => '',
|
||||
'params' => json_encode(array('store.split', $logResult), JSON_UNESCAPED_UNICODE), #longtext
|
||||
'msg' => '', #text json字符串
|
||||
'log_type' => '',
|
||||
'api_type' => 'response',
|
||||
'memo' => '',
|
||||
'original_bn' => $arrOrderBn[0],
|
||||
'createtime' => time(),
|
||||
'last_modified' => time(),
|
||||
'msg_id' => '',
|
||||
);
|
||||
$apilogModel->insert($logsdf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过滤出管控库存的仓库
|
||||
@@ -593,4 +569,72 @@ class omeauto_split_storemax extends omeauto_split_abstract
|
||||
|
||||
return $branchIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化拆单详情数据用于日志记录
|
||||
* 只记录代码中实际使用的字段,减少冗余数据
|
||||
*
|
||||
* @param array $rs 原始拆单结果数据
|
||||
* @return array 优化后的拆单结果数据
|
||||
*/
|
||||
private function optimizeSplitDetailsForLog($rs) {
|
||||
$optimizedRs = array();
|
||||
|
||||
// 优化 order 信息,只记录实际使用的字段
|
||||
if (isset($rs['order'])) {
|
||||
$optimizedOrder = array();
|
||||
foreach ($rs['order'] as $branchId => $orders) {
|
||||
$optimizedOrder[$branchId] = array();
|
||||
foreach ($orders as $order) {
|
||||
$optimizedOrderData = array(
|
||||
'order_id' => $order['order_id'],
|
||||
'order_bn' => $order['order_bn']
|
||||
);
|
||||
|
||||
// 只记录代码中实际使用的 item 字段
|
||||
if (isset($order['objects'])) {
|
||||
$optimizedOrderData['items'] = array();
|
||||
foreach ($order['objects'] as $object) {
|
||||
if (isset($object['items'])) {
|
||||
foreach ($object['items'] as $item) {
|
||||
$optimizedOrderData['items'][] = array(
|
||||
'product_id' => $item['product_id'], // 用于库存计算
|
||||
'nums' => $item['nums'] ?? 0, // 用于数量计算
|
||||
'split_num' => $item['split_num'] ?? 0, // 用于拆单逻辑
|
||||
'original_num' => $item['original_num'] ?? 0 // 用于记录原始数量
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$optimizedOrder[$branchId][] = $optimizedOrderData;
|
||||
}
|
||||
}
|
||||
$optimizedRs['order'] = $optimizedOrder;
|
||||
}
|
||||
|
||||
// 优化 branchInfo 信息,只保留实际使用的字段
|
||||
if (isset($rs['branchInfo'])) {
|
||||
$optimizedBranchInfo = array();
|
||||
foreach ($rs['branchInfo'] as $branchId => $branchData) {
|
||||
$optimizedBranchInfo[$branchId] = array(
|
||||
'branch_id' => $branchData['branch_id'],
|
||||
'store' => $branchData['store'] // 用于库存计算,保留完整数据
|
||||
);
|
||||
}
|
||||
$optimizedRs['branchInfo'] = $optimizedBranchInfo;
|
||||
}
|
||||
|
||||
// 保留 sku_num 和 is_split 信息(代码中直接使用)
|
||||
if (isset($rs['sku_num'])) {
|
||||
$optimizedRs['sku_num'] = $rs['sku_num'];
|
||||
}
|
||||
|
||||
if (isset($rs['is_split'])) {
|
||||
$optimizedRs['is_split'] = $rs['is_split'];
|
||||
}
|
||||
|
||||
return $optimizedRs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,10 @@ class omeauto_mdl_order_split extends dbeav_model{
|
||||
'skuvolume' => '按商品体积拆',
|
||||
'branchgroup' => '按仓库分组拆',
|
||||
'virtualsku' => '按虚拟商品拆,虚拟商品自动发货',
|
||||
'skuchannel' => '按京东开普勒商品渠道ID拆',
|
||||
//'skuchannel' => '按京东开普勒商品渠道ID拆',
|
||||
'oid' => '按京东子订单拆',
|
||||
'orderhost' => '按达人信息拆',
|
||||
'customerclassify' => '按客户分类拆',
|
||||
);
|
||||
|
||||
protected $batchConfirmSplitType = array('storemax', 'sku', 'skuweight','skucategory', 'skuvolume', 'oid');
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<option value="ordertype" <{if $init.role=='ordertype'}>selected<{/if}>>订单类型</option>
|
||||
<option value="materialtype" <{if $init.role=='materialtype'}>selected<{/if}>>按基础物料类型</option>
|
||||
<option value="materialcat" <{if $init.role=='materialcat'}>selected<{/if}>>按基础物料分类</option>
|
||||
<option value="customer" <{if $init.role=='customer'}>selected<{/if}>>按客户分类</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>标签代码:</th>
|
||||
<td><input name="label_code" type="text" value="<{$data.label_code}>" maxlength="20" vtype="required" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9]/g,'')" />
|
||||
<span style="color:red;">*</span>必填项,支持英文字母、数字</td>
|
||||
<td><input name="label_code" type="text" value="<{$data.label_code}>" maxlength="20" vtype="required" onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9_]/g,'')" />
|
||||
<span style="color:red;">*</span>必填项,支持英文字母、数字、下划线</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>标签名称:</th>
|
||||
|
||||
34
app/omeauto/view/order/type/materialcat.html
Normal file
34
app/omeauto/view/order/type/materialcat.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<style>
|
||||
.in_ul{clear: both;}
|
||||
.in_ul li {font-size: 12px; float: left;}
|
||||
</style>
|
||||
<span>
|
||||
<ul class="in_ul">
|
||||
<li>
|
||||
<span>筛选范围:</span>
|
||||
</li>
|
||||
<li>
|
||||
<input type="radio" name="find_type" value="include" <{if $init.content.find_type != 'not_include'}>checked<{/if}> />包含
|
||||
</li>
|
||||
<li>
|
||||
<input type="radio" name="find_type" value="not_include" <{if $init.content.find_type == 'not_include'}>checked<{/if}> />不包含
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
|
||||
<span style="padding-top:10px;">
|
||||
<ul class="in_ul">
|
||||
<li>
|
||||
<span>基础物料分类:</span>
|
||||
</li>
|
||||
<li>
|
||||
<select type="select" name="cat_id" id="cat_id" required="true" class=" x-input-select inputstyle">
|
||||
<{if $cat_list}>
|
||||
<{foreach from=$cat_list key=keyVal item=itemVal}>
|
||||
<option value="<{$itemVal.cat_id}>" <{if $itemVal.cat_id == $init.content.cat_id}>selected<{/if}>><{$itemVal.cat_name}></option>
|
||||
<{/foreach}>
|
||||
<{/if}>
|
||||
</select>
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
@@ -28,10 +28,15 @@
|
||||
<td><{input type="textarea" cols="100" rows="4" name="describe" id='t_describe' value=$info.describe}><br/>(对此订单类型的简单描述)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="60"><{help}>按京东开普勒商品渠道ID拆:现仅用于【抖音平台】订单使用【京东云交易】仓储进行发货。<{/help}> 拆单类型: </th>
|
||||
<th width="60">拆单类型: </th>
|
||||
<td>
|
||||
<{input type="select" id='t_split_type' name="split_type" value=$info.split_type options=$split_type required="required"}>
|
||||
<div id="split_type_special" style="padding-top: 10px"></div> <span style="color:red;">*提示:如果设置了 "按虚拟商品拆单" 规则,系统会优先执行虚拟商品自动拆单并自动发货。</span>
|
||||
<div id="split_type_special" style="padding-top: 10px"></div>
|
||||
|
||||
<br>
|
||||
<span style="color:red;">*提示:“按库存就全拆”拆单类型,不适用【订单审核时不需要管控库存】,如果有不需要库存管控的订单明细,请单独创建一个审单规则,并且【分组规则】权重值必须设置高一些。</span>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
6
app/omeauto/view/order/type/split/customerclassify.html
Normal file
6
app/omeauto/view/order/type/split/customerclassify.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="mt-10">
|
||||
<div>
|
||||
客户分类:
|
||||
<{input type='object' object="customer_classify@material" required="required" filter="disabled=false" name="split_config[class_id]" value=$data.split_config.class_id}>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user