1
0
mirror of synced 2024-11-25 06:46:08 +03:00

Payment and shipment status

This commit is contained in:
DanielWeiser 2020-07-23 16:28:36 +03:00 committed by GitHub
parent ad73c0c1dc
commit 2bc97c84ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 1 deletions

View File

@ -51,6 +51,9 @@ class RetailcrmConfigProvider
/** @var bool|null|string */
private static $corporateClient;
/** @var bool|null|string $shipmentDeducted */
private static $shipmentDeducted;
/** @var array $sitesList */
private static $sitesList;
@ -517,6 +520,20 @@ class RetailcrmConfigProvider
return static::$shops;
}
/**
* getShipmentDeducted
*
* @return bool|string|null
*/
public static function getShipmentDeducted()
{
if (self::isEmptyNotZero(static::$shipmentDeducted)) {
static::$shipmentDeducted = static::getOption(RetailcrmConstants::CRM_SHIPMENT_DEDUCTED);
}
return static::$shipmentDeducted;
}
/**
* isPhoneRequired
*

View File

@ -76,4 +76,5 @@ class RetailcrmConstants
const CRM_ORDER_DIMENSIONS = 'order_dimensions';
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
const CRM_INTEGRATION_DELIVERY = 'integration_delivery';
const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted';
}

View File

@ -101,7 +101,7 @@ class RetailCrmHistory
$registerNewUser = true;
if (!empty($customer['email'])) {
if (!empty($customer['email'])) {
$dbUser = CUser::GetList(($by = 'ID'), ($sort = 'ASC'), array('=EMAIL' => $customer['email']));
switch ($dbUser->SelectedRowsCount()) {
case 0:
@ -212,6 +212,7 @@ class RetailCrmHistory
$optionsCanselOrder = RetailcrmConfigProvider::getCancellableOrderPaymentStatuses();
$currency = RetailcrmConfigProvider::getCurrencyOrDefault();
$contragentTypes = array_flip(RetailcrmConfigProvider::getContragentTypes());
$shipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted();
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
@ -1127,6 +1128,32 @@ class RetailCrmHistory
unset($orderCrm);
}
if (isset($order['fullPaidAt']) && is_string($order['fullPaidAt'])) {
$newOrder->setField('PAID', 'Y');
}
if ($shipmentDeducted === 'Y') {
$collection = $newOrder->getShipmentCollection()->getNotSystemItems();
if (isset($order['shipped'])) {
if ($order['shipped']) {
if ($collection->count() === 0) {
$collection = $newOrder->getShipmentCollection();
$shipment = $collection->createItem();
$shipment->setField('DEDUCTED', 'Y');
} else {
foreach ($collection as $shipment) {
$shipment->setField('DEDUCTED', 'Y');
}
}
} else {
foreach ($collection as $shipment) {
$shipment->setField('DEDUCTED', 'N');
}
}
}
}
$newOrder->setField('PRICE', $orderSumm);
self::orderSave($newOrder);

View File

@ -462,6 +462,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmDc", "add");
}
//shipment
if (htmlspecialchars(trim($_POST['shipment_deducted'])) == 'Y') {
$shipment_deducted = 'Y';
} else {
$shipment_deducted = 'N';
}
//corporate-cliente
if (htmlspecialchars(trim($_POST['corp-client'])) == 'Y') {
$cc = 'Y';
@ -563,6 +570,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
COption::SetOptionString($mid, $CRM_DISCOUNT_ROUND, $discount_round);
COption::SetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, $purchasePrice_null);
COption::SetOptionString($mid, RetailcrmConstants::CRM_SHIPMENT_DEDUCTED, $shipment_deducted);
COption::SetOptionString($mid, $CRM_CC, $cc);
COption::SetOptionString($mid, $CRM_CORP_SHOPS, serialize(RCrmActions::clearArr($bitrixCorpShopsArr)));
@ -682,6 +690,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$optionDiscRound = COption::GetOptionString($mid, $CRM_DISCOUNT_ROUND, 0);
$optionPricePrchaseNull = COption::GetOptionString($mid, $CRM_PURCHASE_PRICE_NULL, 0);
$optionShipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted();
//corporate-cliente
$optionCorpClient = COption::GetOptionString($mid, $CRM_CC, 0);
@ -1460,6 +1469,14 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php endforeach;?>
</td>
</tr>
<tr class="heading">
<td colspan="2" class="option-other-heading">
<b>
<label><input class="addr" type="checkbox" name="shipment_deducted" value="Y" <?php if($optionShipmentDeducted === 'Y') echo "checked"; ?>><?php echo "Изменять статус отгрузки при получении соответствующего флага из crm" ?></label>
</b>
</td>
</tr>
<?php endif;?>
<?php $tabControl->Buttons(); ?>
<input type="hidden" name="Update" value="Y" />