|
|
@@ -143,55 +143,13 @@ class TestController extends Controller
|
|
|
}
|
|
|
public function test()
|
|
|
{
|
|
|
- $asn = "ASN2107011344";
|
|
|
- $barCode = "XUNI03";
|
|
|
- $item = app("StoreItemService")->getMaxAvailableDetail($asn,$barCode);
|
|
|
- if (!$item)$this->error("无此单据记录");
|
|
|
- $blacklist = [];
|
|
|
- $model = CommodityMaterialBoxModel::query()->where("commodity_id",505012)->first();
|
|
|
- $query = \App\Storage::query()->with("materialBox")->whereHas("materialBox",function (Builder $query)use($model){
|
|
|
- $query->where("material_box_model_id",$model->material_box_model_id);
|
|
|
- })->where("commodity_id",$model->commodity_id)->where("amount","<",$model->maximum)
|
|
|
- ->where("status",0)->where(DB::raw("{$model->maximum}-amount"),">",0);
|
|
|
- if ($blacklist)$query->whereHas("materialBox",function (Builder $query)use($blacklist){
|
|
|
- $query->whereNotIn("id",$blacklist);
|
|
|
- });
|
|
|
- $query->get()->each(function ($storage)use(&$boxCodes,&$map){
|
|
|
- $boxCodes .= "'".$storage->materialBox->code."',";
|
|
|
- $map[$storage->materialBox->code] = $storage;
|
|
|
- });
|
|
|
- //不存在跳出
|
|
|
- if (!$boxCodes)return null;
|
|
|
- $boxCodes = mb_substr($boxCodes,0,-1);
|
|
|
- //查询对应asn detail
|
|
|
- $detail = DB::connection("oracle")->selectOne(DB::raw("SELECT * FROM DOC_ASN_DETAILS WHERE ASNNO = ? AND ASNLINENO = ?"),[
|
|
|
- $asn,$item->asn_line_code
|
|
|
- ]);
|
|
|
- if(!$detail)return null;
|
|
|
- $detail = get_object_vars($detail);
|
|
|
- //查询对应批次属性
|
|
|
- $lot = DB::connection("oracle")->selectOne(DB::raw("SELECT * FROM BAS_LOTID WHERE LOTID = (SELECT LOTID FROM BAS_SKU WHERE CUSTOMERID = ? AND SKU = ?)"),[
|
|
|
- $detail["customerid"],$detail["sku"]
|
|
|
- ]);
|
|
|
- if(!$lot)return null;
|
|
|
- //通过符合条件的批次号来查询 库存
|
|
|
- $lot = get_object_vars($lot);
|
|
|
- $sql = <<<sql
|
|
|
-SELECT * FROM INV_LOT_LOC_ID WHERE LOTNUM IN
|
|
|
- (SELECT LOTNUM FROM INV_LOT_ATT WHERE INV_LOT_ATT.CUSTOMERID = ? AND SKU = ?
|
|
|
-sql;
|
|
|
- //拼接可以合并的批次属性要求
|
|
|
- for ($i=1;$i<=8;$i++){
|
|
|
- if ($lot["lotkey0{$i}"]=='Y'){
|
|
|
- $val = $detail["lotatt0{$i}"] ? "'{$detail["lotatt0{$i}"]}'" : null;
|
|
|
- $sql .= " AND LOTATT0{$i} = $val";
|
|
|
- }
|
|
|
+ ini_set('max_execution_time', 0);
|
|
|
+ foreach (Order::query()->whereBetween("wms_edittime",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
|
|
|
+ ->whereNotIn("id",OwnerFeeDetail::query()->select("outer_id")
|
|
|
+ ->whereBetween("worked_at",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
|
|
|
+ ->where("outer_table_name","orders"))->get() as $order){
|
|
|
+ dispatch(new OrderCreateInstantBill($order));
|
|
|
}
|
|
|
- $sql .= ") AND LOCATIONID IN ({$boxCodes}) AND TRACEID = '*' AND {$model->maximum}-QTY > 0 ORDER BY {$model->maximum}-QTY";
|
|
|
- $res = DB::connection("oracle")->selectOne(DB::raw($sql),[
|
|
|
- $detail["customerid"],$detail["sku"]
|
|
|
- ]);
|
|
|
- return $res ? $map[$res->locationid] : null;
|
|
|
}
|
|
|
public function orderCreateBill()
|
|
|
{
|