Commit 3afdbddb by duwenjun

Merge branch 'master' into dev/ver/cloud_1.0.0

* master:
  修改key
  调整采购接口
  邮件或者短信
  更新已报价
  自动报价
  更新自动报价
  更新用户去重
  添加pdf目录
  新增、修改询价调整状态
  调整
  调整
  调整导入报价
  调整
  更新自动报价
parents 5e35695e 56c7cb5b
......@@ -3,4 +3,5 @@
Homestead.yaml
Homestead.json
.idea
.env
\ No newline at end of file
.env
storage/logs/
......@@ -25,20 +25,21 @@ class HdController extends Controller
//添加参数
private function cf(){
$mongo = \DB::connection("mongodb")
->collection("spu")
// ->where("****","***")
->first();
print_r($mongo);
die();
$param = [
["spu_name"=>"RCP0603W110RGS3","brand_name"=>"vishay"]
];
$res = (new SearchModel())->getClassName(\GuzzleHttp\json_encode($param));
print_r($res);
return;
$t = '{"0":{"inquiry_id":"1","inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"RCP0603W110RGS3","brand_id":"0","brand_name":"vishay","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","price_origin":2.9,"raw_goods_sn":"1597-1134-ND","raw_goods_packing":"Bulk","raw_brand_name":"Seeed Technology Co., Ltd"}}';
// $mongo = \DB::connection("mongodb")
// ->collection("spu")
//// ->where("****","***")
// ->first();
// print_r($mongo);
// die();
// $param = [
// ["spu_name"=>"RCP0603W110RGS3","brand_name"=>"vishay"]
// ];
// $res = (new SearchModel())->getClassName(\GuzzleHttp\json_encode($param));
// print_r($res);
//
// return;
# $t = '{"0":{"inquiry_id":"1","inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"RCP0603W110RGS3","brand_id":"0","brand_name":"vishay","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","price_origin":2.9,"raw_goods_sn":"1597-1134-ND","raw_goods_packing":"Bulk","raw_brand_name":"Seeed Technology Co., Ltd"}}';
$t = '{"0":{"inquiry_id":"109","inquiry_sn":"X2021042600489","inquiry_items_id":"300","currency":1,"goods_id":"41757","goods_name":"XC6210B332MR","brand_id":"4725","brand_name":"n//a","supplier_id":"10000","supplier_name":"猎芯自营","quote_number":"100","remark":"3-7工作日","price_rmb":"0.8457","status":1,"create_uid":1737,"create_name":"陈进"}}';
$res = (new QuoteModel())->addBatch($t);
print_r($res);
die();
......
......@@ -7,6 +7,7 @@ use Request;
use DB;
use App\Model\CmsModel;
use App\Model\Mongo\SpuModel;
use App\Http\Controllers\PermController;
//公共模型
class CommonModel extends Model
......@@ -86,10 +87,27 @@ class CommonModel extends Model
/*
* 查询采购名称
*/
public function UserList($k,$types = 1){
public function UserList($k,$types = 1)
{
$dbcms = DB::connection();
if ($types == 1) { #模糊搜索
$purInfo = $dbcms->select("select userId as value,name as name from user_info where name like '%".$k."%' limit 10");
if ($types == 1) { #模糊搜索
$perm = new PermController;
$perm->getSubDepartmentId(8, $department_ids); // 获取采购所有部门
$CmsModel = new CmsModel;
$purInfo = $CmsModel->where('status', 0)
->whereIn('department_id', $department_ids)
->where(function($query) use ($k) {
if ($k) {
$query->where('name', 'like', '%'.$k.'%');
}
})
->select('userId as value', 'name')
->get()
->toArray();
// $purInfo = $dbcms->select("select userId as value,name as name from user_info where department_id in (".json_encode($department_ids).") and status = 0 and name like '%".$k."%'");
echo json_encode($purInfo,JSON_UNESCAPED_UNICODE) ;
exit();
}else{
......@@ -148,9 +166,9 @@ class CommonModel extends Model
* 发送短信、邮件
* @param [type] $userId [指定发送人的后台ID]
* @param [type] $contents [发送内容]
* @return [type] [description]
* @param int $types 短信还是邮件: 1 发送邮件+短信 2 只发短信 3 只发邮件
*/
public function send_msg($userId, $contents)
public function send_msg($userId, $contents,$types = 1)
{
//调用消息接口
$url = Config('website.api_domain').'msg/sendmessagebyauto';
......@@ -180,7 +198,7 @@ class CommonModel extends Model
];
// 短信
if ($user_id) {
if ($user_id && $types != 3) {
$msgData['keyword'] = $keyword_text;
$msgData['touser'] = $user_id;
......@@ -190,7 +208,7 @@ class CommonModel extends Model
}
// 邮件
if ($email) {
if ($email && $types != 2) {
$msgData['keyword'] = $keyword_email;
$msgData['touser'] = json_encode([$email]);
$msgData['is_ignore'] = 1;
......
......@@ -261,6 +261,8 @@ class InquiryItemsModel extends Model
if(count($assignInsert) >0){ #插入指定人
(new InquiryItemsAssignModel())->insert($assignInsert);
}
$this->where('id', $inquiryItemsId)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
}
#日志
......@@ -342,6 +344,8 @@ class InquiryItemsModel extends Model
if(count($assignInsert) >0){ #插入指定人
$InquiryItemsAssignModel->insert($assignInsert);
}
$this->where('id', $inquiry_items_id)->update(['status' => 4]); // 存在指定采购,则标记状态为已领取
}
#发送消息
......
......@@ -217,7 +217,7 @@ class InquiryItemsReportModel extends Model
* 判断是否能生成销售单
*/
public function checkOrder($input){
$check = $this->where(["price_origin"=>0,"price_rmb"=>0])->whereIn("id",explode(",",$input["inquiry_items_id"]))->count();
$check = $this->where(["price_origin"=>0,"price_rmb"=>0])->whereIn("id",explode(",",$input["report_ids"]))->count();
return $check >0 ? [1001,"没有销售报价的报价单不能生成销售订单"] : [0,"通过"];
}
/*
......
......@@ -449,8 +449,13 @@ class InquiryModel extends Model
];
$user = \GuzzleHttp\json_decode($input["user"], true);
if ($input["user_types"] == 1) { #个人询价
if ($user[0]["value"] == 0) { #客户id是0,新建客户
$userId = (new InquiryUsersModel())->insertGetId(["create_uid" => $input["user_id"], "user_name" => $user[0]["name"], "create_time" => time()]);
if ($user[0]["value"] == 0) { #客户id是0
$userInfo= (new InquiryUsersModel())->where(["create_uid" => $input["user_id"], "user_name" => $user[0]["name"]])->first();
if ($userInfo){
$userId = $userInfo->id;
}else{
$userId = (new InquiryUsersModel())->insertGetId(["create_uid" => $input["user_id"], "user_name" => $user[0]["name"], "create_time" => time()]);
}
}else{
$userId = $user[0]["value"];
}
......
......@@ -198,6 +198,8 @@ class QuoteModel extends Model
}
$list = $list->whereNotIn('q.status', [0, -1, 9]); // 过滤报价草稿
} elseif ($type == 3) {
$list = $list->where('q.status', 0)->whereIn('q.inquiry_items_id', explode(',', $input['inquiry_items_ids']));
} elseif (@$input['inquiry_items_id'] > 0) {
$list = $list->whereNotIn('q.status', [0, -1, 9])->where('q.inquiry_items_id', $input['inquiry_items_id']);
} elseif (isset($input['inquiry_items_ids']) && $input['inquiry_items_ids']) {
......@@ -211,7 +213,12 @@ class QuoteModel extends Model
}
$list = $list->select($field)->orderBy('id', 'desc');
// dump($list->getBindings());
// dump($list->toSql());
// $tmp = str_replace('?', '"'.'%s'.'"', $list->toSql());
// $tmp = vsprintf($tmp, $list->getBindings());
// echo $tmp;
// exit;
if ($export) {
$list = $list->get()->toArray();
......@@ -347,7 +354,7 @@ class QuoteModel extends Model
{
$list = $this->from('quote as q')->join('inquiry_items as it', 'q.inquiry_items_id', '=', 'it.id');
if (isset($input['type']) && $input['type'] == 4) {
if (isset($type) && $type == 4) {
$list = $list->leftJoin('inquiry as i', 'it.inquiry_id', '=', 'i.id');
$perm = new PermController;
......@@ -563,7 +570,7 @@ class QuoteModel extends Model
/*
* 批量新增报价
* 批量新增报价(自动报价用)
*
*/
public function addBatch($indata)
......@@ -631,6 +638,7 @@ class QuoteModel extends Model
'create_name' => "系统",
]);
} else {
$v["is_auto"] = 1; #todo 2021.5.4 增加自动报价标识
$v["quote_sn"] = createSn($QuoteModel, 'quote_sn', 'B');
$v["create_time"] = time();
$v["update_time"] = time();
......@@ -661,7 +669,7 @@ class QuoteModel extends Model
$inquiry_uid = $InquiryModel->where('id', $inquiry_id)->value('create_uid'); // 询价人
$contents = '您有新报价,请及时查看!';
$CommonModel->send_msg($inquiry_uid, $contents);
$CommonModel->send_msg($inquiry_uid, $contents,2);
return [0, "新增成功"];
} catch (\Exception $e) {
......@@ -1033,7 +1041,7 @@ class QuoteModel extends Model
}
$inquiry_items_ids = explode(",", $input['inquiry_items_ids']);
$inquiry_items_ids = array_values(array_filter($inquiry_items_ids));
$inquiry_items_ids = array_unique(array_values(array_filter($inquiry_items_ids)));
try {
foreach ($inquiry_items_ids as $inquiry_items_id){
......
......@@ -91,7 +91,7 @@ return [
|
*/
'key' => env('APP_KEY'),
'key' => "base64:JzR5tuUk6qEKrnTb2cKRN8g9V/QKJSh1uLSwFBwjkO8=",
'cipher' => 'AES-256-CBC',
......
No preview for this file type
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