getMerchantStockOrderList($content); $res['status'] = 1; $res['data'] = $result['data']['list']; $res['msg'] = $result['message']; $this->ajaxReturn($res); } /* * 调拨单列表 */ public function AllocateOrderList() { $data = I("post."); $merchant_id = $data['merchantid']; $store_id = $data['storeid']; $add_time = $data['add_time']; $status = $data['status']; $order_number = $data['order_number']; $page = $data['page']; $limit = $data['limit']; if (!empty($add_time)) { $start_time = strtotime($add_time[0]); $end_time = strtotime($add_time[1]); $where['add_time'] = array('between', array($start_time, $end_time)); } if (!empty($order_number)) { $where['order_number'] = $order_number; } if (!empty($status)) { $where['status'] = $status; } $where['store_id'] = $store_id; $where['merchant_id'] = $merchant_id; $list = D('AllocationOrder')->getSelect($where, $page, $limit); if ($list) { $count = D('AllocationOrder')->getCount($where); foreach ($list as $key => &$val) { $val['index'] = $key + 1; $val['operator'] = A('Api/Inventory')->OperatorName($val['s_operator_id']); $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); if (!empty($val['stock_time'])) { $val['stock_time'] = date('Y-m-d H:i:s', $val['stock_time']); } if (!empty($val['storage_time'])) { $val['storage_time'] = date('Y-m-d H:i:s', $val['storage_time']); } else if (!empty($val['refuse_time'])) { $val['storage_time'] = date('Y-m-d H:i:s', $val['refuse_time']); } switch ($val['status']) { case 1: $val['warehousing_name'] = "申请中"; break; case 2: if ($val['refuse_status'] == 2) { $val['warehousing_name'] = "已拒收"; } else { $val['warehousing_name'] = "已出库"; } break; case 3: $val['warehousing_name'] = "已入库"; break; } } } else { $count = 0; } $res['status'] = 1; $res['count'] = $count; $res['data'] = $list; $this->ajaxReturn($res); } /** * 商户确认出库操作 * type 出库类型 0其他出库 1调拨出库 2盘亏出库 3门店申请调拨出库 4退货出库 * store_id 目标门店 */ public function AllocateConfirm() { $data = I('post.'); $data['merchant_id'] = $data['merchantid']; $result = A("Api/Inventory")->MerStockOut($data); if ($result['status'] == 1) { $log_data = [ 'source' => 1, 'type' => 3, 'desc' => '出库单-新增', 'request_data' => json_encode($_POST), 'operator_id' => $_POST['operator_id'], 'mer_id' => $_POST['merchantid'] ]; action_log_v2($log_data); } $this->ajaxReturn($result); } public function AllocateApply() { $reg2 = "/^[0-9]+(.[0-9]{1,3})?$/"; $reg3 = "/^\+?[1-9][0-9]*$/"; $data = I("post."); $merchant_id = $data['merchantid']; $store_id = $data['storeid']; $time = $_SERVER['REQUEST_TIME']; $goodsList = $data['goodsList']; $goodsList = json_decode(htmlspecialchars_decode($goodsList), true); if (!$merchant_id || !$store_id || !$goodsList) { $res['status'] = 0; $res['msg'] = '缺少参数'; $this->ajaxReturn($res); } $remarks = $data['remarks']; if (count($goodsList) > 500) { $res['status'] = 0; $res['msg'] = '单次操作上限为500种'; $this->ajaxReturn($res); } foreach ($goodsList as $key => &$val) { if (!$val['output_num']) { $res['status'] = 0; $res['msg'] = $val['goods_name'] . $val['sku_name'] . "请输入正确数量"; $this->ajaxReturn($res); } if ($val['attribute_state'] == 1 && $val['pricing_method'] == 2) { if (!preg_match($reg2, $val['output_num'])) { $res['status'] = 0; $res['msg'] = $val['goods_name'] . $val['sku_name'] . "请输入正确数量"; $this->ajaxReturn($res); } } else { if (!preg_match($reg3, $val['output_num'])) { $res['status'] = 0; $res['msg'] = $val['goods_name'] . $val['sku_name'] . "请输入正确数量"; $this->ajaxReturn($res); } } } $order = array(); $order['store_id'] = $store_id; $order['merchant_id'] = $merchant_id; $order['add_time'] = $time; $order['status'] = 1; $order['remarks'] = $remarks; $OperatorInfo = A('Api/Inventory')->Operator($data['operator_id']); if ($OperatorInfo) { $order['s_operator_id'] = $OperatorInfo['id']; } $res = D('AllocationOrder')->addData($order); if ($res['status'] == 0) { $res['msg'] = "订单创建失败"; $this->ajaxReturn($res); } $orderId = $res['data']; $orderNumber = 'SS' . orderNumber($orderId); foreach ($goodsList as $key => &$val) { $content = []; $content['store_id'] = $store_id; $content['merchant_id'] = $merchant_id; $content['allocation_id'] = $orderId; $content['order_number'] = $orderNumber; $content['add_time'] = $time; $content['goods_id'] = $val['goods_id']; $content['goods_name'] = $val['goods_name']; $content['goods_class_id'] = $val['goods_class_id']; $content['goods_number'] = $val['goods_number']; $content['goods_code'] = $val['goods_code']; $content['company'] = $val['company']; $content['attribute_state'] = $val['attribute_state']; $content['pricing_method'] = $val['pricing_method']; $content['apply_num'] = $val['output_num']; $content['remarks'] = $val['remarks']; $content['serial_number_state'] = $val['serial_number_state'] ? $val['serial_number_state'] : 0; if ($val['attribute_state'] == 2) { $content['sku_id'] = $val['sku_id']; $content['sku_name'] = $val['sku_name']; $content['sku_id_list'] = $val['sku_id_list']; $content['sku_goods_number'] = $val['sku_goods_number']; $content['sku_code'] = $val['sku_code']; $content['sku_num'] = $val['sku_num']; } $res = D('AllocationGoods')->addData($content); if ($res['status'] == 0) { $res['msg'] = '商品存入失败'; $this->ajaxReturn($res); } } $text = array(); $text['store_goods_species'] = count($goodsList); $text['order_number'] = $orderNumber; $res = D('AllocationOrder')->updateData(array('id' => $orderId), $text); if ($res['status'] == 0) { $res['msg'] = '订单修改失败'; $this->ajaxReturn($res); } $log_data = [ 'source' => 1, 'type' => 4, 'desc' => '调拨单-新增', 'request_data' => json_encode($data), 'operator_id' => $data['operator_id'], 'mer_id' => $data['merchantid'] ]; action_log_v2($log_data); $this->ajaxReturn($res); } }