20240120-ljl-routeConfig
ljl 10 months ago
parent acf89ee7b7
commit 6775907169

@ -42,6 +42,7 @@ class LogisticsConst {
const SFKY = 'SFKY';
const DB = 'DB';
const DBL = 'DBL';
const ZYKD = 'ZYKD';
const HOAU = 'HOAU';
const LB = 'LB';
@ -204,6 +205,14 @@ class LogisticsConst {
const pddCompanyIdSf = 44;
const pddCompanyIdKysy = 183;
const zhongyouPayTypeSendPay = '1';
const zhongyouPayTypeReceiverPay = '2';
const zhongyouPayTypeMonthPay = '3';
const guaranteeTypeCustom = '2';
const guaranteeTypeOrderAmount = '1';
const guaranteeTypeNo = '0';
public static function getSellerFieldsMap() {
$fieldMap = array(
self::sName => '寄件人姓名',
@ -235,7 +244,7 @@ class LogisticsConst {
return $fieldMap;
}
public static function getLogisticsMap($cpCode) {
public static function getLogisticsMap($cpCode = null) {
$cpMap = array(
self::SF => '顺丰速运',
self::EMS => 'EMS标准快递',

@ -440,6 +440,42 @@ class PrintSettingController extends AbstractApiController {
return $this->renderSuccess(['invoiceTplList' => $invoiceTplList]);
}
/**
* @api GET 获取全部快递单模板
*/
public function getAllExpressTplList() {
$expressTplList = $this->expressTplService->getAllExpressTplList($this->mallId);
return $this->renderSuccess(['expressTplList' => $expressTplList]);
}
/**
* @api GET 获取快递单模板详情
* @param int tplId 模板ID
*/
public function getUserExpressDetail() {
$data = $this->expressTplService->getUserExpressDetail($_GET['tplId'], CommonTool::getOperatorInfo());
return $this->renderSuccess($data);
}
/**
* @api GET 获取系统模板详情
* @param int tplId 模板ID
*/
public function getSysExpressTpl() {
$data = $this->expressTplService->getSysExpressTpl($_GET['tplId'], CommonTool::getOperatorInfo());
return $this->renderSuccess($data);
}
/**
* @api GET 获取系统模板列表
* @param string expressType 类型(ptmd/dzmd, 不填表示全部)
* @param string waybillType 面单类型(多个用逗号连接)
*/
public function getNormalSysExpressTplMap() {
$normalSysExpressTplMap = $this->expressTplService->getNormalSysExpressTplMap($_GET['expressType'] ?: null, $_GET['waybillType'] ?: null);
return $this->renderSuccess(['normalSysExpressTplMap' => $normalSysExpressTplMap]);
}
/**
* @api POST 取消模板分享
* @param string tplId * 模板id

@ -25,4 +25,19 @@ class OpUserExpressTplDao extends AbstractDao {
$sql = 'select * from %b where op_user_express_tpl_id = %i and mall_id = %i';
return $this->queryFirstRow($sql, $this->getTable(), $tplId, $mallId);
}
public function searchList($mallId, $filter) {
$logisticsTbl = LogisticsDao::tableName();
$where = [];
if ($filter['tplId'] > 0) {
$where[] = $this->prepare('and ovet.op_user_express_tpl_id = %i', $filter['tplId']);
}
if (!empty($filter['expressType'])) {
$where[] = $this->prepare('and ovet.express_type = %s', $filter['expressType']);
}
$whereStr = !empty($where) ? implode(' ', $where) : '';
return $this->query("select ovet.*, l.logistics_name, l.logistics_code from %b ovet left join %b l on l.logistics_id = ovet.logistics_id where ovet.mall_id = %i %l order by ovet.is_default desc, ovet.op_user_express_tpl_id desc", $this->getTable(), $logisticsTbl, $mallId, $whereStr);
}
}

@ -0,0 +1,8 @@
<?php
namespace Dao\OrderPrint;
use Dao\AbstractDao;
class WbUserDao extends AbstractDao {
}

@ -9,4 +9,9 @@ class WbUserMallDao extends AbstractDao {
$exist = $this->queryFirstField('select 1 from %b where mall_id = %i and wb_user_id = %s', $this->getTable(), $mallId, $wbUserId);
return !empty($exist);
}
public function getListByMallId($mallId) {
$userTbl = WbUserDao::tableName();
return $this->query('select wu.wb_user_id,wu.user_name from %b wum left join %b wu on wum.wb_user_id = wu.wb_user_id where wum.mall_id = %i', $this->getTable(), $userTbl, $mallId);
}
}

@ -396,7 +396,7 @@ class AreaRepository extends AbstractRepository {
return $addressInfo;
}
public function getAreaIdsBynameFromAreaTree($areaTree, $provinceName, $cityName, $countyName) {
public function getAreaIdsByAreaNameFromAreaTree($areaTree, $provinceName, $cityName, $countyName) {
$provinceAreaId = $cityAreaId = $countyAreaId = 0;
$citys = $countys = [];
foreach ($areaTree as $area) {

@ -32,21 +32,34 @@ class ExpressTplRepository extends AbstractRepository {
public function getSysExpressTplById($tplId) {
$row = $this->opSysExpressTplDao->getByIdWithLogistics($tplId);
$row['customAreaX'] = ($row['customAreaX'] !== null) ? $row['customAreaX'] : 0;
return $this->rebuildUserExpressTpl($row);
}
public function getUserExpressTplList($mallId, $filter = null) {
$expressList = $this->opUserExpressTplDao->searchList($mallId, $filter);
foreach ($expressList as $tmpExpress) {
$tmpExpress = $this->rebuildUserExpressTpl($tmpExpress);
}
return $expressList;
}
private function rebuildUserExpressTpl($row) {
$row['customAreaX'] = ($row['customAreaX'] !== null) ? $row['customAreaX'] : 0;
$row['customAreaY'] = ($row['customAreaY'] !== null) ? $row['customAreaY'] : $row['fixedAreaHeight'];
$row['customAreaWidth'] = ($row['customAreaWidth'] !== null) ? $row['customAreaWidth'] : $row['tplWidth'];
$row['customAreaHeight'] = ($row['customAreaHeight'] !== null) ? $row['customAreaHeight'] : ($row['tplHeight'] - $row['fixedAreaHeight']);
$row['globalStyle'] = unserialize($row['globalStyle']);
$row['positionMap'] = unserialize($row['positionMap']);
$row['waybillAccount'] = unserialize($row['waybillAccount']);
$row['printLogo'] = $row['waybillAccount']['printLogo'];
foreach ($row['positionMap'] as &$item) {
$item = PrintTplTool::transferOldNode($item);
if (($item['type'] == 'image' || $item['type'] == 'logo') && !empty($item['imgPath'])) {
$item['imgSrc'] = OrderPrintTool::opPubAbsUrl($item['imgPath']);
}
}
return $row;
}
return $row;
}
public function getUserExpressTplById($mallId, $tplId) {
if (CommonTool::anyEmpty($mallId, $tplId)) {

@ -24,7 +24,9 @@ use Dao\OrderPrint\OpUserExpressTplDao;
use Dao\OrderPrint\WbUserMallDao;
use Exception\BizException;
use Exception\CheckClientException;
use OrderPrintConst;
use PddApi;
use PddOAuthUtil;
use Repository\Mall\MallRepository;
use Repository\OrderPrint\SenderAddressRepository;
@ -460,4 +462,179 @@ class ExpressTplService extends AbstractService {
}
return $senderAddress;
}
public function getUserExpressTplList($mallId, $expressType) {
$expressType = in_array($expressType, [OrderPrintConst::expressTypePtmd, OrderPrintConst::expressTypeDzmd, OrderPrintConst::expressTypeCainaoYun]) ? $_POST['type'] : OrderPrintConst::expressTypePtmd;
$expressTplList = $this->expressTplRepository->getUserExpressTplList($mallId, ['expressType' => $expressType]);
$ownerMallIds = array_filter(ZcArrayHelper::getSub($expressTplList, 'ownerMallId'));
$mallIdAndMallNameMap = $this->mallSDao->getMallIdAndMallNameMap($ownerMallIds);
foreach ($expressTplList as &$expressTpl) {
$expressTpl['ownerMallName'] = $mallIdAndMallNameMap[$expressTpl['ownerMallId']];
}
return $expressTplList;
}
public function getAllExpressTplList($mallId) {
$filter = ['status' => StatusConst::normal];
$expressTplList = $this->expressTplRepository->getUserExpressTplList($mallId, $filter);
$ptmdExpressList = array_filter($expressTplList, function ($value) {
return $value['expressType'] == OrderPrintConst::expressTypePtmd;
});
$dzmdExpressList = array_filter($expressTplList, function ($value) {
return $value['expressType'] == OrderPrintConst::expressTypeDzmd;
});
return [
OrderPrintConst::expressTypePtmd => array_values($ptmdExpressList),
OrderPrintConst::expressTypeDzmd => array_values($dzmdExpressList),
];
}
public function getNormalSysExpressTplMap($expressType, $waybillTypes = null, $sort = null, $allColumns = false) {
$logisticsMap = LogisticsConst::getLogisticsMap();
$tplList = $this->opSysExpressTplDao->searchNormalTplList($expressType, $waybillTypes, $sort);
$columns = ['opSysExpressTplId','cpCode','tplName','tplImgUrl', 'waybillType', 'expressType', 'isChildParent'];
$groupTpls = [];
foreach ($tplList as $key => $tpl) {
if (empty($logisticsMap[$tpl['cpCode']])) {
continue;
}
if (!$allColumns) {
$tpl = ZcArrayHelper::filterColumns($tpl, $columns);
}
$tpl['logisticsName'] = $logisticsMap[$tpl['cpCode']];
$tpl['tplImgUrl'] = OrderPrintTool::opPubAbsUrl( $tpl['tplImgUrl']);
if (empty($groupTpls[$tpl['cpCode']])) {
$groupTpls[$tpl['cpCode']] = [
'cpCode' => $tpl['cpCode'],
'logisticsName' => $logisticsMap[$tpl['cpCode']],
'tpls' => [$tpl]
];
} else {
$groupTpls[$tpl['cpCode']]['tpls'][] = $tpl;
}
}
return array_values($groupTpls);
}
public function getSysExpressTpl($tplId, $operatorInfo) {
$sysExpressTpl = $this->opSysExpressTplDao->getFormatedById($tplId);
$sysExpressTpl['tplWidthPx'] = OrderPrintTool::convertMm2Px($sysExpressTpl['tplWidth']);
$sysExpressTpl['tplHeightPx'] = OrderPrintTool::convertMm2Px($sysExpressTpl['tplHeight']);
if (!empty($sysExpressTpl['tplImgUrl'])) {
$sysExpressTpl['tplImgUrl'] = OrderPrintTool::opPubAbsUrl($sysExpressTpl['tplImgUrl']);
}
if (!empty($sysExpressTpl['waybillCoverImg'])) {
$sysExpressTpl['waybillCoverImg'] = OrderPrintTool::opPubAbsUrl($sysExpressTpl['waybillCoverImg']);
}
$serviceList = $this->getServiceList($sysExpressTpl['waybillType'], $sysExpressTpl['cpCode']);
return ['sysExpressTpl' => $sysExpressTpl, 'serviceList' => $serviceList];
}
private function getServiceList($waybillType, $cpCode) {
$serviceList = [];
if ($waybillType == LogisticsConst::waybillWangdian) {
$serviceList = [
$this->getServiceItem('serviceType', $cpCode),
$this->getServiceItem('orderType', $cpCode),
$this->getServiceItem('payType', $cpCode),
];
if ($cpCode == 'ZYKD') {
$serviceList[] = $this->getServiceItem('payType', $cpCode);
$serviceList[] = $this->getServiceItem('insureType', $cpCode);
}
}
return $serviceList;
}
private function getServiceItem($serviceName, $cpCode, $field = null, $name = null, $remark = null) {
$services = [
'serviceType' => [
'name' => '运单类型',
'field' => 'serviceType',
'options' => CommonTool::convertMapToOptions(OrderPrintTool::getWangdianExpressServiceTypeOptions($cpCode)),
'type' => 'select',
],
'orderType' => [
'name' => '订单类型',
'field' => 'orderType',
'options' => CommonTool::convertMapToOptions(OrderPrintTool::getWangdianExpressOrderTypeOptions($cpCode)),
'type' => 'select',
],
'payType' => [
'name' => '运费支付方式',
'field' => 'payType',
'options' => CommonTool::convertMapToOptions(OrderPrintTool::getWangdianExpressPayTypeOptions($cpCode)),
'type' => 'select',
],
'insureType' => [
'name' => '保价',
'field' => 'insureType',
'options' => CommonTool::convertMapToOptions(OrderPrintTool::getGuaranteeTypeMap()),
'type' => 'select',
]
];
$service = $services[$serviceName] ?: null;
if ($service) {
if ($field) {
$service['field'] = $field;
}
if ($name) {
$service['name'] = $name;
}
if ($remark) {
$service['remark'] = $remark;
}
}
return $service;
}
public function getUserExpressDetail($tplId, $operatorInfo) {
$accessToken = $operatorInfo['mallId'];
$mallId = $operatorInfo['accessToken'];
$expressTpl = $this->expressTplRepository->getUserExpressTplById($mallId, $tplId);
$tplMallId = $expressTpl['ownerMallId'] ? : $mallId;
if (empty($expressTpl)) {
throw new CheckClientException('模板不存在');
}
$isWaybill = ($expressTpl['expressType'] == OrderPrintConst::expressTypeDzmd);
$renderData = array(
'expressTpl' => $expressTpl,
'isWaybill' => $isWaybill,
'cropperW' => $isWaybill ? 600 : 980,
'cropperH' => $isWaybill ? 800 : 600,
'defWidth' => $isWaybill ? 100 : 230,
'defHeight' => $isWaybill ? 180 : 126,
);
if (LogisticsConst::isPddWlb($expressTpl['waybillType'])) {
$pddLogisticsCode = $this->logisticsPlatformDao->getCompanyCodeByLogisticsId($expressTpl['logisticsId'], AppConst::appPlatformPdd);
$searchWaybillRet = PddApi::searchPddWaybill($pddLogisticsCode, $accessToken, $expressTpl['wbUserId']);
$waybillApplyInfo = $searchWaybillRet['waybillApplyInfos'][$pddLogisticsCode];
$renderData['pddWaybillBranchList'] = $waybillApplyInfo['branch_account_cols'];
} elseif ($isWaybill && LogisticsConst::isWangdianWlb($expressTpl['waybillType'])) {
$renderData['serviceTypeOptions'] = OrderPrintTool::getWangdianExpressServiceTypeOptions($expressTpl['logisticsCode']);
$renderData['orderTypeOptions'] = OrderPrintTool::getWangdianExpressOrderTypeOptions($expressTpl['logisticsCode']);
}
$renderData['pddWayBillUserMap'] = $this->getPddWayBillUserMap($tplMallId);
$renderData['authUrl'] = PddOAuthUtil::buildWbAuthUrl();
$renderData['serviceList'] = $this->getServiceList($expressTpl['waybillType'], $expressTpl['cpCode']);
return $renderData;
}
public function getPddWayBillUserMap($mallId) {
$userList = $this->wbUserMallDao->getListByMallId($mallId);
$mallInfo = $this->mallRepository->getMallInfo($mallId);
$userMap = [
0 => $mallInfo['mallName']
];
foreach ($userList as $user) {
$userMap[$user['wbUserId']] = $user['userName'].'(站外授权)';
}
return $userMap;
}
}

@ -3821,4 +3821,12 @@ class CommonTool {
$str = $separator. str_replace($separator, " ", $str);
return ltrim(str_replace(" ", "", ucwords($str)), $separator );
}
public static function convertMapToOptions($map) {
$options = [];
foreach ($map as $key => $value) {
$options[] = ['label' => $value, 'value' => '' . $key];
}
return $options;
}
}

@ -579,39 +579,55 @@ class OrderPrintTool{
public static function getWangdianExpressServiceTypeOptions($logisticsCode) {
if ($logisticsCode == LogisticsConst::SF) {
return array(
'1' => '顺丰标快',
'2' => '顺丰特惠',
'3' => '电商特惠',
'4' => '四日件',
'5' => '顺丰次晨',
'6' => '顺丰即日',
'7' => '电商速配',
'11' => '医药常温',
'12' => '医药温控',
'13' => '物流普运',
'14' => '冷运到家',
'15' => '生鲜速配',
'16' => '大闸蟹专递',
'17' => '汽配吉运',
'18' => '重货快运',
'20' => '行邮专列',
'21' => '医药转运(常温)',
'22' => '医药转运(温控)',
'28' => '电商专配',
'34' => '即日2200',
'35' => '物资配送',
'36' => '汇票专送',
'110' => '证照专递产品',
'112' => '顺丰空配',
'125' => '专线普运',
'134' => '夜配',
'153' => '重货包裹',
'155' => '小票零担',
'195' => '医药常温(陆)',
'202' => '顺丰微小件',
'203' => '医药快运',
'204' => '陆运微小件 ',
'208' => '特惠专配',
'1' => '顺丰特快',
'2' => '顺丰标快',
'6' => '顺丰即日',
'10' => '国际小包',
'12' => '国际特惠配送',
'23' => '顺丰国际特惠(文件)',
'24' => '顺丰国际特惠(包裹)',
'29' => '国际电商专递-标准',
'30' => '三号便利箱(特快)',
'31' => '便利封/袋(特快)',
'32' => '二号便利箱(特快)',
'33' => '岛内件(80CM)',
'35' => '物资配送',
'39' => '岛内件(110CM)',
'50' => '千点取60',
'53' => '电商盒子F1',
'54' => '电商盒子F2',
'59' => 'E顺递',
'60' => '顺丰特快(文件)',
'61' => 'C1类包裹',
'111' => '顺丰干配',
'153' => '整车直达',
'154' => '重货包裹',
'155' => '标准零担',
'199' => '特快包裹',
'201' => '冷运标快',
'202' => '顺丰微小件',
'209' => '高铁专送',
'215' => '大票直送',
'221' => '香港冷运到家(≤60厘米)',
'229' => '精温专递',
'231' => '陆运包裹',
'233' => '精温专递(样本陆)',
'235' => '极效前置-预售',
'238' => '纯重特配',
'242' => '丰网速运',
'247' => '电商标快',
'250' => '极置店配',
'255' => '顺丰卡航',
'256' => '顺丰卡航D类',
'257' => '退换上门',
'258' => '退换自寄',
'260' => '入仓电标',
'261' => 'O2O店配',
'263' => '同城半日达',
'265' => '预售电标',
'266' => '顺丰空配(新)',
'283' => '填舱标快',
'285' => '填舱电标',
);
} elseif ($logisticsCode == LogisticsConst::YTO) {
return array(
@ -639,6 +655,26 @@ class OrderPrintTool{
);
}
}
public static function getWangdianExpressPayTypeOptions($cpCode){
if($cpCode == LogisticsConst::ZYKD){
return [
LogisticsConst::zhongyouPayTypeSendPay => '寄付',
LogisticsConst::zhongyouPayTypeReceiverPay => '到付',
LogisticsConst::zhongyouPayTypeMonthPay => '月结'
];
}else{
return [];
}
}
public static function getGuaranteeTypeMap() {
return array(
LogisticsConst::guaranteeTypeNo => '不保价',
LogisticsConst::guaranteeTypeOrderAmount => '订单金额保价',
LogisticsConst::guaranteeTypeCustom => '声明价值保价'
);
}
public static function getJdAlphaOrderPayTypeOptions() {
return array(

@ -2,6 +2,9 @@
abstract class PddApiAbstract {
/**
* @var PddOAuthClient
*/
protected static $client;
/**

Loading…
Cancel
Save