|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|