Commit fddf8d7f by 杨树贤

Merge branch 'dev/ver/1.0.0' of http://git.ichunt.net/semour/semour_web into dev/ver/1.0.0

parents 45aa4c3b 1ceaa074
......@@ -26,6 +26,16 @@ class HomeController extends Controller
*/
public function index()
{
// $data = [
// 'name'=>rand(100,100000),
// 'order_sn'=>rand(100,100000),
// ];
// $res = SendMsg($data,'semour_order',['13713025362'],0);
// $res = SendMsg($data,'semour_order',['578953158@qq.com'],1);
// print_r($res);
// die();
return view('home.home');
}
}
......@@ -2,6 +2,7 @@
namespace App\Http\Services;
use App\Models\Cms\CmsUserModel;
use App\Models\InquiryModel;
use App\Models\InquiryItemsModel;
use Carbon\Carbon;
......@@ -15,8 +16,9 @@ class InquiryService
$items = \Arr::get($data, 'items', []);
$items = json_decode($items, true);
$remark = $data['remark'];
$sn = self::generateSn();
$inquiry = [
'inquiry_sn' => self::generateSn(),
'inquiry_sn' => $sn,
'user_id' => $user->id,
'sales_id' => $user->sale_id,
'priority' => InquiryModel::PRIORITY_HIGH,
......@@ -35,7 +37,25 @@ class InquiryService
'remark' => $remark,
];
}
return InquiryItemsModel::addInquiryItems($inquiryItems);
$result = InquiryItemsModel::addInquiryItems($inquiryItems);
if ($result) {
//判断客户类型,如果是个人则取客户名称,如果是公司取公司名称
if ($user->account_properties == 1) {
$name = $user->name;
} else {
$name = $user->company_name;
}
if (empty($user->sale_id)) {
return true;
}
$salesEmail = CmsUserModel::where('userId', $user->sale_id)->value('email');
$data = [
'name' => $name,
'inquiry_sn' => $sn,
];
SendMsg($data, 'semour_inquire', [$salesEmail], 1);
}
return $result;
});
}
......
......@@ -4,6 +4,7 @@ namespace App\Http\Services;
use App\Exceptions\InvalidRequestException;
use App\Http\Models\User\TaxInfoModel;
use App\Models\Cms\CmsUserModel;
use App\Models\OrderAddressModel;
use App\Models\OrderItemsModel;
use App\Models\OrderModel;
......@@ -226,6 +227,19 @@ class OrderService
$con->commit();
#发送钉钉消息
$saleInfo = CmsUserModel::getInfoByUserId($userInfo["sale_id"]);
$msgData = [
'name' => $userInfo["account_properties"] == 1 ? $userInfo["name"]:$userInfo["company_name"],
'order_sn' => $order_sn,
];
if ($saleInfo["mobile"]){
SendMsg($msgData,'semour_order',[$saleInfo["mobile"]],0);
}
if ($saleInfo["email"]){
SendMsg($msgData,'semour_order',[$saleInfo["email"]],1);
}
return $order_id;
}catch (\Exception $e){
$con->rollback();
......
......@@ -26,6 +26,38 @@ if (!function_exists('generate_letters')) {
}
/*
* 发送信息
* @param array $data 替换的内容数组,["name"=>"小红"]
* @param string $key 在消息系统新建的模板编号,如:
semour_inquire 深茂询价消息
semour_order 深茂订单消息
* @param array $ToUser 指定接收人 [13713025362,13713025363]
*/
function SendMsg($data=[], $key = '', $ToUser = 'INNER_PERSON',$is_ignore = 0){
if ($key == ""){
return false;
}
$touser_json = json_encode($ToUser);
$check['touser'] = $touser_json;
$check['data'] = urldecode(json_encode($data,JSON_UNESCAPED_UNICODE));
# $check['data'] ="{\"goods_name\":\"MPVZ5004GW7U\",\"brand_name\":\"恩智浦牌\\/NXP牌\",\"goods_title\":\"多元件集成电路\",\"material_sn\":\"WL2021060300070421\",\"tax_rate_low\":\"0.7000\",\"tax_rate_land\":\"0.0000\",\"tax_rate_added\":\"13.0000\",\"supervision_con\":\"\",\"number\":\"8542391000\"}";
$check['pf'] = 1;
$check['keyword'] = $key;
$check['is_ignore'] = $is_ignore;
$check['k1']=time();
$check['k2']=MD5(MD5($check['k1'])."fh6y5t4rr351d2c3bryi");
$response = Http::asForm()->post("http://api.ichunt.com/msg/sendMessageByAuto", $check);
# print_r($response->body());
# die();
$res = json_decode($response->body(),true);
if(empty($res['err_code']) || $res['err_code']!=0) return false;
return true;
}
/*
* 反爬虫用html标签替换数字,不包括“.”
* $number 数字串
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment