/
var
/
www
/
vhosts
/
nabawater
/
api
/
modules
/
v1
/
models
/
/var/www/vhosts/nabawater/api/modules/v1/models
mkdir
upload
Name
Size
Mode
Actions
.gitkeep
0
0644
edit
dl
rm
ActivityLog.php
160
0644
edit
dl
rm
AddressType.php
160
0644
edit
dl
rm
AddressTypeLang.php
172
0644
edit
dl
rm
AdminUser.php
154
0644
edit
dl
rm
Area.php
139
0644
edit
dl
rm
AreaLang.php
151
0644
edit
dl
rm
Banner.php
1078
0644
edit
dl
rm
BannerLang.php
157
0644
edit
dl
rm
Branch.php
13454
0644
edit
dl
rm
BranchApi.php
2796
0644
edit
dl
rm
BranchDeliveryArea.php
181
0644
edit
dl
rm
BranchImage.php
526
0644
edit
dl
rm
BranchLang.php
233
0644
edit
dl
rm
BranchList.php
15218
0644
edit
dl
rm
BranchReview.php
914
0644
edit
dl
rm
BranchTimeslot.php
609
0644
edit
dl
rm
Cart.php
139
0644
edit
dl
rm
Category.php
1295
0644
edit
dl
rm
CategoryLang.php
164
0644
edit
dl
rm
City.php
139
0644
edit
dl
rm
CityLang.php
151
0644
edit
dl
rm
Cms.php
515
0644
edit
dl
rm
CmsLang.php
148
0644
edit
dl
rm
Configuration.php
166
0644
edit
dl
rm
ContactUs.php
154
0644
edit
dl
rm
Country.php
148
0644
edit
dl
rm
CountryLang.php
160
0644
edit
dl
rm
Coupon.php
145
0644
edit
dl
rm
CouponLang.php
157
0644
edit
dl
rm
CouponUser.php
157
0644
edit
dl
rm
CouponVendor.php
163
0644
edit
dl
rm
CreditHistory.php
824
0644
edit
dl
rm
Cuisine.php
515
0644
edit
dl
rm
CuisineLang.php
160
0644
edit
dl
rm
DeliveryArea.php
163
0644
edit
dl
rm
DeliveryBoy.php
160
0664
edit
dl
rm
Deliveryboy.php
160
0644
edit
dl
rm
DeliveryboyLang.php
172
0644
edit
dl
rm
DeliveryBoyOrder.php
7121
0644
edit
dl
rm
DeliveryBoyOrderItem.php
1062
0644
edit
dl
rm
DeliveryboyRequest.php
181
0644
edit
dl
rm
DeliveryboyRequestHistory.php
1646
0644
edit
dl
rm
DeliveryChargeSetting.php
190
0644
edit
dl
rm
EmailQueue.php
157
0644
edit
dl
rm
Enquiry.php
2085
0644
edit
dl
rm
Faq.php
136
0644
edit
dl
rm
FaqLang.php
148
0644
edit
dl
rm
FeaturedVendor.php
2052
0644
edit
dl
rm
Ingredient.php
157
0644
edit
dl
rm
IngredientLang.php
169
0644
edit
dl
rm
Item.php
4786
0644
edit
dl
rm
ItemBottleRefundHistory.php
196
0644
edit
dl
rm
ItemImage.php
490
0644
edit
dl
rm
ItemImportTrack.php
172
0644
edit
dl
rm
ItemIngredientGroup.php
1211
0644
edit
dl
rm
ItemIngredientGroupLang.php
196
0644
edit
dl
rm
ItemIngredientGroupMapping.php
205
0644
edit
dl
rm
ItemIngredientMapping.php
505
0644
edit
dl
rm
ItemLang.php
151
0644
edit
dl
rm
ItemList.php
3868
0644
edit
dl
rm
ItemMapping.php
160
0644
edit
dl
rm
ItemMappingGroup.php
175
0644
edit
dl
rm
ItemType.php
301
0644
edit
dl
rm
ItemTypeDetails.php
172
0644
edit
dl
rm
ItemTypeLang.php
163
0644
edit
dl
rm
Item_Image.php
157
0644
edit
dl
rm
Item_Ingredient_Group.php
190
0644
edit
dl
rm
Item_ingredient_group_lang.php
205
0644
edit
dl
rm
item_ingredient_group_mapping.php
214
0644
edit
dl
rm
Item_lang.php
154
0644
edit
dl
rm
Item_mapping.php
163
0644
edit
dl
rm
Item_mapping_group.php
181
0644
edit
dl
rm
Language.php
151
0644
edit
dl
rm
LoaylityPoint.php
166
0644
edit
dl
rm
LoyalityPoint.php
166
0644
edit
dl
rm
LoyalityPointReference.php
193
0644
edit
dl
rm
MallProduct.php
624
0644
edit
dl
rm
MallProductDescription.php
193
0644
edit
dl
rm
MallProductLang.php
172
0644
edit
dl
rm
Message.php
148
0644
edit
dl
rm
MetaTag.php
148
0644
edit
dl
rm
MobileTranslation.php
178
0644
edit
dl
rm
Newsletter.php
157
0644
edit
dl
rm
NewsletterSubscriber.php
975
0644
edit
dl
rm
NodeOrder.php
154
0644
edit
dl
rm
Notification.php
924
0644
edit
dl
rm
Order.php
6316
0644
edit
dl
rm
OrderCoupon.php
160
0644
edit
dl
rm
OrderCouponLang.php
172
0644
edit
dl
rm
OrderDetail.php
6729
0644
edit
dl
rm
OrderDetailV1.php
11483
0644
edit
dl
rm
OrderItem.php
1564
0644
edit
dl
rm
OrderItemImage.php
169
0644
edit
dl
rm
OrderItemIngredientGroup.php
199
0644
edit
dl
rm
OrderItemIngredientGroupLang.php
211
0644
edit
dl
rm
OrderItemIngredientMapping.php
205
0644
edit
dl
rm
OrderItemIngredientMappingLang.php
217
0644
edit
dl
rm
OrderItemLang.php
166
0644
edit
dl
rm
OrderItemV1.php
1810
0644
edit
dl
rm
OrderMallProduct.php
175
0644
edit
dl
rm
OrderMallProductLang.php
187
0644
edit
dl
rm
OrderParcel.php
160
0644
edit
dl
rm
OrderParcelItemImage.php
187
0644
edit
dl
rm
OrderPromotion.php
1329
0644
edit
dl
rm
OrderPromotionLang.php
181
0644
edit
dl
rm
OrderSignature.php
564
0644
edit
dl
rm
OrderSubscription.php
449
0644
edit
dl
rm
OrderSubscriptionItem.php
743
0644
edit
dl
rm
OrderTax.php
704
0644
edit
dl
rm
OrderTaxLang.php
163
0644
edit
dl
rm
OtpTemp.php
179
0644
edit
dl
rm
ParcelItemType.php
314
0644
edit
dl
rm
ParcelItemTypeLang.php
181
0644
edit
dl
rm
PointHistory.php
598
0644
edit
dl
rm
Post.php
1179
0644
edit
dl
rm
PostImage.php
294
0644
edit
dl
rm
Promotion.php
1306
0644
edit
dl
rm
PromotionLang.php
166
0644
edit
dl
rm
Role.php
139
0644
edit
dl
rm
SignatureUploadForm.php
659
0644
edit
dl
rm
SourceMessage.php
166
0644
edit
dl
rm
Tax.php
136
0644
edit
dl
rm
TaxLang.php
148
0644
edit
dl
rm
TimeZone.php
151
0644
edit
dl
rm
TodaySpecial.php
1592
0644
edit
dl
rm
TodaySpecialLang.php
175
0644
edit
dl
rm
Topup.php
412
0644
edit
dl
rm
TopupHistory.php
163
0644
edit
dl
rm
Unit.php
139
0644
edit
dl
rm
UnitLang.php
151
0644
edit
dl
rm
User.php
8960
0644
edit
dl
rm
UserAddress.php
4137
0644
edit
dl
rm
UserAddressLang.php
1478
0644
edit
dl
rm
UserEmptyBottleRefundRequest.php
211
0644
edit
dl
rm
UserFavourite.php
1726
0644
edit
dl
rm
UserFriendList.php
169
0644
edit
dl
rm
UserLevel.php
632
0644
edit
dl
rm
UserNotification.php
175
0644
edit
dl
rm
UserPromotion.php
1039
0644
edit
dl
rm
UserPromotionBranch.php
184
0644
edit
dl
rm
UserPromotionLang.php
178
0644
edit
dl
rm
UserPromotionUser.php
178
0644
edit
dl
rm
UserReminder.php
2086
0644
edit
dl
rm
UserUploadForm.php
628
0644
edit
dl
rm
Vendor.php
352
0644
edit
dl
rm
VendorApi.php
2670
0644
edit
dl
rm
VendorBank.php
157
0644
edit
dl
rm
VendorCategory.php
169
0644
edit
dl
rm
VendorCuisine.php
166
0644
edit
dl
rm
VendorLang.php
157
0644
edit
dl
rm
VendorOrder.php
13925
0644
edit
dl
rm
VendorOrderItem.php
3304
0644
edit
dl
rm
VendorReport.php
1100
0644
edit
dl
rm
VendorReportDetail.php
6538
0644
edit
dl
rm
VendorType.php
606
0644
edit
dl
rm
VendorTypeDetail.php
175
0644
edit
dl
rm
VendorTypeLang.php
169
0644
edit
dl
rm
WalletTransaction.php
1811
0644
edit
dl
rm
Edit:
/var/www/vhosts/nabawater/api/modules/v1/models/VendorOrder.php
(13925B)
<?php namespace api\modules\v1\models; use common\helpers\DateTimeHelper; use common\helpers\UploadHelper; use api\modules\v1\models\Branch; use api\modules\v1\models\VendorLang; use api\modules\v1\models\OrderCoupon; use api\modules\v1\models\OrderTax; use yii\helpers\ArrayHelper; use common\helpers\Com; use Yii; /** * Class VendorOrder * @package api\modules\v1\models */ class VendorOrder extends \common\models\Order { /** * * @var string */ public $currency_code, $pickup_date, $pickup_time, $dining_date, $dining_time, $member_count, $product_id, $delivery_city, $delivery_area, $flat_no, $apartment, $delivery_instruction, $message, $alternate_contact, $landmark, $postal_code, $delivery_minutes, $products, $product_price, $product_total_price, $product_quantity, $delivery_type_label, $order_type_label; /** * * @return array */ public function fields() { return [ 'vendor_id', 'outlet_key' => function (self $model) { $modelBranch = Branch::findOne($model->branch_id); return $modelBranch !== null ? $modelBranch->branch_key : null; }, 'customer_id' => 'user_id', 'shop_logo' => function (self $model) { $modelVendor = VendorLang::findOne([ 'vendor_id' => $model->vendor_id, 'language_code' => Yii::$app->language ]); $path = null; if ($modelVendor !== null) { $path = $modelVendor->vendor_image_path; } return UploadHelper::getInstance()->get($path); }, 'order_datetime' => function (self $model) { $dtHelper = DateTimeHelper::getInstance(); return $dtHelper->format($model->order_date_time, $dtHelper::MYSQL_DATETIME_FORMAT); }, 'order_key', 'order_number', 'order_total', 'rejected_reason', 'currency_code' => function (self $model) { return $model->currency_code !== null ? $model->currency_code : ''; }, 'first_name' => 'customer_first_name', 'last_name' => 'customer_last_name', 'email' => 'customer_email', 'mobile_number' => 'customer_mobile_number', 'promocode' => function (self $model) { $modelCoupon = OrderCoupon::findOne(['order_id' => $model->order_id]); if ($modelCoupon !== null) { return $modelCoupon->coupon_code; } return ''; }, 'promocode_amount' => 'coupon_offer_value', 'tax' => function (self $model) { $tax = []; $tax['service_tax'] = $model->service_tax; $tax['vat'] = $model->vat; $taxvalues[] = $tax; return $taxvalues; }, 'sub_total' => 'item_total', 'pickup_date' => function (self $model) { return $this->isNull($model->pickup_date); }, 'pickup_time' => function (self $model) { return $this->isNull($model->pickup_time); }, 'dining_date' => function (self $model) { return $this->isNull($model->dining_date); }, 'dining_time' => function (self $model) { return $this->isNull($model->dining_time); }, 'member_count'=> function (self $model) { return $this->isNull($model->member_count); }, 'product_id'=> function (self $model) { return $this->isNull($model->product_id); }, 'delivery_fee', 'delivery_boy_tip', 'delivery_city' => function (self $model) { if ((int)$model->order_type === $model::ORDER_TYPE_DELIVERY) { $modelAddress = self::getUserAddress(); return ($modelAddress != null) ? $modelAddress->city : '' ; } return ''; }, 'delivery_area' => function (self $model) { if ((int)$model->order_type === $model::ORDER_TYPE_DELIVERY) { $modelAddress = self::getUserAddress(); return ($modelAddress != null) ? $modelAddress->area : '' ; } return ''; }, 'flat_no' => function (self $model){ if ((int)$model->order_type === $model::ORDER_TYPE_DELIVERY) { $modelAddress = self::getUserAddress(); return ($modelAddress != null) ? $modelAddress->flat_no : '' ; } return ''; }, 'apartment' => function (self $model) { if ((int)$model->order_type === $model::ORDER_TYPE_DELIVERY) { $modelAddress = self::getUserAddress(); return ($modelAddress != null) ? $modelAddress->apartment : '' ; } return ''; }, 'delivery_instruction' => function (self $model) { return ''; }, 'message' => function (self $model) { return $this->isNull($model->order_message); }, 'alternate_contact' => function (self $model) { return ''; }, 'landmark' => function (self $model) { if ((int)$model->order_type === $model::ORDER_TYPE_DELIVERY) { $modelAddress = self::getUserAddress(); return ($modelAddress != null) ? $modelAddress->landmark : '' ; } return ''; }, 'payment_status' =>function (self $model) { return $model->payment_status; }, 'payment_type' => function (self $model) { return $model->payment_option; }, 'delivery_status' => function (self $model) { $label = $this->getDeliveryStatus((int)$model->order_status); if((int)$model->order_status === $model::ORDER_STATUS_READY_TO_PICKUP) { if ((int)$model->order_type === $model::ORDER_TYPE_PICKUP) { return 'Ready To Pickup'; } else { return 'Ready To Delivery'; } } return $this->getDeliveryStatus((int)$model->order_status); }, 'delivery_status_label' => function (self $model) { $label = $this->getDeliveryStatus((int)$model->order_status); if((int)$model->order_status === $model::ORDER_STATUS_READY_TO_PICKUP) { if ((int)$model->order_type === $model::ORDER_TYPE_PICKUP) { return 'Ready To Pickup'; } else { return 'Ready To Delivery'; } } return $this->getDeliveryStatus((int)$model->order_status); }, 'delivery_type' => 'delivery_option', 'delivery_type_label' => function (self $model) { return $this->getDeliveryType((int)$model->delivery_option); }, 'order_type' => function (self $model) { return $model->order_type; }, 'order_type_label' => function (self $model) { return $this->getOrderType((int)$model->order_type); }, 'postal_code' => function (self $model) { return $this->isNull($model->postal_code); }, 'package_price' => function (self $model) { $price = $model->package_price; return empty($price) ? 0 : $price; }, 'cgst_amount' => function (self $model) { $vat_cgst = $model->vat_cgst; return empty($vat_cgst) ? 0 : $vat_cgst; }, 'sgst_amount' => function (self $model) { $vat_sgst = $model->vat_sgst; return empty($vat_sgst) ? 0 : $vat_sgst; }, 'igst_amount' => function (self $model) { $vat_igst = $model->vat_igst; return empty($vat_igst) ? 0 : $vat_igst; }, 'order_id', 'delivery_timing' => 'delivery_option', 'later_datetime' => 'pickup_delivery_date_time', 'delivery_minutes' => function (self $model) { return $this->isNull($model->delivery_minutes); }, 'product_details' => function (self $model) { $modelItemName = $model->getOrderItemName(); return $modelItemName; }, 'products', 'product_price' => function (self $model) { return []; }, 'product_total_price' => function (self $model) { return []; }, 'product_quantity' => function (self $model) { return OrderItem::find()->where(['order_id' => $model->order_id])->count(); } ]; } public function getUserAddress() { $address = UserAddress::find()->select(['UAL.*','UA.latitude','UA.longitude']) ->alias('UA') ->leftJoin(['UAL' => UserAddressLang::tableName()],'UA.user_address_id = UAL.user_address_id') ->where(['UA.user_address_id' => $this->user_address_id]) ->one(); return $address; } /** * * @return type */ public function getOrderItemName() { $orderItemName = VendorOrderItem::find()->alias('OI') ->select(['OI.quantity', 'OI.item_total_price','OI.item_price','OI.special_instructions', 'OIM.item_image_path', 'OI.order_item_id','IL.item_name']) ->leftJoin(['OIM' => OrderItemImage::tableName()], 'OIM.order_item_id = OI.order_item_id') ->leftJoin(['IL' => ItemLang::tableName()], 'IL.item_id = OI.item_id') ->where(['OI.order_id' => $this->order_id]); //Item::selectTranslation($orderItemName); return $orderItemName->all(); } /** * * @param type $index * @return $array */ public function getDeliveryType($index = '') { $deliveryTypeData = [ 1 => Yii::t('backend', 'ASAP'), 2 => Yii::t('backend', 'Later'), ]; ($index == '') ? ($deliveryTypeData = $deliveryTypeData) : ($deliveryTypeData = ArrayHelper::getValue($deliveryTypeData, $index)); return $deliveryTypeData; } /** * @param $status * @return string */ public function getDeliveryStatus($status) { $statusLabel = ''; switch ($status) { case self::ORDER_STATUS_DELIVERYBOY_ACCEPTED: $statusLabel = 'Confirmed'; break; case self::ORDER_STATUS_DELIVERYBOY_ASSIGNED: $statusLabel = 'Confirmed'; break; case self::ORDER_STATUS_PENDING: $statusLabel = 'Pending'; break; case self::ORDER_STATUS_ACCEPTED: $statusLabel = 'Confirmed'; break; case self::ORDER_STATUS_PREPARED: $statusLabel = 'Preparation'; break; case self::ORDER_STATUS_DELIVERED: $statusLabel = 'Delivered'; break; case self::ORDER_STATUS_REJECTED: $statusLabel = 'Cancelled'; break; case self::ORDER_STATUS_READY_TO_PICKUP: $statusLabel = 'Ready To Pickup'; break; case self::ORDER_STATUS_ONTHEWAY: $statusLabel = 'Order on its way'; break; case self::ORDER_STATUS_DELIVERYBOY_REQUESTED: $statusLabel = 'Confirmed'; break; } return $statusLabel; } public function getNextDeliveryStatus($status,$order_type) { $statusLabel = ''; switch ($status) { case self::ORDER_STATUS_DELIVERYBOY_ACCEPTED: $statusLabel = 'Confirm'; break; case self::ORDER_STATUS_DELIVERYBOY_ASSIGNED: $statusLabel = 'Confirm'; break; case self::ORDER_STATUS_ACCEPTED: $statusLabel = 'Preparation'; break; case self::ORDER_STATUS_PREPARED: if($order_type == Order::ORDER_TYPE_DELIVERY) { $statusLabel = 'Ready to pickup'; } else { $statusLabel = 'Delivered'; } break; } return $statusLabel; } public function getOrderType($type) { $type_label = ''; if($type == Order::ORDER_TYPE_DELIVERY) { $type_label = yii::t('api','Delivery'); } else if($type == Order::ORDER_TYPE_PICKUP) { $type_label = yii::t('api','Pickup'); } else { $type_label = Yii::t('api', 'Other'); } return $type_label; } /** * @param $value * @return string */ private function isNull($value) { return $value === null ? '' : $value; } }
Save
cmd:
run