temp save here

<?php session_start();$session=session_id();?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>

<?php include("image/conn.php");
//计算batch号
$q5=$m->query("select max(batch) as batch from pick");
$r5=($q5->fetch_array(MYSQLI_USE_RESULT));
$batch=$r5['batch']+1;
//end 计算batch号

$q=$m->query("select I.name,I.number,I.style,I.color,I.size,sum(C.qty) as qty,C.input from cart C left join caseinfo I on C.number=I.number where C.status='0' and C.session='".$session."' group by I.style,I.size");//购物车需要的数量
while($r=$q->fetch_array(MYSQLI_USE_RESULT)){
	$qtyTemp=$r['qty'];
	$q2=$m->query("select I.number,I.pcs from inventory I left join caseinfo C on I.number=C.number where C.name=(select name from caseinfo where number='".$r[number]."') and C.style=(select style from caseinfo where number='".$r[number]."') and C.color=(select color from caseinfo where number='".$r[number]."') and C.size=(select size from caseInfo where number='".$r[number]."') and I.status='0' order by I.id");//库存里的数量
	while($r2=$q2->fetch_array(MYSQLI_USE_RESULT)){
		if($qtyTemp>=$r2['pcs']){
			$qtyTemp-=(int)$r2['pcs'];
			$m->query("insert into pick (batch,number,input) values ('".$batch."','".$r2['number']."','".$input."')");
			$m->query("update inventory set status='1' where number='".$r2['number']."'");
			$m->query("update caseinfo set status='2' where number='".$r2['number']."'");
			echo 'case pcs:'.$qtyTemp.'<br>';
			}
		else{
			$k=abs($qtyTemp);
			$qtyTemp-=(int)$r2['pcs'];
			$m->query("insert into pick (batch,number,pcs,input) values ('".$batch."','".$r2['number']."','".$k."','".$input."')");//放在拣货单

			$m->query("update inventory set status='1',batch='".$batch."',pick='".$k."' where number='".$r2['number']."'");//把原始的更新
			$m->query("update caseinfo set status='2' where number='".$r2['number']."'");
			//计算出剩下的数量与原库位
			$q7=$m->query("select weight,vol,pcs,location from inventory where number='".$r2['number']."' and id=(select min(id) from inventory where number='".$r2['number']."')");
			$r7=$q7->fetch_array(MYSQLI_USE_RESULT);
			$left=$r7[pcs]-$k;//把剩下的数量,变成新的箱子
			//end 数量与原为库位
			$m->query("insert into inventory (number,weight,vol,pcs,batch,location,op,input) values ('".$r2['number']."','".$r7[weight]."','".$r7[vol]."','".$left."','".$batch."','".$r7[location]."','".$_SESSION['auth']."','".$input."')");
			echo "insert into inventory (number,weight,vol,pcs,batch,location,op,input) values ('".$r2['number']."','".$r7[weight]."','".$r7[vol]."','".$left."','".$batch."','".$r7[location]."','".$_SESSION['auth']."','".$input."')<br>";
			echo 'rep-pick:'.$qtyTemp.'<br>';
			}
		if($qtyTemp<=0){
			$m->query("update cart set status='1' where session='".$session."'");
			break;}
		
		}
	}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值