mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-31 13:25:32 +08:00
119 lines
3.7 KiB
PHP
119 lines
3.7 KiB
PHP
<?php
|
||
/**
|
||
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http://www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the License.
|
||
*/
|
||
|
||
class omeauto_auto_plugin_checksplitgift extends omeauto_auto_plugin_abstract implements omeauto_auto_plugin_interface {
|
||
|
||
/**
|
||
* 是否支持批量审单
|
||
*/
|
||
protected $__SUP_REP_ROLE = false;
|
||
/**
|
||
* 状态码
|
||
*/
|
||
protected $__STATE_CODE = omeauto_auto_const::__CHECKSPLITGIFT_CODE;
|
||
|
||
private $__MUST_CHECK_GIFT = ['kuaishou','taobao'];
|
||
|
||
/**
|
||
* 开始处理
|
||
*
|
||
* @param omeauto_auto_group_item $group 要处理的订单组
|
||
* @return Array
|
||
*/
|
||
public function process(& $group, &$confirmRoles=null) {
|
||
$allow = false;
|
||
if($this->_checkStatus($confirmRoles, $group)){
|
||
foreach ($group->getOrders() as $order) {
|
||
foreach ($order['objects'] as $object) {
|
||
foreach ($object['items'] as $item) {
|
||
if($item['item_type'] != 'gift') {
|
||
$allow = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//检测objects层标识,是否有顺手购标识
|
||
foreach ($group->getOrders() as $order) {
|
||
foreach ($order['objects'] as $object) {
|
||
if (!kernel::single('ome_order_bool_objecttype')->isActivityPurchase($object['object_bool_type'])) {
|
||
$allow = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if(!$allow){
|
||
foreach ($group->getOrders() as $order) {
|
||
$group->setOrderStatus($order['order_id'], $this->getMsgFlag());
|
||
}
|
||
$group->setStatus(omeauto_auto_group_item::__OPT_HOLD, $this->_getPlugName());
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* 获取配置信息
|
||
*
|
||
* @param void
|
||
* @return array
|
||
*/
|
||
private function _checkStatus($configRoles, $group) {
|
||
// 拆单后不允许单独发礼品的,返回true
|
||
foreach ($group->getOrders() as $order) {
|
||
if (in_array($order['shop_type'], $this->__MUST_CHECK_GIFT) && $order['process_status'] == 'unconfirmed') {
|
||
foreach ($order['objects'] as $objects) {
|
||
if ($objects['obj_type'] == 'gift' && $objects['main_oid']) {
|
||
return true;
|
||
}
|
||
|
||
//顺手购
|
||
if (kernel::single('ome_order_bool_objecttype')->isActivityPurchase($objects['object_bool_type'])) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
$osg = app::get('ome')->getConf('ome.order.split.gift');
|
||
if ($osg == '1') {
|
||
return true;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取该插件名称
|
||
*
|
||
* @param Void
|
||
* @return String
|
||
*/
|
||
public function getTitle() {
|
||
return '仅赠品不生成发货单';
|
||
}
|
||
|
||
/**
|
||
* 获取提示信息
|
||
*
|
||
* @param Array $order 订单内容
|
||
* @return Array
|
||
*/
|
||
public function getAlertMsg(& $order) {
|
||
return array('color' => 'RED', 'flag' => '仅', 'msg' => '仅赠品不生成发货单');
|
||
}
|
||
|
||
}
|