fix: review feedback
This commit is contained in:
parent
62e0a471aa
commit
db2da3543d
4 changed files with 20 additions and 20 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Api\v1;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Campagne;
|
||||
use App\Coupon;
|
||||
use App\Enums\LogActions;
|
||||
|
|
@ -35,7 +36,7 @@ class BasketController extends Controller
|
|||
// ---- Contrôle des paramètres
|
||||
$error = false;
|
||||
if (
|
||||
(!isset($request->refadherent) || $request->refadherent == "") ||
|
||||
(!isset($request->customer_hashcode) || $request->customer_hashcode == "") ||
|
||||
(!isset($request->refcamp) || $request->refcamp == "") ||
|
||||
(!isset($request->refsite) || $request->refsite == "") ||
|
||||
(!isset($request->panier) || $request->panier == "")
|
||||
|
|
@ -100,8 +101,8 @@ class BasketController extends Controller
|
|||
if ($error) {
|
||||
$this->writeLogErrorWrongRequestParameters(
|
||||
$request->refcamp,
|
||||
$request->refadherent,
|
||||
$request->refsite,
|
||||
$request->customer_hashcode,
|
||||
$campagne->camp_siteId,
|
||||
$request->panier
|
||||
);
|
||||
|
||||
|
|
@ -112,8 +113,8 @@ class BasketController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
// ---- Ajout/MAJ du customer
|
||||
$customer = Customers::where(['hashcode' => $request->refadherent])->first();
|
||||
// ---- Récupération du Customer
|
||||
$customer = Customers::where(['hashcode' => $request->customer_hashcode])->first();
|
||||
|
||||
// ---- Ajout/MAJ du panier
|
||||
$panier = Basket::where(['campagne_id' => $refcamp, 'customer_id' => $customer->id])->first();
|
||||
|
|
@ -136,7 +137,7 @@ class BasketController extends Controller
|
|||
} else {
|
||||
// Ajout du panier et du contenu
|
||||
$panier = new Basket();
|
||||
$panier->ref = strtoupper(md5(uniqid(time(), true)));
|
||||
$panier->ref = Str::uuid();
|
||||
$panier->campagne()->associate($refcamp);
|
||||
$panier->customer()->associate($customer);
|
||||
$panier->save();
|
||||
|
|
@ -152,7 +153,7 @@ class BasketController extends Controller
|
|||
|
||||
$this->writeLogSuccessBasketCreated(
|
||||
$request->refcamp,
|
||||
$request->refadherent,
|
||||
$request->customer_hashcode,
|
||||
$request->refsite,
|
||||
$request->panier,
|
||||
$panierCoupons
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ class Customers extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Basket model relation
|
||||
* Panier model relation
|
||||
* @return HasMany
|
||||
*/
|
||||
public function paniers()
|
||||
{
|
||||
return $this->hasMany(Panier::class, 'customer_id', 'id');
|
||||
return $this->hasMany(Panier::class, 'panier_contactId', 'id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ class MesBR
|
|||
|
||||
private $refCamp;
|
||||
|
||||
public function __construct($endpoint, $refCamp)
|
||||
private $refSite;
|
||||
|
||||
public function __construct($endpoint, $refCamp, $refSite)
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
$this->refCamp = $refCamp;
|
||||
$this->refSite = $refSite;
|
||||
}
|
||||
|
||||
public function createCustomer(string $hashcode, string $email, string $country)
|
||||
|
|
@ -90,25 +93,21 @@ class MesBR
|
|||
* Update basket
|
||||
*
|
||||
* @param \LDC\LDCCRM\Models\Customer $crm_customer
|
||||
* @param string $ref_site
|
||||
* @param string $coupon_id
|
||||
* @param integer $quantity
|
||||
* @return array<string,string>
|
||||
* 'status' => 'OK',
|
||||
* 'link' => URL,
|
||||
* 'verif' => URL,
|
||||
* 'basketId' => 'ID'
|
||||
* 'ref' => Basket REF,
|
||||
*/
|
||||
public function updateBasket(
|
||||
Customer $crm_customer,
|
||||
string $ref_site,
|
||||
string $coupon_id,
|
||||
int $quantity = 1
|
||||
): array {
|
||||
$res = $this->callAPI("GET", "/customer/basket/update", [
|
||||
'refsite' => $ref_site,
|
||||
'refsite' => $this->refSite,
|
||||
'refcamp' => $this->refCamp,
|
||||
'refadherent' => $crm_customer->hashcode,
|
||||
'customer_hashcode' => $crm_customer->hashcode,
|
||||
'panier' => "({$quantity}){$coupon_id}"
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('site_user', function (Blueprint $table) {
|
||||
$table->dropForeign('site_user_site_id_foreign');
|
||||
$table->dropForeign('site_user_user_id_foreign');
|
||||
Schema::table('printed_coupons', function (Blueprint $table) {
|
||||
$table->dropColumn('id');
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue