Commit 5d6f7776 by 朱继来

导入销售报价

parent 9a1c7220
......@@ -61,10 +61,7 @@ Class AddOrderController extends Controller
$info = $this->getPageInfo($request);
$info['title'] = '新增联营订单';
$info['sale_id'] = $request->user->userId;
$crm_user_id = $request->input('user_id', 0);
$info['crm_account'] = '';
if ($crm_user_id) {
......@@ -78,8 +75,9 @@ Class AddOrderController extends Controller
$url = Config('website.api_domain').'cart/getDJKConfg';
$info['api_dgk_url'] = ($url.'?k1='.$data['k1']."&".'k2='.$data['k2']);
$info['company'] = (new CmsModel())->getCompany(); // 获取公司组织
$info['company'] = (new CmsModel())->getCompany(); // 获取公司组织
$info['report_ids'] = $request->input('report_ids', ''); // 询价系统销售报价ID
return view('addOrder', $info);
}
......
......@@ -31,6 +31,7 @@ use App\Model\OrderServiceLogModel;
use App\Model\OrderRefundModel;
use App\Model\OrderRefundLogModel;
use DB;
use App\Model\Frq\InquiryItemsReportModel;
class ApiController extends Controller
{
......@@ -623,5 +624,61 @@ class ApiController extends Controller
return DB::connection('order')->table('lie_region')->where('region_id', $id)->value('region_name');
}
// 导入销售报价物料
public function importGoods($request)
{
$user_id = $request->input('user_id', 0);
$report_ids = $request->input('report_ids', '');
if (!$user_id || !$report_ids) $this->Export(-1, '参数缺失');
$report_ids = explode(',', $report_ids);
$InquiryItemsReportModel = new InquiryItemsReportModel;
$inquiry = $InquiryItemsReportModel->getData($report_ids);
if (empty($inquiry)) $this->Export(-2, '未获取到销售报价明细');
$items = [];
foreach ($inquiry as $k=>$v) {
$goods_price = $v['currency'] == 1 ? $v['price_rmb'] : $v['price_origin'];
if ($goods_price <= 0) $this->Export(-3, '导入销售报价明细,商品:'.$v['goods_name'].' 单价不能为0');
if ($v['inquiry_number'] <= 0) $this->Export(-3, '导入销售报价明细,商品:'.$v['goods_name'].' 数量不能为0');
$items[$k]['id'] = $v['goods_id'];
$items[$k]['goods_name'] = $v['goods_name'];
$items[$k]['brand_name'] = $v['brand_name'];
$items[$k]['supplier_name'] = $v['supplier_name'];
$items[$k]['num'] = $v['inquiry_number'];
$items[$k]['goods_price'] = $goods_price;
$items[$k]['delivery_time'] = $v['delivery_time'];
$items[$k]['buyer_id'] = 0;
$items[$k]['remarks'] = '';
$items[$k]['batch'] = $v['batch'];
$items[$k]['raw_goods_sn'] = $v['raw_goods_sn'];
$items[$k]['raw_goods_packing'] = $v['raw_goods_packing'];
$items[$k]['raw_brand_name'] = $v['raw_brand_name'];
}
$delivery_place = $inquiry[0]['currency'] == 1 ? 1 : 2;
// 推送到API
$data['data'] = $items;
$data['operator_id'] = $request->user->userId;
$data['operator_name'] = $request->user->name;
$data['type'] = 4; // 批量导入销售报价
$data['uid'] = $user_id;
$data['delivery_place'] = $delivery_place;
$url = Config('website.api_domain').'cart/addBatchByOrderSystem';
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$temp = json_decode(curlApi($url, $data, "POST"), true);
$this->Export($temp['err_code'], $temp['err_msg']);
}
}
<?php
namespace App\Model\Frq;
use Illuminate\Database\Eloquent\Model;
class InquiryItemsReportModel extends Model
{
protected $connection = 'frq';
protected $table = 'inquiry_items_report';
protected $primaryKey = 'id';
public $timestamps = false;
// 获取指定销售报价
public function getData($id)
{
if (is_array($id)) return $this->whereIn('id', $id)->get()->toArray();
return $this->where('id', $id)->first();
}
}
\ No newline at end of file
......@@ -109,6 +109,7 @@ return [
'prefix' => 'lie_',
'strict' => false,
],
'bom' => [
'driver' => 'mysql',
'host' => env('DB_HOST_BOM', ''),
......@@ -121,6 +122,20 @@ return [
'prefix' => 'lie_',
'strict' => false,
],
'frq' => [
'driver' => 'mysql',
'host' => env('DB_HOST_RFQ', ''),
'database' => env('DB_DATABASE_RFQ', ''),
'username' => env('DB_USERNAME_RFQ', ''),
'password' => env('DB_PASSWORD_RFQ', ''),
'port' => env('DB_PORT_RFQ', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
......
......@@ -21,7 +21,7 @@ layui.config({
// 公司、账号输入后,赋值ID,并检查绑定客服、发票
$('.inv-user-info').blur(function() {
var val = $(this).val();
var val = $(this).val();
var type = $(this).data('type'); // 1-公司,2-会员账号
if (!val) return false;
......@@ -40,6 +40,12 @@ layui.config({
$('.' + field).val(resp.data);
checkBindUser();
if (type == 2 && resp.data && report_ids) { // 会员ID、销售报价ID存在
importGoods(resp.data, report_ids);
return false;
}
renderTable();
}
})
......@@ -118,6 +124,30 @@ layui.config({
},
})
}
// importGoods(70132, '48,49');
// 导入销售报价的物料
function importGoods(user_id, report_ids)
{
var datax = {};
datax.user_id = user_id;
datax.report_ids = report_ids;
$.ajax({
type: "POST",
url: '/api/importGoods',
data: datax,
dataType: "json",
success: function(resp){
if (resp.errcode != 0) {
layer.alert(resp.errmsg);
return false;
}
layer.msg('导入销售报价明细成功');
renderTable();
}
})
}
// 选择个人发票
form.on('select(user_tax_id)', function(data) {
......@@ -568,7 +598,7 @@ layui.config({
return false;
}
if (inv_type == 3) { // 专票
if (inv_type == 3) { // 增值税专票
var tax_title = $('.tax_title').text();
var tax_no = $('.tax_no').text();
var com_bank = $('.com_bank').text();
......@@ -605,7 +635,7 @@ layui.config({
layer.msg('发票信息不完善:无注册地址');
return false;
}
} else if (inv_type == 4) {
} else if (inv_type == 4) { // 增值税普票
var tax_title = $('.tax_title_1').text();
var tax_no = $('.tax_no_1').text();
......
......@@ -52,4 +52,9 @@
</div>
</div>
</form>
</div>
\ No newline at end of file
</div>
<script>
var report_ids = "{{ $report_ids }}";
console.log(report_ids)
</script>
\ No newline at end of file
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