getFindField([ 'purchase_order_number' => $param['order_number'], 'goods_id' => $param['goods_id'], 'sku_id' => $param['sku_id'], ], 'id', true); if (!empty($id_arr)) { $SerialClass = new SerialNumberGoods(); $result = $SerialClass->purchaseDetailSerial([ 'user_type' => $param['user_type'], 'id' => $id_arr, 'type' => 2, 'serial_number' => $param['serial_number'], 'page' => $param['page'], 'limit' => $param['limit'] ]); return callBack(statusCode()['success'], '查询成功', [ 'list' => $result['data']['list'], 'count' => $result['data']['count'] ]); } else { return callBack(statusCode()['success'], '查询成功', [ 'list' => [], 'count' => 0 ]); } } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', [ 'list' => [], 'count' => 0 ]); } } /** * 退货详情列表 * @param $param * [ * user_type 3商户 4门店 * id 退货单id * showPrice 1可以查看进价 2不可以 * identity 1商户查看 2门店查看 * ] * @return mixed */ public function detailsList($param) { try { switch ($param['user_type']) { case 3: $RetreatGoodsModel = new RetreatGoodsModel(); break; case 4: $RetreatGoodsModel = new SRetreatGoodsModel(); break; } $list = $RetreatGoodsModel->getSelect([ 'retreat_order_id' => $param['id'] ], '', '', '*', 'id asc'); if (!empty($list)) { foreach ($list as $key => &$val) { $val['index'] = $key + 1; if (!empty($val['build_date'])) { $val['build_date'] = date('Y-m-d', $val['build_date']); } $val['retreat_num'] = round($val['retreat_num'], 3); $val['retreat_price'] = round($val['retreat_price'], 2); $val['subtotal'] = round($val['subtotal'], 2); $val['sku_num'] = round($val['sku_num'], 3); if ($val['attribute_state'] == 2) { $val['goods_number'] = $val['sku_goods_number']; $val['goods_code'] = $val['sku_code']; } if ($param['user_type'] == 3 || ($param['showPrice'] != 2 || $param['identity'] == 1)) { $val['purchase_price'] = round($val['purchase_price'], 2); $val['difference_money'] = round(($val['retreat_price'] - $val['purchase_price']) * $val['retreat_num'], 2); } else { $val['difference_money'] = "***"; $val['purchase_price'] = "***"; } } } return callBack(statusCode()['success'], '查询成功', $list); } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', []); } } /** * 退货订单列表 * @param $param * [ * operator_type 1后台端 2收银端 3助手端 * user_type 3商户 4门店 * merchant_id * store_id * add_time 后台时间搜搜 * start_time 助手端开始时间 * end_time 助手端结束时间 * warehouse_id 仓库id * supplier_id 供货商id * order_number 订单号 * page * limit * ] * @return mixed */ public function orderList($param) { $where = $this->orderListTerm($param); //查询条件 switch ($param['user_type']) { case 3: $RetreatOrderModel = new PurchaseRetreatOrderModel(); $SupperModel = new RetailSupplierModel(); $PurchaseWarehouseModel = new PurchaseWarehouseModel(); break; case 4: $RetreatOrderModel = new SPurchaseRetreatOrderModel(); $SupperModel = new SSupplierModel(); $PurchaseWarehouseModel = new SPurchaseWarehouseModel(); break; } try { $list = $RetreatOrderModel->getSelect($where, $param['page'], $param['limit'], "*", "id desc"); if (!empty($list)) { if ($param['operator_type'] == 1) { $count = $RetreatOrderModel->getCount($where); } $InventoryClass = new InventoryController(); foreach ($list as $key => &$val) { $val['index'] = $key + 1; $val['operator'] = $InventoryClass->OperatorName($val['operator_id']); $val['add_time'] = date('Y-m-d H:i:s', $val['add_time']); $val['supplier'] = $SupperModel->getFindField(['id' => $val['supplier_id']], 'supplier_name'); $val['warehouse'] = $PurchaseWarehouseModel->getFindField(['id' => $val['warehouse_id']], "name"); $val['goods_species'] = $val['goods_species'] . "种"; $val['total_cost_price'] = round($val['total_cost_price'], 2); $val['money_total'] = round($val['money_total'], 2); $val['difference_money'] = round($val['money_total'] - $val['total_cost_price'], 2); } } 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 * add_time * warehouse_id * supplier_id * order_number * ] * @return mixed */ public function orderTotal($param) { $where = $this->orderListTerm($param); //查询条件 try { switch ($param['user_type']) { case 3: $RetreatOrderModel = new PurchaseRetreatOrderModel(); break; case 4: $RetreatOrderModel = new SPurchaseRetreatOrderModel(); break; } $orderCount = $RetreatOrderModel->getCount($where); $goodsCount = $RetreatOrderModel->getSum($where, "goods_species"); $totalMoney = $RetreatOrderModel->getSum($where, "money_total"); $total_cost_price = $RetreatOrderModel->getSum($where, "total_cost_price"); $goodsCount = $goodsCount ? $goodsCount : 0; $totalMoney = $totalMoney ? $totalMoney : 0; $total_cost_price = $total_cost_price ? $total_cost_price : 0; $TotalList = [ 'orderCount' => $orderCount ? $orderCount : 0, 'goodsCount' => $goodsCount, 'totalMoney' => round($totalMoney, 2), 'total_cost_price' => round($total_cost_price, 2), 'difference_money' => round($totalMoney - $total_cost_price, 2), ]; return callBack(statusCode()['success'], '查询成功', [$TotalList]); } catch (\Exception $e) { return callBack(statusCode()['success'], '查询成功', [[]]); } } /** * 退货订单列表的查询条件 * @param $param * [ * operator_type 1后台端 2收银端 3助手端 * user_type 3商户 4门店 * merchant_id * store_id * add_time 后台时间搜索 * start_time 助手端开始时间 * end_time 助手端结束时间 * warehouse_id * supplier_id * order_number * page * limit * ] * @return mixed */ public function orderListTerm($param) { if (!empty($param['order_number'])) { $where['order_number'] = array('like', $param['order_number'] . '%'); } if (!empty($param['supplier_id'])) { $where['supplier_id'] = $param['supplier_id']; } if (!empty($param['warehouse_id'])) { $where['warehouse_id'] = $param['warehouse_id']; } switch ($param['operator_type']) { case 1: if (!empty($param['add_time'])) { $start_time = strtotime($param['add_time'][0]); $end_time = strtotime($param['add_time'][1]); $where['add_time'] = array('between', array($start_time, $end_time)); } break; case 3: $start_time = $param['start_time']; $end_time = $param['end_time']; if (!empty($start_time) && !empty($end_time)) { $start_time = strtotime($start_time . "00:00:00"); $end_time = strtotime($end_time . "23:59:59"); $where['add_time'] = array('between', array($start_time, $end_time)); } else if (!empty($start_time)) { $start_time = strtotime($start_time . "00:00:00"); $where['add_time'] = array('gt', $start_time); } else if (!empty($end_time)) { $end_time = strtotime($end_time . "23:59:59"); $where['add_time'] = array('lt', $end_time); } break; } if ($param['user_type'] == 4) { $where['store_id'] = $param['store_id']; } $where['merchant_id'] = $param['merchant_id']; $where['status'] = 1; return $where; } }