Ejemplo n.º 1
0
    def add_customer_card(self, request):
        _message = None
        _status = self.interruption
        _data_card = None
        _data = None
        try:
            _entity = customerCardEntity()
            _entity.requestToClass(request)
            _model = customerModel()
            _chargeModel = chargeModel()
            _data = _chargeModel.add_card_culqi(_entity.cvv,
                                                _entity.cardNumberNotEncrypted,
                                                _entity.expYearNotEncripted,
                                                _entity.expMonthNotEcrypted,
                                                _entity.email)

            if _data["object"] == "error":
                _status = self.interruption
                _message = _data["user_message"]
            else:
                _data_card = _model.add_customer_card(_entity)
                _status = self.OK
                _message = self.messageOK
        except (Exception) as e:
            _status = self.interruption
            _message = self.messageInterruption + str(e)
            print('error: ' + str(e))
        return responseEntity(_status, _message, _data_card).toJSON()
Ejemplo n.º 2
0
    def recover_password_customer(self, request):
        _message = None
        _status = self.interruption
        _entity = None
        _email = None
        try:
            _model = customerModel()
            _entity = customerEntity()
            _entity.requestToEmail(request)
            _entity = _model.get_password_by_id(_entity.mail)
            if _entity is None:
                _status = self.failUser
                _message = self.userDontExist
            else:
                _modelLogin = notificationModel()
                _modelLogin.sen_sms_message(_entity.password,
                                            _entity.cellphone)
                _status = self.OK
                _message = self.smsSuccess + str(_entity.cellphone)

        except (Exception) as e:
            _status = self.interruption
            _message = self.messageInterruption + str(e)
            print('error: ' + str(e))
        return responseEntity(_status, _message, None).toJSON()
Ejemplo n.º 3
0
    def refuse_sale(self, index):
        _message = None
        _status = self.interruption
        _id_sale = None
        _id_fire_base_token = None
        try:
            _model = saleModel()
            _customerModel = customerModel()
            _notificationModel = notificationModel()
            _id_sale = _model.update_status_sale(index,
                                                 self.status_sale_refuse)
            _id_customer = _model.get_id_customer_by_id_sale(index)
            _id_fire_base_token = _customerModel.get_id_fire_base_token_by_id_customer(
                _id_customer)

            if _id_fire_base_token is not None:
                _response = _notificationModel.send_push_message(
                    _id_fire_base_token, self.push_message_refuse_sale)
            print(_response)
            if _response is None:
                _status = self.OK
                _message = self.pushSuccess
            else:
                _status = self.OK
                _message = self.pushNotSuccess
        except (Exception) as e:
            _status = self.interruption
            _message = self.messageInterruption + str(e)
            print('error: ' + str(e))
        return responseEntity(_status, _message, _id_sale).toJSON()
Ejemplo n.º 4
0
    def add_customer(self, request):
        _message = None
        _status = self.interruption
        _entity = None
        try:
            _entity = customerEntity()
            _model = customerModel()
            _entity.requestToClass(request)

            if _model.validate_mail(_entity.mail):
                _status = self.interruption
                _message = self.duplicatedMail
            else:
                if _entity.referred_code == "" or _entity.referred_code is None:
                    _entity = _model.add_customer(_entity)
                    _status = self.OK
                    _message = self.addCustomer
                else:
                    _id_customer_main = _model.validate_referred_code(
                        _entity.referred_code)
                    if _id_customer_main is not None:
                        _entity = _model.add_customer(_entity)
                        _model.add_customer_coupon(_entity.id,
                                                   _id_customer_main)
                        _status = self.OK
                        _message = self.addCustomerAndCode
                    else:
                        _status = self.interruption
                        _message = self.invalidCoupon

        except (Exception) as e:
            _status = self.interruption
            _message = self.messageInterruption + str(e)
            print('error: ' + str(e))
        return responseEntity(_status, _message, _entity).toJSON()
Ejemplo n.º 5
0
 def get_customer_coupon_by_id(self, index):
     _message = None
     _status = self.interruption
     _data = None
     try:
         _model = customerModel()
         _data = _model.get_customer_coupon_by_id(index)
         _status = self.OK
         _message = self.messageOK
     except (Exception) as e:
         _status = self.interruption
         _message = self.messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, _data).toJSON()
Ejemplo n.º 6
0
 def delete_customer_card(self, index):
     _message = None
     _status = self.interruption
     id_customer_address = None
     try:
         _model = customerModel()
         id_customer_address = _model.delete_customer_card(index)
         _status = self.OK
         _message = self.messageOK
     except (Exception) as e:
         _status = self.interruption
         _message = self.messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, id_customer_address).toJSON()
