提交 14fd4367 authored 作者: 李大见's avatar 李大见

自动派单修改

上级 f6d16592
......@@ -13,6 +13,7 @@ use App\Http\Controllers\Admin\Push;
use App\Models\Temporary;
use App\Models\Disareanew;
use App\Models\Bserviss;
use App\Services\OrderDeductionFeeService;
use DB;
class AotuorderController extends BaseController
......@@ -217,6 +218,7 @@ class AotuorderController extends BaseController
}else{
$data=$this->addWorkOrder($order,$sys_num,$list[0]['id'],$order['new_customer_id'],0,$goodid,$admin_acc,$admin_id);
}
$this->insertingLog("系统派单,",$sys_num,"订单l".$data['msg'].";距离(".$list[0]['id']."):".$list[0]['juli'],"订单管理",$ip,$admin_acc);//日志
return true;
}
......@@ -316,6 +318,18 @@ class AotuorderController extends BaseController
$data['msg']="派单失败,该订单状态不正确,请刷新核实!";
return $data;
}
// 派单扣除 订单所属公司金额
// 扣费
$post_data['adm_id'] = $orderinfo['admin_id'];
$post_data['company_id'] = $orderinfo['company_id'];
$post_data['order_number'] = $sys_num;
$post_data['reo_price'] = -0.5;
$reduce_price = OrderDeductionFeeService::deductFee($post_data);
if ($reduce_price['code'] != 200) {
$data['code']=2;
$data['msg']="余额不足";
return $data;
}
// 绑定状态1.否2.是
$binds=DB::table('admin_infor')->where('admin_id',$ser_id)->value("bind");
......@@ -366,6 +380,10 @@ class AotuorderController extends BaseController
$get['admin_id']=$admin_id??'1133';//创建人id
$get['creater']=$admin_acc??'系统录入';//创建人
$get['customer_id']=$user_id;//用户id
$agency_id = DB::table('admin')
->where('id',$ser_id)
->value('company_id');
$get['agency_id'] = $agency_id;//代理商id(运营商)
$get['customer_phone']=$shr_phone['shr_phone'];//客户手机号
$get['orli_type']=$orderinfo['order_type'];//订单类型
$get['pay_typel']=$orderinfo['pay_type'];//支付方式
......
......@@ -260,6 +260,7 @@ class OrderListController extends BaseController
*/
public function executeGetOrder ( $input , $session , $ip ){
$checkKey = CommonService::checkKey(['id','type'],$input);
if($checkKey['code']!=1){
return $this->error('参数'.$checkKey['data'].'未填写,或值为空', ErrorInc::INVALID_PARAM);exit;
}
......@@ -398,23 +399,13 @@ class OrderListController extends BaseController
$orderPrice = (double)$input['order_price'];
$arr['company_id'] = $orderListArr['company_id'];
$arr['agency_id'] = $orderListArr['agency_id'];
if($returncount==1){
// if($orderListArr['sys_num']=='L20210813171821054'){
// dump($supply_price);exit;
// }
$ret = $this->getOrderOne($id,$supply_price,$input['install_person'],$orderListArr, $info, $post, $get, $arr,$negotiated,$reward,$admin_acc,$orderPrice,$MsgArr,$is_bool,$ip);
if($ret==5){
$pt_type = Pt::where('id',$orderListArr['p_id'])->value('pt_type');
if($pt_type==3){
// $arr_u['workerRO']['inspectionStation'] = Admin::where('id',$orderListArr['ser_id'])->value('company_name');
// $arr_u['workerRO']['workOrderId'] = $orderListArr['order_num'];
// $arr_u['workerRO']['carNumber'] = $insArr['plate_num']??'暂无';
// $arr_u['workerRO']['workerName'] = $insArr['install_name'];
// $arr_u['workerRO']['workerMobile'] = $insArr['install_phone'];
// $arr_u['workerRO']['channel'] = DB::table('tm_proprietary')->where('order_id',$orderListArr['order_num'])->value('channel');
$arr_up['inspectionStation'] = Admin::where('id',$orderListArr['ser_id'])->value('company_name');
$arr_up['workOrderId'] = $orderListArr['order_num'];
$arr_up['carNumber'] = $insArr['plate_num']??'暂无';
......@@ -1832,11 +1823,11 @@ class OrderListController extends BaseController
}
}
// 扣费
$post_data['adm_id'] = $orderListArr['admin_id'];
$post_data['company_id'] = $orderListArr['company_id'];
$post_data['order_number'] = $orderListArr['sys_num'];
$post_data['reo_price'] = -0.5;
$reduce_price = OrderDeductionFeeService::deductFee($post_data);
// $post_data['adm_id'] = $orderListArr['admin_id'];
// $post_data['company_id'] = $orderListArr['company_id'];
// $post_data['order_number'] = $orderListArr['sys_num'];
// $post_data['reo_price'] = -0.5;
// $reduce_price = OrderDeductionFeeService::deductFee($post_data);
// 扣库存
$ware_id = DB::table('warehouse')
->where('company_id', $orderListArr['agency_id'])
......
......@@ -38,10 +38,15 @@ class WarehouseController extends BaseController
public function index(Request $request) {
$session = Request()->get('session_token');//用户信息
$Db = new Warehouse();
$Db = $Db->leftjoin('company', 'com_id', '=', 'company_id');
if($request->filled('shck_ckmc')){ //仓库名称
$shck_ckmc = $request->input('shck_ckmc');
$Db = $Db->where('shck_ckmc', 'like','%'.$shck_ckmc.'%');
}
if($request->filled('comapny_name')){ //仓库名称
$comapny_name = $request->input('comapny_name');
$Db = $Db->where('com_name', 'like','%'.$comapny_name.'%');
}
$page_size = $request->input('page_size',10);
$page = $request->input('page',1);
if ($session['admin_groupnew'] != 7) {
......@@ -66,10 +71,18 @@ class WarehouseController extends BaseController
$list = self::dataToArray($paginate->items());
if($list){
foreach ($list as $k =>$v){
$button = [];
$list[$k]['ware_goods_num'] = DB::table('ware_goods')
->where('wago_ware_id', $v['id'])
->sum('wago_stock_num');
$button = ['wareGoods', 'addGoodsNum'];
$list[$k]['comapny_name'] = DB::table('company')
->where('com_id', $v['company_id'])
->value('com_name');
if ($session['admin_groupnew'] == 7) {
$button = ['wareGoods', 'addGoodsNum'];
} else {
$button = ['wareGoods'];
}
$button = BmmcService::getListButton($button,$all_button);
$list[$k]['button_one'] = $button['button_one']??[];
$list[$k]['button_two'] = $button['button_two']??[];
......@@ -97,48 +110,54 @@ class WarehouseController extends BaseController
* @param Request $request [description]
*/
public function addGoodsNum(Request $request) {
if (empty($request['ware_id'])) {
if (empty($request['company_id'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择仓库', 'ErrorCode' => 2]);
}
if (empty($request['goods_id'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择商品', 'ErrorCode' => 2]);
}
if (empty($request['goods_num'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择数量', 'ErrorCode' => 2]);
}
$find_goods = DB::table('pj_goods')
->where('pg_id', $request['goods_id'])
->first();
if (empty($find_goods)) {
return response()->json(['Data' =>'', 'ErrorMessage' => '未查询到此商品', 'ErrorCode' => 2]);
}
if ($find_goods['is_delect'] == 2) {
return response()->json(['Data' =>'', 'ErrorMessage' => '此商品已停用', 'ErrorCode' => 2]);
if (empty($request['ware_id'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择仓库', 'ErrorCode' => 2]);
}
$find_data = DB::table('ware_goods')
->where('wago_ware_id', $request['ware_id'])
->where('wago_goo_id', $request['goods_id'])
->first();
$goods_data = $request['goods_data'];
DB::beginTransaction();
if (empty($find_data)) {
$add_data['wago_company_id'] = $session['company_id'];
$add_data['wago_ware_id'] = $request['ware_id'];
$add_data['wago_goo_id'] = $request['goods_id'];
$add_data['wago_stock_num'] = $request['goods_num'];
$add_res = DB::table('ware_goods')->insertGetId($add_data);
} else {
$update['wago_stock_num'] = $find_data['wago_stock_num'] + $request['goods_num'];
$add_res = DB::table('ware_goods')
->where('wago_id', $find_data['wago_id'])
->update($update);
$add_res = $find_data['wago_id'];
foreach ($goods_data as $key => $value) {
if (empty($value['goods_id'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择商品', 'ErrorCode' => 2]);
}
if (empty($value['goods_num'])) {
return response()->json(['Data' =>'', 'ErrorMessage' => '请选择数量', 'ErrorCode' => 2]);
}
$find_goods = DB::table('pj_goods')
->where('pg_id', $value['goods_id'])
->first();
if (empty($find_goods)) {
return response()->json(['Data' =>'', 'ErrorMessage' => '未查询到此商品', 'ErrorCode' => 2]);
}
if ($find_goods['is_delect'] == 2) {
return response()->json(['Data' =>'', 'ErrorMessage' => '此商品已停用', 'ErrorCode' => 2]);
}
$find_data = DB::table('ware_goods')
->where('wago_ware_id', $request['ware_id'])
->where('wago_goo_id', $value['goods_id'])
->first();
if (empty($find_data)) {
$add_data['wago_company_id'] = $request['company_id'];
$add_data['wago_ware_id'] = $request['ware_id'];
$add_data['wago_goo_id'] = $value['goods_id'];
$add_data['wago_stock_num'] = $value['goods_num'];
$add_res = DB::table('ware_goods')->insertGetId($add_data);
} else {
$update['wago_stock_num'] = $find_data['wago_stock_num'] + $value['goods_num'];
$add_res = DB::table('ware_goods')
->where('wago_id', $find_data['wago_id'])
->update($update);
$add_res = $find_data['wago_id'];
}
$add_record['goio_ware_id'] = $request['ware_id'];
$add_record['goio_wago_id'] = $add_res;
$add_record['goio_goo_id'] = $value['goods_id'];
$add_record['goio_num'] = $value['goods_num'];
$add_record['goio_type'] = '增加库存';
$add_record_res = DB::table('goods_inout')->insert($add_record);
}
$add_record['goio_ware_id'] = $request['ware_id'];
$add_record['goio_wago_id'] = $add_res;
$add_record['goio_goo_id'] = $request['goods_id'];
$add_record['goio_num'] = $request['goods_num'];
$add_record['goio_type'] = '增加库存';
$add_record_res = DB::table('goods_inout')->insert($add_record);
if ($add_res && $add_record_res) {
DB::commit();
return response()->json(['Data' =>'', 'ErrorMessage' => '成功', 'ErrorCode' => 1]);
......@@ -163,6 +182,11 @@ class WarehouseController extends BaseController
$paginate = DB::table('ware_goods')
->leftjoin('pj_goods','pg_id', '=', 'wago_goo_id')
->where('wago_ware_id', $request['ware_id'])
->where(function ($query) use ($request) {
if (!empty($request['goods_id'])) {
$query->where('wago_goo_id', $request['goods_id']);
}
})
->select('ware_goods.*', 'pj_goods.pg_goodsname', 'brand_name', 'pg_series')
->paginate($page_size);
$list = $paginate->items();
......@@ -207,8 +231,22 @@ class WarehouseController extends BaseController
->leftjoin('pj_goods as p', 'p.pg_id', '=', 'g.goio_goo_id')
->leftjoin('warehouse as w', 'g.goio_ware_id', '=', 'w.id')
->leftjoin('company as c','c.com_id', '=', 'w.company_id')
->where('com_id', $session['company_id'])
->select('shck_ckmc', 'pg_goodsname', 'goio_num', 'goio_type', 'goio_sys_num', 'goio_serial_number', 'goio_old_num', 'goio_new_num')
->where(function ($query) use ($request) {
if (!empty($request['company_id'])) {
$query->where('company_id', $request['company_id']);
}
})
->where(function ($query) use ($request) {
if (!empty($request['pg_goodsname'])) {
$query->where('pg_goodsname', 'like','%'.$request['pg_goodsname'].'%');
}
})
->where(function ($query) use ($request) {
if (!empty($request['goods_id'])) {
$query->where('goio_goo_id', $request['goods_id']);
}
})
->select('shck_ckmc', 'pg_goodsname', 'goio_num', 'goio_type', 'goio_sys_num', 'goio_serial_number', 'goio_old_num', 'goio_new_num', 'com_name')
->paginate($page_size);
$list = $paginate->items();
if($list){
......
......@@ -176,6 +176,13 @@ class AdminsController extends BaseController
$admins['ptid'] = $request->input('ptid');//默认平台
}
$find_data = DB::table('admin')
->where('company_id', $admins['company_id'])
->count();
if ($find_data >= 5) {
return $this->error('添加数量超出限制', ErrorInc::MYSQL_FAILED, []);
}
$post['phone'] = $request->input('phone');//电话
$post['qq'] = $request->input('qq');//QQ
DB::beginTransaction();
......
......@@ -160,7 +160,7 @@ class StatementsListService extends Model
DB::beginTransaction();
$session = $request['session'];
$find_data = DB::table('statements_list')
->where('id', $request['id'])
->where('stl_id', $request['id'])
->first();
if ($find_data['stl_type'] !=1){
......@@ -169,7 +169,7 @@ class StatementsListService extends Model
$info['stl_type'] = 2;//改为处理中
$res = DB::table('statements_list')
->where('id', $request['id'])
->where('stl_id', $request['id'])
->update($info);
if ($res){
DB::commit();
......
......@@ -76,7 +76,7 @@ class OrderDeductionFeeService extends Service
$add_dfee['reo_client_type'] = $find_company_info['com_type'];//公司类型
$update['adre_banlance'] = $find_balance['adre_banlance'] + $data['reo_price'];
if (($update['adre_banlance'] + $find_balance['adre_credit_limit']) <= 0) {
return ['code'=>500, 'msg'=>'余额不足,请充值'];
return ['code'=>501, 'msg'=>'余额不足,请充值'];
}
$add_res = DB::table('recharge_order')->insertGetId($add_dfee);
$update_res = DB::table('admin_recharge')
......
......@@ -127,7 +127,7 @@ class OrderListService extends Service
* @author du 2021年7月31日下午1:23:57
*/
public static function getOrderListByID($id){
$data = OrderList::where('id',$id)->select('id','create_time','install_id','locklist_type','sys_num','order_num','orli_type','serial_number','p_id','order_goods_id','ser_id','customer_id','stauas','pay_typel','feeds_time','category','goods_brand','manhourfee','send_sms','ol_dispamount','store_type','intall_person','intall_phone','company_id')->first();
$data = OrderList::where('id',$id)->select('id','create_time','install_id','locklist_type','sys_num','order_num','orli_type','serial_number','p_id','order_goods_id','ser_id','customer_id','stauas','pay_typel','feeds_time','category','goods_brand','manhourfee','send_sms','ol_dispamount','store_type','intall_person','intall_phone','company_id', 'agency_id')->first();
if($data){
$data = CommonService::dataToArray($data);
return $data;
......
......@@ -1285,9 +1285,9 @@ class OrderService extends Service
$post_data['order_number'] = $input['sys_num'];
$post_data['reo_price'] = -0.5;
$reduce_price = OrderDeductionFeeService::deductFee($post_data);
if ($reduce_price['code'] == 500) {
if ($reduce_price['code'] != 200) {
DB::rollback();
return ['Data' => '', 'ErrorMessage' =>$reduce_price['msg'], 'ErrorCode' => 2];
return ['Data' => '', 'ErrorMessage' =>$reduce_price['msg'], 'ErrorCode' =>$reduce_price['code']];
}
if ($returnOrder && $returnOrderList && $returnMan && $pt_res) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论