Revision 60a44450
Von Werner Hahn vor mehr als 7 Jahren hinzugefügt
SL/Controller/ShopOrder.pm | ||
---|---|---|
10 | 10 |
use SL::DB::ShopOrderItem; |
11 | 11 |
use SL::DB::Shop; |
12 | 12 |
use SL::DB::History; |
13 |
use SL::DBUtils; |
|
13 | 14 |
use SL::Shop; |
14 | 15 |
use SL::Presenter; |
15 | 16 |
use SL::Helper::Flash; |
... | ... | |
96 | 97 |
my $d_address = $self->check_address(%delivery_address); |
97 | 98 |
#### |
98 | 99 |
|
99 |
my $lastname = $shop_order->customer_lastname; |
|
100 |
# Only Customers which are not found will be applied |
|
101 |
my $name = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_firstname . "%" . $shop_order->billing_lastname . "%" : ''; |
|
102 |
my $lastname = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_lastname . "%" : ''; |
|
103 |
my $company = $shop_order->billing_company ne '' ? "%" . $shop_order->billing_company . "%" : ''; |
|
104 |
my $street = $shop_order->billing_street ne '' ? $shop_order->billing_street : ''; |
|
105 |
# Fuzzysearch for street to find e.g. "Dorfstrasse - Dorfstr. - Dorfstraße" |
|
106 |
my $dbh = $::form->get_standard_dbh(); |
|
107 |
my $fs_query = "SELECT id FROM customer WHERE ( ( ( name ILIKE ? |
|
108 |
OR name ILIKE ? |
|
109 |
) |
|
110 |
AND zipcode ILIKE ? |
|
111 |
) |
|
112 |
OR ( street % ? |
|
113 |
AND zipcode ILIKE ? |
|
114 |
) |
|
115 |
OR email ILIKE ? |
|
116 |
)"; |
|
117 |
my @values = ($lastname, $company, $shop_order->billing_zipcode, $street, $shop_order->billing_zipcode, $shop_order->billing_email); |
|
118 |
my @c_ids = selectall_array_query($::form, $dbh, $fs_query, @values); |
|
119 |
$main::lxdebug->dump(0, 'WH:C_IDs ',\@c_ids); |
|
100 | 120 |
|
101 | 121 |
my $proposals = SL::DB::Manager::Customer->get_all( |
102 |
where => [
|
|
103 |
or => [ |
|
104 |
and => [ # when matching names also match zipcode |
|
105 |
or => [ 'name' => { ilike => "%$lastname%"}, |
|
106 |
'name' => { ilike => $shop_order->customer_company }, |
|
107 |
], |
|
108 |
'zipcode' => { ilike => $shop_order->customer_zipcode }, |
|
109 |
], |
|
110 |
and => [ # check for street and zipcode |
|
111 |
and => [ 'street' => { ilike => "%".$shop_order->customer_street."%" }, |
|
112 |
'zipcode' => { ilike => $shop_order->customer_zipcode }, |
|
113 |
], |
|
114 |
], |
|
115 |
or => [ 'email' => { ilike => $shop_order->customer_email } ], |
|
116 |
], |
|
122 |
query => [ id => [ @c_ids ],
|
|
123 |
# or => [
|
|
124 |
# and => [ # when matching names also match zipcode
|
|
125 |
# or => [ 'name' => { ilike => "%$lastname%"},
|
|
126 |
# 'name' => { ilike => $shop_order->customer_company },
|
|
127 |
# ],
|
|
128 |
# 'zipcode' => { ilike => $shop_order->customer_zipcode },
|
|
129 |
# ],
|
|
130 |
# and => [ # check for street and zipcode
|
|
131 |
# and => [ 'street' => { ilike => "%".$shop_order->customer_street."%" },
|
|
132 |
# 'zipcode' => { ilike => $shop_order->customer_zipcode },
|
|
133 |
# ],
|
|
134 |
# ],
|
|
135 |
# or => [ 'email' => { ilike => $shop_order->customer_email } ],
|
|
136 |
# ],
|
|
117 | 137 |
], |
118 | 138 |
); |
119 | 139 |
|
SL/ShopConnector/Shopware.pm | ||
---|---|---|
130 | 130 |
$shop_order->{positions} = $position-1; |
131 | 131 |
|
132 | 132 |
# Only Customers which are not found will be applied |
133 |
my $name = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_firstname . "%" . $shop_order->billing_lastname . "%" : '';
|
|
133 |
my $name = $shop_order->billing_lastname ne '' ? $shop_order->billing_firstname . " " . $shop_order->billing_lastname : '';
|
|
134 | 134 |
my $lastname = $shop_order->billing_lastname ne '' ? "%" . $shop_order->billing_lastname . "%" : ''; |
135 | 135 |
my $company = $shop_order->billing_company ne '' ? "%" . $shop_order->billing_company . "%" : ''; |
136 | 136 |
my $street = $shop_order->billing_street ne '' ? $shop_order->billing_street : ''; |
... | ... | |
160 | 160 |
'email' => $shop_order->billing_email, |
161 | 161 |
'country' => $shop_order->billing_country, |
162 | 162 |
'greeting' => $shop_order->billing_greeting, |
163 |
'contact' => ($shop_order->billing_greeting eq "Herr" ? "Sehr geehrter Herr $lastname" : "Sehr geehrte Frau $lastname"), |
|
163 | 164 |
'fax' => $shop_order->billing_fax, |
164 | 165 |
'phone' => $shop_order->billing_phone, |
165 | 166 |
'ustid' => $shop_order->billing_vat, |
... | ... | |
185 | 186 |
$shop_order->save; |
186 | 187 |
|
187 | 188 |
}elsif(scalar(@c_ids) == 1){ |
188 |
my $customer = SL::DB::Manager::Customer->get_first( query => [ id => $c_ids[0], email => $shop_order->billing_email ] ); |
|
189 |
my $customer = SL::DB::Manager::Customer->get_first( query => [ |
|
190 |
id => $c_ids[0], |
|
191 |
email => $shop_order->billing_email, |
|
192 |
street => $shop_order->billing_street, |
|
193 |
zipcode => $shop_order->billing_zipcode, |
|
194 |
city => $shop_order->billing_city, |
|
195 |
name => $name, |
|
196 |
]); |
|
197 |
$main::lxdebug->dump(0, 'WH:CUS ',\$customer); |
|
198 |
|
|
199 |
if(ref $customer){ |
|
200 |
$shop_order->{kivi_customer_id} = $customer->id; |
|
201 |
$shop_order->save; |
|
202 |
} |
|
203 |
}else{ |
|
204 |
my $customer = SL::DB::Manager::Customer->get_first( query => [ #or => [id => \@c_ids ], |
|
205 |
name => $name, |
|
206 |
street => $shop_order->billing_street, |
|
207 |
zipcode => $shop_order->billing_zipcode, |
|
208 |
email => $shop_order->billing_email, |
|
209 |
] |
|
210 |
); |
|
211 |
$main::lxdebug->dump(0, 'WH:CUS ',\$customer); |
|
212 |
|
|
213 |
if(ref $customer){ |
|
214 |
$shop_order->{kivi_customer_id} = $customer->id; |
|
215 |
$shop_order->save; |
|
216 |
} |
|
217 |
} |
|
218 |
# DF Versandkosten als Position am ende einfügen Dreschflegelspezifisch event. konfigurierbar machen |
|
189 | 219 |
|
190 | 220 |
if(ref $customer){ |
191 | 221 |
$shop_order->{kivi_customer_id} = $customer->id; |
Auch abrufbar als: Unified diff
Shopmodul: Fuzzysearch verbessert