$quantity) throw new ApiException('实收桶数不能超过配送桶数'); if ($empty>(int)$account['empty_qty']) throw new ApiException('回收空桶超过企业账面空桶,请先核对现场库存'); if ((int)$sku['transit']<$quantity || (int)$account['frozen']<$quantity || (int)$account['entitlement']<$quantity) throw new ApiException('在途库存或冻结权益异常,请先核账'); return [ 'sku'=>['transit'=>(int)$sku['transit']-$accepted], 'account'=>['entitlement'=>(int)$account['entitlement']-$accepted,'frozen'=>(int)$account['frozen']-$accepted, 'full_qty'=>(int)$account['full_qty']+$accepted,'empty_qty'=>(int)$account['empty_qty']-$empty], ]; } public static function returned(array $task,array $sku,array $account,int $good,int $damaged): array { $remaining=(int)$task['quantity']-(int)$task['delivered_qty']; if ($good+$damaged!==$remaining) throw new ApiException('可用退回与破损隔离桶数合计必须等于待退回桶数'); if ((int)$sku['transit']<$remaining || (int)$account['frozen']<$remaining) throw new ApiException('在途库存或冻结权益异常,请先核账'); return [ 'sku'=>['transit'=>(int)$sku['transit']-$remaining,'available'=>(int)$sku['available']+$good,'damaged_qty'=>(int)$sku['damaged_qty']+$damaged], 'account'=>['frozen'=>(int)$account['frozen']-$remaining], ]; } }