Merge branch 'master' of codeup.aliyun.com:64d9c5feeceb191898f636d7/honor-dd-light-ds-java into ljl-dsPurchaseOrder

20230922-ljl-fixBug
ljl 1 year ago
commit 743b75a7a7

@ -5,8 +5,8 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \
--data-raw '{
"appId":"7264840234423027259",
"authId":"4463798",
"method":"getShopCloudHotProducts",
"data":"{\"sourceChannelCode\":\"query_none_less\",\"pageSize\":20,\"pageNo\":1}"
"method":"getFreightTemplateList",
"data":"{}"
}'

@ -0,0 +1,649 @@
<?php
class QueueDao {
private $db;
/**
*
* @var TimerDao
*/
private $timerDao;
private $reviveQueueLog;
private $solidRedis;
public function __construct() {
$this->db = Zc::getDb();
$this->timerDao = Zc::singleton("TimerDao");
$this->reviveQueueLog = Zc::getLog('timer/check/revive_queue');
$this->solidRedis = RedisExt::factory('solidCache');
}
public function addQueueMsg($queueName, $shopId, $app, $accessToken, $priority = 100) {
$ret = $this->db->insert($queueName, array (
'shop_id' => $shopId,
'app' => $app,
// 'access_token' => $accessToken, //为了安全起见,不再存这个段,在同步的时候实时取
'priority' => $priority,
'locked' => 0,
'gmt_create' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
));
return ($ret === false) ? false : $this->db->lastInsertId();
}
public function getQueueMsg($queueName, $queueId) {
return $this->db->queryFirstRow('select * from %b where %b = %i', $queueName, QueueConst::getQueueIdColumnName($queueName), $queueId);
}
public function unlockTimeoutQueue($queueName, $expiredSeconds = 300, $status = null) {
$deadTime = date('Y-m-d H:i:s', strtotime("-$expiredSeconds second"));
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$where = $this->db->prepare('WHERE locked > 0 AND gmt_last_heartbeat < %s', $deadTime);
if ($status) {
$where .= ' ' . $this->db->prepare('and `status` = %s', $status);
}
$queueList = $this->db->useDbIdOnce($realDb)->query('SELECT * FROM %b %l', $queueName, $where);
if (empty($queueList)) {
return 0;
}
list($realTimerDb, $realTimerLockTbl) = DbRoute::getDbAndTbl('timer_lock');
$queueIdColumnName = QueueConst::getQueueIdColumnName($queueName);
foreach ($queueList as $queue) {
$ar1 = $this->db->useDbIdOnce($realDb)->update($realTbl, array(
'locked' => 0,
'gmt_modified' => ZcDbEval::now()
), '%b = %i', $queueIdColumnName, $queue[$queueIdColumnName]);
$ar2 = $this->timerDao->deleteTimerLock($queue['locked'], $realTimerDb, '', $queue['hostname']);
$this->reviveQueueLog->info('unlockQueue queue ' . ZcArrayHelper::sp($queue) . ", unlockedQueue $ar1, deleteTimerLock: $ar2");
}
return count($queueList);
}
public function unlockSolidRedisDeadQueue($queueName, $expiredSeconds = 300, $status = null) {
$deadTime = date('Y-m-d H:i:s', strtotime("-$expiredSeconds second"));
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$where = $this->db->prepare('WHERE locked > 0 AND gmt_last_heartbeat < %s', $deadTime);
if ($status) {
$where .= ' ' . $this->db->prepare('and `status` = %s', $status);
}
$queueList = $this->db->useDbIdOnce($realDb)->query('SELECT * FROM %b %l', $realTbl, $where);
if (empty($queueList)) {
return 0;
}
list($realTimerDb, $realTimerLockTbl) = DbRoute::getDbAndTbl('timer_lock');
$queueIdColumnName = QueueConst::getQueueIdColumnName($queueName);
foreach ($queueList as $queue) {
$ar1 = $this->db->useDbIdOnce($realDb)->update($realTbl, array(
'locked' => 0,
'gmt_modified' => ZcDbEval::now()
), '%b = %i', $queueIdColumnName, $queue[$queueIdColumnName]);
$queueId = $queue[$queueIdColumnName];
if ($queueId) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueName, CommonTool::isCurrAdminSelfShop($queue['shop_id']));
$this->solidRedis->lPush($queueRedisKey, $queueId);
}
$ar2 = $this->timerDao->deleteTimerLock($queue['locked'], $realTimerDb, '', $queue['hostname']);
$this->reviveQueueLog->info('unlockQueue queue ' . ZcArrayHelper::sp($queue) . ", unlockedQueue $ar1, deleteTimerLock: $ar2");
}
return count($queueList);
}
public function unlockSolidRedisSkipQueue($queueName, $status = null) {
$queueRedisKeySelf = RedisKeyConst::getQueueRedisKey($queueName, true);
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueName, false);
$selfRedisIds = $this->solidRedis->lrange($queueRedisKeySelf, 0, -1) ?: [];
$redisIds = $this->solidRedis->lrange($queueRedisKey, 0, -1) ?: [];
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$where = '';
if ($status) {
$where = $this->db->prepare('AND `status` = %s', $status);
}
$queueIdColumnName = QueueConst::getQueueIdColumnName($queueName);
$startQueueId = 0;
$limit = 100;
$allQueueList = array();
while (true) {
if ($startQueueId > 0) {
$queueIdWhere = $this->db->prepare('AND %b > %i', $queueIdColumnName, $startQueueId);
}
$queueList = $this->db->useDbIdOnce($realDb)->query('SELECT * FROM %b WHERE locked = 0 %l %l order by %b asc limit %i', $realTbl, $where, $queueIdWhere, $queueIdColumnName, $limit);
if (empty($queueList)) {
break;
}
$startQueueId = end($queueList)[$queueIdColumnName];
$allQueueList = array_merge($allQueueList, $queueList);
if (count($queueList) < $limit) {
break;
}
}
if (empty($allQueueList)) {
return 0;
}
$newSelfRedisIds = $this->solidRedis->lrange($queueRedisKeySelf, 0, -1) ?: [];
$newRedisIds = $this->solidRedis->lrange($queueRedisKey, 0, -1) ?: [];
$selfRedisIds = array_unique(array_merge($selfRedisIds, $newSelfRedisIds));
$redisIds = array_unique(array_merge($redisIds, $newRedisIds));
foreach ($allQueueList as $queue) {
$queueId = $queue[$queueIdColumnName];
if ($queueId) {
if (in_array($queueId, $selfRedisIds) || in_array($queueId, $redisIds)) {
continue;
}
if (in_array($queue['shop_id'], CommonTool::adminSelfShopIds())) {
$this->solidRedis->lPush($queueRedisKeySelf, $queueId);
} else {
$this->solidRedis->lPush($queueRedisKey, $queueId);
}
}
}
return count($queueList);
}
public function getQueueMsgList($queueName, $shopId) {
return $this->db->query('select * from %b where shop_id = %i order by gmt_modified asc', $queueName, $shopId);
}
public function updateQueuePriority($queueName, $queueId, $priority) {
$ret = $this->db->update($queueName, array('priority' => $priority), '%b = %i', QueueConst::getQueueIdColumnName($queueName), $queueId);
return $ret;
}
public function insertUpdateShopQueue($queueName, $shopId, $priority = 100) {
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$queueInfo = $this->db->useDbIdOnce($realDb)->queryFirstRow("select * FROM %b WHERE shop_id = %i", $realTbl, $shopId);
if (!$queueInfo) {
$insert = array (
'shop_id' => $shopId,
'locked' => 0,
'priority' => $priority,
'gmt_create' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
);
return $this->db->useDbIdOnce($realDb)->insert($realTbl, $insert);
}
if (($queueInfo['locked'] > 0) || ($queueInfo['priority'] <= $priority)) {
return true;
}
$update = array(
'priority' => $priority,
'gmt_modified' => ZcDbEval::now()
);
return $this->db->useDbIdOnce($realDb)->update($realTbl, $update, 'shop_id = %i', $shopId);
}
public function deleteShopQueue($queueName, $shopId) {
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
return $this->db->useDbIdOnce($realDb)->delete($realTbl, 'shop_id = %i',$shopId);
}
public function lockQueueMsg($timerLockId, $filter) {
$queueName = $filter['queueName'];
$where = '';
if ($queueName != QueueConst::titleKeywordRsyncQueue) {
if ($filter['includeShopIds']) {
$where = $this->db->prepare('and shop_id in %li', $filter['includeShopIds']);
}
if ($filter['excludeShopIds']) {
$where = $this->db->prepare('and shop_id not in %li', $filter['excludeShopIds']);
}
}
$row = $this->db->queryFirstRow("select * from %b where `locked` = 0 %l order by priority asc, gmt_modified asc", $queueName, $where);
if (empty($row)) {
return $row;
}
// 乐观锁
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
$queueId = $row[$primaryColumn];
$affectRows = $this->db->update($queueName, array (
'locked' => $timerLockId,
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i and locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$row['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $row;
}
return array ();
}
public function lockQueueRandom($timerLockId, $queueName, $filter) {
$batchTypeWhere = '';
$where = array();
if (!empty($filter['includeShopIds'])) {
$where[] = $this->db->prepare('and shop_id in %li', $filter['includeShopIds']);
}
if (!empty($filter['excludeShopIds'])) {
$where[] = $this->db->prepare('and shop_id not in %li', $filter['excludeShopIds']);
}
$whereString = implode(' ', $where);
$shopIds = $this->db->queryFirstColumn("select distinct `shop_id` from %b where `locked` = 0 %l %l", $queueName, $whereString);
if (empty($shopIds)) {
return array();
}
$shopId = $shopIds[array_rand($shopIds, 1)];
$queueMsg = $this->db->queryFirstRow('SELECT * FROM %b WHERE `shop_id` = %i AND locked = 0 %l', $queueName, $shopId);
if (empty($queueMsg)) {
return array();
}
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
$queueId = $queueMsg[$primaryColumn];
$affectRows = $this->db->update($queueName, array (
'locked' => $timerLockId,
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i AND locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$queueMsg['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $queueMsg;
}
return array ();
}
public function deleteQueueMsg($queueName, $row) {
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
return $this->db->useDbIdOnce($realDb)->delete($realTbl, '%b = %i', $primaryColumn, $row[$primaryColumn]);
}
/**
* 根据 priority asc、queueId asc 来 lockQueue支持根据includeVenderIds、excludeVenderIds、gmtExec来筛选
* @param integer $timerLockId
* @param string $queueName
* @param array $filter
* @return array
*/
public function lockPriorityQueue($timerLockId, $queueName, $filter) {
list ($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($realTbl);
$sortBy = $primaryColumn;
$where = array();
if ($filter['includeShopIds']) {
$where[] = $this->db->prepare('and shop_id in %li', $filter['includeShopIds']);
}
if ($filter['excludeShopIds']) {
$where[] = $this->db->prepare('and shop_id not in %li', $filter['excludeShopIds']);
}
if ($filter['gmtExec']) {
$where[] = $this->db->prepare('and (gmt_exec is null or gmt_exec <= %s)', date('Y-m-d H:i:s', strtotime($filter['gmtExec'])));
$sortBy = 'gmt_exec';
}
$whereString = implode(' ', $where);
$row = $this->db->useDbIdOnce($realDb)->queryFirstRow("select * from %b where `locked` = 0 %l order by priority asc, %b asc", $realTbl, $whereString, $sortBy);
if (empty($row)) {
return array();
}
// 乐观锁
$queueId = $row[$primaryColumn];
$affectRows = $this->db->useDbIdOnce($realDb)->update($realTbl, array (
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i and locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$row['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $row;
}
return array ();
}
/**
* 根据 queueId asc 来 lockQueue支持根据includeVenderIds、excludeVenderIds、gmtExec来筛选
* @param integer $timerLockId
* @param string $queueName
* @param array $filter
* @return array
*/
public function lockFifoQueue($timerLockId, $queueName, $filter) {
list ($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($realTbl);
$sortBy = $primaryColumn;
$where = '';
if ($filter['includeShopIds']) {
$where[] = $this->db->prepare('and shop_id in %li', $filter['includeShopIds']);
}
if ($filter['excludeShopIds']) {
$where[] = $this->db->prepare('and shop_id not in %li', $filter['excludeShopIds']);
}
if ($filter['gmtExec']) {
$where[] = $this->db->prepare('and (gmt_exec is null or gmt_exec <= %s)', date('Y-m-d H:i:s', strtotime($filter['gmtExec'])));
$sortBy = 'gmt_exec';
}
$whereString = implode(' ', $where);
$row = $this->db->useDbIdOnce($realDb)->queryFirstRow("select * from %b where `locked` = 0 %l order by %b asc", $realTbl, $whereString, $sortBy);
if (empty($row)) {
return array();
}
// 乐观锁
$queueId = $row[$primaryColumn];
$affectRows = $this->db->useDbIdOnce($realDb)->update($realTbl, array (
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i and locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$row['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $row;
}
return array ();
}
/**
* 根据 venderId 平均 lockQueue支持根据includeVenderIds、excludeVenderIds、gmtExec来筛选
* @param integer $timerLockId
* @param string $queueName
* @param array $filter
* @return array
*/
public function lockVenderAvgQueue($timerLockId, $queueName, $filter) {
$where = array();
if (!empty($filter['includeShopIds'])) {
$where[] = $this->db->prepare('and shop_id in %li', $filter['includeShopIds']);
}
if (!empty($filter['excludeShopIds'])) {
$where[] = $this->db->prepare('and shop_id not in %li', $filter['excludeShopIds']);
}
if (!empty($filter['gmtExec'])) {
$where[] = $this->db->prepare('and (gmt_exec is null or gmt_exec <= %s)', date('Y-m-d H:i:s', strtotime($filter['gmtExec'])));
}
$whereString = implode(' ', $where);
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($realTbl);
$shopIds = $this->db->useDbIdOnce($realDb)->queryFirstColumn("select distinct `shop_id` from %b where `locked` = 0 %l %l", $realTbl, $whereString);
if (empty($shopIds)) {
return array();
}
$shopId = $shopIds[array_rand($shopIds, 1)];
$queueMsg = $this->db->useDbIdOnce($realDb)->queryFirstRow('SELECT * FROM %b WHERE `shop_id` = %i AND locked = 0 %l ORDER BY %l ASC', $realTbl, $shopId, $whereString, $primaryColumn);
if (empty($queueMsg)) {
return array();
}
$queueId = $queueMsg[$primaryColumn];
$affectRows = $this->db->useDbIdOnce($realDb)->update($queueName, array (
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i AND locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$queueMsg['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $queueMsg;
}
return array ();
}
/**
* 根据 redis 中弹出的id来锁定queue
* @param integer $timerLockId
* @param string $queueName
* @param boolean $isAdminSelf
* @return array
*/
public function lockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueName, $isAdminSelf);
$queueId = $this->solidRedis->rPop($queueRedisKey);
if (empty($queueId)) {
return array();
}
list ($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
$row = $this->db->useDbIdOnce($realDb)->queryFirstRow("select * from %b where `locked` = 0 and %b = %i", $realTbl, $primaryColumn, $queueId);
if (empty($row)) {
return array();
}
$queueId = $row[$primaryColumn];
$affectRows = $this->db->useDbIdOnce($realDb)->update($realTbl, array(
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i and locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$row['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $row;
}
return array();
}
public function batchLockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf, $lockCount) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueName, $isAdminSelf);
$queueIds = [];
for ($i = 0; $i < $lockCount; $i++) {
$queueId = $this->solidRedis->rPop($queueRedisKey);
if (!$queueId) {
break;
}
$queueIds[] = $queueId;
}
if (!$queueIds) {
return [];
}
list ($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
$rows = $this->db->useDbIdOnce($realDb)->query("select * from %b where `locked` = 0 and %b in %li", $realTbl, $primaryColumn, $queueIds);
if (empty($rows)) {
return [];
}
$findQueueIds = array_column($rows, $primaryColumn);
$affectRows = $this->db->useDbIdOnce($realDb)->update($realTbl, array(
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b in %li and locked = 0", $primaryColumn, $findQueueIds);
if (count($findQueueIds) == $affectRows) {
$rows = array_map(function ($row) use ($timerLockId) {
$row['locked'] = $timerLockId;
return $row;
}, $rows);
$this->timerDao->updateTimerLockHeartbeat($timerLockId, null);
return $rows;
}
Zc::getLog("timer/batch_lock_fail/{$queueName}")->info("find queueIds[" . implode(',', $findQueueIds) . "] lock affectRows[$affectRows]");
return [];
}
/**
* 根据 redis 中弹出的id来锁定queue
* @param integer $timerLockId
* @param string $queueName
* @param boolean $isAdminSelf
* @return array
*/
public function lockSolidRedisQueueByBufferId($timerLockId, $queueName, $isAdminSelf, $bufferPrimaryColumn) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueName, $isAdminSelf);
$bufferId = $this->solidRedis->rPop($queueRedisKey);
if (empty($bufferId)) {
return array();
}
list ($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$row = $this->db->useDbIdOnce($realDb)->queryFirstRow("select * from %b where `locked` = 0 and %b = %i", $realTbl, $bufferPrimaryColumn, $bufferId);
if (empty($row)) {
return array();
}
$primaryColumn = QueueConst::getQueueIdColumnName($queueName);
$queueId = $row[$primaryColumn];
$affectRows = $this->db->useDbIdOnce($realDb)->update($realTbl, array(
'locked' => $timerLockId,
'hostname' => gethostname(),
'gmt_last_heartbeat' => ZcDbEval::now(),
'gmt_locked' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
), "%b = %i and locked = 0", $primaryColumn, $queueId);
if ($affectRows == 1) {
$row['locked'] = $timerLockId;
$this->timerDao->addHeartbeat($timerLockId, $queueId, $queueName);
return $row;
}
return array();
}
public function addMonitorRedisLockErrorLog($queueName, $timerLockId, $primaryKeyId, $sql, $reason) {
list($logDbId, $realLogTbl) = DbRoute::getDbAndTbl(TblConst::redis_lock_error_log);
return $this->db->useDbIdOnce($logDbId)->insert($realLogTbl, array(
'queue_name' => $queueName,
'timer_lock_id' => $timerLockId,
'primary_key_id' => $primaryKeyId,
'sql' => $sql,
'reason' => $reason,
'hostname' => gethostname(),
'gmt_create' => ZcDbEval::now(),
'gmt_modified' => ZcDbEval::now()
));
}
public function allocBufferToQueueByShopAvg($bufferName, $queueName, $filter, $maxQueueCount = 300, $shopLimit = null) {
$allowMoveCnt = $maxQueueCount - $this->getQueueCnt($queueName, $filter);
if ($allowMoveCnt < 1) {
return array();
}
$shopIdAndCntMap = $this->getShopIdAndBufferCntMap($bufferName, $filter);
if (is_numeric($shopLimit)) {
$shopIdAndCntMap = $this->rebuildShopIdAndCntMapByShopLimit($shopIdAndCntMap, $queueName, $shopLimit);
}
return $this->allotShopMoveBufferCnt($shopIdAndCntMap, $allowMoveCnt);
}
private function getQueueCnt($queueName, $filter) {
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$whereStr = $this->getFilterShopIdWhere($filter['includeShopIds'], $filter['excludeShopIds']);
return $this->db->useDbIdOnce($realDb)->queryFirstField("SELECT COUNT(*) FROM %b WHERE %l", $realTbl, $whereStr);
}
private function getShopIdAndBufferCntMap($bufferName, $filter) {
list($realDb, $realTbl) = DbRoute::getDbAndTbl($bufferName);
$whereStr = $this->getFilterShopIdWhere($filter['includeShopIds'], $filter['excludeShopIds'], $filter['gmtExec']);
$bufferList = $this->db->useDbIdOnce($realDb)->query("SELECT shop_id, COUNT(*) AS cnt FROM %b WHERE %l GROUP BY shop_id", $realTbl, $whereStr);
return ZcArrayHelper::mapNameValue($bufferList, 'shop_id', 'cnt');
}
public function getFilterShopIdWhere($includeShopIds, $excludeShopIds, $gmtExec = null) {
$extraWhere = '';
if ($gmtExec) {
$extraWhere = ' ' . $this->db->prepare('and gmt_exec <= %s', date('Y-m-d H:i:s', strtotime($gmtExec)));
}
if (!empty($includeShopIds)) {
return $this->db->prepare('shop_id IN %li', $includeShopIds) . $extraWhere;
}
if (!empty($excludeShopIds)) {
return $this->db->prepare('shop_id not in %li', $excludeShopIds) . $extraWhere;
}
return '1 = 1' . $extraWhere;
}
private function rebuildShopIdAndCntMapByShopLimit($shopIdAndCntMap, $queueName, $shopLimit) {
if (empty($shopIdAndCntMap) || !is_numeric($shopLimit)) {
return $shopIdAndCntMap;
}
list($realDb, $realTbl) = DbRoute::getDbAndTbl($queueName);
$queueStatList = $this->db->useDbIdOnce($realDb)->query("SELECT shop_id, COUNT(*) AS cnt FROM %b GROUP BY shop_id", $realTbl);
$shopIdAndQueueCntMap = ZcArrayHelper::mapNameValue($queueStatList, 'shop_id', 'cnt');
foreach ($shopIdAndCntMap as $shopId => $cnt) {
$shopAllowMoveMaxCnt = $shopLimit - $shopIdAndQueueCntMap[$shopId];
$shopAllowMoveCnt = min(array($cnt, $shopAllowMoveMaxCnt));
if ($shopAllowMoveCnt < 1) {
unset($shopIdAndCntMap[$shopId]);
continue;
}
$shopIdAndCntMap[$shopId] = $shopAllowMoveCnt;
}
return $shopIdAndCntMap;
}
private function allotShopMoveBufferCnt($shopIdAndCntMap, $allowMoveCnt){
$shopIdAndMoveCntMap = array();
$waitSelectShopIds = array_keys($shopIdAndCntMap);
shuffle($waitSelectShopIds);
do {
if (empty($waitSelectShopIds) || ($allowMoveCnt < 1)) {
break;
}
foreach ($waitSelectShopIds as $index => $mallId) {
if ($allowMoveCnt < 1) {
break;
}
$waitMoveCnt = $shopIdAndCntMap[$mallId];
if ($waitMoveCnt < 1) {
unset($waitSelectShopIds[$index]);
continue;
}
$shopIdAndMoveCntMap[$mallId]++;
$shopIdAndCntMap[$mallId]--;
$allowMoveCnt--;
}
} while(true);
return $shopIdAndMoveCntMap;
}
}

@ -0,0 +1,201 @@
<?php
class QueueService {
/**
*
* @var QueueDao
*/
private $queueDao;
private $db;
private $solidRedis;
public function __construct() {
$this->queueDao = Zc::singleton('QueueDao');
$this->db = Zc::getDb();
$this->solidRedis = RedisExt::factory('solidCache');
}
public function getQueueMsgList($queueName, $shopId) {
return $this->queueDao->getQueueMsgList($queueName, $shopId);
}
public function getQueueMsg($queueName, $queueId) {
return $this->queueDao->getQueueMsg($queueName, $queueId);
}
public function addQueueMsg($queueName, $shopId, $app, $accessToken) {
return $this->queueDao->addQueueMsg($queueName, $shopId, $app, $accessToken);
}
public function lockQueueMsg($timerLockId, $filter) {
return $this->queueDao->lockQueueMsg($timerLockId, $filter);
}
public function unlockTimeoutQueue($queueName, $expiredSeconds = 300, $status = null) {
return $this->queueDao->unlockTimeoutQueue($queueName, $expiredSeconds, $status);
}
public function unlockTimeoutSolidRedisQueue($queueName, $heartbeatExpiredSeconds = 300, $status = null) {
$c1 = $this->queueDao->unlockSolidRedisDeadQueue($queueName, $heartbeatExpiredSeconds, $status);
$c2 = $this->queueDao->unlockSolidRedisSkipQueue($queueName, $status);
return $c1 + $c2;
}
public function deleteQueueMsg($queueName, $row) {
return $this->queueDao->deleteQueueMsg($queueName, $row);
}
public function lockPriorityQueue($timerLockId, $queueName, $filter) {
return $this->queueDao->lockPriorityQueue($timerLockId, $queueName, $filter);
}
public function lockFifoQueue($timerLockId, $queueName, $filter) {
return $this->queueDao->lockFifoQueue($timerLockId, $queueName, $filter);
}
public function lockVenderAvgQueue($timerLockId, $queueName, $filter) {
return $this->queueDao->lockVenderAvgQueue($timerLockId, $queueName, $filter);
}
public function lockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf) {
return $this->queueDao->lockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf);
}
public function batchLockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf, $lockCount) {
return $this->queueDao->batchLockSolidRedisQueue($timerLockId, $queueName, $isAdminSelf, $lockCount);
}
public function lockSolidRedisQueueByBufferId($timerLockId, $queueName, $isAdminSelf, $bufferPrimaryColumn) {
return $this->queueDao->lockSolidRedisQueueByBufferId($timerLockId, $queueName, $isAdminSelf, $bufferPrimaryColumn);
}
public function allocBufferToQueueByShopAvg($bufferName, $queueName, $filter, $maxQueueCount = 300, $shopLimit = null) {
return $this->queueDao->allocBufferToQueueByShopAvg($bufferName, $queueName, $filter, $maxQueueCount, $shopLimit);
}
public function moveBufferToSolidRedisQueue($bufferTableName, $queueTableName, $filter, $maxQueueCount = 2000) {
list($realDbId, $bufferTbl) = DbRoute::getDbAndTbl($bufferTableName);
list($realDbId, $queueTbl) = DbRoute::getDbAndTbl($queueTableName);
$wheres = [];
if ($filter['gmtExec']) {
$wheres[] = $this->db->prepare('and (gmt_exec is null or gmt_exec <= %s)', $filter['gmtExec']);
}
if ($filter['includeShopIds']) {
$wheres[] = $this->db->prepare('AND shop_id IN %li', $filter['includeShopIds']);
}
$queueCount = $this->db->useDbIdOnce($realDbId)->queryFirstField('select count(*) from %b', $queueTbl);
if ($queueCount > $maxQueueCount) {
return false;
}
$needMoveQueueCount = $maxQueueCount - $queueCount;
$limit = 100;
$stopFilePath = Zc::C(ZcConfigConst::LogDir) . "stop_do_move_{$bufferTableName}_to_queue";
$bufferPrimaryField = QueueConst::getQueueIdColumnName($bufferTbl);
$startBufferId = 0;
while (true) {
if (file_exists($stopFilePath)) {
break;
}
if ($needMoveQueueCount <= 0) {
break;
}
$loopWheres = $wheres;
$loopWheres[] = $this->db->prepare('AND %l > %i', $bufferPrimaryField, $startBufferId);
$whereStr = implode(' ', $loopWheres);
$loopLimit = $needMoveQueueCount > $limit ? $limit : $needMoveQueueCount;
$bufferList = $this->db->useDbIdOnce($realDbId)->query('select * from %b where 1=1 %l order by %l asc limit %i', $bufferTbl, $whereStr, $bufferPrimaryField, $loopLimit);
if (empty($bufferList)) {
break;
}
$deleteBufferIds = [];
$queueDatas = [];
foreach ($bufferList as $bufferData) {
$startBufferId = $bufferData[$bufferPrimaryField];
if (!$filter['includeShopIds'] && CommonTool::isCurrAdminSelfShop($bufferData['shop_id'])) {
continue;
}
$deleteBufferIds[] = $bufferData[$bufferPrimaryField];
$tmpBufferData = $bufferData;
unset($tmpBufferData['gmt_exec']);
unset($tmpBufferData[$bufferPrimaryField]);
$tmpBufferData['locked'] = 0;
$tmpBufferData['gmt_create'] = ZcDbEval::now();
$tmpBufferData['gmt_modified'] = ZcDbEval::now();
$queueDatas[] = $tmpBufferData;
}
$oldErrorMode = $this->db->setErrorMode(ZcDb::ERROR_MODE_EXCEPTION);
$transStatus = $this->db->useDbIdOnce($realDbId)->startTransaction();
try {
if ($queueDatas) {
$this->db->useDbIdOnce($realDbId)->insert($queueTbl, $queueDatas);
$startQueueId = $this->db->lastInsertId();
}
if ($deleteBufferIds) {
$this->db->useDbIdOnce($realDbId)->delete($bufferTbl, '%l IN %li', $bufferPrimaryField, $deleteBufferIds);
}
$this->db->useDbIdOnce($realDbId)->commit($transStatus);
$this->db->setErrorMode($oldErrorMode);
} catch (Exception $e) {
$this->db->useDbIdOnce($realDbId)->rollback($transStatus);
$this->db->setErrorMode($oldErrorMode);
break;
}
$selfQueueIds = $notSelfQueueIds = [];
if (!empty($startQueueId)) {
$queueCount = count($queueDatas);
$queueIdLoop = 0;
for ($queueId = $startQueueId; $queueId < ($queueCount + $startQueueId); $queueId ++) {
$loopQueueData = $queueDatas[$queueIdLoop];
if (CommonTool::isCurrAdminSelfShop($loopQueueData['shop_id'])) {
$selfQueueIds[] = $queueId;
} else {
$notSelfQueueIds[] = $queueId;
}
$queueIdLoop ++;
}
}
Zc::getLog('timer/common/move_buffer_to_queue/move_buffer')->info("loop startBufferId[{$startBufferId}]");
if ($selfQueueIds) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueTbl, true);
$redisRet = $this->solidRedis->lPush($queueRedisKey, ...$selfQueueIds);
if (false === $redisRet) {
/** @var Exception $ex */
$ex = $this->solidRedis->lastException();
$reason = $ex ? $ex->getMessage() : "emptyEx";
Zc::getLog('timer/common/move_buffer_to_queue/move_buffer')->info("addQueueIdsToSolidRedisQueue[$queueRedisKey] -> reason : " . $reason);
}
}
if ($notSelfQueueIds) {
$queueRedisKey = RedisKeyConst::getQueueRedisKey($queueTbl, false);
$redisRet = $this->solidRedis->lPush($queueRedisKey, ...$notSelfQueueIds);
if (false === $redisRet) {
/** @var Exception $ex */
$ex = $this->solidRedis->lastException();
$reason = $ex ? $ex->getMessage() : "emptyEx";
Zc::getLog('timer/common/move_buffer_to_queue/move_buffer')->info("addQueueIdsToSolidRedisQueue[$queueRedisKey] -> reason : " . $reason);
}
}
$needMoveQueueCount -= count($deleteBufferIds);
if ($needMoveQueueCount <= 0 || count($bufferList) < $limit) {
break;
}
}
return true;
}
}

@ -0,0 +1,22 @@
package com.ms.api.dto.move;
import lombok.Data;
/*
*
*/
@Data
public class GetFreightTemplateListRequestDTO {
/**
* 1
*/
private String name;
/**
*
*/
private String page;
/**
*
*/
private String size = "100";
}

@ -20,6 +20,11 @@ public class SearchChoicenessSourceItemRequestDTO {
*/
private Integer topCid;
/**
* ID
*/
private Integer cid;
/**
* default/saleCntAsc/saleCntDesc/priceAsc/priceDesc
*/

@ -1,47 +1,48 @@
package com.ms.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.common.Ret;
import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.ItemDTO;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.tool.SecurityTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
@ExtensionService("testSpi")
@Slf4j
public class TestSpiService implements ExtensionServiceHandler<ItemDTO, Ret> {
public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, JSONObject> {
@Autowired
private DsJsonRequestTemplate dsJsonRequestTemplate;
@Override
public BaseResponse<Ret> handle(BaseRequest<ItemDTO> req) {
String resourceFileName = "/getProductCatTree.txt"; // 注意路径的开头是一个斜杠
String lines = null;
try (InputStream is = InputStream.class.getResourceAsStream(resourceFileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
log.info(line);
lines = lines + line;
}
} catch (IOException e) {
log.error(e.getMessage());
public BaseResponse<JSONObject> handle(BaseRequest<ItemDTO> req) {
initHandle(req);
getAuthCode();
String res = null;
HashMap<String, Object> params = new HashMap<>();
params.put("platformItemId", SecurityTool.encodeByAES("1"));
params.put("sourceItemId", "33");
params.put("authCode", authCode);
try {
res = dsJsonRequestTemplate.execute("/micro_move/add_platform_item_to_source_item_relation", params);
log.info("rrrr"+res);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
Map<String, Object> result = new HashMap<>();
result.put("line", lines);
return R.ok(Ret.success(result));
return R.ok(JSON.parseObject(res));
}
}

@ -1,7 +1,5 @@
package com.ms.api.common;
import java.util.List;
import com.jinritemai.cloud.base.api.BaseResponse;
public class R<T> {

@ -0,0 +1,27 @@
package com.ms.api.consts;
public class QueueConst {
public static final String orderCareRsyncQueue = "order_care_rsync_queue";
public static final String orderFullRsyncQueue = "order_full_rsync_queue";
public static final String orderQuickRsyncQueue = "order_quick_rsync_queue";
public static final String wareQuickRsyncQueue = "ware_quick_rsync_queue";
public static final String wareFullRsyncQueue = "ware_full_rsync_queue";
public static final String crmMemberFullRsyncQueue = "crm_member_full_rsync_queue";
public static final String crmMemberQuickRsyncQueue = "crm_member_quick_rsync_queue";
public static final String titleKeywordRsyncQueue = "title_keyword_rsync_queue";
public static final String statusProcessing = "processing";
public static final String statusWait = "wait";
public static final String statusFinish = "finish";
public static final Integer maxMoveImportTaskQueueCount = 1000;
public static final Integer maxMoveImportTaskQueueCountSelf = 50;
public static String getQueueIdColumnName(String queueName) {
return queueName.concat("_id");
}
}

@ -2,6 +2,8 @@ package com.ms.api.service;
import com.ms.dal.entity.DoudianMsg;
import java.util.List;
/**
*
*/
@ -18,4 +20,6 @@ public interface DoudianMsgService {
int updateByPrimaryKeySelective(DoudianMsg record);
int updateByPrimaryKey(DoudianMsg record);
boolean addDoudianMsg(String msgBody);
}

@ -1,5 +1,7 @@
package com.ms.api.service;
import java.util.List;
import com.ms.dal.entity.OpOrderRsyncQueue;
/**
@ -18,4 +20,6 @@ public interface OpOrderRsyncQueueService {
int updateByPrimaryKeySelective(OpOrderRsyncQueue record);
int updateByPrimaryKey(OpOrderRsyncQueue record);
OpOrderRsyncQueue lockSolidRedisQueue(Long timerLockId, boolean isAdminSelf);
}

@ -0,0 +1,21 @@
package com.ms.api.service;
import com.ms.dal.entity.PurchaseOrderCustom;
/**
*
*/
public interface PurchaseOrderCustomService {
int deleteByPrimaryKey(Long id);
int insert(PurchaseOrderCustom record);
int insertSelective(PurchaseOrderCustom record);
PurchaseOrderCustom selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PurchaseOrderCustom record);
int updateByPrimaryKey(PurchaseOrderCustom record);
}

@ -0,0 +1,21 @@
package com.ms.api.service;
import com.ms.dal.entity.PurchaseOrderDsEncrypt;
/**
*
*/
public interface PurchaseOrderDsEncryptService {
int deleteByPrimaryKey(Long id);
int insert(PurchaseOrderDsEncrypt record);
int insertSelective(PurchaseOrderDsEncrypt record);
PurchaseOrderDsEncrypt selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PurchaseOrderDsEncrypt record);
int updateByPrimaryKey(PurchaseOrderDsEncrypt record);
}

@ -0,0 +1,4 @@
package com.ms.api.service;
public interface QueueService {
}

@ -1,21 +1,30 @@
package com.ms.api.service.impl;
import com.ms.dal.entity.DoudianMsg;
import com.ms.api.consts.StatusConst;
import com.ms.api.service.DoudianMsgService;
import com.ms.dal.entity.DoudianMsg;
import com.ms.dal.entity.DoudianMsgParseQueue;
import com.ms.dal.mapper.DoudianMsgMapper;
import com.ms.dal.mapper.DoudianMsgParseQueueMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
*
*/
@Service
public class DoudianMsgServiceImpl implements DoudianMsgService{
public class DoudianMsgServiceImpl implements DoudianMsgService {
@Autowired
private DoudianMsgMapper doudianMsgMapper;
@Autowired
private DoudianMsgParseQueueMapper doudianMsgParseQueueMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return doudianMsgMapper.deleteByPrimaryKey(id);
@ -46,6 +55,30 @@ public class DoudianMsgServiceImpl implements DoudianMsgService{
return doudianMsgMapper.updateByPrimaryKey(record);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean addDoudianMsg(String msgBody) {
DoudianMsg doudianMsgData = new DoudianMsg();
doudianMsgData.setMsgBody(msgBody);
doudianMsgData.setStatus(StatusConst.wait);
doudianMsgData.setGmtCreate(new Date());
doudianMsgData.setGmtModified(new Date());
doudianMsgMapper.insertSelective(doudianMsgData);
DoudianMsgParseQueue doudianMsgParseQueueData = new DoudianMsgParseQueue();
doudianMsgParseQueueData.setDoudianMsgId(doudianMsgData.getDoudianMsgId());
doudianMsgParseQueueData.setLocked(0L);
doudianMsgParseQueueData.setGmtCreate(new Date());
doudianMsgParseQueueData.setGmtModified(new Date());
doudianMsgParseQueueMapper.insertSelective(doudianMsgParseQueueData);
return true;
}
// public boolean addDoudianFailMsg(String msgBody) {
// return true;
// }
}

@ -1,20 +1,27 @@
package com.ms.api.service.impl;
import com.ms.dal.entity.OpOrderRsyncQueue;
import java.util.Date;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.service.OpOrderRsyncQueueService;
import com.ms.dal.entity.OpOrderRsyncQueue;
import com.ms.dal.mapper.OpOrderRsyncQueueMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class OpOrderRsyncQueueServiceImpl implements OpOrderRsyncQueueService{
public class OpOrderRsyncQueueServiceImpl implements OpOrderRsyncQueueService {
@Autowired
private OpOrderRsyncQueueMapper opOrderRsyncQueueMapper;
@Autowired
private RedisTemplate<String, String> redisTemplate;
@Override
public int deleteByPrimaryKey(Long id) {
@ -46,6 +53,30 @@ public class OpOrderRsyncQueueServiceImpl implements OpOrderRsyncQueueService{
return opOrderRsyncQueueMapper.updateByPrimaryKey(record);
}
@Override
public OpOrderRsyncQueue lockSolidRedisQueue(Long timerLockId, boolean isAdminSelf) {
String queueRedisKey = RedisKeyConst.getQueueRedisKey("op_order_rsync_queue", isAdminSelf);
String queueIdRedis = redisTemplate.opsForList().rightPop(queueRedisKey);
if (StrUtil.isBlank(queueIdRedis)) {
return null;
}
OpOrderRsyncQueue row = opOrderRsyncQueueMapper.queryFirstRowByQueueId(queueIdRedis);
if (ObjectUtil.isEmpty(row)) {
return null;
}
Date date = new Date();
row.setLocked(timerLockId);
row.setHostname("");
row.setGmtLastHeartbeat(date);
row.setGmtModified(date);
row.setGmtLocked(date);
int affectRows = opOrderRsyncQueueMapper.updateByPrimaryKey(row);
if (affectRows == 1) {
return row;
}
return null;
}
}

@ -0,0 +1,53 @@
package com.ms.api.service.impl;
import com.ms.dal.entity.PurchaseOrderCustom;
import com.ms.api.service.PurchaseOrderCustomService;
import com.ms.dal.mapper.PurchaseOrderCustomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class PurchaseOrderCustomServiceImpl implements PurchaseOrderCustomService{
@Autowired
private PurchaseOrderCustomMapper purchaseOrderCustomMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return purchaseOrderCustomMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(PurchaseOrderCustom record) {
return purchaseOrderCustomMapper.insert(record);
}
@Override
public int insertSelective(PurchaseOrderCustom record) {
return purchaseOrderCustomMapper.insertSelective(record);
}
@Override
public PurchaseOrderCustom selectByPrimaryKey(Long id) {
return purchaseOrderCustomMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(PurchaseOrderCustom record) {
return purchaseOrderCustomMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(PurchaseOrderCustom record) {
return purchaseOrderCustomMapper.updateByPrimaryKey(record);
}
}

@ -0,0 +1,53 @@
package com.ms.api.service.impl;
import com.ms.dal.entity.PurchaseOrderDsEncrypt;
import com.ms.api.service.PurchaseOrderDsEncryptService;
import com.ms.dal.mapper.PurchaseOrderDsEncryptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class PurchaseOrderDsEncryptServiceImpl implements PurchaseOrderDsEncryptService{
@Autowired
private PurchaseOrderDsEncryptMapper purchaseOrderDsEncryptMapper;
@Override
public int deleteByPrimaryKey(Long id) {
return purchaseOrderDsEncryptMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(PurchaseOrderDsEncrypt record) {
return purchaseOrderDsEncryptMapper.insert(record);
}
@Override
public int insertSelective(PurchaseOrderDsEncrypt record) {
return purchaseOrderDsEncryptMapper.insertSelective(record);
}
@Override
public PurchaseOrderDsEncrypt selectByPrimaryKey(Long id) {
return purchaseOrderDsEncryptMapper.selectByPrimaryKey(id);
}
@Override
public int updateByPrimaryKeySelective(PurchaseOrderDsEncrypt record) {
return purchaseOrderDsEncryptMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(PurchaseOrderDsEncrypt record) {
return purchaseOrderDsEncryptMapper.updateByPrimaryKey(record);
}
}

@ -0,0 +1,30 @@
package com.ms.api.service.impl;
import cn.hutool.core.util.StrUtil;
import com.ms.api.consts.QueueConst;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.service.QueueService;
import com.ms.dal.mapper.QueueMapper;
import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
public class QueueServiceImpl implements QueueService {
private final RedisTemplate<String, String> redisTemplate;
private final QueueMapper queueMapper;
// public void lockSolidRedisQueue(Integer timerLockId, String queueName, boolean isAdminSelf) {
// String queueRedisKey = RedisKeyConst.getQueueRedisKey(queueName, isAdminSelf);
// String queueId = redisTemplate.opsForList().rightPop(queueRedisKey);
// if (StrUtil.isBlank(queueId)) {
// return;
// }
// String primaryColumn = QueueConst.getQueueIdColumnName(queueName);
// queueMapper.queryFirstRow("select * from %b where `locked` = 0 and %b = %i");
//
// }
}

@ -8,7 +8,9 @@ import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.auth.PlatformAuthCallBackRequestDTO;
import com.ms.api.service.DoudianMsgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@ -19,14 +21,36 @@ import java.util.List;
@Slf4j
public class OpenMsgConsumerService extends SPIBaseService implements ExtensionServiceHandler<List<String>, Void> {
@Autowired
private DoudianMsgService doudianMsgService;
@Override
public BaseResponse<Void> handle(BaseRequest<List<String>> req) {
initHandle(req);
// ----参数校验----
List<String> msgList = req.getData();
if (msgList == null || msgList.size() == 0) {
R.ok();
}
String msgBody = JSON.toJSONString(msgList);
// ----逻辑校验----
// ----业务处理----
return R.ok();
boolean addRet = false;
try {
addRet = doudianMsgService.addDoudianMsg(msgBody);
} catch (Exception e) {
log.error(String.format("addDoudianMsg fail, exception: %s", e.getMessage()));
}
if (!addRet) {
log.info(String.format("fail msgBody: %s", JSON.toJSONString(msgList)));
return BaseResponse.<Void>builder().success(false).code("1").build();
}
// 处理成功则返回 true code 0
return BaseResponse.<Void>builder().success(true).code("0").build();
}
}

@ -0,0 +1,49 @@
package com.ms.api.spi.move;
import com.doudian.open.api.freightTemplate_list.data.FreightTemplateListData;
import com.doudian.open.api.freightTemplate_list.param.FreightTemplateListParam;
import com.doudian.open.api.product_isv_getClueList.data.ProductIsvGetClueListData;
import com.doudian.open.api.product_isv_getClueList.param.ProductIsvGetClueListParam;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.common.Ret;
import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.move.GetFreightTemplateListRequestDTO;
import com.ms.api.dto.move.GetShopCloudHotProductsRequestDTO;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.util.DdRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
@ExtensionService("getFreightTemplateList")
@Slf4j
public class GetFreightTemplateList extends SPIBaseService implements ExtensionServiceHandler<GetFreightTemplateListRequestDTO, Ret> {
@Override
public BaseResponse<Ret> handle(BaseRequest<GetFreightTemplateListRequestDTO> req) {
initHandle(req);
// ----参数校验----
GetFreightTemplateListRequestDTO fields = req.getData();
// ----逻辑校验----
// ----业务处理----
FreightTemplateListParam param = new FreightTemplateListParam();
param.setSize(fields.getSize());
FreightTemplateListData data = DdRequestUtil.FreightTemplateListDataRequest(param);
Map<String, Object> result = new HashMap<>();
result.put("data", data.getList());
result.put("total", data.getCount());
// ----结果返回----
return R.ok(Ret.success(result));
}
}

@ -26,10 +26,6 @@ import java.util.Map;
@ExtensionService("getShopCloudHotProducts")
@Slf4j
public class GetShopCloudHotProductsService extends SPIBaseService implements ExtensionServiceHandler<GetShopCloudHotProductsRequestDTO, Ret> {
@Autowired
private DsJsonRequestTemplate dsJsonRequestTemplate;
@Override
public BaseResponse<Ret> handle(BaseRequest<GetShopCloudHotProductsRequestDTO> req) {
initHandle(req);

@ -1,5 +1,6 @@
package com.ms.api.spi.move;
import com.doudian.open.api.freightTemplate_list.FreightTemplateListRequest;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;

@ -42,6 +42,7 @@ public class SearchChoicenessSourceItemService extends SPIBaseService implements
HashMap<String, Object> params = new HashMap<>();
params.put("keyword",fields.getKeyword());
params.put("topCid",fields.getTopCid());
params.put("cid",fields.getCid());
params.put("sort",fields.getSort());
params.put("ruleIds", fields.getRuleIds());
params.put("isHideMoved",fields.getIsHideMoved());

@ -209,7 +209,7 @@ public class SavePurchaseSettingService extends SPIBaseService implements Extens
*/
private boolean checkSignedAutoPayProtocal(Long shopId) throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("userId", SecurityTool.encodeByAES(String.valueOf(shopId)));
params.put("shopId", SecurityTool.encodeByAES(String.valueOf(shopId)));
params.put("platform", CommonConst.PLATFORM);
String res = dsJsonRequestTemplate.execute("/order/getOrderPayProtocolPay", params);
log.info(res);
@ -219,8 +219,8 @@ public class SavePurchaseSettingService extends SPIBaseService implements Extens
log.error("自动扣款协议请求失败,原因:" + jsonObject.getString("reason"));
throw new RuntimeException(jsonObject.getString("reason"));
} else {
JSONArray paymentAgreements = jsonObject.getJSONObject("data").getJSONArray("paymentAgreements");
for (Object paymentAgreement : paymentAgreements) {
JSONObject paymentAgreements = jsonObject.getJSONObject("data").getJSONObject("paymentAgreements");
for (Object paymentAgreement : paymentAgreements.values()) {
JSONObject obj = (JSONObject)paymentAgreement;
String signedStatus = obj.getString("signedStatus");
if (signedStatus.equals("true")) {

@ -0,0 +1,126 @@
package com.ms.api.task;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.util.StrUtil;
import com.ms.api.common.StrObjMap;
import com.ms.api.common.TaskBaseService;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.service.MoveProductPublishQueueService;
import com.ms.api.service.OpOrderRsyncQueueService;
import com.ms.api.tool.CommonTool;
import com.ms.dal.entity.MoveProductPublishBuffer;
import com.ms.dal.entity.MoveProductPublishQueue;
import com.ms.dal.entity.MoveShopConfig;
import com.ms.dal.entity.OpOrderRsyncQueue;
import com.ms.dal.mapper.OpOrderRsyncQueueMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
/**
* move_product_publish_buffer
* move_product_publish_queue
*/
@Configuration
@Component
@Slf4j
public class RsyncOpTaskService extends TaskBaseService {
private static final String TASK_NAME = "RsyncOp";
@Autowired
private OpOrderRsyncQueueService opOrderRsyncQueueService;
/**
*
*/
@Override
public int getCorePoolSiz() {
return 3;
}
/**
*
*/
@Override
public String getTaskExecutorName() {
return "rsyncOpTaskPool";
}
@Bean(name = "rsyncOpTaskPool")
@Override
public Executor getAsyncExecutor() {
return super.getAsyncExecutor();
}
@Resource(name = "rsyncOpTaskPool")
protected Executor taskPool;
@Override
protected Executor getTaskPool() {
return taskPool;
}
@Override
public void runTask() {
super.runTask();
}
/**
*
*/
@Override
public Object getTask() {
return getBuffer(500);
}
/**
*
*
* @param params
* @return
*/
@Override
public Object processTask(Object params) {
Map<Long, Integer> selectMap = (Map<Long, Integer>) params;
log.info("start moveProductPublishBufferToQueue");
Map<Long, Integer> bufferCountMap = bufferToQueue(selectMap);
log.info("end moveProductPublishBufferToQueue ret: " + bufferCountMap.toString());
return bufferCountMap;
}
private Map<Long, Integer> bufferToQueue(Map<Long, Integer> selectMap) {
return new HashMap();
}
/**
*
*
* @param params
*/
@Override
public void clearTask(Object params) {
}
private Map<Long, Integer> getBuffer(int maxQueueCount) {
log.info("handle {}",TASK_NAME);
return new HashMap<>();
}
private void lockRsyncOpQueue(Long timerLockId){
opOrderRsyncQueueService.lockSolidRedisQueue(timerLockId,false);
}
}

@ -8,6 +8,10 @@ import com.doudian.open.api.afterSale_Detail.AfterSaleDetailRequest;
import com.doudian.open.api.afterSale_Detail.AfterSaleDetailResponse;
import com.doudian.open.api.afterSale_Detail.data.AfterSaleDetailData;
import com.doudian.open.api.afterSale_Detail.param.AfterSaleDetailParam;
import com.doudian.open.api.freightTemplate_list.FreightTemplateListRequest;
import com.doudian.open.api.freightTemplate_list.FreightTemplateListResponse;
import com.doudian.open.api.freightTemplate_list.data.FreightTemplateListData;
import com.doudian.open.api.freightTemplate_list.param.FreightTemplateListParam;
import com.doudian.open.api.order_BatchSearchIndex.OrderBatchSearchIndexRequest;
import com.doudian.open.api.order_BatchSearchIndex.OrderBatchSearchIndexResponse;
import com.doudian.open.api.order_BatchSearchIndex.data.OrderBatchSearchIndexData;
@ -200,4 +204,21 @@ public class DdRequestUtil {
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
}
public static FreightTemplateListData FreightTemplateListDataRequest(FreightTemplateListParam param) {
String activeProfile= System.getenv("sys-deploy-env");
if (!"Prod".equals(activeProfile)){
AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID);
}
FreightTemplateListRequest request = new FreightTemplateListRequest();
request.setParam(param);
log.info("=============Dd请求餐素:{}===================", JSONObject.toJSONString(param));
FreightTemplateListResponse response = request.execute();
log.info("=============Dd请求返回:{}===================", JSONObject.toJSONString(response));
boolean success = CommonTool.checkDdApiRequestIsSuccess(response);
if (success && ObjectUtil.isNotEmpty(response.getData())) {
return response.getData();
}
throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
}
}

@ -0,0 +1,70 @@
package com.ms.dal.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName purchase_order_custom
*/
@Data
public class PurchaseOrderCustom implements Serializable {
/**
*
*/
private Long purchaseOrderCustomId;
/**
*
*/
private Long purchaseOrderId;
/**
*
*/
private Long shopId;
/**
*
*/
private BigDecimal customPurchaseOrderPayment;
/**
*
*/
private String customPurchaseOrderBuyer;
/**
*
*/
private String customPurchaseOrderSeller;
/**
*
*/
private Long operateShopId;
/**
*
*/
private String operateIp;
/**
*
*/
private String lastPayFailReason;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,64 @@
package com.ms.dal.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @TableName purchase_order_ds_encrypt
*/
@Data
public class PurchaseOrderDsEncrypt implements Serializable {
/**
*
*/
private Long purchaseOrderDsEncryptId;
/**
*
*/
private Long shopId;
/**
*
*/
private String orderId;
/**
*
*/
private String purchaseOrderSn;
/**
*
*/
private Boolean isSupportEncryptOrder;
/**
*
*/
private Byte isEncryptOrder;
/**
*
*/
private String result;
/**
*
*/
private String reason;
/**
*
*/
private Date gmtCreate;
/**
*
*/
private Date gmtModified;
private static final long serialVersionUID = 1L;
}

@ -27,4 +27,6 @@ public interface OpOrderRsyncQueueMapper {
List<OpOrderRsyncQueue> getByShopId(@Param("shopIds") List<String> shopid);
int insertUpdate(OpOrderRsyncQueue queueInfo);
OpOrderRsyncQueue queryFirstRowByQueueId(@Param("queueId") String queueId);
}

@ -0,0 +1,26 @@
package com.ms.dal.mapper;
import com.ms.dal.entity.PurchaseOrderCustom;
import org.apache.ibatis.annotations.Mapper;
/**
* @Entity com.ms.dal.entity.PurchaseOrderCustom
*/
@Mapper
public interface PurchaseOrderCustomMapper {
int deleteByPrimaryKey(Long id);
int insert(PurchaseOrderCustom record);
int insertOrUpdate(PurchaseOrderCustom record);
int insertSelective(PurchaseOrderCustom record);
PurchaseOrderCustom selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PurchaseOrderCustom record);
int updateByPrimaryKey(PurchaseOrderCustom record);
}

@ -0,0 +1,26 @@
package com.ms.dal.mapper;
import com.ms.dal.entity.PurchaseOrderDsEncrypt;
import org.apache.ibatis.annotations.Mapper;
/**
* @Entity com.ms.dal.entity.PurchaseOrderDsEncrypt
*/
@Mapper
public interface PurchaseOrderDsEncryptMapper {
int deleteByPrimaryKey(Long id);
int insert(PurchaseOrderDsEncrypt record);
int insertOrUpdate(PurchaseOrderDsEncrypt record);
int insertSelective(PurchaseOrderDsEncrypt record);
PurchaseOrderDsEncrypt selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PurchaseOrderDsEncrypt record);
int updateByPrimaryKey(PurchaseOrderDsEncrypt record);
}

@ -0,0 +1,8 @@
package com.ms.dal.mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface QueueMapper {
}

@ -51,6 +51,9 @@
</foreach>
</if>
</select>
<select id="queryFirstRowByQueueId" resultType="com.ms.dal.entity.OpOrderRsyncQueue">
select * from op_order_rsync_queue where `locked` = 0 and op_order_rsync_queue_id = #{queueId}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from op_order_rsync_queue

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.PurchaseOrderCustomMapper">
<resultMap id="BaseResultMap" type="com.ms.dal.entity.PurchaseOrderCustom">
<id property="purchaseOrderCustomId" column="purchase_order_custom_id" jdbcType="BIGINT"/>
<result property="purchaseOrderId" column="purchase_order_id" jdbcType="BIGINT"/>
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
<result property="customPurchaseOrderPayment" column="custom_purchase_order_payment" jdbcType="DECIMAL"/>
<result property="customPurchaseOrderBuyer" column="custom_purchase_order_buyer" jdbcType="VARCHAR"/>
<result property="customPurchaseOrderSeller" column="custom_purchase_order_seller" jdbcType="VARCHAR"/>
<result property="operateShopId" column="operate_shop_id" jdbcType="BIGINT"/>
<result property="operateIp" column="operate_ip" jdbcType="VARCHAR"/>
<result property="lastPayFailReason" column="last_pay_fail_reason" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
purchase_order_custom_id,purchase_order_id,shop_id,
custom_purchase_order_payment,custom_purchase_order_buyer,custom_purchase_order_seller,
operate_shop_id,operate_ip,last_pay_fail_reason,
gmt_create,gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from purchase_order_custom
where purchase_order_custom_id = #{purchaseOrderCustomId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from purchase_order_custom
where purchase_order_custom_id = #{purchaseOrderCustomId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="purchase_order_custom_id" keyProperty="purchaseOrderCustomId" parameterType="com.ms.dal.entity.PurchaseOrderCustom" useGeneratedKeys="true">
insert into purchase_order_custom
( purchase_order_custom_id,purchase_order_id,shop_id
,custom_purchase_order_payment,custom_purchase_order_buyer,custom_purchase_order_seller
,operate_shop_id,operate_ip,last_pay_fail_reason
,gmt_create,gmt_modified)
values (#{purchaseOrderCustomId,jdbcType=BIGINT},#{purchaseOrderId,jdbcType=BIGINT},#{shopId,jdbcType=BIGINT}
,#{customPurchaseOrderPayment,jdbcType=DECIMAL},#{customPurchaseOrderBuyer,jdbcType=VARCHAR},#{customPurchaseOrderSeller,jdbcType=VARCHAR}
,#{operateShopId,jdbcType=BIGINT},#{operateIp,jdbcType=VARCHAR},#{lastPayFailReason,jdbcType=VARCHAR}
,#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP})
</insert>
<update id="insertOrUpdate" keyColumn="purchase_order_custom_id" keyProperty="purchaseOrderCustomId" parameterType="com.ms.dal.entity.PurchaseOrderCustom"
useGeneratedKeys="true">
insert into purchase_order_custom
( purchase_order_custom_id,purchase_order_id,shop_id
,custom_purchase_order_payment,custom_purchase_order_buyer,custom_purchase_order_seller
,operate_shop_id,operate_ip,last_pay_fail_reason
,gmt_create,gmt_modified)
values (#{purchaseOrderCustomId,jdbcType=BIGINT},#{purchaseOrderId,jdbcType=BIGINT},#{shopId,jdbcType=BIGINT}
,#{customPurchaseOrderPayment,jdbcType=DECIMAL},#{customPurchaseOrderBuyer,jdbcType=VARCHAR},#{customPurchaseOrderSeller,jdbcType=VARCHAR}
,#{operateShopId,jdbcType=BIGINT},#{operateIp,jdbcType=VARCHAR},#{lastPayFailReason,jdbcType=VARCHAR}
,#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP})
ON DUPLICATE KEY UPDATE
purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT}, shop_id = #{shopId,jdbcType=BIGINT}, custom_purchase_order_payment = #{customPurchaseOrderPayment,jdbcType=DECIMAL}, custom_purchase_order_buyer = #{customPurchaseOrderBuyer,jdbcType=VARCHAR}, custom_purchase_order_seller = #{customPurchaseOrderSeller,jdbcType=VARCHAR}, operate_shop_id = #{operateShopId,jdbcType=BIGINT}, operate_ip = #{operateIp,jdbcType=VARCHAR}, last_pay_fail_reason = #{lastPayFailReason,jdbcType=VARCHAR}, gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
</update>
<insert id="insertSelective" keyColumn="purchase_order_custom_id" keyProperty="purchaseOrderCustomId" parameterType="com.ms.dal.entity.PurchaseOrderCustom" useGeneratedKeys="true">
insert into purchase_order_custom
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="purchaseOrderCustomId != null">purchase_order_custom_id,</if>
<if test="purchaseOrderId != null">purchase_order_id,</if>
<if test="shopId != null">shop_id,</if>
<if test="customPurchaseOrderPayment != null">custom_purchase_order_payment,</if>
<if test="customPurchaseOrderBuyer != null">custom_purchase_order_buyer,</if>
<if test="customPurchaseOrderSeller != null">custom_purchase_order_seller,</if>
<if test="operateShopId != null">operate_shop_id,</if>
<if test="operateIp != null">operate_ip,</if>
<if test="lastPayFailReason != null">last_pay_fail_reason,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseOrderCustomId != null">#{purchaseOrderCustomId,jdbcType=BIGINT},</if>
<if test="purchaseOrderId != null">#{purchaseOrderId,jdbcType=BIGINT},</if>
<if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
<if test="customPurchaseOrderPayment != null">#{customPurchaseOrderPayment,jdbcType=DECIMAL},</if>
<if test="customPurchaseOrderBuyer != null">#{customPurchaseOrderBuyer,jdbcType=VARCHAR},</if>
<if test="customPurchaseOrderSeller != null">#{customPurchaseOrderSeller,jdbcType=VARCHAR},</if>
<if test="operateShopId != null">#{operateShopId,jdbcType=BIGINT},</if>
<if test="operateIp != null">#{operateIp,jdbcType=VARCHAR},</if>
<if test="lastPayFailReason != null">#{lastPayFailReason,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.PurchaseOrderCustom">
update purchase_order_custom
<set>
<if test="purchaseOrderId != null">
purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="customPurchaseOrderPayment != null">
custom_purchase_order_payment = #{customPurchaseOrderPayment,jdbcType=DECIMAL},
</if>
<if test="customPurchaseOrderBuyer != null">
custom_purchase_order_buyer = #{customPurchaseOrderBuyer,jdbcType=VARCHAR},
</if>
<if test="customPurchaseOrderSeller != null">
custom_purchase_order_seller = #{customPurchaseOrderSeller,jdbcType=VARCHAR},
</if>
<if test="operateShopId != null">
operate_shop_id = #{operateShopId,jdbcType=BIGINT},
</if>
<if test="operateIp != null">
operate_ip = #{operateIp,jdbcType=VARCHAR},
</if>
<if test="lastPayFailReason != null">
last_pay_fail_reason = #{lastPayFailReason,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where purchase_order_custom_id = #{purchaseOrderCustomId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.PurchaseOrderCustom">
update purchase_order_custom
set
purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT},
shop_id = #{shopId,jdbcType=BIGINT},
custom_purchase_order_payment = #{customPurchaseOrderPayment,jdbcType=DECIMAL},
custom_purchase_order_buyer = #{customPurchaseOrderBuyer,jdbcType=VARCHAR},
custom_purchase_order_seller = #{customPurchaseOrderSeller,jdbcType=VARCHAR},
operate_shop_id = #{operateShopId,jdbcType=BIGINT},
operate_ip = #{operateIp,jdbcType=VARCHAR},
last_pay_fail_reason = #{lastPayFailReason,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where purchase_order_custom_id = #{purchaseOrderCustomId,jdbcType=BIGINT}
</update>
</mapper>

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.PurchaseOrderDsEncryptMapper">
<resultMap id="BaseResultMap" type="com.ms.dal.entity.PurchaseOrderDsEncrypt">
<id property="purchaseOrderDsEncryptId" column="purchase_order_ds_encrypt_id" jdbcType="BIGINT"/>
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
<result property="purchaseOrderSn" column="purchase_order_sn" jdbcType="VARCHAR"/>
<result property="isSupportEncryptOrder" column="is_support_encrypt_order" jdbcType="BOOLEAN"/>
<result property="isEncryptOrder" column="is_encrypt_order" jdbcType="TINYINT"/>
<result property="result" column="result" jdbcType="VARCHAR"/>
<result property="reason" column="reason" jdbcType="VARCHAR"/>
<result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
<result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
purchase_order_ds_encrypt_id,shop_id,order_id,
purchase_order_sn,is_support_encrypt_order,is_encrypt_order,
result,reason,gmt_create,
gmt_modified
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from purchase_order_ds_encrypt
where purchase_order_ds_encrypt_id = #{purchaseOrderDsEncryptId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from purchase_order_ds_encrypt
where purchase_order_ds_encrypt_id = #{purchaseOrderDsEncryptId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="purchase_order_ds_encrypt_id" keyProperty="purchaseOrderDsEncryptId" parameterType="com.ms.dal.entity.PurchaseOrderDsEncrypt" useGeneratedKeys="true">
insert into purchase_order_ds_encrypt
( purchase_order_ds_encrypt_id,shop_id,order_id
,purchase_order_sn,is_support_encrypt_order,is_encrypt_order
,result,reason,gmt_create
,gmt_modified)
values (#{purchaseOrderDsEncryptId,jdbcType=BIGINT},#{shopId,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR}
,#{purchaseOrderSn,jdbcType=VARCHAR},#{isSupportEncryptOrder,jdbcType=BOOLEAN},#{isEncryptOrder,jdbcType=TINYINT}
,#{result,jdbcType=VARCHAR},#{reason,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP}
,#{gmtModified,jdbcType=TIMESTAMP})
</insert>
<update id="insertOrUpdate" keyColumn="purchase_order_ds_encrypt_id" keyProperty="purchaseOrderDsEncryptId" parameterType="com.ms.dal.entity.PurchaseOrderDsEncrypt"
useGeneratedKeys="true">
insert into purchase_order_ds_encrypt
( purchase_order_ds_encrypt_id,shop_id,order_id
,purchase_order_sn,is_support_encrypt_order,is_encrypt_order
,result,reason,gmt_create
,gmt_modified)
values (#{purchaseOrderDsEncryptId,jdbcType=BIGINT},#{shopId,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR}
,#{purchaseOrderSn,jdbcType=VARCHAR},#{isSupportEncryptOrder,jdbcType=BOOLEAN},#{isEncryptOrder,jdbcType=TINYINT}
,#{result,jdbcType=VARCHAR},#{reason,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP}
,#{gmtModified,jdbcType=TIMESTAMP})
ON DUPLICATE KEY UPDATE
shop_id = #{shopId,jdbcType=BIGINT}, order_id = #{orderId,jdbcType=VARCHAR}, purchase_order_sn = #{purchaseOrderSn,jdbcType=VARCHAR}, is_support_encrypt_order = #{isSupportEncryptOrder,jdbcType=BOOLEAN}, is_encrypt_order = #{isEncryptOrder,jdbcType=TINYINT}, result = #{result,jdbcType=VARCHAR}, reason = #{reason,jdbcType=VARCHAR}, gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
</update>
<insert id="insertSelective" keyColumn="purchase_order_ds_encrypt_id" keyProperty="purchaseOrderDsEncryptId" parameterType="com.ms.dal.entity.PurchaseOrderDsEncrypt" useGeneratedKeys="true">
insert into purchase_order_ds_encrypt
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="purchaseOrderDsEncryptId != null">purchase_order_ds_encrypt_id,</if>
<if test="shopId != null">shop_id,</if>
<if test="orderId != null">order_id,</if>
<if test="purchaseOrderSn != null">purchase_order_sn,</if>
<if test="isSupportEncryptOrder != null">is_support_encrypt_order,</if>
<if test="isEncryptOrder != null">is_encrypt_order,</if>
<if test="result != null">result,</if>
<if test="reason != null">reason,</if>
<if test="gmtCreate != null">gmt_create,</if>
<if test="gmtModified != null">gmt_modified,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseOrderDsEncryptId != null">#{purchaseOrderDsEncryptId,jdbcType=BIGINT},</if>
<if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
<if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
<if test="purchaseOrderSn != null">#{purchaseOrderSn,jdbcType=VARCHAR},</if>
<if test="isSupportEncryptOrder != null">#{isSupportEncryptOrder,jdbcType=BOOLEAN},</if>
<if test="isEncryptOrder != null">#{isEncryptOrder,jdbcType=TINYINT},</if>
<if test="result != null">#{result,jdbcType=VARCHAR},</if>
<if test="reason != null">#{reason,jdbcType=VARCHAR},</if>
<if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
<if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.PurchaseOrderDsEncrypt">
update purchase_order_ds_encrypt
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=BIGINT},
</if>
<if test="orderId != null">
order_id = #{orderId,jdbcType=VARCHAR},
</if>
<if test="purchaseOrderSn != null">
purchase_order_sn = #{purchaseOrderSn,jdbcType=VARCHAR},
</if>
<if test="isSupportEncryptOrder != null">
is_support_encrypt_order = #{isSupportEncryptOrder,jdbcType=BOOLEAN},
</if>
<if test="isEncryptOrder != null">
is_encrypt_order = #{isEncryptOrder,jdbcType=TINYINT},
</if>
<if test="result != null">
result = #{result,jdbcType=VARCHAR},
</if>
<if test="reason != null">
reason = #{reason,jdbcType=VARCHAR},
</if>
<if test="gmtCreate != null">
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
</if>
<if test="gmtModified != null">
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where purchase_order_ds_encrypt_id = #{purchaseOrderDsEncryptId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.PurchaseOrderDsEncrypt">
update purchase_order_ds_encrypt
set
shop_id = #{shopId,jdbcType=BIGINT},
order_id = #{orderId,jdbcType=VARCHAR},
purchase_order_sn = #{purchaseOrderSn,jdbcType=VARCHAR},
is_support_encrypt_order = #{isSupportEncryptOrder,jdbcType=BOOLEAN},
is_encrypt_order = #{isEncryptOrder,jdbcType=TINYINT},
result = #{result,jdbcType=VARCHAR},
reason = #{reason,jdbcType=VARCHAR},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where purchase_order_ds_encrypt_id = #{purchaseOrderDsEncryptId,jdbcType=BIGINT}
</update>
</mapper>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ms.dal.mapper.QueueMapper">
</mapper>
Loading…
Cancel
Save