Commit d6bf41e8 by 朱继来

合并v3.09

parents f3d4e84c 6abb2f02
...@@ -193,6 +193,13 @@ class ApiController extends Controller ...@@ -193,6 +193,13 @@ class ApiController extends Controller
$data['id'] = $request->input('id'); $data['id'] = $request->input('id');
$data['remarks'] = $request->input('remarks'); $data['remarks'] = $request->input('remarks');
$data['buyer_id'] = $request->input('userId');//采购id
$data['batch'] = $request->input('batch');//采购id
if($data['buyer_id'] == -1){
unset($data['buyer_id']);
}
$result = $OrderItemsModel->updateData($data); $result = $OrderItemsModel->updateData($data);
...@@ -204,4 +211,22 @@ class ApiController extends Controller ...@@ -204,4 +211,22 @@ class ApiController extends Controller
} }
/*
检查内部系统用户是否存在
*/
public function check_user_exists($request){
$CmsModel = new CmsModel();
$userName = $request->input('user');
$user_info = $CmsModel->getUserInfo(array('name'=>$userName));
if($user_info){
$this->Export(1, 'success',$user_info['userId']);
}else{
$this->Export(-1, 'error');
}
}
} }
...@@ -17,6 +17,7 @@ use App\Model\UserMainModel; ...@@ -17,6 +17,7 @@ use App\Model\UserMainModel;
use App\Model\OrderActionLogModel; use App\Model\OrderActionLogModel;
use App\Model\OrderReturnModel; use App\Model\OrderReturnModel;
use App\Model\OrderItemsTrackModel; use App\Model\OrderItemsTrackModel;
use App\Model\CmsModel;
use Session; use Session;
use Hprose\Http\Client; use Hprose\Http\Client;
...@@ -401,6 +402,7 @@ Class OrderController extends Controller ...@@ -401,6 +402,7 @@ Class OrderController extends Controller
// 页面参数 // 页面参数
$map['order_type'] = $request->input('order_type', ''); $map['order_type'] = $request->input('order_type', '');
$map['select_time_val'] = $request->input('select_time_val', '');
$map['order_contain'] = $request->input('order_contain', ''); $map['order_contain'] = $request->input('order_contain', '');
$map['order_sn'] = $request->input('order_sn', ''); $map['order_sn'] = $request->input('order_sn', '');
$map['erp_sn'] = $request->input('erp_sn', ''); $map['erp_sn'] = $request->input('erp_sn', '');
...@@ -747,6 +749,7 @@ Class OrderController extends Controller ...@@ -747,6 +749,7 @@ Class OrderController extends Controller
public function templateData(Request $request, $id, $view_id) public function templateData(Request $request, $id, $view_id)
{ {
$info = $this->orderDetail($request, $id); $info = $this->orderDetail($request, $id);
$this->pageHeader($request, $info, '订单详情'); $this->pageHeader($request, $info, '订单详情');
if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单 if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单
...@@ -760,6 +763,38 @@ Class OrderController extends Controller ...@@ -760,6 +763,38 @@ Class OrderController extends Controller
return view($view_id, $info); return view($view_id, $info);
} }
/*
获取采购人名称
*/
public function getBuyerName(&$info){
if(count($info['order_items_info']) <=0){
return;
}
foreach ($info['order_items_info'] as $key => $value) {
$data[] = $value['buyer_id'];
}
$CmsModel = new CmsModel();
$name_data = $CmsModel->getBatchUserName($data);
foreach ($info['order_items_info'] as $key => $value) {
foreach ($name_data as $k => $v) {
if($v['userId'] == $value['buyer_id']){
$info['order_items_info'][$key]['buyerName'] = $v['name'];
$info['order_items_info'][$key]['send_email'] = $v['email'];
break;//找到了就不必再循环这个数组了
}
}
}
}
// 详情页自营其他数据 // 详情页自营其他数据
public function selfOtherData(&$info, $order_id) public function selfOtherData(&$info, $order_id)
{ {
...@@ -790,6 +825,7 @@ Class OrderController extends Controller ...@@ -790,6 +825,7 @@ Class OrderController extends Controller
public function changeOrder(Request $request, $id) public function changeOrder(Request $request, $id)
{ {
$info = $this->orderDetail($request, $id); $info = $this->orderDetail($request, $id);
$this->pageHeader($request, $info, '人工审单', ["title" => '人工审单', "href" => '#']); $this->pageHeader($request, $info, '人工审单', ["title" => '人工审单', "href" => '#']);
if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单 if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单
...@@ -1549,6 +1585,9 @@ Class OrderController extends Controller ...@@ -1549,6 +1585,9 @@ Class OrderController extends Controller
$response = array_merge($response, $info); $response = array_merge($response, $info);
// 获取数组中的采购人id的名字
$this->getBuyerName($response);
return $response; return $response;
} }
...@@ -2020,4 +2059,100 @@ Class OrderController extends Controller ...@@ -2020,4 +2059,100 @@ Class OrderController extends Controller
}); });
} }
/*
发送邮件
*/
public function send_mail(Request $request){
$id = $_REQUEST['id'];
$info = $this->orderDetail($request, $id);
//循环订单详情
foreach ($info['order_items_info'] as $key => $value) {
$tmp['orderNum'] = $info['order_temp_info']['erp_sn'];
$tmp['goods'] = $value['goods_name'];
$tmp['purchasingPrice'] = $value['goods_price'];//采购价
$tmp['unitPrice'] = $value['goods_price'];//单价
$tmp['brand'] = $value['brand_name'];
$tmp['nums'] = $value['goods_number'];
$tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元';
$tmp['totalPrice'] = $value['goods_amount'];
$tmp['remarks'] = $value['remarks'];
$tmp['material'] = $value['erp_rec_id'];
$tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:'';
$tmp['projectId'] = $key+1;
if(empty($value['batch'])){
$msg = '商品:'.$tmp['goods'].'缺少批次<br/>'.'请填写批次后再发送';
echo json_encode(['errcode'=>-1,'errmsg'=>$msg]);
exit;
}
if(empty($value['buyerName'])){
$msg = '商品:'.$tmp['goods'].'缺少采购人员<br/>'.'请填写采购后再发送';
echo json_encode(['errcode'=>-1,'errmsg'=>$msg]);
exit;
}
//批次
$tmp['deliveryTime'] = $value['batch'];
$tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:'';
$data['data'][] = $tmp;
}
//循环出邮件接收人
foreach ($data['data'] as $key => $value) {
$send_mail_array[] = $value['send_email'];
}
$send_mail_array = array_unique($send_mail_array);
$data['combined'] = $info['order_info']['order_amount'];
$data['order_amount'] = $info['order_info']['order_amount'];
$data['date'] = date('Y-m-d',time());
if(empty($send_mail_array[0])){
echo json_encode(['errcode'=>-1,'errmsg'=>'没有填写采购人员,请至少填写一个采购人员']);
exit;
}
$data['toUser'] = $send_mail_array[0];
unset($send_mail_array[0]);
$data['ccUser'] = $send_mail_array;
$CmsModel = new CmsModel();
//获取业务员
$data['id'] = $CmsModel->getUserName($info['order_info']['sale_id']);
$crm_url = Config('website.crm_domain').'/api/sendCaiGouEmailByOrderAdmin';
$data = json_encode($data);
$crm_header = array('api-key: crm a1b2c3d4e5f6g7h8i9jk');
$res = json_decode(post_curl($crm_url, $data,$crm_header));
if(!empty($res->err_code) && $res->err_code == 0){
echo json_encode(['errcode'=>1,'errmsg'=>'发送成功']);
exit;
}else{
echo json_encode(['errcode'=>-1,'errmsg'=>'邮件发送接口错误,邮件发送失败']);
exit;
}
}
} }
\ No newline at end of file
...@@ -483,3 +483,28 @@ function S_hash($key, $field='', $value='') ...@@ -483,3 +483,28 @@ function S_hash($key, $field='', $value='')
return $redis->hset($key, $field, $value); return $redis->hset($key, $field, $value);
} }
// curl post
function post_curl($url, $data, $headers = array(), $cookie ="")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
if (count($headers)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if ($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if (strpos($url, 'https://') !== false) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
\ No newline at end of file
...@@ -62,6 +62,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -62,6 +62,7 @@ Route::group(['middleware' => 'web'], function () {
Route::resource('/prompt', 'PromptController@index'); Route::resource('/prompt', 'PromptController@index');
Route::get('/count', 'OrderCountController@count'); Route::get('/count', 'OrderCountController@count');
Route::post('/send_mail', 'OrderController@send_mail');
Route::get('/self_count', 'OrderCountController@selfCount'); Route::get('/self_count', 'OrderCountController@selfCount');
Route::get('/amount', 'OrderCountController@amount'); Route::get('/amount', 'OrderCountController@amount');
Route::get('/self_amount', 'OrderCountController@selfAmount'); Route::get('/self_amount', 'OrderCountController@selfAmount');
......
...@@ -32,4 +32,20 @@ class CmsModel extends Model ...@@ -32,4 +32,20 @@ class CmsModel extends Model
return $user ? $user->userId : 0; return $user ? $user->userId : 0;
} }
/*
查询cms系统用户信息
*/
public function getUserInfo($where){
return $this->where($where)->select('userId')->first();
}
/*
批量查询用户姓名
*/
public function getBatchUserName($user_ids){
return $this->whereIn('userId',$user_ids)->select('userId','name','email')->get()->toArray();
}
} }
\ No newline at end of file
...@@ -43,11 +43,22 @@ ...@@ -43,11 +43,22 @@
</dd> </dd>
</dl> </dl>
<dl> <dl>
<dt>创建日期: </dt> <dd style="width: 110px;">
<dd style="width:auto !important;"> <div class="droplist" data-default="{{$condition['select_time_type']}}" id="select_time_type" name="select_time_type">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" /> <ul class="dropdown-menu">
<li class="select_time_type_tab active" data-val="">创建日期</li>
<li class="select_time_type_tab" data-val="1">审核日期</li>
<li class="select_time_type_tab" data-val="2">收款日期</li>
<li class="select_time_type_tab" data-val="3">发货日期</li>
<li class="select_time_type_tab" data-val="4">订单完成</li>
</ul>
</div>
</dd> </dd>
<dd style="width:auto !important;"> <!-- <dt>创建日期: </dt> -->
<dd style="width: 120px;">
<input type="text" name="time_start" value="{{ !empty($condition['time_start']) ? date('Y/m/d', $condition['time_start']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="开始时间" autocomplete="off" style="width: 140px;" />
</dd>
<dd style="width: 120px; margin-left: 20px;">
<input type="text" name="time_end" value="{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="结束时间" autocomplete="off" /> <input type="text" name="time_end" value="{{ !empty($condition['time_end']) ? date('Y/m/d', $condition['time_end']) : '' }}" class="Wdate " onfocus="WdatePicker({dateFmt:'yyyy/MM/dd'})" placeholder="结束时间" autocomplete="off" />
</dd> </dd>
</dl> </dl>
...@@ -69,6 +80,9 @@ ...@@ -69,6 +80,9 @@
</select> </select>
</dd> </dd>
</dl> </dl>
<dl> <dl>
<dt>付款类型:</dt> <dt>付款类型:</dt>
<dd> <dd>
......
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