Ejemplo n.º 7
0
 def update_customer_user_favorite(self, request):
     _message = None
     _status = self.interruption
     try:
         _entity = customerUserFavoriteEntity()
         _entity.requestToClass(request)
         _model = customerModel()
         _entity = _model.update_customer_user_favorite(_entity)
         _status = self.OK
         _message = self.messageOK
     except (Exception) as e:
         _status = self.interruption
         _message = self.messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, _entity).toJSON()
Ejemplo n.º 8
0
 def add_customer_rate(self, request):
     _message = None
     _status = responseController().interruption
     _entity = None
     try:
         _entity = customerRateEntity()
         _model = customerModel()
         _entity.requestToClass(request)
         _entity = _model.add_customer_rate(_entity)
         _status = responseController().OK
         _message = responseController().messageOK
     except (Exception) as e:
         _status = responseController().interruption
         _message = responseController().messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, _entity).toJSON()
Ejemplo n.º 9
0
 def update_customer(self, request):
     _message = ''
     _status = self.interruption
     _userEntity = None
     try:
         _customerEntity = customerEntity()
         _customerModel = customerModel()
         _customerEntity.requestUpdateToClass(request)
         _id = _customerModel.update_customer(_customerEntity)
         _status = self.OK
         _message = self.messageOK
     except (Exception) as e:
         _status = self.interruption
         _message = self.messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, _id).toJSON()
Ejemplo n.º 10
0
 def update_customer_address(self, request):
     _message = None
     _status = self.interruption
     _data = None
     try:
         _entity = customerAddressEntity()
         _entity.requestToClassUpdate(request)
         _model = customerModel()
         _data = _model.update_customer_address(_entity)
         _status = self.OK
         _message = self.messageOK
     except (Exception) as e:
         _status = self.interruption
         _message = self.messageInterruption + str(e)
         print('error: ' + str(e))
     return responseEntity(_status, _message, _data).toJSON()
Ejemplo n.º 11
0
    def add_sale_confirm(self, request):
        _message = None
        _status = self.interruption
        _entity = None
        _response = None
        _coupon = None
        _id_sale = None
        _id_customer = None
        _id_quantity_sales_referred = 0
        _cellphone = None
        try:

            _entity = saleConfirmEntity()
            _model = saleModel()
            _customerModel = customerModel()
            _chargeModel = chargeModel()
            _entity.requestToClass(request)

            _data = _chargeModel.charge_culqi(
                _entity.cvv, _entity.document_number, _entity.expiration_year,
                _entity.expiration_month, _entity.mail, _entity.total_amount,
                "Venta Appunto")
            if _data["object"] == "error":
                _status = self.interruption
                _message = _data["user_message"]
            else:

                _id_sale = _model.add_sale_confirm(_entity.id_sale)
                _coupon = _model.get_coupon_by_id_sale(_entity.id_sale)
                if _coupon is not None:
                    _customerModel.delete_customer_coupon(_coupon)

                _id_customer = _model.get_id_customer_by_id_sale(
                    _entity.id_sale)
                if _id_customer is not None:
                    _customerModel.update_first_sale(_id_customer)

                _id_quantity_sales_referred = _customerModel.get_quantity_first_sales(
                    _id_customer)
                print("_id_quantity_sales_referred " +
                      str(_id_quantity_sales_referred))
                if _id_quantity_sales_referred >= 3:
                    _id_customer_main = _customerModel.get_id_customer_main_referred(
                        _id_customer)
                    _customerModel.add_customer_coupon(_id_customer_main, 0)
                    _customerModel.update_first_sale_done(_id_customer)
                    _cellphone = _customerModel.get_cellphone_by_id(
                        _id_customer_main)
                    _notificationModel = notificationModel()
                    print(_cellphone)
                    _notificationModel.send_sms_coupon(_cellphone)

                _sale = _model.get_sale_by_id_sale(_id_sale)
                _status = self.OK
                if (_sale is not None):
                    if (_sale.id_type_availability == 1):
                        _message = "Pago procesado con éxito, el profesional estará llegando a tu domicilio a las " + str(
                            _sale.hour_availability) + ":00h el " + str(
                                _sale.date_availability)
                    else:
                        _message = "Pago procesado con éxito, te esperamos en : " + str(
                            _sale.address_store)

                else:
                    _message = self.saleSuccessConfirm

        except (Exception) as e:
            _status = self.interruption
            _message = self.messageInterruption + str(e)
            print('error: ' + str(e))
        return responseEntity(_status, _message, _id_sale).toJSON()