20240120-ljl-routeConfig
ljl 10 months ago
parent 8c460de44c
commit 0aab17114f

@ -469,4 +469,61 @@ class OrderPrintConst {
OrderPrintConst::printFromFdsOrder
];
}
public static function getFootBarBtnNameAndTextMap() {
return [
// 已有的
'batchPrintExpress' => '批量打印快递单',
'batchPrintInvoice' => '批量打印发货单',
'batchSend' => '批量发货',
'batchScanAndSend' => '扫描发货',
'batchVenderRemark' => '商家备注',
'batchVenderNote' => '批量本地备注',
'batchSetIsolation' => '批量挂起订单',
'manualOutstorage' => '手动发货',
// 新添加的
'batchPrintItemTag' => '打印拿货小标签',
'copyOrderInfo' => '复制快递单号',
'copyWaybillInfo' => '复制快递信息',
];
}
/**
* 新添加的底部操作按钮
* 1. 此方法不影响已有操作按钮功能
* 2. 在此方法添加新按钮的同时,也需要在 getFootBarBtnNameAndTextMap() 方法中添加
*/
public static function getFootBarBtnNameAndTextMapForNew() {
return [
'batchPrintItemTag' => '打印拿货小标签',
];
}
public static function getShipAssistBtnName() {
return [
'batchPrintExpress',
'batchPrintInvoice',
'batchSend',
'batchScanAndSend',
'manualOutstorage',
];
}
public static function getShowFootBarBtnNameList() {
return [
'batchPrintExpress',
'batchPrintInvoice',
'batchSend',
];
}
public static function getOperateBtnTypeList() {
return [
'primary',
'success',
'info',
'warning',
'danger',
];
}
}

@ -652,4 +652,29 @@ class PrintSettingController extends AbstractApiController {
$this->printSettingService->delCustomProvincesFilter($this->mallId, $_POST['filterId']);
return $this->renderSuccess();
}
/**
* @api POST 保存操作按钮配置
* @param operateBtnData[] operateBtnList 操作按钮列表
* @param string operateBtnData.group 按钮组别:底部菜单-footBarBtn发货辅助-shipAssistBtnotherBtn-其他功能
* @param string operateBtnData.field 按钮字段
* @param string operateBtnData.color 按钮颜色
*/
public function saveOpSettingOperateBtnConfig() {
$operateBtnList = $_POST['operateBtnList'];
$this->printSettingService->saveOpSettingOperateBtnConfig($this->sellerId, $operateBtnList);
return $this->renderSuccess();
}
/**
* @api GET 获取操作按钮配置
*/
public function getOpSettingOperateBtnConfig() {
list($operateBtnGroupAndDataMap, $moreOperateBtnList) = $this->printSettingService->getOpSettingOperateBtnConfig($this->sellerId);
return $this->renderSuccess([
'operateBtnGroupAndDataMap' => $operateBtnGroupAndDataMap,
'moreOperateBtnList' => $moreOperateBtnList,
]);
}
}

@ -5,4 +5,7 @@ namespace Dao\Mall;
use Dao\AbstractDao;
class MallOpDao extends AbstractDao {
public function getGmtLastChangeOperateBtnByMallId($mallId) {
return $this->queryFirstField('select gmt_last_change_operate_btn from %b where mall_id = %s', $this->getTable(), $mallId);
}
}

