mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-23 13:05:33 +08:00
1. 【新增】售后单售后原因类型支持搜索
2. 【新增】手工创建订单折扣可输入正数 3. 【优化】盘点申请单确认 4. 【修复】采购退货单模拟出库失败问题 5. 【新增】订单金额客户实付与结算金额 6. 【优化】仓库发货统计报表物料名称显示 7. 【优化】自有仓储虚拟发货逻辑 8. 【修复】基础物料分类管理问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user