new feature on sms and some bugs fixed
This commit is contained in:
@@ -25,7 +25,9 @@ class BankAccountController extends SuperController
|
||||
$accoun->save();
|
||||
if ($accoun->sts == 2) {
|
||||
$customer = Customer::find($accoun->customer_id);
|
||||
$this->SendMessage($customer->mobile, 'کارت بانکی شما در ' . $this->Config('name_fa') . ' تایید شد');
|
||||
if (self::isSmsNotifEnabled('sms_notif_bank_card_customer')) {
|
||||
$this->SendMessage($customer->mobile, 'کارت بانکی شما در ' . $this->Config('name_fa') . ' تایید شد');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use App\Models\Message;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\SmsProfanityFilter;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
|
||||
@@ -22,6 +24,9 @@ class MassageController extends Controller
|
||||
// یافتن مشتریان با شمارههای داده شده
|
||||
$customers = Customer::whereIn('mobile', $request->numbers)->get();
|
||||
|
||||
$filter = app(SmsProfanityFilter::class);
|
||||
$filter->assertClean((string) ($request->message ?? ''));
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
// جایگزین کردن نام در پیام
|
||||
$message = str_replace('%name%', $customer->name, $request->message);
|
||||
@@ -32,6 +37,59 @@ class MassageController extends Controller
|
||||
|
||||
return response()->json(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* پیامک تکی به یک مشتری — فقط وقتی customer_direct_sms روشن باشد.
|
||||
*/
|
||||
public function send_customer_message(Request $request)
|
||||
{
|
||||
if (! app(ConfigService::class)->getBool('customer_direct_sms', false)) {
|
||||
throw new UnprocessableEntityHttpException('ارسال پیامک تکی به مشتری غیرفعال است.');
|
||||
}
|
||||
|
||||
$customerId = (int) ($request->input('customer_id') ?? 0);
|
||||
$rawMessage = trim((string) ($request->input('message') ?? ''));
|
||||
|
||||
if ($customerId <= 0) {
|
||||
throw new UnprocessableEntityHttpException('مشتری مشخص نشده است.');
|
||||
}
|
||||
if ($rawMessage === '') {
|
||||
throw new UnprocessableEntityHttpException('متن پیامک خالی است.');
|
||||
}
|
||||
if (mb_strlen($rawMessage) > 700) {
|
||||
throw new UnprocessableEntityHttpException('متن پیامک بیش از حد طولانی است.');
|
||||
}
|
||||
|
||||
app(SmsProfanityFilter::class)->assertClean($rawMessage);
|
||||
|
||||
$customer = Customer::find($customerId);
|
||||
if (! $customer || ! $customer->mobile) {
|
||||
throw new UnprocessableEntityHttpException('مشتری یا شماره موبایل یافت نشد.');
|
||||
}
|
||||
|
||||
$cfg = app(ConfigService::class);
|
||||
$appName = (string) ($cfg->get('name_fa', '') ?: '');
|
||||
$appUrl = (string) ($cfg->get('app_url', '') ?: '');
|
||||
|
||||
$message = str_replace(
|
||||
['%name%', '%نام%', '%app_name%', '%نام_اپ%', '%app_url%', '%لینک_اپ%', '%لینک%'],
|
||||
[
|
||||
(string) $customer->name,
|
||||
(string) $customer->name,
|
||||
$appName,
|
||||
$appName,
|
||||
$appUrl,
|
||||
$appUrl,
|
||||
$appUrl,
|
||||
],
|
||||
$rawMessage
|
||||
);
|
||||
|
||||
$this->send($customer->mobile, $message);
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
public function getFunctionDescriptions()
|
||||
{
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class WalletController extends Controller
|
||||
|
||||
//send sms to users and customer
|
||||
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
||||
if($this->Config('charge_notif') == "true"){
|
||||
if (self::isSmsNotifEnabled('charge_notif')) {
|
||||
$message = 'کیف پول کاربر ' . $customer->name . ' به مقدار ' . self::formatSmsRialAmount($data['value']) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
. "\n"
|
||||
@@ -150,13 +150,13 @@ class WalletController extends Controller
|
||||
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data) {
|
||||
$this->send($admin->mobile, $message);
|
||||
});
|
||||
}
|
||||
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsRialAmount($data['value']) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
. "\n"
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsRialAmount($data['value']) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
. "\n"
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
}
|
||||
$this->broadcastCustomerWalletAssets($customer);
|
||||
|
||||
return response()->json(true);
|
||||
@@ -215,7 +215,7 @@ class WalletController extends Controller
|
||||
//send sms to users and customer
|
||||
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
||||
$weightUnit = self::tradeWeightUnit();
|
||||
if($this->Config('charge_notif') == "true"){
|
||||
if (self::isSmsNotifEnabled('charge_notif')) {
|
||||
$message = 'کیف پول کاربر ' . $customer->name . ' به مقدار ' . self::formatSmsGoldWeight($data['value']) . " {$weightUnit} در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
. "\n"
|
||||
@@ -223,12 +223,12 @@ class WalletController extends Controller
|
||||
User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data) {
|
||||
$this->send($admin->mobile, $message);
|
||||
});
|
||||
}
|
||||
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsGoldWeight($data['value']) . " {$weightUnit} در تاریخ " . verta()->format('Y/n/j H:i:s') . $status . " بابت" . "\n"
|
||||
. $data['note']
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
$message = 'کیف پول شما به اندازه ' . self::formatSmsGoldWeight($data['value']) . " {$weightUnit} در تاریخ " . verta()->format('Y/n/j H:i:s') . $status . " بابت" . "\n"
|
||||
. $data['note']
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
}
|
||||
$this->broadcastCustomerWalletAssets($customer);
|
||||
|
||||
return response()->json(true);
|
||||
@@ -364,7 +364,7 @@ class WalletController extends Controller
|
||||
$status = $deposit ? ' شارژ شد ' : ' کسر شد ';
|
||||
$formatted = self::formatSmsGoldWeight($data['value']);
|
||||
|
||||
if ($this->Config('charge_notif') == 'true') {
|
||||
if (self::isSmsNotifEnabled('charge_notif')) {
|
||||
$message = 'کیف پول کاربر ' . $customer->name . ' به مقدار ' . $formatted . ' ' . $unitLabel . ' در تاریخ ' . verta()->format('Y/n/j H:i:s') . $status . 'بابت' . "\n"
|
||||
. ($data['note'] ?? '')
|
||||
. "\n"
|
||||
@@ -372,13 +372,13 @@ class WalletController extends Controller
|
||||
User::where('send_sms', 1)->get()->each(function ($admin) use ($message) {
|
||||
$this->send($admin->mobile, $message);
|
||||
});
|
||||
}
|
||||
|
||||
$message = 'کیف پول شما به اندازه ' . $formatted . ' ' . $unitLabel . ' در تاریخ ' . verta()->format('Y/n/j H:i:s') . $status . ' بابت' . "\n"
|
||||
. ($data['note'] ?? '')
|
||||
. "\n"
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
$message = 'کیف پول شما به اندازه ' . $formatted . ' ' . $unitLabel . ' در تاریخ ' . verta()->format('Y/n/j H:i:s') . $status . ' بابت' . "\n"
|
||||
. ($data['note'] ?? '')
|
||||
. "\n"
|
||||
. $this->Config('name_fa');
|
||||
$this->Send($customer->mobile, $message);
|
||||
}
|
||||
$this->broadcastCustomerWalletAssets($customer);
|
||||
|
||||
return response()->json(true);
|
||||
|
||||
Reference in New Issue
Block a user