@ -73,6 +73,10 @@ class OpSettingRepository extends AbstractRepository {
$update['filter_custom_ship_time_left_hours'] = $data['customShipTimeLeftHours'] ? implode(',', $data['customShipTimeLeftHours']) : '';
}
if (isset($data['operateBtnConfig'])) {
$update['operate_btn_config'] = $data['operateBtnConfig'];
}
$boolFields = [
'isSinglePrintInvoiceAfterPrintExpress',
'isSingleAutoShipmentAfterPrintExpress',

@ -3,8 +3,10 @@
namespace Service\OrderPrint;
use Area;
use CheckClient;
use CommonTool;
use Dao\Common\AreaDao;
use Dao\Mall\MallOpDao;
use Dao\Order\OpOrderAreaFilterDao;
use Dao\Order\OpOrderSearchTplDao;
use Dao\Order\OpSkuShortDao;
@ -27,6 +29,7 @@ class PrintSettingService extends AbstractService {
private $mallRepository;
private $areaDao;
private $mallOpDao;
private $opSettingDao;
private $opPageSettingDao;
private $opSkuShortDao;
@ -39,6 +42,7 @@ class PrintSettingService extends AbstractService {
$this->opSettingRepository = OpSettingRepository::instance();
$this->mallRepository = MallRepository::instance();
$this->mallOpDao = MallOpDao::instance();
$this->areaDao = AreaDao::instance();
$this->opSettingDao = OpSettingDao::instance();
$this->opPageSettingDao = OpPageSettingDao::instance();
@ -497,4 +501,98 @@ class PrintSettingService extends AbstractService {
throw new BizException('删除失败');
}
}
public function saveOpSettingOperateBtnConfig($mallId, $operateBtnList) {
CheckClient::checkAnyEmpty('参数有误', $mallId, $operateBtnList);
$this->checkOperateBtnConfig($operateBtnList);
$gmtLastChangeOperateBtn = $this->mallOpDao->getGmtLastChangeOperateBtnByMallId($mallId);
if (!$gmtLastChangeOperateBtn) {
$opSetting = $this->opSettingRepository->getUserOpSetting($mallId);
$operateBtnConfig = $opSetting['operateBtnConfig'];
if ($operateBtnConfig && md5(json_encode($operateBtnList)) != md5($operateBtnConfig)) {
$updateData = array(
'gmtLastChangeOperateBtn' => \ZcDbEval::now(),
'gmtModified' => \ZcDbEval::now(),
);
$this->mallOpDao->update($updateData, 'mall_id = %s', $mallId);
}
}
$updateData = array(
'operateBtnConfig' => json_encode($operateBtnList)
);
$affRow = $this->opSettingRepository->saveUserOpSetting($mallId, $updateData);
if ($affRow === false) {
throw new BizException("保存操作按钮配置失败");
}
}
private function checkOperateBtnConfig($operateBtnList) {
$btnNamelist = array_keys(\OrderPrintConst::getFootBarBtnNameAndTextMap());
foreach ($operateBtnList as $operateBtnData) {
if (!in_array($operateBtnData['group'], ['footBarBtn', 'shipAssistBtn', 'otherBtn'])) {
throw new BizException("操作按钮组别有误");
}
if (!in_array($operateBtnData['field'], $btnNamelist)) {
throw new BizException("操作按钮字段有误");
}
if ($operateBtnData['color'] && !in_array($operateBtnData['color'], \OrderPrintConst::getOperateBtnTypeList()) && !preg_match('/#([a-f]|[A-F]|[0-9]){6}/', $operateBtnData['color'])) {
throw new BizException("操作按钮颜色有误");
}
}
}
public function getOpSettingOperateBtnConfig($mallId) {
$opSetting = $this->opSettingRepository->getUserOpSetting($mallId);
$operateBtnConfig = json_decode($opSetting['operateBtnConfig'], true);
$operateBtnConfig = $this->initOperateBtnConfig($mallId, $operateBtnConfig, $opSetting);
$operateBtnGroupAndDataMap = $moreOperateBtnList = $btnHasMap = [];
foreach ($operateBtnConfig as $operateBtn) {
$btnHasMap[$operateBtn['field']] = true;
$operateBtnGroupAndDataMap[$operateBtn['group']][] = $operateBtn;
if ($operateBtn['group'] != 'footBarBtn') {
$moreOperateBtnList[] = $operateBtn;
}
}
return [$operateBtnGroupAndDataMap, $moreOperateBtnList];
}
private function initOperateBtnConfig($mallId, $oldOperateBtnConfig, $opSetting) {
$oldOperateBtnConfig = $oldOperateBtnConfig ?: [];
$btnAndTextMap = \OrderPrintConst::getFootBarBtnNameAndTextMap();
$showFootBarBtnNameList = \OrderPrintConst::getShowFootBarBtnNameList();
$shipAssistBtnNameList = \OrderPrintConst::getShipAssistBtnName();
$allBtns = array_keys($btnAndTextMap);
$oldBtns = array_column($oldOperateBtnConfig, 'field');
$newBtns = array_diff($allBtns, $oldBtns);
$newOperateBtnConfig = $oldOperateBtnConfig;
foreach ($newBtns as $btnField) {
if (in_array($btnField, $showFootBarBtnNameList)) {
$newOperateBtnConfig[] = [
'group' => 'footBarBtn',
'field' => $btnField,
'color' => $btnField == 'batchPrintExpress' ? 'primary' : '',
];
} elseif (in_array($btnField, $shipAssistBtnNameList)) {
$newOperateBtnConfig[] = [
'group' => 'shipAssistBtn',
'field' => $btnField,
'color' => '',
];
} else {
$newOperateBtnConfig[] = [
'group' => 'otherBtn',
'field' => $btnField,
'color' => '',
];
}
}
$this->saveOpSettingOperateBtnConfig($mallId, $newOperateBtnConfig);
return $newOperateBtnConfig;
}
}
Loading…
Cancel
Save