siyet / tetris Goto Github PK
View Code? Open in Web Editor NEWУзкоспециализированное SPA для наведения порядка на складе
Узкоспециализированное SPA для наведения порядка на складе
Необходимо написать скрипт, который подключиться к API SureDone, переберет все товары у которых поле storagelocation
не пустое.
В данном поле вписаны данные вида:
056302 053621/1 32321
Для каждого набора цифр состоящего из 5 штук нужно добавить префикс "0", т. е.
implode( " ", array_map(
function ($item) { return preg_match("/[0-9]{5}/", $item) ? "0" + $item : $item; },
preg_split("/[\s,]+/", $row['storagelocation'])
) );
разделителями могут быть не только пробелы, разделители нужно сохранить, если в данном поле вписано что либо отличное от "/[0-9]{5|6}*/", то пишем в лог значение поля sku
и напротив значение поля storagelocation
.
В config.php есть токен для подключения к api.
Описание API: https://www.suredone.com/guides/api/
API_URL_BASE = 'https://api.suredone.com/v1/'
HEADERS = {
'x-auth-token': '[тута токен]',
'x-auth-user': '[тута имя пользователя]'
}
response = requests.get('{0}bulk/exports/?type=items&mode=include&fields=sku'.format(API_URL_BASE), headers=HEADERS)
if response.status_code == 200:
data = json.loads(response.content.decode('utf-8'))
if data['result'] != 'success':
print(data['message'])
raise
time.sleep(8)
_response = requests.get('{0}bulk/exports/{1}'.format(API_URL_BASE, data['export_file']), headers=HEADERS)
if _response.status_code == 200:
_data = json.loads(_response.content.decode('utf-8'))
__response = requests.get(_data['url'])
if __response.status_code == 200:
_updatable = csv.DictReader(__response.content.decode('utf-8').split('\n')[:-1], delimiter=',', quotechar='"')
for row in _updatable:
skus_SD.append(row['sku'])
Пример, как вносить изменения в БД SureDone есть в файле edit.php, и в описании API.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.