进一步完成
This commit is contained in:
parent
348a990f88
commit
d715a5fcf0
|
|
@ -41,7 +41,7 @@ class ApplySmsTemp extends Command
|
||||||
$str = '亲爱的${用户昵称}您好,${店铺名称}祝您生日快乐!感谢您一直的陪伴。为您准备了${数量}张超值优惠券,已放入账户,愿我们的礼物能为您增添一份喜悦。拒收请回复R';
|
$str = '亲爱的${用户昵称}您好,${店铺名称}祝您生日快乐!感谢您一直的陪伴。为您准备了${数量}张超值优惠券,已放入账户,愿我们的礼物能为您增添一份喜悦。拒收请回复R';
|
||||||
$templateContent_arr = ShopInfo::handleSmsTemplates($str);
|
$templateContent_arr = ShopInfo::handleSmsTemplates($str);
|
||||||
$a = '{"店铺名称":"火锅店","用户昵称":"嘿嘿","数量":"123"}';
|
$a = '{"店铺名称":"火锅店","用户昵称":"嘿嘿","数量":"123"}';
|
||||||
p(replace_json_keys($a, json_encode($templateContent_arr, 256)));
|
p(replace_json_keys($a, json_encode($templateContent_arr, 256), []));
|
||||||
$t_str = replace_placeholder_keys($str, $templateContent_arr);
|
$t_str = replace_placeholder_keys($str, $templateContent_arr);
|
||||||
p($templateContent_arr, $t_str);
|
p($templateContent_arr, $t_str);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ if (!function_exists('replace_placeholder_keys')) {
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('replace_json_keys')) {
|
if (!function_exists('replace_json_keys')) {
|
||||||
function replace_json_keys($originalJson, $mapJson)
|
function replace_json_keys($originalJson, $mapJson, $user)
|
||||||
{
|
{
|
||||||
$originalData = json_decode($originalJson, true);
|
$originalData = json_decode($originalJson, true);
|
||||||
$mapData = json_decode($mapJson, true);
|
$mapData = json_decode($mapJson, true);
|
||||||
|
|
@ -168,6 +168,9 @@ if (!function_exists('replace_json_keys')) {
|
||||||
// 如果原始键在映射中存在,则替换为对应的新键;否则保留原键
|
// 如果原始键在映射中存在,则替换为对应的新键;否则保留原键
|
||||||
$newKey = $reverseMap[$oldKey] ?? $oldKey;
|
$newKey = $reverseMap[$oldKey] ?? $oldKey;
|
||||||
$newData[$newKey] = $value;
|
$newData[$newKey] = $value;
|
||||||
|
if($newKey == 'username') {
|
||||||
|
$newData[$newKey] = $user['nick_name'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$newJson = json_encode($newData, JSON_UNESCAPED_UNICODE);
|
$newJson = json_encode($newData, JSON_UNESCAPED_UNICODE);
|
||||||
return $newJson;
|
return $newJson;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class ShopInfo
|
||||||
$push_user[] = [
|
$push_user[] = [
|
||||||
'user_id' => $user['id'],
|
'user_id' => $user['id'],
|
||||||
'phone' => $user['phone'],
|
'phone' => $user['phone'],
|
||||||
'nickName' => $user['nickName'],
|
'nick_name' => $user['nickName'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $push_user;
|
return $push_user;
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,18 @@ class BirthdayGiftSms implements Consumer
|
||||||
// 待发送
|
// 待发送
|
||||||
if($record['push_status'] == 'wait_push') {
|
if($record['push_status'] == 'wait_push') {
|
||||||
$user = Db::table('tb_shop_user')->where(['id' => $record['user_id']])->find();
|
$user = Db::table('tb_shop_user')->where(['id' => $record['user_id']])->find();
|
||||||
|
// 张松 需要加主模版ID
|
||||||
|
$y_temp = Db::table('sms_shop_template')->where(['id' => $record['push_event_id']])->find();
|
||||||
if($user && !empty($user['phone'])) {
|
if($user && !empty($user['phone'])) {
|
||||||
// 检测余额
|
// 检测余额
|
||||||
$shop_money = Db::table('sms_shop_money')->where(['shop_id' => $record['main_shop_id']])->find();
|
$shop_money = Db::table('sms_shop_money')->where(['shop_id' => $record['main_shop_id']])->find();
|
||||||
if($shop_money) {
|
if($shop_money) {
|
||||||
// 余额计算
|
// 余额计算
|
||||||
if($shop_money['money'] > config('cons.sms_price')) {
|
if($shop_money['money'] > config('cons.sms_price')) {
|
||||||
|
$templateParam = replace_json_keys($record['template_content'], $y_temp['content_json'], $user);
|
||||||
$data = [
|
$data = [
|
||||||
'templateCode' => $record['template_code'],
|
'templateCode' => $record['template_code'],
|
||||||
'templateParam' => $record['template_content'],
|
'templateParam' => $templateParam,
|
||||||
'phoneNumbers' => $user['phone'],
|
'phoneNumbers' => $user['phone'],
|
||||||
'signName' => config('cons.sms_sign'),
|
'signName' => config('cons.sms_sign'),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class SendMarkSms implements Consumer
|
||||||
if($shop_money['money'] > config('cons.sms_price')) {
|
if($shop_money['money'] > config('cons.sms_price')) {
|
||||||
$templateParam = replace_json_keys($record['json'], $y_temp['content_json']);
|
$templateParam = replace_json_keys($record['json'], $y_temp['content_json']);
|
||||||
$data = [
|
$data = [
|
||||||
'templateCode' => $record['template_code'],
|
'templateCode' => $y_temp['template_code'],
|
||||||
'templateParam' => $templateParam,
|
'templateParam' => $templateParam,
|
||||||
'phoneNumbers' => $user_list['phone'],
|
'phoneNumbers' => $user_list['phone'],
|
||||||
'signName' => config('cons.sms_sign'),
|
'signName' => config('cons.sms_sign'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue