getFindField([ 'store_id' => $param['store_id'], 'outside_id' => $param['outside_id'] ], 'main_serial_number', true); return callBack(statusCode()['success'], '查询成功', $number_arr); } /** * 串号出售汇总 * @param $param * [ * merchant_id * store_id * goods_id * sku_id * serial_number 串号搜索 * page * limit * ] * @return mixed */ public function serialSummaryList($param) { $where = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'goods_id' => $param['goods_id'], 'type' => 1, 'num' => ['gt', 0] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } $page = $param['page'] ? $param['page'] : ''; $limit = $param['limit'] ? $param['limit'] : ''; if (!empty($param['page']) && !empty($param['limit'])) { $page = $page . ',' . $limit; } $SellSerialModel = new SellSerialModel(); $list = $SellSerialModel->getSelect($where, 'main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two', 'id desc', $page); $count = 0; if (!empty($list)) { $count = $SellSerialModel->getCount($where); foreach ($list as $key => &$val) { $val['index'] = $key + 1; } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ]); } /** * 盘点验证 * @param $param * [ * operator_type 1后台端 2收银端 3助手端 * user_type 3商户 4门店 * merchant_id * store_id * goods_id * sku_id * serial_list * ] * @return mixed */ public function inventorySerialVerify($param) { $VerifyClass = new VerifyParam(); $verifyResult = $VerifyClass->identityVerify($param); if ($verifyResult['status'] != 1) { return $verifyResult; } switch ($param['user_type']) { case 3: $WarehouseSerialModel = new WarehouseGoodsSerialModel(); break; case 4: case 6: $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); break; } $where = [ 'merchant_id' => $param['merchant_id'], 'goods_id' => ['neq', $param['goods_id']], 'num' => ['gt', 0] ]; if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } if (!empty($param['sku_id'])) { $where['sku_id'] = ['neq', $param['sku_id']]; } $serialList = $param['serial_list']; foreach ($serialList as $key => $val) { $arr = []; $arr[] = $val['main_serial_number']; if (!empty($val['auxiliary_serial_number_one'])) { $arr[] = $val['auxiliary_serial_number_one']; } if (!empty($val['auxiliary_serial_number_two'])) { $arr[] = $val['auxiliary_serial_number_two']; } $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['in', $arr]; $id = $WarehouseSerialModel->getFindField($where, 'id'); if (!empty($id)) { return callBack(statusCode()['error'], '该商品的第' . $key . '个串号其他商品已存在'); } } return callBack(statusCode()['success'], '验证成功'); } /** * 串号修改记录 * @param $param * [ * id 串号记录id * page * limit * ] * @return mixed */ public function serialModifyRecord($param) { if (empty($param['id'])) { return callBack(statusCode()['error'], '缺少唯一标识'); } $page = $param['page'] ? $param['page'] : ''; $limit = $param['limit'] ? $param['limit'] : ''; if (!empty($page) && !empty($limit)) { $page = $page . ',' . $limit; } $where['outside_id'] = $param['id']; $SerialRecordModel = new SerialRecordModel(); $list = $SerialRecordModel->getSelect($where, '*', 'id desc', $page); if (!empty($list)) { $count = $SerialRecordModel->getCount($where); $JurisdictionModel = new JurisdictionUserModel(); $CashierModel = new RetailCashierModel(); foreach ($list as &$val) { $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); switch ($val['operator_type']) { case 1: $val['operator_type'] = '后台'; break; case 2: $val['operator_type'] = '收银端'; break; case 3: $val['operator_type'] = '助手端'; break; } if ($val['user_type'] == 6) { //收银员 $val['operator_name'] = $CashierModel->getFindField([ 'id' => $val['operator_id'] ], 'name'); } else { $val['operator_name'] = $JurisdictionModel->getFindField([ 'id' => $val['operator_id'] ], 'name'); } } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } /** * 串号修改 * @param $param * [ * user_type 3 商户 4门店 6收银员 * operator_type 1后台 2收银端 3助手端 * merchant_id * store_id * cashier_id * operator_id 操作人id * id 串号记录id * warehouse_goods_id 仓库串号记录id * ] * @return mixed */ public function serialModify($param) { $VerifyClass = new VerifyParam(); $verifyResult = $VerifyClass->identityVerify($param); //验证参数 if ($verifyResult['status'] != 1) { return $verifyResult; } if (empty($param['id']) || empty($param['warehouse_goods_id'])) { return callBack(statusCode()['error'], '请选择'); } try { $SellSerialModel = new SellSerialModel(); $old_info = $SellSerialModel->getFind([ 'id' => $param['id'] ]); if (empty($old_info)) { return callBack(statusCode()['error'], '未找到该串号信息'); } $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); $new_info = $WarehouseSerialModel->getFind([ 'id' => $param['warehouse_goods_id'], 'num' => ['gt', 0] ]); if (empty($new_info)) { return callBack(statusCode()['error'], '仓库未找到该串号,请刷新'); } $time = $_SERVER['REQUEST_TIME']; M()->startTrans(); $updateResult = $SellSerialModel->updateOrder([ 'id' => $param['id'] ], [ 'main_serial_number' => $new_info['main_serial_number'], 'auxiliary_serial_number_one' => $new_info['auxiliary_serial_number_one'], 'auxiliary_serial_number_two' => $new_info['auxiliary_serial_number_two'] ]); if (empty($updateResult)) { M()->rollback(); return callBack(statusCode()['error'], '记录修改失败'); } $SerialRecordModel = new SerialRecordModel(); $add_id = $SerialRecordModel->addOrder([ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'outside_id' => $param['id'], 'goods_id' => $old_info['goods_id'], 'sku_id' => $old_info['sku_id'], 'old_main_serial_number' => $old_info['main_serial_number'], 'old_auxiliary_serial_number_one' => $old_info['auxiliary_serial_number_one'], 'old_auxiliary_serial_number_two' => $old_info['auxiliary_serial_number_two'], 'main_serial_number' => $new_info['main_serial_number'], 'auxiliary_serial_number_one' => $new_info['auxiliary_serial_number_one'], 'auxiliary_serial_number_two' => $new_info['auxiliary_serial_number_two'], 'add_time' => $time, 'operator_type' => $param['operator_type'], 'operator_id' => $param['operator_id'], 'user_type' => $param['user_type'] ]); if (empty($add_id)) { M()->rollback(); return callBack(statusCode()['error'], '修改记录添加失败'); } $where = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'goods_id' => $old_info['goods_id'], 'main_serial_number' => $old_info['main_serial_number'] ]; if (!empty($old_info['sku_id'])) { $where['sku_id'] = $old_info['sku_id']; } $updateResult = $WarehouseSerialModel->updateData($where, [ 'num' => 1 ]); if (empty($updateResult)) { M()->rollback(); return callBack(statusCode()['error'], '串号数量修改失败'); } $where['main_serial_number'] = $new_info['main_serial_number']; $updateResult = $WarehouseSerialModel->updateData($where, [ 'num' => 0 ]); if (empty($updateResult)) { M()->rollback(); return callBack(statusCode()['error'], '串号数量修改失败'); } $where['main_serial_number'] = $old_info['main_serial_number']; $where['type'] = ['not in', ['0', '1', '2', '3', '9', '10']]; $StockSerialModel = new SStockGoodsSerialModel(); $updateResult = $StockSerialModel->updateData($where, [ 'main_serial_number' => $new_info['main_serial_number'], 'auxiliary_serial_number_one' => $new_info['auxiliary_serial_number_one'], 'auxiliary_serial_number_two' => $new_info['auxiliary_serial_number_two'], ]); if (empty($updateResult)) { M()->rollback(); return callBack(statusCode()['error'], '出库记录修改失败'); } M()->commit(); return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } /** * 采购退货串号列表 * @param $param * [ * user_type 3商户 4门店 6收银员 * order_number 采购订单号 * serial_number 串号搜索 * goods_id * sku_id * ] * @return mixed */ public function purchaseRetreatSerial($param) { try { switch ($param['user_type']) { case 3: $RetreatModel = new RetreatGoodsModel(); $PurchaseSerialModel = new PurchaseGoodsSerialModel(); break; case 4: case 6: $RetreatModel = new SRetreatGoodsModel(); $PurchaseSerialModel = new SPurchaseGoodsSerialModel(); break; } $where = [ 'purchase_order_number' => $param['order_number'], 'goods_id' => $param['goods_id'] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } $id_arr = $RetreatModel->getFindField($where, 'id', true); if (!empty($id_arr)) { $map = [ 'outside_id' => ['in', $id_arr], 'type' => 2, 'status' => 1 ]; if (!empty($param['serial_number'])) { $map['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } $list = $PurchaseSerialModel->getSelect($map, $param['page'], $param['limit'], 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); if (!empty($param['page']) && !empty($param['limit'])) { $count = $PurchaseSerialModel->getCount($map); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } catch (\Exception $e) { return callBack(statusCode()['error'], '查询失败'); } } /** * 采购已入库串号列表 * @param $param * [ * user_type 3商户 4门店 6收银员 * order_number 采购订单号 * serial_number 串号搜索 * goods_id 商品id * sku_id 规格id * page * limit * ] * @return mixed */ public function purchaseWarehouseSerial($param) { try { switch ($param['user_type']) { case 3: $WarehouseGoodsModel = new WarehousingGoodsModel(); $WarehouseSerialModel = new WarehouseGoodsSerialModel(); break; case 4: case 6: $WarehouseGoodsModel = new SWarehousingGoodsModel(); $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); break; } $where = [ 'type' => ['in', ['1', '2']], 'purchase_order_number' => $param['order_number'], 'goods_id' => $param['goods_id'] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } $id_arr = $WarehouseGoodsModel->getFindField($where, 'id', true); if (!empty($id_arr)) { $map = [ 'outside_id' => ['in', $id_arr] ]; if (!empty($param['serial_number'])) { $map['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } $list = $WarehouseSerialModel->getSelect($map, $param['page'], $param['limit'], 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); if (!empty($param['page']) && !empty($param['limit'])) { $count = $WarehouseSerialModel->getCount($map); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } catch (\Exception $e) { return callBack(statusCode()['error'], '查询失败'); } } /** * 删除出售入库串号信息 * @param $param * [ * merchant_id * store_id * number_arr 主串号集合|外部id集合 * type 1出库 2入库 * param_type 默认1 主串号集合 2外部id集合 * ] * @return mixed */ public function sellSerialDelete($param) { $where = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'] ]; if (!empty($param['type'])) { $where['type'] = $param['type'] ? $param['type'] : 2; } if (!empty($param['param_type']) && $param['param_type'] == 2) { $where['outside_id'] = ['in', $param['number_arr']]; } else { $where['main_serial_number'] = ['in', $param['number_arr']]; } $SellSerialModel = new SellSerialModel(); $SellSerialModel->deleteOrder($where); return callBack(statusCode()['success'], '操作成功'); } /** * 出售串号信息 * @param $param * [ * id 出售记录id * serial_number 串号搜索 * files 查询的字段 * type 1出售 2可退 * page * limit * ] * @return mixed */ public function sellSerialList($param) { try { $where = [ 'outside_id' => $param['id'], ]; if ($param['type'] == 2) { $where['num'] = ['gt', 0]; } $page = $param['page'] ? $param['page'] : ''; $limit = $param['limit'] ? $param['limit'] : ''; if (!empty($page) && !empty($limit)) { $page = $page . ',' . $limit; } $files = $param['files'] ? $param['files'] : 'id,goods_id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two,edit_type'; if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } $SerialModel = new SellSerialModel(); $list = $SerialModel->getSelect($where, $files, 'id asc', $page); if (!empty($list)) { if (!empty($page)) { $count = $SerialModel->getCount($where); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } catch (\Exception $e) { return callBack(statusCode()['error'], '查询失败', [ 'list' => [], 'count' => 0 ]); } } /** * 出售串号库存修改 * @param $param * [ * id 出售记录id集合 * type 1出库 2入库 * num * option_type 1修改 2删除 * ] * @return mixed */ public function sellSerialNumOperation($param) { $where = [ 'outside_id' => ['in', $param['id']], ]; if (!empty($param['type'])) { $where['type'] = $param['type']; } $SerialModel = new SellSerialModel(); if ($param['option_type'] == 2) { $SerialModel->deleteOrder($where); } else { $SerialModel->updateOrder($where, [ 'num' => $param['num'] ? $param['num'] : 0 ]); } return callBack(statusCode()['success'], '操作成功'); } /** * 依据串号进行串号出库 * @param $param * [ * type 1增加 2减少 * store_id * goods_list 商品信息 * [ * serial_number_state 串号状态 0关闭 1开启 * serial_list 串号信息 * ] * ] * @return mixed */ public function basisNumberOperation($param) { try { $goodsList = $param['goods_list']; $serial_arr = []; foreach ($goodsList as $value) { //串号出库 if ($value['serial_number_state'] == 1) { foreach ($value['serial_list'] as $val) { $serial_arr[] = $val['main_serial_number']; } } } if (!empty($serial_arr)) { $SerialModel = new SWarehouseGoodsSerialModel(); $where = [ 'store_id' => $param['store_id'], 'main_serial_number' => ['in', $serial_arr], ]; switch ($param['type']) { case 1: $id_arr = []; foreach ($serial_arr as $val) { $id_arr[] = $SerialModel->basisOrderGetFindField([ 'store_id' => $param['store_id'], 'main_serial_number' => $val ], 'id', 'id desc'); } if (!empty($id_arr)) { $SerialModel->updateData([ 'id' => ['in', $id_arr] ], [ 'num' => 1 ]); } break; case 2: $SerialModel->updateData($where, [ 'num' => 0 ]); break; } } return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['success'], '操作失败'); } } /** * 收银串号添加 * @param $param * [ * merchant_id * store_id * goods_id * sku_id * outside_id * sell_list 商品信息 * ] * @return mixed */ public function cashierSerialAdd($param) { $serial_arr = []; $serial_list = $param['sell_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'add_time' => $_SERVER['REQUEST_TIME'], 'outside_id' => $param['outside_id'], 'type' => 1, 'num' => 1, ]; foreach ($serial_list as $val) { //串号信息处理 $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $serial_arr[] = $data; } if (!empty($serial_arr)) { try { $SellSerialModel = new SellSerialModel(); $id = $SellSerialModel->addAll($serial_arr); if (empty($id)) { return callBack(statusCode()['error'], '串号保存失败'); } return callBack(statusCode()['success'], '串号保存成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '串号保存失败'); } } else { return callBack(statusCode()['error'], '串号保存失败'); } } /** * 出售串号添加操作 * @param $param * [ * merchant_id * store_id * sell_list 商品信息 * type 1出库 2入库 * ] * @return mixed */ public function sellSerialAdd($param) { $serial_arr = []; $update_arr = []; $sell_list = $param['sell_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'add_time' => $_SERVER['REQUEST_TIME'], 'type' => $param['type'] ? $param['type'] : 1, 'num' => 1, 'edit_type' => $param['type'] == 2 ? 2 : 1 ]; foreach ($sell_list as $val) { //串号信息处理 if ($val['serial_number_state'] == 1) { $data['outside_id'] = $val['id']; $data['goods_id'] = $val['goods_id']; $data['sku_id'] = $val['sku_id'] ? $val['sku_id'] : 0; $serial_list = $val['serial_list']; foreach ($serial_list as $v) { $data['main_serial_number'] = $v['main_serial_number']; $data['auxiliary_serial_number_one'] = $v['auxiliary_serial_number_one'] ? $v['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $v['auxiliary_serial_number_two'] ? $v['auxiliary_serial_number_two'] : ''; $serial_arr[] = $data; if (!empty($v['id']) && $param['type'] == 2) { $update_arr[] = $v['id']; } } } } if (!empty($serial_arr)) { try { M()->startTrans(); $SellSerialModel = new SellSerialModel(); $id = $SellSerialModel->addAll($serial_arr); if (empty($id)) { M()->rollback(); return callBack(statusCode()['error'], '串号保存失败'); } if (!empty($update_arr)) { $SellSerialModel->updateOrder([ 'id' => ['in', $update_arr] ], [ 'num' => 0, 'edit_type' => 2 ]); } M()->commit(); return callBack(statusCode()['success'], '商品信息确认成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '串号保存失败'); } } else { return callBack(statusCode()['success'], '商品信息确认成功'); } } /** * 依据串号查询商品信息 * @param $param * [ * user_type 3商户 4门店 * serial_number 串号 * store_id * merchant_id * type 1返一条 其他返多条 * ] * @return mixed */ public function basisSerialGetGoods($param) { if (empty($param['serial_number'])) { return callBack(statusCode()['error'], '请输入串号'); } $where = [ 'merchant_id' => $param['merchant_id'], 'num' => ['gt', 0], 'main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two' => trim($param['serial_number']) ]; if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } try { switch ($param['user_type']) { case 3: $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: $SerialModel = new SWarehouseGoodsSerialModel(); break; } if ($param['type'] == 1) { $list = $SerialModel->basisOrderFind($where, 'goods_id,sku_id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); } else { $list = $SerialModel->getSelect($where, 'goods_id,sku_id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); } if (!empty($list)) { return callBack(statusCode()['success'], '查询成功', $list); } else { return callBack(statusCode()['error'], '仓库未找到该串号'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '仓库未找到该串号'); } } /** * 查询门店仓库中某串号信息 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * goods_id * sku_id * serial_number 串号搜索 * ] * @return mixed */ public function searchWarehouseSerial($param) { if (empty($param['goods_id']) || empty($param['serial_number'])) { return callBack(statusCode()['error'], '请输入串号'); } $where = [ 'merchant_id' => $param['merchant_id'], 'goods_id' => $param['goods_id'], 'num' => ['gt', 0], 'main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two' => trim($param['serial_number']) ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } try { switch ($param['user_type']) { case 3: $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: $SerialModel = new SWarehouseGoodsSerialModel(); break; } $info = $SerialModel->basisOrderFind($where, 'id as warehouse_goods_id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); if (!empty($info)) { return callBack(statusCode()['success'], '查询成功', $info); } else { return callBack(statusCode()['error'], '仓库未找到该串号'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '仓库未找到该串号'); } } /** * 串号位置 * @param $param * [ * serial_number 串号 * merchant_id * ] * @return mixed */ public function serialPosition($param) { if (empty($param['serial_number'])) { return callBack(statusCode()['error'], '请输入串号'); } $where = [ 'merchant_id' => $param['merchant_id'], ]; $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = trim($param['serial_number'], ' '); try { $StoreClass = new Store(); $ImageClass = new Image(); $GoodsModel = new RetailMgoodsModel(); $SkuGoodsModel = new SkuMGoodsModel(); $StoreGoodsModel = new RetailGoodsModel(); $StoreSkuGoodsModel = new RetailSkuGoodsModel(); $data = []; //数据 //商户采购仓 $PurchaseGoodsSerialModel = new PurchaseGoodsSerialModel(); $info = $PurchaseGoodsSerialModel->getFind($where); if (!empty($info)) { //零售价 if (!empty($info['sku_id'])) { $retail_price = $SkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $GoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } $PurchaseGoodsModel = new PurchaseGoodsModel(); $goods = $PurchaseGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'warehouse_id,goods_name,sku_name,order_number,goods_id,sku_id,purchase_price,add_time'); if (!empty($goods)) { $PurchaseWarehouseModel = new PurchaseWarehouseModel(); $warehouse_name = $PurchaseWarehouseModel->getFindField([ 'id' => $goods['warehouse_id'] ], 'name'); $data['name'] = '商户'; $data['position'] = '采购仓' . $warehouse_name; $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['purchase_price'], 2); //进价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 3, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['order_number'], 'position' => '商户的' . $warehouse_name . '采购仓采购入库-' ]; } } //商户供给仓 $WarehouseGoodsSerialModel = new WarehouseGoodsSerialModel(); $info = $WarehouseGoodsSerialModel->getFind($where); if (!empty($info)) { if (empty($data['retail_price'])) { //零售价 if (!empty($info['sku_id'])) { $retail_price = $SkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $GoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } } $WarehouseGoodsModel = new WarehousingGoodsModel(); $goods = $WarehouseGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'goods_name,sku_name,goods_id,sku_id,warehouse_price,add_time,warehouse_order_number'); if (!empty($goods)) { if (empty($data['goods_name']) || empty($data['purchase_price'])) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['warehouse_price'], 2); //进价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 3, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; } $data['name'] = '商户'; $data['position'] = '供给仓'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['warehouse_order_number'], 'position' => '商户供给仓入库-' ]; } } //商户出库 $where['type'] = ['in', ['1', '3']]; $StockGoodsSerialModel = new StockGoodsSerialModel(); $info = $StockGoodsSerialModel->getFind($where); if (!empty($info)) { $StockGoodsModel = new StockOutGoodsModel(); $goods = $StockGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'goods_name,sku_name,type,stock_out_id,stock_order_number,goods_id,sku_id,cost_price,add_time,stock_order_number'); if (!empty($goods)) { $StockOrderModel = new StockOutOrderModel(); $stock_info = $StockOrderModel->basisOrderFind([ 'id' => $goods['stock_out_id'] ], 'warehousing_status,store_id'); //零售价 if (empty($data['retail_price'])) { if (!empty($info['sku_id'])) { $retail_price = $SkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $GoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } } if (empty($data['goods_name']) || empty($data['purchase_price'])) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['cost_price'], 2); //成本价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 3, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; } if ($goods['type'] == 1) { $name = '商户调拨出库至' . $StoreClass->getStoreName($stock_info['store_id']); } else { $name = $StoreClass->getStoreName($stock_info['store_id']) . '申请调拨出库'; } $data['name'] = '商户'; $data['position'] = $name; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['stock_order_number'], 'position' => $name ]; } } unset($where['type']); //商户报损 $LossSerialModel = new LossReportSerialModel(); $info = $LossSerialModel->getFind($where); if (!empty($info)) { $LossGoodsModel = new LossReportGoodsModel(); $loss_order_number = $LossGoodsModel->getFindField([ 'id' => $info['outside_id'] ], 'loss_order_number'); $data['name'] = '商户'; $data['position'] = '供给仓报损'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $info['add_time']), 'order_number' => $loss_order_number, 'position' => '供给仓报损' ]; } //门店供给仓 $SWarehouseGoodsSerialModel = new SWarehouseGoodsSerialModel(); $info = $SWarehouseGoodsSerialModel->getFind($where); if (!empty($info)) { //零售价 if (!empty($info['sku_id'])) { $retail_price = $StoreSkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $StoreGoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } if (!empty($info['outside_id'])) { $map = [ 'id' => $info['outside_id'] ]; } else { $map = [ 'goods_id' => $info['goods_id'], 'sku_id' => $info['sku_id'] ]; } $SWarehouseGoodsModel = new SWarehousingGoodsModel(); $goods = $SWarehouseGoodsModel->basisOrderFind($map, 'goods_name,sku_name,goods_id,sku_id,warehouse_price,add_time,warehouse_order_number'); if (!empty($goods)) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['warehouse_price'], 2); //成本价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 4, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; $name = $StoreClass->getStoreName($info['store_id']); $data['name'] = $name; $data['position'] = '供给仓'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['warehouse_order_number'], 'position' => $name . '供给仓入库' ]; } } //门店采购仓 $SPurchaseGoodsSerialModel = new SPurchaseGoodsSerialModel(); $info = $SPurchaseGoodsSerialModel->getFind($where); if (!empty($info)) { //零售价 if (empty($data['retail_price'])) { if (!empty($info['sku_id'])) { $retail_price = $StoreSkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $StoreGoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } } $SPurchaseGoodsModel = new SPurchaseGoodsModel(); $goods = $SPurchaseGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'warehouse_id,goods_name,sku_name,order_number,goods_id,sku_id,purchase_price,add_time'); $SPurchaseWarehouseModel = new SPurchaseWarehouseModel(); $warehouse_name = $SPurchaseWarehouseModel->getFindField([ 'id' => $goods['warehouse_id'] ], 'name'); if (!empty($goods)) { if (empty($data['purchase_price']) || empty($data['retail_price'])) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['purchase_price'], 2); //采购价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 4, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; } $name = $StoreClass->getStoreName($info['store_id']); $data['name'] = $name; $data['position'] = '采购仓' . $warehouse_name; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['order_number'], 'position' => $name . $warehouse_name . '的采购仓采购入库-' ]; } } //门店出库 $SStockGoodsSerialModel = new SStockGoodsSerialModel(); $info = $SStockGoodsSerialModel->getFind($where); if (!empty($info) && in_array($info['type'], [1, 3])) { $SStockGoodsModel = new SStockOutGoodsModel(); $goods = $SStockGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'goods_name,sku_name,type,stock_out_id,stock_order_number,goods_id,sku_id,cost_price,add_time'); if (!empty($goods)) { //零售价 if (empty($data['retail_price'])) { if (!empty($info['sku_id'])) { $retail_price = $StoreSkuGoodsModel->getFindField([ 'id' => $info['sku_id'] ], 'retail_price'); } else { $retail_price = $StoreGoodsModel->getFindField([ 'id' => $info['goods_id'] ], 'retail_price'); } } $SStockOrderModel = new SStockOutOrderModel(); $stock_info = $SStockOrderModel->basisOrderFind([ 'id' => $goods['stock_out_id'] ], 'warehousing_status,store_id,transfer_to_store_id,merchant_id'); if (!empty($stock_info) && $stock_info['warehousing_status'] != 1) { if (empty($data['retail_price']) || empty($data['purchase_price'])) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['cost_price'], 2); //成本价 $data['retail_price'] = round($retail_price, 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 4, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; } if ($goods['type'] == 1) { $name = $StoreClass->getStoreName($info['store_id']) . '退货至商户'; } else { $name = $StoreClass->getStoreName($info['store_id']) . '调拨出库至' . $StoreClass->getStoreName($stock_info['transfer_to_store_id']); } $data['name'] = $name; $data['position'] = '出库单'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $goods['add_time']), 'order_number' => $goods['stock_order_number'], 'position' => $name ]; } } } //门店出售 $SellSerialModel = new SellSerialModel(); $info = $SellSerialModel->getOrderFind($where, '*', 'id desc'); if (!empty($info)) { $SellModel = new RetailSellModel(); $sell_info = $SellModel->sellOrderInfo('s.original_price,s.goods_id,s.sku_id,s.add_time,b.order_no,b.store_id', [ 's.id' => $info['outside_id'] ]); if (!empty($sell_info)) { $map = [ 'goods_id' => $sell_info['goods_id'] ]; if (!empty($sell_info['sku_id'])) { $map['sku_id'] = $sell_info['sku_id']; } $SaleGoodsModel = new SSaleMGoodsModel(); $goods = $SaleGoodsModel->getFind($map, 'goods_name,sku_name,cost_price'); if (!empty($goods)) { if (empty($data['purchase_price']) || empty($data['retail_price'])) { $data['goods_name'] = $goods['goods_name']; $data['sku_name'] = $goods['sku_name']; $data['purchase_price'] = round($goods['cost_price'], 2); //成本价 $data['retail_price'] = round($sell_info['original_price'], 2); $data['image_path'] = $ImageClass->basisGoodsIdGetImg([ 'user_type' => 4, 'goods_id' => $goods['goods_id'], 'sku_id' => $goods['sku_id'] ]); $data['main_serial_number'] = $info['main_serial_number']; $data['auxiliary_serial_number_one'] = $info['auxiliary_serial_number_one']; $data['auxiliary_serial_number_two'] = $info['auxiliary_serial_number_two']; } $name = $StoreClass->getStoreName($sell_info['store_id']); $data['name'] = $name; $data['position'] = '已出售'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $sell_info['add_time']), 'order_number' => $sell_info['order_no'], 'position' => $name . '已售' ]; } } } //门店报损 $LossSerialModel = new SLossReportSerialModel(); $info = $LossSerialModel->getFind($where); if (!empty($info)) { $LossGoodsModel = new SLossReportGoodsModel(); $loss_info = $LossGoodsModel->basisOrderFind([ 'id' => $info['outside_id'] ], 'loss_order_number,store_id'); $name = $StoreClass->getStoreName($loss_info['store_id']); $data['name'] = $name; $data['position'] = '供给仓报损'; $data['popular'][] = [ 'add_time' => date('Y-m-d H:i:s', $info['add_time']), 'order_number' => $loss_info['loss_order_number'], 'position' => $name . '供给仓报损' ]; } if (!empty($data)) { $popular = $data['popular'];//路径 array_multisort(array_column($popular, 'add_time'), SORT_ASC, $popular); $data['popular'] = $popular; return callBack(statusCode()['success'], '查询成功', $data); } else { return callBack(statusCode()['error'], '未找到该串号'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '未找到该串号'); } } /** * 盘点删除串号记录 * @param $param * [ * user_type 3商户 4门店 6收银员 * id 记录id * goods_id * sku_id * ] * @return mixed */ public function inventorySerialDelete($param) { switch ($param['user_type']) { case 3: $InventorySerialModel = new InventoryGoodsSerialModel(); break; case 4: case 6: $InventorySerialModel = new SInventoryGoodsSerialModel(); break; } $where = [ 'outside_id' => $param['id'], 'goods_id' => $param['goods_id'] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } $InventorySerialModel->deleteData($where); return callBack(statusCode()['success'], '操作成功'); } /** * 盘点串号筛选 * @param $param * [ * user_type 3商户 4门店 6收银员 * merchant_id * store_id * goods_id * sku_id * serial_list * type 1盘盈 2盘亏 3无盈亏 * num 数量 * add_time * ] * @return mixed */ public function inventoryScreen($param) { $serialList = $param['serial_list']; $num = $param['num']; $type = $param['type']; $serial_arr = []; //出入库的串号信息 $surplus_arr = []; //多余的不同串号 $serial_list_arr = []; //修改入库记录的数量 try { switch ($param['user_type']) { case 3: $WarehouseSerialModel = new WarehouseGoodsSerialModel(); break; case 4: case 6: $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); break; } $where = [ 'goods_id' => $param['goods_id'], 'num' => ['gt', 0] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } $list = $WarehouseSerialModel->getSelect($where, '', '', 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); switch ($type) { case 1: case 3: if (!empty($serialList)) { if (!empty($list)) { $warehouse_main_serial_number_arr = array_columns($list, 'main_serial_number'); } else { $warehouse_main_serial_number_arr = []; } foreach ($serialList as $val) { if (!in_array($val['main_serial_number'], $warehouse_main_serial_number_arr, true)) { //入库 if (count($serial_arr) < $num) { $serial_arr[] = $val; } else { $surplus_arr[] = $val; } } } //不存在的串号修改 if (!empty($list)) { $stock_main_serial_number_arr = array_columns($serialList, 'main_serial_number'); foreach ($list as $key => $val) { if (!in_array($val['main_serial_number'], $stock_main_serial_number_arr, true)) { array_push($serial_list_arr, $val['id']); } } } } else { if ($type == 3) { $WarehouseSerialModel->updateData($where, [ 'num' => 0 ]); } } break; case 2: if (!empty($serialList)) { $stock_main_serial_number_arr = array_columns($serialList, 'main_serial_number'); } else { $stock_main_serial_number_arr = []; } if (!empty($list)) { foreach ($list as $val) { if (!in_array($val['main_serial_number'], $stock_main_serial_number_arr, true)) { //出库 if (count($serial_arr) < $num) { $serial_arr[] = $val; } else { array_push($serial_list_arr, $val['id']); } } } } if (!empty($serialList)) { $warehouse_main_serial_number_arr = array_columns($list, 'main_serial_number'); foreach ($serialList as $val) { if (!in_array($val['main_serial_number'], $warehouse_main_serial_number_arr, true)) { $surplus_arr[] = $val; } } } break; } //修改入库的串号数量 if (!empty($serial_list_arr)) { $WarehouseSerialModel->updateData([ 'id' => ['in', $serial_list_arr] ], [ 'num' => 0 ]); } //新的入库信息. if (!empty($surplus_arr)) { $serialResult = $this->warehouseSerial([ 'user_type' => $param['user_type'], 'merchant_id' => $param['merchant_id'], 'store_id' => in_array($param['user_type'], ['4', '6']) ? $param['store_id'] : 0, 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'type' => 3, 'add_time' => $param['add_time'], 'serial_list' => $surplus_arr ]); if ($serialResult['status'] != 1) { return $serialResult; } } return callBack(statusCode()['success'], '操作成功', [ 'serial_arr' => $serial_arr ]); } catch (\Exception $e) { return callBack(statusCode()['error'], '串号操作失败'); } } /** * 盘点的串号记录添加 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id * goods_id * sku_id * add_time * serial_list 串号列表 * ] * @return mixed */ public function inventorySerial($param) { $serial_list = $param['serial_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'add_time' => $param['add_time'], 'num' => 1 ]; if ($param['user_type'] == 4 || $param['user_type'] == 6) { $data['store_id'] = $param['store_id']; } if (!empty($serial_list)) { $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { if (!empty($content)) { switch ($param['user_type']) { case 3: $InventorySerialModel = new InventoryGoodsSerialModel(); break; case 4: case 6: $InventorySerialModel = new SInventoryGoodsSerialModel(); break; } $id = $InventorySerialModel->addAll($content); if (!empty($id)) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 拒收的商品串号列表 * @param $param * [ * id 记录id * serial_number * page * limit * ] * @return mixed */ public function refuseSerialList($param) { $where = [ 'outside_id' => $param['id'], ]; if (!empty($parma['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . ' % ']; } $param['page'] = $param['page'] ? $param['page'] : ''; $param['limit'] = $param['limit'] ? $param['limit'] : ''; $RefuseSerialModel = new RefuseWarehousingSerialModel(); $list = $RefuseSerialModel->getSelect($where, $param['page'], $param['limit'], ' * '); if (!empty($list)) { $count = $RefuseSerialModel->getCount($where); foreach ($list as &$val) { $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } /** * 门店拒收的串号信息操作 * @param $param * [ * merchant_id * store_id * outside_id * goods_id * sku_id * type 拒收类型 1拒收商户调拨 2拒收申请商户调拨 3拒收门店调拨 * add_time * serial_list 串号信息 * ] * @return mixed */ public function refuseSerial($param) { $serial_list = $param['serial_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'type' => $param['type'], 'add_time' => $param['add_time'], 'num' => 1 ]; if (!empty($serial_list)) { $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { $SerialModel = new RefuseWarehousingSerialModel(); $id = $SerialModel->addAll($content); if (!empty($id)) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '操作失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 门店依据外部id删除串号出库记录 * @param $param * [ * outside_id 外部id * merchant_id * store_id * type * ] * @return mixed */ public function basisOutIdStockSerialDelete($param) { $SerialModel = new SStockGoodsSerialModel(); $where = [ 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'], 'outside_id' => is_array($param['outside_id']) ? ['in', $param['outside_id']] : $param['outside_id'], ]; if (!empty($param['type'])) { $where['type'] = is_array($param['type']) ? ['in', $param['type']] : $param['type']; } else { $where['type'] = ['in', ['4', '5', '8', '11']]; } $SerialModel->deleteData($where); return callBack(statusCode()['success'], '删除成功'); } /** * 出库串号删除操作 * @param $param * [ * user_type 3商户 4门店 * outside_id 外部id * merchant_id * store_id * goods_id * sku_id * type * ] * @return array */ public function stockSerialDelete($param) { switch ($param['user_type']) { case 3: $SerialModel = new StockGoodsSerialModel(); break; case 4: $SerialModel = new SStockGoodsSerialModel(); break; } $where = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'type' => $param['type'], ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } $SerialModel->deleteData($where); return callBack(statusCode()['success'], '删除成功'); } /** * 出库串号添加操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id 外部id * type 出库类型 * goods_id * sku_id * add_time * serial_list 串号信息 * ] * @return mixed */ public function stockSerial($param) { $serial_list = $param['serial_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'type' => $param['type'], 'add_time' => is_numeric($param['add_time']) ? $param['add_time'] : $_SERVER['REQUEST_TIME'], 'num' => 1 ]; if ($param['user_type'] == 4) { $data['store_id'] = $param['store_id']; } if (!empty($serial_list)) { $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { if (!empty($content)) { switch ($param['user_type']) { case 3: $SerialModel = new StockGoodsSerialModel(); break; case 4: $SerialModel = new SStockGoodsSerialModel(); break; } $id = $SerialModel->addAll($content); if (!empty($id)) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '操作失败'); } } return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 拒收调拨时出库方商品串号数量增加操作 * @param $param * [ * user_type 3商户 4门店 * main_serial_number_arr 主串号集合 * ] * @return mixed */ public function recoverySerialInc($param) { if (!empty($param['main_serial_number_arr'])) { switch ($param['user_type']) { case 3: $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: $SerialModel = new SWarehouseGoodsSerialModel(); break; } try { $SerialModel->updateData([ 'main_serial_number' => ['in', $param['main_serial_number_arr']] ], [ 'num' => 1 ]); return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '缺失串号信息'); } } /** * 入库记录串号数量减少操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * serial_id_arr 串号id或串号列表集合 * type 1id 集合 2串号集合 * ] * @return mixed */ public function warehouseSerialDec($param) { if (!empty($param['serial_id_arr']) && !empty($param['type'])) { switch ($param['user_type']) { case 3: $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: $SerialModel = new SWarehouseGoodsSerialModel(); break; } try { $where = [ 'num' => ['gt', 0], 'merchant_id' => $param['merchant_id'], 'store_id' => $param['store_id'] ]; switch ($param['type']) { case 1: $where['id'] = ['in', $param['serial_id_arr']]; $SerialModel->updateData($where, [ 'num' => 0 ]); break; case 2: $where['main_serial_number'] = ['in', $param['serial_id_arr']]; $serial_id_arr = $param['serial_id_arr']; foreach ($serial_id_arr as $val) { $where['main_serial_number'] = $val['main_serial_number']; $where['goods_id'] = $val['goods_id']; $SerialModel->updateData($where, [ 'num' => 0 ]); } break; } return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '缺失串号信息'); } } /** * 入库串号操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id 明细id * goods_id * sku_id * type * add_time 添加时间 * serial_list 串号信息 * ] * @return mixed */ public function warehouseSerial($param) { $serial_list = $param['serial_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'type' => $param['type'], 'add_time' => $param['add_time'], 'num' => 1, ]; if ($param['user_type'] == 4 || $param['user_type'] == 6) { $data['store_id'] = $param['store_id']; } if (!empty($serial_list)) { $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { switch ($param['user_type']) { case 3: $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: case 6: $SerialModel = new SWarehouseGoodsSerialModel(); break; } $id = $SerialModel->addAll($content); if (!empty($id)) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '操作失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 采购入库的采购串号信息操作 * @param $param * [ * user_type 3商户 4门店 * serial_list 串号信息 * ] * @return mixed */ public function warehousePurchaseSerial($param) { $serial_list = $param['serial_list']; if (!empty($serial_list)) { try { switch ($param['user_type']) { case 3: $SerialModel = new PurchaseGoodsSerialModel(); break; case 4: $SerialModel = new SPurchaseGoodsSerialModel(); break; } foreach ($serial_list as $val) { $SerialModel->updateData([ 'id' => $val['id'] ], [ 'num' => 0 ]); } return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 入库记录可操作的串号信息 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * goods_id * sku_id * serial_number 串号 * exists_id_arr 已经选择的串号主键id集合 * page * limit * ] * @return mixed */ public function warehouseSerialList($param) { $where = [ 'merchant_id' => $param['merchant_id'], 'goods_id' => $param['goods_id'], 'num' => ['gt', 0] ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } if (!empty($param['exists_id_arr'])) { $where['id'] = ['not in', $param['exists_id_arr']]; } if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } try { switch ($param['user_type']) { case 3: //商户 $SerialModel = new WarehouseGoodsSerialModel(); break; case 4: //门店 $SerialModel = new SWarehouseGoodsSerialModel(); break; } $list = $SerialModel->getSelect($where, $param['page'], $param['limit'], 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two,add_time'); if (!empty($list)) { $count = $SerialModel->getCount($where); foreach ($list as &$val) { $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', [ 'list' => [], 'count' => 0 ]); } } /** * 报损记录关联的串号操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id * goods_id * sku_id * add_time * serial_list * ] * @return mixed */ public function lossSerial($param) { $serial_list = $param['serial_list']; $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'], 'type' => 1, 'add_time' => $param['add_time'], 'num' => 1 ]; if ($param['user_type'] == 4) { $data['store_id'] = $param['store_id']; } if (!empty($serial_list)) { $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { switch ($param['user_type']) { case 3: $SerialModel = new LossReportSerialModel(); break; case 4: $SerialModel = new SLossReportSerialModel(); break; } $id = $SerialModel->addAll($content); if (!empty($id)) { return callBack(statusCode()['success'], '操作成功'); } else { return callBack(statusCode()['error'], '操作失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } else { return callBack(statusCode()['error'], '操作失败'); } } /** * 记录详情的串号列表 * @param $param * [ * user_type 3商户 4门店 * id 记录id * serial_number 串号搜所 * fields * page * limit * serial_type 1报损 2入库 3出库 4盘点 * type入库类型 入库类型 0其他入库 1采购入库 2补货入库 3盘盈入库 4商户调拨入库 5其他门店调拨入库 6该门店申请调拨入库 7初始化商品档案入库 8拼团退货入库 9秒杀退货入库 10拆分入库 11收银退货入库 12商城退货入库 13组合入库 14拼团换货入库 *15秒杀换货入库 16商城普通换货入库 17预售退货入库 18预售换货入库 19收银赠品退货入库 20 商城赠品退货入库 21门店调拨拒收入库 * ] * @return mixed */ public function recordSerialList($param) { switch ($param['user_type']) { case 3: switch ($param['serial_type']) { case 1: $RecordModel = new LossReportSerialModel(); break; case 2: $RecordModel = new WarehouseGoodsSerialModel(); break; case 3: $RecordModel = new StockGoodsSerialModel(); break; case 4: $RecordModel = new InventoryGoodsSerialModel(); break; } break; case 4: switch ($param['serial_type']) { case 1: $RecordModel = new SLossReportSerialModel(); break; case 2: $RecordModel = new SWarehouseGoodsSerialModel(); break; case 3: $RecordModel = new SStockGoodsSerialModel(); break; case 4: $RecordModel = new SInventoryGoodsSerialModel(); break; } break; } $where['outside_id'] = is_array($param['id']) ? ['in', $param['id']] : $param['id']; if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } if (!empty($param['type'])) { $where['type'] = is_array($param['type']) ? ['in', $param['type']] : $param['type']; } $param['page'] = $param['page'] ? $param['page'] : ''; $param['limit'] = $param['limit'] ? $param['limit'] : ''; $fields = $param['fields'] ? $param['fields'] : '*'; $list = $RecordModel->getSelect($where, $param['page'], $param['limit'], $fields); if (!empty($list)) { if (!empty($param['page']) && !empty($param['limit'])) { $count = $RecordModel->getCount($where); } if (empty($param['fields'])) { foreach ($list as &$val) { $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); } } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } /** * 采购编辑串号操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * goods_id * sku_id * add_time * outside_id 外部id * serial_list 串号信息 * ] * @return mixed */ public function purchaseSerialUpdate($param) { $serial_list = $param['serial_list']; try { switch ($param['user_type']) { case 3: //商户 $SerialModel = new PurchaseGoodsSerialModel(); $WarehouseSerialModel = new WarehouseGoodsSerialModel(); break; case 4: //门店 $SerialModel = new SPurchaseGoodsSerialModel(); $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); break; } $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'] ? $param['sku_id'] : 0, 'type' => 1, 'add_time' => $param['add_time'], 'num' => 1, 'status' => 1 ]; if (!empty($serial_list)) { $content = []; $serial_id_arr = []; //id集合 $map = [ 'type' => ['in', '1,2'], 'num' => 1, 'merchant_id' => $param['merchant_id'], ]; if ($param['user_type'] == 4) { $data['store_id'] = $param['store_id']; $map['store_id'] = $param['store_id']; } foreach ($serial_list as $val) { if (!empty($val['id'])) { $old_info = $SerialModel->basisOrderFind([ 'id' => $val['id'] ], 'main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); $map['main_serial_number'] = $old_info['main_serial_number']; $WarehouseSerialModel->updateData($map, [ 'main_serial_number' => $val['main_serial_number'], 'auxiliary_serial_number_one' => $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : '', 'auxiliary_serial_number_two' => $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : '' ]); $SerialModel->updateData([ 'id' => $val['id'] ], [ 'main_serial_number' => $val['main_serial_number'], 'auxiliary_serial_number_one' => $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : '', 'auxiliary_serial_number_two' => $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : '' ]); $serial_id_arr[] = $val['id']; } else { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } } if (!empty($serial_id_arr)) { $SerialModel->updateData(['outside_id' => $param['outside_id'], 'id' => ['not in', $serial_id_arr]], [ 'status' => 2 ]); } else { $SerialModel->updateData(['outside_id' => $param['outside_id']], [ 'status' => 2 ]); } if (!empty($content)) { $SerialModel->addAll($content); } return callBack(statusCode()['success'], '串号操作成功'); } else { return callBack(statusCode()['error'], '串号操作失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '串号操作失败'); } } /** * 采购退货串号操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id 退货明细id * goods_id * sku_id * add_time 添加时间 * serial_list 串号信息 * ] * @return mixed */ public function retreatSerial($param) { $param['type'] = 2; //采购退货 $result = $this->purchaseSerial($param); if ($result['status'] != 1) { return $result; } $serial_list = $param['serial_list']; try { switch ($param['user_type']) { case 3: $SerialMode = new PurchaseGoodsSerialModel(); break; case 4: $SerialMode = new SPurchaseGoodsSerialModel(); break; } foreach ($serial_list as $val) { $SerialMode->updateSetDec([ 'id' => $val['id'] ], 'num', 1); } return callBack(statusCode()['success'], '操作成功'); } catch (\Exception $e) { return callBack(statusCode()['error'], '操作失败'); } } /** * 采购管理串码信息操作 * @param $param * [ * user_type 3商户 4门店 * merchant_id * store_id * outside_id 外部id * goods_id * sku_id * type 1采购 2采购退货 * add_time 添加时间 * serial_list 串码信息 * ] * @return mixed */ public function purchaseSerial($param) { $serial_list = $param['serial_list']; if (!empty($serial_list)) { $data = [ 'merchant_id' => $param['merchant_id'], 'outside_id' => $param['outside_id'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'], 'type' => $param['type'], 'add_time' => $param['add_time'], 'num' => 1, 'status' => 1 ]; if ($param['user_type'] == 4) { $data['store_id'] = $param['store_id']; } $content = []; foreach ($serial_list as $val) { $data['main_serial_number'] = $val['main_serial_number']; $data['auxiliary_serial_number_one'] = $val['auxiliary_serial_number_one'] ? $val['auxiliary_serial_number_one'] : ''; $data['auxiliary_serial_number_two'] = $val['auxiliary_serial_number_two'] ? $val['auxiliary_serial_number_two'] : ''; $content[] = $data; } try { switch ($param['user_type']) { case 3: $SerialModel = new PurchaseGoodsSerialModel(); break; case 4: $SerialModel = new SPurchaseGoodsSerialModel(); break; } $result = $SerialModel->addAll($content); if (!empty($result)) { return callBack(statusCode()['success'], '串码信息保存成功'); } else { return callBack(statusCode()['error'], '串码信息保存失败'); } } catch (\Exception $e) { return callBack(statusCode()['error'], '串码信息保存失败'); } } else { return callBack(statusCode()['error'], '串码信息保存失败'); } } /** * 采购退货可退商品的串码信息 * @param $param * [ * operator_type 1后台 2收银 3助手 * user_type 3商户 4门店 * id 采购明细id * exists_id_arr 已经选中的id * serial_number 串号 * page * limit * ] * @return mixed */ public function returnableSerialList($param) { switch ($param['user_type']) { case 3: $SerialModel = new PurchaseGoodsSerialModel(); break; case 4: $SerialModel = new SPurchaseGoodsSerialModel(); break; } $where = [ 'outside_id' => $param['id'], 'type' => 1, 'num' => ['gt', 0], 'status' => 1 ]; if (!empty($param['serial_number']) && $param['operator_type'] == 3) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = $param['serial_number']; } else if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } if (!empty($param['exists_id_arr'])) { $where['id'] = ['not in', $param['exists_id_arr']]; } try { if (!empty($param['page']) && !empty($param['limit'])) { $list = $SerialModel->getSelect($where, $param['page'], $param['limit'], 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); if (!empty($list)) { $count = $SerialModel->getCount($where); } } else { $list = $SerialModel->getSelect($where, '', '', 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); } return callBack(statusCode()['success'], '查询成功', [ 'count' => $count ? $count : 0, 'list' => $list ? $list : [] ]); } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', [ 'count' => 0, 'list' => [] ]); } } /** * 采购明细与退货明细的串号信息 * @param $param * [ * operator_type 1后台 2收银端 3助手端 * user_type 3商户 4门店 * id 明细id * type 1采购 2退货 * serial_number 串号 * num * page * limit * ] * @return mixed */ public function purchaseDetailSerial($param) { switch ($param['user_type']) { case 3: $SerialModel = new PurchaseGoodsSerialModel(); break; case 4: $SerialModel = new SPurchaseGoodsSerialModel(); break; } $where = [ 'outside_id' => is_array($param['id']) ? ['in', $param['id']] : $param['id'], 'type' => $param['type'], 'status' => 1 ]; if (!empty($param['serial_number'])) { $where['main_serial_number|auxiliary_serial_number_one|auxiliary_serial_number_two'] = ['like', '%' . $param['serial_number'] . '%']; } try { if (!empty($param['page']) && !empty($param['limit'])) { $list = $SerialModel->getSelect($where, $param['page'], $param['limit'], 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two,add_time'); if (!empty($list)) { $count = $SerialModel->getCount($where); foreach ($list as &$val) { $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); } } return callBack(statusCode()['success'], '查询成功', [ 'list' => $list ? $list : [], 'count' => $count ? $count : 0 ]); } else { $list = $SerialModel->getSelect($where, '', '', 'id,main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two,num'); return callBack(statusCode()['success'], '查询成功', $list); } } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', []); } } /** * 单个商品验证串码信息 * @param $param * [ * user_type 3商户 4门店 * exist_id_arr 存在id * merchant_id * store_id * goods_id * sku_id * serial_list 串码信息 * ] * @return mixed */ public function singleGoodsVerify($param) { $serial_list = json_decode(htmlspecialchars_decode($param['serial_list']), true); if (empty($param['goods_id']) || empty($serial_list)) { return callBack(statusCode()['error'], '请输入串码信息'); } $where = [ 'merchant_id', 'goods_id' => $param['goods_id'], 'type' => 1, 'num' => ['gt', 0], 'status' => 1 ]; if (!empty($param['sku_id'])) { $where['sku_id'] = $param['sku_id']; } if (!empty($param['store_id'])) { $where['store_id'] = $param['store_id']; } if (!empty($param['exist_id_arr'])) { $where['outside_id'] = ['not in', $param['exist_id_arr']]; } switch ($param['user_type']) { case 3: $SerialModel = new PurchaseGoodsSerialModel(); $WarehouseSerialModel = new WarehouseGoodsSerialModel(); break; case 4: $SerialModel = new SPurchaseGoodsSerialModel(); $WarehouseSerialModel = new SWarehouseGoodsSerialModel(); break; } $list = $SerialModel->getSelect($where, '', '', 'main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); unset($where['type']); unset($where['status']); unset($where['outside_id']); $warehouseList = $WarehouseSerialModel->getSelect($where, '', '', 'main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); $data = []; if (!empty($list)) { foreach ($list as $val) { if (!empty($val['main_serial_number'])) { $data[] = $val['main_serial_number']; } if (!empty($val['auxiliary_serial_number_one'])) { $data[] = $val['auxiliary_serial_number_one']; } if (!empty($val['auxiliary_serial_number_two'])) { $data[] = $val['auxiliary_serial_number_two']; } } } if (!empty($warehouseList)) { foreach ($warehouseList as $val) { if (!empty($val['main_serial_number'])) { $data[] = $val['main_serial_number']; } if (!empty($val['auxiliary_serial_number_one'])) { $data[] = $val['auxiliary_serial_number_one']; } if (!empty($val['auxiliary_serial_number_two'])) { $data[] = $val['auxiliary_serial_number_two']; } } } $result = $this->serialVerify([ 'serial_list' => $serial_list, 'data' => $data, 'type' => 1, 'user_type' => $param['user_type'] ]); unset($result['data']); return $result; } /** * 验证串号列表信息 * @param $param * [ * user_type 3商户 4门店 * serial_list 串码信息 * data 已经存在的串码集合 非必传 * type 1采购编辑 * ] * @return mixed */ public function serialVerify($param) { $serial_list = $param['serial_list']; if (!empty($param['data'])) { $data = $param['data']; } else { $data = []; } if (!empty($param['type']) && !empty($param['user_type'])) { switch ($param['user_type']) { case 3: if ($param['type'] == 1) { $SerialModel = new PurchaseGoodsSerialModel(); } break; case 4: if ($param['type'] == 1) { $SerialModel = new SPurchaseGoodsSerialModel(); } break; } } foreach ($serial_list as $key => $value) { if (empty($value['main_serial_number']) || mb_strlen($value['main_serial_number'], 'UTF8') > 20) { return callBack(statusCode()['error'], $value['main_serial_number'] . '主串码有误,最长20位'); } if (!empty($value['id']) && !empty($param['type'])) { $serial_info = $SerialModel->getFieldInfo([ 'id' => $value['id'] ], 'main_serial_number,auxiliary_serial_number_one,auxiliary_serial_number_two'); if (!in_array($value['main_serial_number'], $serial_info, true) && in_array($value['main_serial_number'], $data, true)) { return callBack(statusCode()['error'], $value['main_serial_number'] . '主串码存在重复'); } } else if (in_array($value['main_serial_number'], $data, true)) { return callBack(statusCode()['error'], $value['main_serial_number'] . '主串码存在重复'); } $data[] = $value['main_serial_number']; if (!empty($value['auxiliary_serial_number_one'])) { if (mb_strlen($value['auxiliary_serial_number_one'], 'UTF8') > 20) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_one'] . '辅助串码1最长20位'); } if (!empty($value['id']) && !empty($param['type'])) { if (!in_array($value['auxiliary_serial_number_one'], $serial_info, true) && in_array($value['auxiliary_serial_number_one'], $data, true)) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_one'] . '辅助串码1存在重复'); } } else if (in_array($value['auxiliary_serial_number_one'], $data, true)) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_one'] . '辅助串码1存在重复'); } $data[] = $value['auxiliary_serial_number_one']; } if (!empty($value['auxiliary_serial_number_two'])) { if (mb_strlen($value['auxiliary_serial_number_two'], 'UTF8') > 20) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_two'] . '辅助串码2最长20位'); } if (!empty($value['id']) && !empty($param['type'])) { if (!in_array($value['auxiliary_serial_number_two'], $serial_info, true) && in_array($value['auxiliary_serial_number_two'], $data, true)) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_two'] . '辅助串码2存在重复'); } } else if (in_array($value['auxiliary_serial_number_two'], $data, true)) { return callBack(statusCode()['error'], $value['auxiliary_serial_number_two'] . '辅助串码2存在重复'); } $data[] = $value['auxiliary_serial_number_two']; } } return callBack(statusCode()['success'], '验证成功', $data); } }