Commit d5e9f16b by 朱继来

Merge branch 'master' of http://119.23.72.7/zhujilai/Order into zjl_brand_20200608

parents fc990db3 def0c6dd
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use DB;
use Log;
use Illuminate\Support\Facades\Redis;
class JingDiaoUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'JingDiao:ClearUser';
/**
* The console command description.
*
* @var string
*/
protected $description = '清除静调用户是手机号的';
public function userids(){
return [
67483,
63302,
63226,
63060,
61626,
48191,
48138,
47988,
47609,
47135,
46989,
46751,
46416,
46397,
46004,
45545,
45072,
45015,
44946,
44836,
44817,
44740,
43794,
43774,
42750,
42226,
42149,
42077,
40962,
40442,
40270,
40193,
40181,
39816,
39583,
39367,
38481,
38408,
36793,
36309,
35664,
35619,
35450,
33633,
33606,
33176,
32802,
29621,
29458,
26923,
19816,
19811,
19801,
19616,
19563,
19540,
18755,
8936 ,
4745 ,
4469 ,
4355 ,
4291 ,
4289 ,
4200 ,
4171 ,
4063 ,
4054 ,
4044 ,
4024 ,
4011 ,
3962 ,
3961 ,
3924 ,
3812 ,
3783 ,
3759 ,
3752 ,
3624 ,
3623 ,
3546 ,
3495 ,
3491 ,
3489 ,
3460 ,
3394 ,
3268 ,
3260 ,
3249 ,
10
];
}
/*
* 修改用户总积分
*/
public function handle(){
$userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{
DB::Connection("order")->beginTransaction();
foreach($users as $user_id){
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user_id])->update([
"is_type"=>0,
]);
continue;
$zjf_z = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",1)->sum("flow_point");
$zjf_f = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_type",2)->sum("flow_point");
$jifen = intval($zjf_z - $zjf_f);
dump(sprintf("userid:%s 的积分为:%s",$user_id,$jifen));
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
$bk = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$jifen,
"cur_total_point"=>$jifen,
]);
dump($bk);
}
DB::Connection("order")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
}
}
/**
* is_type=1 假用户
* 给下过单的静调用户 增加订单积分
*/
public function handle_addorder_JIFEN()
{
$userids = $this->userids();
$users = DB::Connection("order")->table("lie_user_main")->whereIn("user_id",$userids)->where("is_type","=",1)->pluck("user_id");
try{
DB::Connection("order")->beginTransaction();
foreach($users as $user_id){
// $a = DB::Connection("order")->table("lie_point_log")->where("user_id",$user_id)->where("flow_reason_type",3)->delete();
// dump($a);
// continue;
$orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])
->where("status",">=",10)
->where("create_time",">",1540656000)
->select("order_amount","order_goods_type","is_type","order_pay_type","integral","status","order_id","create_time")->get();
// dump($orders);
$zong_jifen = 0;
$userMobile = DB::Connection("order")->table("lie_user_main")->where("user_id",$user_id)->select("mobile")->first();
foreach($orders as $k=>$order){
$jifen = 0;
if($order->order_pay_type == 3){
$jifen += intval($order->order_amount)*0.7;
}else{
if($order->order_goods_type == 1){
$jifen += intval($order->order_amount);
}elseif($order->order_goods_type == 2){
$jifen += intval($order->order_amount)*2;
}
}
$jifen = intval($jifen);
//增加积分
$jifenData = [
"user_id"=>$user_id,
"user_account"=>$userMobile->mobile,
"flow_type"=>1,
"flow_point"=>$jifen,
"flow_time"=>$order->create_time,
"flow_reason_type"=>3,
"flow_extra_id"=>$order->order_id,
"flow_pf"=>4,
"operator_uid"=>1000,
"operator_name"=>"",
"remark"=>"",
];
// dump($jifenData);
$bk = DB::Connection("order")->table("lie_point_log")->insert($jifenData);
if(!$bk){
throw new \Exception("添加数据失败");
}
$zong_jifen += $jifen;
}
$zong_jifen = intval($zong_jifen);
$userInfo = DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->select("cur_user_point","cur_total_point")->first();
if(!$userInfo){
$userInfo = DB::Connection("order")->table("lie_user_info")->insert([
"user_id"=>$user_id,
"cur_user_point"=>$zong_jifen,
"cur_total_point"=>$zong_jifen,
]);
}
DB::Connection("order")->table("lie_user_info")->where(["user_id"=>$user_id])->update([
"cur_user_point"=>$userInfo->cur_user_point,
"cur_total_point"=>$userInfo->cur_total_point,
]);
if($zong_jifen > 0){
dump(sprintf("user_id:%s 积分:%s", $user_id,$zong_jifen));
}
}
DB::Connection("order")->commit();
}catch(\Exception $e){
dump($e->getMessage());
DB::Connection("order")->rollBack();
}
}
function randMobile($type=0){
//手机号2-3为数组
$yidong = [
"34",
"35",
"36",
"37",
"38",
"39",
"47",
"50",
"51",
"52",
"57",
"58",
"59",
"78",
"82",
"83",
"84",
"87",
"88",
"98",
];
$liantong =[
"30",
"31",
"32",
"45",
"55",
"56",
"66",
"71",
"75",
"76",
"85",
"86"];
$dianxin = [
"33",
"49",
"53",
"73",
"77",
"80",
"81",
"89",
"99",
];
$mobileType = [$yidong,$liantong,$dianxin];
$mobile = 1;
$mobile .= $mobileType[$type][rand(0,count($mobileType[$type])-1)];
$mobile .= str_pad(rand(0,99999999),8,0,STR_PAD_LEFT);
$result = $mobile;
return $result;
}
protected function getOtherEmail($type=0){
$hz = ["@139.com","@wo.com.cn","@189.cn"];
$mobile = $this->randMobile($type);
$email = $mobile.$hz[$type];
return $email;
}
protected function getQQEmail(){
$strs="123456789012345678901234567890";
$name=substr(str_shuffle($strs),mt_rand(0,23),mt_rand(7,11));
$name = $name."@qq.com";
return $name;
}
protected function getEmail($type=0){
if(in_array($type,[0,1,2])){
$emial = $this->getOtherEmail($type);
}else{
$emial = $this->getQQEmail();
}
$count = DB::connection('order')
->table('lie_user_main')
->where(["email"=>$emial])->count();
if($count){
$this->getEmail($type);
}
return $emial;
}
/**
* 静调用户手机号转邮箱
*/
public function handle_mobila_email()
{
$countN=0;
$userJD = [];
DB::Connection("order")->table("lie_user_main")->select("user_id","mobile","is_type")->OrderBy("user_id","desc")->whereRaw(" is_type = 1 and mobile != '' ")
->chunk(100, function($users) use(&$countN,&$userJD) {
foreach ($users as $user) {
$user_id = $user->user_id;
$logs = null;
$orders = null;
$logs = DB::Connection("order")->table("lie_user_login")->where(["user_id"=>$user_id])->count("id");
$orders = DB::Connection("order")->table("lie_order")->where(["user_id"=>$user_id,"is_type"=>0])->count("order_id");
if(!$logs && !$orders){
dump($user->user_id);
Log::info(sprintf("user_id:%s,mobile:%s,is_type:%s",$user->user_id,$user->mobile,$user->is_type));
$email = $this->getEmail(mt_rand(0,3));
dump($email);
$redis = Redis::connection('userssssss');
$tmp = $redis->hget("api_user",$user->user_id);
if($tmp){
$tmp_arr = json_decode($tmp,true);
if(!empty($tmp_arr)){
$tmp_arr["mobile"]="";
$tmp_arr["email"]=$email;
$redis->hset("api_user",$user->user_id,json_encode($tmp_arr));
}
}
$redis->hdel("api_mobile",$user->mobile);
$redis->hset("api_email",$email,$user->user_id);
DB::Connection("order")->table("lie_user_main")->where(["user_id"=>$user->user_id])->update([
"mobile"=>"",
"email"=>$email
]);
}
}
});
dump($countN);
dump($userJD);
}
}
...@@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel ...@@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
*/ */
protected $commands = [ protected $commands = [
Commands\Inspire::class, Commands\Inspire::class,
\App\Console\Commands\JingDiaoUser::class,
]; ];
/** /**
...@@ -24,7 +25,6 @@ class Kernel extends ConsoleKernel ...@@ -24,7 +25,6 @@ class Kernel extends ConsoleKernel
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
$schedule->command('inspire')
->hourly();
} }
} }
<?php
namespace App\Exceptions;
class BomException extends \Exception{
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Bom\BomService;
class BomApiController extends Controller{
public $bomService =null;
public function __construct()
{
$this->bomService = new BomService;
}
public function Entrance(Request $request,$id){
return call_user_func_array([$this,$id],[$request, $id]);
}
private function ajaxReturn($errcode=0,$errmsg='成功',$data=''){
if(is_array($errcode)){
ErrorLog($errcode[0],$errcode[1]);
return [
'errcode'=>$errcode[0],
'errmsg'=>$errcode[1],
'data'=>!empty($errcode[2])?$errcode[2]:''
];
}else{
ErrorLog($errcode,$errmsg);
return [
'errcode'=>$errcode,
'errmsg'=>$errmsg,
'data'=>$data
];
}
}
private function LayuiAjaxReturn($errcode=0,$errmsg=0,$data=[],$count=0,$total=''){
if(is_array($errcode)){
ErrorLog($errcode[0],$errcode[1]);
return [
'code'=>$errcode[0],
'msg'=>$errcode[1],
'data'=>$errcode[2],
'count'=>$errcode[3],
'total'=>!empty($errcode[4])?$errcode[4]:''
];
}else{
ErrorLog($errcode,$errmsg);
return [
'code'=>$errcode,
'msg'=>$errmsg,
'data'=>$data,
'count'=>$count,
'total'=>$total
];
}
}
// bom单列表
public function BomList($request,$id)
{
list($count,$data) = $this->bomService->getBomList($request);
return $this->LayuiAjaxReturn(0,"ok",$data,$count);
}
// bom单详情
public function BomView($request,$id)
{
list($count,$data) = $this->bomService->getBomView($request);
return $this->LayuiAjaxReturn(0,"ok",$data,$count);
}
//bom单详情 保存bom单
public function saveBomInfo($request,$id){
$res = $this->bomService->saveBomInfo($request);
return $this->ajaxReturn($res['errcode'],$res['errmsg']);
}
/*
* 创建订单
*/
public function createBomOrder($request,$id){
$res = $this->bomService->createBomOrder($request);
return $this->ajaxReturn($res['errcode'],$res['errmsg']);
}
/*
* 数据报表
*/
public function bomReportCount($request,$id){
$res = $this->bomService->bomReportCount($request);
return $this->ajaxReturn($res['errcode'],$res['errmsg'],$res['data']);
}
}
\ No newline at end of file
...@@ -898,7 +898,8 @@ Class OrderController extends Controller ...@@ -898,7 +898,8 @@ Class OrderController extends Controller
$order_goods_type = $request->input('order_goods_type', 1); $order_goods_type = $request->input('order_goods_type', 1);
if ($order_goods_type == 1) { if ($order_goods_type == 1) {
$resData['status'] = $auditor_role == 3 ? 1 : 2; // 角色为‘查看自己’时,状态为待审核,否则为待付款 // $resData['status'] = $auditor_role == 3 ? 1 : 2; // 角色为‘查看自己’时,状态为待审核,否则为待付款
$resData['is_manager'] = $auditor_role == 3 ? 0 : 1; // 角色为‘查看自己’时,is_manager = 0
} }
$url = Config('website.api_domain').'order/changeOrder'; $url = Config('website.api_domain').'order/changeOrder';
...@@ -910,6 +911,23 @@ Class OrderController extends Controller ...@@ -910,6 +911,23 @@ Class OrderController extends Controller
} }
} }
// 申请主管审核
public function ajaxApplyManagerAudit(Request $request)
{
if ($request->isMethod('post')) {
$data['order_id'] = $request->input('order_id', '');
$data['operator_id'] = $request->user->userId;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'order/applyManagerAudit';
$temp = json_decode(curlApi($url, $data, "POST"), true);
return array('errcode'=>$temp['err_code'], 'errmsg'=>$temp['err_msg']);
}
}
// 主管审核 // 主管审核
public function ajaxAuditPass(Request $request) public function ajaxAuditPass(Request $request)
{ {
...@@ -2075,6 +2093,8 @@ Class OrderController extends Controller ...@@ -2075,6 +2093,8 @@ Class OrderController extends Controller
$CmsModel = new CmsModel(); $CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员 $sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员
$to_user_array = [];
//循环订单详情 //循环订单详情
foreach ($info['order_items_info'] as $key => $value) { foreach ($info['order_items_info'] as $key => $value) {
if ($value['status'] == -1) continue; if ($value['status'] == -1) continue;
...@@ -2092,52 +2112,32 @@ Class OrderController extends Controller ...@@ -2092,52 +2112,32 @@ Class OrderController extends Controller
$tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元'; $tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元';
$tmp['totalPrice'] = number_format($value['goods_number'] * $value['single_pre_price'], 2, '.', ''); $tmp['totalPrice'] = number_format($value['goods_number'] * $value['single_pre_price'], 2, '.', '');
$tmp['remarks'] = $value['remarks']; $tmp['remarks'] = $value['remarks'];
$tmp['material'] = $value['erp_rec_id']; $tmp['material'] = $value['material_number'];
$tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:''; $tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:'';
$tmp['deliveryTime'] = $value['batch']; //批次 $tmp['deliveryTime'] = $value['batch']; //批次
$tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:''; $tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:'';
$send_buyers[$value['send_email']]['data'][] = $tmp; $send_buyers[$value['buyer_id']]['data'][] = $tmp;
$send_buyers[$value['send_email']]['toUser'] = $value['send_email']; $send_buyers[$value['buyer_id']]['toUser'] = $value['send_email'];
$send_buyers[$value['send_email']]['ccUser'] = []; $send_buyers[$value['buyer_id']]['date'] = date('Y-m-d',time());
$send_buyers[$value['send_email']]['date'] = date('Y-m-d',time()); $send_buyers[$value['buyer_id']]['id'] = $sale_name;
$send_buyers[$value['send_email']]['date'] = intval($id);
$send_buyers[$value['send_email']]['id'] = $sale_name;
$tmp['projectId'] = $key+1; $to_user_array[] = $value['send_email'];
$data['data'][] = $tmp;
}
// 各个采购邮件推入队列 // $tmp['projectId'] = $key+1;
foreach ($send_buyers as &$v) { // $data['data'][] = $tmp;
$v['combined'] = 0;
foreach ($v['data'] as $item) {
$v['combined'] += $item['totalPrice'];
} }
$this->pushQueue($v);
}
$data['toUser'] = $request->user->email; // 收件人
$cc_send_mail_array = Config('config.cc_email'); // 固定抄送人 $cc_send_mail_array = Config('config.cc_email'); // 固定抄送人
$perm = new PermController; $perm = new PermController;
$kefu_manager_email = $perm->getManager($request->user->userId, 63); // 获取当前客服的上级主管邮箱,63-销售经理
$kefu_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $kefu_manager_email); // 合并上级主管邮箱 $perm->getSubDepartmentId(33, $department_ids); // 获取线上销售部所有小组(包含自己)
$is_online = $perm->checkUserDepartment($request->user->userId, $department_ids); // 检查当前客服是否属于线上销售部
$is_online && $cc_send_mail_array = array_merge($cc_send_mail_array, Config('config.joint_online_manager')); // 合并联营线上主管邮箱
// 获取采购经理 $kefu_manager_email = $perm->getManager($request->user->userId, 63); // 获取当前客服的上级主管邮箱,63-销售经理
$buyer_ids = array_unique(array_column($info['order_items_info'], 'buyer_id')); $kefu_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $kefu_manager_email); // 合并上级主管邮箱
foreach ($buyer_ids as $v) {
$buyer_manager_email = $perm->getManager($v, 41); // 获取当前采购的上级主管邮箱,41-采购经理
$buyer_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $buyer_manager_email);
}
$cc_send_mail_array = array_unique($cc_send_mail_array); // 去重
$cc_email_arr = []; $cc_email_arr = [];
...@@ -2150,17 +2150,57 @@ Class OrderController extends Controller ...@@ -2150,17 +2150,57 @@ Class OrderController extends Controller
} }
} }
$data['ccUser'] = array_unique(array_merge($cc_send_mail_array, $cc_email_arr)); $cc_send_mail_array = array_unique(array_merge($cc_send_mail_array, $cc_email_arr));
$data['combined'] = $info['order_info']['order_amount'];
$data['order_amount'] = $info['order_info']['order_amount']; // $data['toUser'] = $request->user->email; // 收件人
$data['date'] = date('Y-m-d',time()); // $data['ccUser'] = $cc_send_mail_array;
$data['kefu_remark'] = $info['order_temp_info']['kefu_remark']; // 客服备注 // $data['combined'] = $info['order_info']['order_amount'];
$data['id'] = $sale_name; // $data['order_amount'] = $info['order_info']['order_amount'];
$data['order_id'] = intval($id); // $data['date'] = date('Y-m-d',time());
$data['operator_id'] = intval($request->user->userId); // $data['id'] = $sale_name;
$data['operator_event'] = '发送邮件成功,收件人邮箱:'.json_encode($data['toUser']).',抄送人邮箱:'.json_encode($data['ccUser']); // $data['order_id'] = intval($id);
// $data['operator_id'] = intval($request->user->userId);
// $data['operator_event'] = '发送邮件成功,收件人邮箱:'.json_encode($data['toUser']).',抄送人邮箱:'.json_encode($data['ccUser']);
// $this->pushQueue($data);
// 同步到ERP
$url = Config('website.api_domain').'order/sysiteminfo';
$resData['order_id'] = $id;
$resData['k1'] = time();
$resData['k2'] = md5(md5($resData['k1']).'fh6y5t4rr351d2c3bryi');
$temp = json_decode(curlApi($url, $resData, "POST"), true); // 连接API
if ($temp['err_code'] != 0) return ['errcode'=>$temp['err_code'], 'errmsg'=>$temp['err_msg']];
// 各个采购邮件推入队列
foreach ($send_buyers as $k => &$v) {
$v['combined'] = 0;
foreach ($v['data'] as $item) {
$v['combined'] += $item['totalPrice'];
}
// 若不属于自营采购部,则添加联营采购管理人员
if (!$perm->checkUserDepartment($k, 51)) {
$joint_purchase_manager = Config('config.joint_purchase_manager');
$cc_send_mail_array = array_merge($cc_send_mail_array, $joint_purchase_manager);
}
array_push($cc_send_mail_array, $request->user->email); // 默认抄送给当前客服
$cc_send_mail_array = array_unique($cc_send_mail_array);
$v['ccUser'] = $cc_send_mail_array;
$this->pushQueue($v);
}
// 添加操作日志
$event = '发送邮件成功,收件人邮箱:'.json_encode($to_user_array).',抄送人邮箱:'.json_encode($cc_send_mail_array);
$this->pushQueue($data); $OrderActionLogModel = new OrderActionLogModel;
$OrderActionLogModel->addLog($id, $request->user->userId, 2, $event);
return ['errcode'=>0, 'errmsg'=>'推送到邮件队列成功,请稍等...']; return ['errcode'=>0, 'errmsg'=>'推送到邮件队列成功,请稍等...'];
} }
......
...@@ -518,5 +518,21 @@ ...@@ -518,5 +518,21 @@
return $user; return $user;
} }
// 检查用户是否属于某部门
public function checkUserDepartment($userId, $department_id)
{
$map = [];
$map['userId'] = $userId;
if (is_array($department_id)) {
$str = implode(',', $department_id);
$map[] = [DB::raw("department_id in ({$str})"), '1'];
} else {
$map['department_id'] = $department_id;
}
return DB::table('user_info')->where($map)->select('userId')->first();
}
} }
\ No newline at end of file
...@@ -315,4 +315,28 @@ class WebController extends Controller ...@@ -315,4 +315,28 @@ class WebController extends Controller
return view('web', $data); return view('web', $data);
} }
// bom列表
public function BomList($request, $data, $id)
{
$data['title'] = 'BOM单列表';
return view('web', $data);
}
// bom列表
public function BomView($request, $data, $id)
{
$data['title'] = 'BOM单详情';
$data["bom_id"] = $request->input("bom_id",0);
return view('web', $data);
}
// bom报表
public function BomReport($request, $data, $id)
{
$data['title'] = 'BOM报表';
return view('web', $data);
}
} }
...@@ -43,6 +43,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -43,6 +43,7 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'], '/sendSales/{id?}', 'OrderController@sendSales'); Route::match(['get', 'post'], '/sendSales/{id?}', 'OrderController@sendSales');
Route::post('/ajaxdeletegoods', 'OrderController@ajaxdeletegoods'); Route::post('/ajaxdeletegoods', 'OrderController@ajaxdeletegoods');
Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange'); Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange');
Route::post('/ajaxApplyManagerAudit', 'OrderController@ajaxApplyManagerAudit');
Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass'); Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass');
Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit'); Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit');
Route::get('/check/{id}', 'OrderController@check'); Route::get('/check/{id}', 'OrderController@check');
...@@ -146,6 +147,11 @@ Route::group(['middleware' => 'web'], function () { ...@@ -146,6 +147,11 @@ Route::group(['middleware' => 'web'], function () {
Route::post('/ajax/batchImportBlackList', 'AddOrderController@batchImportBlackList'); Route::post('/ajax/batchImportBlackList', 'AddOrderController@batchImportBlackList');
//bom单
Route::match(['get', 'post'],'/ajax/bom/{key}', 'BomApiController@Entrance');
}); });
// 不需要登陆态 // 不需要登陆态
......
<?php
namespace App\Model\Bom;
use Illuminate\Database\Eloquent\Model;
class BomExtendModel extends Model{
protected $connection = 'bom'; //库名
protected $table = 'bom_extend';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
// protected $dates = ['fcorder_time'];
public static $STATUS = [
1=>"正常",
2=>"删除",
];
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getFcorderTimeAttribute($value)
{
if($value > 0){
return date("Y-m-d h:i",$value);
}else{
return "";
}
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
use Illuminate\Database\Eloquent\Model;
class BomItemMatchBaseModel extends Model{
protected $suffix = null;
// 设置表后缀
public function setSuffix($suffix)
{
$this->suffix = $suffix;
if ($suffix !== null) {
$this->table = $this->getTable() . '_' . $suffix;
}
}
// 提供一个静态方法设置表后缀
public static function suffix($suffix)
{
$instance = new static;
$instance->setSuffix($suffix);
return $instance->newQuery();
}
// 创建新的"chapters_{$suffix}"的模型实例并返回
public function newInstance($attributes = [], $exists = false)
{
$model = parent::newInstance($attributes, $exists);
$model->setSuffix($this->suffix);
return $model;
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
class BomItemMatchExtendModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_match_extend'; //库名
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = null;
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function get_bom_match_extend($bom_id,$matching_id){
return static::where(["bom_id"=>$bom_id,"matching_id"=>$matching_id])->first();
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
class BomItemMatchModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item_matching'; //库名
protected $primaryKey = 'matching_id'; //设置id
protected $guarded = ['matching_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
public function getBomItemsMatching($bom_id,$bom_item_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("bom_item_id",$bom_item_id)->where("status",1)->first();
}
public function updateBomMatch($bom_id,$where,$data){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where($where)->update($data);
}
public function addBomMatch($bom_id,$data){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->insert($data);
}
public function bomExtend(){
return $this->belongsTo(\App\Model\Bom\BomExtendModel::class,"bom_id","bom_id");
}
/*
* 获取bom下单型号的数量
*/
public function countCOrderBomItems($is_kefu,$bom_sn,$begin_time,$end_time){
$count = 0;
for($i=0;$i<=9;$i++){
$query = self::suffix($i);
$query = $this->buildCountQuery($query,$is_kefu,$bom_sn,$begin_time,$end_time);
$count += $query->where(["is_corder"=>1])->count("matching_id");
}
return $count;
}
protected function buildCountQuery($query,$is_kefu,$bom_sn,$begin_time,$end_time){
$bom_id = 0;
if($bom_sn != ""){
$bom = BomModel::where("bom_sn",trim($bom_sn))->select("bom_id")->first();
$bom_id = $bom ? $bom->bom_id : 0;
}
if($bom_id > 0){
$query = $query->where(["bom_id"=>$bom_id]);
}
$begin_time = $begin_time ? strtotime($begin_time." 00:00:00") : 0;
$end_time = $end_time ? strtotime($end_time." 23:59:59") : 0;
if($begin_time){
if($end_time){
$query = $query->where('add_time',">=",$begin_time)->where('add_time',"<=",$end_time);
}else{
$query = $query->where('add_time',">=",$begin_time);
}
}elseif($end_time){
$query = $query->where('add_time',"<=",$end_time);
}
if($is_kefu == '0'){
$query = $query->whereDoesntHave("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}elseif($is_kefu == '1'){
$query = $query->whereHas("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}
return $query;
}
/*
* 获取bom提交BOM金额
* $type 1提交的bom金额 2下单的bom金额
*/
public function bomAmount($is_kefu,$bom_sn,$begin_time,$end_time,$type=0){
$amount = 0;
for($i=0;$i<=9;$i++){
$query = self::suffix($i);
$query = $this->buildCountQuery($query,$is_kefu,$bom_sn,$begin_time,$end_time);
if($type == 0){
$query = $query->where(["is_corder"=>0]);
}elseif($type == 1){
$query = $query->where(["is_corder"=>1]);
}
$sumamount = $query->selectRaw("sum(number*price) as sumamount")->first();
$amount += $sumamount ? $sumamount->sumamount : 0;
}
return $amount;
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
class BomItemModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item'; //库名
protected $primaryKey = 'bom_item_id'; //设置id
protected $guarded = ['bom_item_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
public function getBomItems($request,$bom_id){
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$suffix = substr(strrev($bom_id),0,1);
$query = self::suffix($suffix)->select("*")->where('bom_id', $bom_id)->where(["del_status"=>1]);
$query = $query->paginate($limit,[],'page',$page);
return $query;
}
public function bomExtend(){
return $this->belongsTo(\App\Model\Bom\BomExtendModel::class,"bom_id","bom_id");
}
/*
* 获取bom提交型号的数量
*/
public function countBomItems($is_kefu,$bom_sn,$begin_time,$end_time){
$count = 0;
for($i=0;$i<=9;$i++){
$query = self::suffix($i);
$bom_id = 0;
if($bom_sn != ""){
$bom = BomModel::where("bom_sn",trim($bom_sn))->select("bom_id")->first();
$bom_id = $bom ? $bom->bom_id : 0;
}
if($bom_id > 0){
$query = $query->where(["bom_id"=>$bom_id]);
}
$begin_time = $begin_time ? strtotime($begin_time." 00:00:00") : 0;
$end_time = $end_time ? strtotime($end_time." 23:59:59") : 0;
if($begin_time){
if($end_time){
$query = $query->where('add_time',">=",$begin_time)->where('add_time',"<=",$end_time);
}else{
$query = $query->where('add_time',">=",$begin_time);
}
}elseif($end_time){
$query = $query->where('add_time',"<=",$end_time);
}
if($is_kefu == '0'){
$query = $query->whereDoesntHave("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}elseif($is_kefu == '1'){
$query = $query->whereHas("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}
$count += $query->count("bom_item_id");
}
return $count;
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
use Illuminate\Database\Eloquent\Model;
class BomModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom';
protected $primaryKey = 'bom_id'; //设置id
protected $guarded = ['bom_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public static $STATUS = [
1=>"正常",
2=>"删除",
];
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function scopeSearchByrole($query,$role_id="",$sale_ids=[]){
if($role_id ==1){
return $query;
}elseif($role_id ==2 && is_array($sale_ids) && !empty($sale_ids) && count($sale_ids) > 0){
array_push($sale_ids,0);
$wherein = implode(",",$sale_ids);
$query = $query->whereRaw("bom_id in (select bom_id from lie_bom_extend where kefu_id in ({$wherein}))");
}elseif($role_id ==3 && !is_array($sale_ids)){
$query = $query->whereRaw("bom_id in (select bom_id from lie_bom_extend where kefu_id = 0 or kefu_id = {$sale_ids})");
}
return $query;
}
public function scopeSearchByBomSn($query,$bom_sn=""){
if($bom_sn != ''){
$query = $query->where('bom_sn',trim($bom_sn));
}
return $query;
}
public function scopeSearchByBomName($query,$bom_name=""){
if($bom_name != ''){
$query = $query->where('bom_name',trim($bom_name));
}
return $query;
}
public function scopeSearchByIsCorder($query,$is_corder=""){
if($is_corder == "all" || $is_corder == "" ){
return $query;
}else{
$query = $query->where('is_corder',intval($is_corder));
}
return $query;
}
public function scopeSearchByUserNameOrKefu($query,$username="",$is_kefu='all'){
$username = trim($username);
$is_kefu = trim($is_kefu);
if($username == "" ){
if($is_kefu == '0'){
$query = $query->whereDoesntHave("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}elseif($is_kefu == '1'){
$query = $query->whereHas("bomExtend",function ($query) {
$query->where('kefu_id', "!=",0);
});
}
return $query;
}else{
$query = $query->whereHas("bomExtend",function ($query) use($username,$is_kefu) {
if($username){
$query->where('user_name', trim($username));
}
if($is_kefu == '0'){
$query->where('kefu_id', "=",0);
}elseif($is_kefu == '1'){
$query->where('kefu_id', "!=",0);
}
});
}
return $query;
}
public function scopeSearchByTime($query,$begin_time='',$end_time=''){
$begin_time = $begin_time ? strtotime($begin_time." 00:00:00") : 0;
$end_time = $end_time ? strtotime($end_time." 23:59:59") : 0;
if($begin_time){
if($end_time){
$query = $query->where('add_time',">=",$begin_time)->where('add_time',"<=",$end_time);
}else{
$query = $query->where('add_time',">=",$begin_time);
}
}elseif($end_time){
$query = $query->where('add_time',"<=",$end_time);
}
return $query;
}
public function scopeCreateUserId($query,$create_userid=0,$role=null,$create_username='',$userType=0){
if($userType == 1){
return $query->where('create_userid',1000);
}
if($create_userid && $role != 1){
$query = $query->where('create_userid',$create_userid);
}
if($create_username && $role == 1){
$query = $query->where('create_username',"like","%".trim($create_username)."%");
}
return $query;
}
public function bomExtend()
{
return $this->hasOne(\App\Model\Bom\BomExtendModel::class,"bom_id","bom_id");
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
use Illuminate\Database\Eloquent\Model;
class BomOrderModel extends Model{
protected $connection = 'bom'; //库名
protected $table = 'bom_order';
protected $primaryKey = 'id'; //设置id
protected $guarded = ['id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
// protected $dates = ['fcorder_time'];
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
//获取bom单的 下单金额
public static function getBomOrderAmount($bom_id=0){
return static::where(["bom_id"=>$bom_id])->sum("add_order_amount");
}
//获取bom单的 下单单号
public static function getBomOrderSn($bom_id=0){
return static::where(["bom_id"=>$bom_id])->get()->pluck("order_sn");
}
}
\ No newline at end of file
...@@ -335,6 +335,7 @@ class OrderModel extends Model ...@@ -335,6 +335,7 @@ class OrderModel extends Model
'1' => '自采', '1' => '自采',
'2' => '立创', '2' => '立创',
'3' => '京北', '3' => '京北',
'4' => '油柑网',
); );
$tmp = array(); $tmp = array();
...@@ -461,7 +462,7 @@ class OrderModel extends Model ...@@ -461,7 +462,7 @@ class OrderModel extends Model
$tmp[$i]['sale_type'] = $order[$i]['sale_type'] == 1 ? '现卖' : '预售'; $tmp[$i]['sale_type'] = $order[$i]['sale_type'] == 1 ? '现卖' : '预售';
// 自营其他业务类型 // 自营其他业务类型
$tmp[$i]['business_type'] = $order[$i]['business_type'] ? Config('params.business_type')[$order[$i]['business_type']] : '正常订单'; $tmp[$i]['business_type'] = $order[$i]['business_type'] ? Config('params.business_type')[$order[$i]['business_type']] : '正常订单';
$tmp[$i]['self_supplier_type'] = $self_supplier_type[$order[$i]['self_supplier_type']]; // 自采标记 $tmp[$i]['self_supplier_type'] = isset($self_supplier_type[$order[$i]['self_supplier_type']]) ? $self_supplier_type[$order[$i]['self_supplier_type']] : '未知'; // 自采标记
$tmp[$i]['sample_demand_desc'] = $order[$i]['sample_demand_desc']; // 样片项目需求描述 $tmp[$i]['sample_demand_desc'] = $order[$i]['sample_demand_desc']; // 样片项目需求描述
//收货地址的电话 //收货地址的电话
$tmp[$i]['receiving_address'] = isset($current_order_addr['mobile']) ? $current_order_addr['mobile'] : ''; $tmp[$i]['receiving_address'] = isset($current_order_addr['mobile']) ? $current_order_addr['mobile'] : '';
......
<?php
namespace App\Services\Bom;
use App\Http\Controllers\PermController;
use App\Model\Bom\BomModel;
use App\Model\Bom\BomItemMatchModel;
use App\Model\Bom\BomItemModel;
use App\Model\Bom\BomItemMatchExtendModel;
use App\Exceptions\BomException;
use App\Model\Bom\BomOrderModel;
use DB;
class BomService {
//1专卖2联营3自营4寄售5第三方仓库 0:自营 1:联营 2:专卖
public static $GOODSTYPE=[
1=>2,
2=>1,
3=>0,
4=>0,
5=>0,
];
public function __construct(){
$this->bomModel = new BomModel;
$this->bomItemMatchModel = new BomItemMatchModel;
}
protected function getRole($request){
$perm = new PermController();
// 用户角色
$role_id = (new PermController)->getUserRole($request);
$sale_ids = [];
if($role_id == 1){
$sale_ids=[];
}else if($role_id == 2){
$sale_ids = (new PermController)->getSubSaleId($request->user->userId);
}elseif($role_id >= 3){
$sale_ids = $request->user->userId;
}
return [$role_id,$sale_ids];
}
public function getBomList($request){
$page = $request->input("page",1);
$limit = $request->input("limit",10);
// $bom_sn = $request->input("bom_sn",'');
$bom_name = $request->input("bom_name",'');
$is_corder = $request->input("is_corder",'all');
$begin_time = $request->input("begin_time",'');
$end_time = $request->input("end_time",'');
$username = $request->input("username",'');
$is_kefu = $request->input("is_kefu",'all');
list($role_id,$sale_ids) = $this->getRole($request);
// dump($role_id);
// dump($sale_ids);
$query = BomModel::select("*")->where(["status"=>1])->with("bomExtend")->SearchByUserNameOrKefu($username,$is_kefu)
->SearchByBomName($bom_name)->SearchByIsCorder($is_corder)->SearchByTime($begin_time,$end_time)
->SearchByrole($role_id,$sale_ids)
->orderBy("bom_id","desc");
// $tmp = str_replace('?', '"'.'%s'.'"', $query->toSql());
// $tmp = vsprintf($tmp, $query->getBindings());
// echo $tmp;
// exit;
$list = $query->paginate($limit,[],'page',$page);
$bomItemMatchModel = new BomItemMatchModel;
foreach($list as $k=>$item){
//bom单金额
$bomMoneyObj = $bomItemMatchModel->getBomAmount($item->bom_id);
$bomMoney = $bomMoneyObj->amount;
$item->bomMoney = $bomMoney ? round($bomMoney,2) : 0;
//bom下单金额
$item->bomCOrderAmount = BomOrderModel::getBomOrderAmount($item->bom_id);
$item->bomCOrderSn = BomOrderModel::getBomOrderSn($item->bom_id);
}
$list = $list->toArray();
// dump($list);
return [$list['total'],$list["data"]];
}
public function getBomView($request){
$bom_id = $request->input("bom_id",0);
$bom = BomModel::where(["bom_id"=>$bom_id])->select("bom_id","bom_sn")->first();
$bomItemModel = new BomItemModel;
$bomItemModelMatch = new BomItemMatchModel;
$bomItemMatchExtendModel = new BomItemMatchExtendModel;
$bom_items = $bomItemModel->getBomItems($request,$bom->bom_id);
foreach($bom_items as $k=>&$item){
$bom_item_matching = $bomItemModelMatch->getBomItemsMatching($bom->bom_id,$item->bom_item_id);
if($bom_item_matching){
$item->match_is_corder = $bom_item_matching->is_corder;
$item->match_goods_type = $bom_item_matching->goods_type;
$item->matching_id = $bom_item_matching->matching_id;
$item->match_number = $bom_item_matching->number;
$item->match_goods_id = $bom_item_matching->goods_id;
$item->match_goods_name = $bom_item_matching->goods_name;
$item->match_brand_name = $bom_item_matching->brand_name;
$item->match_supplier_name = $bom_item_matching->supplier_name;
$item->match_mpq = $bom_item_matching->mpq;
$item->match_moq = $bom_item_matching->moq;
$item->match_delivery = $bom_item_matching->delivery;
$item->match_price = $bom_item_matching->price;
$item->match_amount = $bom_item_matching->price * $bom_item_matching->number;
$item->is_corder = $bom_item_matching->is_corder;
$item->bom_match_extend = $bomItemMatchExtendModel->get_bom_match_extend($bom->bom_id,$bom_item_matching->matching_id);
}
}
$list = $bom_items->toArray();
// dump($list);
return [$list['total'],$list["data"]];
}
protected function getSku($user_id,$item,$extend){
try{
$url = Config('website.search-skuid-finalInfo');
$data['id'] = $item["match_goods_id"];
$data['num'] = isset($item["match_number"]) ? intval($item["match_number"]) : 0;
$data['currency'] = $extend["currency"];
$data['uid'] = intval($user_id) ? intval($user_id) : 0;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$response = json_decode(curlApi($url, $data, 'POST'), true);
if($response['err_code'] != 0){
return false;
}else{
return $response['data'];
}
}catch(\Exception $e){
return false;
}
}
/**
* 新获取最终销售价
* @param [type] $goods [description]
* @return [type] [description]
*/
function ladder_final_price($goods,$extend)
{
$currency = isset($extend['currency']) ? $extend['currency'] : 1;
$use_ac = isset($goods['ac_type']) ? $goods['ac_type'] : 0;
if ($currency == 1) {
$field = $use_ac ? 'price_ac' : 'price_cn';
} else {
$field = $use_ac ? 'price_us' : 'price_us';//美元不支持优惠
}
$arr = [
'price' => $goods[$field],
'price_total' => isset($goods[$field.'_total']) ? $goods[$field.'_total'] : $goods[$field] * $goods['num'],
'num' => $goods['num'],
];
return $arr;
}
/*
* 获取商品的会员价
*/
protected function saveBomItemMatchingBySearchApi($bom_item_matching,$goods,$extend=[]){
// dump("获取api商品信息 修改商品");
//价格计算
$goods_prices = $this->ladder_final_price($goods, $extend);
//获取优惠前 原始价格
// $initial_prices = $this->ladder_final_price($goods, $extend);
//修改bom单匹配信息
$goodsInfo = $goods['goods_info'];
// dump($goodsInfo);
$where = ['bom_id'=>$bom_item_matching['bom_id'],"matching_id"=>$bom_item_matching['matching_id']];
$delivery = "";
if(is_array($goodsInfo['delivery_time'])){
if(isset($goodsInfo['delivery_time'][$extend['delivery_type']])){
$delivery = $goodsInfo['delivery_time'][$extend['delivery_type']];
}
}
$num = $bom_item_matching['match_number'];
if(in_array($goodsInfo['goods_type'], array(1,2))){//联营
}else{//自营
$mpl = !empty($goodsInfo['mpl']) ? $goodsInfo['mpl'] : 1;//旧数据
$modNum = $num % $mpl;
$num = $num - intval($modNum);
}
$data = [
"goods_id"=>$goodsInfo['goods_id'],
"goods_name"=>$goodsInfo['goods_name'],
"brand_id"=>$goodsInfo['brand_id'],
"brand_name"=>$goodsInfo['brand_name'],
"goods_type"=>static::$GOODSTYPE[$goodsInfo['goods_type']],
"supplier_id"=>$goodsInfo['supplier_id'],
"supplier_name"=>$goodsInfo['supplier_name'],
"delivery"=>$delivery,//货期
"delivery_type"=>$extend['delivery_type'],//交货类型
"number"=>$num,
"price"=>$goods_prices['price'],
"pdf"=>$goodsInfo['pdf'],
"stock"=>$goodsInfo['goods_number'],
"moq"=>$goodsInfo['min_buy'],
"mpq"=>$goodsInfo['min_mpq'],
"encap"=>$goodsInfo['encap'],
"status"=>1,
"update_time"=>time(),
"ladder_price"=>json_encode($goodsInfo['tiered']),
];
$bk = $this->bomItemMatchModel->updateBomMatch($bom_item_matching['bom_id'],$where,$data);
if($bk === false){
return false;
}else{
return true;
}
}
protected function addBomItemMatchingBySearchApi($bom_item_matching,$goods,$extend=[]){
//价格计算
$goods_prices = $this->ladder_final_price($goods, $extend);
//获取优惠前 原始价格
// $initial_prices = $this->ladder_final_price($goods, $extend);
//修改bom单匹配信息
$goodsInfo = $goods['goods_info'];
// $where = ['bom_id'=>$bom_item_matching['bom_id'],"matching_id"=>$bom_item_matching['matching_id']];
$num = $bom_item_matching['match_number'];
if(in_array($goodsInfo['goods_type'], array(1,2))){//联营
}else{//自营
$mpl = !empty($goodsInfo['mpl']) ? $goodsInfo['mpl'] : 1;//旧数据
$modNum = $num % $mpl;
$num = $num - intval($modNum);
}
//货期
try{
$delivery_time = $goodsInfo['delivery_time'];
if(is_array($delivery_time) && count($delivery_time) == 2){
$delivery_time = $delivery_time[$extend['delivery_type']];
}
}catch(\Exception $e){
$delivery_time = "";
}
$data = [
"bom_id"=>$bom_item_matching['bom_id'],
"bom_item_id"=>$bom_item_matching['bom_item_id'],
"goods_id"=>$goodsInfo['goods_id'],
"goods_name"=>$goodsInfo['goods_name'],
"brand_id"=>$goodsInfo['brand_id'],
"brand_name"=>$goodsInfo['brand_name'],
"goods_type"=>static::$GOODSTYPE[$goodsInfo['goods_type']],
"supplier_id"=>$goodsInfo['supplier_id'],
"supplier_name"=>$goodsInfo['supplier_name'],
"delivery"=>$delivery_time,
"delivery_type"=>$extend['delivery_type'],//交货类型
"number"=>$num,
"price"=>$goods_prices['price'],
"pdf"=>$goodsInfo['pdf'],
"stock"=>$goodsInfo['goods_number'],
"moq"=>$goodsInfo['min_buy'],
"mpq"=>$goodsInfo['min_mpq'],
"encap"=>$goodsInfo['encap'],
"status"=>1,
"update_time"=>time(),
"ladder_price"=>json_encode($goodsInfo['tiered']),
];
// dump($data);
$bk = $this->bomItemMatchModel->addBomMatch($bom_item_matching['bom_id'],$data);
if($bk === false){
return false;
}else{
return true;
}
}
public function saveBomItemMatching($bom_item_matching,$extend){
// dump("不需要匹配商品,直接修改bom单");
$goodsInfo = $bom_item_matching;
// dump($goodsInfo);return;
if(isset($bom_item_matching['matching_id']) && $bom_item_matching['matching_id'] > 0){
//修改
$where = ['bom_id'=>$bom_item_matching['bom_id'],"matching_id"=>$bom_item_matching['matching_id']];
$data = [
"goods_id"=>0,
"goods_name"=>trim($goodsInfo['match_goods_name']),
"brand_id"=>0,
"brand_name"=>trim($goodsInfo['match_brand_name']),
"goods_type"=>1,//默认联营
"delivery"=>trim($goodsInfo['match_delivery']),//货期
"delivery_type"=>$extend['delivery_type'],//交货类型
"number"=>intval($goodsInfo['match_number']),
"price"=>$goodsInfo['match_price'],
"pdf"=>"",
"supplier_name"=>trim($goodsInfo['match_supplier_name']),
"supplier_id"=>"0",
"stock"=>0,
"moq"=>0,
"mpq"=>0,
"encap"=>"",
"status"=>1,
"update_time"=>time(),
"ladder_price"=>"",
];
$bk = $this->bomItemMatchModel->updateBomMatch($goodsInfo['bom_id'],$where,$data);
if($bk === false){
return false;
}else{
return true;
}
}else{
//新增
$data = [
"bom_id"=>$goodsInfo['bom_id'],
"bom_item_id"=>$goodsInfo['bom_item_id'],
"goods_id"=>0,
"goods_name"=>isset($goodsInfo['match_goods_name']) ? trim($goodsInfo['match_goods_name']) : '',
"brand_id"=>0,
"brand_name"=>isset($goodsInfo['match_brand_name']) ? trim($goodsInfo['match_brand_name']) : '',
"goods_type"=>1,//默认联营
"delivery"=>isset($goodsInfo['match_delivery']) ? trim($goodsInfo['match_delivery']) : '',//货期
"delivery_type"=>isset($extend['delivery_type']) ? $extend['delivery_type'] : 1,//交货类型
"number"=>isset($goodsInfo['match_number']) ? intval($goodsInfo['match_number']) : 0,
"price"=>isset($goodsInfo['match_price']) ? $goodsInfo['match_price'] : 0,
"supplier_name"=>isset($goodsInfo['match_supplier_name']) ? trim($goodsInfo['match_supplier_name']) : '',
"supplier_id"=>"0",
"pdf"=>"",
"stock"=>0,
"moq"=>0,
"mpq"=>0,
"encap"=>"",
"status"=>1,
"add_time"=>time(),
"update_time"=>time(),
"ladder_price"=>"",
];
$bk = $this->bomItemMatchModel->addBomMatch($goodsInfo['bom_id'],$data);
if($bk === false){
return false;
}else{
return true;
}
}
}
public function saveBomInfo($request){
try{
$err_msg = [];
$data = $request->input("data",'');
// dump($data);exit;
$bom_id = $data[0]["bom_id"];
$bom = BomModel::where(["bom_id"=>intval($bom_id)])->select("user_id","where")->first();
$user_id = $bom->user_id;
$bom_where = $bom->where;
$delivery_type = 0;//交货地
if(!$user_id){
throw new BomException("该bom单没有绑定用户id",-1);
}
if($bom_where){
$bom_where_arr = json_decode($bom_where,true);
if(isset($bom_where_arr["delivery_type"])){
$delivery_type = $bom_where_arr["delivery_type"];
}
}
if(!in_array($delivery_type,[1,2])){
$delivery_type = 1;
}
$currency = $delivery_type;
$extend["delivery_type"] = $delivery_type;
$extend["currency"] = $currency;
foreach($data as $k=>$item){
// dump($item);exit;
//已下单的不能修改
if(isset($item['match_is_corder']) && $item['match_is_corder'] == 1){
// array_push($err_msg,sprintf("第%s个型号已下单,无法更改;",$k));
continue;
}
//设置匹配的默认数量
if(!isset($item["match_number"]) || intval($item["match_number"]) <= 0){
if(isset($item['number']) && $item['number'] > 0){
$item["match_number"] = intval($item['number']);
}else{
$item["match_number"] = 1;
}
}
//如果客服修改了goods_id则 需要重新匹配的商品信息
if(isset($item['match_goods_id']) && $item['match_goods_id'] && intval($item['match_goods_id']) > 0){
// dump($item);continue;
//请求api 获取商品信息
$res = $this->getSku($user_id,$item,$extend);
// dump($res);
//如果获取到了商品数据
if($res !== false){
if(isset($item['matching_id']) && $item['matching_id'] > 0){
//修改 查询到了商品信息 修改本地bom单信息
if($this->saveBomItemMatchingBySearchApi($item,$res,$extend)){
continue;
}
}else{
//新增
if($this->addBomItemMatchingBySearchApi($item,$res,$extend)){
continue;
}
}
}else{
//没搜索到商品 直接将商品id设为0
$item["match_goods_id"] = 0;
}
}
//没有找到商品信息
//直接按照客服提交的信息修改内容 并且修改goods_id=0 goods_type类型为联营
$this->saveBomItemMatching($item,$extend);
}
return ['errcode'=>0,"errmsg"=>"保存成功"];
}catch(BomException $e){
return ['errcode'=>$e->getCode(),"errmsg"=>$e->getMessage()];
}catch(\Exception $e){
return ['errcode'=>-1,"errmsg"=>sprintf("操作异常,请联系技术员 %s",$e->getMessage())];
}
}
/*
* bom下单
* 自营单
* 联营单
*/
public function createBomOrder($request){
try{
$err_msg = [];
$data = $request->input("data",'');
$bom_id = $data[0]["bom_id"];
$bom = BomModel::where(["bom_id"=>intval($bom_id)])->select("user_id","where","bom_sn")->first();
$user_id = $bom->user_id;
$bom_where = $bom->where;
$delivery_type = 0;//交货地
if(!$user_id){
throw new BomException("该bom单没有绑定用户id",-1);
}
if($bom_where){
$bom_where_arr = json_decode($bom_where,true);
if(isset($bom_where_arr["delivery_type"])){
$delivery_type = $bom_where_arr["delivery_type"];
}
}
if(!in_array($delivery_type,[1,2])){
$delivery_type = 1;
}
$currency = $delivery_type;
$extend["delivery_type"] = $delivery_type;
$extend["currency"] = $currency;
$extend["bom_id"] = $bom_id;
$extend["bom_sn"] = $bom->bom_sn;
$address_id = $this->getAddress($user_id);
$extend["address_id"] = $address_id;
$ziying = [];
$lianying=[];
foreach($data as $k=>$item){
if(!isset($item["matching_id"])){
array_push($err_msg,sprintf("您勾选的第%s行数据没有匹配到任何型号,不能下单",$k+1));
break;
}
if($item["is_corder"] == 1) {
array_push($err_msg,sprintf("您勾选的第%s行数据已经下单了,不能重复下单",$k+1));
break;
}
if(in_array($item["match_goods_type"],[0])){
if($item["match_goods_id"] <= 0){
array_push($err_msg,sprintf("您勾选的第%s行数据自营订单没有skuid",$k+1));
break;
}
if($item["match_number"] <= 0){
array_push($err_msg,sprintf("您勾选的第%s行数据数量有问题哦",$k+1));
break;
}
//自营
$ziying[$k]["id"] = $item["match_goods_id"];
$ziying[$k]["num"] = $item["match_number"];
$ziying[$k]["delivery_place"] = $delivery_type;
$ziying[$k]["matching_id"] = $item["matching_id"];
}else{
if($item["match_number"] <= 0){
array_push($err_msg,sprintf("您勾选的第%s行数据数量有问题哦",$k+1));
break;
}
if(!$item["match_goods_name"] || !$item['match_brand_name'] || $item['match_price'] <= 0){
array_push($err_msg,sprintf("您勾选的第%s行数据没有填写完整,请检查型号,品牌,数量等是否填写了",$k+1));
break;
}
//联营
$lianying[$k]["matching_id"] = $item['matching_id'];
$lianying[$k]["goods_name"] = $item['match_goods_name'];
$lianying[$k]["brand_name"] = $item['match_brand_name'];
$lianying[$k]["num"] = $item['match_number'];
$lianying[$k]["goods_price"] = $item['match_price'];
$lianying[$k]["delivery_time"] = $item['match_delivery'];
$lianying[$k]["supplier_name"] =$item['match_supplier_name'];
$lianying[$k]["id"] = $item['match_goods_id'];
$lianying[$k]["matching_id"] = $item["matching_id"];
}
}
if(!empty($err_msg)){
throw new BomException("",-1);
}
//清理用户以前的购物车 type=2 后台 extend_type=5 bom
$this->cleanBomShopCart($user_id);
if($ziying){
$bk1 = $this->zyOrder($user_id,$ziying,$extend,$err_msg);
}
if($lianying){
$bk2 = $this->lyOrder($user_id,$lianying,$extend,$err_msg);
}
$returnErrorMsg = "";
if(isset($bk1))
$returnErrorMsg .= $bk1 ? "自营下单成功:\n<br/>" : "自营下单失败:\n<br/>";
if(isset($bk2))
$returnErrorMsg .= $bk2 ? "联营下单成功:\n<br/>" : "联营下单失败:\n<br/>";
if(!empty($err_msg))
$returnErrorMsg .= implode("\n<br/>",$err_msg);
//dump($err_msg);
return ['errcode'=>0,"errmsg"=>$returnErrorMsg];
}catch(BomException $e){
array_push($err_msg,$e->getMessage());
return ['errcode'=>$e->getCode(),"errmsg"=>implode("\n",$err_msg)];
}catch(\Exception $e){
return ['errcode'=>-1,"errmsg"=>$e->getMessage()];
}
}
/*
* 创建联营订单
*/
protected function lyOrder($user_id,$lianying,$extend,&$err_msg){
//创建购物车
$lyShopCart = $this->createLYOrderToShopCart($user_id,$lianying,$extend,$err_msg);
// exit;
if(!empty($lyShopCart) && $lyShopCart['err_code'] == 0){//加入购物车成功
//获取联营购物车
$car_ids = $this->getShopCart($user_id,1);
// array_push($err_msg,$lyShopCart["err_msg"]);
if(!empty($car_ids)){
//创建订单 请求api创建联营订单
$addOrder = $this->createOrder($user_id,$car_ids,$extend,1);
if(!empty($addOrder) && $addOrder['err_code'] == 0){
//创建订单成功
return true;
}else{
if(is_array($addOrder) && !empty($addOrder)){
array_push($err_msg,sprintf("联营订单下单失败 原因:%s",$addOrder["err_msg"]));
}else{
array_push($err_msg,sprintf("联营订单下单失败 原因:%s","出现异常"));
}
}
}else{
array_push($err_msg,sprintf("%s","联营订单加入购物车失败,原因:没有找到该用户bom单购物车数据"));
}
}else{//bom加入购物车失败
if(is_array($lyShopCart) && !empty($lyShopCart)){
array_push($err_msg,sprintf("联营订单加入购物车失败 %s",$lyShopCart["err_msg"]));
}else{
array_push($err_msg,"联营订单加入购物车失败,原因:出现异常");
}
}
return false;
}
/*
* 联营添加购物车
*/
protected function createLYOrderToShopCart($user_id,$lianying,$extend){
$url = Config('website.addlyorder_url');
$data["bom_sn"] = $extend["bom_sn"];
$data['uid'] = intval($user_id) ? intval($user_id) : 0;
$data["type"] = 2;//1-前台,2-后台,3-后台批量添加
$data['delivery_place'] = $extend["delivery_type"];
$data['data'] = $lianying;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$response = json_decode(curlApi($url, $data, 'POST'), true);
return $response;
}
/*
* 创建自营订单
* 1,加入购物车
* 2,下单
*/
protected function zyOrder($user_id,$ziying,$extend,&$err_msg){
//请求 api接口 加入购物车
$addZYShopCart = $this->createZYOrderToShopCart($user_id,$ziying,$extend);
// exit;
if(!empty($addZYShopCart) && $addZYShopCart['err_code'] == 0){//加入购物车成功
//获取自营购物车
$car_ids = $this->getShopCart($user_id,3);
if(!empty($car_ids)){
//创建订单 请求api创建自营订单
$addzyOrder = $this->createOrder($user_id,$car_ids,$extend,2);
if(!empty($addzyOrder) && $addzyOrder['err_code'] == 0){
//创建订单成功
return true;
}else{
if(is_array($addzyOrder) && !empty($addzyOrder)){
array_push($err_msg,sprintf("自营订单下单失败 %s",$addzyOrder["err_msg"]));
}else{
array_push($err_msg,"自营订单下单失败,原因:出现异常");
}
}
}else{
array_push($err_msg,"自营订单加入购物车失败,原因:没有找到该用户bom单购物车数据");
}
}else{//bom加入购物车失败
if(is_array($addZYShopCart) && !empty($addZYShopCart)){
array_push($err_msg,sprintf("自营订单加入购物车失败 %s",$addZYShopCart["err_msg"]));
}else{
array_push($err_msg,"自营订单加入购物车失败,原因:出现异常");
}
}
return false;
}
/*
* 创建订单
*
*/
protected function createOrder($user_id,$car_ids,$extend,$type=2){
$url = Config('website.api_create_order');
$data['uid'] = intval($user_id) ? intval($user_id) : 0;
$data["type"] = $type;//订单类型:1.联营, 2.自营线上, 3.自营线下, 4.自营其他业务订单
$data["cart_id"] = implode(",",$car_ids);
$data['address_id'] = $extend["address_id"];
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
// dump(curlApi($url, $data, 'POST'));exit;
$response = json_decode(curlApi($url, $data, 'POST'), true);
return $response;
}
/*
* 获取到后台加入的自营的购物车商品
*/
protected function getShopCart($user_id=0,$type=3){
$goodsType = [];
if($type == 3){
//自营
$goodsType = [3];
}else{
//联营
$goodsType = [1,2];
}
$query = DB::connection("order")->table("lie_shopping_cart")->where(["user_id"=>$user_id,"status"=>1,"extend_type"=>5])
->whereIn("goods_type",$goodsType)->select("cart_id")->pluck("cart_id");
return $query;
}
/*
* 创建自营订单 到购物车
*/
protected function createZYOrderToShopCart($user_id,$ziying,$extend){
$url = Config('website.addzyorder_url');
$data['type'] = 2;//后台加入购物车
$data['delivery_place'] = $extend['delivery_type'];
$data["bom_sn"] = $extend["bom_sn"];
$data["data"] = array_merge($ziying);
$data['uid'] = intval($user_id) ? intval($user_id) : 0;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$response = json_decode(curlApi($url, $data, 'POST'), true);
return $response;
}
protected function getAddress($user_id){
$address = DB::connection("order")->table("lie_user_address")->where(["user_id"=>$user_id])->select("address_id","is_default")->orderBy("address_id","desc")->get();
if(!$address){
throw new BomException("没有找到该用户对应的收货地址",-1);
}
$address_id = 0;
foreach($address as $k=>$item){
if($item->is_default == 1){
$address_id = $item->address_id;
break;
}
}
if($address_id){
return $address_id;
}
return $address[0]->address_id;
}
protected function getTax($user_id){
$tax = DB::connection("order")->table("lie_taxinfo")->where(["user_id"=>$user_id])->select("tax_id","tax_title","inv_type","is_default")
->orderBy("tax_id","desc")->get();
if(!tax_id){
return false;
}
$tax_id = 0;
foreach($tax as $k=>$item){
if($item->is_default == 1){
$tax_id = $item->tax_id;
break;
}
}
if($tax_id){
return $tax_id;
}
return $tax[0]->tax_id;
}
/*
* 清楚用户bom购物车
*/
protected function cleanBomShopCart($user_id){
if($user_id <= 0) return true;
DB::connection("order")->table("lie_shopping_cart")->where(["user_id"=>$user_id,"type"=>2,"extend_type"=>5])->delete();
}
public function bomReportCount($request){
try{
$is_kefu = $request->input("is_kefu",'all');
$bom_sn = $request->input("bom_sn",'');
$begin_time = $request->input("begin_time",'');
$end_time = $request->input("end_time",'');
$data['field1'] = "-";
$data['field2'] = "-";
$data['field3'] = "-";
$data['field4'] = "-";
$data['field5'] = "";
$data['field6'] = "-";
$data['field7'] = "-";
$data['field8'] = "-";
$data['field9'] = "-";
$data['field10'] = "-";
$data['field11'] = "-";
$bomModel = new BomModel;
$bomItemsModel = new BomItemModel();
$bomItemsMatchModel = new BomItemMatchModel();
//提交BOM单数量
$data['field1'] = $bomModel->SearchByBomSn($bom_sn)->SearchByUserNameOrKefu("",$is_kefu)->where("is_corder",1)->SearchByTime($begin_time,$end_time)->count("bom_id");
//BOM单数量
$data['field2'] = $bomModel->SearchByBomSn($bom_sn)->SearchByUserNameOrKefu("",$is_kefu)->SearchByTime($begin_time,$end_time)->count("bom_id");
//提交型号数
$data['field4'] = $bomItemsModel->countBomItems($is_kefu,$bom_sn,$begin_time,$end_time);
//下单型号数
$data['field5'] = $bomItemsMatchModel->countCOrderBomItems($is_kefu,$bom_sn,$begin_time,$end_time);
//提交BOM金额
$data['field7'] = $bomItemsMatchModel->bomAmount($is_kefu,$bom_sn,$begin_time,$end_time,0);
//下单BOM金额
$data['field8'] = $bomItemsMatchModel->bomAmount($is_kefu,$bom_sn,$begin_time,$end_time,1);
return ['errcode'=>0,"errmsg"=>"ok","data"=>$data];
}catch(BomException $e){
return ['errcode'=>$e->getCode(),"errmsg"=>$e->getMessage(),"data"=>[]];
}catch(\Exception $e){
return ['errcode'=>-1,"errmsg"=>$e->getMessage(),"data"=>[]];
}
}
}
\ No newline at end of file
...@@ -23,6 +23,18 @@ return [ ...@@ -23,6 +23,18 @@ return [
// 'zoe@ichunt.com', // 'zoe@ichunt.com',
], ],
// 联营线上销售
'joint_online_manager' => [
'ysx@ichunt.com',
// 'zhengjf@ichunt.com',
// 'zoe@ichunt.com',
],
// 联营采购负责人
'joint_purchase_manager' => [
'zty@ichunt.com',
],
'footstone_url' => 'http://footstone.liexin.net', 'footstone_url' => 'http://footstone.liexin.net',
'auth_key' => 'LX@ichunt.com82560956-0755', 'auth_key' => 'LX@ichunt.com82560956-0755',
's_standard_brand' => 'StandardBrand', // 缓存key 's_standard_brand' => 'StandardBrand', // 缓存key
......
...@@ -109,6 +109,18 @@ return [ ...@@ -109,6 +109,18 @@ return [
'prefix' => 'lie_', 'prefix' => 'lie_',
'strict' => false, 'strict' => false,
], ],
'bom' => [
'driver' => 'mysql',
'host' => env('DB_HOST_BOM', ''),
'database' => env('DB_DATABASE_BOM', ''),
'username' => env('DB_USERNAME_BOM', ''),
'password' => env('DB_PASSWORD_BOM', ''),
'port' => env('DB_PORT_BOM', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sqlite' => [ 'sqlite' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => database_path('database.sqlite'), 'database' => database_path('database.sqlite'),
...@@ -176,5 +188,12 @@ return [ ...@@ -176,5 +188,12 @@ return [
'port' => env('REDIS_READ_PORT', 6379), 'port' => env('REDIS_READ_PORT', 6379),
'database' => 0, 'database' => 0,
], ],
'userssssss' => [
'host' => "172.18.137.21",
'password' => "icDb29mLy2s",
'port' => 6379,
'database' => 0,
],
], ],
]; ];
...@@ -58,6 +58,17 @@ return [ ...@@ -58,6 +58,17 @@ return [
// 'search-skuid' => 'http://www.liexin.com/v3/sku/list', // 'search-skuid' => 'http://www.liexin.com/v3/sku/list',
'search-skuid' => 'http://api.liexin.com/goods/detail', 'search-skuid' => 'http://api.liexin.com/goods/detail',
'search-skuid-finalInfo' => 'http://api.liexin.com/cart/bomOrderGetFinalGoods',
//自营订单添加购物车
'addzyorder_url' => 'http://api.liexin.com/cart/addBatch',
//联营加入购物车
'addlyorder_url' => 'http://api.liexin.com/cart/addBatchByOrderSystem',
//bom创建订单
'api_create_order' => 'http://api.liexin.com/order/create',
// 新增SKU入口 // 新增SKU入口
'add-sku-url' => 'http://footstone.liexin.net/manage/addsku', 'add-sku-url' => 'http://footstone.liexin.net/manage/addsku',
......
...@@ -4,6 +4,48 @@ ...@@ -4,6 +4,48 @@
$.extend($.lie, { $.extend($.lie, {
audit: { audit: {
index:function() { index:function() {
// 申请主管审核
$('.apply-manager-audit').click(function() {
var order_id = $(this).data('id');
// 弹出提示
layer.open({
area: ['360px'],
title: '提示信息',
content: '确定申请主管审核吗?',
btn:['确定', '取消'],
yes: function(index, layero){
$.ajax({
url : '/ajaxApplyManagerAudit',
type: 'post',
data: {order_id: order_id},
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
return false;
}
layer.alert(resp.errmsg);
return false;
},
error: function (res) {
console.log(res);
}
})
layer.msg('申请中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
},
btn2: function(index, layero){
layer.close(index);
}
});
})
// 主管审核 // 主管审核
$('.manager-audit').click(function() { $('.manager-audit').click(function() {
var order_id = $(this).data('id'); var order_id = $(this).data('id');
......
...@@ -140,6 +140,8 @@ ...@@ -140,6 +140,8 @@
layer.alert('网络异常'); layer.alert('网络异常');
} }
}); });
layer.msg('提交中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
}, },
btn2:function(index){ btn2:function(index){
layer.close(index); layer.close(index);
......
layui.use(['form', 'table', 'laydate'], function(){
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
var renderTable = function () {
table.render({
id: 'list'
,elem: '#list'
,url: '/ajax/bom/BomList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: 'id',field: 'bom_id', fixed: 'left', width: 80}
,{field: 'add_time', title: '创建时间', width: 180}
,{field: 'bom_name', title: 'BOM名称', width: 160}
,{templet: '<div>{{d.bom_extend ? d.bom_extend.user_name : ""}}</div>', title: '会员账号', width: 180}
,{templet: '<div>{{d.bom_extend ? d.bom_extend.company_name : ""}}</div>', title: '公司名称', width: 160}
,{field:'bomMoney', title: 'BOM单金额', width: 130}
,{field: 'is_corder', title: '是否下单', templet: '#is_corder', width: 150}
,{field: '', title: '对应订单编号', width: 120,templet:"#bomCOrderSn"}
,{field: 'bomCOrderAmount', title: '下单金额', width: 150}
,{templet: '<div>{{d.bom_extend ? d.bom_extend.fcorder_time : ""}}</div>', title: '首次下单时间', width: 180}
,{templet: '<div>{{d.bom_extend ? d.bom_extend.kefu_name : ""}}</div>', title: '客服', width: 150}
,{field: 'status', title: '状态', templet: '#status', width: 150}
,{field: 'join_time', title: '操作',toolbar: '#action',width:130,fixed: 'right',}
]]
,limit: 10
,limits: [10, 20, 50,]
});
};
renderTable();
form.on('submit(load)', function(data) {
//执行重载
table.reload('list', {
page: {
curr: 1
}
,where: data.field
});
return false;
});
$('.add').click(function() {
layer.open({
area: ['400px', '200px'],
title: '新增客服',
type: 1,
content: $('#kefu-action'),
btn: ['确认', '取消'],
yes: function(index) {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
$.ajax({
url : '/api/ApiAddKefu',
type: 'post',
data: {email: email},
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg('新增客服中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
$('.kefu-email').val('');
})
// tool操作
table.on('tool(kefu)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var url = '';
var title = '';
var content = '';
var datax = {};
datax.id = data.id;
if(layEvent === 'edit') {
url = '/api/ApiEditKefu';
title = '编辑客服';
content = $('#kefu-action');
} else if (layEvent === 'del') {
url = '/api/ApiDelKefu';
title = '删除客服';
content = '<div style="margin: 40px;">确定删除该客服吗?</div>';
datax.status = data.status;
} else if (layEvent === 'top') {
url = '/api/ApiTopKefu';
title = '置顶客服';
content = '<div style="margin: 40px;">确定置顶该客服吗?</div>';
}
layer.open({
area: ['400px', '200px'],
title: title,
type: 1,
content: content,
btn: ['确认', '取消'],
yes: function(index) {
if (layEvent == 'edit') {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
datax.email = email;
}
$.ajax({
url : url,
type: 'post',
data: datax,
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
if (layEvent == 'edit') {
$('.kefu-email').val(data.email);
}
});
});
\ No newline at end of file
layui.use(['form', 'table', 'laydate'], function() {
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
//时间选择器
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
function initDataCount(datax){
$.post("/ajax/bom/bomReportCount",datax,function(res){
if(res.errcode == 0){
$.each(res.data,function(k,v){
$("#"+k).text(v);
})
}
})
}
initDataCount({});
$("#test1_button").click(function(){
var aa = $("#test1_form").serialize()
initDataCount(aa)
})
})
\ No newline at end of file
layui.use(['form', 'table', 'laydate'], function() {
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
//转换静态表格
table.init('bomView', {
limit:10
,url: '/ajax/bom/BomView?bom_id='+bom_id //数据接口
,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
,defaultToolbar:[]
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
});
function renderTable(){
table.init('bomView', {
limit:10
,url: '/ajax/bom/BomView?bom_id='+bom_id //数据接口
,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
,defaultToolbar:[]
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
});
}
form.on('checkbox(checkall)', function (data) {
var child = $(data.elem).parents('.layui-tab-item').find('input[type="checkbox"]');
child.each(function (index, item) {
item.checked = data.elem.checked;
});
form.render('checkbox');
});
//监听单元格编辑
table.on('edit(bomView)', function(obj){
var value = obj.value //得到修改后的值
,data = obj.data //得到所在行所有键值
,field = obj.field; //得到字段
if(field != "match_goods_id"){
obj.data.match_goods_id = 0;
obj.update(data) //修改当前行数据
}
});
function save_form_ajax(datax){
layer.open({
title: "保存bom单",
content: "你确定保存吗?",
btn: ['确认?', '取消'],
yes: function(index) {
layer.close(index);
$.ajax({
url : "/ajax/bom/saveBomInfo",
type: 'post',
data: datax,
success: function(resp) {
if (resp.errcode == 0) {
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
}else{
layer.alert(resp.errmsg);
}
},
error: function(err) {
console.log(err)
}
})
layer.msg('请耐心等待....', {icon: 16, time: 5000, shade: 0.3})
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
function create_order_ajax(datax){
layer.open({
title: "创建bom订单",
content: "你确定下单吗?",
btn: ['确认?', '取消'],
yes: function(index) {
layer.close(index);
$.ajax({
url : "/ajax/bom/createBomOrder",
type: 'post',
data: datax,
success: function(resp) {
if (resp.errcode == 0) {
layer.alert(resp.errmsg);
//return
renderTable(); // 重新加载table
}else{
layer.alert(resp.errmsg);
}
},
error: function(err) {
console.log(err)
}
})
layer.msg('请耐心等待....', {icon: 16, time: 10000, shade: 0.3})
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
//头工具栏事件
table.on('toolbar(bomView)', function(obj){
var checkStatus = table.checkStatus("layui_table_bomView");
var data = checkStatus.data;
if(checkStatus.data.length <= 0){
layer.msg('请先选择需要保存的数据行', {icon: 16, time: 3000, shade: 0.3})
return
}
var datax = {}
datax.data = data
switch(obj.event){
case 'create_order':
create_order_ajax(datax);
break;
case 'save_form':
save_form_ajax(datax)
break;
};
});
})
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="tabs-box"> <div class="tabs-box">
<div class="order-change-main"> <div class="order-change-main">
@if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 1) || ($order_info['order_goods_type'] == 2 && $order_info['adjust_count'] < 2)) @if (($order_info['order_goods_type'] == 1 && in_array($order_info['status'], [1, 2]) && $order_temp_info['is_manager_audit'] != 3) || ($order_info['order_goods_type'] == 2 && $order_info['adjust_count'] < 2))
<form id="checkOrderForm" class="form-horizontal table-responsive"> <form id="checkOrderForm" class="form-horizontal table-responsive">
<input type="hidden" name="auditor_role" value="{{ $role }}" > <input type="hidden" name="auditor_role" value="{{ $role }}" >
<input type="hidden" name="order_sn" value="{{$order_info['order_sn']}}"> <input type="hidden" name="order_sn" value="{{$order_info['order_sn']}}">
...@@ -417,7 +417,7 @@ ...@@ -417,7 +417,7 @@
</form> </form>
@endif @endif
@if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 2) || ($order_info['order_goods_type'] != 1 && $order_info['adjust_count'] == 2)) @if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 2 && $order_temp_info['is_manager_audit'] == 3) || ($order_info['order_goods_type'] == 2 && $order_info['status'] == 2 && $order_info['adjust_count'] == 2))
<div class="checked_section"> <div class="checked_section">
<div class="checked_left"> <div class="checked_left">
<p>交易状态:&nbsp;审核通过,请联系客户及时付款! <p>交易状态:&nbsp;审核通过,请联系客户及时付款!
......
...@@ -157,20 +157,25 @@ ...@@ -157,20 +157,25 @@
@endif @endif
@if (in_array('check_order', $userPerms) && $order_info['sale_id']) @if (in_array('check_order', $userPerms) && $order_info['sale_id'])
@if ($order_info['status'] == 1) @if (isset($order_temp_info['is_manager_audit']) && $order_temp_info['is_manager_audit'] != 3 && in_array($order_info['status'], [1, 2]))
<a class="btn btn-success" href="{{URL('change', ['order_id'=>$order_info['order_id']])}}" target="_blank">人工审单</a> <a class="btn btn-success" href="{{URL('change', ['order_id'=>$order_info['order_id']])}}" target="_blank">人工审单</a>
@elseif ($order_info['status'] == 2 && in_array($role, [1, 2])) @elseif ($order_info['status'] == 2 && $order_temp_info['is_manager_audit'] == 3 && in_array($role, [1, 2]))
<a class="btn btn-success re-audit" data-id="{{$order_info['order_id']}}">反审</a> <a class="btn btn-success re-audit" data-id="{{$order_info['order_id']}}">反审</a>
@endif @endif
@endif @endif
<!-- 申请主管审核 -->
@if (isset($order_temp_info['is_manager_audit']) && $order_temp_info['is_manager_audit'] == 1 && $order_info['status'] == 2)
<a class="btn btn-info apply-manager-audit" data-id="{{$order_info['order_id']}}">申请主管审核</a>
@endif
<!-- 主管审核 --> <!-- 主管审核 -->
@if ($order_temp_info['is_manager_audit'] && in_array($role, [1, 2]) && $order_info['status'] == 1) @if (isset($order_temp_info['is_manager_audit']) && (($order_info['status'] == 2 && $order_temp_info['is_manager_audit'] == 2) || ($order_info['status'] > 2 && $order_temp_info['is_manager_audit'] != 3)) && in_array($role, [1, 2]) && empty($order_temp_info['erp_sn']))
<a class="btn btn-danger manager-audit" data-id="{{$order_info['order_id']}}">主管审核</a> <a class="btn btn-danger manager-audit" data-id="{{$order_info['order_id']}}">主管审核</a>
@endif @endif
<!-- 判断邮件发送时机 --> <!-- 判断邮件发送时机 -->
@if (!empty($order_temp_info['erp_sn']) ) @if (!empty($order_temp_info['erp_sn']) && in_array($order_info['status'], [2, 3, 4]))
<a class="btn btn-primary send_mail" data-id="{{ $order_info['order_id'] }}">发送邮件</a> <a class="btn btn-primary send_mail" data-id="{{ $order_info['order_id'] }}">发送邮件</a>
@endif @endif
<!-- 预付款 管理员完成首款对账后改变'对账'按钮 --> <!-- 预付款 管理员完成首款对账后改变'对账'按钮 -->
......
<style>
.action_log_event{ word-break: break-all; }
</style>
<p>操作记录</p> <p>操作记录</p>
<div class="tabs-box table-responsive"> <div class="tabs-box table-responsive">
<table class="table table-bordered table-hover"> <table class="table table-bordered table-hover">
...@@ -14,13 +18,13 @@ ...@@ -14,13 +18,13 @@
<tr> <tr>
<td width="15%"><?= date('Y-m-d H:i:s', $v->create_time) ?></td> <td width="15%"><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
<td width="10%"><?= App\Http\Controllers\getOperatorName($v->operator_id, $v->operator_type) ?></td> <td width="10%"><?= App\Http\Controllers\getOperatorName($v->operator_id, $v->operator_type) ?></td>
<td><?= $v->event ?></td> <td class="action_log_event"><?= $v->event ?></td>
</tr> </tr>
<?php } else { ?> <?php } else { ?>
<tr class="other-infos"> <tr class="other-infos">
<td width="15%"><?= date('Y-m-d H:i:s', $v->create_time) ?></td> <td width="15%"><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
<td width="10%"><?= App\Http\Controllers\getOperatorName($v->operator_id, $v->operator_type) ?></td> <td width="10%"><?= App\Http\Controllers\getOperatorName($v->operator_id, $v->operator_type) ?></td>
<td><?= $v->event ?></td> <td class="action_log_event"><?= $v->event ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
<th>发货状态</th> <th>发货状态</th>
<th>物流单号</th> <th>物流单号</th>
<th>京东订单编号</th> <th>京东订单编号</th>
<th width="8%">自动确认收货时间</th> <th>自动确认收货时间</th>
</tr> </tr>
<tr> <tr>
<td>{{ $order_info['order_sn'] }}</td> <td>{{ $order_info['order_sn'] }}</td>
<td>{{ $order_temp_info['is_manager_audit'] ? '待主管审核' : Config('params.order_status')[$order_info['status']] }}</td> <td>{{ Config('params.order_status')[$order_info['status']] }}</td>
<td>{{ $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'] }}</td> <td>{{ $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'] }}</td>
<td> <td>
<?php <?php
......
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
<td> <td>
<!-- <button type="button" class="btn btn-success btn-xs remarks">编辑</button> --> <!-- <button type="button" class="btn btn-success btn-xs remarks">编辑</button> -->
<?php if (in_array($order_info['status'], [1, 2, 3]) && $v['status'] == 1) { ?> <?php if (in_array($order_info['status'], [1, 2, 3, 4]) && $v['status'] == 1) { ?>
<button type="button" class="btn btn-success btn-xs edit-item" data-id="<?= $v['rec_id'] ?>" data-batch="<?= $v['batch'] ?>" data-bid="<?= $v['buyer_id'] ?>" data-remarks="<?= $v['remarks'] ?>">编辑</button> <button type="button" class="btn btn-success btn-xs edit-item" data-id="<?= $v['rec_id'] ?>" data-batch="<?= $v['batch'] ?>" data-bid="<?= $v['buyer_id'] ?>" data-remarks="<?= $v['remarks'] ?>">编辑</button>
<?php } ?> <?php } ?>
</td> </td>
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
<tr class="caption"> <tr class="caption">
<th colspan="8" style="text-align: center; background: #f9f9f9;"> 发票信息 <th colspan="8" style="text-align: center; background: #f9f9f9;"> 发票信息
<?php <?php
//<!-- 发票状态小于2(已发货)且更改权限存在 显示按钮 --> //<!-- 发票状态小于2(已发货)且更改权限存在 且未同步ERP 显示按钮 -->
if (!isset($tags)) { if (empty($tags)) {
if(in_array($order_info['status'], [1, 2, 3, 4]) && $order_invoice_info['invoice_status'] < 2 && in_array('update_invoice', $userPerms)) { if(in_array($order_info['status'], [1, 2, 3, 4]) && $order_invoice_info['invoice_status'] < 2 && in_array('update_invoice', $userPerms) && empty($order_temp_info['erp_sn'])) {
echo '<a href="/changeInvoice/'.$order_info['order_id'].'" class="btn btn-success btn-sm changeBtn">更改发票</a>'; echo '<a href="/changeInvoice/'.$order_info['order_id'].'" class="btn btn-success btn-sm changeBtn">更改发票</a>';
} }
} elseif ($order_info['status'] != -1 && isset($tags) && $tags == 'self' && isset($extend) && !$extend) { } elseif ($order_info['status'] != -1 && isset($tags) && $tags == 'self' && isset($extend) && !$extend) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<script src="/js/md5.js"></script> <script src="/js/md5.js"></script>
<script src="/js/layui/layui.js"></script> <script src="/js/layui/layui.js"></script>
<script src="/js/details.js?v=<?= time() ?>"></script> <script src="/js/details.js?v=<?= time() ?>"></script>
<script src="/js/order_audit.js"></script> <script src="/js/order_audit.js?v=<?= time() ?>"></script>
<script src="/js/order_track.js"></script> <script src="/js/order_track.js"></script>
<script src="/js/order_cancel.js"></script> <script src="/js/order_cancel.js"></script>
<script src="/js/order_send_email.js"></script> <script src="/js/order_send_email.js"></script>
......
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
<th class="pl30">ERP单号</th> <th class="pl30">ERP单号</th>
<th class="pl30">应付金额</th> <th class="pl30">应付金额</th>
<th class="pl30">订单状态</th> <th class="pl30">订单状态</th>
<th class="pl30">主管审核</th>
<th class="pl30">付款类型</th> <th class="pl30">付款类型</th>
<th class="pl30">支付方式</th> <th class="pl30">支付方式</th>
<th class="pl30">业务员</th> <th class="pl30">业务员</th>
...@@ -289,9 +290,6 @@ ...@@ -289,9 +290,6 @@
</td> </td>
<td class="show-list"> <td class="show-list">
<?php <?php
if (!empty($order_extend->is_manager_audit) && $v['status'] == 1) {
echo '<span class="list-text-checking"><b>待主管审核</b></span>';
} else {
switch ($v['status']) { switch ($v['status']) {
case -2: echo '<span class="list-text-no-check"><b>审核未通过</b></span>';break; case -2: echo '<span class="list-text-no-check"><b>审核未通过</b></span>';break;
case -1: echo '<span class="list-text-cancel"><b>已取消</b></span>';break; case -1: echo '<span class="list-text-cancel"><b>已取消</b></span>';break;
...@@ -303,6 +301,21 @@ ...@@ -303,6 +301,21 @@
case 8: echo '<span class="list-text-confirm"><b>待收货</b></span>';break; case 8: echo '<span class="list-text-confirm"><b>待收货</b></span>';break;
case 10: echo '<span class="list-text-success"><b>交易成功</b></span>';break; case 10: echo '<span class="list-text-success"><b>交易成功</b></span>';break;
} }
?>
</td>
<td class="show-list">
<?php
if ($v['status'] >= 1 && isset($order_extend->is_manager_audit)) {
switch ($order_extend->is_manager_audit) {
case 1:
echo '<span class="list-text-checking"><b>未申请</b></span>';break;
case 2:
echo '<span class="list-text-checking"><b>待审核</b></span>';break;
case 3:
echo '<span class="list-text-success"><b>已审核</b></span>';break;
default:
echo ''; break;
}
} }
?> ?>
</td> </td>
...@@ -331,19 +344,24 @@ ...@@ -331,19 +344,24 @@
<td> <td>
<div class="btn-group btn-group-xs" style="min-width: 200px;"> <div class="btn-group btn-group-xs" style="min-width: 200px;">
@if (in_array('check_order', $userPerms) && $v['sale_id']) @if (in_array('check_order', $userPerms) && $v['sale_id'])
@if ($v['status'] == 1) @if (isset($order_extend->is_manager_audit) && $order_extend->is_manager_audit != 3 && in_array($v['status'], [1, 2]))
<a class="btn btn-success" href="{{URL('change', ['order_id'=>$v['order_id']])}}" target="_blank">人工审单</a> <a class="btn btn-success" href="{{URL('change', ['order_id'=>$v['order_id']])}}" target="_blank">人工审单</a>
@elseif ($v['status'] == 2 && in_array($role, [1, 2])) @elseif ($v['status'] == 2 && $order_extend->is_manager_audit == 3 && in_array($role, [1, 2]))
<a class="btn btn-success re-audit" data-id="{{$v['order_id']}}">反审</a> <a class="btn btn-success re-audit" data-id="{{$v['order_id']}}">反审</a>
@endif @endif
@endif @endif
<!-- 主管审核 --> <!-- 申请主管审核 -->
@if (isset($order_extend->is_manager_audit) && in_array($role, [1, 2]) && $v['status'] == 1) @if (isset($order_extend->is_manager_audit) && $order_extend->is_manager_audit == 1 && $v['status'] == 2)
<a class="btn btn-info apply-manager-audit" data-id="{{$v['order_id']}}">申请主管审核</a>
@endif
<!-- 主管审核 (待付款且待主管审核 || 已付款且主管未审核) && 主管角色 && 未同步 -->
@if (isset($order_extend->is_manager_audit) && (($v['status'] == 2 && $order_extend->is_manager_audit == 2) || ($v['status'] > 2 && $order_extend->is_manager_audit != 3)) && in_array($role, [1, 2]) && empty($order_extend->erp_sn))
<a class="btn btn-danger manager-audit" data-id="{{$v['order_id']}}">主管审核</a> <a class="btn btn-danger manager-audit" data-id="{{$v['order_id']}}">主管审核</a>
@endif @endif
@if (!empty($order_extend->erp_sn)) @if (!empty($order_extend->erp_sn) && in_array($v['status'], [2, 3, 4]))
<a class="btn btn-warning send_mail" data-id="{{ $v['order_id'] }}">发送邮件</a> <a class="btn btn-warning send_mail" data-id="{{ $v['order_id'] }}">发送邮件</a>
@endif @endif
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<script src="/js/common.js"></script> <script src="/js/common.js"></script>
<script src="/js/layui/layui.js"></script> <script src="/js/layui/layui.js"></script>
<script src="/js/list.js?v=<?= time() ?>"></script> <script src="/js/list.js?v=<?= time() ?>"></script>
<script src="/js/order_audit.js"></script> <script src="/js/order_audit.js?v=<?= time() ?>"></script>
<script src="/js/order_track.js"></script> <script src="/js/order_track.js"></script>
<script src="/js/order_cancel.js"></script> <script src="/js/order_cancel.js"></script>
<script src="/js/order_send_email.js"></script> <script src="/js/order_send_email.js"></script>
......
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">BOM名称</label>
<div class="layui-input-inline">
<input type="text" name="bom_name" placeholder="填写BOM名称" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建用户</label>
<div class="layui-input-inline">
<input type="text" name="username" placeholder="填写创建用户" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建日期:</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">是否下单</label>
<div class="layui-input-inline">
<select name="is_corder" lay-verify="" lay-search>
<option value="">全部</option>
<option value="1"></option>
<option value="0"></option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">客服</label>
<div class="layui-input-inline">
<select name="is_kefu" lay-verify="" lay-search>
<option value="all">全部</option>
<option value="1"></option>
<option value="0"></option>
</select>
</div>
</div>
<div class="layui-inline" style="text-align: center;">
<button lay-submit lay-filter="load" class="layui-btn" data-type="search">搜索</button>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="action">
{{--<a class="btn btn-xs btn-outline btn-success" href="/web/showTemplate?t_id=@{{ d.bom_id }}" target="_blank" lay-event="show">下载</a>--}}
<a class="btn btn-xs btn-outline btn-success" href="/web/BomView?bom_id=@{{ d.bom_id }}" target="_blank" lay-event="show">详情</a>
</script>
<script type="text/html" id="status">
@{{# if (d.status == 1) { }}
<div style="color:green;">正常</div>
@{{# } else { }}
<div style="color:#ccc;">删除</div>
@{{# } }}
</script>
<script type="text/html" id="is_corder">
@{{# if (d.is_corder == 1) { }}
<div style="color:green;">已下单</div>
@{{# } else { }}
<div style="color:#ccc;">未下单</div>
@{{# } }}
</script>
<script type="text/html" id="kefu_name">
@{{# d.bom_extend.kefu_name }}
</script>
<script type="text/html" id="bomCOrderSn">
@{{# if (d.bomCOrderSn) { }}
@{{ d.bomCOrderSn.join(",")}}
@{{# } }}
</script>
<div class="layui-col-md12" style="padding-bottom: 15px">
<h3>数据概况</h3>
<hr>
<form class="layui-form layui-box" id="test1_form" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">BOM单号</label>
<div class="layui-input-inline">
<input type="text" name="bom_sn" placeholder="填写BOM单号" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建日期:</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">客服</label>
<div class="layui-input-inline">
<select name="is_kefu" lay-verify="" lay-search>
<option value="all">全部</option>
<option value="1"></option>
<option value="0"></option>
</select>
</div>
</div>
<div class="layui-inline" style="text-align: center;">
<a id="test1_button" class="layui-btn" >搜索</a>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
<div class="layui-card-body">
<table class="layui-table" id="dataCont">
<tr>
<th lay-data="">提交BOM单数量</th>
<th lay-data="">BOM单数量</th>
{{--<th lay-data="">BOM付款数量</th>--}}
<th lay-data="">提交型号数</th>
<th lay-data="">下单型号数</th>
{{--<th lay-data=>付款型号数</th>--}}
<th lay-data=>提交BOM金额</th>
<th lay-data=>下单BOM金额</th>
<th >无结果型号</th>
<th>询价型号数</th>
</tr>
<tr>
<th id="field1"></th>
<th id="field2"></th>
{{--<th id="field3"></th>--}}
<th id="field4"></th>
<th id="field5"></th>
{{--<th id="field6"></th>--}}
<th id="field7"></th>
<th id="field8"></th>
<th id="field10"></th>
<th id="field11"></th>
</tr>
</table>
</div>
</div>
{{--<div class="layui-card" style="">--}}
{{--<h3>用户数据</h3>--}}
{{--<hr>--}}
{{--<form class="layui-form layui-box" id="test5" method="post">--}}
{{--<div class="layui-form-item">--}}
{{--<div class="layui-inline">--}}
{{--<label class="layui-form-label">创建日期:</label>--}}
{{--<div class="layui-input-inline">--}}
{{--<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>--}}
{{--</div>--}}
{{--<div class="layui-form-mid">-</div>--}}
{{--<div class="layui-input-inline">--}}
{{--<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="layui-inline">--}}
{{--<label class="layui-form-label">客服</label>--}}
{{--<div class="layui-input-inline">--}}
{{--<select name="is_kefu" lay-verify="" lay-search>--}}
{{--<option value="all">全部</option>--}}
{{--<option value="1"></option>--}}
{{--<option value="0"></option>--}}
{{--</select>--}}
{{--</div>--}}
{{--</div>--}}
{{--<div class="layui-inline" style="text-align: center;">--}}
{{--<button class="layui-btn" data-type="search">搜索</button>--}}
{{--<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->--}}
{{--</div>--}}
{{--</div>--}}
{{--</form>--}}
{{--</div>--}}
<style>
::-webkit-scrollbar-track-piece {
-webkit-border-radius: 0
}
::-webkit-scrollbar {
width: 5px;
height: 10px
}
::-webkit-scrollbar-thumb {
height: 50px;
background-color: #b8b8b8;
-webkit-border-radius: 6px;
outline-offset: -2px;
filter: alpha(opacity = 50);
-moz-opacity: 0.5;
-khtml-opacity: 0.5;
opacity: 0.5
}
::-webkit-scrollbar-thumb:hover {
height: 50px;
background-color: #878987;
-webkit-border-radius: 6px;
}
</style>
<table class="layui-table" lay-filter="bomView" id="layui_table_bomView">
<thead>
<tr>
<th lay-data="{fixed: 'left',templet:'#checkbd'}"><input type="checkbox" >全选</th>
<th lay-data="{type:'numbers', width:80, sort: true,fixed: 'left'}">序号</th>
<th lay-data="{field:'goods_name', width:150}">需求型号</th>
<th lay-data="{field:'brand_name',width:140,}">品牌</th>
<th lay-data="{field:'number',width:120,}">需求数量</th>
<th lay-data="{field:'attrs',width:120,}">参数</th>
<th lay-data="{field: 'match_goods_id',width:150,edit:'text'}">skuID(可修改)</th>
<th lay-data="{field: 'match_goods_name',width:200,edit:'text'}">推荐型号(可修改)</th>
<th lay-data="{field: 'match_brand_name',width:200,edit:'text'}">推荐品牌(可修改)</th>
<th lay-data="{field:'match_number', width:130,edit:'text'}"><i class="layui-icon-edit"></i>推荐数量(可修改)</th>
<th lay-data="{field:'match_price',width:130,edit:'text'}">单价(可修改)</th>
<th lay-data="{field:'match_delivery',width:160,edit:'text'}">货期/天(可修改)</th>
<th lay-data="{field:'match_supplier_name',edit:'text',width:160}">供应商(可修改)</th>
<th lay-data="{field:'match_mpq'}">包装</th>
<th lay-data="{field:'match_moq'}">起订量</th>
<th lay-data="{field:'match_amount',width:100}">小计</th>
<th lay-data="{field:'is_corder',templet: '#match_ic_corder',width:100}">是否下单</th>
{{--<th lay-data="{field:'bom_match_extend',templet: '#match_extend_order_amount',width:150}">下单金额</th>--}}
<th lay-data="{field:'bom_match_extend',templet: '#match_extend_order_sn',width:150}">订单编号</th>
</tr>
</thead>
</table>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="save_form">保存</button>
<button class="layui-btn layui-btn-sm" lay-event="create_order">下单</button>
</div>
</script>
<script type="text/html" id="match_ic_corder">
@{{# if (d.is_corder == 1) { }}
<div style="color: #ff0000">下单</div>
@{{# }else{ }}
未下单
@{{# } }}
</script>
<script type="text/html" id="checkbd">
@{{# if (d.is_corder != 1) { }}
<input type="checkbox" name="layTableCheckbox" lay-skin="primary">
@{{# } }}
</script>
<script type="text/html" id="match_extend_order_amount">
@{{# if (d.bom_match_extend) { }}
@{{ d.bom_match_extend.order_amount }}
@{{# } }}
</script>
<script type="text/html" id="match_extend_order_sn">
@{{# if (d.bom_match_extend) { }}
@{{# if(d.bom_match_extend.order_id > 0){ }}
@{{# if(d.match_goods_type == 0){ }}
<a href="/details/@{{ d.bom_match_extend.order_id }}?tags=self">@{{ d.bom_match_extend.order_sn }}</a>
@{{# }else{ }}
<a href="/details/@{{ d.bom_match_extend.order_id }}">@{{ d.bom_match_extend.order_sn }}</a>
@{{# } }}
@{{# } }}
@{{# } }}
</script>
<script>
var bom_id = "{{$bom_id}}"
</script>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
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